@kaeawc/auto-mobile 0.0.41 → 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.js CHANGED
@@ -166,7 +166,7 @@ Suggestion: ${M.suggestion}`;z(new C(P))}}else if(!B)B=!0,J.endOperation("panicD
166
166
 
167
167
  Suggestion: ${w.suggestion}`;V=new C(F)}else if(_.isDisplayError){let F=`Emulator failed to start: ${_.message}`;if(_.suggestion)F+=`
168
168
 
169
- Suggestion: ${_.suggestion}`;V=new C(F)}else{let F=this.detectArchitecturePanic(q);if(F.isPanic)V=new C(`Emulator failed to start: ${F.message}`);else V=new C(`Emulator process exited with code ${B} while waiting for readiness`)}j.error(`Emulator process exited during readiness wait: ${V.message}`)}})}let U=!0,z=null;W.startOperation("devicePolling");let H=(async()=>{while(U&&!z){try{j.debug(`Background polling iteration - checking for emulator '${$}'...`),j.debug("Checking for running local emulators...");let L=await this.getBootedDevices();if(j.debug(`Device scan complete - found ${L.length} running emulators`),L.length>0){j.debug(`Found ${L.length} running emulators: ${L.map((q)=>`${q.name}(${q.deviceId})`).join(", ")}`);let O=Y??this.getLaunchTargetDeviceId(X),B=O?L.find((q)=>q.deviceId===O):void 0;if(O){if(j.debug(`Exact deviceId match for '${O}': ${B?`Found ${B.deviceId}`:"Not found"}`),B&&!this.matchesRequestedAvdOrUnknown(B,$,O))j.debug(`Exact deviceId match ${B.deviceId} resolved as '${B.name}', not requested AVD '${$}'`),B=void 0}if(!B&&!O)B=L.find((q)=>q.name===$),j.debug(`Exact name match for '${$}': ${B?`Found ${B.deviceId}`:"Not found"}`);if(B&&B.deviceId){j.debug(`Target emulator found: ${B.name} (${B.deviceId}) - starting readiness checks`),j.debug(`[PARALLEL] Running device state, package manager, and boot-complete checks for ${B.deviceId}...`);let q=this.adbFactory.create(B);try{W.startOperation("adbParallelChecks");let[w,_,F,A]=await Promise.allSettled([q.executeCommand("get-state"),q.executeCommand("shell pm list packages"),q.executeCommand("shell getprop sys.boot_completed"),q.executeCommand("shell getprop init.svc.bootanim")]);if(W.endOperation("adbParallelChecks"),w.status!=="fulfilled"||_.status!=="fulfilled"||F.status!=="fulfilled"||A.status!=="fulfilled")j.debug(`[PARALLEL] Checks not yet complete: deviceStatus: ${w.status}, packageManager: ${_.status}, sysBootCompleted: ${F.status}, bootAnimation: ${A.status}`);else{let M=w.value.stdout.trim(),P=F.value.stdout.trim(),k=A.value.stdout.trim();if(j.debug(`[PARALLEL] Package manager command completed for ${B.deviceId} - output: ${_.value.stdout.length} bytes`),!M.includes("device"))j.debug(`[PARALLEL] \u274C Device state check failed for ${B.deviceId}: state="${M}"`);else if(!_.value.stdout||!_.value.stdout.includes("package:"))j.debug(`[PARALLEL] \u274C Package manager returned no packages for ${B.deviceId} (${_.value.stdout.length} bytes output)`);else if(_.value.stderr||_.value.stderr.includes("Failure"))j.debug(`[PARALLEL] \u274C Package manager returned failure for ${B.deviceId}: ${_.value.stderr}`);else if(P!=="1")j.debug(`[PARALLEL] \u274C sys.boot_completed is not set for ${B.deviceId}: "${P}"`);else if(k&&k!=="stopped")j.debug(`[PARALLEL] \u274C boot animation is still active for ${B.deviceId}: "${k}"`);else{j.debug(`[PARALLEL] \u2705 Device state check passed for ${B.deviceId}`),j.debug(`[PARALLEL] \u2705 Package manager is responsive for ${B.deviceId} - emulator is ready!`),j.debug(`[PARALLEL] \u2705 Android boot-complete signals are ready for ${B.deviceId}`),j.debug("[PARALLEL] \u2705 No package manager errors detected - marking emulator as ready"),z=B.deviceId;return}}}catch(w){j.debug(`[PARALLEL] \u274C Parallel checks failed for ${B.deviceId}: ${w}`)}}else j.debug(`No suitable emulator found for '${$}' - will continue polling`)}else j.debug("No running emulators detected - will continue polling")}catch(L){j.debug(`Background polling error (will continue): ${L}`)}j.debug(`Background polling cycle complete - sleeping ${G}ms before next check`),await this.sleep(G)}j.debug(`Background polling stopped - pollingActive: ${U}, foundDeviceId: ${z}`)})();while(this.timer.now()-Q<J){if(K&&V)throw U=!1,await H,W.endOperation("devicePolling"),V;if(z){U=!1,W.endOperation("devicePolling"),j.info(`Emulator '${$}' is ready! Device ID: ${z}`);let L={name:$,platform:"android",deviceId:z};return W.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(L),W.endOperation("wakeAndUnlock"),L}await this.sleep(500)}if(U=!1,await H,W.endOperation("devicePolling"),z){j.info(`Emulator '${$}' is ready! Device ID: ${z}`);let L={name:$,platform:"android",deviceId:z};return W.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(L),W.endOperation("wakeAndUnlock"),L}throw new C(`Emulator '${$}' failed to become ready within ${J}ms`)}async wakeAndUnlock($){let J=this.adbFactory.create($);try{let X=await J.getWakefulness();if(j.info(`[WakeAndUnlock] Device wakefulness state: ${X}`),X!=="Awake")j.info("[WakeAndUnlock] Device not awake, sending KEYCODE_WAKEUP"),await J.executeCommand("shell input keyevent KEYCODE_WAKEUP"),await this.sleep(500);j.info("[WakeAndUnlock] Dismissing keyguard"),await J.executeCommand("shell wm dismiss-keyguard");let Y=await J.getWakefulness();j.info(`[WakeAndUnlock] Final wakefulness state: ${Y}`)}catch(X){j.warn(`[WakeAndUnlock] Failed to wake/unlock device: ${X}`)}}sleep($){return this.timer.sleep($)}}var HO4=async($)=>{let J=await UO4(GO4)($);return{stdout:J.stdout,stderr:J.stderr,toString(){return this.stdout},trim(){return this.stdout.trim()},includes(Y){return this.stdout.includes(Y)}}};var XH=D(()=>{m();i$();p$();eZ();J$();v$();$M$()});class f9{adb;emulator;simctl;constructor($=null,J=null,X=null){this.adb=$||r.create(null),this.simctl=J||new $4,this.emulator=X||new tX}async canDiscoverIosLocally(){if(process.platform==="darwin")return!0;try{return await this.simctl.isAvailable()}catch($){return j.debug(`src/utils/deviceUtils.ts fallback failed: ${$}`,$),!1}}async listIosDeviceImagesIfAvailable($){if(!await this.canDiscoverIosLocally())return[];try{return await this.simctl.listSimulatorImages()}catch(J){if(j.warn(`[DeviceManager] iOS simulator image discovery failed: ${J}`),!$.swallowDiscoveryErrors)throw J;return[]}}async getBootedIosDevicesIfAvailable(){if(!await this.canDiscoverIosLocally())return[];try{return await this.simctl.getBootedSimulators()}catch{return[]}}async listDeviceImages($){switch($){case"android":return this.emulator.listAvds();case"ios":return this.listIosDeviceImagesIfAvailable({swallowDiscoveryErrors:!1});case"either":let J=await this.emulator.listAvds(),X=await this.listIosDeviceImagesIfAvailable({swallowDiscoveryErrors:!0});return[...J,...X]}}async isDeviceImageRunning($){switch($.platform){case"android":return this.emulator.isAvdRunning($.name);case"ios":if(!await this.canDiscoverIosLocally())return!1;if($.deviceId)return(await this.simctl.getBootedSimulators()).some((X)=>X.deviceId===$.deviceId);return this.simctl.isSimulatorRunning($.name)}}async getBootedDevices($){switch($){case"android":return this.emulator.getBootedDevices();case"ios":return this.getBootedIosDevicesIfAvailable();case"either":let J=await this.emulator.getBootedDevices(),X=await this.getBootedIosDevicesIfAvailable();return[...J,...X]}}async getBootedDevicesDetailed($){let J=[],X=new Set;if($==="android"||$==="either")try{let Y=await this.emulator.getBootedDevicesChecked();J.push(...Y),X.add("android")}catch(Y){j.warn(`[DeviceManager] Android booted-device discovery failed; retaining tracked Android devices: ${Y}`)}if($==="ios"||$==="either"){let Y=await this.discoverBootedIosDevices();if(Y.succeeded)J.push(...Y.devices),X.add("ios")}return{devices:J,succeededPlatforms:X}}async discoverBootedIosDevices(){if(!await this.canDiscoverIosLocally())return{devices:[],succeeded:!1};try{return{devices:await this.simctl.getBootedSimulatorsChecked(),succeeded:!0}}catch($){return j.warn(`[DeviceManager] iOS booted-device discovery failed; retaining tracked iOS devices: ${$}`),{devices:[],succeeded:!1}}}async startDevice($,J=hK){if(await this.isDeviceImageRunning($))throw new C(`${$.platform} device '${$.name}' is already running`);switch($.platform){case"android":return this.emulator.startEmulator($.name);case"ios":return this.simctl.startSimulator($.deviceId??$.name,J);default:throw new C("Unknown platform")}}async killDevice($){switch($.platform){case"android":return this.emulator.killDevice($);case"ios":return this.simctl.killSimulator($)}}async waitForDeviceReady($,J=hK,X){switch($.platform){case"android":return this.emulator.waitForEmulatorReady($.name,J,X,$.deviceId);case"ios":return this.simctl.waitForSimulatorReady($.deviceId??$.name,J);default:throw new C("Unknown platform")}}}var jz=D(()=>{i$();p$();l1();XH();m()});import ma from"crypto";class BJ{generateCacheKey($){return ma.createHash("md5").update($).digest("hex")}verifyChecksum($,J){return ma.createHash("sha256").update($).digest("hex").toLowerCase()===J.toLowerCase()}static generateCacheKey=($)=>new BJ().generateCacheKey($);static verifyChecksum=($,J)=>new BJ().verifyChecksum($,J)}var gK=()=>{};import*as uK from"fs/promises";import*as YM$ from"path";class a7{adb;cachedActiveWindow=null;device;cacheDir=$J(M0.WINDOW);constructor($,J=r){this.adb=J.create($),this.device=$}getCacheFilePath(){let $=BJ.generateCacheKey(this.device.deviceId);return YM$.join(this.cacheDir,$)}getDeviceId(){return this.device.deviceId}async writeCacheToDisk($){let J=this.getCacheFilePath();if(!J){j.info("[WINDOW] No device ID, skipping disk cache write");return}try{await uK.mkdir(this.cacheDir,{recursive:!0}),await uK.writeFile(J,JSON.stringify($),"utf-8"),j.debug(`Wrote active window cache to disk: ${J}`)}catch(X){j.error(`Failed to write cache to disk: ${X}`)}}async readCacheFromDisk(){let $=this.getCacheFilePath();if(!$)return j.info("[WINDOW] No device ID, skipping disk cache read"),null;try{let J=await uK.readFile($,"utf-8"),X=JSON.parse(J);return j.debug(`Read active window cache from disk: ${$}`),X}catch(J){return j.debug(`No disk cache found or error reading: ${J}`),null}}async setCachedActiveWindow($){this.cachedActiveWindow=$,await this.writeCacheToDisk($),j.info("[WINDOW] Cached active window from external source")}async clearCache(){this.cachedActiveWindow=null;let $=this.getCacheFilePath();if($)try{await uK.unlink($),j.info("[WINDOW] Cleared cached active window from disk")}catch(J){j.debug(`Could not remove disk cache: ${J}`)}j.info("[WINDOW] Cleared cached active window")}async getCachedActiveWindow(){if(!this.cachedActiveWindow){j.info("[WINDOW] Using disk cached active window");let $=await this.readCacheFromDisk();if($)return this.cachedActiveWindow=$,j.info("[WINDOW] Using disk cached active window"),$}return this.cachedActiveWindow}async getActive($=!1,J=new a){if(!$&&this.cachedActiveWindow)return j.info("[WINDOW] Using memory cached active window"),this.cachedActiveWindow;if(!$&&!this.cachedActiveWindow){j.info("[WINDOW] Using disk cached active window");let X=await J.track("readDiskCache",()=>this.readCacheFromDisk());if(X)return this.cachedActiveWindow=X,j.info("[WINDOW] Using disk cached active window"),X}try{let{stdout:X}=await J.track("adbDumpsysWindowWindows",()=>this.adb.executeCommand('shell "dumpsys window windows"')),Y=null;if(typeof this.adb.getAndroidApiLevel==="function")Y=await this.adb.getAndroidApiLevel();let Q=null;if(Y!==null&&Y!==void 0&&Y<=27){if(Q=XM$(X),!Q)Q=LO4(X);if(!Q)Q=await this.parseActiveWindowFromDumpsysWindow();if(!Q)Q=JM$(X)}else Q=JM$(X);let W=Q?.appId??"",G=Q?.activityName??"",K=0,V=X.matchAll(/mLayoutSeq=([\d\.]+)/g);if(V)for(let z of V){let Z=parseInt(z[1],10);if(!isNaN(Z))K+=Z}let U={appId:W,activityName:G,layoutSeqSum:K};if(this.cachedActiveWindow=U,await this.writeCacheToDisk(U),j.info("[WINDOW] Cached new active window information"),!W||!G){let z=X.trim().slice(0,200);j.warn(`[WINDOW] Failed to parse active window from dumpsys output. Sample: ${z||"<empty>"}`)}return U}catch(X){return j.error(`Failed to get active window information: ${X}`),{appId:"",activityName:"",layoutSeqSum:0}}}async parseActiveWindowFromDumpsysWindow(){try{let{stdout:$}=await this.adb.executeCommand('shell "dumpsys window"');return XM$($)}catch($){return j.error(`Failed to get dumpsys window for legacy fallback: ${$}`),null}}async getActiveHash($=new a){j.info("[WINDOW] Getting hash of active window");let J=await this.getActive(!0,$),X=JSON.stringify(J);return BJ.generateCacheKey(X)}}function JM$($){let J="",X="",Y=$.match(/imeControlTarget.*?Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(Y&&Y.length>=3)J=Y[1],X=Y[2];else{let Q=$.match(/imeControlTarget.*?Window\{([0-9a-f]+)\s+u\d+\s+Pop-Up Window\}/i);if(Q){let W=Q[1],G=new RegExp(`Window #\\d+ Window\\{${W} u\\d+ Pop-Up Window\\}:([\\s\\S]*?)(?=Window #\\d+|$)`),K=$.match(G);if(K){let V=K[1].match(/mActivityRecord=ActivityRecord\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)(?:\s+t\d+)?\}/);if(V&&V.length>=3)J=V[1],X=V[2]}}if(!J||!X){let W=$.matchAll(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?mViewVisibility=0x0[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs);for(let G of W)if(G[1]&&G[2]&&!G[1].includes("android.systemui")&&!G[1].includes("nexuslauncher")){J=G[1],X=G[2];break}if(!J||!X){let G=$.match(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION/);if(G&&G.length>=3)J=G[1],X=G[2]}}if(!J||!X){let G=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs.exec($);if(G&&G.length>=3)J=G[1],X=G[2]}}if(J&&X)return{appId:J,activityName:X};return null}function LO4($){let J=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:([\s\S]*?)(?=Window #\d+|$)/g,X=[...$.matchAll(J)];for(let Y of X){let Q=Y[1],W=Y[2],G=Y[3];if(!Q||!W)continue;if(Q.includes("android.systemui")||Q.includes("nexuslauncher"))continue;if(/\bty=1\b/.test(G)&&/isReadyForDisplay\(\)=true/.test(G))return{appId:Q,activityName:W}}return null}function XM$($){let J=$.match(/mCurrentFocus=Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(J&&J.length>=3)return{appId:J[1],activityName:J[2]};let X=$.match(/mFocusedApp=AppWindowToken\{[^}]*?\s+([^\s/]+)\/([^\s}]+)/);if(X&&X.length>=3)return{appId:X[1],activityName:X[2]};return null}var YH=D(()=>{p$();m();gK();v$();dX()});function KY($,J){let X=$;if(!X||typeof X!=="object"||typeof X.deviceId!=="string"||X.deviceId.length===0||X.platform!=="android"&&X.platform!=="ios")throw Error(`${J}: expected BootedDevice, got ${OO4($)}`)}function OO4($){if(typeof $==="string")return`string "${$}"`;try{return JSON.stringify($)??String($)}catch{return Object.prototype.toString.call($)}}function QM$($,J,X=VY){if(X.length===0)return"";let Q=$.trim().toLowerCase()===$9?X[0]:X.find((W)=>W.version===$);if(!Q)return"";return J==="android"?Q.apkSha256:Q.ipaSha256}function pa($=process.env,J=VY){if(J.length===0)return"";let X=Z6($);return(X===$9?J[0]:J.find((Q)=>Q.version===X))?.runnerSha256??""}function BO4($=VY){if($.length===0)return $9;return $[0].version}function n0($,J=VY){if($===$9)return BO4(J);return $}function Z6($=process.env){let J=$[DO4]?.trim();if(!J||J.length===0)return $9;return J.toLowerCase()===$9?$9:J}function bW($=process.env){return Z6($)!==$9}function Zz($=process.env,J=VY){let X=Z6($);if(X===$9)return J.length>0;return J.some((Y)=>Y.version===X)}function WM$($=process.env){let J=$[la]?.trim();if(J&&J.length>0){let X;try{X=new URL(J)}catch{throw new C(`${la} must be an absolute URL, for example https://mirror.example/auto-mobile.`)}if(J.includes("?")||J.includes("#"))throw new C(`${la} must not include a query string or fragment; use a path-only base URL such as ${X.origin}${X.pathname.replace(/\/+$/,"")}.`);return`${X.origin}${X.pathname}`.replace(/\/+$/,"")}return ca}function GM$($,J,X=ca,Y=VY){let Q=n0(J,Y);if(Q===$9){if(X===ca)return`https://github.com/kaeawc/auto-mobile/releases/latest/download/${$}`;return`${X}/latest/${$}`}return`${X}/${Q}/${$}`}function kW($=process.env,J=VY){return GM$("control-proxy-debug.apk",Z6($),WM$($),J)}function Hz($=process.env,J=VY){return GM$("control-proxy.ipa",Z6($),WM$($),J)}function mK($=process.env){return QM$(Z6($),"android")}function Lz($=process.env){return QM$(Z6($),"ios")}function P8($=process.env){return`${FO4}@${n0(Z6($))}`}var $9="latest",VY,FO4="@kaeawc/auto-mobile",DO4="AUTOMOBILE_VERSION",la="AUTOMOBILE_ASSET_BASE_URL",ca="https://github.com/kaeawc/auto-mobile/releases/download",xD6,vD6,yD6,hD6,gC="",gD6;var x9=D(()=>{a0();VY=[{version:"0.0.41",apkSha256:"ee1dff240e4dfc89b016197c80e929797485aa23292e061eee361b7404c772b4",ipaSha256:"01eaedef0cfcf38acd0a1fa8eebe08c3009e5db59320b23a045cd26506eb235c",runnerSha256:"b281f9fd516116164a76dc049a413d5123bfb7bf96c79c6ad654ba90c08ed982"},{version:"0.0.40",apkSha256:"8e89fbab6462ac1ead1f3f0a334aff4f5f299e7ae72e192045cf75e893ca87aa",ipaSha256:"38adaed641ac6a8590773682e127a80a86c54e5804d47394e1b0cd437009b9ff",runnerSha256:"b281f9fd516116164a76dc049a413d5123bfb7bf96c79c6ad654ba90c08ed982"},{version:"0.0.39",apkSha256:"eaad59dd85e17c4633098b772b9f761f2124ffb73a5ca7ede703a9b435046942",ipaSha256:"87a720544c83718e5b70c987aecf30d2e43bdb0f23163ac75ac225bb4aec0ae4",runnerSha256:""},{version:"0.0.38",apkSha256:"0fb955a617654695036642662634d042c2e3d278b8e1dce20ccb37e425f059f3",ipaSha256:"f5a4a485ff8ebf3bfd0d73c8b7b10769177b419ccd62e48db188bb5122a2fcde",runnerSha256:""},{version:"0.0.37",apkSha256:"f9b0cc92bf8f7416cdb0c458e16c7a41e4fdeefb80bb9429ab7c603388c99083",ipaSha256:"caccbfaa4da0015bab701a36b81ac87e3f3f3330cee77bb10ec8553724275f4f",runnerSha256:""},{version:"0.0.36",apkSha256:"b5f56bb0ab065c60385a22013c97ee706213eb16deb5d4bcfa42f0a707b8620a",ipaSha256:"40e973dc8c87149e40a616658c74d90e648c6514cc642a5c3dd4a45a187e7600",runnerSha256:""},{version:"0.0.35",apkSha256:"039b359bcf35f1ab6cc666005a57823d71a771a96bd9bcaf4f82f2ec945e306d",ipaSha256:"e6afdfd04a90d2388dc4604e7957d3eef87b90a51ca37c5457b8139a54728108",runnerSha256:""},{version:"0.0.34",apkSha256:"4dcee4f6a7359847d081c5e184c57ed100ad135af2e62f3abfc7b0defaa1153c",ipaSha256:"c2a26ca065c85e9f8d5cfcd6dbad1dbaf3ce38b18d770b0983f7bad62129e4a3",runnerSha256:""},{version:"0.0.33",apkSha256:"7289eba90b22890d3c36e05e99db72a545fa4becdf46df079885783a919e6aed",ipaSha256:"425dfa4db4ad5a4febc9f05ffc97df38f3a1098ccdd9330adff1c0b5c877697d",runnerSha256:""},{version:"0.0.32",apkSha256:"4c4a743af5d18ed58214e64b85986c9e2f2332b015edcf7d9d68a24cd6dfda21",ipaSha256:"40f4d9084d3368995b57c0e81c4fe85f38851353da9f789eaff93027aee456a0",runnerSha256:""},{version:"0.0.31",apkSha256:"0b5802ada8d9adccdb69ee140ae788b3251832c0605d2f6baa3e9b7a78260764",ipaSha256:"e60f8689fb6ddd5c06a5d2ff57569b264f407229afb986258d1ce20326dc24c7",runnerSha256:""},{version:"0.0.30",apkSha256:"a1be5e6240f204ee99540e99cc198f7c0b592dbaf3699330c14f6ded7d333ec3",ipaSha256:"5ac285dd5be16439d3a8a8973c98606920461acfce489830e54ee20759a7b235",runnerSha256:""},{version:"0.0.29",apkSha256:"b33a67c7efa84aca2b07faa965aecb3b1819b4defd441dcc8d3bf7e2af209cd8",ipaSha256:"d47c1aea4495270c1489cae361286ea1439c2ba4e7d5bcfd73f66e4580a6c45d",runnerSha256:""},{version:"0.0.28",apkSha256:"0f683d5939bc308afe038ea1259eb29997dff38af0795136a281ad305986e40e",ipaSha256:"eee7accfbca717bb8b89fafd0676f10d8bb08561c3fbd7a04750c9b12c2a7104",runnerSha256:""},{version:"0.0.27",apkSha256:"9966113ae44f38f3cf34544b1375d3c9a3706701edba45a1eec1f220b9c676cc",ipaSha256:"8620de6b014df18465876334f9ba8c106292f6c3059370eea2349f1e44db4f4d",runnerSha256:""},{version:"0.0.26",apkSha256:"2eb2f156fd27602c85003ab8f6e00d3e06850e84f5453d75b7494aa5bbed7be0",ipaSha256:"905df276d2224d31cbc5aa2258d2dcc60eaeb9813727081ddd32c95394fec411",runnerSha256:""},{version:"0.0.25",apkSha256:"f727079edb4906e3b7928dbb641e788543e86b11fff3fc1b76f0c51b9c8d6e5d",ipaSha256:"d8032cc1cebcb456b7232aa67fc42c89ff62729bacf141aa8f594ce6f8bcd980",runnerSha256:""},{version:"0.0.24",apkSha256:"9047795bc6098f4ec687c126123c73c423806a9fd52888af391d6fb5b94ac93f",ipaSha256:"1dd3e0370cb8ed01d8e1020558d8a2808f208bd947bafcf6688211eddc928bf8",runnerSha256:""},{version:"0.0.18",apkSha256:"fd3c8d9f0b8542eaad56c78b18cf8e5666367b04ae8c4af74d8aa6dd1c8d1834",ipaSha256:"2a5eec63bce2f9dfc227c0732fcce67378305e945604d5eedd0e3df48e37fd39",runnerSha256:""},{version:"0.0.17",apkSha256:"916033440931666644474f227c8e39d13d9c80c3515e4292cc5581fd5bd4cc2f",ipaSha256:"e4dcf064d024f2371b8fd79281000e2d49751ef95b8817d1494d685aeda746ac",runnerSha256:""}];xD6=kW({}),vD6=mK({}),yD6=Hz({}),hD6=Lz({}),gD6=pa({})});var na=x((mD6,KM$)=>{KM$.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var uC=x((UM$)=>{var VM$={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function qO4($){return function(...J){if(J.length)$=$.replace(/\{(\d)\}/g,(X,Y)=>J[Y]||"");return Error("ADM-ZIP: "+$)}}for(let $ of Object.keys(VM$))UM$[$]=qO4(VM$[$])});var LM$=x((cD6,HM$)=>{var wO4=a$("fs"),d0=a$("path"),zM$=na(),MO4=uC(),AO4=typeof process==="object"&&process.platform==="win32",jM$=($)=>typeof $==="object"&&$!==null,ZM$=new Uint32Array(256).map(($,J)=>{for(let X=0;X<8;X++)if((J&1)!==0)J=3988292384^J>>>1;else J>>>=1;return J>>>0});function G0($){if(this.sep=d0.sep,this.fs=wO4,jM$($)){if(jM$($.fs)&&typeof $.fs.statSync==="function")this.fs=$.fs}}HM$.exports=G0;G0.prototype.makeDir=function($){let J=this;function X(Y){let Q=Y.split(J.sep)[0];Y.split(J.sep).forEach(function(W){if(!W||W.substr(-1,1)===":")return;Q+=J.sep+W;var G;try{G=J.fs.statSync(Q)}catch(K){if(K.message&&K.message.startsWith("ENOENT"))J.fs.mkdirSync(Q);else throw K}if(G&&G.isFile())throw MO4.FILE_IN_THE_WAY(`"${Q}"`)})}X($)};G0.prototype.writeFileTo=function($,J,X,Y){let Q=this;if(Q.fs.existsSync($)){if(!X)return!1;var W=Q.fs.statSync($);if(W.isDirectory())return!1}var G=d0.dirname($);if(!Q.fs.existsSync(G))Q.makeDir(G);var K;try{K=Q.fs.openSync($,"w",438)}catch(V){Q.fs.chmodSync($,438),K=Q.fs.openSync($,"w",438)}if(K)try{Q.fs.writeSync(K,J,0,J.length,0)}finally{Q.fs.closeSync(K)}return Q.fs.chmodSync($,Y||438),!0};G0.prototype.writeFileToAsync=function($,J,X,Y,Q){if(typeof Y==="function")Q=Y,Y=void 0;let W=this;W.fs.exists($,function(G){if(G&&!X)return Q(!1);W.fs.stat($,function(K,V){if(G&&V.isDirectory())return Q(!1);var U=d0.dirname($);W.fs.exists(U,function(z){if(!z)W.makeDir(U);W.fs.open($,"w",438,function(Z,H){if(Z)W.fs.chmod($,438,function(){W.fs.open($,"w",438,function(L,O){W.fs.write(O,J,0,J.length,0,function(){W.fs.close(O,function(){W.fs.chmod($,Y||438,function(){Q(!0)})})})})});else if(H)W.fs.write(H,J,0,J.length,0,function(){W.fs.close(H,function(){W.fs.chmod($,Y||438,function(){Q(!0)})})});else W.fs.chmod($,Y||438,function(){Q(!0)})})})})})};G0.prototype.findFiles=function($){let J=this;function X(Y,Q,W){if(typeof Q==="boolean")W=Q,Q=void 0;let G=[];return J.fs.readdirSync(Y).forEach(function(K){let V=d0.join(Y,K),U=J.fs.statSync(V);if(!Q||Q.test(V))G.push(d0.normalize(V)+(U.isDirectory()?J.sep:""));if(U.isDirectory()&&W)G=G.concat(X(V,Q,W))}),G}return X($,void 0,!0)};G0.prototype.findFilesAsync=function($,J){let X=this,Y=[];X.fs.readdir($,function(Q,W){if(Q)return J(Q);let G=W.length;if(!G)return J(null,Y);W.forEach(function(K){K=d0.join($,K),X.fs.stat(K,function(V,U){if(V)return J(V);if(U){if(Y.push(d0.normalize(K)+(U.isDirectory()?X.sep:"")),U.isDirectory())X.findFilesAsync(K,function(z,Z){if(z)return J(z);if(Y=Y.concat(Z),!--G)J(null,Y)});else if(!--G)J(null,Y)}})})})};G0.prototype.getAttributes=function(){};G0.prototype.setAttributes=function(){};G0.crc32update=function($,J){return ZM$[($^J)&255]^$>>>8};G0.crc32=function($){if(typeof $==="string")$=Buffer.from($,"utf8");let J=$.length,X=-1;for(let Y=0;Y<J;)X=G0.crc32update(X,$[Y++]);return~X>>>0};G0.methodToString=function($){switch($){case zM$.STORED:return"STORED ("+$+")";case zM$.DEFLATED:return"DEFLATED ("+$+")";default:return"UNSUPPORTED ("+$+")"}};G0.canonical=function($){if(!$)return"";let J=d0.posix.normalize("/"+$.split("\\").join("/"));return d0.join(".",J)};G0.zipnamefix=function($){if(!$)return"";let J=d0.posix.normalize("/"+$.split("\\").join("/"));return d0.posix.join(".",J)};G0.findLast=function($,J){if(!Array.isArray($))throw TypeError("arr is not array");let X=$.length>>>0;for(let Y=X-1;Y>=0;Y--)if(J($[Y],Y,$))return $[Y];return};G0.sanitize=function($,J){$=d0.resolve(d0.normalize($));var X=J.split("/");for(var Y=0,Q=X.length;Y<Q;Y++){var W=d0.normalize(d0.join($,X.slice(Y,Q).join(d0.sep)));if(W===$||W.startsWith($+d0.sep))return W}return d0.normalize(d0.join($,d0.basename(J)))};G0.toBuffer=function(J,X){if(Buffer.isBuffer(J))return J;else if(J instanceof Uint8Array)return Buffer.from(J);else return typeof J==="string"?X(J):Buffer.alloc(0)};G0.readBigUInt64LE=function($,J){let X=$.readUInt32LE(J);return $.readUInt32LE(J+4)*4294967296+X};G0.writeBigUInt64LE=function($,J,X){let Y=J>>>0,Q=Math.floor(J/4294967296)>>>0;$.writeUInt32LE(Y,X),$.writeUInt32LE(Q,X+4)};G0.fromDOS2Date=function($){return new Date(($>>25&127)+1980,Math.max(($>>21&15)-1,0),Math.max($>>16&31,1),$>>11&31,$>>5&63,($&31)<<1)};G0.fromDate2DOS=function($){let J=0,X=0;if($.getFullYear()>1979)J=($.getFullYear()-1980&127)<<9|$.getMonth()+1<<5|$.getDate(),X=$.getHours()<<11|$.getMinutes()<<5|$.getSeconds()>>1;return J<<16|X};G0.isWin=AO4;G0.crcTable=ZM$});var BM$=x((pD6,OM$)=>{var NO4=a$("path");OM$.exports=function($,{fs:J}){var X=$||"",Y=W(),Q=null;function W(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&J.existsSync(X))Q=J.statSync(X),Y.directory=Q.isDirectory(),Y.mtime=Q.mtime,Y.atime=Q.atime,Y.executable=(73&Q.mode)!==0,Y.readonly=(128&Q.mode)===0,Y.hidden=NO4.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return Y.directory},get readOnly(){return Y.readonly},get hidden(){return Y.hidden},get mtime(){return Y.mtime},get atime(){return Y.atime},get executable(){return Y.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:Y.directory,isReadOnly:Y.readonly,isHidden:Y.hidden,isExecutable:Y.executable,mTime:Y.mtime,aTime:Y.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var DM$=x((nD6,FM$)=>{FM$.exports={efs:!0,encode:($)=>Buffer.from($,"utf8"),decode:($)=>$.toString("utf8")}});var WH=x((dD6,QH)=>{QH.exports=LM$();QH.exports.Constants=na();QH.exports.Errors=uC();QH.exports.FileAttr=BM$();QH.exports.decoder=DM$()});var wM$=x((iD6,qM$)=>{var lK=WH(),d$=lK.Constants;qM$.exports=function(){var $=20,J=10,X=0,Y=0,Q=0,W=0,G=0,K=0,V=0,U=0,z=0,Z=0,H=0,L=0,O=0;$|=lK.isWin?2560:768,X|=d$.FLG_EFS;let B={extraLen:0},q=(F)=>Math.max(0,F)>>>0,w=(F)=>Math.max(0,F)&65535,_=(F)=>Math.max(0,F)&255;return Q=lK.fromDate2DOS(new Date),{get made(){return $},set made(F){$=F},get version(){return J},set version(F){J=F},get flags(){return X},set flags(F){X=F},get flags_efs(){return(X&d$.FLG_EFS)>0},set flags_efs(F){if(F)X|=d$.FLG_EFS;else X&=~d$.FLG_EFS},get flags_desc(){return(X&d$.FLG_DESC)>0},set flags_desc(F){if(F)X|=d$.FLG_DESC;else X&=~d$.FLG_DESC},get method(){return Y},set method(F){switch(F){case d$.STORED:this.version=10;break;case d$.DEFLATED:default:this.version=20}Y=F},get time(){return lK.fromDOS2Date(this.timeval)},set time(F){F=new Date(F),this.timeval=lK.fromDate2DOS(F)},get timeval(){return Q},set timeval(F){Q=q(F)},get timeHighByte(){return _(Q>>>8)},get crc(){return W},set crc(F){W=q(F)},get compressedSize(){return G},set compressedSize(F){G=q(F)},get size(){return K},set size(F){K=q(F)},get fileNameLength(){return V},set fileNameLength(F){V=F},get extraLength(){return U},set extraLength(F){U=F},get extraLocalLength(){return B.extraLen},set extraLocalLength(F){B.extraLen=F},get commentLength(){return z},set commentLength(F){z=F},get diskNumStart(){return Z},set diskNumStart(F){Z=q(F)},get inAttr(){return H},set inAttr(F){H=q(F)},get attr(){return L},set attr(F){L=q(F)},get fileAttr(){return(L||0)>>16&4095},get offset(){return O},set offset(F){O=q(F)},get encrypted(){return(X&d$.FLG_ENC)===d$.FLG_ENC},get centralHeaderSize(){return d$.CENHDR+V+U+z},get realDataOffset(){return O+d$.LOCHDR+B.fnameLen+B.extraLen},get localHeader(){return B},loadLocalHeaderFromBinary:function(F){var A=F.slice(O,O+d$.LOCHDR);if(A.readUInt32LE(0)!==d$.LOCSIG)throw lK.Errors.INVALID_LOC();B.version=A.readUInt16LE(d$.LOCVER),B.flags=A.readUInt16LE(d$.LOCFLG),B.flags_desc=(B.flags&d$.FLG_DESC)>0,B.method=A.readUInt16LE(d$.LOCHOW),B.time=A.readUInt32LE(d$.LOCTIM),B.crc=A.readUInt32LE(d$.LOCCRC),B.compressedSize=A.readUInt32LE(d$.LOCSIZ),B.size=A.readUInt32LE(d$.LOCLEN),B.fnameLen=A.readUInt16LE(d$.LOCNAM),B.extraLen=A.readUInt16LE(d$.LOCEXT);let M=O+d$.LOCHDR+B.fnameLen,P=M+B.extraLen;return F.slice(M,P)},loadFromBinary:function(F){if(F.length!==d$.CENHDR||F.readUInt32LE(0)!==d$.CENSIG)throw lK.Errors.INVALID_CEN();$=F.readUInt16LE(d$.CENVEM),J=F.readUInt16LE(d$.CENVER),X=F.readUInt16LE(d$.CENFLG),Y=F.readUInt16LE(d$.CENHOW),Q=F.readUInt32LE(d$.CENTIM),W=F.readUInt32LE(d$.CENCRC),G=F.readUInt32LE(d$.CENSIZ),K=F.readUInt32LE(d$.CENLEN),V=F.readUInt16LE(d$.CENNAM),U=F.readUInt16LE(d$.CENEXT),z=F.readUInt16LE(d$.CENCOM),Z=F.readUInt16LE(d$.CENDSK),H=F.readUInt16LE(d$.CENATT),L=F.readUInt32LE(d$.CENATX),O=F.readUInt32LE(d$.CENOFF)},localHeaderToBinary:function(){var F=Buffer.alloc(d$.LOCHDR);return F.writeUInt32LE(d$.LOCSIG,0),F.writeUInt16LE(J,d$.LOCVER),F.writeUInt16LE(X&~d$.FLG_DESC,d$.LOCFLG),F.writeUInt16LE(Y,d$.LOCHOW),F.writeUInt32LE(Q,d$.LOCTIM),F.writeUInt32LE(W,d$.LOCCRC),F.writeUInt32LE(G,d$.LOCSIZ),F.writeUInt32LE(K,d$.LOCLEN),F.writeUInt16LE(V,d$.LOCNAM),F.writeUInt16LE(B.extraLen,d$.LOCEXT),F},centralHeaderToBinary:function(){var F=Buffer.alloc(d$.CENHDR+V+U+z);return F.writeUInt32LE(d$.CENSIG,0),F.writeUInt16LE($,d$.CENVEM),F.writeUInt16LE(J,d$.CENVER),F.writeUInt16LE(X&~d$.FLG_DESC,d$.CENFLG),F.writeUInt16LE(Y,d$.CENHOW),F.writeUInt32LE(Q,d$.CENTIM),F.writeUInt32LE(W,d$.CENCRC),F.writeUInt32LE(G,d$.CENSIZ),F.writeUInt32LE(K,d$.CENLEN),F.writeUInt16LE(V,d$.CENNAM),F.writeUInt16LE(U,d$.CENEXT),F.writeUInt16LE(z,d$.CENCOM),F.writeUInt16LE(Z,d$.CENDSK),F.writeUInt16LE(H,d$.CENATT),F.writeUInt32LE(L,d$.CENATX),F.writeUInt32LE(O,d$.CENOFF),F},toJSON:function(){let F=function(A){return A+" bytes"};return{made:$,version:J,flags:X,method:lK.methodToString(Y),time:this.time,crc:"0x"+W.toString(16).toUpperCase(),compressedSize:F(G),size:F(K),fileNameLength:F(V),extraLength:F(U),commentLength:F(z),diskNumStart:Z,inAttr:H,attr:L,offset:O,centralHeaderSize:F(d$.CENHDR+V+U+z)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var AM$=x((oD6,MM$)=>{var aX=WH(),z4=aX.Constants;MM$.exports=function(){var $=0,J=0,X=0,Y=0,Q=0;let W=()=>$>z4.EF_ZIP64_OR_16||J>z4.EF_ZIP64_OR_16||X>z4.EF_ZIP64_OR_32||Y>z4.EF_ZIP64_OR_32;return{get diskEntries(){return $},set diskEntries(G){$=J=G},get totalEntries(){return J},set totalEntries(G){J=$=G},get size(){return X},set size(G){X=G},get offset(){return Y},set offset(G){Y=G},get commentLength(){return Q},set commentLength(G){Q=G},get mainHeaderSize(){return(W()?z4.ZIP64HDR+z4.END64HDR:0)+z4.ENDHDR+Q},loadFromBinary:function(G){if((G.length!==z4.ENDHDR||G.readUInt32LE(0)!==z4.ENDSIG)&&(G.length<z4.ZIP64HDR||G.readUInt32LE(0)!==z4.ZIP64SIG))throw aX.Errors.INVALID_END();if(G.readUInt32LE(0)===z4.ENDSIG)$=G.readUInt16LE(z4.ENDSUB),J=G.readUInt16LE(z4.ENDTOT),X=G.readUInt32LE(z4.ENDSIZ),Y=G.readUInt32LE(z4.ENDOFF),Q=G.readUInt16LE(z4.ENDCOM);else $=aX.readBigUInt64LE(G,z4.ZIP64SUB),J=aX.readBigUInt64LE(G,z4.ZIP64TOT),X=aX.readBigUInt64LE(G,z4.ZIP64SIZB),Y=aX.readBigUInt64LE(G,z4.ZIP64OFF),Q=0},toBinary:function(){if(!W()){var G=Buffer.alloc(z4.ENDHDR+Q);return G.writeUInt32LE(z4.ENDSIG,0),G.writeUInt32LE(0,4),G.writeUInt16LE($,z4.ENDSUB),G.writeUInt16LE(J,z4.ENDTOT),G.writeUInt32LE(X,z4.ENDSIZ),G.writeUInt32LE(Y,z4.ENDOFF),G.writeUInt16LE(Q,z4.ENDCOM),G.fill(" ",z4.ENDHDR),G}var G=Buffer.alloc(this.mainHeaderSize);let K=0;G.writeUInt32LE(z4.ZIP64SIG,K),aX.writeBigUInt64LE(G,z4.ZIP64HDR-z4.ZIP64LEAD,K+z4.ZIP64SIZE),G.writeUInt16LE(45,K+z4.ZIP64VEM),G.writeUInt16LE(45,K+z4.ZIP64VER),G.writeUInt32LE(0,K+z4.ZIP64DSK),G.writeUInt32LE(0,K+z4.ZIP64DSKDIR),aX.writeBigUInt64LE(G,$,K+z4.ZIP64SUB),aX.writeBigUInt64LE(G,J,K+z4.ZIP64TOT),aX.writeBigUInt64LE(G,X,K+z4.ZIP64SIZB),aX.writeBigUInt64LE(G,Y,K+z4.ZIP64OFF);let V=Y+X;return K+=z4.ZIP64HDR,G.writeUInt32LE(z4.END64SIG,K),G.writeUInt32LE(0,K+z4.END64START),aX.writeBigUInt64LE(G,V,K+z4.END64OFF),G.writeUInt32LE(1,K+z4.END64NUMDISKS),K+=z4.END64HDR,G.writeUInt32LE(z4.ENDSIG,K),G.writeUInt32LE(0,K+4),G.writeUInt16LE(Math.min($,z4.EF_ZIP64_OR_16),K+z4.ENDSUB),G.writeUInt16LE(Math.min(J,z4.EF_ZIP64_OR_16),K+z4.ENDTOT),G.writeUInt32LE(Math.min(X,z4.EF_ZIP64_OR_32),K+z4.ENDSIZ),G.writeUInt32LE(Math.min(Y,z4.EF_ZIP64_OR_32),K+z4.ENDOFF),G.writeUInt16LE(Q,K+z4.ENDCOM),G.fill(" ",K+z4.ENDHDR),G},toJSON:function(){let G=function(K,V){let U=K.toString(16).toUpperCase();while(U.length<V)U="0"+U;return"0x"+U};return{diskEntries:$,totalEntries:J,size:X+" bytes",offset:G(Y,4),commentLength:Q}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var da=x((_O4)=>{_O4.EntryHeader=wM$();_O4.MainHeader=AM$()});var _M$=x((tD6,NM$)=>{NM$.exports=function($){var J=a$("zlib"),X={chunkSize:(parseInt($.length/1024)+1)*1024};return{deflate:function(){return J.deflateRawSync($,X)},deflateAsync:function(Y){var Q=J.createDeflateRaw(X),W=[],G=0;Q.on("data",function(K){W.push(K),G+=K.length}),Q.on("end",function(){var K=Buffer.alloc(G),V=0;K.fill(0);for(var U=0;U<W.length;U++){var z=W[U];z.copy(K,V),V+=z.length}Y&&Y(K)}),Q.end($)}}}});var EM$=x((aD6,RM$)=>{var PO4=+(process?.versions?.node??"").split(".")[0]||0;RM$.exports=function($,J){var X=a$("zlib");let Y=PO4>=15&&J>0?{maxOutputLength:J}:{};return{inflate:function(){return X.inflateRawSync($,Y)},inflateAsync:function(Q){var W=X.createInflateRaw(Y),G=[],K=0;W.on("data",function(V){G.push(V),K+=V.length}),W.on("end",function(){var V=Buffer.alloc(K),U=0;V.fill(0);for(var z=0;z<G.length;z++){var Z=G[z];Z.copy(V,U),U+=Z.length}Q&&Q(V)}),W.end($)}}}});var SM$=x((sD6,IM$)=>{var{randomFillSync:PM$}=a$("crypto"),CO4=uC(),TO4=new Uint32Array(256).map(($,J)=>{for(let X=0;X<8;X++)if((J&1)!==0)J=J>>>1^3988292384;else J>>>=1;return J>>>0}),TM$=($,J)=>Math.imul($,J)>>>0,CM$=($,J)=>{return TO4[($^J)&255]^$>>>8},_D=()=>{if(typeof PM$==="function")return PM$(Buffer.alloc(12));else return _D.node()};_D.node=()=>{let $=Buffer.alloc(12),J=$.length;for(let X=0;X<J;X++)$[X]=Math.random()*256&255;return $};var mC={genSalt:_D};function lC($){let J=Buffer.isBuffer($)?$:Buffer.from($);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let X=0;X<J.length;X++)this.updateKeys(J[X])}lC.prototype.updateKeys=function($){let J=this.keys;return J[0]=CM$(J[0],$),J[1]+=J[0]&255,J[1]=TM$(J[1],134775813)+1,J[2]=CM$(J[2],J[1]>>>24),$};lC.prototype.next=function(){let $=(this.keys[2]|2)>>>0;return TM$($,$^1)>>8&255};function IO4($){let J=new lC($);return function(X){let Y=Buffer.alloc(X.length),Q=0;for(let W of X)Y[Q++]=J.updateKeys(W^J.next());return Y}}function SO4($){let J=new lC($);return function(X,Y,Q=0){if(!Y)Y=Buffer.alloc(X.length);for(let W of X){let G=J.next();Y[Q++]=W^G,J.updateKeys(W)}return Y}}function bO4($,J,X){if(!$||!Buffer.isBuffer($)||$.length<12)return Buffer.alloc(0);let Y=IO4(X),Q=Y($.slice(0,12)),W=(J.flags&8)===8?J.timeHighByte:J.crc>>>24;if(Q[11]!==W)throw CO4.WRONG_PASSWORD();return Y($.slice(12))}function kO4($){if(Buffer.isBuffer($)&&$.length>=12)mC.genSalt=function(){return $.slice(0,12)};else if($==="node")mC.genSalt=_D.node;else mC.genSalt=_D}function fO4($,J,X,Y=!1){if($==null)$=Buffer.alloc(0);if(!Buffer.isBuffer($))$=Buffer.from($.toString());let Q=SO4(X),W=mC.genSalt();if(W[11]=J.crc>>>24&255,Y)W[10]=J.crc>>>16&255;let G=Buffer.alloc($.length+12);return Q(W,G),Q($,G,12)}IM$.exports={decrypt:bO4,encrypt:fO4,_salter:kO4}});var bM$=x((xO4)=>{xO4.Deflater=_M$();xO4.Inflater=EM$();xO4.ZipCrypto=SM$()});var oa=x(($q6,kM$)=>{var Y1=WH(),gO4=da(),A0=Y1.Constants,ia=bM$();kM$.exports=function($,J){var X=new gO4.EntryHeader,Y=Buffer.alloc(0),Q=Buffer.alloc(0),W=!1,G=null,K=Buffer.alloc(0),V=Buffer.alloc(0),U=!0;let z=$,Z=typeof z.decoder==="object"?z.decoder:Y1.decoder;U=Z.hasOwnProperty("efs")?Z.efs:!1;function H(){if(!J||!(J instanceof Uint8Array))return Buffer.alloc(0);return V=X.loadLocalHeaderFromBinary(J),J.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function L(F){if(!X.flags_desc&&!X.localHeader.flags_desc){if(Y1.crc32(F)!==X.localHeader.crc)return!1}else{let A={},M=X.realDataOffset+X.compressedSize;if(J.readUInt32LE(M)==A0.LOCSIG||J.readUInt32LE(M)==A0.CENSIG)throw Y1.Errors.DESCRIPTOR_NOT_EXIST();if(J.readUInt32LE(M)==A0.EXTSIG)A.crc=J.readUInt32LE(M+A0.EXTCRC),A.compressedSize=J.readUInt32LE(M+A0.EXTSIZ),A.size=J.readUInt32LE(M+A0.EXTLEN);else if(J.readUInt16LE(M+12)===19280)A.crc=J.readUInt32LE(M+A0.EXTCRC-4),A.compressedSize=J.readUInt32LE(M+A0.EXTSIZ-4),A.size=J.readUInt32LE(M+A0.EXTLEN-4);else throw Y1.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==X.compressedSize||A.size!==X.size||A.crc!==X.crc)throw Y1.Errors.DESCRIPTOR_FAULTY();if(Y1.crc32(F)!==A.crc)return!1}return!0}function O(F,A,M){if(typeof A>"u"&&typeof F==="string")M=F,F=void 0;if(W){if(F&&A)A(Buffer.alloc(0),Y1.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var P=H();if(P.length===0){if(F&&A)A(P);return P}if(X.encrypted){if(typeof M!=="string"&&!Buffer.isBuffer(M))throw Y1.Errors.INVALID_PASS_PARAM();P=ia.ZipCrypto.decrypt(P,X,M)}var k=Buffer.alloc(X.size);switch(X.method){case Y1.Constants.STORED:if(P.copy(k),!L(k)){if(F&&A)A(k,Y1.Errors.BAD_CRC());throw Y1.Errors.BAD_CRC()}else{if(F&&A)A(k);return k}case Y1.Constants.DEFLATED:var I=new ia.Inflater(P,X.size);if(!F){if(I.inflate(k).copy(k,0),!L(k))throw Y1.Errors.BAD_CRC(`"${Z.decode(Y)}"`);return k}else I.inflateAsync(function(u){if(u.copy(u,0),A)if(!L(u))A(u,Y1.Errors.BAD_CRC());else A(u)});break;default:if(F&&A)A(Buffer.alloc(0),Y1.Errors.UNKNOWN_METHOD());throw Y1.Errors.UNKNOWN_METHOD()}}function B(F,A){if((!G||!G.length)&&Buffer.isBuffer(J)){if(F&&A)A(H());return H()}if(G.length&&!W){var M;switch(X.method){case Y1.Constants.STORED:if(X.compressedSize=X.size,M=Buffer.alloc(G.length),G.copy(M),F&&A)A(M);return M;default:case Y1.Constants.DEFLATED:var P=new ia.Deflater(G);if(!F){var k=P.deflate();return X.compressedSize=k.length,k}else P.deflateAsync(function(I){M=Buffer.alloc(I.length),X.compressedSize=I.length,I.copy(M),A&&A(M)});P=null;break}}else if(F&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function q(F,A){return Y1.readBigUInt64LE(F,A)}function w(F){try{var A=0,M,P,k;while(A+4<F.length)if(M=F.readUInt16LE(A),A+=2,P=F.readUInt16LE(A),A+=2,k=F.slice(A,A+P),A+=P,A0.ID_ZIP64===M)_(k)}catch(I){throw Y1.Errors.EXTRA_FIELD_PARSE_ERROR()}}function _(F){var A,M,P,k;if(F.length>=A0.EF_ZIP64_SCOMP){if(A=q(F,A0.EF_ZIP64_SUNCOMP),X.size===A0.EF_ZIP64_OR_32)X.size=A}if(F.length>=A0.EF_ZIP64_RHO){if(M=q(F,A0.EF_ZIP64_SCOMP),X.compressedSize===A0.EF_ZIP64_OR_32)X.compressedSize=M}if(F.length>=A0.EF_ZIP64_DSN){if(P=q(F,A0.EF_ZIP64_RHO),X.offset===A0.EF_ZIP64_OR_32)X.offset=P}if(F.length>=A0.EF_ZIP64_DSN+4){if(k=F.readUInt32LE(A0.EF_ZIP64_DSN),X.diskNumStart===A0.EF_ZIP64_OR_16)X.diskNumStart=k}}return{get entryName(){return Z.decode(Y)},get rawEntryName(){return Y},set entryName(F){Y=Y1.toBuffer(F,Z.encode);var A=Y[Y.length-1];W=A===47||A===92,X.fileNameLength=Y.length},get efs(){if(typeof U==="function")return U(this.entryName);else return U},get extra(){return K},set extra(F){K=F,X.extraLength=F.length,w(F)},get comment(){return Z.decode(Q)},set comment(F){if(Q=Y1.toBuffer(F,Z.encode),X.commentLength=Q.length,Q.length>65535)throw Y1.Errors.COMMENT_TOO_LONG()},get name(){var F=Z.decode(Y);return W?F.substr(F.length-1).split("/").pop():F.split("/").pop()},get isDirectory(){return W},getCompressedData:function(){return B(!1,null)},getCompressedDataAsync:function(F){B(!0,F)},setData:function(F){if(G=Y1.toBuffer(F,Y1.decoder.encode),!W&&G.length)X.size=G.length,X.method=Y1.Constants.DEFLATED,X.crc=Y1.crc32(F),X.changed=!0;else X.method=Y1.Constants.STORED},getData:function(F){if(X.changed)return G;else return O(!1,null,F)},getDataAsync:function(F,A){if(X.changed)F(G);else O(!0,F,A)},set attr(F){X.attr=F},get attr(){return X.attr},set header(F){X.loadFromBinary(F)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=K.length;var F=X.centralHeaderToBinary(),A=Y1.Constants.CENHDR;return Y.copy(F,A),A+=Y.length,K.copy(F,A),A+=X.extraLength,Q.copy(F,A),F},packLocalHeader:function(){let F=0;X.flags_efs=this.efs,X.extraLocalLength=V.length;let A=X.localHeaderToBinary(),M=Buffer.alloc(A.length+Y.length+X.extraLocalLength);return A.copy(M,F),F+=A.length,Y.copy(M,F),F+=Y.length,V.copy(M,F),F+=V.length,M},toJSON:function(){let F=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:F(J),data:F(G)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var vM$=x((Jq6,xM$)=>{var fM$=oa(),uO4=da(),v9=WH();xM$.exports=function($,J){var X=[],Y={},Q=Buffer.alloc(0),W=new uO4.MainHeader,G=!1,K=null;let V=new Set,U=J,{noSort:z,decoder:Z}=U;if($)O(U.readEntries);else G=!0;function H(){let q=new Set;for(let w of Object.keys(Y)){let _=w.split("/");if(_.pop(),!_.length)continue;for(let F=0;F<_.length;F++){let A=_.slice(0,F+1).join("/")+"/";q.add(A)}}for(let w of q)if(!(w in Y)){let _=new fM$(U);_.entryName=w,_.attr=16,_.temporary=!0,X.push(_),Y[_.entryName]=_,V.add(_)}}function L(){if(G=!0,Y={},W.diskEntries>($.length-W.offset)/v9.Constants.CENHDR)throw v9.Errors.DISK_ENTRY_TOO_LARGE();X=Array(W.diskEntries);var q=W.offset;for(var w=0;w<X.length;w++){var _=q,F=new fM$(U,$);if(F.header=$.slice(_,_+=v9.Constants.CENHDR),F.entryName=$.slice(_,_+=F.header.fileNameLength),F.header.extraLength)F.extra=$.slice(_,_+=F.header.extraLength);if(F.header.commentLength)F.comment=$.slice(_,_+F.header.commentLength);q+=F.header.centralHeaderSize,X[w]=F,Y[F.entryName]=F}V.clear(),H()}function O(q){var w=$.length-v9.Constants.ENDHDR,_=Math.max(0,w-65535),F=_,A=$.length,M=-1,P=0;if(typeof U.trailingSpace==="boolean"?U.trailingSpace:!1)_=0;for(w;w>=F;w--){if($[w]!==80)continue;if($.readUInt32LE(w)===v9.Constants.ENDSIG){M=w,P=w,A=w+v9.Constants.ENDHDR,F=w-v9.Constants.END64HDR;continue}if($.readUInt32LE(w)===v9.Constants.END64SIG){F=_;continue}if($.readUInt32LE(w)===v9.Constants.ZIP64SIG){M=w,A=w+v9.readBigUInt64LE($,w+v9.Constants.ZIP64SIZE)+v9.Constants.ZIP64LEAD;break}}if(M==-1)throw v9.Errors.INVALID_FORMAT();if(W.loadFromBinary($.slice(M,A)),W.commentLength)Q=$.slice(P+v9.Constants.ENDHDR);if(q)L()}function B(){if(X.length>1&&!z)X.sort((q,w)=>q.entryName.toLowerCase().localeCompare(w.entryName.toLowerCase()))}return{get entries(){if(!G)L();return X.filter((q)=>!V.has(q))},get comment(){return Z.decode(Q)},set comment(q){Q=v9.toBuffer(q,Z.encode),W.commentLength=Q.length},getEntryCount:function(){if(!G)return W.diskEntries;return X.length},forEach:function(q){this.entries.forEach(q)},getEntry:function(q){if(!G)L();return Y[q]||null},setEntry:function(q){if(!G)L();X.push(q),Y[q.entryName]=q,W.totalEntries=X.length},deleteFile:function(q,w=!0){if(!G)L();let _=Y[q];this.getEntryChildren(_,w).map((A)=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(q){if(!G)L();let w=Y[q],_=X.indexOf(w);if(_>=0)X.splice(_,1),delete Y[q],W.totalEntries=X.length},getEntryChildren:function(q,w=!0){if(!G)L();if(typeof q==="object")if(q.isDirectory&&w){let _=[],F=q.entryName;for(let A of X)if(A.entryName.startsWith(F))_.push(A);return _}else return[q];return[]},getChildCount:function(q){if(q&&q.isDirectory){let w=this.getEntryChildren(q);return w.includes(q)?w.length-1:w.length}return 0},compressToBuffer:function(){if(!G)L();B();let q=[],w=[],_=0,F=0;W.size=0,W.offset=0;let A=0;for(let k of this.entries){let I=k.getCompressedData();k.header.offset=F;let u=k.packLocalHeader(),v=u.length+I.length;F+=v,q.push(u),q.push(I);let c=k.packCentralHeader();w.push(c),W.size+=c.length,_+=v+c.length,A++}_+=W.mainHeaderSize,W.offset=F,W.totalEntries=A,F=0;let M=Buffer.alloc(_);for(let k of q)k.copy(M,F),F+=k.length;for(let k of w)k.copy(M,F),F+=k.length;let P=W.toBinary();if(Q)Q.copy(P,P.length-Q.length);return P.copy(M,F),$=M,G=!1,M},toAsyncBuffer:function(q,w,_,F){try{if(!G)L();B();let A=[],M=[],P=0,k=0,I=0;W.size=0,W.offset=0;let u=function(v){if(v.length>0){let c=v.shift(),e=c.entryName+c.extra.toString();if(_)_(e);c.getCompressedDataAsync(function(X$){if(F)F(e);c.header.offset=k;let h$=c.packLocalHeader(),L4=h$.length+X$.length;k+=L4,A.push(h$),A.push(X$);let b$=c.packCentralHeader();M.push(b$),W.size+=b$.length,P+=L4+b$.length,I++,u(v)})}else{P+=W.mainHeaderSize,W.offset=k,W.totalEntries=I,k=0;let c=Buffer.alloc(P);A.forEach(function(X$){X$.copy(c,k),k+=X$.length}),M.forEach(function(X$){X$.copy(c,k),k+=X$.length});let e=W.toBinary();if(Q)Q.copy(e,e.length-Q.length);e.copy(c,k),$=c,G=!1,q(c)}};u(Array.from(this.entries))}catch(A){w(A)}}}}});var ra=x((Xq6,hM$)=>{var V0=WH(),K0=a$("path"),mO4=oa(),lO4=vM$(),Oz=(...$)=>V0.findLast($,(J)=>typeof J==="boolean"),yM$=(...$)=>V0.findLast($,(J)=>typeof J==="string"),cO4=(...$)=>V0.findLast($,(J)=>typeof J==="function"),pO4={noSort:!1,readEntries:!1,method:V0.Constants.NONE,fs:null};hM$.exports=function($,J){let X=null,Y=Object.assign(Object.create(null),pO4);if($&&typeof $==="object"){if(!($ instanceof Uint8Array)){if(Object.assign(Y,$),$=Y.input?Y.input:void 0,Y.input)delete Y.input}if(Buffer.isBuffer($))X=$,Y.method=V0.Constants.BUFFER,$=void 0}Object.assign(Y,J);let Q=new V0(Y);if(typeof Y.decoder!=="object"||typeof Y.decoder.encode!=="function"||typeof Y.decoder.decode!=="function")Y.decoder=V0.decoder;if($&&typeof $==="string")if(Q.fs.existsSync($))Y.method=V0.Constants.FILE,Y.filename=$,X=Q.fs.readFileSync($);else throw V0.Errors.INVALID_FILENAME();let W=new lO4(X,Y),{canonical:G,sanitize:K,zipnamefix:V}=V0;function U(L){if(L&&W){var O;if(typeof L==="string")O=W.getEntry(K0.posix.normalize(L));if(typeof L==="object"&&typeof L.entryName<"u"&&typeof L.header<"u")O=W.getEntry(L.entryName);if(O)return O}return null}function z(L){let{join:O,normalize:B,sep:q}=K0.posix;return O(K0.isAbsolute(L)?"/":".",B(q+L.split("\\").join(q)+q))}function Z(L){if(L instanceof RegExp)return function(O){return function(B){return O.test(B)}}(L);else if(typeof L!=="function")return()=>!0;return L}let H=(L,O)=>{let B=O.slice(-1);return B=B===Q.sep?Q.sep:"",K0.relative(L,O)+B};return{readFile:function(L,O){var B=U(L);return B&&B.getData(O)||null},childCount:function(L){let O=U(L);if(O)return W.getChildCount(O)},readFileAsync:function(L,O){var B=U(L);if(B)B.getDataAsync(O);else O(null,"getEntry failed for:"+L)},readAsText:function(L,O){var B=U(L);if(B){var q=B.getData();if(q&&q.length)return q.toString(O||"utf8")}return""},readAsTextAsync:function(L,O,B){var q=U(L);if(q)q.getDataAsync(function(w,_){if(_){O(w,_);return}if(w&&w.length)O(w.toString(B||"utf8"));else O("")});else O("")},deleteFile:function(L,O=!0){var B=U(L);if(B)W.deleteFile(B.entryName,O)},deleteEntry:function(L){var O=U(L);if(O)W.deleteEntry(O.entryName)},addZipComment:function(L){W.comment=L},getZipComment:function(){return W.comment||""},addZipEntryComment:function(L,O){var B=U(L);if(B)B.comment=O},getZipEntryComment:function(L){var O=U(L);if(O)return O.comment||"";return""},updateFile:function(L,O){var B=U(L);if(B)B.setData(O)},addLocalFile:function(L,O,B,q){if(Q.fs.existsSync(L)){O=O?z(O):"";let w=K0.win32.basename(K0.win32.normalize(L));O+=B?B:w;let _=Q.fs.statSync(L),F=_.isFile()?Q.fs.readFileSync(L):Buffer.alloc(0);if(_.isDirectory())O+=Q.sep;this.addFile(O,F,q,_)}else throw V0.Errors.FILE_NOT_FOUND(L)},addLocalFileAsync:function(L,O){L=typeof L==="object"?L:{localPath:L};let B=K0.resolve(L.localPath),{comment:q}=L,{zipPath:w,zipName:_}=L,F=this;Q.fs.stat(B,function(A,M){if(A)return O(A,!1);w=w?z(w):"";let P=K0.win32.basename(K0.win32.normalize(B));if(w+=_?_:P,M.isFile())Q.fs.readFile(B,function(k,I){if(k)return O(k,!1);return F.addFile(w,I,q,M),setImmediate(O,void 0,!0)});else if(M.isDirectory())return w+=Q.sep,F.addFile(w,Buffer.alloc(0),q,M),setImmediate(O,void 0,!0)})},addLocalFolder:function(L,O,B){if(B=Z(B),O=O?z(O):"",L=K0.normalize(L),Q.fs.existsSync(L)){let q=Q.findFiles(L),w=this;if(q.length)for(let _ of q){let F=K0.join(O,H(L,_));if(B(F))w.addLocalFile(_,K0.dirname(F))}}else throw V0.Errors.FILE_NOT_FOUND(L)},addLocalFolderAsync:function(L,O,B,q){q=Z(q),B=B?z(B):"",L=K0.normalize(L);var w=this;Q.fs.open(L,"r",function(_){if(_&&_.code==="ENOENT")O(void 0,V0.Errors.FILE_NOT_FOUND(L));else if(_)O(void 0,_);else{var F=Q.findFiles(L),A=-1,M=function(){if(A+=1,A<F.length){var P=F[A],k=H(L,P).split("\\").join("/");if(k=k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),q(k))Q.fs.stat(P,function(I,u){if(I)O(void 0,I);if(u.isFile())Q.fs.readFile(P,function(v,c){if(v)O(void 0,v);else w.addFile(B+k,c,"",u),M()});else w.addFile(B+k+"/",Buffer.alloc(0),"",u),M()});else process.nextTick(()=>{M()})}else O(!0,void 0)};M()}})},addLocalFolderAsync2:function(L,O){let B=this;L=typeof L==="object"?L:{localPath:L};let q=K0.resolve(z(L.localPath)),{zipPath:w,filter:_,namefix:F}=L;if(_ instanceof RegExp)_=function(P){return function(k){return P.test(k)}}(_);else if(typeof _!=="function")_=function(){return!0};if(w=w?z(w):"",F==="latin1")F=(P)=>P.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof F!=="function")F=(P)=>P;let A=(P)=>K0.join(w,F(H(q,P))),M=(P)=>K0.win32.basename(K0.win32.normalize(F(P)));Q.fs.open(q,"r",function(P){if(P&&P.code==="ENOENT")O(void 0,V0.Errors.FILE_NOT_FOUND(q));else if(P)O(void 0,P);else Q.findFilesAsync(q,function(k,I){if(k)return O(k);if(I=I.filter((u)=>_(A(u))),!I.length)O(void 0,!1);setImmediate(I.reverse().reduce(function(u,v){return function(c,e){if(c||e===!1)return setImmediate(u,c,!1);B.addLocalFileAsync({localPath:v,zipPath:K0.dirname(A(v)),zipName:M(v)},u)}},O))})})},addLocalFolderPromise:function(L,O){return new Promise((B,q)=>{this.addLocalFolderAsync2(Object.assign({localPath:L},O),(w,_)=>{if(w)q(w);if(_)B(this)})})},addFile:function(L,O,B,q){L=V(L);let w=U(L),_=w!=null;if(!_)w=new mO4(Y),w.entryName=L;w.comment=B||"";let F=typeof q==="object"&&q instanceof Q.fs.Stats;if(F)w.header.time=q.mtime;var A=w.isDirectory?16:0;let M=w.isDirectory?16384:32768;if(F)M|=4095&q.mode;else if(typeof q==="number")M|=4095&q;else M|=w.isDirectory?493:420;if(A=(A|M<<16)>>>0,w.attr=A,w.setData(O),!_)W.setEntry(w);return w},getEntries:function(L){return W.password=L,W?W.entries:[]},getEntry:function(L){return U(L)},getEntryCount:function(){return W.getEntryCount()},forEach:function(L){return W.forEach(L)},extractEntryTo:function(L,O,B,q,w,_){q=Oz(!1,q),w=Oz(!1,w),B=Oz(!0,B),_=yM$(w,_);var F=U(L);if(!F)throw V0.Errors.NO_ENTRY();var A=G(F.entryName),M=K(O,_&&!F.isDirectory?G(_):B?A:K0.basename(A));if(F.isDirectory){var P=W.getEntryChildren(F);return P.forEach(function(u){if(u.isDirectory)return;var v=u.getData();if(!v)throw V0.Errors.CANT_EXTRACT_FILE();var c=G(u.entryName),e=K(O,B?c:K0.basename(c));let X$=w?u.header.fileAttr:void 0;Q.writeFileTo(e,v,q,X$)}),!0}var k=F.getData(W.password);if(!k)throw V0.Errors.CANT_EXTRACT_FILE();if(Q.fs.existsSync(M)&&!q)throw V0.Errors.CANT_OVERRIDE();let I=w?L.header.fileAttr:void 0;return Q.writeFileTo(M,k,q,I),!0},test:function(L){if(!W)return!1;for(var O of W.entries)try{if(O.isDirectory)continue;var B=W.entries[O].getData(L);if(!B)return!1}catch(q){return!1}return!0},extractAllTo:function(L,O,B,q){if(B=Oz(!1,B),q=yM$(B,q),O=Oz(!1,O),!W)throw V0.Errors.NO_ZIP();W.entries.forEach(function(w){var _=K(L,G(w.entryName));if(w.isDirectory){Q.makeDir(_);return}var F=w.getData(q);if(!F)throw V0.Errors.CANT_EXTRACT_FILE();let A=B?w.header.fileAttr:void 0;Q.writeFileTo(_,F,O,A);try{Q.fs.utimesSync(_,w.header.time,w.header.time)}catch(M){throw V0.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(L,O,B,q){if(q=cO4(O,B,q),B=Oz(!1,B),O=Oz(!1,O),!q)return new Promise((M,P)=>{this.extractAllToAsync(L,O,B,function(k){if(k)P(k);else M(this)})});if(!W){q(V0.Errors.NO_ZIP());return}L=K0.resolve(L);let w=(M)=>K(L,K0.normalize(G(M.entryName))),_=(M,P)=>Error(M+': "'+P+'"'),F=[],A=[];W.entries.forEach((M)=>{if(M.isDirectory)F.push(M);else A.push(M)});for(let M of F){let P=w(M),k=B?M.header.fileAttr:void 0;try{if(Q.makeDir(P),k)Q.fs.chmodSync(P,k);Q.fs.utimesSync(P,M.header.time,M.header.time)}catch(I){q(_("Unable to create folder",P))}}A.reverse().reduce(function(M,P){return function(k){if(k)M(k);else{let I=K0.normalize(G(P.entryName)),u=K(L,I);P.getDataAsync(function(v,c){if(c)M(c);else if(!v)M(V0.Errors.CANT_EXTRACT_FILE());else{let e=B?P.header.fileAttr:void 0;Q.writeFileToAsync(u,v,O,e,function(X$){if(!X$)M(_("Unable to write file",u));Q.fs.utimes(u,P.header.time,P.header.time,function(h$){if(h$)M(_("Unable to set times",u));else M()})})}})}}},q)()},writeZip:function(L,O){if(arguments.length===1){if(typeof L==="function")O=L,L=""}if(!L&&Y.filename)L=Y.filename;if(!L)return;var B=W.compressToBuffer();if(B){var q=Q.writeFileTo(L,B,!0);if(typeof O==="function")O(!q?Error("failed"):null,"")}},writeZipPromise:function(L,O){let{overwrite:B,perm:q}=Object.assign({overwrite:!0},O);return new Promise((w,_)=>{if(!L&&Y.filename)L=Y.filename;if(!L)_("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((F)=>{let A=(M)=>M?w(M):_("ADM-ZIP: Wasn't able to write zip file");Q.writeFileToAsync(L,F,B,q,A)},_)})},toBufferPromise:function(){return new Promise((L,O)=>{W.toAsyncBuffer(L,O)})},toBuffer:function(L,O,B,q){if(typeof L==="function")return W.toAsyncBuffer(L,O,B,q),null;return W.compressToBuffer()}}}});class gM${DEFAULT_TTL_MS=60000;cache;timer;constructor($=new aZ){this.timer=$,this.cache=new vK($,{ttlMs:this.DEFAULT_TTL_MS})}async isAccessibilityEnabled($,J,X){if(X?.isEnabled("force-accessibility-mode"))return j.debug(`[AccessibilityDetector] Force-enabled via feature flag for device ${$}`),!0;if(X&&!X.isEnabled("accessibility-auto-detect"))return j.debug(`[AccessibilityDetector] Auto-detection disabled via feature flag for device ${$}`),!1;let W=this.cache.get($);if(W)return j.debug(`[AccessibilityDetector] Using cached result for device ${$}: enabled=${W.enabled}, service=${W.service}`),W.enabled;j.debug(`[AccessibilityDetector] Detecting accessibility state for device ${$}`);let G=this.timer.now(),{enabled:K,service:V}=await this.detectAccessibilityState($,J),U=this.timer.now()-G;if(U>50)j.warn(`[AccessibilityDetector] Detection took ${U}ms (target: <50ms) for device ${$}`);else j.debug(`[AccessibilityDetector] Detection completed in ${U}ms for device ${$}`);return this.cache.set($,{enabled:K,service:V}),K}async detectMethod($,J,X){if(X?.isEnabled("force-accessibility-mode"))return"talkback";if(X&&!X.isEnabled("accessibility-auto-detect"))return"unknown";let W=this.cache.get($);if(W)return W.service;let{enabled:G,service:K}=await this.detectAccessibilityState($,J);return this.cache.set($,{enabled:G,service:K}),K}invalidateCache($){j.debug(`[AccessibilityDetector] Invalidating cache for device ${$}`),this.cache.delete($)}clearAllCache(){j.debug("[AccessibilityDetector] Clearing all cached entries"),this.cache.clear()}async detectAccessibilityState($,J){try{let Y=(await J.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(Y.includes("com.google.android.marvin.talkback")||Y.includes("TalkBackService"))return j.debug(`[AccessibilityDetector] TalkBack detected as enabled on device ${$}`),{enabled:!0,service:"talkback"};if(Y!=="null"&&Y.length>0&&!Y.includes("null"))return j.debug(`[AccessibilityDetector] Unknown accessibility service detected on device ${$}: ${Y}`),{enabled:!0,service:"unknown"};return j.debug(`[AccessibilityDetector] No accessibility services enabled on device ${$}`),{enabled:!1,service:"unknown"}}catch(X){return j.error(`[AccessibilityDetector] Failed to detect accessibility state for device ${$}:`,X),{enabled:!1,service:"unknown"}}}}var fJ;var cK=D(()=>{m();J$();xC();fJ=new gM$});import{execFile as nO4}from"child_process";import{createWriteStream as dO4}from"fs";import*as mM$ from"fs/promises";import iO4 from"http";import oO4 from"https";import*as lM$ from"path";import{promisify as rO4}from"util";class Bz{async download($,J){await mM$.mkdir(lM$.dirname(J),{recursive:!0});try{await this.downloadWithCurl($,J);return}catch(X){if(!this.isCommandUnavailable(X,"curl"))throw X;j.warn("[FileDownloader] curl unavailable, falling back to wget",{error:X instanceof Error?X.message:String(X)})}try{await this.downloadWithWget($,J);return}catch(X){if(!this.isCommandUnavailable(X,"wget"))throw X;j.warn("[FileDownloader] wget unavailable, falling back to Node HTTP",{error:X instanceof Error?X.message:String(X)})}await this.downloadWithNodeHttp($,J,0)}async downloadWithCurl($,J){await uM$("curl",["--fail","--location","--retry","3","--retry-delay","1","--silent","--show-error","-o",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithWget($,J){await uM$("wget",["--tries=3","--timeout=30","-O",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithNodeHttp($,J,X){if(X>5)throw Error(`Too many redirects while downloading ${$}`);await new Promise((Y,Q)=>{let G=($.startsWith("https:")?oO4:iO4).get($,{headers:{"User-Agent":"auto-mobile"}},(K)=>{let V=K.statusCode??0;if(V>=300&&V<400&&K.headers.location){K.resume();let z=new URL(K.headers.location,$).toString();this.downloadWithNodeHttp(z,J,X+1).then(Y).catch(Q);return}if(V<200||V>=300){K.resume(),Q(Error(`Download failed with status ${V} from ${$}`));return}let U=dO4(J);K.pipe(U),U.on("finish",()=>U.close(()=>Y())),U.on("error",(z)=>{U.close(),Q(z)})});G.setTimeout(30000,()=>{G.destroy(Error(`Download request timed out for ${$}`))}),G.on("error",Q)})}isCommandUnavailable($,J){if(!$||typeof $!=="object")return!1;let X=$,Y=typeof X.code==="number"?X.code:Number(X.code);if(X.code==="ENOENT"||!Number.isNaN(Y)&&Y===127)return!0;let Q=`${X.message??""} ${X.stderr??""}`.toLowerCase();if(Q.includes("command not found")||Q.includes("not recognized as an internal or external command")||Q.includes(`${J}: not found`)||Q.includes(`not found: ${J}`))return!0;return!1}}var uM$;var cC=D(()=>{m();uM$=rO4(nO4)});import{execFile as tO4}from"child_process";import{createReadStream as aO4}from"fs";import sO4 from"crypto";import{promisify as eO4}from"util";class Fz{async computeFileSha256($){let J=await this.tryChecksumCommand([$],"sha256sum");if(J)return{checksum:J,source:"sha256sum"};let X=await this.tryChecksumCommand(["-a","256",$],"shasum");if(X)return{checksum:X,source:"shasum"};let Y=sO4.createHash("sha256");return await new Promise((Q,W)=>{let G=aO4($);G.on("data",(K)=>Y.update(K)),G.on("error",W),G.on("end",()=>Q())}),{checksum:Y.digest("hex"),source:"node"}}async tryChecksumCommand($,J){try{let{stdout:X}=await $B4(J,$,{timeout:120000,maxBuffer:10485760}),Y=X.trim().split(/\s+/)[0]?.replace(/^\\/,"");if(!Y)return j.warn("[ChecksumCalculator] checksum tool returned no output",{tool:J}),null;return Y}catch(X){return j.info("[ChecksumCalculator] checksum tool unavailable, falling back",{tool:J,error:X instanceof Error?X.message:String(X)}),null}}}var $B4;var pC=D(()=>{m();$B4=eO4(tO4)});var cM$={};y4(cM$,{AndroidCtrlProxyManager:()=>H$});import*as J0 from"fs/promises";import*as U0 from"path";import JB4 from"crypto";import RD from"os";var ta,H$;var zX=D(()=>{p$();m();i$();x9();cK();v$();J$();cC();pC();q9();ta=T7(ra(),1);H$=class H${device;adb;static PACKAGE="dev.jasonpearson.automobile.ctrlproxy";static ACTIVITY="dev.jasonpearson.automobile.ctrlproxy.MainActivity";static LEGACY_PACKAGE="dev.jasonpearson.automobile.accessibilityservice";cachedAvailability=null;static AVAILABILITY_CACHE_TTL=3600000;cachedVersionCheck=null;static VERSION_CHECK_CACHE_TTL=60000;cachedInstallation=null;cachedEnabled=null;static STATUS_CACHE_TTL=1800000;cachedToggleCapabilities=null;attemptedAutomatedSetup=!1;static instances=new Map;static expectedChecksumOverride=null;static accessibilityDetectorOverride=null;static prefetchPromise=null;static prefetchedApkPath=null;static prefetchError=null;static adbFactory=r;timer;fileDownloader;checksumCalculator;static defaultFileDownloader=new Bz;static defaultChecksumCalculator=new Fz;constructor($,J,X=y,Y=H$.defaultFileDownloader,Q=H$.defaultChecksumCalculator){if(!(process.env.HOME||a$("os").homedir()))throw Error("Home directory for current user not found");this.device=$,this.adb=J,this.timer=X,this.fileDownloader=Y,this.checksumCalculator=Q}static getInstance($,J=r){if(KY($,"AndroidCtrlProxyManager.getInstance"),!H$.instances.has($.deviceId)){let X,Y;if(J&&typeof J.create==="function")Y=J,X=Y.create($);else if(J){let Q=J;X=Q,Y={create:()=>Q}}else Y=r,X=Y.create($);H$.adbFactory=Y,H$.instances.set($.deviceId,new H$($,X))}return H$.instances.get($.deviceId)}static createForTestingWithDeps($,J,X=y,Y=H$.defaultFileDownloader,Q=H$.defaultChecksumCalculator){return KY($,"AndroidCtrlProxyManager.createForTestingWithDeps"),new H$($,J,X,Y,Q)}static resetInstances(){H$.instances.clear()}static prefetchApk(){if(H$.prefetchPromise!==null){j.info("[CTRL_PROXY] APK prefetch already initiated, skipping");return}let $=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH?.trim();if($&&$.length>0){j.info("[CTRL_PROXY] Using local APK override, skipping prefetch");return}j.info("[CTRL_PROXY] Starting APK prefetch");let J=y.now();H$.prefetchError=null,H$.prefetchPromise=H$.doPrefetch().then((X)=>{let Y=y.now()-J;if(X)H$.prefetchedApkPath=X,j.info(`[CTRL_PROXY] APK prefetch completed in ${Y}ms`,{path:X});return X}).catch((X)=>{let Y=y.now()-J;return H$.prefetchError=X instanceof Error?X:Error(String(X)),j.warn(`[CTRL_PROXY] APK prefetch failed after ${Y}ms`,{error:H$.prefetchError.message}),H$.prefetchPromise=null,null})}static async doPrefetch(){if(H$.isPinnedVersionUnverifiable())return j.warn(`[CTRL_PROXY] Prefetch skipped: AUTOMOBILE_VERSION=${Z6()} is not in the release checksum registry, so the APK cannot be integrity-verified`),null;let $=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-prefetch-")),J=U0.join($,"control-proxy.apk");try{let X=kW();j.info("[CTRL_PROXY] Prefetch: downloading APK",{url:X,destination:J}),await H$.defaultFileDownloader.download(X,J);let Y=await J0.stat(J);if(Y.size<1e4)throw Error(`Prefetched APK is too small (${Y.size} bytes), likely invalid`);H$.verifyApkIntegrityStatic(J);let Q=H$.expectedChecksumOverride??mK();if(Q.length>0){let{checksum:W}=await H$.defaultChecksumCalculator.computeFileSha256(J);if(W.toLowerCase()!==Q.toLowerCase())throw Error(`APK checksum verification failed. Expected: ${Q}, Got: ${W}`);j.info("[CTRL_PROXY] Prefetch: checksum verified",{checksum:W})}return j.info("[CTRL_PROXY] Prefetch: APK ready",{path:J,size:Y.size}),J}catch(X){throw await J0.rm($,{recursive:!0,force:!0}).catch(()=>{}),X}}static async getPrefetchedApkPath(){if(H$.prefetchPromise===null)return null;try{return await H$.prefetchPromise,H$.prefetchedApkPath}catch($){return j.debug(`[CTRL_PROXY] Prefetched APK unavailable: ${$ instanceof Error?$.message:String($)}`,$),null}}static async consumePrefetchedApk($){let J=await H$.getPrefetchedApkPath();if(!J)return!1;try{return await J0.mkdir(U0.dirname($),{recursive:!0}),await J0.copyFile(J,$),j.info("[CTRL_PROXY] Copied prefetched APK",{source:J,destination:$}),!0}catch(X){return j.warn("[CTRL_PROXY] Failed to copy prefetched APK",{error:X instanceof Error?X.message:String(X)}),!1}}static async consumeCompletedPrefetchedApk($){if(!H$.prefetchedApkPath)return!1;try{return await J0.mkdir(U0.dirname($),{recursive:!0}),await J0.copyFile(H$.prefetchedApkPath,$),j.info("[CTRL_PROXY] Copied completed prefetched APK",{source:H$.prefetchedApkPath,destination:$}),!0}catch(J){return j.warn("[CTRL_PROXY] Failed to copy completed prefetched APK",{error:J instanceof Error?J.message:String(J)}),!1}}static async cleanupPrefetchedApk(){if(H$.prefetchedApkPath){try{let $=U0.dirname(H$.prefetchedApkPath);await J0.rm($,{recursive:!0,force:!0}),j.info("[CTRL_PROXY] Cleaned up prefetched APK",{path:$})}catch($){j.warn("[CTRL_PROXY] Failed to clean up prefetched APK",{error:$ instanceof Error?$.message:String($)})}H$.prefetchedApkPath=null}H$.prefetchPromise=null,H$.prefetchError=null}static verifyApkIntegrityStatic($){try{if(!new ta.default($).getEntries().some((Q)=>Q.entryName==="AndroidManifest.xml"))throw Error("AndroidManifest.xml missing")}catch(J){throw Error(`APK integrity check failed: ${J instanceof Error?J.message:String(J)}`)}}static setExpectedChecksumForTesting($){H$.expectedChecksumOverride=$}static setAccessibilityDetectorForTesting($){H$.accessibilityDetectorOverride=$}getAccessibilityDetector(){return H$.accessibilityDetectorOverride||fJ}clearAvailabilityCache(){this.cachedAvailability=null,this.cachedInstallation=null,this.cachedEnabled=null,this.cachedToggleCapabilities=null,this.cachedVersionCheck=null,j.info("[CTRL_PROXY] Cleared all availability caches")}resetSetupState(){this.attemptedAutomatedSetup=!1,this.clearAvailabilityCache(),j.info("[CTRL_PROXY] Reset setup state - next setup will be a full attempt")}async isInstalled(){if(this.cachedInstallation&&this.cachedInstallation.isInstalled){let $=this.timer.now()-this.cachedInstallation.timestamp;if($<H$.STATUS_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached installation status (age: ${$}ms): ${this.cachedInstallation.isInstalled?"installed":"not installed"}`),this.cachedInstallation.isInstalled;else this.cachedInstallation=null}try{j.debug("[CTRL_PROXY] Checking if accessibility service is installed");let J=(await this.adb.executeCommand(`shell pm list packages | grep ${H$.PACKAGE}`,void 0,void 0,!0)).stdout.includes(H$.PACKAGE);return this.cachedInstallation={isInstalled:J,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Service installation status: ${J?"installed":"not installed"} (cached for ${H$.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return j.warn(`[CTRL_PROXY] Error checking installation status: ${$}`),!1}}async isEnabled(){if(this.cachedEnabled&&this.cachedEnabled.isEnabled){let $=this.timer.now()-this.cachedEnabled.timestamp;if($<H$.STATUS_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached enabled status (age: ${$}ms): ${this.cachedEnabled.isEnabled?"enabled":"disabled"}`),this.cachedEnabled.isEnabled;else this.cachedEnabled=null}try{j.debug("[CTRL_PROXY] Checking if accessibility service is enabled");let J=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.includes(H$.PACKAGE);return this.cachedEnabled={isEnabled:J,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Service enabled status: ${J?"enabled":"disabled"} (cached for ${H$.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return j.warn(`[CTRL_PROXY] Error checking enabled status: ${$}`),!1}}async isEnabledForUser($){try{j.debug(`[CTRL_PROXY] Checking if accessibility service is enabled for user ${$}`);let X=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.includes(H$.PACKAGE);return j.debug(`[CTRL_PROXY] Service enabled status for user ${$}: ${X?"enabled":"disabled"}`),X}catch(J){return j.warn(`[CTRL_PROXY] Error checking enabled status for user ${$}: ${J}`),!1}}async isAvailable(){let $=this.timer.now();if(this.cachedAvailability&&this.cachedAvailability.isAvailable){let J=this.timer.now()-this.cachedAvailability.timestamp;if(J<H$.AVAILABILITY_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached overall availability (age: ${J}ms): ${this.cachedAvailability.isAvailable}`),this.cachedAvailability.isAvailable;else this.cachedAvailability=null}j.debug("[CTRL_PROXY] Checking availability (no cached result available)");try{let[J,X]=await Promise.all([this.isInstalled(),this.isEnabled()]),Y=J&&X,Q=this.timer.now()-$;return this.cachedAvailability={isAvailable:Y,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Availability check completed in ${Q}ms - Available: ${Y} (cached for ${H$.AVAILABILITY_CACHE_TTL/1000/60} minutes)`),Y}catch(J){let X=this.timer.now()-$;return j.warn(`[CTRL_PROXY] Availability check failed after ${X}ms: ${J}`),this.cachedAvailability=null,!1}}async getInstalledApkSha256(){return(await this.getInstalledApkSha256WithDetails()).sha256}async isVersionCompatible(){let $=this.getExpectedChecksum();if($.length===0)return j.warn("[CTRL_PROXY] Version check skipped (no checksum provided)"),!0;let J=await this.getInstalledApkSha256();if(!J)return!1;return J.toLowerCase()===$.toLowerCase()}async ensureCompatibleVersion($={}){let J=P$();if(this.assertPinnedVersionVerifiable(),!$.bypassVersionCheckCache&&!$.allowDownloadWhenInstalled){let K=this.getCachedVersionCheckResult();if(K)return K}this.clearServiceAvailabilityCache(),J.startOperation("uninstallLegacy"),await this.uninstallLegacyPackageIfPresent(),J.endOperation("uninstallLegacy");let X=this.getExpectedChecksum();if(X.length===0)if($.allowDownloadWhenInstalled)j.warn("[CTRL_PROXY] Version checksum unavailable; explicit update will install APK without checksum comparison");else return this.cacheVersionCheckResult({status:"skipped",expectedSha256:X});J.startOperation("checkInstalled");let Y=await this.isInstalled();if(J.endOperation("checkInstalled"),Y&&this.shouldSkipDownloadIfInstalled()&&!H$.isKnownExplicitPinConfigured()&&!$.allowDownloadWhenInstalled)return j.warn("[CTRL_PROXY] Skipping APK download/version check (preinstalled APK allowed)"),this.cacheVersionCheckResult({status:"skipped",expectedSha256:X});let Q={status:"compatible",expectedSha256:X},W=!1;if(Y){J.startOperation("getChecksum");let K=await this.getInstalledApkSha256WithDetails();J.endOperation("getChecksum"),Q.installedSha256=K.sha256,Q.installedShaSource=K.source,Q.installedApkPath=K.apkPath;let V=K.sha256;if(W=X.length>0&&!V,X.length>0&&!V&&K.error)j.warn("[CTRL_PROXY] Unable to determine installed APK checksum, forcing reinstall",{error:K.error});if(X.length>0&&V&&V.toLowerCase()===X.toLowerCase())return this.cacheVersionCheckResult(Q);if(X.length>0&&!$.allowDownloadWhenInstalled&&!this.getApkPathOverride()){let U=await this.tryUpgradeFromCompletedPrefetch(Q,J);if(U)return this.cacheVersionCheckResult(U);if(H$.isKnownExplicitPinConfigured())throw H$.createKnownPinMismatchError(X,V);return j.warn("[CTRL_PROXY] Installed APK SHA differs from expected release; accepting preinstalled CtrlProxy for nonblocking readiness",{expected:X,actual:V}),this.queueBackgroundApkRefresh(),this.cacheVersionCheckResult({...Q,status:"skipped",attemptedDownload:!1,acceptedPreinstalled:!0})}if(W)j.warn("[CTRL_PROXY] Installed APK checksum unavailable, forcing reinstall");else j.info("[CTRL_PROXY] Installed APK SHA mismatch, attempting upgrade",{expected:X,actual:V})}else j.info("[CTRL_PROXY] Service not installed, downloading and installing");let G=null;try{return Q.attemptedDownload=!0,J.startOperation("downloadApk"),G=await this.downloadApk(),J.endOperation("downloadApk"),await this.installDownloadedApk(G,Q,Y,W,J)}catch(K){let V=K instanceof Error?K.message:String(K),U=this.isNetworkError(V),z={...Q,status:"failed",downloadUnavailable:U,error:U?"Unable to download the latest accessibility service APK while offline. Connect to the internet and retry.":V};return $.allowDownloadWhenInstalled?z:this.cacheVersionCheckResult(z)}finally{if(G)await this.cleanupApk(G)}}async tryUpgradeFromCompletedPrefetch($,J){if(!H$.prefetchedApkPath)return null;let X=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-prefetch-upgrade-")),Y=U0.join(X,"control-proxy.apk");try{if(!await H$.consumeCompletedPrefetchedApk(Y))return null;let W=await this.installDownloadedApk(Y,{...$,attemptedDownload:!1},!0,!1,J);if(W.status!=="failed")return W;if(this.clearServiceAvailabilityCache(),!await this.isInstalled())return j.warn("[CTRL_PROXY] Completed prefetched APK install failed and existing CtrlProxy is no longer installed",{error:W.error||W.upgradeError||W.reinstallError}),W;if(j.warn("[CTRL_PROXY] Completed prefetched APK install failed; verified existing CtrlProxy remains installed for readiness",{error:W.error||W.upgradeError||W.reinstallError}),H$.isKnownExplicitPinConfigured())throw H$.createKnownPinMismatchError($.expectedSha256??"",$.installedSha256);return{...W,status:"skipped",acceptedPreinstalled:!0}}finally{await this.cleanupApk(Y)}}async installDownloadedApk($,J,X,Y,Q){if(X&&!Y)try{return J.attemptedInstall=!0,Q.startOperation("installApk"),await this.adb.executeCommand(`install -r -d "${$}"`),Q.endOperation("installApk"),j.info("[CTRL_PROXY] APK upgraded successfully"),this.clearAvailabilityCache(),{...J,status:"upgraded"}}catch(W){Q.endOperation("installApk");let G=W instanceof Error?W.message:String(W);j.warn("[CTRL_PROXY] Upgrade failed, attempting reinstall",{error:G}),J.upgradeError=G}try{if(J.attemptedReinstall=!0,X)await this.adb.executeCommand(`shell pm uninstall ${H$.PACKAGE}`);return Q.startOperation("installApk"),await this.install($),Q.endOperation("installApk"),await this.enable(),j.info(`[CTRL_PROXY] APK ${X?"reinstalled":"installed"} and service enabled`),this.clearAvailabilityCache(),{...J,status:X?"reinstalled":"installed"}}catch(W){let G=W instanceof Error?W.message:String(W);return j.warn(`[CTRL_PROXY] APK reinstall failed: ${G}`,W),this.clearServiceAvailabilityCache(),{...J,status:"failed",reinstallError:G}}}async downloadApk(){this.assertPinnedVersionVerifiable();let $=P$(),J=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-")),X=U0.join(J,"control-proxy.apk");try{let Y=this.getApkPathOverride();if($.startOperation("httpDownload"),Y){if(j.info("Using local accessibility service APK",{path:Y}),!(await J0.stat(Y)).isFile())throw Error(`Accessibility APK override is not a file: ${Y}`);await J0.copyFile(Y,X)}else if(await H$.consumePrefetchedApk(X))j.info("Using prefetched accessibility service APK",{path:X});else{let K=kW();j.info("Downloading APK",{url:K,destination:X}),await this.fileDownloader.download(K,X)}$.endOperation("httpDownload");let Q=await J0.stat(X);if(Q.size<1e4)throw Error(`Downloaded APK is too small (${Q.size} bytes), likely invalid`);this.verifyApkIntegrity(X);let W=this.getExpectedChecksum();if(W.length>0){$.startOperation("checksumVerify");let{checksum:G,source:K}=await this.checksumCalculator.computeFileSha256(X),V=G.toLowerCase(),U=W.toLowerCase();if(V!==U)throw j.warn("APK checksum verification failed",{expected:U,actual:V}),Error(`APK checksum verification failed. Expected: ${U}, Got: ${V}`);j.info("APK checksum verified successfully",{checksum:V,source:K}),$.endOperation("checksumVerify")}else j.warn("APK checksum verification SKIPPED - no checksum provided (development mode)",{apkUrl:kW()});return j.info("APK downloaded successfully",{path:X,size:Q.size}),X}catch(Y){try{await this.cleanupApk(X)}catch(Q){j.debug(`[CTRL_PROXY] Failed to clean up incomplete APK download: ${Q instanceof Error?Q.message:String(Q)}`,Q)}throw Error(`Failed to download APK: ${Y instanceof Error?Y.message:String(Y)}`)}}verifyApkIntegrity($){try{if(!new ta.default($).getEntries().some((Q)=>Q.entryName==="AndroidManifest.xml"))throw Error("AndroidManifest.xml missing")}catch(J){throw Error(`APK integrity check failed: ${J instanceof Error?J.message:String(J)}`)}}async uninstallLegacyPackageIfPresent(){try{if(!(await this.adb.executeCommand(`shell pm list packages | grep ${H$.LEGACY_PACKAGE}`,void 0,void 0,!0)).stdout.includes(H$.LEGACY_PACKAGE))return;j.info(`[CTRL_PROXY] Found legacy package ${H$.LEGACY_PACKAGE}, uninstalling`),await this.adb.executeCommand(`shell pm uninstall ${H$.LEGACY_PACKAGE}`),j.info("[CTRL_PROXY] Legacy package uninstalled")}catch($){j.warn(`[CTRL_PROXY] Failed to check/uninstall legacy package: ${$}`)}}async install($){try{j.info("Installing APK",{path:$});let J=await this.adb.executeCommand(`install "${$}"`),X=J.toString().toLowerCase();if(X.includes("failure")||X.includes("error"))throw Error(`Installation failed: ${J.toString()}`);if(!X.includes("success"))j.warn("Installation result unclear",{result:J.toString()});j.info("APK installed successfully")}catch(J){throw Error(`Failed to install APK: ${J instanceof Error?J.message:String(J)}`)}}async enableViaSettings(){let $=await this.getToggleCapabilities();if(!$.supportsSettingsToggle){let J=`Settings-based accessibility toggle is not supported on this device. ${$.reason||""}`;throw j.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{j.info("Enabling Accessibility Service via settings commands");let J=P$();J.startOperation("readCurrentServices");let X=await this.adb.executeCommand("shell settings get secure enabled_accessibility_services");J.endOperation("readCurrentServices");let Y=X.stdout.trim();if(Y==="null"||Y==="")Y="";let Q=`${H$.PACKAGE}/${H$.PACKAGE}.CtrlProxy`;if(J.startOperation("writeServiceEnabled"),Y.includes(Q))j.info("Accessibility Service is already enabled");else{let W=Y?`${Y}:${Q}`:Q;await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${W}"`),j.info("Added AutoMobile service to enabled_accessibility_services")}await this.adb.executeCommand("shell settings put secure accessibility_enabled 1"),J.endOperation("writeServiceEnabled"),j.info("Accessibility Service enabled successfully via settings"),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(J){let X=J instanceof Error?J.message:String(J),Y=X.toLowerCase();if(Y.includes("permission denied")||Y.includes("not permitted"))throw Error(`Permission denied while enabling Accessibility Service. The device may require root access, device owner status, or special shell permissions. Original error: ${X}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service. Ensure the device is connected and adb is responsive. Original error: ${X}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service. The device may be unresponsive. Original error: ${X}`);else throw Error(`Failed to enable Accessibility Service via settings. This may indicate an ADB communication issue or device state problem. Original error: ${X}`)}}async disableViaSettings(){let $=await this.getToggleCapabilities();if(!$.supportsSettingsToggle){let J=`Settings-based accessibility toggle is not supported on this device. ${$.reason||""}`;throw j.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{j.info("Disabling Accessibility Service via settings commands");let X=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(X==="null"||X===""){j.info("No accessibility services enabled");return}let Y=X.split(":"),Q=Y.filter((W)=>!W.includes(H$.PACKAGE));if(Q.length===Y.length)j.info("Accessibility Service was not enabled");else{let W=Q.join(":");if(await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${W}"`),j.info("Removed AutoMobile service from enabled_accessibility_services"),Q.length===0||Q.length===1&&Q[0]==="")await this.adb.executeCommand("shell settings put secure accessibility_enabled 0"),j.info("Disabled accessibility globally (no other services remain)")}j.info("Accessibility Service disabled successfully via settings"),this.clearAvailabilityCache()}catch(J){let X=J instanceof Error?J.message:String(J),Y=X.toLowerCase();if(Y.includes("permission denied")||Y.includes("not permitted"))throw Error(`Permission denied while disabling Accessibility Service. The device may require root access, device owner status, or special shell permissions. Original error: ${X}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while disabling Accessibility Service. Ensure the device is connected and adb is responsive. Original error: ${X}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while disabling Accessibility Service. The device may be unresponsive. Original error: ${X}`);else throw Error(`Failed to disable Accessibility Service via settings. This may indicate an ADB communication issue or device state problem. Original error: ${X}`)}}async enable(){return this.enableViaSettings()}async enableForUser($){let J=await this.getToggleCapabilities();if(!J.supportsSettingsToggle){let X=`Settings-based accessibility toggle is not supported on this device. ${J.reason||""}`;throw j.error("[CTRL_PROXY] "+X,{capabilities:J}),Error(X)}try{j.info(`[CTRL_PROXY] Enabling Accessibility Service via settings commands for user ${$}`);let Y=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.trim();if(Y==="null"||Y==="")Y="";let Q=`${H$.PACKAGE}/${H$.PACKAGE}.CtrlProxy`;if(Y.includes(Q))j.info(`[CTRL_PROXY] Accessibility Service is already enabled for user ${$}`);else{let W=Y?`${Y}:${Q}`:Q;await this.adb.executeCommand(`shell settings --user ${$} put secure enabled_accessibility_services "${W}"`),j.info(`[CTRL_PROXY] Added AutoMobile service to enabled_accessibility_services for user ${$}`)}await this.adb.executeCommand(`shell settings --user ${$} put secure accessibility_enabled 1`),j.info(`[CTRL_PROXY] Accessibility Service enabled successfully via settings for user ${$}`),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(X){let Y=X instanceof Error?X.message:String(X),Q=Y.toLowerCase();if(Q.includes("permission denied")||Q.includes("not permitted"))throw Error(`Permission denied while enabling Accessibility Service for user ${$}. The device may require root access, device owner status, or special shell permissions. Original error: ${Y}`);else if(Q.includes("device not found")||Q.includes("no devices")||Q.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service for user ${$}. Ensure the device is connected and adb is responsive. Original error: ${Y}`);else if(Q.includes("timeout")||Q.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service for user ${$}. The device may be unresponsive. Original error: ${Y}`);else throw Error(`Failed to enable Accessibility Service via settings for user ${$}. This may indicate an ADB communication issue or device state problem. Original error: ${Y}`)}}async cleanupApk($){try{let J=U0.resolve(RD.tmpdir()),X=U0.resolve(U0.dirname($)),Y=U0.basename(X),Q=U0.relative(J,X),W=Boolean(Q)&&!Q.startsWith("..")&&!U0.isAbsolute(Q)&&Y.startsWith("auto-mobile-");if(await J0.rm($,{force:!0}),W)await J0.rm(X,{recursive:!0,force:!0}),j.info("Temporary APK directory cleaned up",{path:X});else j.info("Temporary APK file cleaned up",{path:$})}catch(J){j.warn("Failed to clean up temporary APK file",{path:$,error:J instanceof Error?J.message:String(J)})}}async setup($=!1,J=new a){J.serial("a11yServiceSetup");let X=null;if(this.attemptedAutomatedSetup){try{let[Y,Q]=await J.track("recheckStatus",async()=>{return Promise.all([this.isInstalled(),this.isEnabled()])});if(Y&&Q)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()}}catch(Y){j.warn(`[CTRL_PROXY] Failed to re-check service status: ${Y}`)}return J.end(),{success:!1,message:"Setup already attempted",perfTiming:J.getTimings()}}try{let Y=await J.track("ensureCompatibleVersion",()=>this.ensureCompatibleVersion());if(Y.status==="failed")return J.end(),{success:!1,message:"Failed to ensure compatible Accessibility Service version",error:Y.error||Y.upgradeError||Y.reinstallError,perfTiming:J.getTimings()};if(Y.status==="upgraded"||Y.status==="installed"||Y.status==="reinstalled")return J.end(),{success:!0,message:"Accessibility Service upgraded to a compatible version",perfTiming:J.getTimings()};let Q=await J.track("checkInstalled",()=>this.isInstalled()),W=await J.track("checkEnabled",()=>this.isEnabled());if(!$&&Q&&W)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()};if(this.attemptedAutomatedSetup=!0,$||!Q)X=await J.track("downloadApk",()=>this.downloadApk()),await J.track("installApk",()=>this.install(X));if(!W)await J.track("enableService",()=>this.enable());return J.end(),{success:!0,message:"Accessibility Service installed and activated successfully",perfTiming:J.getTimings()}}catch(Y){let Q=Y instanceof Error?Y.message:String(Y),W=Q.toLowerCase(),G="Failed to setup Accessibility Service";if(W.includes("permission denied")||W.includes("not permitted"))G="Failed to setup Accessibility Service due to permission error";else if(W.includes("device not found")||W.includes("no devices")||W.includes("offline"))G="Failed to setup Accessibility Service due to device connection issue";else if(W.includes("timeout")||W.includes("timed out"))G="Failed to setup Accessibility Service due to timeout";else if(W.includes("download")||W.includes("network")||W.includes("unreachable"))G="Failed to setup Accessibility Service due to network/download error";else if(W.includes("not supported"))G="Failed to setup Accessibility Service - settings toggle not supported on this device";else if(W.includes("installation failed")||W.includes("install"))G="Failed to setup Accessibility Service due to APK installation error";return J.end(),{success:!1,message:G,error:Q,perfTiming:J.getTimings()}}finally{if(X)await this.cleanupApk(X)}}async isEmulator(){try{if((await this.adb.executeCommand("shell getprop ro.kernel.qemu",void 0,void 0,!0)).stdout.trim()==="1")return[!0,!1];let Y=(await this.adb.executeCommand("shell getprop ro.product.model",void 0,void 0,!0)).stdout.trim().toLowerCase();return[Y.includes("emulator")||Y.includes("sdk"),!1]}catch($){return j.warn("[CTRL_PROXY] Error detecting device type",{error:$}),[!1,!0]}}async getApiLevel(){try{let $=await this.adb.executeCommand("shell getprop ro.build.version.sdk",void 0,void 0,!0),J=parseInt($.stdout.trim(),10);return[isNaN(J)?null:J,!1]}catch($){return j.warn("[CTRL_PROXY] Error getting API level",{error:$}),[null,!0]}}async canUseSettingsToggle(){return(await this.getToggleCapabilities()).supportsSettingsToggle}async getToggleCapabilities(){if(this.cachedToggleCapabilities)return j.info("[CTRL_PROXY] Using cached toggle capabilities"),this.cachedToggleCapabilities;j.info("[CTRL_PROXY] Detecting toggle capabilities");let[$,J]=await this.isEmulator(),[X,Y]=await this.getApiLevel(),Q=$?"emulator":"physical",W=!1,G,K=J||Y;if(K)W=!1,G="Unable to detect device capabilities due to transient error. Retry may succeed.",j.warn("[CTRL_PROXY] Detection error - not caching result",{emulatorDetectionError:J,apiLevelDetectionError:Y});else if($)W=!0,j.info("[CTRL_PROXY] Emulator detected - settings toggle supported");else W=!1,G="Physical devices may require root, device owner status, or special shell permissions for programmatic accessibility toggle",j.info("[CTRL_PROXY] Physical device detected - settings toggle may not be supported",{reason:G});if(!K&&X!==null&&X<16)W=!1,G=`API level ${X} is too old (requires API 16+)`,j.warn("[CTRL_PROXY] API level too old for settings toggle",{apiLevel:X});let V={supportsSettingsToggle:W,deviceType:Q,apiLevel:X,reason:G};if(!K)this.cachedToggleCapabilities=V,j.info("[CTRL_PROXY] Toggle capabilities detected and cached",V);else j.info("[CTRL_PROXY] Toggle capabilities detected but not cached due to detection errors",V);return V}async getInstalledApkSha256WithDetails(){let $=await this.getInstalledApkPath();if(!$)return{sha256:null,source:"none",error:"Installed APK path not found"};try{let W=(await this.adb.executeCommand(`shell sha256sum "${$}"`)).stdout.trim().split(/\s+/)[0];if(W)return{sha256:W,source:"device",apkPath:$}}catch(Q){j.warn("[CTRL_PROXY] sha256sum unavailable or failed, falling back to host hash",{error:Q instanceof Error?Q.message:String(Q)})}let J=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-apk-")),X=(this.device.deviceId||"device").replace(/[^a-zA-Z0-9_.-]/g,"_"),Y=U0.join(J,`control-proxy-installed-${X}.apk`);try{await this.adb.executeCommand(`pull "${$}" "${Y}"`);let Q=await J0.readFile(Y);return{sha256:JB4.createHash("sha256").update(Q).digest("hex"),source:"host",apkPath:$}}catch(Q){return j.warn("[CTRL_PROXY] Failed to compute installed APK hash via host fallback",{error:Q instanceof Error?Q.message:String(Q)}),{sha256:null,source:"none",apkPath:$,error:Q instanceof Error?Q.message:String(Q)}}finally{try{await J0.rm(J,{recursive:!0,force:!0})}catch(Q){j.debug(`[CTRL_PROXY] Failed to remove temporary APK hash directory: ${Q instanceof Error?Q.message:String(Q)}`,Q)}}}async getInstalledApkPath(){try{let J=(await this.adb.executeCommand(`shell pm path ${H$.PACKAGE}`,void 0,void 0,!0)).stdout.split(`
169
+ Suggestion: ${_.suggestion}`;V=new C(F)}else{let F=this.detectArchitecturePanic(q);if(F.isPanic)V=new C(`Emulator failed to start: ${F.message}`);else V=new C(`Emulator process exited with code ${B} while waiting for readiness`)}j.error(`Emulator process exited during readiness wait: ${V.message}`)}})}let U=!0,z=null;W.startOperation("devicePolling");let H=(async()=>{while(U&&!z){try{j.debug(`Background polling iteration - checking for emulator '${$}'...`),j.debug("Checking for running local emulators...");let L=await this.getBootedDevices();if(j.debug(`Device scan complete - found ${L.length} running emulators`),L.length>0){j.debug(`Found ${L.length} running emulators: ${L.map((q)=>`${q.name}(${q.deviceId})`).join(", ")}`);let O=Y??this.getLaunchTargetDeviceId(X),B=O?L.find((q)=>q.deviceId===O):void 0;if(O){if(j.debug(`Exact deviceId match for '${O}': ${B?`Found ${B.deviceId}`:"Not found"}`),B&&!this.matchesRequestedAvdOrUnknown(B,$,O))j.debug(`Exact deviceId match ${B.deviceId} resolved as '${B.name}', not requested AVD '${$}'`),B=void 0}if(!B&&!O)B=L.find((q)=>q.name===$),j.debug(`Exact name match for '${$}': ${B?`Found ${B.deviceId}`:"Not found"}`);if(B&&B.deviceId){j.debug(`Target emulator found: ${B.name} (${B.deviceId}) - starting readiness checks`),j.debug(`[PARALLEL] Running device state, package manager, and boot-complete checks for ${B.deviceId}...`);let q=this.adbFactory.create(B);try{W.startOperation("adbParallelChecks");let[w,_,F,A]=await Promise.allSettled([q.executeCommand("get-state"),q.executeCommand("shell pm list packages"),q.executeCommand("shell getprop sys.boot_completed"),q.executeCommand("shell getprop init.svc.bootanim")]);if(W.endOperation("adbParallelChecks"),w.status!=="fulfilled"||_.status!=="fulfilled"||F.status!=="fulfilled"||A.status!=="fulfilled")j.debug(`[PARALLEL] Checks not yet complete: deviceStatus: ${w.status}, packageManager: ${_.status}, sysBootCompleted: ${F.status}, bootAnimation: ${A.status}`);else{let M=w.value.stdout.trim(),P=F.value.stdout.trim(),k=A.value.stdout.trim();if(j.debug(`[PARALLEL] Package manager command completed for ${B.deviceId} - output: ${_.value.stdout.length} bytes`),!M.includes("device"))j.debug(`[PARALLEL] \u274C Device state check failed for ${B.deviceId}: state="${M}"`);else if(!_.value.stdout||!_.value.stdout.includes("package:"))j.debug(`[PARALLEL] \u274C Package manager returned no packages for ${B.deviceId} (${_.value.stdout.length} bytes output)`);else if(_.value.stderr||_.value.stderr.includes("Failure"))j.debug(`[PARALLEL] \u274C Package manager returned failure for ${B.deviceId}: ${_.value.stderr}`);else if(P!=="1")j.debug(`[PARALLEL] \u274C sys.boot_completed is not set for ${B.deviceId}: "${P}"`);else if(k&&k!=="stopped")j.debug(`[PARALLEL] \u274C boot animation is still active for ${B.deviceId}: "${k}"`);else{j.debug(`[PARALLEL] \u2705 Device state check passed for ${B.deviceId}`),j.debug(`[PARALLEL] \u2705 Package manager is responsive for ${B.deviceId} - emulator is ready!`),j.debug(`[PARALLEL] \u2705 Android boot-complete signals are ready for ${B.deviceId}`),j.debug("[PARALLEL] \u2705 No package manager errors detected - marking emulator as ready"),z=B.deviceId;return}}}catch(w){j.debug(`[PARALLEL] \u274C Parallel checks failed for ${B.deviceId}: ${w}`)}}else j.debug(`No suitable emulator found for '${$}' - will continue polling`)}else j.debug("No running emulators detected - will continue polling")}catch(L){j.debug(`Background polling error (will continue): ${L}`)}j.debug(`Background polling cycle complete - sleeping ${G}ms before next check`),await this.sleep(G)}j.debug(`Background polling stopped - pollingActive: ${U}, foundDeviceId: ${z}`)})();while(this.timer.now()-Q<J){if(K&&V)throw U=!1,await H,W.endOperation("devicePolling"),V;if(z){U=!1,W.endOperation("devicePolling"),j.info(`Emulator '${$}' is ready! Device ID: ${z}`);let L={name:$,platform:"android",deviceId:z};return W.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(L),W.endOperation("wakeAndUnlock"),L}await this.sleep(500)}if(U=!1,await H,W.endOperation("devicePolling"),z){j.info(`Emulator '${$}' is ready! Device ID: ${z}`);let L={name:$,platform:"android",deviceId:z};return W.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(L),W.endOperation("wakeAndUnlock"),L}throw new C(`Emulator '${$}' failed to become ready within ${J}ms`)}async wakeAndUnlock($){let J=this.adbFactory.create($);try{let X=await J.getWakefulness();if(j.info(`[WakeAndUnlock] Device wakefulness state: ${X}`),X!=="Awake")j.info("[WakeAndUnlock] Device not awake, sending KEYCODE_WAKEUP"),await J.executeCommand("shell input keyevent KEYCODE_WAKEUP"),await this.sleep(500);j.info("[WakeAndUnlock] Dismissing keyguard"),await J.executeCommand("shell wm dismiss-keyguard");let Y=await J.getWakefulness();j.info(`[WakeAndUnlock] Final wakefulness state: ${Y}`)}catch(X){j.warn(`[WakeAndUnlock] Failed to wake/unlock device: ${X}`)}}sleep($){return this.timer.sleep($)}}var HO4=async($)=>{let J=await UO4(GO4)($);return{stdout:J.stdout,stderr:J.stderr,toString(){return this.stdout},trim(){return this.stdout.trim()},includes(Y){return this.stdout.includes(Y)}}};var XH=D(()=>{m();i$();p$();eZ();J$();v$();$M$()});class f9{adb;emulator;simctl;constructor($=null,J=null,X=null){this.adb=$||r.create(null),this.simctl=J||new $4,this.emulator=X||new tX}async canDiscoverIosLocally(){if(process.platform==="darwin")return!0;try{return await this.simctl.isAvailable()}catch($){return j.debug(`src/utils/deviceUtils.ts fallback failed: ${$}`,$),!1}}async listIosDeviceImagesIfAvailable($){if(!await this.canDiscoverIosLocally())return[];try{return await this.simctl.listSimulatorImages()}catch(J){if(j.warn(`[DeviceManager] iOS simulator image discovery failed: ${J}`),!$.swallowDiscoveryErrors)throw J;return[]}}async getBootedIosDevicesIfAvailable(){if(!await this.canDiscoverIosLocally())return[];try{return await this.simctl.getBootedSimulators()}catch{return[]}}async listDeviceImages($){switch($){case"android":return this.emulator.listAvds();case"ios":return this.listIosDeviceImagesIfAvailable({swallowDiscoveryErrors:!1});case"either":let J=await this.emulator.listAvds(),X=await this.listIosDeviceImagesIfAvailable({swallowDiscoveryErrors:!0});return[...J,...X]}}async isDeviceImageRunning($){switch($.platform){case"android":return this.emulator.isAvdRunning($.name);case"ios":if(!await this.canDiscoverIosLocally())return!1;if($.deviceId)return(await this.simctl.getBootedSimulators()).some((X)=>X.deviceId===$.deviceId);return this.simctl.isSimulatorRunning($.name)}}async getBootedDevices($){switch($){case"android":return this.emulator.getBootedDevices();case"ios":return this.getBootedIosDevicesIfAvailable();case"either":let J=await this.emulator.getBootedDevices(),X=await this.getBootedIosDevicesIfAvailable();return[...J,...X]}}async getBootedDevicesDetailed($){let J=[],X=new Set;if($==="android"||$==="either")try{let Y=await this.emulator.getBootedDevicesChecked();J.push(...Y),X.add("android")}catch(Y){j.warn(`[DeviceManager] Android booted-device discovery failed; retaining tracked Android devices: ${Y}`)}if($==="ios"||$==="either"){let Y=await this.discoverBootedIosDevices();if(Y.succeeded)J.push(...Y.devices),X.add("ios")}return{devices:J,succeededPlatforms:X}}async discoverBootedIosDevices(){if(!await this.canDiscoverIosLocally())return{devices:[],succeeded:!1};try{return{devices:await this.simctl.getBootedSimulatorsChecked(),succeeded:!0}}catch($){return j.warn(`[DeviceManager] iOS booted-device discovery failed; retaining tracked iOS devices: ${$}`),{devices:[],succeeded:!1}}}async startDevice($,J=hK){if(await this.isDeviceImageRunning($))throw new C(`${$.platform} device '${$.name}' is already running`);switch($.platform){case"android":return this.emulator.startEmulator($.name);case"ios":return this.simctl.startSimulator($.deviceId??$.name,J);default:throw new C("Unknown platform")}}async killDevice($){switch($.platform){case"android":return this.emulator.killDevice($);case"ios":return this.simctl.killSimulator($)}}async waitForDeviceReady($,J=hK,X){switch($.platform){case"android":return this.emulator.waitForEmulatorReady($.name,J,X,$.deviceId);case"ios":return this.simctl.waitForSimulatorReady($.deviceId??$.name,J);default:throw new C("Unknown platform")}}}var jz=D(()=>{i$();p$();l1();XH();m()});import ma from"crypto";class BJ{generateCacheKey($){return ma.createHash("md5").update($).digest("hex")}verifyChecksum($,J){return ma.createHash("sha256").update($).digest("hex").toLowerCase()===J.toLowerCase()}static generateCacheKey=($)=>new BJ().generateCacheKey($);static verifyChecksum=($,J)=>new BJ().verifyChecksum($,J)}var gK=()=>{};import*as uK from"fs/promises";import*as YM$ from"path";class a7{adb;cachedActiveWindow=null;device;cacheDir=$J(M0.WINDOW);constructor($,J=r){this.adb=J.create($),this.device=$}getCacheFilePath(){let $=BJ.generateCacheKey(this.device.deviceId);return YM$.join(this.cacheDir,$)}getDeviceId(){return this.device.deviceId}async writeCacheToDisk($){let J=this.getCacheFilePath();if(!J){j.info("[WINDOW] No device ID, skipping disk cache write");return}try{await uK.mkdir(this.cacheDir,{recursive:!0}),await uK.writeFile(J,JSON.stringify($),"utf-8"),j.debug(`Wrote active window cache to disk: ${J}`)}catch(X){j.error(`Failed to write cache to disk: ${X}`)}}async readCacheFromDisk(){let $=this.getCacheFilePath();if(!$)return j.info("[WINDOW] No device ID, skipping disk cache read"),null;try{let J=await uK.readFile($,"utf-8"),X=JSON.parse(J);return j.debug(`Read active window cache from disk: ${$}`),X}catch(J){return j.debug(`No disk cache found or error reading: ${J}`),null}}async setCachedActiveWindow($){this.cachedActiveWindow=$,await this.writeCacheToDisk($),j.info("[WINDOW] Cached active window from external source")}async clearCache(){this.cachedActiveWindow=null;let $=this.getCacheFilePath();if($)try{await uK.unlink($),j.info("[WINDOW] Cleared cached active window from disk")}catch(J){j.debug(`Could not remove disk cache: ${J}`)}j.info("[WINDOW] Cleared cached active window")}async getCachedActiveWindow(){if(!this.cachedActiveWindow){j.info("[WINDOW] Using disk cached active window");let $=await this.readCacheFromDisk();if($)return this.cachedActiveWindow=$,j.info("[WINDOW] Using disk cached active window"),$}return this.cachedActiveWindow}async getActive($=!1,J=new a){if(!$&&this.cachedActiveWindow)return j.info("[WINDOW] Using memory cached active window"),this.cachedActiveWindow;if(!$&&!this.cachedActiveWindow){j.info("[WINDOW] Using disk cached active window");let X=await J.track("readDiskCache",()=>this.readCacheFromDisk());if(X)return this.cachedActiveWindow=X,j.info("[WINDOW] Using disk cached active window"),X}try{let{stdout:X}=await J.track("adbDumpsysWindowWindows",()=>this.adb.executeCommand('shell "dumpsys window windows"')),Y=null;if(typeof this.adb.getAndroidApiLevel==="function")Y=await this.adb.getAndroidApiLevel();let Q=null;if(Y!==null&&Y!==void 0&&Y<=27){if(Q=XM$(X),!Q)Q=LO4(X);if(!Q)Q=await this.parseActiveWindowFromDumpsysWindow();if(!Q)Q=JM$(X)}else Q=JM$(X);let W=Q?.appId??"",G=Q?.activityName??"",K=0,V=X.matchAll(/mLayoutSeq=([\d\.]+)/g);if(V)for(let z of V){let Z=parseInt(z[1],10);if(!isNaN(Z))K+=Z}let U={appId:W,activityName:G,layoutSeqSum:K};if(this.cachedActiveWindow=U,await this.writeCacheToDisk(U),j.info("[WINDOW] Cached new active window information"),!W||!G){let z=X.trim().slice(0,200);j.warn(`[WINDOW] Failed to parse active window from dumpsys output. Sample: ${z||"<empty>"}`)}return U}catch(X){return j.error(`Failed to get active window information: ${X}`),{appId:"",activityName:"",layoutSeqSum:0}}}async parseActiveWindowFromDumpsysWindow(){try{let{stdout:$}=await this.adb.executeCommand('shell "dumpsys window"');return XM$($)}catch($){return j.error(`Failed to get dumpsys window for legacy fallback: ${$}`),null}}async getActiveHash($=new a){j.info("[WINDOW] Getting hash of active window");let J=await this.getActive(!0,$),X=JSON.stringify(J);return BJ.generateCacheKey(X)}}function JM$($){let J="",X="",Y=$.match(/imeControlTarget.*?Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(Y&&Y.length>=3)J=Y[1],X=Y[2];else{let Q=$.match(/imeControlTarget.*?Window\{([0-9a-f]+)\s+u\d+\s+Pop-Up Window\}/i);if(Q){let W=Q[1],G=new RegExp(`Window #\\d+ Window\\{${W} u\\d+ Pop-Up Window\\}:([\\s\\S]*?)(?=Window #\\d+|$)`),K=$.match(G);if(K){let V=K[1].match(/mActivityRecord=ActivityRecord\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)(?:\s+t\d+)?\}/);if(V&&V.length>=3)J=V[1],X=V[2]}}if(!J||!X){let W=$.matchAll(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?mViewVisibility=0x0[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs);for(let G of W)if(G[1]&&G[2]&&!G[1].includes("android.systemui")&&!G[1].includes("nexuslauncher")){J=G[1],X=G[2];break}if(!J||!X){let G=$.match(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION/);if(G&&G.length>=3)J=G[1],X=G[2]}}if(!J||!X){let G=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs.exec($);if(G&&G.length>=3)J=G[1],X=G[2]}}if(J&&X)return{appId:J,activityName:X};return null}function LO4($){let J=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:([\s\S]*?)(?=Window #\d+|$)/g,X=[...$.matchAll(J)];for(let Y of X){let Q=Y[1],W=Y[2],G=Y[3];if(!Q||!W)continue;if(Q.includes("android.systemui")||Q.includes("nexuslauncher"))continue;if(/\bty=1\b/.test(G)&&/isReadyForDisplay\(\)=true/.test(G))return{appId:Q,activityName:W}}return null}function XM$($){let J=$.match(/mCurrentFocus=Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(J&&J.length>=3)return{appId:J[1],activityName:J[2]};let X=$.match(/mFocusedApp=AppWindowToken\{[^}]*?\s+([^\s/]+)\/([^\s}]+)/);if(X&&X.length>=3)return{appId:X[1],activityName:X[2]};return null}var YH=D(()=>{p$();m();gK();v$();dX()});function KY($,J){let X=$;if(!X||typeof X!=="object"||typeof X.deviceId!=="string"||X.deviceId.length===0||X.platform!=="android"&&X.platform!=="ios")throw Error(`${J}: expected BootedDevice, got ${OO4($)}`)}function OO4($){if(typeof $==="string")return`string "${$}"`;try{return JSON.stringify($)??String($)}catch{return Object.prototype.toString.call($)}}function QM$($,J,X=VY){if(X.length===0)return"";let Q=$.trim().toLowerCase()===$9?X[0]:X.find((W)=>W.version===$);if(!Q)return"";return J==="android"?Q.apkSha256:Q.ipaSha256}function pa($=process.env,J=VY){if(J.length===0)return"";let X=Z6($);return(X===$9?J[0]:J.find((Q)=>Q.version===X))?.runnerSha256??""}function BO4($=VY){if($.length===0)return $9;return $[0].version}function n0($,J=VY){if($===$9)return BO4(J);return $}function Z6($=process.env){let J=$[DO4]?.trim();if(!J||J.length===0)return $9;return J.toLowerCase()===$9?$9:J}function bW($=process.env){return Z6($)!==$9}function Zz($=process.env,J=VY){let X=Z6($);if(X===$9)return J.length>0;return J.some((Y)=>Y.version===X)}function WM$($=process.env){let J=$[la]?.trim();if(J&&J.length>0){let X;try{X=new URL(J)}catch{throw new C(`${la} must be an absolute URL, for example https://mirror.example/auto-mobile.`)}if(J.includes("?")||J.includes("#"))throw new C(`${la} must not include a query string or fragment; use a path-only base URL such as ${X.origin}${X.pathname.replace(/\/+$/,"")}.`);return`${X.origin}${X.pathname}`.replace(/\/+$/,"")}return ca}function GM$($,J,X=ca,Y=VY){let Q=n0(J,Y);if(Q===$9){if(X===ca)return`https://github.com/kaeawc/auto-mobile/releases/latest/download/${$}`;return`${X}/latest/${$}`}return`${X}/${Q}/${$}`}function kW($=process.env,J=VY){return GM$("control-proxy-debug.apk",Z6($),WM$($),J)}function Hz($=process.env,J=VY){return GM$("control-proxy.ipa",Z6($),WM$($),J)}function mK($=process.env){return QM$(Z6($),"android")}function Lz($=process.env){return QM$(Z6($),"ios")}function P8($=process.env){return`${FO4}@${n0(Z6($))}`}var $9="latest",VY,FO4="@kaeawc/auto-mobile",DO4="AUTOMOBILE_VERSION",la="AUTOMOBILE_ASSET_BASE_URL",ca="https://github.com/kaeawc/auto-mobile/releases/download",xD6,vD6,yD6,hD6,gC="",gD6;var x9=D(()=>{a0();VY=[{version:"0.0.42",apkSha256:"cb00a835f58ce2d0344483f27b7c35036bb6faa973aa3fcc66fe67e75428abb0",ipaSha256:"de55b77ee0e821b4f08b7cd1b84f9a2706f69279422901546e2dc6fdd4cc3f0f",runnerSha256:"b281f9fd516116164a76dc049a413d5123bfb7bf96c79c6ad654ba90c08ed982"},{version:"0.0.41",apkSha256:"ee1dff240e4dfc89b016197c80e929797485aa23292e061eee361b7404c772b4",ipaSha256:"01eaedef0cfcf38acd0a1fa8eebe08c3009e5db59320b23a045cd26506eb235c",runnerSha256:"b281f9fd516116164a76dc049a413d5123bfb7bf96c79c6ad654ba90c08ed982"},{version:"0.0.40",apkSha256:"8e89fbab6462ac1ead1f3f0a334aff4f5f299e7ae72e192045cf75e893ca87aa",ipaSha256:"38adaed641ac6a8590773682e127a80a86c54e5804d47394e1b0cd437009b9ff",runnerSha256:"b281f9fd516116164a76dc049a413d5123bfb7bf96c79c6ad654ba90c08ed982"},{version:"0.0.39",apkSha256:"eaad59dd85e17c4633098b772b9f761f2124ffb73a5ca7ede703a9b435046942",ipaSha256:"87a720544c83718e5b70c987aecf30d2e43bdb0f23163ac75ac225bb4aec0ae4",runnerSha256:""},{version:"0.0.38",apkSha256:"0fb955a617654695036642662634d042c2e3d278b8e1dce20ccb37e425f059f3",ipaSha256:"f5a4a485ff8ebf3bfd0d73c8b7b10769177b419ccd62e48db188bb5122a2fcde",runnerSha256:""},{version:"0.0.37",apkSha256:"f9b0cc92bf8f7416cdb0c458e16c7a41e4fdeefb80bb9429ab7c603388c99083",ipaSha256:"caccbfaa4da0015bab701a36b81ac87e3f3f3330cee77bb10ec8553724275f4f",runnerSha256:""},{version:"0.0.36",apkSha256:"b5f56bb0ab065c60385a22013c97ee706213eb16deb5d4bcfa42f0a707b8620a",ipaSha256:"40e973dc8c87149e40a616658c74d90e648c6514cc642a5c3dd4a45a187e7600",runnerSha256:""},{version:"0.0.35",apkSha256:"039b359bcf35f1ab6cc666005a57823d71a771a96bd9bcaf4f82f2ec945e306d",ipaSha256:"e6afdfd04a90d2388dc4604e7957d3eef87b90a51ca37c5457b8139a54728108",runnerSha256:""},{version:"0.0.34",apkSha256:"4dcee4f6a7359847d081c5e184c57ed100ad135af2e62f3abfc7b0defaa1153c",ipaSha256:"c2a26ca065c85e9f8d5cfcd6dbad1dbaf3ce38b18d770b0983f7bad62129e4a3",runnerSha256:""},{version:"0.0.33",apkSha256:"7289eba90b22890d3c36e05e99db72a545fa4becdf46df079885783a919e6aed",ipaSha256:"425dfa4db4ad5a4febc9f05ffc97df38f3a1098ccdd9330adff1c0b5c877697d",runnerSha256:""},{version:"0.0.32",apkSha256:"4c4a743af5d18ed58214e64b85986c9e2f2332b015edcf7d9d68a24cd6dfda21",ipaSha256:"40f4d9084d3368995b57c0e81c4fe85f38851353da9f789eaff93027aee456a0",runnerSha256:""},{version:"0.0.31",apkSha256:"0b5802ada8d9adccdb69ee140ae788b3251832c0605d2f6baa3e9b7a78260764",ipaSha256:"e60f8689fb6ddd5c06a5d2ff57569b264f407229afb986258d1ce20326dc24c7",runnerSha256:""},{version:"0.0.30",apkSha256:"a1be5e6240f204ee99540e99cc198f7c0b592dbaf3699330c14f6ded7d333ec3",ipaSha256:"5ac285dd5be16439d3a8a8973c98606920461acfce489830e54ee20759a7b235",runnerSha256:""},{version:"0.0.29",apkSha256:"b33a67c7efa84aca2b07faa965aecb3b1819b4defd441dcc8d3bf7e2af209cd8",ipaSha256:"d47c1aea4495270c1489cae361286ea1439c2ba4e7d5bcfd73f66e4580a6c45d",runnerSha256:""},{version:"0.0.28",apkSha256:"0f683d5939bc308afe038ea1259eb29997dff38af0795136a281ad305986e40e",ipaSha256:"eee7accfbca717bb8b89fafd0676f10d8bb08561c3fbd7a04750c9b12c2a7104",runnerSha256:""},{version:"0.0.27",apkSha256:"9966113ae44f38f3cf34544b1375d3c9a3706701edba45a1eec1f220b9c676cc",ipaSha256:"8620de6b014df18465876334f9ba8c106292f6c3059370eea2349f1e44db4f4d",runnerSha256:""},{version:"0.0.26",apkSha256:"2eb2f156fd27602c85003ab8f6e00d3e06850e84f5453d75b7494aa5bbed7be0",ipaSha256:"905df276d2224d31cbc5aa2258d2dcc60eaeb9813727081ddd32c95394fec411",runnerSha256:""},{version:"0.0.25",apkSha256:"f727079edb4906e3b7928dbb641e788543e86b11fff3fc1b76f0c51b9c8d6e5d",ipaSha256:"d8032cc1cebcb456b7232aa67fc42c89ff62729bacf141aa8f594ce6f8bcd980",runnerSha256:""},{version:"0.0.24",apkSha256:"9047795bc6098f4ec687c126123c73c423806a9fd52888af391d6fb5b94ac93f",ipaSha256:"1dd3e0370cb8ed01d8e1020558d8a2808f208bd947bafcf6688211eddc928bf8",runnerSha256:""},{version:"0.0.18",apkSha256:"fd3c8d9f0b8542eaad56c78b18cf8e5666367b04ae8c4af74d8aa6dd1c8d1834",ipaSha256:"2a5eec63bce2f9dfc227c0732fcce67378305e945604d5eedd0e3df48e37fd39",runnerSha256:""},{version:"0.0.17",apkSha256:"916033440931666644474f227c8e39d13d9c80c3515e4292cc5581fd5bd4cc2f",ipaSha256:"e4dcf064d024f2371b8fd79281000e2d49751ef95b8817d1494d685aeda746ac",runnerSha256:""}];xD6=kW({}),vD6=mK({}),yD6=Hz({}),hD6=Lz({}),gD6=pa({})});var na=x((mD6,KM$)=>{KM$.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var uC=x((UM$)=>{var VM$={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function qO4($){return function(...J){if(J.length)$=$.replace(/\{(\d)\}/g,(X,Y)=>J[Y]||"");return Error("ADM-ZIP: "+$)}}for(let $ of Object.keys(VM$))UM$[$]=qO4(VM$[$])});var LM$=x((cD6,HM$)=>{var wO4=a$("fs"),d0=a$("path"),zM$=na(),MO4=uC(),AO4=typeof process==="object"&&process.platform==="win32",jM$=($)=>typeof $==="object"&&$!==null,ZM$=new Uint32Array(256).map(($,J)=>{for(let X=0;X<8;X++)if((J&1)!==0)J=3988292384^J>>>1;else J>>>=1;return J>>>0});function G0($){if(this.sep=d0.sep,this.fs=wO4,jM$($)){if(jM$($.fs)&&typeof $.fs.statSync==="function")this.fs=$.fs}}HM$.exports=G0;G0.prototype.makeDir=function($){let J=this;function X(Y){let Q=Y.split(J.sep)[0];Y.split(J.sep).forEach(function(W){if(!W||W.substr(-1,1)===":")return;Q+=J.sep+W;var G;try{G=J.fs.statSync(Q)}catch(K){if(K.message&&K.message.startsWith("ENOENT"))J.fs.mkdirSync(Q);else throw K}if(G&&G.isFile())throw MO4.FILE_IN_THE_WAY(`"${Q}"`)})}X($)};G0.prototype.writeFileTo=function($,J,X,Y){let Q=this;if(Q.fs.existsSync($)){if(!X)return!1;var W=Q.fs.statSync($);if(W.isDirectory())return!1}var G=d0.dirname($);if(!Q.fs.existsSync(G))Q.makeDir(G);var K;try{K=Q.fs.openSync($,"w",438)}catch(V){Q.fs.chmodSync($,438),K=Q.fs.openSync($,"w",438)}if(K)try{Q.fs.writeSync(K,J,0,J.length,0)}finally{Q.fs.closeSync(K)}return Q.fs.chmodSync($,Y||438),!0};G0.prototype.writeFileToAsync=function($,J,X,Y,Q){if(typeof Y==="function")Q=Y,Y=void 0;let W=this;W.fs.exists($,function(G){if(G&&!X)return Q(!1);W.fs.stat($,function(K,V){if(G&&V.isDirectory())return Q(!1);var U=d0.dirname($);W.fs.exists(U,function(z){if(!z)W.makeDir(U);W.fs.open($,"w",438,function(Z,H){if(Z)W.fs.chmod($,438,function(){W.fs.open($,"w",438,function(L,O){W.fs.write(O,J,0,J.length,0,function(){W.fs.close(O,function(){W.fs.chmod($,Y||438,function(){Q(!0)})})})})});else if(H)W.fs.write(H,J,0,J.length,0,function(){W.fs.close(H,function(){W.fs.chmod($,Y||438,function(){Q(!0)})})});else W.fs.chmod($,Y||438,function(){Q(!0)})})})})})};G0.prototype.findFiles=function($){let J=this;function X(Y,Q,W){if(typeof Q==="boolean")W=Q,Q=void 0;let G=[];return J.fs.readdirSync(Y).forEach(function(K){let V=d0.join(Y,K),U=J.fs.statSync(V);if(!Q||Q.test(V))G.push(d0.normalize(V)+(U.isDirectory()?J.sep:""));if(U.isDirectory()&&W)G=G.concat(X(V,Q,W))}),G}return X($,void 0,!0)};G0.prototype.findFilesAsync=function($,J){let X=this,Y=[];X.fs.readdir($,function(Q,W){if(Q)return J(Q);let G=W.length;if(!G)return J(null,Y);W.forEach(function(K){K=d0.join($,K),X.fs.stat(K,function(V,U){if(V)return J(V);if(U){if(Y.push(d0.normalize(K)+(U.isDirectory()?X.sep:"")),U.isDirectory())X.findFilesAsync(K,function(z,Z){if(z)return J(z);if(Y=Y.concat(Z),!--G)J(null,Y)});else if(!--G)J(null,Y)}})})})};G0.prototype.getAttributes=function(){};G0.prototype.setAttributes=function(){};G0.crc32update=function($,J){return ZM$[($^J)&255]^$>>>8};G0.crc32=function($){if(typeof $==="string")$=Buffer.from($,"utf8");let J=$.length,X=-1;for(let Y=0;Y<J;)X=G0.crc32update(X,$[Y++]);return~X>>>0};G0.methodToString=function($){switch($){case zM$.STORED:return"STORED ("+$+")";case zM$.DEFLATED:return"DEFLATED ("+$+")";default:return"UNSUPPORTED ("+$+")"}};G0.canonical=function($){if(!$)return"";let J=d0.posix.normalize("/"+$.split("\\").join("/"));return d0.join(".",J)};G0.zipnamefix=function($){if(!$)return"";let J=d0.posix.normalize("/"+$.split("\\").join("/"));return d0.posix.join(".",J)};G0.findLast=function($,J){if(!Array.isArray($))throw TypeError("arr is not array");let X=$.length>>>0;for(let Y=X-1;Y>=0;Y--)if(J($[Y],Y,$))return $[Y];return};G0.sanitize=function($,J){$=d0.resolve(d0.normalize($));var X=J.split("/");for(var Y=0,Q=X.length;Y<Q;Y++){var W=d0.normalize(d0.join($,X.slice(Y,Q).join(d0.sep)));if(W===$||W.startsWith($+d0.sep))return W}return d0.normalize(d0.join($,d0.basename(J)))};G0.toBuffer=function(J,X){if(Buffer.isBuffer(J))return J;else if(J instanceof Uint8Array)return Buffer.from(J);else return typeof J==="string"?X(J):Buffer.alloc(0)};G0.readBigUInt64LE=function($,J){let X=$.readUInt32LE(J);return $.readUInt32LE(J+4)*4294967296+X};G0.writeBigUInt64LE=function($,J,X){let Y=J>>>0,Q=Math.floor(J/4294967296)>>>0;$.writeUInt32LE(Y,X),$.writeUInt32LE(Q,X+4)};G0.fromDOS2Date=function($){return new Date(($>>25&127)+1980,Math.max(($>>21&15)-1,0),Math.max($>>16&31,1),$>>11&31,$>>5&63,($&31)<<1)};G0.fromDate2DOS=function($){let J=0,X=0;if($.getFullYear()>1979)J=($.getFullYear()-1980&127)<<9|$.getMonth()+1<<5|$.getDate(),X=$.getHours()<<11|$.getMinutes()<<5|$.getSeconds()>>1;return J<<16|X};G0.isWin=AO4;G0.crcTable=ZM$});var BM$=x((pD6,OM$)=>{var NO4=a$("path");OM$.exports=function($,{fs:J}){var X=$||"",Y=W(),Q=null;function W(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&J.existsSync(X))Q=J.statSync(X),Y.directory=Q.isDirectory(),Y.mtime=Q.mtime,Y.atime=Q.atime,Y.executable=(73&Q.mode)!==0,Y.readonly=(128&Q.mode)===0,Y.hidden=NO4.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return Y.directory},get readOnly(){return Y.readonly},get hidden(){return Y.hidden},get mtime(){return Y.mtime},get atime(){return Y.atime},get executable(){return Y.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:Y.directory,isReadOnly:Y.readonly,isHidden:Y.hidden,isExecutable:Y.executable,mTime:Y.mtime,aTime:Y.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var DM$=x((nD6,FM$)=>{FM$.exports={efs:!0,encode:($)=>Buffer.from($,"utf8"),decode:($)=>$.toString("utf8")}});var WH=x((dD6,QH)=>{QH.exports=LM$();QH.exports.Constants=na();QH.exports.Errors=uC();QH.exports.FileAttr=BM$();QH.exports.decoder=DM$()});var wM$=x((iD6,qM$)=>{var lK=WH(),d$=lK.Constants;qM$.exports=function(){var $=20,J=10,X=0,Y=0,Q=0,W=0,G=0,K=0,V=0,U=0,z=0,Z=0,H=0,L=0,O=0;$|=lK.isWin?2560:768,X|=d$.FLG_EFS;let B={extraLen:0},q=(F)=>Math.max(0,F)>>>0,w=(F)=>Math.max(0,F)&65535,_=(F)=>Math.max(0,F)&255;return Q=lK.fromDate2DOS(new Date),{get made(){return $},set made(F){$=F},get version(){return J},set version(F){J=F},get flags(){return X},set flags(F){X=F},get flags_efs(){return(X&d$.FLG_EFS)>0},set flags_efs(F){if(F)X|=d$.FLG_EFS;else X&=~d$.FLG_EFS},get flags_desc(){return(X&d$.FLG_DESC)>0},set flags_desc(F){if(F)X|=d$.FLG_DESC;else X&=~d$.FLG_DESC},get method(){return Y},set method(F){switch(F){case d$.STORED:this.version=10;break;case d$.DEFLATED:default:this.version=20}Y=F},get time(){return lK.fromDOS2Date(this.timeval)},set time(F){F=new Date(F),this.timeval=lK.fromDate2DOS(F)},get timeval(){return Q},set timeval(F){Q=q(F)},get timeHighByte(){return _(Q>>>8)},get crc(){return W},set crc(F){W=q(F)},get compressedSize(){return G},set compressedSize(F){G=q(F)},get size(){return K},set size(F){K=q(F)},get fileNameLength(){return V},set fileNameLength(F){V=F},get extraLength(){return U},set extraLength(F){U=F},get extraLocalLength(){return B.extraLen},set extraLocalLength(F){B.extraLen=F},get commentLength(){return z},set commentLength(F){z=F},get diskNumStart(){return Z},set diskNumStart(F){Z=q(F)},get inAttr(){return H},set inAttr(F){H=q(F)},get attr(){return L},set attr(F){L=q(F)},get fileAttr(){return(L||0)>>16&4095},get offset(){return O},set offset(F){O=q(F)},get encrypted(){return(X&d$.FLG_ENC)===d$.FLG_ENC},get centralHeaderSize(){return d$.CENHDR+V+U+z},get realDataOffset(){return O+d$.LOCHDR+B.fnameLen+B.extraLen},get localHeader(){return B},loadLocalHeaderFromBinary:function(F){var A=F.slice(O,O+d$.LOCHDR);if(A.readUInt32LE(0)!==d$.LOCSIG)throw lK.Errors.INVALID_LOC();B.version=A.readUInt16LE(d$.LOCVER),B.flags=A.readUInt16LE(d$.LOCFLG),B.flags_desc=(B.flags&d$.FLG_DESC)>0,B.method=A.readUInt16LE(d$.LOCHOW),B.time=A.readUInt32LE(d$.LOCTIM),B.crc=A.readUInt32LE(d$.LOCCRC),B.compressedSize=A.readUInt32LE(d$.LOCSIZ),B.size=A.readUInt32LE(d$.LOCLEN),B.fnameLen=A.readUInt16LE(d$.LOCNAM),B.extraLen=A.readUInt16LE(d$.LOCEXT);let M=O+d$.LOCHDR+B.fnameLen,P=M+B.extraLen;return F.slice(M,P)},loadFromBinary:function(F){if(F.length!==d$.CENHDR||F.readUInt32LE(0)!==d$.CENSIG)throw lK.Errors.INVALID_CEN();$=F.readUInt16LE(d$.CENVEM),J=F.readUInt16LE(d$.CENVER),X=F.readUInt16LE(d$.CENFLG),Y=F.readUInt16LE(d$.CENHOW),Q=F.readUInt32LE(d$.CENTIM),W=F.readUInt32LE(d$.CENCRC),G=F.readUInt32LE(d$.CENSIZ),K=F.readUInt32LE(d$.CENLEN),V=F.readUInt16LE(d$.CENNAM),U=F.readUInt16LE(d$.CENEXT),z=F.readUInt16LE(d$.CENCOM),Z=F.readUInt16LE(d$.CENDSK),H=F.readUInt16LE(d$.CENATT),L=F.readUInt32LE(d$.CENATX),O=F.readUInt32LE(d$.CENOFF)},localHeaderToBinary:function(){var F=Buffer.alloc(d$.LOCHDR);return F.writeUInt32LE(d$.LOCSIG,0),F.writeUInt16LE(J,d$.LOCVER),F.writeUInt16LE(X&~d$.FLG_DESC,d$.LOCFLG),F.writeUInt16LE(Y,d$.LOCHOW),F.writeUInt32LE(Q,d$.LOCTIM),F.writeUInt32LE(W,d$.LOCCRC),F.writeUInt32LE(G,d$.LOCSIZ),F.writeUInt32LE(K,d$.LOCLEN),F.writeUInt16LE(V,d$.LOCNAM),F.writeUInt16LE(B.extraLen,d$.LOCEXT),F},centralHeaderToBinary:function(){var F=Buffer.alloc(d$.CENHDR+V+U+z);return F.writeUInt32LE(d$.CENSIG,0),F.writeUInt16LE($,d$.CENVEM),F.writeUInt16LE(J,d$.CENVER),F.writeUInt16LE(X&~d$.FLG_DESC,d$.CENFLG),F.writeUInt16LE(Y,d$.CENHOW),F.writeUInt32LE(Q,d$.CENTIM),F.writeUInt32LE(W,d$.CENCRC),F.writeUInt32LE(G,d$.CENSIZ),F.writeUInt32LE(K,d$.CENLEN),F.writeUInt16LE(V,d$.CENNAM),F.writeUInt16LE(U,d$.CENEXT),F.writeUInt16LE(z,d$.CENCOM),F.writeUInt16LE(Z,d$.CENDSK),F.writeUInt16LE(H,d$.CENATT),F.writeUInt32LE(L,d$.CENATX),F.writeUInt32LE(O,d$.CENOFF),F},toJSON:function(){let F=function(A){return A+" bytes"};return{made:$,version:J,flags:X,method:lK.methodToString(Y),time:this.time,crc:"0x"+W.toString(16).toUpperCase(),compressedSize:F(G),size:F(K),fileNameLength:F(V),extraLength:F(U),commentLength:F(z),diskNumStart:Z,inAttr:H,attr:L,offset:O,centralHeaderSize:F(d$.CENHDR+V+U+z)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var AM$=x((oD6,MM$)=>{var aX=WH(),z4=aX.Constants;MM$.exports=function(){var $=0,J=0,X=0,Y=0,Q=0;let W=()=>$>z4.EF_ZIP64_OR_16||J>z4.EF_ZIP64_OR_16||X>z4.EF_ZIP64_OR_32||Y>z4.EF_ZIP64_OR_32;return{get diskEntries(){return $},set diskEntries(G){$=J=G},get totalEntries(){return J},set totalEntries(G){J=$=G},get size(){return X},set size(G){X=G},get offset(){return Y},set offset(G){Y=G},get commentLength(){return Q},set commentLength(G){Q=G},get mainHeaderSize(){return(W()?z4.ZIP64HDR+z4.END64HDR:0)+z4.ENDHDR+Q},loadFromBinary:function(G){if((G.length!==z4.ENDHDR||G.readUInt32LE(0)!==z4.ENDSIG)&&(G.length<z4.ZIP64HDR||G.readUInt32LE(0)!==z4.ZIP64SIG))throw aX.Errors.INVALID_END();if(G.readUInt32LE(0)===z4.ENDSIG)$=G.readUInt16LE(z4.ENDSUB),J=G.readUInt16LE(z4.ENDTOT),X=G.readUInt32LE(z4.ENDSIZ),Y=G.readUInt32LE(z4.ENDOFF),Q=G.readUInt16LE(z4.ENDCOM);else $=aX.readBigUInt64LE(G,z4.ZIP64SUB),J=aX.readBigUInt64LE(G,z4.ZIP64TOT),X=aX.readBigUInt64LE(G,z4.ZIP64SIZB),Y=aX.readBigUInt64LE(G,z4.ZIP64OFF),Q=0},toBinary:function(){if(!W()){var G=Buffer.alloc(z4.ENDHDR+Q);return G.writeUInt32LE(z4.ENDSIG,0),G.writeUInt32LE(0,4),G.writeUInt16LE($,z4.ENDSUB),G.writeUInt16LE(J,z4.ENDTOT),G.writeUInt32LE(X,z4.ENDSIZ),G.writeUInt32LE(Y,z4.ENDOFF),G.writeUInt16LE(Q,z4.ENDCOM),G.fill(" ",z4.ENDHDR),G}var G=Buffer.alloc(this.mainHeaderSize);let K=0;G.writeUInt32LE(z4.ZIP64SIG,K),aX.writeBigUInt64LE(G,z4.ZIP64HDR-z4.ZIP64LEAD,K+z4.ZIP64SIZE),G.writeUInt16LE(45,K+z4.ZIP64VEM),G.writeUInt16LE(45,K+z4.ZIP64VER),G.writeUInt32LE(0,K+z4.ZIP64DSK),G.writeUInt32LE(0,K+z4.ZIP64DSKDIR),aX.writeBigUInt64LE(G,$,K+z4.ZIP64SUB),aX.writeBigUInt64LE(G,J,K+z4.ZIP64TOT),aX.writeBigUInt64LE(G,X,K+z4.ZIP64SIZB),aX.writeBigUInt64LE(G,Y,K+z4.ZIP64OFF);let V=Y+X;return K+=z4.ZIP64HDR,G.writeUInt32LE(z4.END64SIG,K),G.writeUInt32LE(0,K+z4.END64START),aX.writeBigUInt64LE(G,V,K+z4.END64OFF),G.writeUInt32LE(1,K+z4.END64NUMDISKS),K+=z4.END64HDR,G.writeUInt32LE(z4.ENDSIG,K),G.writeUInt32LE(0,K+4),G.writeUInt16LE(Math.min($,z4.EF_ZIP64_OR_16),K+z4.ENDSUB),G.writeUInt16LE(Math.min(J,z4.EF_ZIP64_OR_16),K+z4.ENDTOT),G.writeUInt32LE(Math.min(X,z4.EF_ZIP64_OR_32),K+z4.ENDSIZ),G.writeUInt32LE(Math.min(Y,z4.EF_ZIP64_OR_32),K+z4.ENDOFF),G.writeUInt16LE(Q,K+z4.ENDCOM),G.fill(" ",K+z4.ENDHDR),G},toJSON:function(){let G=function(K,V){let U=K.toString(16).toUpperCase();while(U.length<V)U="0"+U;return"0x"+U};return{diskEntries:$,totalEntries:J,size:X+" bytes",offset:G(Y,4),commentLength:Q}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var da=x((_O4)=>{_O4.EntryHeader=wM$();_O4.MainHeader=AM$()});var _M$=x((tD6,NM$)=>{NM$.exports=function($){var J=a$("zlib"),X={chunkSize:(parseInt($.length/1024)+1)*1024};return{deflate:function(){return J.deflateRawSync($,X)},deflateAsync:function(Y){var Q=J.createDeflateRaw(X),W=[],G=0;Q.on("data",function(K){W.push(K),G+=K.length}),Q.on("end",function(){var K=Buffer.alloc(G),V=0;K.fill(0);for(var U=0;U<W.length;U++){var z=W[U];z.copy(K,V),V+=z.length}Y&&Y(K)}),Q.end($)}}}});var EM$=x((aD6,RM$)=>{var PO4=+(process?.versions?.node??"").split(".")[0]||0;RM$.exports=function($,J){var X=a$("zlib");let Y=PO4>=15&&J>0?{maxOutputLength:J}:{};return{inflate:function(){return X.inflateRawSync($,Y)},inflateAsync:function(Q){var W=X.createInflateRaw(Y),G=[],K=0;W.on("data",function(V){G.push(V),K+=V.length}),W.on("end",function(){var V=Buffer.alloc(K),U=0;V.fill(0);for(var z=0;z<G.length;z++){var Z=G[z];Z.copy(V,U),U+=Z.length}Q&&Q(V)}),W.end($)}}}});var SM$=x((sD6,IM$)=>{var{randomFillSync:PM$}=a$("crypto"),CO4=uC(),TO4=new Uint32Array(256).map(($,J)=>{for(let X=0;X<8;X++)if((J&1)!==0)J=J>>>1^3988292384;else J>>>=1;return J>>>0}),TM$=($,J)=>Math.imul($,J)>>>0,CM$=($,J)=>{return TO4[($^J)&255]^$>>>8},_D=()=>{if(typeof PM$==="function")return PM$(Buffer.alloc(12));else return _D.node()};_D.node=()=>{let $=Buffer.alloc(12),J=$.length;for(let X=0;X<J;X++)$[X]=Math.random()*256&255;return $};var mC={genSalt:_D};function lC($){let J=Buffer.isBuffer($)?$:Buffer.from($);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let X=0;X<J.length;X++)this.updateKeys(J[X])}lC.prototype.updateKeys=function($){let J=this.keys;return J[0]=CM$(J[0],$),J[1]+=J[0]&255,J[1]=TM$(J[1],134775813)+1,J[2]=CM$(J[2],J[1]>>>24),$};lC.prototype.next=function(){let $=(this.keys[2]|2)>>>0;return TM$($,$^1)>>8&255};function IO4($){let J=new lC($);return function(X){let Y=Buffer.alloc(X.length),Q=0;for(let W of X)Y[Q++]=J.updateKeys(W^J.next());return Y}}function SO4($){let J=new lC($);return function(X,Y,Q=0){if(!Y)Y=Buffer.alloc(X.length);for(let W of X){let G=J.next();Y[Q++]=W^G,J.updateKeys(W)}return Y}}function bO4($,J,X){if(!$||!Buffer.isBuffer($)||$.length<12)return Buffer.alloc(0);let Y=IO4(X),Q=Y($.slice(0,12)),W=(J.flags&8)===8?J.timeHighByte:J.crc>>>24;if(Q[11]!==W)throw CO4.WRONG_PASSWORD();return Y($.slice(12))}function kO4($){if(Buffer.isBuffer($)&&$.length>=12)mC.genSalt=function(){return $.slice(0,12)};else if($==="node")mC.genSalt=_D.node;else mC.genSalt=_D}function fO4($,J,X,Y=!1){if($==null)$=Buffer.alloc(0);if(!Buffer.isBuffer($))$=Buffer.from($.toString());let Q=SO4(X),W=mC.genSalt();if(W[11]=J.crc>>>24&255,Y)W[10]=J.crc>>>16&255;let G=Buffer.alloc($.length+12);return Q(W,G),Q($,G,12)}IM$.exports={decrypt:bO4,encrypt:fO4,_salter:kO4}});var bM$=x((xO4)=>{xO4.Deflater=_M$();xO4.Inflater=EM$();xO4.ZipCrypto=SM$()});var oa=x(($q6,kM$)=>{var Y1=WH(),gO4=da(),A0=Y1.Constants,ia=bM$();kM$.exports=function($,J){var X=new gO4.EntryHeader,Y=Buffer.alloc(0),Q=Buffer.alloc(0),W=!1,G=null,K=Buffer.alloc(0),V=Buffer.alloc(0),U=!0;let z=$,Z=typeof z.decoder==="object"?z.decoder:Y1.decoder;U=Z.hasOwnProperty("efs")?Z.efs:!1;function H(){if(!J||!(J instanceof Uint8Array))return Buffer.alloc(0);return V=X.loadLocalHeaderFromBinary(J),J.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function L(F){if(!X.flags_desc&&!X.localHeader.flags_desc){if(Y1.crc32(F)!==X.localHeader.crc)return!1}else{let A={},M=X.realDataOffset+X.compressedSize;if(J.readUInt32LE(M)==A0.LOCSIG||J.readUInt32LE(M)==A0.CENSIG)throw Y1.Errors.DESCRIPTOR_NOT_EXIST();if(J.readUInt32LE(M)==A0.EXTSIG)A.crc=J.readUInt32LE(M+A0.EXTCRC),A.compressedSize=J.readUInt32LE(M+A0.EXTSIZ),A.size=J.readUInt32LE(M+A0.EXTLEN);else if(J.readUInt16LE(M+12)===19280)A.crc=J.readUInt32LE(M+A0.EXTCRC-4),A.compressedSize=J.readUInt32LE(M+A0.EXTSIZ-4),A.size=J.readUInt32LE(M+A0.EXTLEN-4);else throw Y1.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==X.compressedSize||A.size!==X.size||A.crc!==X.crc)throw Y1.Errors.DESCRIPTOR_FAULTY();if(Y1.crc32(F)!==A.crc)return!1}return!0}function O(F,A,M){if(typeof A>"u"&&typeof F==="string")M=F,F=void 0;if(W){if(F&&A)A(Buffer.alloc(0),Y1.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var P=H();if(P.length===0){if(F&&A)A(P);return P}if(X.encrypted){if(typeof M!=="string"&&!Buffer.isBuffer(M))throw Y1.Errors.INVALID_PASS_PARAM();P=ia.ZipCrypto.decrypt(P,X,M)}var k=Buffer.alloc(X.size);switch(X.method){case Y1.Constants.STORED:if(P.copy(k),!L(k)){if(F&&A)A(k,Y1.Errors.BAD_CRC());throw Y1.Errors.BAD_CRC()}else{if(F&&A)A(k);return k}case Y1.Constants.DEFLATED:var I=new ia.Inflater(P,X.size);if(!F){if(I.inflate(k).copy(k,0),!L(k))throw Y1.Errors.BAD_CRC(`"${Z.decode(Y)}"`);return k}else I.inflateAsync(function(u){if(u.copy(u,0),A)if(!L(u))A(u,Y1.Errors.BAD_CRC());else A(u)});break;default:if(F&&A)A(Buffer.alloc(0),Y1.Errors.UNKNOWN_METHOD());throw Y1.Errors.UNKNOWN_METHOD()}}function B(F,A){if((!G||!G.length)&&Buffer.isBuffer(J)){if(F&&A)A(H());return H()}if(G.length&&!W){var M;switch(X.method){case Y1.Constants.STORED:if(X.compressedSize=X.size,M=Buffer.alloc(G.length),G.copy(M),F&&A)A(M);return M;default:case Y1.Constants.DEFLATED:var P=new ia.Deflater(G);if(!F){var k=P.deflate();return X.compressedSize=k.length,k}else P.deflateAsync(function(I){M=Buffer.alloc(I.length),X.compressedSize=I.length,I.copy(M),A&&A(M)});P=null;break}}else if(F&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function q(F,A){return Y1.readBigUInt64LE(F,A)}function w(F){try{var A=0,M,P,k;while(A+4<F.length)if(M=F.readUInt16LE(A),A+=2,P=F.readUInt16LE(A),A+=2,k=F.slice(A,A+P),A+=P,A0.ID_ZIP64===M)_(k)}catch(I){throw Y1.Errors.EXTRA_FIELD_PARSE_ERROR()}}function _(F){var A,M,P,k;if(F.length>=A0.EF_ZIP64_SCOMP){if(A=q(F,A0.EF_ZIP64_SUNCOMP),X.size===A0.EF_ZIP64_OR_32)X.size=A}if(F.length>=A0.EF_ZIP64_RHO){if(M=q(F,A0.EF_ZIP64_SCOMP),X.compressedSize===A0.EF_ZIP64_OR_32)X.compressedSize=M}if(F.length>=A0.EF_ZIP64_DSN){if(P=q(F,A0.EF_ZIP64_RHO),X.offset===A0.EF_ZIP64_OR_32)X.offset=P}if(F.length>=A0.EF_ZIP64_DSN+4){if(k=F.readUInt32LE(A0.EF_ZIP64_DSN),X.diskNumStart===A0.EF_ZIP64_OR_16)X.diskNumStart=k}}return{get entryName(){return Z.decode(Y)},get rawEntryName(){return Y},set entryName(F){Y=Y1.toBuffer(F,Z.encode);var A=Y[Y.length-1];W=A===47||A===92,X.fileNameLength=Y.length},get efs(){if(typeof U==="function")return U(this.entryName);else return U},get extra(){return K},set extra(F){K=F,X.extraLength=F.length,w(F)},get comment(){return Z.decode(Q)},set comment(F){if(Q=Y1.toBuffer(F,Z.encode),X.commentLength=Q.length,Q.length>65535)throw Y1.Errors.COMMENT_TOO_LONG()},get name(){var F=Z.decode(Y);return W?F.substr(F.length-1).split("/").pop():F.split("/").pop()},get isDirectory(){return W},getCompressedData:function(){return B(!1,null)},getCompressedDataAsync:function(F){B(!0,F)},setData:function(F){if(G=Y1.toBuffer(F,Y1.decoder.encode),!W&&G.length)X.size=G.length,X.method=Y1.Constants.DEFLATED,X.crc=Y1.crc32(F),X.changed=!0;else X.method=Y1.Constants.STORED},getData:function(F){if(X.changed)return G;else return O(!1,null,F)},getDataAsync:function(F,A){if(X.changed)F(G);else O(!0,F,A)},set attr(F){X.attr=F},get attr(){return X.attr},set header(F){X.loadFromBinary(F)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=K.length;var F=X.centralHeaderToBinary(),A=Y1.Constants.CENHDR;return Y.copy(F,A),A+=Y.length,K.copy(F,A),A+=X.extraLength,Q.copy(F,A),F},packLocalHeader:function(){let F=0;X.flags_efs=this.efs,X.extraLocalLength=V.length;let A=X.localHeaderToBinary(),M=Buffer.alloc(A.length+Y.length+X.extraLocalLength);return A.copy(M,F),F+=A.length,Y.copy(M,F),F+=Y.length,V.copy(M,F),F+=V.length,M},toJSON:function(){let F=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:F(J),data:F(G)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var vM$=x((Jq6,xM$)=>{var fM$=oa(),uO4=da(),v9=WH();xM$.exports=function($,J){var X=[],Y={},Q=Buffer.alloc(0),W=new uO4.MainHeader,G=!1,K=null;let V=new Set,U=J,{noSort:z,decoder:Z}=U;if($)O(U.readEntries);else G=!0;function H(){let q=new Set;for(let w of Object.keys(Y)){let _=w.split("/");if(_.pop(),!_.length)continue;for(let F=0;F<_.length;F++){let A=_.slice(0,F+1).join("/")+"/";q.add(A)}}for(let w of q)if(!(w in Y)){let _=new fM$(U);_.entryName=w,_.attr=16,_.temporary=!0,X.push(_),Y[_.entryName]=_,V.add(_)}}function L(){if(G=!0,Y={},W.diskEntries>($.length-W.offset)/v9.Constants.CENHDR)throw v9.Errors.DISK_ENTRY_TOO_LARGE();X=Array(W.diskEntries);var q=W.offset;for(var w=0;w<X.length;w++){var _=q,F=new fM$(U,$);if(F.header=$.slice(_,_+=v9.Constants.CENHDR),F.entryName=$.slice(_,_+=F.header.fileNameLength),F.header.extraLength)F.extra=$.slice(_,_+=F.header.extraLength);if(F.header.commentLength)F.comment=$.slice(_,_+F.header.commentLength);q+=F.header.centralHeaderSize,X[w]=F,Y[F.entryName]=F}V.clear(),H()}function O(q){var w=$.length-v9.Constants.ENDHDR,_=Math.max(0,w-65535),F=_,A=$.length,M=-1,P=0;if(typeof U.trailingSpace==="boolean"?U.trailingSpace:!1)_=0;for(w;w>=F;w--){if($[w]!==80)continue;if($.readUInt32LE(w)===v9.Constants.ENDSIG){M=w,P=w,A=w+v9.Constants.ENDHDR,F=w-v9.Constants.END64HDR;continue}if($.readUInt32LE(w)===v9.Constants.END64SIG){F=_;continue}if($.readUInt32LE(w)===v9.Constants.ZIP64SIG){M=w,A=w+v9.readBigUInt64LE($,w+v9.Constants.ZIP64SIZE)+v9.Constants.ZIP64LEAD;break}}if(M==-1)throw v9.Errors.INVALID_FORMAT();if(W.loadFromBinary($.slice(M,A)),W.commentLength)Q=$.slice(P+v9.Constants.ENDHDR);if(q)L()}function B(){if(X.length>1&&!z)X.sort((q,w)=>q.entryName.toLowerCase().localeCompare(w.entryName.toLowerCase()))}return{get entries(){if(!G)L();return X.filter((q)=>!V.has(q))},get comment(){return Z.decode(Q)},set comment(q){Q=v9.toBuffer(q,Z.encode),W.commentLength=Q.length},getEntryCount:function(){if(!G)return W.diskEntries;return X.length},forEach:function(q){this.entries.forEach(q)},getEntry:function(q){if(!G)L();return Y[q]||null},setEntry:function(q){if(!G)L();X.push(q),Y[q.entryName]=q,W.totalEntries=X.length},deleteFile:function(q,w=!0){if(!G)L();let _=Y[q];this.getEntryChildren(_,w).map((A)=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(q){if(!G)L();let w=Y[q],_=X.indexOf(w);if(_>=0)X.splice(_,1),delete Y[q],W.totalEntries=X.length},getEntryChildren:function(q,w=!0){if(!G)L();if(typeof q==="object")if(q.isDirectory&&w){let _=[],F=q.entryName;for(let A of X)if(A.entryName.startsWith(F))_.push(A);return _}else return[q];return[]},getChildCount:function(q){if(q&&q.isDirectory){let w=this.getEntryChildren(q);return w.includes(q)?w.length-1:w.length}return 0},compressToBuffer:function(){if(!G)L();B();let q=[],w=[],_=0,F=0;W.size=0,W.offset=0;let A=0;for(let k of this.entries){let I=k.getCompressedData();k.header.offset=F;let u=k.packLocalHeader(),v=u.length+I.length;F+=v,q.push(u),q.push(I);let c=k.packCentralHeader();w.push(c),W.size+=c.length,_+=v+c.length,A++}_+=W.mainHeaderSize,W.offset=F,W.totalEntries=A,F=0;let M=Buffer.alloc(_);for(let k of q)k.copy(M,F),F+=k.length;for(let k of w)k.copy(M,F),F+=k.length;let P=W.toBinary();if(Q)Q.copy(P,P.length-Q.length);return P.copy(M,F),$=M,G=!1,M},toAsyncBuffer:function(q,w,_,F){try{if(!G)L();B();let A=[],M=[],P=0,k=0,I=0;W.size=0,W.offset=0;let u=function(v){if(v.length>0){let c=v.shift(),e=c.entryName+c.extra.toString();if(_)_(e);c.getCompressedDataAsync(function(X$){if(F)F(e);c.header.offset=k;let h$=c.packLocalHeader(),L4=h$.length+X$.length;k+=L4,A.push(h$),A.push(X$);let b$=c.packCentralHeader();M.push(b$),W.size+=b$.length,P+=L4+b$.length,I++,u(v)})}else{P+=W.mainHeaderSize,W.offset=k,W.totalEntries=I,k=0;let c=Buffer.alloc(P);A.forEach(function(X$){X$.copy(c,k),k+=X$.length}),M.forEach(function(X$){X$.copy(c,k),k+=X$.length});let e=W.toBinary();if(Q)Q.copy(e,e.length-Q.length);e.copy(c,k),$=c,G=!1,q(c)}};u(Array.from(this.entries))}catch(A){w(A)}}}}});var ra=x((Xq6,hM$)=>{var V0=WH(),K0=a$("path"),mO4=oa(),lO4=vM$(),Oz=(...$)=>V0.findLast($,(J)=>typeof J==="boolean"),yM$=(...$)=>V0.findLast($,(J)=>typeof J==="string"),cO4=(...$)=>V0.findLast($,(J)=>typeof J==="function"),pO4={noSort:!1,readEntries:!1,method:V0.Constants.NONE,fs:null};hM$.exports=function($,J){let X=null,Y=Object.assign(Object.create(null),pO4);if($&&typeof $==="object"){if(!($ instanceof Uint8Array)){if(Object.assign(Y,$),$=Y.input?Y.input:void 0,Y.input)delete Y.input}if(Buffer.isBuffer($))X=$,Y.method=V0.Constants.BUFFER,$=void 0}Object.assign(Y,J);let Q=new V0(Y);if(typeof Y.decoder!=="object"||typeof Y.decoder.encode!=="function"||typeof Y.decoder.decode!=="function")Y.decoder=V0.decoder;if($&&typeof $==="string")if(Q.fs.existsSync($))Y.method=V0.Constants.FILE,Y.filename=$,X=Q.fs.readFileSync($);else throw V0.Errors.INVALID_FILENAME();let W=new lO4(X,Y),{canonical:G,sanitize:K,zipnamefix:V}=V0;function U(L){if(L&&W){var O;if(typeof L==="string")O=W.getEntry(K0.posix.normalize(L));if(typeof L==="object"&&typeof L.entryName<"u"&&typeof L.header<"u")O=W.getEntry(L.entryName);if(O)return O}return null}function z(L){let{join:O,normalize:B,sep:q}=K0.posix;return O(K0.isAbsolute(L)?"/":".",B(q+L.split("\\").join(q)+q))}function Z(L){if(L instanceof RegExp)return function(O){return function(B){return O.test(B)}}(L);else if(typeof L!=="function")return()=>!0;return L}let H=(L,O)=>{let B=O.slice(-1);return B=B===Q.sep?Q.sep:"",K0.relative(L,O)+B};return{readFile:function(L,O){var B=U(L);return B&&B.getData(O)||null},childCount:function(L){let O=U(L);if(O)return W.getChildCount(O)},readFileAsync:function(L,O){var B=U(L);if(B)B.getDataAsync(O);else O(null,"getEntry failed for:"+L)},readAsText:function(L,O){var B=U(L);if(B){var q=B.getData();if(q&&q.length)return q.toString(O||"utf8")}return""},readAsTextAsync:function(L,O,B){var q=U(L);if(q)q.getDataAsync(function(w,_){if(_){O(w,_);return}if(w&&w.length)O(w.toString(B||"utf8"));else O("")});else O("")},deleteFile:function(L,O=!0){var B=U(L);if(B)W.deleteFile(B.entryName,O)},deleteEntry:function(L){var O=U(L);if(O)W.deleteEntry(O.entryName)},addZipComment:function(L){W.comment=L},getZipComment:function(){return W.comment||""},addZipEntryComment:function(L,O){var B=U(L);if(B)B.comment=O},getZipEntryComment:function(L){var O=U(L);if(O)return O.comment||"";return""},updateFile:function(L,O){var B=U(L);if(B)B.setData(O)},addLocalFile:function(L,O,B,q){if(Q.fs.existsSync(L)){O=O?z(O):"";let w=K0.win32.basename(K0.win32.normalize(L));O+=B?B:w;let _=Q.fs.statSync(L),F=_.isFile()?Q.fs.readFileSync(L):Buffer.alloc(0);if(_.isDirectory())O+=Q.sep;this.addFile(O,F,q,_)}else throw V0.Errors.FILE_NOT_FOUND(L)},addLocalFileAsync:function(L,O){L=typeof L==="object"?L:{localPath:L};let B=K0.resolve(L.localPath),{comment:q}=L,{zipPath:w,zipName:_}=L,F=this;Q.fs.stat(B,function(A,M){if(A)return O(A,!1);w=w?z(w):"";let P=K0.win32.basename(K0.win32.normalize(B));if(w+=_?_:P,M.isFile())Q.fs.readFile(B,function(k,I){if(k)return O(k,!1);return F.addFile(w,I,q,M),setImmediate(O,void 0,!0)});else if(M.isDirectory())return w+=Q.sep,F.addFile(w,Buffer.alloc(0),q,M),setImmediate(O,void 0,!0)})},addLocalFolder:function(L,O,B){if(B=Z(B),O=O?z(O):"",L=K0.normalize(L),Q.fs.existsSync(L)){let q=Q.findFiles(L),w=this;if(q.length)for(let _ of q){let F=K0.join(O,H(L,_));if(B(F))w.addLocalFile(_,K0.dirname(F))}}else throw V0.Errors.FILE_NOT_FOUND(L)},addLocalFolderAsync:function(L,O,B,q){q=Z(q),B=B?z(B):"",L=K0.normalize(L);var w=this;Q.fs.open(L,"r",function(_){if(_&&_.code==="ENOENT")O(void 0,V0.Errors.FILE_NOT_FOUND(L));else if(_)O(void 0,_);else{var F=Q.findFiles(L),A=-1,M=function(){if(A+=1,A<F.length){var P=F[A],k=H(L,P).split("\\").join("/");if(k=k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),q(k))Q.fs.stat(P,function(I,u){if(I)O(void 0,I);if(u.isFile())Q.fs.readFile(P,function(v,c){if(v)O(void 0,v);else w.addFile(B+k,c,"",u),M()});else w.addFile(B+k+"/",Buffer.alloc(0),"",u),M()});else process.nextTick(()=>{M()})}else O(!0,void 0)};M()}})},addLocalFolderAsync2:function(L,O){let B=this;L=typeof L==="object"?L:{localPath:L};let q=K0.resolve(z(L.localPath)),{zipPath:w,filter:_,namefix:F}=L;if(_ instanceof RegExp)_=function(P){return function(k){return P.test(k)}}(_);else if(typeof _!=="function")_=function(){return!0};if(w=w?z(w):"",F==="latin1")F=(P)=>P.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof F!=="function")F=(P)=>P;let A=(P)=>K0.join(w,F(H(q,P))),M=(P)=>K0.win32.basename(K0.win32.normalize(F(P)));Q.fs.open(q,"r",function(P){if(P&&P.code==="ENOENT")O(void 0,V0.Errors.FILE_NOT_FOUND(q));else if(P)O(void 0,P);else Q.findFilesAsync(q,function(k,I){if(k)return O(k);if(I=I.filter((u)=>_(A(u))),!I.length)O(void 0,!1);setImmediate(I.reverse().reduce(function(u,v){return function(c,e){if(c||e===!1)return setImmediate(u,c,!1);B.addLocalFileAsync({localPath:v,zipPath:K0.dirname(A(v)),zipName:M(v)},u)}},O))})})},addLocalFolderPromise:function(L,O){return new Promise((B,q)=>{this.addLocalFolderAsync2(Object.assign({localPath:L},O),(w,_)=>{if(w)q(w);if(_)B(this)})})},addFile:function(L,O,B,q){L=V(L);let w=U(L),_=w!=null;if(!_)w=new mO4(Y),w.entryName=L;w.comment=B||"";let F=typeof q==="object"&&q instanceof Q.fs.Stats;if(F)w.header.time=q.mtime;var A=w.isDirectory?16:0;let M=w.isDirectory?16384:32768;if(F)M|=4095&q.mode;else if(typeof q==="number")M|=4095&q;else M|=w.isDirectory?493:420;if(A=(A|M<<16)>>>0,w.attr=A,w.setData(O),!_)W.setEntry(w);return w},getEntries:function(L){return W.password=L,W?W.entries:[]},getEntry:function(L){return U(L)},getEntryCount:function(){return W.getEntryCount()},forEach:function(L){return W.forEach(L)},extractEntryTo:function(L,O,B,q,w,_){q=Oz(!1,q),w=Oz(!1,w),B=Oz(!0,B),_=yM$(w,_);var F=U(L);if(!F)throw V0.Errors.NO_ENTRY();var A=G(F.entryName),M=K(O,_&&!F.isDirectory?G(_):B?A:K0.basename(A));if(F.isDirectory){var P=W.getEntryChildren(F);return P.forEach(function(u){if(u.isDirectory)return;var v=u.getData();if(!v)throw V0.Errors.CANT_EXTRACT_FILE();var c=G(u.entryName),e=K(O,B?c:K0.basename(c));let X$=w?u.header.fileAttr:void 0;Q.writeFileTo(e,v,q,X$)}),!0}var k=F.getData(W.password);if(!k)throw V0.Errors.CANT_EXTRACT_FILE();if(Q.fs.existsSync(M)&&!q)throw V0.Errors.CANT_OVERRIDE();let I=w?L.header.fileAttr:void 0;return Q.writeFileTo(M,k,q,I),!0},test:function(L){if(!W)return!1;for(var O of W.entries)try{if(O.isDirectory)continue;var B=W.entries[O].getData(L);if(!B)return!1}catch(q){return!1}return!0},extractAllTo:function(L,O,B,q){if(B=Oz(!1,B),q=yM$(B,q),O=Oz(!1,O),!W)throw V0.Errors.NO_ZIP();W.entries.forEach(function(w){var _=K(L,G(w.entryName));if(w.isDirectory){Q.makeDir(_);return}var F=w.getData(q);if(!F)throw V0.Errors.CANT_EXTRACT_FILE();let A=B?w.header.fileAttr:void 0;Q.writeFileTo(_,F,O,A);try{Q.fs.utimesSync(_,w.header.time,w.header.time)}catch(M){throw V0.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(L,O,B,q){if(q=cO4(O,B,q),B=Oz(!1,B),O=Oz(!1,O),!q)return new Promise((M,P)=>{this.extractAllToAsync(L,O,B,function(k){if(k)P(k);else M(this)})});if(!W){q(V0.Errors.NO_ZIP());return}L=K0.resolve(L);let w=(M)=>K(L,K0.normalize(G(M.entryName))),_=(M,P)=>Error(M+': "'+P+'"'),F=[],A=[];W.entries.forEach((M)=>{if(M.isDirectory)F.push(M);else A.push(M)});for(let M of F){let P=w(M),k=B?M.header.fileAttr:void 0;try{if(Q.makeDir(P),k)Q.fs.chmodSync(P,k);Q.fs.utimesSync(P,M.header.time,M.header.time)}catch(I){q(_("Unable to create folder",P))}}A.reverse().reduce(function(M,P){return function(k){if(k)M(k);else{let I=K0.normalize(G(P.entryName)),u=K(L,I);P.getDataAsync(function(v,c){if(c)M(c);else if(!v)M(V0.Errors.CANT_EXTRACT_FILE());else{let e=B?P.header.fileAttr:void 0;Q.writeFileToAsync(u,v,O,e,function(X$){if(!X$)M(_("Unable to write file",u));Q.fs.utimes(u,P.header.time,P.header.time,function(h$){if(h$)M(_("Unable to set times",u));else M()})})}})}}},q)()},writeZip:function(L,O){if(arguments.length===1){if(typeof L==="function")O=L,L=""}if(!L&&Y.filename)L=Y.filename;if(!L)return;var B=W.compressToBuffer();if(B){var q=Q.writeFileTo(L,B,!0);if(typeof O==="function")O(!q?Error("failed"):null,"")}},writeZipPromise:function(L,O){let{overwrite:B,perm:q}=Object.assign({overwrite:!0},O);return new Promise((w,_)=>{if(!L&&Y.filename)L=Y.filename;if(!L)_("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((F)=>{let A=(M)=>M?w(M):_("ADM-ZIP: Wasn't able to write zip file");Q.writeFileToAsync(L,F,B,q,A)},_)})},toBufferPromise:function(){return new Promise((L,O)=>{W.toAsyncBuffer(L,O)})},toBuffer:function(L,O,B,q){if(typeof L==="function")return W.toAsyncBuffer(L,O,B,q),null;return W.compressToBuffer()}}}});class gM${DEFAULT_TTL_MS=60000;cache;timer;constructor($=new aZ){this.timer=$,this.cache=new vK($,{ttlMs:this.DEFAULT_TTL_MS})}async isAccessibilityEnabled($,J,X){if(X?.isEnabled("force-accessibility-mode"))return j.debug(`[AccessibilityDetector] Force-enabled via feature flag for device ${$}`),!0;if(X&&!X.isEnabled("accessibility-auto-detect"))return j.debug(`[AccessibilityDetector] Auto-detection disabled via feature flag for device ${$}`),!1;let W=this.cache.get($);if(W)return j.debug(`[AccessibilityDetector] Using cached result for device ${$}: enabled=${W.enabled}, service=${W.service}`),W.enabled;j.debug(`[AccessibilityDetector] Detecting accessibility state for device ${$}`);let G=this.timer.now(),{enabled:K,service:V}=await this.detectAccessibilityState($,J),U=this.timer.now()-G;if(U>50)j.warn(`[AccessibilityDetector] Detection took ${U}ms (target: <50ms) for device ${$}`);else j.debug(`[AccessibilityDetector] Detection completed in ${U}ms for device ${$}`);return this.cache.set($,{enabled:K,service:V}),K}async detectMethod($,J,X){if(X?.isEnabled("force-accessibility-mode"))return"talkback";if(X&&!X.isEnabled("accessibility-auto-detect"))return"unknown";let W=this.cache.get($);if(W)return W.service;let{enabled:G,service:K}=await this.detectAccessibilityState($,J);return this.cache.set($,{enabled:G,service:K}),K}invalidateCache($){j.debug(`[AccessibilityDetector] Invalidating cache for device ${$}`),this.cache.delete($)}clearAllCache(){j.debug("[AccessibilityDetector] Clearing all cached entries"),this.cache.clear()}async detectAccessibilityState($,J){try{let Y=(await J.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(Y.includes("com.google.android.marvin.talkback")||Y.includes("TalkBackService"))return j.debug(`[AccessibilityDetector] TalkBack detected as enabled on device ${$}`),{enabled:!0,service:"talkback"};if(Y!=="null"&&Y.length>0&&!Y.includes("null"))return j.debug(`[AccessibilityDetector] Unknown accessibility service detected on device ${$}: ${Y}`),{enabled:!0,service:"unknown"};return j.debug(`[AccessibilityDetector] No accessibility services enabled on device ${$}`),{enabled:!1,service:"unknown"}}catch(X){return j.error(`[AccessibilityDetector] Failed to detect accessibility state for device ${$}:`,X),{enabled:!1,service:"unknown"}}}}var fJ;var cK=D(()=>{m();J$();xC();fJ=new gM$});import{execFile as nO4}from"child_process";import{createWriteStream as dO4}from"fs";import*as mM$ from"fs/promises";import iO4 from"http";import oO4 from"https";import*as lM$ from"path";import{promisify as rO4}from"util";class Bz{async download($,J){await mM$.mkdir(lM$.dirname(J),{recursive:!0});try{await this.downloadWithCurl($,J);return}catch(X){if(!this.isCommandUnavailable(X,"curl"))throw X;j.warn("[FileDownloader] curl unavailable, falling back to wget",{error:X instanceof Error?X.message:String(X)})}try{await this.downloadWithWget($,J);return}catch(X){if(!this.isCommandUnavailable(X,"wget"))throw X;j.warn("[FileDownloader] wget unavailable, falling back to Node HTTP",{error:X instanceof Error?X.message:String(X)})}await this.downloadWithNodeHttp($,J,0)}async downloadWithCurl($,J){await uM$("curl",["--fail","--location","--retry","3","--retry-delay","1","--silent","--show-error","-o",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithWget($,J){await uM$("wget",["--tries=3","--timeout=30","-O",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithNodeHttp($,J,X){if(X>5)throw Error(`Too many redirects while downloading ${$}`);await new Promise((Y,Q)=>{let G=($.startsWith("https:")?oO4:iO4).get($,{headers:{"User-Agent":"auto-mobile"}},(K)=>{let V=K.statusCode??0;if(V>=300&&V<400&&K.headers.location){K.resume();let z=new URL(K.headers.location,$).toString();this.downloadWithNodeHttp(z,J,X+1).then(Y).catch(Q);return}if(V<200||V>=300){K.resume(),Q(Error(`Download failed with status ${V} from ${$}`));return}let U=dO4(J);K.pipe(U),U.on("finish",()=>U.close(()=>Y())),U.on("error",(z)=>{U.close(),Q(z)})});G.setTimeout(30000,()=>{G.destroy(Error(`Download request timed out for ${$}`))}),G.on("error",Q)})}isCommandUnavailable($,J){if(!$||typeof $!=="object")return!1;let X=$,Y=typeof X.code==="number"?X.code:Number(X.code);if(X.code==="ENOENT"||!Number.isNaN(Y)&&Y===127)return!0;let Q=`${X.message??""} ${X.stderr??""}`.toLowerCase();if(Q.includes("command not found")||Q.includes("not recognized as an internal or external command")||Q.includes(`${J}: not found`)||Q.includes(`not found: ${J}`))return!0;return!1}}var uM$;var cC=D(()=>{m();uM$=rO4(nO4)});import{execFile as tO4}from"child_process";import{createReadStream as aO4}from"fs";import sO4 from"crypto";import{promisify as eO4}from"util";class Fz{async computeFileSha256($){let J=await this.tryChecksumCommand([$],"sha256sum");if(J)return{checksum:J,source:"sha256sum"};let X=await this.tryChecksumCommand(["-a","256",$],"shasum");if(X)return{checksum:X,source:"shasum"};let Y=sO4.createHash("sha256");return await new Promise((Q,W)=>{let G=aO4($);G.on("data",(K)=>Y.update(K)),G.on("error",W),G.on("end",()=>Q())}),{checksum:Y.digest("hex"),source:"node"}}async tryChecksumCommand($,J){try{let{stdout:X}=await $B4(J,$,{timeout:120000,maxBuffer:10485760}),Y=X.trim().split(/\s+/)[0]?.replace(/^\\/,"");if(!Y)return j.warn("[ChecksumCalculator] checksum tool returned no output",{tool:J}),null;return Y}catch(X){return j.info("[ChecksumCalculator] checksum tool unavailable, falling back",{tool:J,error:X instanceof Error?X.message:String(X)}),null}}}var $B4;var pC=D(()=>{m();$B4=eO4(tO4)});var cM$={};y4(cM$,{AndroidCtrlProxyManager:()=>H$});import*as J0 from"fs/promises";import*as U0 from"path";import JB4 from"crypto";import RD from"os";var ta,H$;var zX=D(()=>{p$();m();i$();x9();cK();v$();J$();cC();pC();q9();ta=T7(ra(),1);H$=class H${device;adb;static PACKAGE="dev.jasonpearson.automobile.ctrlproxy";static ACTIVITY="dev.jasonpearson.automobile.ctrlproxy.MainActivity";static LEGACY_PACKAGE="dev.jasonpearson.automobile.accessibilityservice";cachedAvailability=null;static AVAILABILITY_CACHE_TTL=3600000;cachedVersionCheck=null;static VERSION_CHECK_CACHE_TTL=60000;cachedInstallation=null;cachedEnabled=null;static STATUS_CACHE_TTL=1800000;cachedToggleCapabilities=null;attemptedAutomatedSetup=!1;static instances=new Map;static expectedChecksumOverride=null;static accessibilityDetectorOverride=null;static prefetchPromise=null;static prefetchedApkPath=null;static prefetchError=null;static adbFactory=r;timer;fileDownloader;checksumCalculator;static defaultFileDownloader=new Bz;static defaultChecksumCalculator=new Fz;constructor($,J,X=y,Y=H$.defaultFileDownloader,Q=H$.defaultChecksumCalculator){if(!(process.env.HOME||a$("os").homedir()))throw Error("Home directory for current user not found");this.device=$,this.adb=J,this.timer=X,this.fileDownloader=Y,this.checksumCalculator=Q}static getInstance($,J=r){if(KY($,"AndroidCtrlProxyManager.getInstance"),!H$.instances.has($.deviceId)){let X,Y;if(J&&typeof J.create==="function")Y=J,X=Y.create($);else if(J){let Q=J;X=Q,Y={create:()=>Q}}else Y=r,X=Y.create($);H$.adbFactory=Y,H$.instances.set($.deviceId,new H$($,X))}return H$.instances.get($.deviceId)}static createForTestingWithDeps($,J,X=y,Y=H$.defaultFileDownloader,Q=H$.defaultChecksumCalculator){return KY($,"AndroidCtrlProxyManager.createForTestingWithDeps"),new H$($,J,X,Y,Q)}static resetInstances(){H$.instances.clear()}static prefetchApk(){if(H$.prefetchPromise!==null){j.info("[CTRL_PROXY] APK prefetch already initiated, skipping");return}let $=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH?.trim();if($&&$.length>0){j.info("[CTRL_PROXY] Using local APK override, skipping prefetch");return}j.info("[CTRL_PROXY] Starting APK prefetch");let J=y.now();H$.prefetchError=null,H$.prefetchPromise=H$.doPrefetch().then((X)=>{let Y=y.now()-J;if(X)H$.prefetchedApkPath=X,j.info(`[CTRL_PROXY] APK prefetch completed in ${Y}ms`,{path:X});return X}).catch((X)=>{let Y=y.now()-J;return H$.prefetchError=X instanceof Error?X:Error(String(X)),j.warn(`[CTRL_PROXY] APK prefetch failed after ${Y}ms`,{error:H$.prefetchError.message}),H$.prefetchPromise=null,null})}static async doPrefetch(){if(H$.isPinnedVersionUnverifiable())return j.warn(`[CTRL_PROXY] Prefetch skipped: AUTOMOBILE_VERSION=${Z6()} is not in the release checksum registry, so the APK cannot be integrity-verified`),null;let $=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-prefetch-")),J=U0.join($,"control-proxy.apk");try{let X=kW();j.info("[CTRL_PROXY] Prefetch: downloading APK",{url:X,destination:J}),await H$.defaultFileDownloader.download(X,J);let Y=await J0.stat(J);if(Y.size<1e4)throw Error(`Prefetched APK is too small (${Y.size} bytes), likely invalid`);H$.verifyApkIntegrityStatic(J);let Q=H$.expectedChecksumOverride??mK();if(Q.length>0){let{checksum:W}=await H$.defaultChecksumCalculator.computeFileSha256(J);if(W.toLowerCase()!==Q.toLowerCase())throw Error(`APK checksum verification failed. Expected: ${Q}, Got: ${W}`);j.info("[CTRL_PROXY] Prefetch: checksum verified",{checksum:W})}return j.info("[CTRL_PROXY] Prefetch: APK ready",{path:J,size:Y.size}),J}catch(X){throw await J0.rm($,{recursive:!0,force:!0}).catch(()=>{}),X}}static async getPrefetchedApkPath(){if(H$.prefetchPromise===null)return null;try{return await H$.prefetchPromise,H$.prefetchedApkPath}catch($){return j.debug(`[CTRL_PROXY] Prefetched APK unavailable: ${$ instanceof Error?$.message:String($)}`,$),null}}static async consumePrefetchedApk($){let J=await H$.getPrefetchedApkPath();if(!J)return!1;try{return await J0.mkdir(U0.dirname($),{recursive:!0}),await J0.copyFile(J,$),j.info("[CTRL_PROXY] Copied prefetched APK",{source:J,destination:$}),!0}catch(X){return j.warn("[CTRL_PROXY] Failed to copy prefetched APK",{error:X instanceof Error?X.message:String(X)}),!1}}static async consumeCompletedPrefetchedApk($){if(!H$.prefetchedApkPath)return!1;try{return await J0.mkdir(U0.dirname($),{recursive:!0}),await J0.copyFile(H$.prefetchedApkPath,$),j.info("[CTRL_PROXY] Copied completed prefetched APK",{source:H$.prefetchedApkPath,destination:$}),!0}catch(J){return j.warn("[CTRL_PROXY] Failed to copy completed prefetched APK",{error:J instanceof Error?J.message:String(J)}),!1}}static async cleanupPrefetchedApk(){if(H$.prefetchedApkPath){try{let $=U0.dirname(H$.prefetchedApkPath);await J0.rm($,{recursive:!0,force:!0}),j.info("[CTRL_PROXY] Cleaned up prefetched APK",{path:$})}catch($){j.warn("[CTRL_PROXY] Failed to clean up prefetched APK",{error:$ instanceof Error?$.message:String($)})}H$.prefetchedApkPath=null}H$.prefetchPromise=null,H$.prefetchError=null}static verifyApkIntegrityStatic($){try{if(!new ta.default($).getEntries().some((Q)=>Q.entryName==="AndroidManifest.xml"))throw Error("AndroidManifest.xml missing")}catch(J){throw Error(`APK integrity check failed: ${J instanceof Error?J.message:String(J)}`)}}static setExpectedChecksumForTesting($){H$.expectedChecksumOverride=$}static setAccessibilityDetectorForTesting($){H$.accessibilityDetectorOverride=$}getAccessibilityDetector(){return H$.accessibilityDetectorOverride||fJ}clearAvailabilityCache(){this.cachedAvailability=null,this.cachedInstallation=null,this.cachedEnabled=null,this.cachedToggleCapabilities=null,this.cachedVersionCheck=null,j.info("[CTRL_PROXY] Cleared all availability caches")}resetSetupState(){this.attemptedAutomatedSetup=!1,this.clearAvailabilityCache(),j.info("[CTRL_PROXY] Reset setup state - next setup will be a full attempt")}async isInstalled(){if(this.cachedInstallation&&this.cachedInstallation.isInstalled){let $=this.timer.now()-this.cachedInstallation.timestamp;if($<H$.STATUS_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached installation status (age: ${$}ms): ${this.cachedInstallation.isInstalled?"installed":"not installed"}`),this.cachedInstallation.isInstalled;else this.cachedInstallation=null}try{j.debug("[CTRL_PROXY] Checking if accessibility service is installed");let J=(await this.adb.executeCommand(`shell pm list packages | grep ${H$.PACKAGE}`,void 0,void 0,!0)).stdout.includes(H$.PACKAGE);return this.cachedInstallation={isInstalled:J,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Service installation status: ${J?"installed":"not installed"} (cached for ${H$.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return j.warn(`[CTRL_PROXY] Error checking installation status: ${$}`),!1}}async isEnabled(){if(this.cachedEnabled&&this.cachedEnabled.isEnabled){let $=this.timer.now()-this.cachedEnabled.timestamp;if($<H$.STATUS_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached enabled status (age: ${$}ms): ${this.cachedEnabled.isEnabled?"enabled":"disabled"}`),this.cachedEnabled.isEnabled;else this.cachedEnabled=null}try{j.debug("[CTRL_PROXY] Checking if accessibility service is enabled");let J=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.includes(H$.PACKAGE);return this.cachedEnabled={isEnabled:J,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Service enabled status: ${J?"enabled":"disabled"} (cached for ${H$.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return j.warn(`[CTRL_PROXY] Error checking enabled status: ${$}`),!1}}async isEnabledForUser($){try{j.debug(`[CTRL_PROXY] Checking if accessibility service is enabled for user ${$}`);let X=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.includes(H$.PACKAGE);return j.debug(`[CTRL_PROXY] Service enabled status for user ${$}: ${X?"enabled":"disabled"}`),X}catch(J){return j.warn(`[CTRL_PROXY] Error checking enabled status for user ${$}: ${J}`),!1}}async isAvailable(){let $=this.timer.now();if(this.cachedAvailability&&this.cachedAvailability.isAvailable){let J=this.timer.now()-this.cachedAvailability.timestamp;if(J<H$.AVAILABILITY_CACHE_TTL)return j.debug(`[CTRL_PROXY] Using cached overall availability (age: ${J}ms): ${this.cachedAvailability.isAvailable}`),this.cachedAvailability.isAvailable;else this.cachedAvailability=null}j.debug("[CTRL_PROXY] Checking availability (no cached result available)");try{let[J,X]=await Promise.all([this.isInstalled(),this.isEnabled()]),Y=J&&X,Q=this.timer.now()-$;return this.cachedAvailability={isAvailable:Y,timestamp:this.timer.now()},j.debug(`[CTRL_PROXY] Availability check completed in ${Q}ms - Available: ${Y} (cached for ${H$.AVAILABILITY_CACHE_TTL/1000/60} minutes)`),Y}catch(J){let X=this.timer.now()-$;return j.warn(`[CTRL_PROXY] Availability check failed after ${X}ms: ${J}`),this.cachedAvailability=null,!1}}async getInstalledApkSha256(){return(await this.getInstalledApkSha256WithDetails()).sha256}async isVersionCompatible(){let $=this.getExpectedChecksum();if($.length===0)return j.warn("[CTRL_PROXY] Version check skipped (no checksum provided)"),!0;let J=await this.getInstalledApkSha256();if(!J)return!1;return J.toLowerCase()===$.toLowerCase()}async ensureCompatibleVersion($={}){let J=P$();if(this.assertPinnedVersionVerifiable(),!$.bypassVersionCheckCache&&!$.allowDownloadWhenInstalled){let K=this.getCachedVersionCheckResult();if(K)return K}this.clearServiceAvailabilityCache(),J.startOperation("uninstallLegacy"),await this.uninstallLegacyPackageIfPresent(),J.endOperation("uninstallLegacy");let X=this.getExpectedChecksum();if(X.length===0)if($.allowDownloadWhenInstalled)j.warn("[CTRL_PROXY] Version checksum unavailable; explicit update will install APK without checksum comparison");else return this.cacheVersionCheckResult({status:"skipped",expectedSha256:X});J.startOperation("checkInstalled");let Y=await this.isInstalled();if(J.endOperation("checkInstalled"),Y&&this.shouldSkipDownloadIfInstalled()&&!H$.isKnownExplicitPinConfigured()&&!$.allowDownloadWhenInstalled)return j.warn("[CTRL_PROXY] Skipping APK download/version check (preinstalled APK allowed)"),this.cacheVersionCheckResult({status:"skipped",expectedSha256:X});let Q={status:"compatible",expectedSha256:X},W=!1;if(Y){J.startOperation("getChecksum");let K=await this.getInstalledApkSha256WithDetails();J.endOperation("getChecksum"),Q.installedSha256=K.sha256,Q.installedShaSource=K.source,Q.installedApkPath=K.apkPath;let V=K.sha256;if(W=X.length>0&&!V,X.length>0&&!V&&K.error)j.warn("[CTRL_PROXY] Unable to determine installed APK checksum, forcing reinstall",{error:K.error});if(X.length>0&&V&&V.toLowerCase()===X.toLowerCase())return this.cacheVersionCheckResult(Q);if(X.length>0&&!$.allowDownloadWhenInstalled&&!this.getApkPathOverride()){let U=await this.tryUpgradeFromCompletedPrefetch(Q,J);if(U)return this.cacheVersionCheckResult(U);if(H$.isKnownExplicitPinConfigured())throw H$.createKnownPinMismatchError(X,V);return j.warn("[CTRL_PROXY] Installed APK SHA differs from expected release; accepting preinstalled CtrlProxy for nonblocking readiness",{expected:X,actual:V}),this.queueBackgroundApkRefresh(),this.cacheVersionCheckResult({...Q,status:"skipped",attemptedDownload:!1,acceptedPreinstalled:!0})}if(W)j.warn("[CTRL_PROXY] Installed APK checksum unavailable, forcing reinstall");else j.info("[CTRL_PROXY] Installed APK SHA mismatch, attempting upgrade",{expected:X,actual:V})}else j.info("[CTRL_PROXY] Service not installed, downloading and installing");let G=null;try{return Q.attemptedDownload=!0,J.startOperation("downloadApk"),G=await this.downloadApk(),J.endOperation("downloadApk"),await this.installDownloadedApk(G,Q,Y,W,J)}catch(K){let V=K instanceof Error?K.message:String(K),U=this.isNetworkError(V),z={...Q,status:"failed",downloadUnavailable:U,error:U?"Unable to download the latest accessibility service APK while offline. Connect to the internet and retry.":V};return $.allowDownloadWhenInstalled?z:this.cacheVersionCheckResult(z)}finally{if(G)await this.cleanupApk(G)}}async tryUpgradeFromCompletedPrefetch($,J){if(!H$.prefetchedApkPath)return null;let X=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-prefetch-upgrade-")),Y=U0.join(X,"control-proxy.apk");try{if(!await H$.consumeCompletedPrefetchedApk(Y))return null;let W=await this.installDownloadedApk(Y,{...$,attemptedDownload:!1},!0,!1,J);if(W.status!=="failed")return W;if(this.clearServiceAvailabilityCache(),!await this.isInstalled())return j.warn("[CTRL_PROXY] Completed prefetched APK install failed and existing CtrlProxy is no longer installed",{error:W.error||W.upgradeError||W.reinstallError}),W;if(j.warn("[CTRL_PROXY] Completed prefetched APK install failed; verified existing CtrlProxy remains installed for readiness",{error:W.error||W.upgradeError||W.reinstallError}),H$.isKnownExplicitPinConfigured())throw H$.createKnownPinMismatchError($.expectedSha256??"",$.installedSha256);return{...W,status:"skipped",acceptedPreinstalled:!0}}finally{await this.cleanupApk(Y)}}async installDownloadedApk($,J,X,Y,Q){if(X&&!Y)try{return J.attemptedInstall=!0,Q.startOperation("installApk"),await this.adb.executeCommand(`install -r -d "${$}"`),Q.endOperation("installApk"),j.info("[CTRL_PROXY] APK upgraded successfully"),this.clearAvailabilityCache(),{...J,status:"upgraded"}}catch(W){Q.endOperation("installApk");let G=W instanceof Error?W.message:String(W);j.warn("[CTRL_PROXY] Upgrade failed, attempting reinstall",{error:G}),J.upgradeError=G}try{if(J.attemptedReinstall=!0,X)await this.adb.executeCommand(`shell pm uninstall ${H$.PACKAGE}`);return Q.startOperation("installApk"),await this.install($),Q.endOperation("installApk"),await this.enable(),j.info(`[CTRL_PROXY] APK ${X?"reinstalled":"installed"} and service enabled`),this.clearAvailabilityCache(),{...J,status:X?"reinstalled":"installed"}}catch(W){let G=W instanceof Error?W.message:String(W);return j.warn(`[CTRL_PROXY] APK reinstall failed: ${G}`,W),this.clearServiceAvailabilityCache(),{...J,status:"failed",reinstallError:G}}}async downloadApk(){this.assertPinnedVersionVerifiable();let $=P$(),J=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-")),X=U0.join(J,"control-proxy.apk");try{let Y=this.getApkPathOverride();if($.startOperation("httpDownload"),Y){if(j.info("Using local accessibility service APK",{path:Y}),!(await J0.stat(Y)).isFile())throw Error(`Accessibility APK override is not a file: ${Y}`);await J0.copyFile(Y,X)}else if(await H$.consumePrefetchedApk(X))j.info("Using prefetched accessibility service APK",{path:X});else{let K=kW();j.info("Downloading APK",{url:K,destination:X}),await this.fileDownloader.download(K,X)}$.endOperation("httpDownload");let Q=await J0.stat(X);if(Q.size<1e4)throw Error(`Downloaded APK is too small (${Q.size} bytes), likely invalid`);this.verifyApkIntegrity(X);let W=this.getExpectedChecksum();if(W.length>0){$.startOperation("checksumVerify");let{checksum:G,source:K}=await this.checksumCalculator.computeFileSha256(X),V=G.toLowerCase(),U=W.toLowerCase();if(V!==U)throw j.warn("APK checksum verification failed",{expected:U,actual:V}),Error(`APK checksum verification failed. Expected: ${U}, Got: ${V}`);j.info("APK checksum verified successfully",{checksum:V,source:K}),$.endOperation("checksumVerify")}else j.warn("APK checksum verification SKIPPED - no checksum provided (development mode)",{apkUrl:kW()});return j.info("APK downloaded successfully",{path:X,size:Q.size}),X}catch(Y){try{await this.cleanupApk(X)}catch(Q){j.debug(`[CTRL_PROXY] Failed to clean up incomplete APK download: ${Q instanceof Error?Q.message:String(Q)}`,Q)}throw Error(`Failed to download APK: ${Y instanceof Error?Y.message:String(Y)}`)}}verifyApkIntegrity($){try{if(!new ta.default($).getEntries().some((Q)=>Q.entryName==="AndroidManifest.xml"))throw Error("AndroidManifest.xml missing")}catch(J){throw Error(`APK integrity check failed: ${J instanceof Error?J.message:String(J)}`)}}async uninstallLegacyPackageIfPresent(){try{if(!(await this.adb.executeCommand(`shell pm list packages | grep ${H$.LEGACY_PACKAGE}`,void 0,void 0,!0)).stdout.includes(H$.LEGACY_PACKAGE))return;j.info(`[CTRL_PROXY] Found legacy package ${H$.LEGACY_PACKAGE}, uninstalling`),await this.adb.executeCommand(`shell pm uninstall ${H$.LEGACY_PACKAGE}`),j.info("[CTRL_PROXY] Legacy package uninstalled")}catch($){j.warn(`[CTRL_PROXY] Failed to check/uninstall legacy package: ${$}`)}}async install($){try{j.info("Installing APK",{path:$});let J=await this.adb.executeCommand(`install "${$}"`),X=J.toString().toLowerCase();if(X.includes("failure")||X.includes("error"))throw Error(`Installation failed: ${J.toString()}`);if(!X.includes("success"))j.warn("Installation result unclear",{result:J.toString()});j.info("APK installed successfully")}catch(J){throw Error(`Failed to install APK: ${J instanceof Error?J.message:String(J)}`)}}async enableViaSettings(){let $=await this.getToggleCapabilities();if(!$.supportsSettingsToggle){let J=`Settings-based accessibility toggle is not supported on this device. ${$.reason||""}`;throw j.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{j.info("Enabling Accessibility Service via settings commands");let J=P$();J.startOperation("readCurrentServices");let X=await this.adb.executeCommand("shell settings get secure enabled_accessibility_services");J.endOperation("readCurrentServices");let Y=X.stdout.trim();if(Y==="null"||Y==="")Y="";let Q=`${H$.PACKAGE}/${H$.PACKAGE}.CtrlProxy`;if(J.startOperation("writeServiceEnabled"),Y.includes(Q))j.info("Accessibility Service is already enabled");else{let W=Y?`${Y}:${Q}`:Q;await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${W}"`),j.info("Added AutoMobile service to enabled_accessibility_services")}await this.adb.executeCommand("shell settings put secure accessibility_enabled 1"),J.endOperation("writeServiceEnabled"),j.info("Accessibility Service enabled successfully via settings"),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(J){let X=J instanceof Error?J.message:String(J),Y=X.toLowerCase();if(Y.includes("permission denied")||Y.includes("not permitted"))throw Error(`Permission denied while enabling Accessibility Service. The device may require root access, device owner status, or special shell permissions. Original error: ${X}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service. Ensure the device is connected and adb is responsive. Original error: ${X}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service. The device may be unresponsive. Original error: ${X}`);else throw Error(`Failed to enable Accessibility Service via settings. This may indicate an ADB communication issue or device state problem. Original error: ${X}`)}}async disableViaSettings(){let $=await this.getToggleCapabilities();if(!$.supportsSettingsToggle){let J=`Settings-based accessibility toggle is not supported on this device. ${$.reason||""}`;throw j.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{j.info("Disabling Accessibility Service via settings commands");let X=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(X==="null"||X===""){j.info("No accessibility services enabled");return}let Y=X.split(":"),Q=Y.filter((W)=>!W.includes(H$.PACKAGE));if(Q.length===Y.length)j.info("Accessibility Service was not enabled");else{let W=Q.join(":");if(await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${W}"`),j.info("Removed AutoMobile service from enabled_accessibility_services"),Q.length===0||Q.length===1&&Q[0]==="")await this.adb.executeCommand("shell settings put secure accessibility_enabled 0"),j.info("Disabled accessibility globally (no other services remain)")}j.info("Accessibility Service disabled successfully via settings"),this.clearAvailabilityCache()}catch(J){let X=J instanceof Error?J.message:String(J),Y=X.toLowerCase();if(Y.includes("permission denied")||Y.includes("not permitted"))throw Error(`Permission denied while disabling Accessibility Service. The device may require root access, device owner status, or special shell permissions. Original error: ${X}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while disabling Accessibility Service. Ensure the device is connected and adb is responsive. Original error: ${X}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while disabling Accessibility Service. The device may be unresponsive. Original error: ${X}`);else throw Error(`Failed to disable Accessibility Service via settings. This may indicate an ADB communication issue or device state problem. Original error: ${X}`)}}async enable(){return this.enableViaSettings()}async enableForUser($){let J=await this.getToggleCapabilities();if(!J.supportsSettingsToggle){let X=`Settings-based accessibility toggle is not supported on this device. ${J.reason||""}`;throw j.error("[CTRL_PROXY] "+X,{capabilities:J}),Error(X)}try{j.info(`[CTRL_PROXY] Enabling Accessibility Service via settings commands for user ${$}`);let Y=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.trim();if(Y==="null"||Y==="")Y="";let Q=`${H$.PACKAGE}/${H$.PACKAGE}.CtrlProxy`;if(Y.includes(Q))j.info(`[CTRL_PROXY] Accessibility Service is already enabled for user ${$}`);else{let W=Y?`${Y}:${Q}`:Q;await this.adb.executeCommand(`shell settings --user ${$} put secure enabled_accessibility_services "${W}"`),j.info(`[CTRL_PROXY] Added AutoMobile service to enabled_accessibility_services for user ${$}`)}await this.adb.executeCommand(`shell settings --user ${$} put secure accessibility_enabled 1`),j.info(`[CTRL_PROXY] Accessibility Service enabled successfully via settings for user ${$}`),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(X){let Y=X instanceof Error?X.message:String(X),Q=Y.toLowerCase();if(Q.includes("permission denied")||Q.includes("not permitted"))throw Error(`Permission denied while enabling Accessibility Service for user ${$}. The device may require root access, device owner status, or special shell permissions. Original error: ${Y}`);else if(Q.includes("device not found")||Q.includes("no devices")||Q.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service for user ${$}. Ensure the device is connected and adb is responsive. Original error: ${Y}`);else if(Q.includes("timeout")||Q.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service for user ${$}. The device may be unresponsive. Original error: ${Y}`);else throw Error(`Failed to enable Accessibility Service via settings for user ${$}. This may indicate an ADB communication issue or device state problem. Original error: ${Y}`)}}async cleanupApk($){try{let J=U0.resolve(RD.tmpdir()),X=U0.resolve(U0.dirname($)),Y=U0.basename(X),Q=U0.relative(J,X),W=Boolean(Q)&&!Q.startsWith("..")&&!U0.isAbsolute(Q)&&Y.startsWith("auto-mobile-");if(await J0.rm($,{force:!0}),W)await J0.rm(X,{recursive:!0,force:!0}),j.info("Temporary APK directory cleaned up",{path:X});else j.info("Temporary APK file cleaned up",{path:$})}catch(J){j.warn("Failed to clean up temporary APK file",{path:$,error:J instanceof Error?J.message:String(J)})}}async setup($=!1,J=new a){J.serial("a11yServiceSetup");let X=null;if(this.attemptedAutomatedSetup){try{let[Y,Q]=await J.track("recheckStatus",async()=>{return Promise.all([this.isInstalled(),this.isEnabled()])});if(Y&&Q)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()}}catch(Y){j.warn(`[CTRL_PROXY] Failed to re-check service status: ${Y}`)}return J.end(),{success:!1,message:"Setup already attempted",perfTiming:J.getTimings()}}try{let Y=await J.track("ensureCompatibleVersion",()=>this.ensureCompatibleVersion());if(Y.status==="failed")return J.end(),{success:!1,message:"Failed to ensure compatible Accessibility Service version",error:Y.error||Y.upgradeError||Y.reinstallError,perfTiming:J.getTimings()};if(Y.status==="upgraded"||Y.status==="installed"||Y.status==="reinstalled")return J.end(),{success:!0,message:"Accessibility Service upgraded to a compatible version",perfTiming:J.getTimings()};let Q=await J.track("checkInstalled",()=>this.isInstalled()),W=await J.track("checkEnabled",()=>this.isEnabled());if(!$&&Q&&W)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()};if(this.attemptedAutomatedSetup=!0,$||!Q)X=await J.track("downloadApk",()=>this.downloadApk()),await J.track("installApk",()=>this.install(X));if(!W)await J.track("enableService",()=>this.enable());return J.end(),{success:!0,message:"Accessibility Service installed and activated successfully",perfTiming:J.getTimings()}}catch(Y){let Q=Y instanceof Error?Y.message:String(Y),W=Q.toLowerCase(),G="Failed to setup Accessibility Service";if(W.includes("permission denied")||W.includes("not permitted"))G="Failed to setup Accessibility Service due to permission error";else if(W.includes("device not found")||W.includes("no devices")||W.includes("offline"))G="Failed to setup Accessibility Service due to device connection issue";else if(W.includes("timeout")||W.includes("timed out"))G="Failed to setup Accessibility Service due to timeout";else if(W.includes("download")||W.includes("network")||W.includes("unreachable"))G="Failed to setup Accessibility Service due to network/download error";else if(W.includes("not supported"))G="Failed to setup Accessibility Service - settings toggle not supported on this device";else if(W.includes("installation failed")||W.includes("install"))G="Failed to setup Accessibility Service due to APK installation error";return J.end(),{success:!1,message:G,error:Q,perfTiming:J.getTimings()}}finally{if(X)await this.cleanupApk(X)}}async isEmulator(){try{if((await this.adb.executeCommand("shell getprop ro.kernel.qemu",void 0,void 0,!0)).stdout.trim()==="1")return[!0,!1];let Y=(await this.adb.executeCommand("shell getprop ro.product.model",void 0,void 0,!0)).stdout.trim().toLowerCase();return[Y.includes("emulator")||Y.includes("sdk"),!1]}catch($){return j.warn("[CTRL_PROXY] Error detecting device type",{error:$}),[!1,!0]}}async getApiLevel(){try{let $=await this.adb.executeCommand("shell getprop ro.build.version.sdk",void 0,void 0,!0),J=parseInt($.stdout.trim(),10);return[isNaN(J)?null:J,!1]}catch($){return j.warn("[CTRL_PROXY] Error getting API level",{error:$}),[null,!0]}}async canUseSettingsToggle(){return(await this.getToggleCapabilities()).supportsSettingsToggle}async getToggleCapabilities(){if(this.cachedToggleCapabilities)return j.info("[CTRL_PROXY] Using cached toggle capabilities"),this.cachedToggleCapabilities;j.info("[CTRL_PROXY] Detecting toggle capabilities");let[$,J]=await this.isEmulator(),[X,Y]=await this.getApiLevel(),Q=$?"emulator":"physical",W=!1,G,K=J||Y;if(K)W=!1,G="Unable to detect device capabilities due to transient error. Retry may succeed.",j.warn("[CTRL_PROXY] Detection error - not caching result",{emulatorDetectionError:J,apiLevelDetectionError:Y});else if($)W=!0,j.info("[CTRL_PROXY] Emulator detected - settings toggle supported");else W=!1,G="Physical devices may require root, device owner status, or special shell permissions for programmatic accessibility toggle",j.info("[CTRL_PROXY] Physical device detected - settings toggle may not be supported",{reason:G});if(!K&&X!==null&&X<16)W=!1,G=`API level ${X} is too old (requires API 16+)`,j.warn("[CTRL_PROXY] API level too old for settings toggle",{apiLevel:X});let V={supportsSettingsToggle:W,deviceType:Q,apiLevel:X,reason:G};if(!K)this.cachedToggleCapabilities=V,j.info("[CTRL_PROXY] Toggle capabilities detected and cached",V);else j.info("[CTRL_PROXY] Toggle capabilities detected but not cached due to detection errors",V);return V}async getInstalledApkSha256WithDetails(){let $=await this.getInstalledApkPath();if(!$)return{sha256:null,source:"none",error:"Installed APK path not found"};try{let W=(await this.adb.executeCommand(`shell sha256sum "${$}"`)).stdout.trim().split(/\s+/)[0];if(W)return{sha256:W,source:"device",apkPath:$}}catch(Q){j.warn("[CTRL_PROXY] sha256sum unavailable or failed, falling back to host hash",{error:Q instanceof Error?Q.message:String(Q)})}let J=await J0.mkdtemp(U0.join(RD.tmpdir(),"auto-mobile-apk-")),X=(this.device.deviceId||"device").replace(/[^a-zA-Z0-9_.-]/g,"_"),Y=U0.join(J,`control-proxy-installed-${X}.apk`);try{await this.adb.executeCommand(`pull "${$}" "${Y}"`);let Q=await J0.readFile(Y);return{sha256:JB4.createHash("sha256").update(Q).digest("hex"),source:"host",apkPath:$}}catch(Q){return j.warn("[CTRL_PROXY] Failed to compute installed APK hash via host fallback",{error:Q instanceof Error?Q.message:String(Q)}),{sha256:null,source:"none",apkPath:$,error:Q instanceof Error?Q.message:String(Q)}}finally{try{await J0.rm(J,{recursive:!0,force:!0})}catch(Q){j.debug(`[CTRL_PROXY] Failed to remove temporary APK hash directory: ${Q instanceof Error?Q.message:String(Q)}`,Q)}}}async getInstalledApkPath(){try{let J=(await this.adb.executeCommand(`shell pm path ${H$.PACKAGE}`,void 0,void 0,!0)).stdout.split(`
170
170
  `).map((X)=>X.trim()).find((X)=>X.startsWith("package:"));if(!J)return null;return J.replace("package:","").trim()||null}catch($){return j.warn("[CTRL_PROXY] Failed to resolve installed APK path",{error:$ instanceof Error?$.message:String($)}),null}}getExpectedChecksum(){if(this.shouldSkipChecksum())return"";return H$.expectedChecksumOverride??mK()}assertPinnedVersionVerifiable(){if(H$.isPinnedVersionUnverifiable())throw new C(`AUTOMOBILE_VERSION=${Z6()} is not in the AutoMobile release checksum registry, so the CtrlProxy APK cannot be integrity-verified. Pin a released version, or set AUTOMOBILE_SKIP_ACCESSIBILITY_CHECKSUM=1 to override.`)}getCachedVersionCheckResult(){if(!this.cachedVersionCheck)return null;let $=this.timer.now()-this.cachedVersionCheck.timestamp;if($>=H$.VERSION_CHECK_CACHE_TTL)return this.cachedVersionCheck=null,null;return j.debug(`[CTRL_PROXY] Using cached version check result (age: ${$}ms): ${this.cachedVersionCheck.result.status}`),{...this.cachedVersionCheck.result}}cacheVersionCheckResult($){return this.cachedVersionCheck={result:{...$},timestamp:this.timer.now()},$}clearServiceAvailabilityCache(){this.cachedAvailability=null,this.cachedInstallation=null,this.cachedEnabled=null}queueBackgroundApkRefresh(){if(this.fileDownloader!==H$.defaultFileDownloader)return;H$.prefetchApk()}isNetworkError($){let J=$.toLowerCase();return J.includes("could not resolve host")||J.includes("failed to connect")||J.includes("network is unreachable")||J.includes("connection timed out")||J.includes("timed out")||J.includes("name lookup timed out")||J.includes("temporary failure in name resolution")||J.includes("enotfound")||J.includes("econnrefused")||J.includes("ehostunreach")||J.includes("enetunreach")||J.includes("etimedout")}getApkPathOverride(){let $=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH;if(!$)return null;let J=$.trim();return J.length>0?W1(J):null}shouldSkipChecksum(){return H$.isChecksumSkipConfigured()}static isChecksumSkipConfigured(){let $=process.env.AUTOMOBILE_SKIP_ACCESSIBILITY_CHECKSUM??process.env.AUTO_MOBILE_ACCESSIBILITY_SERVICE_SHA_SKIP_CHECK;if($&&($==="1"||$.toLowerCase()==="true"))return!0;let J=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH?.trim();return Boolean(J&&J.length>0)}static isPinnedVersionUnverifiable(){if(H$.expectedChecksumOverride!==null)return!1;if(H$.isChecksumSkipConfigured())return!1;return bW()&&!Zz()}static isKnownExplicitPinConfigured(){if(H$.isChecksumSkipConfigured())return!1;return bW()&&Zz()}static createKnownPinMismatchError($,J){return new C(`Installed CtrlProxy APK SHA differs from expected release checksum for AUTOMOBILE_VERSION=${Z6()}. Expected: ${$}, Got: ${J??"unknown"}. Install the pinned CtrlProxy APK, restart with a matching daemon, or set AUTOMOBILE_SKIP_ACCESSIBILITY_CHECKSUM=1 to override.`)}shouldSkipDownloadIfInstalled(){let $=process.env.AUTOMOBILE_SKIP_ACCESSIBILITY_DOWNLOAD_IF_INSTALLED;return Boolean($&&($==="1"||$.toLowerCase()==="true"))}}});import*as nC from"fs/promises";class aa{fileDownloader;checksumCalculator;constructor($=new Bz,J=new Fz){this.fileDownloader=$,this.checksumCalculator=J}async download($,J){return this.fileDownloader.download($,J)}async computeFileSha256($){return this.checksumCalculator.computeFileSha256($)}async extractBundle($,J){await nC.rm(J,{recursive:!0,force:!0}),await nC.mkdir(J,{recursive:!0}),new pM$.default($).extractAllTo(J,!0)}}var pM$;var nM$=D(()=>{cC();pC();pM$=T7(ra(),1)});import{createHash as XB4}from"crypto";import{promises as sa}from"fs";import{join as dM$,relative as YB4}from"path";var QB4,WB4=($)=>$==="_CodeSignature"||$==="SC_Info",GB4=($)=>$==="embedded.mobileprovision"||$==="PkgInfo"||$.endsWith(".xcent"),KB4=($)=>{let J=$.split("/").filter(Boolean);if(J.some((Y)=>WB4(Y)))return!0;let X=J[J.length-1]??"";return GB4(X)},iM$=async($,J,X,Y)=>{let Q=await X.readDir(J);Q.sort();for(let W of Q){let G=dM$(J,W),K=await X.stat(G),V=YB4($,G).replace(/\\/g,"/");if(KB4(V))continue;if(K.isDirectory())await iM$($,G,X,Y);else if(K.isFile())Y.push(V)}},ED=async($,J=QB4)=>{let X=XB4("sha256"),Y=[];await iM$($,$,J,Y),Y.sort();for(let Q of Y){let W=dM$($,Q);X.update(Q),X.update("\x00");let G=await J.readFile(W);X.update(G),X.update("\x00")}return X.digest("hex")};var ea=D(()=>{QB4={readDir:async($)=>sa.readdir($),stat:async($)=>sa.stat($),readFile:async($)=>sa.readFile($)}});var dC=x((oM$)=>{(function(){oM$.defaults={"0.1":{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},"0.2":{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
171
171
  `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(oM$)});var UY=x((rM$,pK)=>{(function(){var $,J,X,Y,Q,W,G,K=[].slice,V={}.hasOwnProperty;$=function(){var U,z,Z,H,L,O;if(O=arguments[0],L=2<=arguments.length?K.call(arguments,1):[],Q(Object.assign))Object.assign.apply(null,arguments);else for(U=0,Z=L.length;U<Z;U++)if(H=L[U],H!=null)for(z in H){if(!V.call(H,z))continue;O[z]=H[z]}return O},Q=function(U){return!!U&&Object.prototype.toString.call(U)==="[object Function]"},W=function(U){var z;return!!U&&((z=typeof U)==="function"||z==="object")},X=function(U){if(Q(Array.isArray))return Array.isArray(U);else return Object.prototype.toString.call(U)==="[object Array]"},Y=function(U){var z;if(X(U))return!U.length;else{for(z in U){if(!V.call(U,z))continue;return!1}return!0}},G=function(U){var z,Z;return W(U)&&(Z=Object.getPrototypeOf(U))&&(z=Z.constructor)&&typeof z==="function"&&z instanceof z&&Function.prototype.toString.call(z)===Function.prototype.toString.call(Object)},J=function(U){if(Q(U.valueOf))return U.valueOf();else return U},rM$.assign=$,rM$.isFunction=Q,rM$.isObject=W,rM$.isArray=X,rM$.isEmpty=Y,rM$.isPlainObject=G,rM$.getValue=J}).call(rM$)});var $s=x((tM$,aM$)=>{(function(){var $;aM$.exports=$=function(){function J(){}return J.prototype.hasFeature=function(X,Y){return!0},J.prototype.createDocumentType=function(X,Y,Q){throw Error("This DOM method is not implemented.")},J.prototype.createDocument=function(X,Y,Q){throw Error("This DOM method is not implemented.")},J.prototype.createHTMLDocument=function(X){throw Error("This DOM method is not implemented.")},J.prototype.getFeature=function(X,Y){throw Error("This DOM method is not implemented.")},J}()}).call(tM$)});var $A$=x((sM$,eM$)=>{(function(){var $;eM$.exports=$=function(){function J(){}return J.prototype.handleError=function(X){throw Error(X)},J}()}).call(sM$)});var YA$=x((JA$,XA$)=>{(function(){var $;XA$.exports=$=function(){function J(X){this.arr=X||[]}return Object.defineProperty(J.prototype,"length",{get:function(){return this.arr.length}}),J.prototype.item=function(X){return this.arr[X]||null},J.prototype.contains=function(X){return this.arr.indexOf(X)!==-1},J}()}).call(JA$)});var GA$=x((QA$,WA$)=>{(function(){var $,J,X;J=$A$(),X=YA$(),WA$.exports=$=function(){function Y(){var Q;this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new J,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=Q=Object.create(this.defaultParams)}return Object.defineProperty(Y.prototype,"parameterNames",{get:function(){return new X(Object.keys(this.defaultParams))}}),Y.prototype.getParameter=function(Q){if(this.params.hasOwnProperty(Q))return this.params[Q];else return null},Y.prototype.canSetParameter=function(Q,W){return!0},Y.prototype.setParameter=function(Q,W){if(W!=null)return this.params[Q]=W;else return delete this.params[Q]},Y}()}).call(QA$)});var y0=x((KA$,VA$)=>{(function(){VA$.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(KA$)});var Js=x((UA$,zA$)=>{(function(){var $,J,X;$=y0(),X=jX(),zA$.exports=J=function(){function Y(Q,W,G){if(this.parent=Q,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(W==null)throw Error("Missing attribute name. "+this.debugInfo(W));this.name=this.stringify.name(W),this.value=this.stringify.attValue(G),this.type=$.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(Y.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(Y.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(Y.prototype,"textContent",{get:function(){return this.value},set:function(Q){return this.value=Q||""}}),Object.defineProperty(Y.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(Y.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(Y.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(Y.prototype,"specified",{get:function(){return!0}}),Y.prototype.clone=function(){return Object.create(this)},Y.prototype.toString=function(Q){return this.options.writer.attribute(this,this.options.writer.filterOptions(Q))},Y.prototype.debugInfo=function(Q){if(Q=Q||this.name,Q==null)return"parent: <"+this.parent.name+">";else return"attribute: {"+Q+"}, parent: <"+this.parent.name+">"},Y.prototype.isEqualNode=function(Q){if(Q.namespaceURI!==this.namespaceURI)return!1;if(Q.prefix!==this.prefix)return!1;if(Q.localName!==this.localName)return!1;if(Q.value!==this.value)return!1;return!0},Y}()}).call(UA$)});var iC=x((jA$,ZA$)=>{(function(){var $;ZA$.exports=$=function(){function J(X){this.nodes=X}return Object.defineProperty(J.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),J.prototype.clone=function(){return this.nodes=null},J.prototype.getNamedItem=function(X){return this.nodes[X]},J.prototype.setNamedItem=function(X){var Y=this.nodes[X.nodeName];return this.nodes[X.nodeName]=X,Y||null},J.prototype.removeNamedItem=function(X){var Y=this.nodes[X];return delete this.nodes[X],Y||null},J.prototype.item=function(X){return this.nodes[Object.keys(this.nodes)[X]]||null},J.prototype.getNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},J.prototype.setNamedItemNS=function(X){throw Error("This DOM method is not implemented.")},J.prototype.removeNamedItemNS=function(X,Y){throw Error("This DOM method is not implemented.")},J}()}).call(jA$)});var oC=x((HA$,LA$)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U=function(Z,H){for(var L in H)if(z.call(H,L))Z[L]=H[L];function O(){this.constructor=Z}return O.prototype=H.prototype,Z.prototype=new O,Z.__super__=H.prototype,Z},z={}.hasOwnProperty;V=UY(),K=V.isObject,G=V.isFunction,W=V.getValue,Q=jX(),$=y0(),J=Js(),Y=iC(),LA$.exports=X=function(Z){U(H,Z);function H(L,O,B){var q,w,_,F;if(H.__super__.constructor.call(this,L),O==null)throw Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(O),this.type=$.Element,this.attribs={},this.schemaTypeInfo=null,B!=null)this.attribute(B);if(L.type===$.Document){if(this.isRoot=!0,this.documentObject=L,L.rootObject=this,L.children){F=L.children;for(w=0,_=F.length;w<_;w++)if(q=F[w],q.type===$.DocType){q.name=this.name;break}}}}return Object.defineProperty(H.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(H.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(H.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(H.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(H.prototype,"id",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(H.prototype,"className",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(H.prototype,"classList",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(H.prototype,"attributes",{get:function(){if(!this.attributeMap||!this.attributeMap.nodes)this.attributeMap=new Y(this.attribs);return this.attributeMap}}),H.prototype.clone=function(){var L,O,B,q;if(B=Object.create(this),B.isRoot)B.documentObject=null;B.attribs={},q=this.attribs;for(O in q){if(!z.call(q,O))continue;L=q[O],B.attribs[O]=L.clone()}return B.children=[],this.children.forEach(function(w){var _=w.clone();return _.parent=B,B.children.push(_)}),B},H.prototype.attribute=function(L,O){var B,q;if(L!=null)L=W(L);if(K(L))for(B in L){if(!z.call(L,B))continue;q=L[B],this.attribute(B,q)}else{if(G(O))O=O.apply();if(this.options.keepNullAttributes&&O==null)this.attribs[L]=new J(this,L,"");else if(O!=null)this.attribs[L]=new J(this,L,O)}return this},H.prototype.removeAttribute=function(L){var O,B,q;if(L==null)throw Error("Missing attribute name. "+this.debugInfo());if(L=W(L),Array.isArray(L))for(B=0,q=L.length;B<q;B++)O=L[B],delete this.attribs[O];else delete this.attribs[L];return this},H.prototype.toString=function(L){return this.options.writer.element(this,this.options.writer.filterOptions(L))},H.prototype.att=function(L,O){return this.attribute(L,O)},H.prototype.a=function(L,O){return this.attribute(L,O)},H.prototype.getAttribute=function(L){if(this.attribs.hasOwnProperty(L))return this.attribs[L].value;else return null},H.prototype.setAttribute=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getAttributeNode=function(L){if(this.attribs.hasOwnProperty(L))return this.attribs[L];else return null},H.prototype.setAttributeNode=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.removeAttributeNode=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getElementsByTagName=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getAttributeNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.setAttributeNS=function(L,O,B){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.removeAttributeNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getAttributeNodeNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.setAttributeNodeNS=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getElementsByTagNameNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.hasAttribute=function(L){return this.attribs.hasOwnProperty(L)},H.prototype.hasAttributeNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.setIdAttribute=function(L,O){if(this.attribs.hasOwnProperty(L))return this.attribs[L].isId;else return O},H.prototype.setIdAttributeNS=function(L,O,B){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.setIdAttributeNode=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getElementsByTagName=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getElementsByTagNameNS=function(L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.getElementsByClassName=function(L){throw Error("This DOM method is not implemented."+this.debugInfo())},H.prototype.isEqualNode=function(L){var O,B,q;if(!H.__super__.isEqualNode.apply(this,arguments).isEqualNode(L))return!1;if(L.namespaceURI!==this.namespaceURI)return!1;if(L.prefix!==this.prefix)return!1;if(L.localName!==this.localName)return!1;if(L.attribs.length!==this.attribs.length)return!1;for(O=B=0,q=this.attribs.length-1;0<=q?B<=q:B>=q;O=0<=q?++B:--B)if(!this.attribs[O].isEqualNode(L.attribs[O]))return!1;return!0},H}(Q)}).call(HA$)});var PD=x((OA$,BA$)=>{(function(){var $,J,X=function(Q,W){for(var G in W)if(Y.call(W,G))Q[G]=W[G];function K(){this.constructor=Q}return K.prototype=W.prototype,Q.prototype=new K,Q.__super__=W.prototype,Q},Y={}.hasOwnProperty;J=jX(),BA$.exports=$=function(Q){X(W,Q);function W(G){W.__super__.constructor.call(this,G),this.value=""}return Object.defineProperty(W.prototype,"data",{get:function(){return this.value},set:function(G){return this.value=G||""}}),Object.defineProperty(W.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(W.prototype,"textContent",{get:function(){return this.value},set:function(G){return this.value=G||""}}),W.prototype.clone=function(){return Object.create(this)},W.prototype.substringData=function(G,K){throw Error("This DOM method is not implemented."+this.debugInfo())},W.prototype.appendData=function(G){throw Error("This DOM method is not implemented."+this.debugInfo())},W.prototype.insertData=function(G,K){throw Error("This DOM method is not implemented."+this.debugInfo())},W.prototype.deleteData=function(G,K){throw Error("This DOM method is not implemented."+this.debugInfo())},W.prototype.replaceData=function(G,K,V){throw Error("This DOM method is not implemented."+this.debugInfo())},W.prototype.isEqualNode=function(G){if(!W.__super__.isEqualNode.apply(this,arguments).isEqualNode(G))return!1;if(G.data!==this.data)return!1;return!0},W}(J)}).call(OA$)});var rC=x((FA$,DA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;$=y0(),X=PD(),DA$.exports=J=function(W){Y(G,W);function G(K,V){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=$.CData,this.value=this.stringify.cdata(V)}return G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return this.options.writer.cdata(this,this.options.writer.filterOptions(K))},G}(X)}).call(FA$)});var tC=x((qA$,wA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;$=y0(),J=PD(),wA$.exports=X=function(W){Y(G,W);function G(K,V){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=$.Comment,this.value=this.stringify.comment(V)}return G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return this.options.writer.comment(this,this.options.writer.filterOptions(K))},G}(J)}).call(qA$)});var aC=x((MA$,AA$)=>{(function(){var $,J,X,Y,Q=function(G,K){for(var V in K)if(W.call(K,V))G[V]=K[V];function U(){this.constructor=G}return U.prototype=K.prototype,G.prototype=new U,G.__super__=K.prototype,G},W={}.hasOwnProperty;Y=UY().isObject,X=jX(),$=y0(),AA$.exports=J=function(G){Q(K,G);function K(V,U,z,Z){var H;if(K.__super__.constructor.call(this,V),Y(U))H=U,U=H.version,z=H.encoding,Z=H.standalone;if(!U)U="1.0";if(this.type=$.Declaration,this.version=this.stringify.xmlVersion(U),z!=null)this.encoding=this.stringify.xmlEncoding(z);if(Z!=null)this.standalone=this.stringify.xmlStandalone(Z)}return K.prototype.toString=function(V){return this.options.writer.declaration(this,this.options.writer.filterOptions(V))},K}(X)}).call(MA$)});var sC=x((NA$,_A$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;X=jX(),$=y0(),_A$.exports=J=function(W){Y(G,W);function G(K,V,U,z,Z,H){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing DTD element name. "+this.debugInfo());if(U==null)throw Error("Missing DTD attribute name. "+this.debugInfo(V));if(!z)throw Error("Missing DTD attribute type. "+this.debugInfo(V));if(!Z)throw Error("Missing DTD attribute default. "+this.debugInfo(V));if(Z.indexOf("#")!==0)Z="#"+Z;if(!Z.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(V));if(H&&!Z.match(/^(#FIXED|#DEFAULT)$/))throw Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(V));if(this.elementName=this.stringify.name(V),this.type=$.AttributeDeclaration,this.attributeName=this.stringify.name(U),this.attributeType=this.stringify.dtdAttType(z),H)this.defaultValue=this.stringify.dtdAttDefault(H);this.defaultValueType=Z}return G.prototype.toString=function(K){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(K))},G}(X)}).call(NA$)});var eC=x((RA$,EA$)=>{(function(){var $,J,X,Y,Q=function(G,K){for(var V in K)if(W.call(K,V))G[V]=K[V];function U(){this.constructor=G}return U.prototype=K.prototype,G.prototype=new U,G.__super__=K.prototype,G},W={}.hasOwnProperty;Y=UY().isObject,X=jX(),$=y0(),EA$.exports=J=function(G){Q(K,G);function K(V,U,z,Z){if(K.__super__.constructor.call(this,V),z==null)throw Error("Missing DTD entity name. "+this.debugInfo(z));if(Z==null)throw Error("Missing DTD entity value. "+this.debugInfo(z));if(this.pe=!!U,this.name=this.stringify.name(z),this.type=$.EntityDeclaration,!Y(Z))this.value=this.stringify.dtdEntityValue(Z),this.internal=!0;else{if(!Z.pubID&&!Z.sysID)throw Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(z));if(Z.pubID&&!Z.sysID)throw Error("System identifier is required for a public external entity. "+this.debugInfo(z));if(this.internal=!1,Z.pubID!=null)this.pubID=this.stringify.dtdPubID(Z.pubID);if(Z.sysID!=null)this.sysID=this.stringify.dtdSysID(Z.sysID);if(Z.nData!=null)this.nData=this.stringify.dtdNData(Z.nData);if(this.pe&&this.nData)throw Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(z))}}return Object.defineProperty(K.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(K.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(K.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(K.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(K.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(K.prototype,"xmlVersion",{get:function(){return null}}),K.prototype.toString=function(V){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(V))},K}(X)}).call(RA$)});var $T=x((PA$,CA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;X=jX(),$=y0(),CA$.exports=J=function(W){Y(G,W);function G(K,V,U){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing DTD element name. "+this.debugInfo());if(!U)U="(#PCDATA)";if(Array.isArray(U))U="("+U.join(",")+")";this.name=this.stringify.name(V),this.type=$.ElementDeclaration,this.value=this.stringify.dtdElementValue(U)}return G.prototype.toString=function(K){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(K))},G}(X)}).call(PA$)});var JT=x((TA$,IA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;X=jX(),$=y0(),IA$.exports=J=function(W){Y(G,W);function G(K,V,U){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing DTD notation name. "+this.debugInfo(V));if(!U.pubID&&!U.sysID)throw Error("Public or system identifiers are required for an external entity. "+this.debugInfo(V));if(this.name=this.stringify.name(V),this.type=$.NotationDeclaration,U.pubID!=null)this.pubID=this.stringify.dtdPubID(U.pubID);if(U.sysID!=null)this.sysID=this.stringify.dtdSysID(U.sysID)}return Object.defineProperty(G.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(G.prototype,"systemId",{get:function(){return this.sysID}}),G.prototype.toString=function(K){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(K))},G}(X)}).call(TA$)});var XT=x((SA$,bA$)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U=function(Z,H){for(var L in H)if(z.call(H,L))Z[L]=H[L];function O(){this.constructor=Z}return O.prototype=H.prototype,Z.prototype=new O,Z.__super__=H.prototype,Z},z={}.hasOwnProperty;V=UY().isObject,K=jX(),$=y0(),J=sC(),Y=eC(),X=$T(),Q=JT(),G=iC(),bA$.exports=W=function(Z){U(H,Z);function H(L,O,B){var q,w,_,F,A,M;if(H.__super__.constructor.call(this,L),this.type=$.DocType,L.children){F=L.children;for(w=0,_=F.length;w<_;w++)if(q=F[w],q.type===$.Element){this.name=q.name;break}}if(this.documentObject=L,V(O))A=O,O=A.pubID,B=A.sysID;if(B==null)M=[O,B],B=M[0],O=M[1];if(O!=null)this.pubID=this.stringify.dtdPubID(O);if(B!=null)this.sysID=this.stringify.dtdSysID(B)}return Object.defineProperty(H.prototype,"entities",{get:function(){var L,O,B,q,w;q={},w=this.children;for(O=0,B=w.length;O<B;O++)if(L=w[O],L.type===$.EntityDeclaration&&!L.pe)q[L.name]=L;return new G(q)}}),Object.defineProperty(H.prototype,"notations",{get:function(){var L,O,B,q,w;q={},w=this.children;for(O=0,B=w.length;O<B;O++)if(L=w[O],L.type===$.NotationDeclaration)q[L.name]=L;return new G(q)}}),Object.defineProperty(H.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(H.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(H.prototype,"internalSubset",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),H.prototype.element=function(L,O){var B=new X(this,L,O);return this.children.push(B),this},H.prototype.attList=function(L,O,B,q,w){var _=new J(this,L,O,B,q,w);return this.children.push(_),this},H.prototype.entity=function(L,O){var B=new Y(this,!1,L,O);return this.children.push(B),this},H.prototype.pEntity=function(L,O){var B=new Y(this,!0,L,O);return this.children.push(B),this},H.prototype.notation=function(L,O){var B=new Q(this,L,O);return this.children.push(B),this},H.prototype.toString=function(L){return this.options.writer.docType(this,this.options.writer.filterOptions(L))},H.prototype.ele=function(L,O){return this.element(L,O)},H.prototype.att=function(L,O,B,q,w){return this.attList(L,O,B,q,w)},H.prototype.ent=function(L,O){return this.entity(L,O)},H.prototype.pent=function(L,O){return this.pEntity(L,O)},H.prototype.not=function(L,O){return this.notation(L,O)},H.prototype.up=function(){return this.root()||this.documentObject},H.prototype.isEqualNode=function(L){if(!H.__super__.isEqualNode.apply(this,arguments).isEqualNode(L))return!1;if(L.name!==this.name)return!1;if(L.publicId!==this.publicId)return!1;if(L.systemId!==this.systemId)return!1;return!0},H}(K)}).call(SA$)});var YT=x((kA$,fA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;$=y0(),J=jX(),fA$.exports=X=function(W){Y(G,W);function G(K,V){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing raw text. "+this.debugInfo());this.type=$.Raw,this.value=this.stringify.raw(V)}return G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return this.options.writer.raw(this,this.options.writer.filterOptions(K))},G}(J)}).call(kA$)});var QT=x((xA$,vA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;$=y0(),J=PD(),vA$.exports=X=function(W){Y(G,W);function G(K,V){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=$.Text,this.value=this.stringify.text(V)}return Object.defineProperty(G.prototype,"isElementContentWhitespace",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(G.prototype,"wholeText",{get:function(){var K,V,U;U="",V=this.previousSibling;while(V)U=V.data+U,V=V.previousSibling;U+=this.data,K=this.nextSibling;while(K)U=U+K.data,K=K.nextSibling;return U}}),G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return this.options.writer.text(this,this.options.writer.filterOptions(K))},G.prototype.splitText=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.replaceWholeText=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},G}(J)}).call(xA$)});var WT=x((yA$,hA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;$=y0(),J=PD(),hA$.exports=X=function(W){Y(G,W);function G(K,V,U){if(G.__super__.constructor.call(this,K),V==null)throw Error("Missing instruction target. "+this.debugInfo());if(this.type=$.ProcessingInstruction,this.target=this.stringify.insTarget(V),this.name=this.target,U)this.value=this.stringify.insValue(U)}return G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(K))},G.prototype.isEqualNode=function(K){if(!G.__super__.isEqualNode.apply(this,arguments).isEqualNode(K))return!1;if(K.target!==this.target)return!1;return!0},G}(J)}).call(yA$)});var Xs=x((gA$,uA$)=>{(function(){var $,J,X,Y=function(W,G){for(var K in G)if(Q.call(G,K))W[K]=G[K];function V(){this.constructor=W}return V.prototype=G.prototype,W.prototype=new V,W.__super__=G.prototype,W},Q={}.hasOwnProperty;X=jX(),$=y0(),uA$.exports=J=function(W){Y(G,W);function G(K){G.__super__.constructor.call(this,K),this.type=$.Dummy}return G.prototype.clone=function(){return Object.create(this)},G.prototype.toString=function(K){return""},G}(X)}).call(gA$)});var cA$=x((mA$,lA$)=>{(function(){var $;lA$.exports=$=function(){function J(X){this.nodes=X}return Object.defineProperty(J.prototype,"length",{get:function(){return this.nodes.length||0}}),J.prototype.clone=function(){return this.nodes=null},J.prototype.item=function(X){return this.nodes[X]||null},J}()}).call(mA$)});var dA$=x((pA$,nA$)=>{(function(){nA$.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(pA$)});var jX=x((iA$,oA$)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U,z,Z,H,L,O,B,q,w,_,F={}.hasOwnProperty;_=UY(),w=_.isObject,q=_.isFunction,B=_.isEmpty,O=_.getValue,K=null,X=null,Y=null,Q=null,W=null,H=null,L=null,Z=null,G=null,J=null,z=null,V=null,$=null,oA$.exports=U=function(){function A(M){if(this.parent=M,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(this.value=null,this.children=[],this.baseURI=null,!K)K=oC(),X=rC(),Y=tC(),Q=aC(),W=XT(),H=YT(),L=QT(),Z=WT(),G=Xs(),J=y0(),z=cA$(),V=iC(),$=dA$()}return Object.defineProperty(A.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(A.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(A.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(A.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(A.prototype,"childNodes",{get:function(){if(!this.childNodeList||!this.childNodeList.nodes)this.childNodeList=new z(this.children);return this.childNodeList}}),Object.defineProperty(A.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(A.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(A.prototype,"previousSibling",{get:function(){var M=this.parent.children.indexOf(this);return this.parent.children[M-1]||null}}),Object.defineProperty(A.prototype,"nextSibling",{get:function(){var M=this.parent.children.indexOf(this);return this.parent.children[M+1]||null}}),Object.defineProperty(A.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(A.prototype,"textContent",{get:function(){var M,P,k,I,u;if(this.nodeType===J.Element||this.nodeType===J.DocumentFragment){u="",I=this.children;for(P=0,k=I.length;P<k;P++)if(M=I[P],M.textContent)u+=M.textContent;return u}else return null},set:function(M){throw Error("This DOM method is not implemented."+this.debugInfo())}}),A.prototype.setParent=function(M){var P,k,I,u,v;if(this.parent=M,M)this.options=M.options,this.stringify=M.stringify;u=this.children,v=[];for(k=0,I=u.length;k<I;k++)P=u[k],v.push(P.setParent(this));return v},A.prototype.element=function(M,P,k){var I,u,v,c,e,X$,h$,L4,b$,$1,S4;if(X$=null,P===null&&k==null)b$=[{},null],P=b$[0],k=b$[1];if(P==null)P={};if(P=O(P),!w(P))$1=[P,k],k=$1[0],P=$1[1];if(M!=null)M=O(M);if(Array.isArray(M))for(v=0,h$=M.length;v<h$;v++)u=M[v],X$=this.element(u);else if(q(M))X$=this.element(M.apply());else if(w(M))for(e in M){if(!F.call(M,e))continue;if(S4=M[e],q(S4))S4=S4.apply();if(!this.options.ignoreDecorators&&this.stringify.convertAttKey&&e.indexOf(this.stringify.convertAttKey)===0)X$=this.attribute(e.substr(this.stringify.convertAttKey.length),S4);else if(!this.options.separateArrayItems&&Array.isArray(S4)&&B(S4))X$=this.dummy();else if(w(S4)&&B(S4))X$=this.element(e);else if(!this.options.keepNullNodes&&S4==null)X$=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(S4))for(c=0,L4=S4.length;c<L4;c++)u=S4[c],I={},I[e]=u,X$=this.element(I);else if(w(S4))if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&e.indexOf(this.stringify.convertTextKey)===0)X$=this.element(S4);else X$=this.element(e),X$.element(S4);else X$=this.element(e,S4)}else if(!this.options.keepNullNodes&&k===null)X$=this.dummy();else if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&M.indexOf(this.stringify.convertTextKey)===0)X$=this.text(k);else if(!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&M.indexOf(this.stringify.convertCDataKey)===0)X$=this.cdata(k);else if(!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&M.indexOf(this.stringify.convertCommentKey)===0)X$=this.comment(k);else if(!this.options.ignoreDecorators&&this.stringify.convertRawKey&&M.indexOf(this.stringify.convertRawKey)===0)X$=this.raw(k);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&M.indexOf(this.stringify.convertPIKey)===0)X$=this.instruction(M.substr(this.stringify.convertPIKey.length),k);else X$=this.node(M,P,k);if(X$==null)throw Error("Could not create any elements with: "+M+". "+this.debugInfo());return X$},A.prototype.insertBefore=function(M,P,k){var I,u,v,c,e;if(M!=null?M.type:void 0){if(v=M,c=P,v.setParent(this),c)u=children.indexOf(c),e=children.splice(u),children.push(v),Array.prototype.push.apply(children,e);else children.push(v);return v}else{if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(M));return u=this.parent.children.indexOf(this),e=this.parent.children.splice(u),I=this.parent.element(M,P,k),Array.prototype.push.apply(this.parent.children,e),I}},A.prototype.insertAfter=function(M,P,k){var I,u,v;if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(M));return u=this.parent.children.indexOf(this),v=this.parent.children.splice(u+1),I=this.parent.element(M,P,k),Array.prototype.push.apply(this.parent.children,v),I},A.prototype.remove=function(){var M,P;if(this.isRoot)throw Error("Cannot remove the root element. "+this.debugInfo());return M=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[M,M-M+1].concat(P=[])),this.parent},A.prototype.node=function(M,P,k){var I,u;if(M!=null)M=O(M);if(P||(P={}),P=O(P),!w(P))u=[P,k],k=u[0],P=u[1];if(I=new K(this,M,P),k!=null)I.text(k);return this.children.push(I),I},A.prototype.text=function(M){var P;if(w(M))this.element(M);return P=new L(this,M),this.children.push(P),this},A.prototype.cdata=function(M){var P=new X(this,M);return this.children.push(P),this},A.prototype.comment=function(M){var P=new Y(this,M);return this.children.push(P),this},A.prototype.commentBefore=function(M){var P,k,I;return k=this.parent.children.indexOf(this),I=this.parent.children.splice(k),P=this.parent.comment(M),Array.prototype.push.apply(this.parent.children,I),this},A.prototype.commentAfter=function(M){var P,k,I;return k=this.parent.children.indexOf(this),I=this.parent.children.splice(k+1),P=this.parent.comment(M),Array.prototype.push.apply(this.parent.children,I),this},A.prototype.raw=function(M){var P=new H(this,M);return this.children.push(P),this},A.prototype.dummy=function(){var M=new G(this);return M},A.prototype.instruction=function(M,P){var k,I,u,v,c;if(M!=null)M=O(M);if(P!=null)P=O(P);if(Array.isArray(M))for(v=0,c=M.length;v<c;v++)k=M[v],this.instruction(k);else if(w(M))for(k in M){if(!F.call(M,k))continue;I=M[k],this.instruction(k,I)}else{if(q(P))P=P.apply();u=new Z(this,M,P),this.children.push(u)}return this},A.prototype.instructionBefore=function(M,P){var k,I,u;return I=this.parent.children.indexOf(this),u=this.parent.children.splice(I),k=this.parent.instruction(M,P),Array.prototype.push.apply(this.parent.children,u),this},A.prototype.instructionAfter=function(M,P){var k,I,u;return I=this.parent.children.indexOf(this),u=this.parent.children.splice(I+1),k=this.parent.instruction(M,P),Array.prototype.push.apply(this.parent.children,u),this},A.prototype.declaration=function(M,P,k){var I,u;if(I=this.document(),u=new Q(I,M,P,k),I.children.length===0)I.children.unshift(u);else if(I.children[0].type===J.Declaration)I.children[0]=u;else I.children.unshift(u);return I.root()||I},A.prototype.dtd=function(M,P){var k,I,u,v,c,e,X$,h$,L4,b$;I=this.document(),u=new W(I,M,P),L4=I.children;for(v=c=0,X$=L4.length;c<X$;v=++c)if(k=L4[v],k.type===J.DocType)return I.children[v]=u,u;b$=I.children;for(v=e=0,h$=b$.length;e<h$;v=++e)if(k=b$[v],k.isRoot)return I.children.splice(v,0,u),u;return I.children.push(u),u},A.prototype.up=function(){if(this.isRoot)throw Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},A.prototype.root=function(){var M=this;while(M)if(M.type===J.Document)return M.rootObject;else if(M.isRoot)return M;else M=M.parent},A.prototype.document=function(){var M=this;while(M)if(M.type===J.Document)return M;else M=M.parent},A.prototype.end=function(M){return this.document().end(M)},A.prototype.prev=function(){var M=this.parent.children.indexOf(this);if(M<1)throw Error("Already at the first node. "+this.debugInfo());return this.parent.children[M-1]},A.prototype.next=function(){var M=this.parent.children.indexOf(this);if(M===-1||M===this.parent.children.length-1)throw Error("Already at the last node. "+this.debugInfo());return this.parent.children[M+1]},A.prototype.importDocument=function(M){var P=M.root().clone();return P.parent=this,P.isRoot=!1,this.children.push(P),this},A.prototype.debugInfo=function(M){var P,k;if(M=M||this.name,M==null&&!((P=this.parent)!=null?P.name:void 0))return"";else if(M==null)return"parent: <"+this.parent.name+">";else if(!((k=this.parent)!=null?k.name:void 0))return"node: <"+M+">";else return"node: <"+M+">, parent: <"+this.parent.name+">"},A.prototype.ele=function(M,P,k){return this.element(M,P,k)},A.prototype.nod=function(M,P,k){return this.node(M,P,k)},A.prototype.txt=function(M){return this.text(M)},A.prototype.dat=function(M){return this.cdata(M)},A.prototype.com=function(M){return this.comment(M)},A.prototype.ins=function(M,P){return this.instruction(M,P)},A.prototype.doc=function(){return this.document()},A.prototype.dec=function(M,P,k){return this.declaration(M,P,k)},A.prototype.e=function(M,P,k){return this.element(M,P,k)},A.prototype.n=function(M,P,k){return this.node(M,P,k)},A.prototype.t=function(M){return this.text(M)},A.prototype.d=function(M){return this.cdata(M)},A.prototype.c=function(M){return this.comment(M)},A.prototype.r=function(M){return this.raw(M)},A.prototype.i=function(M,P){return this.instruction(M,P)},A.prototype.u=function(){return this.up()},A.prototype.importXMLBuilder=function(M){return this.importDocument(M)},A.prototype.replaceChild=function(M,P){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.removeChild=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.appendChild=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.hasChildNodes=function(){return this.children.length!==0},A.prototype.cloneNode=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.normalize=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.isSupported=function(M,P){return!0},A.prototype.hasAttributes=function(){return this.attribs.length!==0},A.prototype.compareDocumentPosition=function(M){var P,k;if(P=this,P===M)return 0;else if(this.document()!==M.document()){if(k=$.Disconnected|$.ImplementationSpecific,Math.random()<0.5)k|=$.Preceding;else k|=$.Following;return k}else if(P.isAncestor(M))return $.Contains|$.Preceding;else if(P.isDescendant(M))return $.Contains|$.Following;else if(P.isPreceding(M))return $.Preceding;else return $.Following},A.prototype.isSameNode=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.lookupPrefix=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.isDefaultNamespace=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.lookupNamespaceURI=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.isEqualNode=function(M){var P,k,I;if(M.nodeType!==this.nodeType)return!1;if(M.children.length!==this.children.length)return!1;for(P=k=0,I=this.children.length-1;0<=I?k<=I:k>=I;P=0<=I?++k:--k)if(!this.children[P].isEqualNode(M.children[P]))return!1;return!0},A.prototype.getFeature=function(M,P){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.setUserData=function(M,P,k){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.getUserData=function(M){throw Error("This DOM method is not implemented."+this.debugInfo())},A.prototype.contains=function(M){if(!M)return!1;return M===this||this.isDescendant(M)},A.prototype.isDescendant=function(M){var P,k,I,u,v;v=this.children;for(I=0,u=v.length;I<u;I++){if(P=v[I],M===P)return!0;if(k=P.isDescendant(M),k)return!0}return!1},A.prototype.isAncestor=function(M){return M.isDescendant(this)},A.prototype.isPreceding=function(M){var P,k;if(P=this.treePosition(M),k=this.treePosition(this),P===-1||k===-1)return!1;else return P<k},A.prototype.isFollowing=function(M){var P,k;if(P=this.treePosition(M),k=this.treePosition(this),P===-1||k===-1)return!1;else return P>k},A.prototype.treePosition=function(M){var P,k;if(k=0,P=!1,this.foreachTreeNode(this.document(),function(I){if(k++,!P&&I===M)return P=!0}),P)return k;else return-1},A.prototype.foreachTreeNode=function(M,P){var k,I,u,v,c;M||(M=this.document()),v=M.children;for(I=0,u=v.length;I<u;I++)if(k=v[I],c=P(k))return c;else if(c=this.foreachTreeNode(k,P),c)return c},A}()}).call(iA$)});var Ys=x((rA$,tA$)=>{(function(){var $,J=function(Y,Q){return function(){return Y.apply(Q,arguments)}},X={}.hasOwnProperty;tA$.exports=$=function(){function Y(Q){this.assertLegalName=J(this.assertLegalName,this),this.assertLegalChar=J(this.assertLegalChar,this);var W,G,K;if(Q||(Q={}),this.options=Q,!this.options.version)this.options.version="1.0";G=Q.stringify||{};for(W in G){if(!X.call(G,W))continue;K=G[W],this[W]=K}}return Y.prototype.name=function(Q){if(this.options.noValidation)return Q;return this.assertLegalName(""+Q||"")},Y.prototype.text=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(this.textEscape(""+Q||""))},Y.prototype.cdata=function(Q){if(this.options.noValidation)return Q;return Q=""+Q||"",Q=Q.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(Q)},Y.prototype.comment=function(Q){if(this.options.noValidation)return Q;if(Q=""+Q||"",Q.match(/--/))throw Error("Comment text cannot contain double-hypen: "+Q);return this.assertLegalChar(Q)},Y.prototype.raw=function(Q){if(this.options.noValidation)return Q;return""+Q||""},Y.prototype.attValue=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(this.attEscape(Q=""+Q||""))},Y.prototype.insTarget=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.insValue=function(Q){if(this.options.noValidation)return Q;if(Q=""+Q||"",Q.match(/\?>/))throw Error("Invalid processing instruction value: "+Q);return this.assertLegalChar(Q)},Y.prototype.xmlVersion=function(Q){if(this.options.noValidation)return Q;if(Q=""+Q||"",!Q.match(/1\.[0-9]+/))throw Error("Invalid version number: "+Q);return Q},Y.prototype.xmlEncoding=function(Q){if(this.options.noValidation)return Q;if(Q=""+Q||"",!Q.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw Error("Invalid encoding: "+Q);return this.assertLegalChar(Q)},Y.prototype.xmlStandalone=function(Q){if(this.options.noValidation)return Q;if(Q)return"yes";else return"no"},Y.prototype.dtdPubID=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdSysID=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdElementValue=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdAttType=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdAttDefault=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdEntityValue=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.dtdNData=function(Q){if(this.options.noValidation)return Q;return this.assertLegalChar(""+Q||"")},Y.prototype.convertAttKey="@",Y.prototype.convertPIKey="?",Y.prototype.convertTextKey="#text",Y.prototype.convertCDataKey="#cdata",Y.prototype.convertCommentKey="#comment",Y.prototype.convertRawKey="#raw",Y.prototype.assertLegalChar=function(Q){var W,G;if(this.options.noValidation)return Q;if(W="",this.options.version==="1.0"){if(W=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,G=Q.match(W))throw Error("Invalid character in string: "+Q+" at index "+G.index)}else if(this.options.version==="1.1"){if(W=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,G=Q.match(W))throw Error("Invalid character in string: "+Q+" at index "+G.index)}return Q},Y.prototype.assertLegalName=function(Q){var W;if(this.options.noValidation)return Q;if(this.assertLegalChar(Q),W=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!Q.match(W))throw Error("Invalid character in name");return Q},Y.prototype.textEscape=function(Q){var W;if(this.options.noValidation)return Q;return W=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,Q.replace(W,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")},Y.prototype.attEscape=function(Q){var W;if(this.options.noValidation)return Q;return W=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,Q.replace(W,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")},Y}()}).call(rA$)});var CD=x((aA$,sA$)=>{(function(){sA$.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(aA$)});var Qs=x((eA$,$N$)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U,z,Z,H,L,O,B,q,w={}.hasOwnProperty;q=UY().assign,$=y0(),V=aC(),U=XT(),X=rC(),Y=tC(),Z=oC(),L=YT(),O=QT(),H=WT(),z=Xs(),Q=sC(),W=$T(),G=eC(),K=JT(),J=CD(),$N$.exports=B=function(){function _(F){var A,M,P;F||(F={}),this.options=F,M=F.writer||{};for(A in M){if(!w.call(M,A))continue;P=M[A],this["_"+A]=this[A],this[A]=P}}return _.prototype.filterOptions=function(F){var A,M,P,k,I,u,v,c;if(F||(F={}),F=q({},this.options,F),A={writer:this},A.pretty=F.pretty||!1,A.allowEmpty=F.allowEmpty||!1,A.indent=(M=F.indent)!=null?M:" ",A.newline=(P=F.newline)!=null?P:`
172
172
  `,A.offset=(k=F.offset)!=null?k:0,A.dontPrettyTextNodes=(I=(u=F.dontPrettyTextNodes)!=null?u:F.dontprettytextnodes)!=null?I:0,A.spaceBeforeSlash=(v=(c=F.spaceBeforeSlash)!=null?c:F.spacebeforeslash)!=null?v:"",A.spaceBeforeSlash===!0)A.spaceBeforeSlash=" ";return A.suppressPrettyCount=0,A.user={},A.state=J.None,A},_.prototype.indent=function(F,A,M){var P;if(!A.pretty||A.suppressPrettyCount)return"";else if(A.pretty){if(P=(M||0)+A.offset+1,P>0)return Array(P).join(A.indent)}return""},_.prototype.endline=function(F,A,M){if(!A.pretty||A.suppressPrettyCount)return"";else return A.newline},_.prototype.attribute=function(F,A,M){var P;return this.openAttribute(F,A,M),P=" "+F.name+'="'+F.value+'"',this.closeAttribute(F,A,M),P},_.prototype.cdata=function(F,A,M){var P;return this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<![CDATA[",A.state=J.InsideTag,P+=F.value,A.state=J.CloseTag,P+="]]>"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.comment=function(F,A,M){var P;return this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<!-- ",A.state=J.InsideTag,P+=F.value,A.state=J.CloseTag,P+=" -->"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.declaration=function(F,A,M){var P;if(this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<?xml",A.state=J.InsideTag,P+=' version="'+F.version+'"',F.encoding!=null)P+=' encoding="'+F.encoding+'"';if(F.standalone!=null)P+=' standalone="'+F.standalone+'"';return A.state=J.CloseTag,P+=A.spaceBeforeSlash+"?>",P+=this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.docType=function(F,A,M){var P,k,I,u,v;if(M||(M=0),this.openNode(F,A,M),A.state=J.OpenTag,u=this.indent(F,A,M),u+="<!DOCTYPE "+F.root().name,F.pubID&&F.sysID)u+=' PUBLIC "'+F.pubID+'" "'+F.sysID+'"';else if(F.sysID)u+=' SYSTEM "'+F.sysID+'"';if(F.children.length>0){u+=" [",u+=this.endline(F,A,M),A.state=J.InsideTag,v=F.children;for(k=0,I=v.length;k<I;k++)P=v[k],u+=this.writeChildNode(P,A,M+1);A.state=J.CloseTag,u+="]"}return A.state=J.CloseTag,u+=A.spaceBeforeSlash+">",u+=this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),u},_.prototype.element=function(F,A,M){var P,k,I,u,v,c,e,X$,h$,L4,b$,$1,S4,L1;M||(M=0),L4=!1,b$="",this.openNode(F,A,M),A.state=J.OpenTag,b$+=this.indent(F,A,M)+"<"+F.name,$1=F.attribs;for(h$ in $1){if(!w.call($1,h$))continue;P=$1[h$],b$+=this.attribute(P,A,M)}if(I=F.children.length,u=I===0?null:F.children[0],I===0||F.children.every(function(y1){return(y1.type===$.Text||y1.type===$.Raw)&&y1.value===""}))if(A.allowEmpty)b$+=">",A.state=J.CloseTag,b$+="</"+F.name+">"+this.endline(F,A,M);else A.state=J.CloseTag,b$+=A.spaceBeforeSlash+"/>"+this.endline(F,A,M);else if(A.pretty&&I===1&&(u.type===$.Text||u.type===$.Raw)&&u.value!=null)b$+=">",A.state=J.InsideTag,A.suppressPrettyCount++,L4=!0,b$+=this.writeChildNode(u,A,M+1),A.suppressPrettyCount--,L4=!1,A.state=J.CloseTag,b$+="</"+F.name+">"+this.endline(F,A,M);else{if(A.dontPrettyTextNodes){S4=F.children;for(v=0,e=S4.length;v<e;v++)if(k=S4[v],(k.type===$.Text||k.type===$.Raw)&&k.value!=null){A.suppressPrettyCount++,L4=!0;break}}b$+=">"+this.endline(F,A,M),A.state=J.InsideTag,L1=F.children;for(c=0,X$=L1.length;c<X$;c++)k=L1[c],b$+=this.writeChildNode(k,A,M+1);if(A.state=J.CloseTag,b$+=this.indent(F,A,M)+"</"+F.name+">",L4)A.suppressPrettyCount--;b$+=this.endline(F,A,M),A.state=J.None}return this.closeNode(F,A,M),b$},_.prototype.writeChildNode=function(F,A,M){switch(F.type){case $.CData:return this.cdata(F,A,M);case $.Comment:return this.comment(F,A,M);case $.Element:return this.element(F,A,M);case $.Raw:return this.raw(F,A,M);case $.Text:return this.text(F,A,M);case $.ProcessingInstruction:return this.processingInstruction(F,A,M);case $.Dummy:return"";case $.Declaration:return this.declaration(F,A,M);case $.DocType:return this.docType(F,A,M);case $.AttributeDeclaration:return this.dtdAttList(F,A,M);case $.ElementDeclaration:return this.dtdElement(F,A,M);case $.EntityDeclaration:return this.dtdEntity(F,A,M);case $.NotationDeclaration:return this.dtdNotation(F,A,M);default:throw Error("Unknown XML node type: "+F.constructor.name)}},_.prototype.processingInstruction=function(F,A,M){var P;if(this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<?",A.state=J.InsideTag,P+=F.target,F.value)P+=" "+F.value;return A.state=J.CloseTag,P+=A.spaceBeforeSlash+"?>",P+=this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.raw=function(F,A,M){var P;return this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M),A.state=J.InsideTag,P+=F.value,A.state=J.CloseTag,P+=this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.text=function(F,A,M){var P;return this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M),A.state=J.InsideTag,P+=F.value,A.state=J.CloseTag,P+=this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.dtdAttList=function(F,A,M){var P;if(this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<!ATTLIST",A.state=J.InsideTag,P+=" "+F.elementName+" "+F.attributeName+" "+F.attributeType,F.defaultValueType!=="#DEFAULT")P+=" "+F.defaultValueType;if(F.defaultValue)P+=' "'+F.defaultValue+'"';return A.state=J.CloseTag,P+=A.spaceBeforeSlash+">"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.dtdElement=function(F,A,M){var P;return this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<!ELEMENT",A.state=J.InsideTag,P+=" "+F.name+" "+F.value,A.state=J.CloseTag,P+=A.spaceBeforeSlash+">"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.dtdEntity=function(F,A,M){var P;if(this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<!ENTITY",A.state=J.InsideTag,F.pe)P+=" %";if(P+=" "+F.name,F.value)P+=' "'+F.value+'"';else{if(F.pubID&&F.sysID)P+=' PUBLIC "'+F.pubID+'" "'+F.sysID+'"';else if(F.sysID)P+=' SYSTEM "'+F.sysID+'"';if(F.nData)P+=" NDATA "+F.nData}return A.state=J.CloseTag,P+=A.spaceBeforeSlash+">"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.dtdNotation=function(F,A,M){var P;if(this.openNode(F,A,M),A.state=J.OpenTag,P=this.indent(F,A,M)+"<!NOTATION",A.state=J.InsideTag,P+=" "+F.name,F.pubID&&F.sysID)P+=' PUBLIC "'+F.pubID+'" "'+F.sysID+'"';else if(F.pubID)P+=' PUBLIC "'+F.pubID+'"';else if(F.sysID)P+=' SYSTEM "'+F.sysID+'"';return A.state=J.CloseTag,P+=A.spaceBeforeSlash+">"+this.endline(F,A,M),A.state=J.None,this.closeNode(F,A,M),P},_.prototype.openNode=function(F,A,M){},_.prototype.closeNode=function(F,A,M){},_.prototype.openAttribute=function(F,A,M){},_.prototype.closeAttribute=function(F,A,M){},_}()}).call(eA$)});var GT=x((JN$,XN$)=>{(function(){var $,J,X=function(Q,W){for(var G in W)if(Y.call(W,G))Q[G]=W[G];function K(){this.constructor=Q}return K.prototype=W.prototype,Q.prototype=new K,Q.__super__=W.prototype,Q},Y={}.hasOwnProperty;J=Qs(),XN$.exports=$=function(Q){X(W,Q);function W(G){W.__super__.constructor.call(this,G)}return W.prototype.document=function(G,K){var V,U,z,Z,H;K=this.filterOptions(K),Z="",H=G.children;for(U=0,z=H.length;U<z;U++)V=H[U],Z+=this.writeChildNode(V,K,0);if(K.pretty&&Z.slice(-K.newline.length)===K.newline)Z=Z.slice(0,-K.newline.length);return Z},W}(J)}).call(JN$)});var Ws=x((YN$,QN$)=>{(function(){var $,J,X,Y,Q,W,G,K,V=function(z,Z){for(var H in Z)if(U.call(Z,H))z[H]=Z[H];function L(){this.constructor=z}return L.prototype=Z.prototype,z.prototype=new L,z.__super__=Z.prototype,z},U={}.hasOwnProperty;K=UY().isPlainObject,X=$s(),J=GA$(),Q=jX(),$=y0(),G=Ys(),W=GT(),QN$.exports=Y=function(z){V(Z,z);function Z(H){if(Z.__super__.constructor.call(this,null),this.name="#document",this.type=$.Document,this.documentURI=null,this.domConfig=new J,H||(H={}),!H.writer)H.writer=new W;this.options=H,this.stringify=new G(H)}return Object.defineProperty(Z.prototype,"implementation",{value:new X}),Object.defineProperty(Z.prototype,"doctype",{get:function(){var H,L,O,B;B=this.children;for(L=0,O=B.length;L<O;L++)if(H=B[L],H.type===$.DocType)return H;return null}}),Object.defineProperty(Z.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(Z.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(Z.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(Z.prototype,"xmlEncoding",{get:function(){if(this.children.length!==0&&this.children[0].type===$.Declaration)return this.children[0].encoding;else return null}}),Object.defineProperty(Z.prototype,"xmlStandalone",{get:function(){if(this.children.length!==0&&this.children[0].type===$.Declaration)return this.children[0].standalone==="yes";else return!1}}),Object.defineProperty(Z.prototype,"xmlVersion",{get:function(){if(this.children.length!==0&&this.children[0].type===$.Declaration)return this.children[0].version;else return"1.0"}}),Object.defineProperty(Z.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(Z.prototype,"origin",{get:function(){return null}}),Object.defineProperty(Z.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(Z.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(Z.prototype,"contentType",{get:function(){return null}}),Z.prototype.end=function(H){var L={};if(!H)H=this.options.writer;else if(K(H))L=H,H=this.options.writer;return H.document(this,H.filterOptions(L))},Z.prototype.toString=function(H){return this.options.writer.document(this,this.options.writer.filterOptions(H))},Z.prototype.createElement=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createDocumentFragment=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createTextNode=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createComment=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createCDATASection=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createProcessingInstruction=function(H,L){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createAttribute=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createEntityReference=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.getElementsByTagName=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.importNode=function(H,L){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createElementNS=function(H,L){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createAttributeNS=function(H,L){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.getElementsByTagNameNS=function(H,L){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.getElementById=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.adoptNode=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.normalizeDocument=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.renameNode=function(H,L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.getElementsByClassName=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createEvent=function(H){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createRange=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createNodeIterator=function(H,L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},Z.prototype.createTreeWalker=function(H,L,O){throw Error("This DOM method is not implemented."+this.debugInfo())},Z}(Q)}).call(YN$)});var KN$=x((WN$,GN$)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U,z,Z,H,L,O,B,q,w,_,F,A,M,P,k,I={}.hasOwnProperty;k=UY(),M=k.isObject,A=k.isFunction,P=k.isPlainObject,F=k.getValue,$=y0(),Z=Ws(),L=oC(),Y=rC(),Q=tC(),B=YT(),_=QT(),O=WT(),U=aC(),z=XT(),W=sC(),K=eC(),G=$T(),V=JT(),X=Js(),w=Ys(),q=GT(),J=CD(),GN$.exports=H=function(){function u(v,c,e){var X$;if(this.name="?xml",this.type=$.Document,v||(v={}),X$={},!v.writer)v.writer=new q;else if(P(v.writer))X$=v.writer,v.writer=new q;this.options=v,this.writer=v.writer,this.writerOptions=this.writer.filterOptions(X$),this.stringify=new w(v),this.onDataCallback=c||function(){},this.onEndCallback=e||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return u.prototype.createChildNode=function(v){var c,e,X$,h$,L4,b$,$1,S4;switch(v.type){case $.CData:this.cdata(v.value);break;case $.Comment:this.comment(v.value);break;case $.Element:X$={},$1=v.attribs;for(e in $1){if(!I.call($1,e))continue;c=$1[e],X$[e]=c.value}this.node(v.name,X$);break;case $.Dummy:this.dummy();break;case $.Raw:this.raw(v.value);break;case $.Text:this.text(v.value);break;case $.ProcessingInstruction:this.instruction(v.target,v.value);break;default:throw Error("This XML node type is not supported in a JS object: "+v.constructor.name)}S4=v.children;for(L4=0,b$=S4.length;L4<b$;L4++)if(h$=S4[L4],this.createChildNode(h$),h$.type===$.Element)this.up();return this},u.prototype.dummy=function(){return this},u.prototype.node=function(v,c,e){var X$;if(v==null)throw Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw Error("Document can only have one root node. "+this.debugInfo(v));if(this.openCurrent(),v=F(v),c==null)c={};if(c=F(c),!M(c))X$=[c,e],e=X$[0],c=X$[1];if(this.currentNode=new L(this,v,c),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,e!=null)this.text(e);return this},u.prototype.element=function(v,c,e){var X$,h$,L4,b$,$1,S4;if(this.currentNode&&this.currentNode.type===$.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(v)||M(v)||A(v)){b$=this.options.noValidation,this.options.noValidation=!0,S4=new Z(this.options).element("TEMP_ROOT"),S4.element(v),this.options.noValidation=b$,$1=S4.children;for(h$=0,L4=$1.length;h$<L4;h$++)if(X$=$1[h$],this.createChildNode(X$),X$.type===$.Element)this.up()}else this.node(v,c,e);return this},u.prototype.attribute=function(v,c){var e,X$;if(!this.currentNode||this.currentNode.children)throw Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(v));if(v!=null)v=F(v);if(M(v))for(e in v){if(!I.call(v,e))continue;X$=v[e],this.attribute(e,X$)}else{if(A(c))c=c.apply();if(this.options.keepNullAttributes&&c==null)this.currentNode.attribs[v]=new X(this,v,"");else if(c!=null)this.currentNode.attribs[v]=new X(this,v,c)}return this},u.prototype.text=function(v){var c;return this.openCurrent(),c=new _(this,v),this.onData(this.writer.text(c,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.cdata=function(v){var c;return this.openCurrent(),c=new Y(this,v),this.onData(this.writer.cdata(c,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.comment=function(v){var c;return this.openCurrent(),c=new Q(this,v),this.onData(this.writer.comment(c,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.raw=function(v){var c;return this.openCurrent(),c=new B(this,v),this.onData(this.writer.raw(c,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.instruction=function(v,c){var e,X$,h$,L4,b$;if(this.openCurrent(),v!=null)v=F(v);if(c!=null)c=F(c);if(Array.isArray(v))for(e=0,L4=v.length;e<L4;e++)X$=v[e],this.instruction(X$);else if(M(v))for(X$ in v){if(!I.call(v,X$))continue;h$=v[X$],this.instruction(X$,h$)}else{if(A(c))c=c.apply();b$=new O(this,v,c),this.onData(this.writer.processingInstruction(b$,this.writerOptions,this.currentLevel+1),this.currentLevel+1)}return this},u.prototype.declaration=function(v,c,e){var X$;if(this.openCurrent(),this.documentStarted)throw Error("declaration() must be the first node.");return X$=new U(this,v,c,e),this.onData(this.writer.declaration(X$,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.doctype=function(v,c,e){if(this.openCurrent(),v==null)throw Error("Missing root node name.");if(this.root)throw Error("dtd() must come before the root node.");return this.currentNode=new z(this,c,e),this.currentNode.rootNodeName=v,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},u.prototype.dtdElement=function(v,c){var e;return this.openCurrent(),e=new G(this,v,c),this.onData(this.writer.dtdElement(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.attList=function(v,c,e,X$,h$){var L4;return this.openCurrent(),L4=new W(this,v,c,e,X$,h$),this.onData(this.writer.dtdAttList(L4,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.entity=function(v,c){var e;return this.openCurrent(),e=new K(this,!1,v,c),this.onData(this.writer.dtdEntity(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.pEntity=function(v,c){var e;return this.openCurrent(),e=new K(this,!0,v,c),this.onData(this.writer.dtdEntity(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.notation=function(v,c){var e;return this.openCurrent(),e=new V(this,v,c),this.onData(this.writer.dtdNotation(e,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},u.prototype.up=function(){if(this.currentLevel<0)throw Error("The document node has no parent.");if(this.currentNode){if(this.currentNode.children)this.closeNode(this.currentNode);else this.openNode(this.currentNode);this.currentNode=null}else this.closeNode(this.openTags[this.currentLevel]);return delete this.openTags[this.currentLevel],this.currentLevel--,this},u.prototype.end=function(){while(this.currentLevel>=0)this.up();return this.onEnd()},u.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},u.prototype.openNode=function(v){var c,e,X$,h$;if(!v.isOpen){if(!this.root&&this.currentLevel===0&&v.type===$.Element)this.root=v;if(e="",v.type===$.Element){this.writerOptions.state=J.OpenTag,e=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<"+v.name,h$=v.attribs;for(X$ in h$){if(!I.call(h$,X$))continue;c=h$[X$],e+=this.writer.attribute(c,this.writerOptions,this.currentLevel)}e+=(v.children?">":"/>")+this.writer.endline(v,this.writerOptions,this.currentLevel),this.writerOptions.state=J.InsideTag}else{if(this.writerOptions.state=J.OpenTag,e=this.writer.indent(v,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+v.rootNodeName,v.pubID&&v.sysID)e+=' PUBLIC "'+v.pubID+'" "'+v.sysID+'"';else if(v.sysID)e+=' SYSTEM "'+v.sysID+'"';if(v.children)e+=" [",this.writerOptions.state=J.InsideTag;else this.writerOptions.state=J.CloseTag,e+=">";e+=this.writer.endline(v,this.writerOptions,this.currentLevel)}return this.onData(e,this.currentLevel),v.isOpen=!0}},u.prototype.closeNode=function(v){var c;if(!v.isClosed){if(c="",this.writerOptions.state=J.CloseTag,v.type===$.Element)c=this.writer.indent(v,this.writerOptions,this.currentLevel)+"</"+v.name+">"+this.writer.endline(v,this.writerOptions,this.currentLevel);else c=this.writer.indent(v,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(v,this.writerOptions,this.currentLevel);return this.writerOptions.state=J.None,this.onData(c,this.currentLevel),v.isClosed=!0}},u.prototype.onData=function(v,c){return this.documentStarted=!0,this.onDataCallback(v,c+1)},u.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},u.prototype.debugInfo=function(v){if(v==null)return"";else return"node: <"+v+">"},u.prototype.ele=function(){return this.element.apply(this,arguments)},u.prototype.nod=function(v,c,e){return this.node(v,c,e)},u.prototype.txt=function(v){return this.text(v)},u.prototype.dat=function(v){return this.cdata(v)},u.prototype.com=function(v){return this.comment(v)},u.prototype.ins=function(v,c){return this.instruction(v,c)},u.prototype.dec=function(v,c,e){return this.declaration(v,c,e)},u.prototype.dtd=function(v,c,e){return this.doctype(v,c,e)},u.prototype.e=function(v,c,e){return this.element(v,c,e)},u.prototype.n=function(v,c,e){return this.node(v,c,e)},u.prototype.t=function(v){return this.text(v)},u.prototype.d=function(v){return this.cdata(v)},u.prototype.c=function(v){return this.comment(v)},u.prototype.r=function(v){return this.raw(v)},u.prototype.i=function(v,c){return this.instruction(v,c)},u.prototype.att=function(){if(this.currentNode&&this.currentNode.type===$.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},u.prototype.a=function(){if(this.currentNode&&this.currentNode.type===$.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},u.prototype.ent=function(v,c){return this.entity(v,c)},u.prototype.pent=function(v,c){return this.pEntity(v,c)},u.prototype.not=function(v,c){return this.notation(v,c)},u}()}).call(WN$)});var zN$=x((VN$,UN$)=>{(function(){var $,J,X,Y,Q=function(G,K){for(var V in K)if(W.call(K,V))G[V]=K[V];function U(){this.constructor=G}return U.prototype=K.prototype,G.prototype=new U,G.__super__=K.prototype,G},W={}.hasOwnProperty;$=y0(),Y=Qs(),J=CD(),UN$.exports=X=function(G){Q(K,G);function K(V,U){this.stream=V,K.__super__.constructor.call(this,U)}return K.prototype.endline=function(V,U,z){if(V.isLastRootNode&&U.state===J.CloseTag)return"";else return K.__super__.endline.call(this,V,U,z)},K.prototype.document=function(V,U){var z,Z,H,L,O,B,q,w,_;q=V.children;for(Z=H=0,O=q.length;H<O;Z=++H)z=q[Z],z.isLastRootNode=Z===V.children.length-1;U=this.filterOptions(U),w=V.children,_=[];for(L=0,B=w.length;L<B;L++)z=w[L],_.push(this.writeChildNode(z,U,0));return _},K.prototype.attribute=function(V,U,z){return this.stream.write(K.__super__.attribute.call(this,V,U,z))},K.prototype.cdata=function(V,U,z){return this.stream.write(K.__super__.cdata.call(this,V,U,z))},K.prototype.comment=function(V,U,z){return this.stream.write(K.__super__.comment.call(this,V,U,z))},K.prototype.declaration=function(V,U,z){return this.stream.write(K.__super__.declaration.call(this,V,U,z))},K.prototype.docType=function(V,U,z){var Z,H,L,O;if(z||(z=0),this.openNode(V,U,z),U.state=J.OpenTag,this.stream.write(this.indent(V,U,z)),this.stream.write("<!DOCTYPE "+V.root().name),V.pubID&&V.sysID)this.stream.write(' PUBLIC "'+V.pubID+'" "'+V.sysID+'"');else if(V.sysID)this.stream.write(' SYSTEM "'+V.sysID+'"');if(V.children.length>0){this.stream.write(" ["),this.stream.write(this.endline(V,U,z)),U.state=J.InsideTag,O=V.children;for(H=0,L=O.length;H<L;H++)Z=O[H],this.writeChildNode(Z,U,z+1);U.state=J.CloseTag,this.stream.write("]")}return U.state=J.CloseTag,this.stream.write(U.spaceBeforeSlash+">"),this.stream.write(this.endline(V,U,z)),U.state=J.None,this.closeNode(V,U,z)},K.prototype.element=function(V,U,z){var Z,H,L,O,B,q,w,_,F,A;z||(z=0),this.openNode(V,U,z),U.state=J.OpenTag,this.stream.write(this.indent(V,U,z)+"<"+V.name),F=V.attribs;for(w in F){if(!W.call(F,w))continue;Z=F[w],this.attribute(Z,U,z)}if(L=V.children.length,O=L===0?null:V.children[0],L===0||V.children.every(function(M){return(M.type===$.Text||M.type===$.Raw)&&M.value===""}))if(U.allowEmpty)this.stream.write(">"),U.state=J.CloseTag,this.stream.write("</"+V.name+">");else U.state=J.CloseTag,this.stream.write(U.spaceBeforeSlash+"/>");else if(U.pretty&&L===1&&(O.type===$.Text||O.type===$.Raw)&&O.value!=null)this.stream.write(">"),U.state=J.InsideTag,U.suppressPrettyCount++,_=!0,this.writeChildNode(O,U,z+1),U.suppressPrettyCount--,_=!1,U.state=J.CloseTag,this.stream.write("</"+V.name+">");else{this.stream.write(">"+this.endline(V,U,z)),U.state=J.InsideTag,A=V.children;for(B=0,q=A.length;B<q;B++)H=A[B],this.writeChildNode(H,U,z+1);U.state=J.CloseTag,this.stream.write(this.indent(V,U,z)+"</"+V.name+">")}return this.stream.write(this.endline(V,U,z)),U.state=J.None,this.closeNode(V,U,z)},K.prototype.processingInstruction=function(V,U,z){return this.stream.write(K.__super__.processingInstruction.call(this,V,U,z))},K.prototype.raw=function(V,U,z){return this.stream.write(K.__super__.raw.call(this,V,U,z))},K.prototype.text=function(V,U,z){return this.stream.write(K.__super__.text.call(this,V,U,z))},K.prototype.dtdAttList=function(V,U,z){return this.stream.write(K.__super__.dtdAttList.call(this,V,U,z))},K.prototype.dtdElement=function(V,U,z){return this.stream.write(K.__super__.dtdElement.call(this,V,U,z))},K.prototype.dtdEntity=function(V,U,z){return this.stream.write(K.__super__.dtdEntity.call(this,V,U,z))},K.prototype.dtdNotation=function(V,U,z){return this.stream.write(K.__super__.dtdNotation.call(this,V,U,z))},K}(Y)}).call(VN$)});var ZN$=x((jN$,nK)=>{(function(){var $,J,X,Y,Q,W,G,K,V,U;U=UY(),K=U.assign,V=U.isFunction,X=$s(),Y=Ws(),Q=KN$(),G=GT(),W=zN$(),$=y0(),J=CD(),jN$.create=function(z,Z,H,L){var O,B;if(z==null)throw Error("Root element needs a name.");if(L=K({},Z,H,L),O=new Y(L),B=O.element(z),!L.headless){if(O.declaration(L),L.pubID!=null||L.sysID!=null)O.dtd(L)}return B},jN$.begin=function(z,Z,H){var L;if(V(z))L=[z,Z],Z=L[0],H=L[1],z={};if(Z)return new Q(z,Z,H);else return new Y(z)},jN$.stringWriter=function(z){return new G(z)},jN$.streamWriter=function(z,Z){return new W(z,Z)},jN$.implementation=new X,jN$.nodeType=$,jN$.writerState=J}).call(jN$)});var LN$=x((HN$)=>{(function(){var $,J,X,Y,Q,W={}.hasOwnProperty;$=ZN$(),J=dC().defaults,Y=function(G){return typeof G==="string"&&(G.indexOf("&")>=0||G.indexOf(">")>=0||G.indexOf("<")>=0)},Q=function(G){return"<![CDATA["+X(G)+"]]>"},X=function(G){return G.replace("]]>","]]]]><![CDATA[>")},HN$.Builder=function(){function G(K){var V,U,z;this.options={},U=J["0.2"];for(V in U){if(!W.call(U,V))continue;z=U[V],this.options[V]=z}for(V in K){if(!W.call(K,V))continue;z=K[V],this.options[V]=z}}return G.prototype.buildObject=function(K){var V,U,z,Z,H;if(V=this.options.attrkey,U=this.options.charkey,Object.keys(K).length===1&&this.options.rootName===J["0.2"].rootName)H=Object.keys(K)[0],K=K[H];else H=this.options.rootName;return z=function(L){return function(O,B){var q,w,_,F,A,M;if(typeof B!=="object")if(L.options.cdata&&Y(B))O.raw(Q(B));else O.txt(B);else if(Array.isArray(B))for(F in B){if(!W.call(B,F))continue;w=B[F];for(A in w)_=w[A],O=z(O.ele(A),_).up()}else for(A in B){if(!W.call(B,A))continue;if(w=B[A],A===V){if(typeof w==="object")for(q in w)M=w[q],O=O.att(q,M)}else if(A===U)if(L.options.cdata&&Y(w))O=O.raw(Q(w));else O=O.txt(w);else if(Array.isArray(w))for(F in w){if(!W.call(w,F))continue;if(_=w[F],typeof _==="string")if(L.options.cdata&&Y(_))O=O.ele(A).raw(Q(_)).up();else O=O.ele(A,_).up();else O=z(O.ele(A),_).up()}else if(typeof w==="object")O=z(O.ele(A),w).up();else if(typeof w==="string"&&L.options.cdata&&Y(w))O=O.ele(A).raw(Q(w)).up();else{if(w==null)w="";O=O.ele(A,w.toString()).up()}}return O}}(this),Z=$.create(H,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),z(Z,K).end(this.options.renderOpts)},G}()}).call(HN$)});var ON$=x((KT)=>{(function($){$.parser=function(g,f){return new X(g,f)},$.SAXParser=X,$.SAXStream=U,$.createStream=V,$.MAX_BUFFER_LENGTH=65536;var J=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];$.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function X(g,f){if(!(this instanceof X))return new X(g,f);var j$=this;if(Q(j$),j$.q=j$.c="",j$.bufferCheckPosition=$.MAX_BUFFER_LENGTH,j$.opt=f||{},j$.opt.lowercase=j$.opt.lowercase||j$.opt.lowercasetags,j$.looseCase=j$.opt.lowercase?"toLowerCase":"toUpperCase",j$.tags=[],j$.closed=j$.closedRoot=j$.sawRoot=!1,j$.tag=j$.error=null,j$.strict=!!g,j$.noscript=!!(g||j$.opt.noscript),j$.state=I.BEGIN,j$.strictEntities=j$.opt.strictEntities,j$.ENTITIES=j$.strictEntities?Object.create($.XML_ENTITIES):Object.create($.ENTITIES),j$.attribList=[],j$.opt.xmlns)j$.ns=Object.create(O);if(j$.opt.unquotedAttributeValues===void 0)j$.opt.unquotedAttributeValues=!g;if(j$.trackPosition=j$.opt.position!==!1,j$.trackPosition)j$.position=j$.line=j$.column=0;v(j$,"onready")}if(!Object.create)Object.create=function(g){function f(){}f.prototype=g;var j$=new f;return j$};if(!Object.keys)Object.keys=function(g){var f=[];for(var j$ in g)if(g.hasOwnProperty(j$))f.push(j$);return f};function Y(g){var f=Math.max($.MAX_BUFFER_LENGTH,10),j$=0;for(var d=0,O6=J.length;d<O6;d++){var h1=g[J[d]].length;if(h1>f)switch(J[d]){case"textNode":e(g);break;case"cdata":c(g,"oncdata",g.cdata),g.cdata="";break;case"script":c(g,"onscript",g.script),g.script="";break;default:h$(g,"Max buffer length exceeded: "+J[d])}j$=Math.max(j$,h1)}var t1=$.MAX_BUFFER_LENGTH-j$;g.bufferCheckPosition=t1+g.position}function Q(g){for(var f=0,j$=J.length;f<j$;f++)g[J[f]]=""}function W(g){if(e(g),g.cdata!=="")c(g,"oncdata",g.cdata),g.cdata="";if(g.script!=="")c(g,"onscript",g.script),g.script=""}X.prototype={end:function(){L4(this)},write:P7,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){W(this)}};var G;try{G=a$("stream").Stream}catch(g){G=function(){}}if(!G)G=function(){};var K=$.EVENTS.filter(function(g){return g!=="error"&&g!=="end"});function V(g,f){return new U(g,f)}function U(g,f){if(!(this instanceof U))return new U(g,f);G.apply(this),this._parser=new X(g,f),this.writable=!0,this.readable=!0;var j$=this;this._parser.onend=function(){j$.emit("end")},this._parser.onerror=function(d){j$.emit("error",d),j$._parser.error=null},this._decoder=null,K.forEach(function(d){Object.defineProperty(j$,"on"+d,{get:function(){return j$._parser["on"+d]},set:function(O6){if(!O6)return j$.removeAllListeners(d),j$._parser["on"+d]=O6,O6;j$.on(d,O6)},enumerable:!0,configurable:!1})})}U.prototype=Object.create(G.prototype,{constructor:{value:U}}),U.prototype.write=function(g){if(typeof Buffer==="function"&&typeof Buffer.isBuffer==="function"&&Buffer.isBuffer(g)){if(!this._decoder){var f=a$("string_decoder").StringDecoder;this._decoder=new f("utf8")}g=this._decoder.write(g)}return this._parser.write(g.toString()),this.emit("data",g),!0},U.prototype.end=function(g){if(g&&g.length)this.write(g);return this._parser.end(),!0},U.prototype.on=function(g,f){var j$=this;if(!j$._parser["on"+g]&&K.indexOf(g)!==-1)j$._parser["on"+g]=function(){var d=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);d.splice(0,0,g),j$.emit.apply(j$,d)};return G.prototype.on.call(j$,g,f)};var z="[CDATA[",Z="DOCTYPE",H="http://www.w3.org/XML/1998/namespace",L="http://www.w3.org/2000/xmlns/",O={xml:H,xmlns:L},B=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,q=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,w=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function F(g){return g===" "||g===`
@@ -839,4 +839,4 @@ Options:
839
839
 
840
840
  `)},f76):void 0,U=()=>{if(V)y.clearInterval(V)};J.on("close",U),J.on("finish",U);try{await Q.handleRequest($,J,W)}catch(z){j.error("Streamable HTTP request handling failed:",z),K("Server error",z)}finally{U()}}else J.writeHead(404,{"Content-Type":"application/json"}),J.end(JSON.stringify({error:"Not found"}))}),new Promise(($,J)=>{this.httpServer.listen(this.port,this.host,()=>{j.info(`automobile:${this.host}:${this.port}${eH}`),$()}),this.httpServer.on("error",(X)=>{j.error(`HTTP server error: ${X}`),J(X)})})}async persistPidFileData($){await I76(b76(hJ),{recursive:!0}),await S76(hJ,JSON.stringify($,null,2),{encoding:"utf-8",mode:384}),this.pidFileWritten=!0}async writeEarlyOwnerRecord(){let $={pid:process.pid,socketPath:q1,port:this.port,dbPath:aW(),startedAt:this.timer.now(),version:F5,assetVersion:n0(Z6()),options:this.options};await this.persistPidFileData($),j.info(`Early daemon owner record written to ${hJ} (dbPath ${$.dbPath})`)}async writePidFile(){let $=w7(),J={pid:process.pid,socketPath:q1,sockets:Ne$(),port:this.port,dbPath:aW(),startedAt:this.timer.now(),version:F5,assetVersion:n0(Z6()),entryScript:$.entryScript,buildId:$.buildId,options:this.options};await this.persistPidFileData(J),j.info(`PID file written to ${hJ}`)}setupDeviceDataStreamCallback(){let $=C1();if(!$){j.warn("[Daemon] Observation stream server not available for callback setup");return}$.setOnSubscriberConnected((J)=>{j.info(`[Daemon] IDE plugin subscribed to observation stream (device: ${J??"all"}), ensuring WebSocket connections...`);let X=this.devicePool.getAllDevices();if(Re$(J,X,{streamServer:$,androidClientFactory:(Y)=>Y$.getInstance(Y,r),iosClientFactory:(Y)=>this.createObservationStreamIosClient(Y)}).catch((Y)=>{j.warn(`[Daemon] Error pushing initial observation frame: ${Y}`)}),X.length===0)j.info("[Daemon] No devices in pool to connect")}),$.setOnScreenshotCadenceChanged((J)=>{let X=this.devicePool.getAllDevices().filter((Y)=>J===null||Y.id===J);for(let Y of X)if(Y.platform==="android")Y$.getExistingInstance(Y.id)?.refreshObservationStreamScreenshotCadence();else if(Y.platform==="ios")G$.getExistingInstance(Y.id)?.refreshObservationStreamScreenshotCadence()}),$.setOnHierarchyCadenceChanged((J)=>{let X=this.devicePool.getAllDevices().filter((Y)=>J===null||Y.id===J);for(let Y of X)if(Y.platform==="android")Y$.getExistingInstance(Y.id)?.refreshObservationStreamHierarchyCadence();else if(Y.platform==="ios"){let Q=G$.getExistingInstance(Y.id);if(!Q)continue;let W=$.getHierarchyIntervalMsForDevice(Y.id);Q.ensureConnected().then((G)=>{if(G)Q.refreshObservationStreamHierarchyCadence(W)}).catch((G)=>{j.warn(`[Daemon] Failed to refresh iOS hierarchy cadence for ${Y.id}: ${G}`)})}else continue}),$.setOnObservationRequested(async({deviceId:J,signal:X})=>{let Y=J?[this.devicePool.getDevice(J)].filter((G)=>G!==null):this.devicePool.getAllDevices();if(Y.length===0)throw Error(J?`Device ${J} is not available`:"No devices are available");let Q=this.timer.now(),W=[];for(let G of Y){if(X.aborted)throw Error("Observation request was aborted");let K={deviceId:G.id,name:G.name,platform:G.platform,iosVersion:G.iosVersion},U=await new M6(K).execute({skipWaitForFresh:!1,minTimestamp:Q,signal:X});W.push({deviceId:G.id,observation:U})}return W}),j.info("[Daemon] Observation stream callback configured"),this.setupNavigationGraphStreamListener($)}createObservationStreamIosClient($){let J=G$.getInstance($);return{ensureConnected:async()=>{let X=await J.ensureConnected(),Y=C1();if(X&&Y)J.refreshObservationStreamHierarchyCadence(Y.getHierarchyIntervalMsForDevice($.deviceId));return X},getLatestHierarchy:(...X)=>J.getLatestHierarchy(...X),requestHierarchySyncWithoutObservationStreamPush:async(...X)=>{let Y=await J.requestHierarchySyncWithoutObservationStreamPush(...X);return Y?{hierarchy:Y.hierarchy}:null},convertToViewHierarchyResult:(X)=>J.convertToViewHierarchyResult(X),requestScreenshotWithoutObservationStreamPush:(...X)=>J.requestScreenshotWithoutObservationStreamPush(...X)}}setupNavigationGraphStreamListener($){if(!$)return;let J=B4.getInstance();J.setGraphUpdateListener(async()=>{j.info("[Daemon] Navigation graph listener triggered, exporting summary...");try{let X=await J.exportGraphSummary();j.info(`[Daemon] Got summary: appId=${X.appId}, nodes=${X.nodes.length}, edges=${X.edges.length}`);let Y=Se$(X);$.pushNavigationGraphUpdate(Y),j.info(`[Daemon] Pushed navigation graph update: ${X.nodes.length} nodes, ${X.edges.length} edges`)}catch(X){j.warn(`[Daemon] Failed to push navigation graph update: ${X}`)}}),$.setOnNavigationGraphRequested(async(X)=>{try{let Y=X?await J.exportGraphSummaryForApp(X):await J.exportGraphSummary();return Se$(Y)}catch(Y){return j.warn(`[Daemon] Failed to export navigation graph on request: ${Y}`),null}}),j.info("[Daemon] Navigation graph stream listener configured")}startHealthCheckTimer(){let X=0,Y="unknown",Q=(G)=>{if(Y!==G)X=0;Y=G,X++},W=()=>{X=0,Y="unknown"};if(this.healthCheckTimer=this.timer.setInterval(async()=>{try{if(!this.httpServer)j.warn("Health check failed: HTTP server not initialized"),Q("http");else if(!this.httpServer.listening)j.warn("Health check failed: HTTP server not listening"),Q("http");else if(!this.socketServer||!this.socketServer.isListening())j.warn("Health check failed: Socket server not listening"),Q("socket");else try{await this.databaseHealthProbe.check(),W(),j.debug("Health check passed")}catch(G){j.warn(`Health check failed: Database probe failed: ${G}`),Q("database")}if(X>=3)j.error(`Health check failed ${X} times, attempting recovery...`),await this.attemptRecovery(Y),W()}catch(G){j.warn(`Health check error: ${G}`),Q("unknown")}},30000),typeof this.healthCheckTimer.unref==="function")this.healthCheckTimer.unref()}stopHealthCheckTimer(){if(this.healthCheckTimer)this.timer.clearInterval(this.healthCheckTimer),this.healthCheckTimer=null}startHeartbeatMonitor(){this.heartbeatMonitor=new aQ$(this.sessionManager,($)=>GY.hasActiveSessionUuidExecutions($),($)=>this.cancelAndReleaseSession($),this.timer),this.heartbeatMonitor.start()}startDeviceDisconnectMonitor(){if(this.deviceDisconnectTimer)return;let $=new f9;this.deviceDisconnectTimer=y.setInterval(async()=>{try{if(U$.isPlanExecutionActive()){j.debug("[DisconnectMonitor] Skipping \u2014 plan execution active");return}let J=await $.getBootedDevicesDetailed("either"),X=J.devices,Y=J.succeededPlatforms,Q=new Set(X.map((Z)=>Z.deviceId)),W=await oj(),G=new Map,K=new Set,V=new Map,U=new Set;for(let Z of W)K.add(Z.deviceId),V.set(Z.deviceId,Z.platform);for(let Z of this.devicePool.getAllDevices())if(K.add(Z.id),V.set(Z.id,Z.platform),Z.status==="idle")U.add(Z.id);for(let Z of this.sessionManager.getAssignedDevices())K.add(Z);let z=Pe$({deviceDisconnectMisses:this.deviceDisconnectMisses,confirmedDisconnectedDeviceIds:this.confirmedDisconnectedDeviceIds,bootedDeviceIds:Q,candidateDeviceIds:K,succeededPlatforms:Y,candidatePlatforms:V,idleCandidateIds:U,missThreshold:CW$});if(z.skippedAdbUnreachable){j.warn(`[DisconnectMonitor] ADB returned 0 devices but ${K.size} tracked \u2014 skipping miss count (ADB likely unreachable)`);return}for(let{deviceId:Z,misses:H}of z.missed)j.info(`[DisconnectMonitor] Device ${Z} not in booted list (miss ${H}/${CW$}, booted=${Q.size})`);for(let Z of z.disconnected)G.set(Z,[]);for(let Z of W)if(G.has(Z.deviceId))G.get(Z.deviceId).push(Z.recordingId);for(let[Z,H]of G.entries()){let L=!0;FV().stopMonitoring(Z);for(let B of H){if(this.stoppingRecordings.has(B)){L=!1;continue}this.stoppingRecordings.add(B);try{await B7(B),j.warn(`[Daemon] Stopped recording ${B} after device ${Z} disconnected`)}catch(q){j.warn(`[Daemon] Failed to stop recording ${B} after device ${Z} disconnected: ${q}`);try{await Ch$(B),j.warn(`[Daemon] Marked recording ${B} interrupted after device ${Z} disconnected`)}catch(w){L=!1,j.warn(`[Daemon] Failed to mark recording ${B} interrupted after device ${Z} disconnected: ${w}`)}}finally{this.stoppingRecordings.delete(B)}}let O=this.sessionManager.getSessionForDevice(Z);if(O)j.warn(`[DisconnectMonitor] Device ${Z} confirmed disconnected after ${CW$} consecutive misses \u2014 cancelling session ${O}`),await this.cancelAndReleaseSession(O);if(await this.devicePool.removeDisconnectedDevice(Z),this.devicePool.getDevice(Z))L=!1;if(L)this.confirmedDisconnectedDeviceIds.add(Z),this.deviceDisconnectMisses.delete(Z)}}catch(J){j.warn(`[Daemon] Device disconnect monitor failed: ${J}`)}},k76),this.deviceDisconnectTimer.unref()}async cancelAndReleaseSession($){let J=await GY.cancelSessionUuidExecutions($),X=await this.sessionManager.releaseSession($);if(X)await this.devicePool.releaseDevice(X);j.info(`Cancelled session ${$} (${J} executions) and released device ${X??"unknown"}`)}async attemptRecovery($="unknown"){try{if(j.info("Attempting daemon recovery..."),$==="database"){j.error("Database health check failed repeatedly; exiting daemon for a clean restart."),this.recoverFromDatabaseHealthFailure(1);return}if(this.socketServer&&!this.socketServer.isListening()){j.info("Restarting socket server...");try{await this.socketServer.close()}catch(X){j.warn(`Error closing socket server during recovery: ${X}`)}let J=`http://${this.host}:${this.port}${eH}`;this.socketServer=new vN(q1,J,void 0,void 0,YJ.getInstance());try{await this.socketServer.start(),j.info("Socket server restarted successfully")}catch(X){j.error(`Failed to restart socket server: ${X}`)}}}catch(J){j.error(`Recovery attempt failed: ${J}`)}}async initializeDevicePoolWithTimeout($){let J,X=new Promise((W)=>{if(J=y.setTimeout(()=>{j.warn(`Device pool initialization timed out after ${$}ms`),W()},$),typeof J.unref==="function")J.unref()}),Y=this.initializeDevicePool();try{await Promise.race([Y,X])}finally{if(J!==void 0)y.clearTimeout(J)}let Q=this.devicePool.getTotalDeviceCount();if(Q===0)j.warn("Device pool is empty after initialization."),j.warn("Tests will fail until devices are available."),j.warn("Start an emulator or connect a physical device, then restart the daemon.");else j.info(`Device pool ready with ${Q} device(s)`)}async initializeDevicePool(){try{let J=await new f9().getBootedDevices("either");if(J.length>0)await this.devicePool.initializeWithDevices(J),j.info(`Device pool initialized with ${J.length} devices: ${J.map((X)=>X.deviceId).join(", ")}`);else j.warn("No devices detected during daemon startup. Device pool is empty."),j.warn("Start an emulator or connect a physical device before creating sessions.")}catch($){j.error(`Failed to initialize device pool: ${$}`)}}async initializeIosServices(){let J=this.devicePool.getAllDevices().filter((Q)=>Q.platform==="ios");if(J.length===0){j.debug("[Daemon] No iOS devices to initialize CtrlProxy iOS for");return}j.info(`[Daemon] Initializing CtrlProxy iOS for ${J.length} iOS device(s)...`);let X=I1.getInstance(),Y=5000;for(let Q of J)try{j.info(`[Daemon] Setting up CtrlProxy iOS for iOS device ${Q.id}`);let W=new Promise((G,K)=>{let V=y.setTimeout(()=>{K(Error(`Timeout after ${Y}ms`))},Y);if(typeof V.unref==="function")V.unref()});await Promise.race([X.verifyIosDevice(Q.id,{skipCtrlProxyDownload:!0}),W]),j.info(`[Daemon] CtrlProxy iOS ready for iOS device ${Q.id}`)}catch(W){j.warn(`[Daemon] Failed to initialize CtrlProxy iOS for ${Q.id}: ${W}`)}}async initializeDatabase(){try{await this.databaseInitializer.initialize(),await this.installedAppsRepository.clearOldDaemonSessions(this.daemonSessionId),await this.deviceSessionRepository.markStaleActiveSessionsExpired(this.daemonSessionId,this.timer.now(),"daemon-restart"),j.info(`[Daemon] Cleared old daemon session caches, current session: ${this.daemonSessionId}`)}catch($){await Zh($,this.startupFailureTracker,this.timer)}}setupShutdownHandlers(){if(this.shutdownHandlersRegistered)return;this.shutdownHandlersRegistered=!0,tN();let $=async(X)=>{if(this.shutdownInProgress)return;this.shutdownInProgress=!0,j.info(`Received ${X}, shutting down daemon...`),await this.stop()},J=(X,Y)=>{j.error(`${X}: ${Y instanceof Error?Y.stack??Y.message:String(Y)}`),cq(this.getDaemonFileCleanupOptions()),j.close(),process.exit(1)};aN($),process.once("exit",()=>{cq(this.getDaemonFileCleanupOptions())}),sN((X)=>{if(X.type==="uncaughtException"){J("Uncaught exception in daemon",X.error);return}J("Unhandled rejection in daemon",X.reason)})}async stop(){if(j.info("Stopping daemon..."),this.stopHealthCheckTimer(),this.heartbeatMonitor)this.heartbeatMonitor.stop(),this.heartbeatMonitor=null;if(this.deviceDisconnectTimer)clearInterval(this.deviceDisconnectTimer),this.deviceDisconnectTimer=null;if(this.sessionManager.stopCleanupTimer(),this.socketServer)await this.socketServer.close();await KW$(),await jW$(),await OW$(),await AW$(),await De$(),await GC$(),await XC$(),await Ae$(),await RC$(),await vP$(),DW$(),O6$();for(let[X,Y]of this.transports)try{await Y.close()}catch(Q){j.warn(`Error closing Streamable HTTP session ${X}:`,Q)}if(this.transports.clear(),this.httpServer)await new Promise((X)=>{this.httpServer.close(()=>{j.info("HTTP server stopped"),X()})});if(await vz(this.getDaemonFileCleanupOptions()),!await c9().drain(Te$))j.warn(`Timed out after ${Te$}ms draining in-flight DB writes; closing database anyway`);if(!await US(Ie$))j.warn(`Timed out after ${Ie$}ms awaiting in-flight startup migration; closing database anyway`);await zS(),j.info("Daemon stopped"),j.close()}getDaemonFileCleanupOptions(){if(this.pidFileWritten)return{expectedPid:process.pid};let $=XL();return $&&$.pid!==process.pid?{expectedPid:process.pid}:{}}getSessionManager(){return this.sessionManager}getDevicePool(){return this.devicePool}}function Se$($){return{appId:$.appId,nodes:$.nodes.map((J)=>({id:J.id,screenName:J.screenName,visitCount:J.visitCount,screenshotPath:J.screenshotPath})),edges:$.edges.map((J)=>({id:J.id,from:J.from,to:J.to,toolName:J.toolName,traversalCount:J.traversalCount})),currentScreen:$.currentScreen}}async function x76($={}){await new TW$($).start()}var k76=5000,CW$=3,f76=30000,Te$=1000,Ie$=5000;var ke$=D(()=>{Ms$();wQ$();m();jz();Je$();tQ$();Xe$();Ye$();D5();D5();zU();G9();IC();lS();$W$();We$();XW$();Hh();pN();Lh();Oh();Bh();qh();_W$();wS();LV();PW$();vS();jS();_e$();l4();p$();t4();Ee$();p9();R5();cz();Vh();UG();Dh();HL();EG();J$();zz();Yj();R6();v$();ih();q9();x9()});var fe$={};y4(fe$,{runDirectModeStartup:()=>v76});async function v76($){if($.noProxy)await $.assertDbOwnership();await $.applyFeatureFlagStartup()}var he$={};y4(he$,{findConflictingDaemons:()=>g76,createDefaultDirectModeGuardDeps:()=>m76,assertDirectModeDbOwnership:()=>u76});import{realpathSync as xe$}from"fs";import{basename as y76,dirname as h76,resolve as ve$}from"path";function IW$($){let J=ve$($);try{return xe$(J)}catch{try{return ve$(xe$(h76(J)),y76(J))}catch{return J}}}function ye$($,J){return $.filter((X)=>X.dbPath!==void 0&&IW$(X.dbPath)===J)}function g76($){return ye$($.findLiveDaemonDbOwners(),IW$($.resolveDbPath()))}function u76($){let J=IW$($.resolveDbPath()),X=$.findLiveDaemonDbOwners(),Y=ye$(X,J);if(Y.length>0){let W=Y.map((G)=>G.pid).join(", ");throw new C(`A live AutoMobile daemon (pid ${W}) already owns the database at ${J}. Direct mode (--no-proxy/--direct) would open a second writer on the same SQLite file, causing SQLITE_BUSY stalls and competing migrations. Resolve this by either running without --no-proxy/--direct to share the daemon, stopping the daemon, or setting AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database for this direct-mode instance.`)}let Q=X.filter((W)=>W.dbPath===void 0);if(Q.length>0){let W=Q.map((G)=>G.pid).join(", ");throw new C(`Cannot safely start direct mode (--no-proxy/--direct): a live AutoMobile daemon (pid ${W}) is running but its database path could not be determined (it may still be starting up, or is using a non-default PID file), so a collision on ${J} cannot be ruled out. Wait for the daemon to finish starting and retry, stop the daemon, or set AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database for this direct-mode instance.`)}}function m76($={}){let J=$.manager??new $Q,X=$.readPidFileData??XL;return{resolveDbPath:$.resolveDbPath??aW,findLiveDaemonDbOwners:()=>{let Q;try{Q=J.findLiveDaemonProcesses()}catch(U){let z=U instanceof Error?U.message:String(U);throw j.warn(`Direct-mode guard: process-table scan failed; refusing direct mode because same-DB daemon ownership cannot be verified. ${z}`,U),new C(`Cannot verify daemon ownership before starting direct mode (--no-proxy/--direct): failed to inspect the process table (${z}). Retry, stop any running daemon, or set AUTOMOBILE_DB_PATH (or AUTOMOBILE_DB_DIR) to an isolated database.`)}if(Q.length===0)return[];let W=[],G=new Set,K=X();if(K&&typeof K.pid==="number"&&K.dbPath!==void 0&&Q.includes(K.pid))W.push({pid:K.pid,dbPath:K.dbPath}),G.add(K.pid);let V=Q.filter((U)=>!G.has(U));if(V.length>0){j.debug(`Direct-mode guard: ${V.length} live daemon(s) could not be mapped to a DB path (starting up or non-default PID file); direct mode will refuse to be safe: ${V.join(", ")}`);for(let U of V)W.push({pid:U,dbPath:void 0})}return W}}}var ge$=D(()=>{i$();lS();m();KN();G9()});import*as vW$ from"fs";import*as Sh from"os";import*as iJ from"path";function yW$(){ae$(),se$()}function ae$(){let $=iJ.delimiter,J=process.env.PATH??"",X=new Set(J.split($).filter(Boolean)),Y=ee$(),Q=[];for(let W of Y)if(!X.has(W)&&hW$(W))Q.push(W),X.add(W);if(Q.length===0)return;process.env.PATH=J.length>0?`${J}${$}${Q.join($)}`:Q.join($)}function se$(){if(process.env.ANDROID_HOME||process.env.ANDROID_SDK_ROOT)return;for(let $ of $$4())if(hW$($)){process.env.ANDROID_HOME=$;return}}function ee$(){let $=process.platform,J=Sh.homedir();if($==="darwin")return["/usr/bin","/bin","/usr/sbin","/sbin","/usr/local/bin","/usr/local/sbin","/opt/homebrew/bin","/opt/homebrew/sbin",iJ.join(J,"Library/Android/sdk/platform-tools"),iJ.join(J,"Library/Android/sdk/emulator"),iJ.join(J,"Library/Android/sdk/cmdline-tools/latest/bin")];if($==="linux")return["/usr/bin","/bin","/usr/sbin","/sbin","/usr/local/bin","/usr/local/sbin",iJ.join(J,"Android/Sdk/platform-tools"),iJ.join(J,"Android/Sdk/emulator"),iJ.join(J,"Android/Sdk/cmdline-tools/latest/bin")];if($==="win32"){let X=process.env.LOCALAPPDATA,Y=X?iJ.join(X,"Android","Sdk"):"";return[...Y?[iJ.join(Y,"platform-tools"),iJ.join(Y,"emulator"),iJ.join(Y,"cmdline-tools","latest","bin")]:[]]}return[]}function $$4(){let $=Sh.homedir(),J=process.platform;if(J==="darwin")return[iJ.join($,"Library/Android/sdk")];if(J==="linux")return[iJ.join($,"Android/Sdk")];if(J==="win32"){let X=process.env.LOCALAPPDATA;return X?[iJ.join(X,"Android","Sdk")]:[]}return[]}function hW$($){try{return vW$.statSync($).isDirectory()}catch{}return!1}q9();cN();function Y$4($){let J=$.findIndex((Y)=>Y==="--cli"||Y==="--daemon"),X=J>=0?$.slice(0,J):$;return X.includes("--version")||X.includes("-v")}function mW$($,J){return Y$4($)?J:void 0}pN();j8();nh();ih();yW$();process.env[_U]??=kB();var gN;function ue$($,J){let X=J instanceof Error?J.stack??J.message:String(J);if(gN)gN.error(`${$}: ${X}`);else console.error(`${$}: ${X}`)}var me$=mW$(process.argv.slice(2),c0());if(me$!==void 0)console.log(me$),process.exit(0);tN();sN(($)=>{if($.type==="uncaughtException"){ue$("Uncaught exception",$.error);return}ue$("Unhandled rejection",$.reason)});function l76($){let J=process.argv.slice(2),X,Y,Q=J.includes("--cli"),W=J.includes("--daemon-mode"),G=J.includes("--no-proxy")||J.includes("--direct"),K=J.includes("--no-daemon"),V=J.indexOf("--daemon"),U=V>=0?J[V+1]:void 0,z=V>=0?J.slice(V+2):[],Z=J.includes("--debug-perf")||J.includes("--ui-perf-debug")||process.env.AUTOMOBILE_DEBUG_PERF==="1",H=J.includes("--debug")||process.env.AUTOMOBILE_DEBUG==="1",L=!J.includes("--no-ui-perf-mode"),O=J.includes("--mem-perf-audit"),B=J.includes("--accessibility-audit"),q,w,_,F=!1,A=J.includes("--predictive")||J.includes("--predictive-ui"),M=J.includes("--raw-element-search"),P=oN(J),k=J.includes("--embedded-sdk"),I=J.includes("--network-mockable"),u=J.includes("--dismiss-keyboard-after-input"),v=J.includes("--mcp-recording"),c=!J.includes("--no-navigation-screenshots"),e=J.includes("--no-waitfor-polling-overhead"),X$=J.includes("--no-include-not-important-views"),h$=J.includes("--no-report-view-ids"),L4=J.includes("--no-retrieve-interactive-windows"),b$=gW$(J,process.env),$1=rN(J,process.env,M3()),S4="session",L1={},y1=(t$,B6,a4)=>{if(!t$)return;let C7=a4?Number(t$):parseInt(t$,10);if(!Number.isFinite(C7)||C7<=0){$.warn(`Invalid ${B6}: ${t$}`);return}return a4?C7:Math.round(C7)},fX=new Set(["low","medium","high"]),u5=new Set(["mp4"]),U8=(t$,B6)=>{if(!t$)return;if(!fX.has(t$)){$.warn(`Invalid video quality preset (${B6}): ${t$}`);return}L1.qualityPreset=t$},xX=(t$,B6)=>{if(!t$)return;if(!u5.has(t$)){$.warn(`Invalid video format (${B6}): ${t$}`);return}L1.format=t$};U8(process.env.AUTOMOBILE_VIDEO_QUALITY_PRESET??process.env.AUTO_MOBILE_VIDEO_QUALITY_PRESET,"env");let P7=process.env.AUTOMOBILE_VIDEO_TARGET_BITRATE_KBPS??process.env.AUTO_MOBILE_VIDEO_TARGET_BITRATE_KBPS,g=process.env.AUTOMOBILE_VIDEO_MAX_THROUGHPUT_MBPS??process.env.AUTO_MOBILE_VIDEO_MAX_THROUGHPUT_MBPS,f=process.env.AUTOMOBILE_VIDEO_FPS??process.env.AUTO_MOBILE_VIDEO_FPS,j$=process.env.AUTOMOBILE_VIDEO_MAX_ARCHIVE_MB??process.env.AUTO_MOBILE_VIDEO_MAX_ARCHIVE_MB,d=process.env.AUTOMOBILE_VIDEO_FORMAT??process.env.AUTO_MOBILE_VIDEO_FORMAT,O6=y1(P7,"video target bitrate",!1);if(O6!==void 0)L1.targetBitrateKbps=O6;let h1=y1(g,"video max throughput",!0);if(h1!==void 0)L1.maxThroughputMbps=h1;let t1=y1(f,"video fps",!1);if(t1!==void 0)L1.fps=t1;let W0=y1(j$,"video max archive size",!0);if(W0!==void 0)L1.maxArchiveSizeMb=W0;xX(d,"env");let k0=J.indexOf("--cli"),vX=Q?J.slice(k0+1):[];for(let t$=0;t$<J.length;t$++){let B6=J[t$];if(B6==="--cli")break;if(B6==="--port"){let a4=parseInt(J[t$+1],10);if(!isNaN(a4)&&a4>0&&a4<65536)X=a4,t$++;else $.warn(`Invalid port: ${J[t$+1]}`),t$++}else if(B6==="--host"){let a4=J[t$+1];if(a4&&!a4.startsWith("--"))Y=a4,t$++;else $.warn(`Invalid host: ${a4}`),t$++}else if(B6==="--a11y-level")q=J[t$+1],t$++;else if(B6==="--a11y-failure-mode")w=J[t$+1],t$++;else if(B6==="--a11y-min-severity")_=J[t$+1],t$++;else if(B6==="--a11y-use-baseline")F=!0;else if(B6==="--plan-execution-lock-scope"){let a4=J[t$+1];if(a4==="global"||a4==="session")S4=a4;else $.warn(`Invalid plan execution lock scope: ${a4}. Using default: ${S4}`);t$++}else if(B6==="--video-quality"||B6==="--video-quality-preset"){let a4=J[t$+1];U8(a4,"cli"),t$++}else if(B6==="--video-target-bitrate-kbps"){let a4=y1(J[t$+1],"video target bitrate",!1);if(a4!==void 0)L1.targetBitrateKbps=a4;t$++}else if(B6==="--video-max-throughput-mbps"){let a4=y1(J[t$+1],"video max throughput",!0);if(a4!==void 0)L1.maxThroughputMbps=a4;t$++}else if(B6==="--video-fps"){let a4=y1(J[t$+1],"video fps",!1);if(a4!==void 0)L1.fps=a4;t$++}else if(B6==="--video-format"){let a4=J[t$+1];xX(a4,"cli"),t$++}else if(B6==="--video-archive-size-mb"){let a4=y1(J[t$+1],"video max archive size",!0);if(a4!==void 0)L1.maxArchiveSizeMb=a4;t$++}}return{cliMode:Q,cliArgs:vX,daemonPort:X,daemonHost:Y,debugPerf:Z,debug:H,uiPerfMode:L,memPerfAuditMode:O,a11yAuditMode:B,a11yLevel:q,a11yFailureMode:w,a11yMinSeverity:_,a11yUseBaseline:F,predictiveUi:A,rawElementSearch:M,planExecutionLockScope:S4,videoRecordingDefaults:L1,daemonMode:W,daemonCommand:U,daemonArgs:z,skipCtrlProxyDownload:P,embeddedSdk:k,networkMockable:I,dismissKeyboardAfterInput:u,mcpRecording:v,navigationScreenshots:c,noWaitForPollingOverhead:e,noProxy:G,noDaemon:K,noA11yIncludeNotImportantViews:X$,noA11yReportViewIds:h$,noA11yRetrieveInteractiveWindows:L4,outputReduction:b$,toolOutputsDir:$1}}async function c76(){let{StdioServerTransport:$}=await Promise.resolve().then(() => (zU$(),UU$)),{createMcpServer:J}=await Promise.resolve().then(() => (wQ$(),aa$)),{createProxyMcpServer:X}=await Promise.resolve().then(() => (Qs$(),Ys$)),{logger:Y}=await Promise.resolve().then(() => (m(),_w$));gN=Y;let{runCliCommand:Q}=await Promise.resolve().then(() => (zs$(),Us$)),{runDaemonCommand:W}=await Promise.resolve().then(() => (KN(),vp$)),{startDaemon:G}=await Promise.resolve().then(() => (ke$(),be$)),{guardDatabaseStartup:K}=await Promise.resolve().then(() => (Hh(),YW$)),{DefaultDatabaseInitializer:V}=await Promise.resolve().then(() => ($W$(),Qe$)),U=await Promise.resolve().then(() => (Lh(),Ue$)),z=await Promise.resolve().then(() => (Oh(),ze$)),Z=await Promise.resolve().then(() => (Bh(),je$)),H=await Promise.resolve().then(() => (qh(),Le$)),L=await Promise.resolve().then(() => (Dh(),He$)),{FeatureFlagService:O}=await Promise.resolve().then(() => (Yj(),fT$)),{serverConfig:B}=await Promise.resolve().then(() => (R6(),dW$)),{AndroidCtrlProxyManager:q}=await Promise.resolve().then(() => (zX(),cM$)),{IOSCtrlProxyBuilder:w}=await Promise.resolve().then(() => (TD(),TN$)),{IOSCtrlProxyManager:_}=await Promise.resolve().then(() => (zY(),lN$));F0.mark("processEntry");let{startVideoRecordingSocketServer:F,stopVideoRecordingSocketServer:A}=U,{startTestRecordingSocketServer:M,stopTestRecordingSocketServer:P}=z,{startDeviceSnapshotSocketServer:k,stopDeviceSnapshotSocketServer:I}=Z,{startAppearanceSocketServer:u,stopAppearanceSocketServer:v}=H,{startAppearanceSyncScheduler:c,stopAppearanceSyncScheduler:e}=L;aN(async(X$)=>{Y.info(`Received ${X$} signal, shutting down`),await A(),await P(),await I(),await v(),e(),await q.cleanupPrefetchedApk(),Y.close()});try{let{cliMode:X$,cliArgs:h$,daemonPort:L4,daemonHost:b$,debugPerf:$1,debug:S4,uiPerfMode:L1,memPerfAuditMode:y1,a11yAuditMode:fX,a11yLevel:u5,a11yFailureMode:U8,a11yMinSeverity:xX,a11yUseBaseline:P7,predictiveUi:g,rawElementSearch:f,planExecutionLockScope:j$,videoRecordingDefaults:d,daemonMode:O6,daemonCommand:h1,daemonArgs:t1,skipCtrlProxyDownload:W0,embeddedSdk:k0,networkMockable:vX,dismissKeyboardAfterInput:t$,mcpRecording:B6,navigationScreenshots:a4,noWaitForPollingOverhead:C7,noProxy:w3,noDaemon:uN,noA11yIncludeNotImportantViews:Ah,noA11yReportViewIds:Nh,noA11yRetrieveInteractiveWindows:_h,outputReduction:Rh,toolOutputsDir:Eh}=l76(Y);if(B.setPlanExecutionLockScope(j$),B.setVideoRecordingDefaults(d),B.setToolOutputsDir(Eh),B.setSkipCtrlProxyDownload(W0),B.setEmbeddedSdkEnabled(k0),B.setNetworkMockableEnabled(vX),B.setDismissKeyboardAfterInputEnabled(t$),W0)Y.info(`CtrlProxy downloads disabled (${hh} or ${mG})`);else q.prefetchApk();if(process.platform==="darwin")if(await _.reapOrphanedRunnerProcessesOnStartup(),W0)Y.info(`CtrlProxy iOS prefetch disabled (${hh} or ${mG})`);else w.prefetchBuild();let Ph=O.getInstance(),le$=[["debug",S4,"--debug"],["debug-perf",$1,"--debug-perf/--ui-perf-debug"],["ui-perf-mode",L1,"--ui-perf-mode"],["mem-perf-audit",y1,"--mem-perf-audit"],["accessibility-audit",fX,"--accessibility-audit",fX?{level:u5||"AA",failureMode:U8||"report",minSeverity:xX||(U8==="strict"?"error":"warning"),useBaseline:P7}:null],["predictive-ui",g,"--predictive/--predictive-ui"],["raw-element-search",f,"--raw-element-search"],["mcp-recording",B6,"--mcp-recording"],...A3.map((z8)=>[z8.featureFlagKey,Rh[z8.field],z8.label,void 0])],SW$=async()=>{await Ph.initialize();for(let[z8,AU,NU,Ch]of le$){if(!AU)continue;await Ph.setFlag(z8,!0,Ch),Y.info(`Feature flag enabled (${NU})`)}if(!a4)await Ph.setFlag("navigation-screenshots",!1),Y.info("Navigation screenshots disabled (--no-navigation-screenshots)")};if(O6)await K(async()=>{await new V().initialize(),await SW$()});else{let{runDirectModeStartup:z8}=await Promise.resolve().then(() => fe$);await z8({noProxy:w3,assertDbOwnership:async()=>{let{assertDirectModeDbOwnership:AU,createDefaultDirectModeGuardDeps:NU}=await Promise.resolve().then(() => (ge$(),he$));AU(NU())},applyFeatureFlagStartup:SW$})}if(C7)B.setWaitForPollingOverheadEnabled(!1),Y.info("WaitFor polling overhead disabled (--no-waitfor-polling-overhead): screenshots and back stack skipped during observe waitFor polling");let ce$=[[!L1,"UI perf mode disabled (--no-ui-perf-mode): skipping selection-state visual capture on taps and UI perf auditing"],[k0,"Embedded SDK tools enabled (--embedded-sdk)"],[t$,"Dismiss keyboard after inputText enabled (--dismiss-keyboard-after-input)"],[Ah,"Accessibility includeNotImportantViews disabled (--no-include-not-important-views)"],[Nh,"Accessibility reportViewIds disabled (--no-report-view-ids)"],[_h,"Accessibility retrieveInteractiveWindows disabled (--no-retrieve-interactive-windows)"]];for(let[z8,AU]of ce$)if(z8)Y.info(AU);if(O6){await G({port:L4,...b$!==void 0?{host:b$}:{},debug:S4,debugPerf:$1,planExecutionLockScope:j$,videoQualityPreset:d.qualityPreset,videoTargetBitrateKbps:d.targetBitrateKbps,videoMaxThroughputMbps:d.maxThroughputMbps,videoFps:d.fps,videoFormat:d.format,videoMaxArchiveSizeMb:d.maxArchiveSizeMb,toolOutputsDir:Eh,networkMockable:vX,embeddedSdk:k0,dismissKeyboardAfterInput:t$,noUiPerfMode:!L1,memPerfAudit:y1,accessibilityAudit:fX,accessibilityLevel:u5,accessibilityFailureMode:U8,accessibilityMinSeverity:xX,accessibilityUseBaseline:P7,predictiveUi:g,rawElementSearch:f,skipCtrlProxyDownload:W0,mcpRecording:B6,noNavigationScreenshots:!a4,noWaitForPollingOverhead:C7,noA11yIncludeNotImportantViews:Ah,noA11yReportViewIds:Nh,noA11yRetrieveInteractiveWindows:_h,...Rh});return}if(h1)await W(h1,t1),Y.close(),process.exit(0);if(X$)Y.info("Running in CLI mode"),await Q(h$),Y.close(),process.exit(0);else{let z8=!w3,AU={debug:S4,debugPerf:$1,planExecutionLockScope:j$,mcpRecording:B6,videoQualityPreset:d.qualityPreset,videoTargetBitrateKbps:d.targetBitrateKbps,videoMaxThroughputMbps:d.maxThroughputMbps,videoFps:d.fps,videoFormat:d.format,videoMaxArchiveSizeMb:d.maxArchiveSizeMb,toolOutputsDir:Eh,networkMockable:vX,embeddedSdk:k0,dismissKeyboardAfterInput:t$,noUiPerfMode:!L1,memPerfAudit:y1,accessibilityAudit:fX,accessibilityLevel:u5,accessibilityFailureMode:U8,accessibilityMinSeverity:xX,accessibilityUseBaseline:P7,predictiveUi:g,rawElementSearch:f,skipCtrlProxyDownload:W0,noNavigationScreenshots:!a4,noWaitForPollingOverhead:C7,noA11yIncludeNotImportantViews:Ah,noA11yReportViewIds:Nh,noA11yRetrieveInteractiveWindows:_h,...Rh};if(z8)Y.info("Starting MCP server in proxy mode (connecting to daemon)");else Y.info("Starting MCP server in direct mode (--no-proxy flag)"),await F(),await M(),await k(),await u(),c();let NU=()=>{Y.info("stdin closed \u2014 MCP client disconnected, shutting down"),Y.close(),process.exit(0)};process.stdin.on("end",NU),process.stdin.on("error",NU),process.stdin.on("close",NU);let Ch=new $,Th,Ih;try{if(z8){let m5=X({proxyConfig:{autoStartDaemon:!uN,daemonOptions:AU}});Th=m5.server,Ih=m5.proxy}else Th=J({debug:S4})}catch(m5){throw Y.error("Failed to create MCP server:",m5),m5}try{if(Y.info("Connecting MCP server to stdio transport"),F0.startPhase("serverListening"),await Th.connect(Ch),F0.endPhase("serverListening"),Y.info("MCP server connected to stdio transport"),Y.info(`AutoMobile MCP server running on stdio (${z8?"proxy":"direct"} mode)`),F0.emit("mcp-server",{transport:"stdio",mode:z8?"proxy":"direct"}),Ih){let m5=async()=>{await Ih.close()};process.on("beforeExit",m5)}}catch(m5){throw Y.error("MCP server connect failed:",m5),m5}}}catch(X$){throw Y.error("Error initializing server:",X$),X$}}c76().catch(async($)=>{console.error("Fatal error in main():",$),gN?.error("Fatal error in main():",$),gN?.close();let{resolveDaemonStartupExitCode:J}=await Promise.resolve().then(() => (Hh(),YW$));process.exit(J($))});
841
841
 
842
- //# debugId=B06E8C03FED9B83464756E2164756E21
842
+ //# debugId=5BF8C0511478B27164756E2164756E21