function script_setup(e,t){var d={startvars:t};return e.length<6?(console.error("Invalid script length"),null):612182341!=ReadInt(e,0)?(console.error("Invalid binary script"),null):1="==p[2]&&p[1]>=p[3]||">"==p[2]&&p[1]>p[3])&&(d.ip=p[0]);break;case 2:null==a[1]?delete d.variables[a[0]]:d.setVar(a[0],p[1]);break;case 3:d.onConsole?d.onConsole(d.toString(p[0]),d):console.log(d.toString(p[0]));break;case 4:d.state=2,d.dialog=!0,setDialogMode(11,p[0],p[2],d.xxStepDialogOk,p[1],d);break;case 5:for(var s in p[1])p[1][s][p[2]]==p[3]&&(u=s);break;case 6:u=p[1].substr(p[2],p[3]);break;case 7:u=p[1].indexOf(p[2]);break;case 8:u=p[1].split(p[2]);break;case 9:u=p[1].join(p[2]);break;case 10:u=p[1].length;break;case 11:u=JSON.parse(p[1]);break;case 12:u=JSON.stringify(p[1]);break;case 13:u=p[1]+p[2];break;case 14:u=p[1]-p[2];break;case 15:u=parseInt(p[1]);break;case 16:d.state=2,d.amtstack.BatchEnum(p[0],p[1],d.xxWsmanReturn,d);break;case 17:d.state=2,d.amtstack.Put(p[0],p[1],d.xxWsmanReturn,d);break;case 18:d.state=2,d.amtstack.Create(p[0],p[1],d.xxWsmanReturn,d);break;case 19:d.state=2,d.amtstack.Delete(p[0],p[1],d.xxWsmanReturn,d);break;case 20:d.state=2,d.amtstack.Exec(p[0],p[1],p[2],d.xxWsmanReturn,d,0,p[3]);break;case 21:d.stepspeed=p[0],null!=d.timer&&(clearInterval(d.timer),d.timer=setInterval(function(){d.step()},d.stepspeed));break;case 22:d.state=2,d.amtstack.Subscribe(p[0],p[1],p[2],d.xxWsmanReturn,d,0,p[3],p[4],p[5],p[6]);break;case 23:d.state=2,d.amtstack.UnSubscribe(p[0],d.xxWsmanReturn,d,0,p[1]);break;case 24:console.log(p[1],p[2],p[1].charCodeAt(p[2])),u=p[1].charCodeAt(p[2]);break;case 25:d.state=2,amtcert_signWithCaKey(p[0],null,p[1],{CN:"Untrusted Root Certificate"},d.xxSignWithDummyCaReturn);break;default:d.state=9,console.error("Script Error, unknown command: "+e)}else e<2e4?u=script_functionTableX2[e-1e4](p[1],p[2],p[3],p[4],p[5],p[6]):script_functionTableX3&&script_functionTableX3[e-2e4]&&(u=script_functionTableX3[e-2e4](d,p[1],p[2],p[3],p[4],p[5],p[6]));null!=u&&d.setVar(a[0],u)}catch(e){"object"==typeof e&&(e=e.message),d.setVar("_exception",e)}}return 1==d.state&&d.ip>=d.script.length&&(d.state=0,d.stop()),d.onStep&&d.onStep(d),d}},d.xxStepDialogOk=function(e){d.variables.DialogSelect=e,d.state=1,d.dialog=!1,d.onStep&&d.onStep(d)},d.xxWsmanReturnFix=function(e){e&&null!=e&&(e.Header&&(e.Header=e.Header,delete e.Header),e.Body&&(e.Body=e.Body,delete e.Body),e.Responses&&(e.Responses=e.Responses,delete e.Responses),e.Response&&(e.Response=e.Response,delete e.Response),e.ReturnValueStr&&(e.ReturnValueStr=e.ReturnValueStr,delete e.ReturnValueStr))},d.xxWsmanReturn=function(e,t,r,n){if(r)for(var a in d.xxWsmanReturnFix(r),r)for(var s in d.xxWsmanReturnFix(r[a]),r[a])d.xxWsmanReturnFix(r[a][s]);d.setVar(t,r),d.setVar("wsman_result",n),d.setVar("wsman_result_str",httpErrorTable[n]||"Error #"+n),d.state=1,d.onStep&&d.onStep(d)},d.xxSignWithDummyCaReturn=function(e){d.setVar("signed_cert",btoa(_arrayBufferToString(e))),d.state=1,d.onStep&&d.onStep(d)},d.toString=function(e){return"object"==typeof e?JSON.stringify(e):e},d.reset(),d)}function script_compile(e,t){var r,n="",a=e.split("\n"),s={},o=[],i=[];for(r in a){var l=a[r];if(l.startsWith("##SWAP ")&&3==(c=l.split(" ")).length&&(i[c[1]]=c[2]),"#"!=l[0]&&0!=l.length){for(var c in i)l=l.split(c).join(i[c]);var u=l.match(/"[^"]*"|[^\s"]+/g);if(0!=u.length)if(":"==l[0])s[u[0].toUpperCase()]=n.length;else{var p=script_functionTable1.indexOf(u[0].toLowerCase());if(-1==p&&0<=(p=script_functionTable2.indexOf(u[0].toLowerCase()))&&(p+=1e4),-1==p&&0<=(p=script_functionTable3.indexOf(u[0].toLowerCase()))&&(p+=2e4),-1==p)return t&&t("Unabled to compile, unknown command: "+u[0]),"";var d,h,b=ShortToStr(u.length-1);for(d in u)0!=d&&(":"==u[d][0]?(o.push([u[d],n.length+b.length+7]),b+=ShortToStr(5)+String.fromCharCode(3)+IntToStr(4294967295)):(h=parseInt(u[d]))==u[d]?b+=ShortToStr(5)+String.fromCharCode(2)+IntToStr(h):'"'==u[d][0]&&'"'==u[d][u[d].length-1]?b+=ShortToStr(u[d].length-1)+String.fromCharCode(1)+u[d].substring(1,u[d].length-1):b+=ShortToStr(u[d].length+1)+String.fromCharCode(0)+u[d]);n+=b=ShortToStr(p)+ShortToStr(b.length+4)+b}}}for(r in o){var f=o[r][0].toUpperCase(),g=o[r][1],S=s[f];if(null==S)return t&&t("Unabled to compile, unknown label: "+f),"";n=n.substr(0,g)+IntToStr(S)+n.substr(g+4)}return IntToStr(612182341)+ShortToStr(1)+n}function script_decompile(e,t){var r="",n=6,a={};if(0<=t)n=t;else{if(e.length<6)return"# Invalid script length";var s=ReadInt(e,0),o=ReadShort(e,4);if(612182341!=s)return"# Invalid binary script: "+s;if(1!=o)return"# Invalid script version"}for(;n