functionAmtManager(c,m,r){varE=function(K){c.SendCommand({action:"msg",type:"console",value:K})};varn=function(K){if(r){E("amt-manager: "+K)}};varg=null,h=0;vare=null,f=0;vard=null;varB=null;varA=null;varj=null;varz=this;z.state=0;z.lmsstate=0;z.onStateChange=null;z.setDebug=function(K){r=K};z.setPolicy=function(K){if(JSON.stringify(j)!=JSON.stringify(K)){j=K;z.applyPolicy()}};varD=0;z.reset=function(){++D;g=null,h=0,e=null,f=0,z.state=0,z.lmsstate=0;try{varK=require("amt-mei");g=newK();g.on("error",function(M){n("MEI error");g=null;h=-1;z.state=-1;z.onStateChange(h)});g.getVersion(function(M){if(M==null){h=-1;z.state=-1;if(z.onStateChange!=null){z.onStateChange(h)}if(D<10){setTimeout(z.reset,10000)}}else{d=M;h=2;z.state=2;D=0;if(z.onStateChange!=null){z.onStateChange(h)}z.lmsreset()}})}catch(L){n("MEI exception: "+L);g=null;h=-1;z.state=-1}};vari=null;z.getAmtInfo=function(L){if((g==null)||(h<2)){if(L!=null){L(null)}return}try{i={Flags:0};g.getProtocolVersion(function(M){if(M!=null){i.MeiVersion=M}});g.getVersion(function(M){if(M){i.Versions={};for(varNinM.Versions){i.Versions[M.Versions[N].Description]=M.Versions[N].Version}}});g.getProvisioningMode(function(M){if(M){i.ProvisioningMode=M.mode}});g.getProvisioningState(function(M){if(M){i.ProvisioningState=M.state}});g.getEHBCState(function(M){if((M!=null)&&(M.EHBC==true)){i.Flags+=1}});g.getControlMode(function(M){if(M!=null){if(M.controlMode==1){i.Flags+=2}if(M.controlMode==2){i.Flags+=4}}});g.getLanInterfaceSettings(0,function(M){if(M){i.net0=M}});g.getLanInterfaceSettings(1,function(M){if(M){i.net1=M}});g.getUuid(function(M){if((M!=null)&&(M.uuid!=null)){i.UUID=M.uuid}});g.getDnsSuffix(function(M){if(M!=null){i.dns=M}if(L!=null){L(i)}})}catch(K){if(L!=null){L(null)}return}};varp=function(N){if((N==null)||(N.Body==null)||(N.Body.MessageID==null)||(N.Body.MessageArguments==null)){returnnull}varK=N.Body.MessageID,L=N.Body.MessageArguments[0],M=null;switch(K){case"iAMT0050":if(L=="48"){M="Intel® AMT Serial-over-LAN connected"}else{if(L=="49"){M="Intel® AMT Serial-over-LAN disconnected"}}break;case"iAMT0052":if(L=="1"){M="Intel® AMT KVM connected"}else{if(L=="2"){M="Intel® AMT KVM disconnected"}}break;default:break}if(M!=null){c.SendCommand({action:"msg",type:"notify",value:M,tag:"general"})}};z.lmsreset=function(){varK=null,L=0;z.lmsstate=0;try{varN=require("amt-lme");L=1;z.lmsstate=1;K=newN();K.on("error",function(O){L=0;z.lmsstate=0;K=null;n("LMS error");F(1)});K.on("connect",function(){L=2;z.lmsstate=2;n("LMS connected");F(2)});K.on("notify",function(P,Q,R,O){if(O=="iAMT0052-3"){u()}else{p(P)}})}catch(M){L=-1;z.lmsstate=-1;K=null}};varF=function(K){if((g==null)||(h<2)||(d==null)){return}g.getLocalSystemAccount(function(R){if(R==null){return}varP=require("amt-wsman-duk");varQ=require("amt-wsman");varL=require("amt");B=newQ(P,"127.0.0.1",16992,R.user,R.pass,false);A=newL(B);h=3;z.state=3;if(z.onStateChange!=null){z.onStateChange(h)}z.applyPolicy();varM=null;try{for(varOind.Versions){if(d.Versions[O].Description=="AMT"){M=parseInt(d.Versions[O].Version.split(".")[0])}}}catch(N){}if((M!=null)&&(M>=12)){n("KVM data channel setup");u("skip");z.kvmTempTimer=setInterval(function(){u()},2000);w(JSON.stringify({action:"restart",ver:1}))}})};varu=function(K){A.IPS_KVMRedirectionSettingData_DataChannelRead(z.kvmDataGetResponse,K)};vart=function(N,L,M,O,P){if((P!="skip")&&(O==200)&&(M.Body.ReturnValue==0)){varQ=null;try{Q=Buffer.from(M.Body.DataMessage,"base64").toString()}catch(K){return}if(Q!=null){z.kvmProcessData(M.Body.RealmsBitmap,M.Body.MessageId,Q)}}};varH=null;varv=function(N,M,P){varK=null;try{K=JSON.parse(P)}catch(L){}if((K!=null)&&(K.action)){if(K.action=="present"){w(JSON.stringify({action:"present",ver:1,platform:process.platform}))}if(K.action=="offer"){H={};varO=require("ILibWebRTC");H.webrtc=O.createConnection();H.webrtc.on("connected",function(){});H.webrtc.on("disconnected",function(){z.webRtcCleanUp()});H.webrtc.on("dataChannel",function(Q){H.rtcchannel=Q;H.kvm=mesh.getRemoteDesktopStream();H.kvm.pipe(H.