@kaeawc/auto-mobile 0.0.33 → 0.0.34

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
@@ -93,7 +93,7 @@ Suggestion: ${_.suggestion}`;if(!z.killed)z.kill();if(!M)M=!0,X.endOperation("pa
93
93
 
94
94
  Suggestion: ${D.suggestion}`;U(new u(R))}}else if(!M)M=!0,X.endOperation("panicDetection"),U(new u(`Emulator process exited with code: ${O}`))}else B.info(`Emulator process exited with code: ${O}`)}),z.on("error",(O)=>{if(clearTimeout(A),!M)M=!0,X.endOperation("panicDetection"),U(new u(`Emulator failed to start: ${O.message}`))})})}async killDevice($){let X=(await this.getBootedDevices()).find((Y)=>Y.deviceId===$.deviceId);if(!X||!X.deviceId)throw new u(`Emulator '${$.name}' is not running`);await this.adbFactory.create(X).executeCommand("emu kill"),B.info(`Killed emulator '${$.name}'`)}async waitForEmulatorReady($,J=120000,X){let W=this.timer.now(),Y=w0(),G=Math.max(parseInt(process.env.EMULATOR_POLLING_INTERVAL_MS||"500",10),100);B.info(`Waiting for emulator '${$}' to be ready... (polling interval: ${G}ms)`);let Q=!1,q=null;if(X&&X.pid){let z=[],K=(w)=>{let L=w.toString();if(z.push(L),z.length>50)z.splice(0,z.length-50)};X.stdout?.on("data",K),X.stderr?.on("data",K),X.on("exit",(w)=>{if(w!==null&&w!==0){Q=!0;let L=z.join(""),M=this.detectCorruptImage(L);if(M.isCorrupt){let F=`Emulator failed to start: ${M.message}`;if(M.suggestion)F+=`
95
95
 
96
- Suggestion: ${M.suggestion}`;q=new u(F)}else{let F=this.detectArchitecturePanic(L);if(F.isPanic)q=new u(`Emulator failed to start: ${F.message}`);else q=new u(`Emulator process exited with code ${w} while waiting for readiness`)}B.error(`Emulator process exited during readiness wait: ${q.message}`)}})}let H=!0,V=null;Y.startOperation("devicePolling");let U=(async()=>{while(H&&!V){try{B.debug(`Background polling iteration - checking for emulator '${$}'...`),B.debug("Checking for running local emulators...");let z=await this.getBootedDevices();if(B.debug(`Device scan complete - found ${z.length} running emulators`),z.length>0){B.debug(`Found ${z.length} running emulators: ${z.map((w)=>`${w.name}(${w.deviceId})`).join(", ")}`);let K=z.find((w)=>w.name===$);if(B.debug(`Exact name match for '${$}': ${K?`Found ${K.deviceId}`:"Not found"}`),!K)if(K=z.find((w)=>w.source==="local"),K)B.debug(`Found local emulator with deviceId ${K.deviceId}, but name mismatch. Expected: ${$}, Found: ${K.name}`);else B.debug("No local emulators found to use as fallback");if(K&&K.deviceId){B.debug(`Target emulator found: ${K.name} (${K.deviceId}) - starting readiness checks`),B.debug(`[PARALLEL] Running device state and package manager checks for ${K.deviceId}...`);let w=this.adbFactory.create(K);try{Y.startOperation("adbParallelChecks");let[L,M]=await Promise.allSettled([w.executeCommand("get-state"),w.executeCommand("shell pm list packages")]);if(Y.endOperation("adbParallelChecks"),L.status!=="fulfilled"||M.status!=="fulfilled")B.debug(`[PARALLEL] Checks not yet complete: deviceStatus: ${L.status}, packageManager: ${M.status}`);else{let F=L.value.stdout.trim();if(B.debug(`[PARALLEL] Package manager command completed for ${K.deviceId} - output: ${M.value.stdout.length} bytes`),!F.includes("device"))B.debug(`[PARALLEL] \u274C Device state check failed for ${K.deviceId}: state="${F}"`);else if(!M.value.stdout||!M.value.stdout.includes("package:"))B.debug(`[PARALLEL] \u274C Package manager returned no packages for ${K.deviceId} (${M.value.stdout.length} bytes output)`);else if(M.value.stderr||M.value.stderr.includes("Failure"))B.debug(`[PARALLEL] \u274C Package manager returned failure for ${K.deviceId}: ${M.value.stderr}`);else{B.debug(`[PARALLEL] \u2705 Device state check passed for ${K.deviceId}`),B.debug(`[PARALLEL] \u2705 Package manager is responsive for ${K.deviceId} - emulator is ready!`),B.debug("[PARALLEL] \u2705 No package manager errors detected - marking emulator as ready"),V=K.deviceId;return}}}catch(L){B.debug(`[PARALLEL] \u274C Parallel checks failed for ${K.deviceId}: ${L}`)}}else B.debug(`No suitable emulator found for '${$}' - will continue polling`)}else B.debug("No running emulators detected - will continue polling")}catch(z){B.debug(`Background polling error (will continue): ${z}`)}B.debug(`Background polling cycle complete - sleeping ${G}ms before next check`),await this.sleep(G)}B.debug(`Background polling stopped - pollingActive: ${H}, foundDeviceId: ${V}`)})();while(this.timer.now()-W<J){if(Q&&q)throw H=!1,await U,Y.endOperation("devicePolling"),q;if(V){H=!1,Y.endOperation("devicePolling"),B.info(`Emulator '${$}' is ready! Device ID: ${V}`);let z={name:$,platform:"android",deviceId:V};return Y.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(z),Y.endOperation("wakeAndUnlock"),z}await this.sleep(500)}if(H=!1,await U,Y.endOperation("devicePolling"),V){B.info(`Emulator '${$}' is ready! Device ID: ${V}`);let z={name:$,platform:"android",deviceId:V};return Y.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(z),Y.endOperation("wakeAndUnlock"),z}throw new u(`Emulator '${$}' failed to become ready within ${J}ms`)}async wakeAndUnlock($){let J=this.adbFactory.create($);try{let X=await J.getWakefulness();if(B.info(`[WakeAndUnlock] Device wakefulness state: ${X}`),X!=="Awake")B.info("[WakeAndUnlock] Device not awake, sending KEYCODE_WAKEUP"),await J.executeCommand("shell input keyevent KEYCODE_WAKEUP"),await this.sleep(500);B.info("[WakeAndUnlock] Dismissing keyguard"),await J.executeCommand("shell wm dismiss-keyguard");let W=await J.getWakefulness();B.info(`[WakeAndUnlock] Final wakefulness state: ${W}`)}catch(X){B.warn(`[WakeAndUnlock] Failed to wake/unlock device: ${X}`)}}sleep($){return this.timer.sleep($)}}var oy0=async($)=>{let J=await ny0(cy0)($);return{stdout:J.stdout,stderr:J.stderr,toString(){return this.stdout},trim(){return this.stdout.trim()},includes(W){return this.stdout.includes(W)}}};var hR=E(()=>{e();C6();O6();TR();E$();c0();ry$()});class WW{adb;emulator;simctl;constructor($=null,J=null,X=null){this.adb=$||z$.create(null),this.simctl=J||new V1,this.emulator=X||new yG}async listDeviceImages($){switch($){case"android":return this.emulator.listAvds();case"ios":return this.simctl.listSimulatorImages();case"either":let J=await this.emulator.listAvds(),X=await this.simctl.listSimulatorImages();return[...J,...X]}}async isDeviceImageRunning($){switch($.platform){case"android":return this.emulator.isAvdRunning($.name);case"ios":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.simctl.getBootedSimulators();case"either":let J=await this.emulator.getBootedDevices(),X=await this.simctl.getBootedSimulators();return[...J,...X]}}async startDevice($){if(await this.isDeviceImageRunning($))throw new u(`${$.platform} device '${$.name}' is already running`);switch($.platform){case"android":return this.emulator.startEmulator($.name);case"ios":return this.simctl.startSimulator($.deviceId??$.name);default:throw new u("Unknown platform")}}async killDevice($){switch($.platform){case"android":return this.emulator.killDevice($);case"ios":return this.simctl.killSimulator($)}}async waitForDeviceReady($,J=120000,X){switch($.platform){case"android":return this.emulator.waitForEmulatorReady($.name,J,X);case"ios":return this.simctl.waitForSimulatorReady($.deviceId??$.name,J);default:throw new u("Unknown platform")}}}var KO=E(()=>{C6();O6();h5();hR()});import WH$ from"crypto";class $7{generateCacheKey($){return WH$.createHash("md5").update($).digest("hex")}verifyChecksum($,J){return WH$.createHash("sha256").update($).digest("hex").toLowerCase()===J.toLowerCase()}static generateCacheKey=($)=>new $7().generateCacheKey($);static verifyChecksum=($,J)=>new $7().verifyChecksum($,J)}var qK=()=>{};import ry0 from"fs";import ay0 from"os";import ay$ from"path";function hQ($){return ay$.join(ty0,$)}function ty$($){let J=hQ($);return ry0.mkdirSync(J,{recursive:!0,mode:sy0}),J}var ty0,sy0=448,gG;var wO=E(()=>{ty0=ay$.join(ay0.tmpdir(),"auto-mobile");gG={LOGS:"logs",TOOL_LOGS:"tool_logs",SCREENSHOTS:"screenshots",NAVIGATION_SCREENSHOTS:"navigation-screenshots",VIEW_HIERARCHY:"view_hierarchy",OBSERVE_RESULTS:"observe_results",WINDOW:"window",CACHE:"cache"}});import*as HK from"fs/promises";import*as $g$ from"path";class yQ{adb;cachedActiveWindow=null;device;cacheDir=hQ(gG.WINDOW);constructor($,J=z$){if(J&&typeof J.create==="function")this.adb=J.create($);else if(J)this.adb=J;else this.adb=z$.create($);this.device=$}getCacheFilePath(){let $=$7.generateCacheKey(this.device.deviceId);return $g$.join(this.cacheDir,$)}getDeviceId(){return this.device.deviceId}async writeCacheToDisk($){let J=this.getCacheFilePath();if(!J){B.info("[WINDOW] No device ID, skipping disk cache write");return}try{await HK.mkdir(this.cacheDir,{recursive:!0}),await HK.writeFile(J,JSON.stringify($),"utf-8"),B.debug(`Wrote active window cache to disk: ${J}`)}catch(X){B.error(`Failed to write cache to disk: ${X}`)}}async readCacheFromDisk(){let $=this.getCacheFilePath();if(!$)return B.info("[WINDOW] No device ID, skipping disk cache read"),null;try{let J=await HK.readFile($,"utf-8"),X=JSON.parse(J);return B.debug(`Read active window cache from disk: ${$}`),X}catch(J){return B.debug(`No disk cache found or error reading: ${J}`),null}}async setCachedActiveWindow($){this.cachedActiveWindow=$,await this.writeCacheToDisk($),B.info("[WINDOW] Cached active window from external source")}async clearCache(){this.cachedActiveWindow=null;let $=this.getCacheFilePath();if($)try{await HK.unlink($),B.info("[WINDOW] Cleared cached active window from disk")}catch(J){B.debug(`Could not remove disk cache: ${J}`)}B.info("[WINDOW] Cleared cached active window")}async getCachedActiveWindow(){if(!this.cachedActiveWindow){B.info("[WINDOW] Using disk cached active window");let $=await this.readCacheFromDisk();if($)return this.cachedActiveWindow=$,B.info("[WINDOW] Using disk cached active window"),$}return this.cachedActiveWindow}async getActive($=!1,J=new N$){if(!$&&this.cachedActiveWindow)return B.info("[WINDOW] Using memory cached active window"),this.cachedActiveWindow;if(!$&&!this.cachedActiveWindow){B.info("[WINDOW] Using disk cached active window");let X=await J.track("readDiskCache",()=>this.readCacheFromDisk());if(X)return this.cachedActiveWindow=X,B.info("[WINDOW] Using disk cached active window"),X}try{let{stdout:X}=await J.track("adbDumpsysWindowWindows",()=>this.adb.executeCommand('shell "dumpsys window windows"')),W=null;if(typeof this.adb.getAndroidApiLevel==="function")W=await this.adb.getAndroidApiLevel();let Y=null;if(W!==null&&W!==void 0&&W<=27){if(Y=ey$(X),!Y)Y=ey0(X);if(!Y)Y=await this.parseActiveWindowFromDumpsysWindow();if(!Y)Y=sy$(X)}else Y=sy$(X);let G=Y?.appId??"",Q=Y?.activityName??"",q=0,H=X.matchAll(/mLayoutSeq=([\d\.]+)/g);if(H)for(let j of H){let U=parseInt(j[1],10);if(!isNaN(U))q+=U}let V={appId:G,activityName:Q,layoutSeqSum:q};if(this.cachedActiveWindow=V,await this.writeCacheToDisk(V),B.info("[WINDOW] Cached new active window information"),!G||!Q){let j=X.trim().slice(0,200);B.warn(`[WINDOW] Failed to parse active window from dumpsys output. Sample: ${j||"<empty>"}`)}return V}catch(X){return B.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 ey$($)}catch($){return B.error(`Failed to get dumpsys window for legacy fallback: ${$}`),null}}async getActiveHash($=new N$){B.info("[WINDOW] Getting hash of active window");let J=await this.getActive(!0,$),X=JSON.stringify(J);return $7.generateCacheKey(X)}}function sy$($){let J="",X="",W=$.match(/imeControlTarget.*?Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(W&&W.length>=3)J=W[1],X=W[2];else{let Y=$.match(/imeControlTarget.*?Window\{([0-9a-f]+)\s+u\d+\s+Pop-Up Window\}/i);if(Y){let G=Y[1],Q=new RegExp(`Window #\\d+ Window\\{${G} u\\d+ Pop-Up Window\\}:([\\s\\S]*?)(?=Window #\\d+|$)`),q=$.match(Q);if(q){let H=q[1].match(/mActivityRecord=ActivityRecord\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)(?:\s+t\d+)?\}/);if(H&&H.length>=3)J=H[1],X=H[2]}}if(!J||!X){let G=$.matchAll(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?mViewVisibility=0x0[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs);for(let Q of G)if(Q[1]&&Q[2]&&!Q[1].includes("android.systemui")&&!Q[1].includes("nexuslauncher")){J=Q[1],X=Q[2];break}if(!J||!X){let Q=$.match(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION/);if(Q&&Q.length>=3)J=Q[1],X=Q[2]}}if(!J||!X){let Q=/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(Q&&Q.length>=3)J=Q[1],X=Q[2]}}if(J&&X)return{appId:J,activityName:X};return null}function ey0($){let J=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:([\s\S]*?)(?=Window #\d+|$)/g,X=[...$.matchAll(J)];for(let W of X){let Y=W[1],G=W[2],Q=W[3];if(!Y||!G)continue;if(Y.includes("android.systemui")||Y.includes("nexuslauncher"))continue;if(/\bty=1\b/.test(Q)&&/isReadyForDisplay\(\)=true/.test(Q))return{appId:Y,activityName:G}}return null}function ey$($){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 yR=E(()=>{O6();e();qK();c0();wO()});function VK($,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 ${$g0($)}`)}function $g0($){if(typeof $==="string")return`string "${$}"`;try{return JSON.stringify($)??String($)}catch{return Object.prototype.toString.call($)}}function EV($,J,X=YH$){if(X.length===0)return"";let Y=$.trim().toLowerCase()==="latest"?X[0]:X.find((G)=>G.version===$);if(!Y)return"";return J==="android"?Y.apkSha256:Y.ipaSha256}function Jg0(){if(YH$.length===0)return"latest";return YH$[0].version}function gZ($){if($==="latest")return Jg0();return $}function Jg$($,J){let X=gZ(J);if(X==="latest")return`https://github.com/kaeawc/auto-mobile/releases/latest/download/${$}`;return`https://github.com/kaeawc/auto-mobile/releases/download/${X}/${$}`}var Yi="latest",YH$,YW="latest",gR,Xg$,Jz,Gi,Wg$,Qi="",Yg$="";var LO=E(()=>{YH$=[{version:"0.0.33",apkSha256:"7289eba90b22890d3c36e05e99db72a545fa4becdf46df079885783a919e6aed",ipaSha256:"425dfa4db4ad5a4febc9f05ffc97df38f3a1098ccdd9330adff1c0b5c877697d"},{version:"0.0.32",apkSha256:"4c4a743af5d18ed58214e64b85986c9e2f2332b015edcf7d9d68a24cd6dfda21",ipaSha256:"40f4d9084d3368995b57c0e81c4fe85f38851353da9f789eaff93027aee456a0"},{version:"0.0.31",apkSha256:"0b5802ada8d9adccdb69ee140ae788b3251832c0605d2f6baa3e9b7a78260764",ipaSha256:"e60f8689fb6ddd5c06a5d2ff57569b264f407229afb986258d1ce20326dc24c7"},{version:"0.0.30",apkSha256:"a1be5e6240f204ee99540e99cc198f7c0b592dbaf3699330c14f6ded7d333ec3",ipaSha256:"5ac285dd5be16439d3a8a8973c98606920461acfce489830e54ee20759a7b235"},{version:"0.0.29",apkSha256:"b33a67c7efa84aca2b07faa965aecb3b1819b4defd441dcc8d3bf7e2af209cd8",ipaSha256:"d47c1aea4495270c1489cae361286ea1439c2ba4e7d5bcfd73f66e4580a6c45d"},{version:"0.0.28",apkSha256:"0f683d5939bc308afe038ea1259eb29997dff38af0795136a281ad305986e40e",ipaSha256:"eee7accfbca717bb8b89fafd0676f10d8bb08561c3fbd7a04750c9b12c2a7104"},{version:"0.0.27",apkSha256:"9966113ae44f38f3cf34544b1375d3c9a3706701edba45a1eec1f220b9c676cc",ipaSha256:"8620de6b014df18465876334f9ba8c106292f6c3059370eea2349f1e44db4f4d"},{version:"0.0.26",apkSha256:"2eb2f156fd27602c85003ab8f6e00d3e06850e84f5453d75b7494aa5bbed7be0",ipaSha256:"905df276d2224d31cbc5aa2258d2dcc60eaeb9813727081ddd32c95394fec411"},{version:"0.0.25",apkSha256:"f727079edb4906e3b7928dbb641e788543e86b11fff3fc1b76f0c51b9c8d6e5d",ipaSha256:"d8032cc1cebcb456b7232aa67fc42c89ff62729bacf141aa8f594ce6f8bcd980"},{version:"0.0.24",apkSha256:"9047795bc6098f4ec687c126123c73c423806a9fd52888af391d6fb5b94ac93f",ipaSha256:"1dd3e0370cb8ed01d8e1020558d8a2808f208bd947bafcf6688211eddc928bf8"},{version:"0.0.18",apkSha256:"fd3c8d9f0b8542eaad56c78b18cf8e5666367b04ae8c4af74d8aa6dd1c8d1834",ipaSha256:"2a5eec63bce2f9dfc227c0732fcce67378305e945604d5eedd0e3df48e37fd39"},{version:"0.0.17",apkSha256:"916033440931666644474f227c8e39d13d9c80c3515e4292cc5581fd5bd4cc2f",ipaSha256:"e4dcf064d024f2371b8fd79281000e2d49751ef95b8817d1494d685aeda746ac"}];gR=Jg$("control-proxy-debug.apk",YW),Xg$=EV(YW,"android"),Jz=YW,Gi=Jg$("control-proxy.ipa",Jz),Wg$=EV(Jz,"ios")});var GH$=h((lY4,Gg$)=>{Gg$.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 qi=h((qg$)=>{var Qg$={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 Xg0($){return function(...J){if(J.length)$=$.replace(/\{(\d)\}/g,(X,W)=>J[W]||"");return Error("ADM-ZIP: "+$)}}for(let $ of Object.keys(Qg$))qg$[$]=Xg0(Qg$[$])});var zg$=h((pY4,Ug$)=>{var Wg0=K0("fs"),y5=K0("path"),Hg$=GH$(),Yg0=qi(),Gg0=typeof process==="object"&&process.platform==="win32",Vg$=($)=>typeof $==="object"&&$!==null,jg$=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 q5($){if(this.sep=y5.sep,this.fs=Wg0,Vg$($)){if(Vg$($.fs)&&typeof $.fs.statSync==="function")this.fs=$.fs}}Ug$.exports=q5;q5.prototype.makeDir=function($){let J=this;function X(W){let Y=W.split(J.sep)[0];W.split(J.sep).forEach(function(G){if(!G||G.substr(-1,1)===":")return;Y+=J.sep+G;var Q;try{Q=J.fs.statSync(Y)}catch(q){if(q.message&&q.message.startsWith("ENOENT"))J.fs.mkdirSync(Y);else throw q}if(Q&&Q.isFile())throw Yg0.FILE_IN_THE_WAY(`"${Y}"`)})}X($)};q5.prototype.writeFileTo=function($,J,X,W){let Y=this;if(Y.fs.existsSync($)){if(!X)return!1;var G=Y.fs.statSync($);if(G.isDirectory())return!1}var Q=y5.dirname($);if(!Y.fs.existsSync(Q))Y.makeDir(Q);var q;try{q=Y.fs.openSync($,"w",438)}catch(H){Y.fs.chmodSync($,438),q=Y.fs.openSync($,"w",438)}if(q)try{Y.fs.writeSync(q,J,0,J.length,0)}finally{Y.fs.closeSync(q)}return Y.fs.chmodSync($,W||438),!0};q5.prototype.writeFileToAsync=function($,J,X,W,Y){if(typeof W==="function")Y=W,W=void 0;let G=this;G.fs.exists($,function(Q){if(Q&&!X)return Y(!1);G.fs.stat($,function(q,H){if(Q&&H.isDirectory())return Y(!1);var V=y5.dirname($);G.fs.exists(V,function(j){if(!j)G.makeDir(V);G.fs.open($,"w",438,function(U,z){if(U)G.fs.chmod($,438,function(){G.fs.open($,"w",438,function(K,w){G.fs.write(w,J,0,J.length,0,function(){G.fs.close(w,function(){G.fs.chmod($,W||438,function(){Y(!0)})})})})});else if(z)G.fs.write(z,J,0,J.length,0,function(){G.fs.close(z,function(){G.fs.chmod($,W||438,function(){Y(!0)})})});else G.fs.chmod($,W||438,function(){Y(!0)})})})})})};q5.prototype.findFiles=function($){let J=this;function X(W,Y,G){if(typeof Y==="boolean")G=Y,Y=void 0;let Q=[];return J.fs.readdirSync(W).forEach(function(q){let H=y5.join(W,q),V=J.fs.statSync(H);if(!Y||Y.test(H))Q.push(y5.normalize(H)+(V.isDirectory()?J.sep:""));if(V.isDirectory()&&G)Q=Q.concat(X(H,Y,G))}),Q}return X($,void 0,!0)};q5.prototype.findFilesAsync=function($,J){let X=this,W=[];X.fs.readdir($,function(Y,G){if(Y)return J(Y);let Q=G.length;if(!Q)return J(null,W);G.forEach(function(q){q=y5.join($,q),X.fs.stat(q,function(H,V){if(H)return J(H);if(V){if(W.push(y5.normalize(q)+(V.isDirectory()?X.sep:"")),V.isDirectory())X.findFilesAsync(q,function(j,U){if(j)return J(j);if(W=W.concat(U),!--Q)J(null,W)});else if(!--Q)J(null,W)}})})})};q5.prototype.getAttributes=function(){};q5.prototype.setAttributes=function(){};q5.crc32update=function($,J){return jg$[($^J)&255]^$>>>8};q5.crc32=function($){if(typeof $==="string")$=Buffer.from($,"utf8");let J=$.length,X=-1;for(let W=0;W<J;)X=q5.crc32update(X,$[W++]);return~X>>>0};q5.methodToString=function($){switch($){case Hg$.STORED:return"STORED ("+$+")";case Hg$.DEFLATED:return"DEFLATED ("+$+")";default:return"UNSUPPORTED ("+$+")"}};q5.canonical=function($){if(!$)return"";let J=y5.posix.normalize("/"+$.split("\\").join("/"));return y5.join(".",J)};q5.zipnamefix=function($){if(!$)return"";let J=y5.posix.normalize("/"+$.split("\\").join("/"));return y5.posix.join(".",J)};q5.findLast=function($,J){if(!Array.isArray($))throw TypeError("arr is not array");let X=$.length>>>0;for(let W=X-1;W>=0;W--)if(J($[W],W,$))return $[W];return};q5.sanitize=function($,J){$=y5.resolve(y5.normalize($));var X=J.split("/");for(var W=0,Y=X.length;W<Y;W++){var G=y5.normalize(y5.join($,X.slice(W,Y).join(y5.sep)));if(G.indexOf($)===0)return G}return y5.normalize(y5.join($,y5.basename(J)))};q5.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)};q5.readBigUInt64LE=function($,J){let X=$.readUInt32LE(J);return $.readUInt32LE(J+4)*4294967296+X};q5.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)};q5.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};q5.isWin=Gg0;q5.crcTable=jg$});var Kg$=h((nY4,Bg$)=>{var Qg0=K0("path");Bg$.exports=function($,{fs:J}){var X=$||"",W=G(),Y=null;function G(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&J.existsSync(X))Y=J.statSync(X),W.directory=Y.isDirectory(),W.mtime=Y.mtime,W.atime=Y.atime,W.executable=(73&Y.mode)!==0,W.readonly=(128&Y.mode)===0,W.hidden=Qg0.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return W.directory},get readOnly(){return W.readonly},get hidden(){return W.hidden},get mtime(){return W.mtime},get atime(){return W.atime},get executable(){return W.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:W.directory,isReadOnly:W.readonly,isHidden:W.hidden,isExecutable:W.executable,mTime:W.mtime,aTime:W.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Lg$=h((dY4,wg$)=>{wg$.exports={efs:!0,encode:($)=>Buffer.from($,"utf8"),decode:($)=>$.toString("utf8")}});var mR=h((iY4,uR)=>{uR.exports=zg$();uR.exports.Constants=GH$();uR.exports.Errors=qi();uR.exports.FileAttr=Kg$();uR.exports.decoder=Lg$()});var Og$=h((oY4,Mg$)=>{var jK=mR(),M6=jK.Constants;Mg$.exports=function(){var $=20,J=10,X=0,W=0,Y=0,G=0,Q=0,q=0,H=0,V=0,j=0,U=0,z=0,K=0,w=0;$|=jK.isWin?2560:768,X|=M6.FLG_EFS;let L={extraLen:0},M=(O)=>Math.max(0,O)>>>0,F=(O)=>Math.max(0,O)&65535,A=(O)=>Math.max(0,O)&255;return Y=jK.fromDate2DOS(new Date),{get made(){return $},set made(O){$=O},get version(){return J},set version(O){J=O},get flags(){return X},set flags(O){X=O},get flags_efs(){return(X&M6.FLG_EFS)>0},set flags_efs(O){if(O)X|=M6.FLG_EFS;else X&=~M6.FLG_EFS},get flags_desc(){return(X&M6.FLG_DESC)>0},set flags_desc(O){if(O)X|=M6.FLG_DESC;else X&=~M6.FLG_DESC},get method(){return W},set method(O){switch(O){case M6.STORED:this.version=10;case M6.DEFLATED:default:this.version=20}W=O},get time(){return jK.fromDOS2Date(this.timeval)},set time(O){O=new Date(O),this.timeval=jK.fromDate2DOS(O)},get timeval(){return Y},set timeval(O){Y=M(O)},get timeHighByte(){return A(Y>>>8)},get crc(){return G},set crc(O){G=M(O)},get compressedSize(){return Q},set compressedSize(O){Q=M(O)},get size(){return q},set size(O){q=M(O)},get fileNameLength(){return H},set fileNameLength(O){H=O},get extraLength(){return V},set extraLength(O){V=O},get extraLocalLength(){return L.extraLen},set extraLocalLength(O){L.extraLen=O},get commentLength(){return j},set commentLength(O){j=O},get diskNumStart(){return U},set diskNumStart(O){U=M(O)},get inAttr(){return z},set inAttr(O){z=M(O)},get attr(){return K},set attr(O){K=M(O)},get fileAttr(){return(K||0)>>16&4095},get offset(){return w},set offset(O){w=M(O)},get encrypted(){return(X&M6.FLG_ENC)===M6.FLG_ENC},get centralHeaderSize(){return M6.CENHDR+H+V+j},get realDataOffset(){return w+M6.LOCHDR+L.fnameLen+L.extraLen},get localHeader(){return L},loadLocalHeaderFromBinary:function(O){var N=O.slice(w,w+M6.LOCHDR);if(N.readUInt32LE(0)!==M6.LOCSIG)throw jK.Errors.INVALID_LOC();L.version=N.readUInt16LE(M6.LOCVER),L.flags=N.readUInt16LE(M6.LOCFLG),L.flags_desc=(L.flags&M6.FLG_DESC)>0,L.method=N.readUInt16LE(M6.LOCHOW),L.time=N.readUInt32LE(M6.LOCTIM),L.crc=N.readUInt32LE(M6.LOCCRC),L.compressedSize=N.readUInt32LE(M6.LOCSIZ),L.size=N.readUInt32LE(M6.LOCLEN),L.fnameLen=N.readUInt16LE(M6.LOCNAM),L.extraLen=N.readUInt16LE(M6.LOCEXT);let D=w+M6.LOCHDR+L.fnameLen,R=D+L.extraLen;return O.slice(D,R)},loadFromBinary:function(O){if(O.length!==M6.CENHDR||O.readUInt32LE(0)!==M6.CENSIG)throw jK.Errors.INVALID_CEN();$=O.readUInt16LE(M6.CENVEM),J=O.readUInt16LE(M6.CENVER),X=O.readUInt16LE(M6.CENFLG),W=O.readUInt16LE(M6.CENHOW),Y=O.readUInt32LE(M6.CENTIM),G=O.readUInt32LE(M6.CENCRC),Q=O.readUInt32LE(M6.CENSIZ),q=O.readUInt32LE(M6.CENLEN),H=O.readUInt16LE(M6.CENNAM),V=O.readUInt16LE(M6.CENEXT),j=O.readUInt16LE(M6.CENCOM),U=O.readUInt16LE(M6.CENDSK),z=O.readUInt16LE(M6.CENATT),K=O.readUInt32LE(M6.CENATX),w=O.readUInt32LE(M6.CENOFF)},localHeaderToBinary:function(){var O=Buffer.alloc(M6.LOCHDR);return O.writeUInt32LE(M6.LOCSIG,0),O.writeUInt16LE(J,M6.LOCVER),O.writeUInt16LE(X,M6.LOCFLG),O.writeUInt16LE(W,M6.LOCHOW),O.writeUInt32LE(Y,M6.LOCTIM),O.writeUInt32LE(G,M6.LOCCRC),O.writeUInt32LE(Q,M6.LOCSIZ),O.writeUInt32LE(q,M6.LOCLEN),O.writeUInt16LE(H,M6.LOCNAM),O.writeUInt16LE(L.extraLen,M6.LOCEXT),O},centralHeaderToBinary:function(){var O=Buffer.alloc(M6.CENHDR+H+V+j);return O.writeUInt32LE(M6.CENSIG,0),O.writeUInt16LE($,M6.CENVEM),O.writeUInt16LE(J,M6.CENVER),O.writeUInt16LE(X,M6.CENFLG),O.writeUInt16LE(W,M6.CENHOW),O.writeUInt32LE(Y,M6.CENTIM),O.writeUInt32LE(G,M6.CENCRC),O.writeUInt32LE(Q,M6.CENSIZ),O.writeUInt32LE(q,M6.CENLEN),O.writeUInt16LE(H,M6.CENNAM),O.writeUInt16LE(V,M6.CENEXT),O.writeUInt16LE(j,M6.CENCOM),O.writeUInt16LE(U,M6.CENDSK),O.writeUInt16LE(z,M6.CENATT),O.writeUInt32LE(K,M6.CENATX),O.writeUInt32LE(w,M6.CENOFF),O},toJSON:function(){let O=function(N){return N+" bytes"};return{made:$,version:J,flags:X,method:jK.methodToString(W),time:this.time,crc:"0x"+G.toString(16).toUpperCase(),compressedSize:O(Q),size:O(q),fileNameLength:O(H),extraLength:O(V),commentLength:O(j),diskNumStart:U,inAttr:z,attr:K,offset:w,centralHeaderSize:O(M6.CENHDR+H+V+j)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Fg$=h((rY4,Dg$)=>{var lR=mR(),E9=lR.Constants;Dg$.exports=function(){var $=0,J=0,X=0,W=0,Y=0;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 W},set offset(G){W=G},get commentLength(){return Y},set commentLength(G){Y=G},get mainHeaderSize(){return E9.ENDHDR+Y},loadFromBinary:function(G){if((G.length!==E9.ENDHDR||G.readUInt32LE(0)!==E9.ENDSIG)&&(G.length<E9.ZIP64HDR||G.readUInt32LE(0)!==E9.ZIP64SIG))throw lR.Errors.INVALID_END();if(G.readUInt32LE(0)===E9.ENDSIG)$=G.readUInt16LE(E9.ENDSUB),J=G.readUInt16LE(E9.ENDTOT),X=G.readUInt32LE(E9.ENDSIZ),W=G.readUInt32LE(E9.ENDOFF),Y=G.readUInt16LE(E9.ENDCOM);else $=lR.readBigUInt64LE(G,E9.ZIP64SUB),J=lR.readBigUInt64LE(G,E9.ZIP64TOT),X=lR.readBigUInt64LE(G,E9.ZIP64SIZE),W=lR.readBigUInt64LE(G,E9.ZIP64OFF),Y=0},toBinary:function(){var G=Buffer.alloc(E9.ENDHDR+Y);return G.writeUInt32LE(E9.ENDSIG,0),G.writeUInt32LE(0,4),G.writeUInt16LE($,E9.ENDSUB),G.writeUInt16LE(J,E9.ENDTOT),G.writeUInt32LE(X,E9.ENDSIZ),G.writeUInt32LE(W,E9.ENDOFF),G.writeUInt16LE(Y,E9.ENDCOM),G.fill(" ",E9.ENDHDR),G},toJSON:function(){let G=function(Q,q){let H=Q.toString(16).toUpperCase();while(H.length<q)H="0"+H;return"0x"+H};return{diskEntries:$,totalEntries:J,size:X+" bytes",offset:G(W,4),commentLength:Y}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var QH$=h((qg0)=>{qg0.EntryHeader=Og$();qg0.MainHeader=Fg$()});var Ag$=h((tY4,Ng$)=>{Ng$.exports=function($){var J=K0("zlib"),X={chunkSize:(parseInt($.length/1024)+1)*1024};return{deflate:function(){return J.deflateRawSync($,X)},deflateAsync:function(W){var Y=J.createDeflateRaw(X),G=[],Q=0;Y.on("data",function(q){G.push(q),Q+=q.length}),Y.on("end",function(){var q=Buffer.alloc(Q),H=0;q.fill(0);for(var V=0;V<G.length;V++){var j=G[V];j.copy(q,H),H+=j.length}W&&W(q)}),Y.end($)}}}});var _g$=h((sY4,Rg$)=>{var jg0=+(process.versions?process.versions.node:"").split(".")[0]||0;Rg$.exports=function($,J){var X=K0("zlib");let W=jg0>=15&&J>0?{maxOutputLength:J}:{};return{inflate:function(){return X.inflateRawSync($,W)},inflateAsync:function(Y){var G=X.createInflateRaw(W),Q=[],q=0;G.on("data",function(H){Q.push(H),q+=H.length}),G.on("end",function(){var H=Buffer.alloc(q),V=0;H.fill(0);for(var j=0;j<Q.length;j++){var U=Q[j];U.copy(H,V),V+=U.length}Y&&Y(H)}),G.end($)}}}});var Ig$=h((eY4,Cg$)=>{var{randomFillSync:Eg$}=K0("crypto"),Ug0=qi(),zg0=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}),Pg$=($,J)=>Math.imul($,J)>>>0,Sg$=($,J)=>{return zg0[($^J)&255]^$>>>8},uZ=()=>{if(typeof Eg$==="function")return Eg$(Buffer.alloc(12));else return uZ.node()};uZ.node=()=>{let $=Buffer.alloc(12),J=$.length;for(let X=0;X<J;X++)$[X]=Math.random()*256&255;return $};var Hi={genSalt:uZ};function Vi($){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])}Vi.prototype.updateKeys=function($){let J=this.keys;return J[0]=Sg$(J[0],$),J[1]+=J[0]&255,J[1]=Pg$(J[1],134775813)+1,J[2]=Sg$(J[2],J[1]>>>24),$};Vi.prototype.next=function(){let $=(this.keys[2]|2)>>>0;return Pg$($,$^1)>>8&255};function Bg0($){let J=new Vi($);return function(X){let W=Buffer.alloc(X.length),Y=0;for(let G of X)W[Y++]=J.updateKeys(G^J.next());return W}}function Kg0($){let J=new Vi($);return function(X,W,Y=0){if(!W)W=Buffer.alloc(X.length);for(let G of X){let Q=J.next();W[Y++]=G^Q,J.updateKeys(G)}return W}}function wg0($,J,X){if(!$||!Buffer.isBuffer($)||$.length<12)return Buffer.alloc(0);let W=Bg0(X),Y=W($.slice(0,12)),G=(J.flags&8)===8?J.timeHighByte:J.crc>>>24;if(Y[11]!==G)throw Ug0.WRONG_PASSWORD();return W($.slice(12))}function Lg0($){if(Buffer.isBuffer($)&&$.length>=12)Hi.genSalt=function(){return $.slice(0,12)};else if($==="node")Hi.genSalt=uZ.node;else Hi.genSalt=uZ}function Mg0($,J,X,W=!1){if($==null)$=Buffer.alloc(0);if(!Buffer.isBuffer($))$=Buffer.from($.toString());let Y=Kg0(X),G=Hi.genSalt();if(G[11]=J.crc>>>24&255,W)G[10]=J.crc>>>16&255;let Q=Buffer.alloc($.length+12);return Y(G,Q),Y($,Q,12)}Cg$.exports={decrypt:wg0,encrypt:Mg0,_salter:Lg0}});var vg$=h((Og0)=>{Og0.Deflater=Ag$();Og0.Inflater=_g$();Og0.ZipCrypto=Ig$()});var HH$=h((JG4,kg$)=>{var RJ=mR(),Ag0=QH$(),H5=RJ.Constants,qH$=vg$();kg$.exports=function($,J){var X=new Ag0.EntryHeader,W=Buffer.alloc(0),Y=Buffer.alloc(0),G=!1,Q=null,q=Buffer.alloc(0),H=Buffer.alloc(0),V=!0;let j=$,U=typeof j.decoder==="object"?j.decoder:RJ.decoder;V=U.hasOwnProperty("efs")?U.efs:!1;function z(){if(!J||!(J instanceof Uint8Array))return Buffer.alloc(0);return H=X.loadLocalHeaderFromBinary(J),J.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function K(O){if(!X.flags_desc&&!X.localHeader.flags_desc){if(RJ.crc32(O)!==X.localHeader.crc)return!1}else{let N={},D=X.realDataOffset+X.compressedSize;if(J.readUInt32LE(D)==H5.LOCSIG||J.readUInt32LE(D)==H5.CENSIG)throw RJ.Errors.DESCRIPTOR_NOT_EXIST();if(J.readUInt32LE(D)==H5.EXTSIG)N.crc=J.readUInt32LE(D+H5.EXTCRC),N.compressedSize=J.readUInt32LE(D+H5.EXTSIZ),N.size=J.readUInt32LE(D+H5.EXTLEN);else if(J.readUInt16LE(D+12)===19280)N.crc=J.readUInt32LE(D+H5.EXTCRC-4),N.compressedSize=J.readUInt32LE(D+H5.EXTSIZ-4),N.size=J.readUInt32LE(D+H5.EXTLEN-4);else throw RJ.Errors.DESCRIPTOR_UNKNOWN();if(N.compressedSize!==X.compressedSize||N.size!==X.size||N.crc!==X.crc)throw RJ.Errors.DESCRIPTOR_FAULTY();if(RJ.crc32(O)!==N.crc)return!1}return!0}function w(O,N,D){if(typeof N>"u"&&typeof O==="string")D=O,O=void 0;if(G){if(O&&N)N(Buffer.alloc(0),RJ.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var R=z();if(R.length===0){if(O&&N)N(R);return R}if(X.encrypted){if(typeof D!=="string"&&!Buffer.isBuffer(D))throw RJ.Errors.INVALID_PASS_PARAM();R=qH$.ZipCrypto.decrypt(R,X,D)}var _=Buffer.alloc(X.size);switch(X.method){case RJ.Constants.STORED:if(R.copy(_),!K(_)){if(O&&N)N(_,RJ.Errors.BAD_CRC());throw RJ.Errors.BAD_CRC()}else{if(O&&N)N(_);return _}case RJ.Constants.DEFLATED:var S=new qH$.Inflater(R,X.size);if(!O){if(S.inflate(_).copy(_,0),!K(_))throw RJ.Errors.BAD_CRC(`"${U.decode(W)}"`);return _}else S.inflateAsync(function(k){if(k.copy(k,0),N)if(!K(k))N(k,RJ.Errors.BAD_CRC());else N(k)});break;default:if(O&&N)N(Buffer.alloc(0),RJ.Errors.UNKNOWN_METHOD());throw RJ.Errors.UNKNOWN_METHOD()}}function L(O,N){if((!Q||!Q.length)&&Buffer.isBuffer(J)){if(O&&N)N(z());return z()}if(Q.length&&!G){var D;switch(X.method){case RJ.Constants.STORED:if(X.compressedSize=X.size,D=Buffer.alloc(Q.length),Q.copy(D),O&&N)N(D);return D;default:case RJ.Constants.DEFLATED:var R=new qH$.Deflater(Q);if(!O){var _=R.deflate();return X.compressedSize=_.length,_}else R.deflateAsync(function(S){D=Buffer.alloc(S.length),X.compressedSize=S.length,S.copy(D),N&&N(D)});R=null;break}}else if(O&&N)N(Buffer.alloc(0));else return Buffer.alloc(0)}function M(O,N){return RJ.readBigUInt64LE(O,N)}function F(O){try{var N=0,D,R,_;while(N+4<O.length)if(D=O.readUInt16LE(N),N+=2,R=O.readUInt16LE(N),N+=2,_=O.slice(N,N+R),N+=R,H5.ID_ZIP64===D)A(_)}catch(S){throw RJ.Errors.EXTRA_FIELD_PARSE_ERROR()}}function A(O){var N,D,R,_;if(O.length>=H5.EF_ZIP64_SCOMP){if(N=M(O,H5.EF_ZIP64_SUNCOMP),X.size===H5.EF_ZIP64_OR_32)X.size=N}if(O.length>=H5.EF_ZIP64_RHO){if(D=M(O,H5.EF_ZIP64_SCOMP),X.compressedSize===H5.EF_ZIP64_OR_32)X.compressedSize=D}if(O.length>=H5.EF_ZIP64_DSN){if(R=M(O,H5.EF_ZIP64_RHO),X.offset===H5.EF_ZIP64_OR_32)X.offset=R}if(O.length>=H5.EF_ZIP64_DSN+4){if(_=O.readUInt32LE(H5.EF_ZIP64_DSN),X.diskNumStart===H5.EF_ZIP64_OR_16)X.diskNumStart=_}}return{get entryName(){return U.decode(W)},get rawEntryName(){return W},set entryName(O){W=RJ.toBuffer(O,U.encode);var N=W[W.length-1];G=N===47||N===92,X.fileNameLength=W.length},get efs(){if(typeof V==="function")return V(this.entryName);else return V},get extra(){return q},set extra(O){q=O,X.extraLength=O.length,F(O)},get comment(){return U.decode(Y)},set comment(O){if(Y=RJ.toBuffer(O,U.encode),X.commentLength=Y.length,Y.length>65535)throw RJ.Errors.COMMENT_TOO_LONG()},get name(){var O=U.decode(W);return G?O.substr(O.length-1).split("/").pop():O.split("/").pop()},get isDirectory(){return G},getCompressedData:function(){return L(!1,null)},getCompressedDataAsync:function(O){L(!0,O)},setData:function(O){if(Q=RJ.toBuffer(O,RJ.decoder.encode),!G&&Q.length)X.size=Q.length,X.method=RJ.Constants.DEFLATED,X.crc=RJ.crc32(O),X.changed=!0;else X.method=RJ.Constants.STORED},getData:function(O){if(X.changed)return Q;else return w(!1,null,O)},getDataAsync:function(O,N){if(X.changed)O(Q);else w(!0,O,N)},set attr(O){X.attr=O},get attr(){return X.attr},set header(O){X.loadFromBinary(O)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=q.length;var O=X.centralHeaderToBinary(),N=RJ.Constants.CENHDR;return W.copy(O,N),N+=W.length,q.copy(O,N),N+=X.extraLength,Y.copy(O,N),O},packLocalHeader:function(){let O=0;X.flags_efs=this.efs,X.extraLocalLength=H.length;let N=X.localHeaderToBinary(),D=Buffer.alloc(N.length+W.length+X.extraLocalLength);return N.copy(D,O),O+=N.length,W.copy(D,O),O+=W.length,H.copy(D,O),O+=H.length,D},toJSON:function(){let O=function(N){return"<"+(N&&N.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:O(J),data:O(Q)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Zg$=h((XG4,Tg$)=>{var bg$=HH$(),Rg0=QH$(),R7=mR();Tg$.exports=function($,J){var X=[],W={},Y=Buffer.alloc(0),G=new Rg0.MainHeader,Q=!1,q=null;let H=new Set,V=J,{noSort:j,decoder:U}=V;if($)w(V.readEntries);else Q=!0;function z(){let M=new Set;for(let F of Object.keys(W)){let A=F.split("/");if(A.pop(),!A.length)continue;for(let O=0;O<A.length;O++){let N=A.slice(0,O+1).join("/")+"/";M.add(N)}}for(let F of M)if(!(F in W)){let A=new bg$(V);A.entryName=F,A.attr=16,A.temporary=!0,X.push(A),W[A.entryName]=A,H.add(A)}}function K(){if(Q=!0,W={},G.diskEntries>($.length-G.offset)/R7.Constants.CENHDR)throw R7.Errors.DISK_ENTRY_TOO_LARGE();X=Array(G.diskEntries);var M=G.offset;for(var F=0;F<X.length;F++){var A=M,O=new bg$(V,$);if(O.header=$.slice(A,A+=R7.Constants.CENHDR),O.entryName=$.slice(A,A+=O.header.fileNameLength),O.header.extraLength)O.extra=$.slice(A,A+=O.header.extraLength);if(O.header.commentLength)O.comment=$.slice(A,A+O.header.commentLength);M+=O.header.centralHeaderSize,X[F]=O,W[O.entryName]=O}H.clear(),z()}function w(M){var F=$.length-R7.Constants.ENDHDR,A=Math.max(0,F-65535),O=A,N=$.length,D=-1,R=0;if(typeof V.trailingSpace==="boolean"?V.trailingSpace:!1)A=0;for(F;F>=O;F--){if($[F]!==80)continue;if($.readUInt32LE(F)===R7.Constants.ENDSIG){D=F,R=F,N=F+R7.Constants.ENDHDR,O=F-R7.Constants.END64HDR;continue}if($.readUInt32LE(F)===R7.Constants.END64SIG){O=A;continue}if($.readUInt32LE(F)===R7.Constants.ZIP64SIG){D=F,N=F+R7.readBigUInt64LE($,F+R7.Constants.ZIP64SIZE)+R7.Constants.ZIP64LEAD;break}}if(D==-1)throw R7.Errors.INVALID_FORMAT();if(G.loadFromBinary($.slice(D,N)),G.commentLength)Y=$.slice(R+R7.Constants.ENDHDR);if(M)K()}function L(){if(X.length>1&&!j)X.sort((M,F)=>M.entryName.toLowerCase().localeCompare(F.entryName.toLowerCase()))}return{get entries(){if(!Q)K();return X.filter((M)=>!H.has(M))},get comment(){return U.decode(Y)},set comment(M){Y=R7.toBuffer(M,U.encode),G.commentLength=Y.length},getEntryCount:function(){if(!Q)return G.diskEntries;return X.length},forEach:function(M){this.entries.forEach(M)},getEntry:function(M){if(!Q)K();return W[M]||null},setEntry:function(M){if(!Q)K();X.push(M),W[M.entryName]=M,G.totalEntries=X.length},deleteFile:function(M,F=!0){if(!Q)K();let A=W[M];this.getEntryChildren(A,F).map((N)=>N.entryName).forEach(this.deleteEntry)},deleteEntry:function(M){if(!Q)K();let F=W[M],A=X.indexOf(F);if(A>=0)X.splice(A,1),delete W[M],G.totalEntries=X.length},getEntryChildren:function(M,F=!0){if(!Q)K();if(typeof M==="object")if(M.isDirectory&&F){let A=[],O=M.entryName;for(let N of X)if(N.entryName.startsWith(O))A.push(N);return A}else return[M];return[]},getChildCount:function(M){if(M&&M.isDirectory){let F=this.getEntryChildren(M);return F.includes(M)?F.length-1:F.length}return 0},compressToBuffer:function(){if(!Q)K();L();let M=[],F=[],A=0,O=0;G.size=0,G.offset=0;let N=0;for(let _ of this.entries){let S=_.getCompressedData();_.header.offset=O;let k=_.packLocalHeader(),b=k.length+S.length;O+=b,M.push(k),M.push(S);let v=_.packCentralHeader();F.push(v),G.size+=v.length,A+=b+v.length,N++}A+=G.mainHeaderSize,G.offset=O,G.totalEntries=N,O=0;let D=Buffer.alloc(A);for(let _ of M)_.copy(D,O),O+=_.length;for(let _ of F)_.copy(D,O),O+=_.length;let R=G.toBinary();if(Y)Y.copy(R,R7.Constants.ENDHDR);return R.copy(D,O),$=D,Q=!1,D},toAsyncBuffer:function(M,F,A,O){try{if(!Q)K();L();let N=[],D=[],R=0,_=0,S=0;G.size=0,G.offset=0;let k=function(b){if(b.length>0){let v=b.shift(),f=v.entryName+v.extra.toString();if(A)A(f);v.getCompressedDataAsync(function(g){if(O)O(f);v.header.offset=_;let m=v.packLocalHeader(),p=m.length+g.length;_+=p,N.push(m),N.push(g);let l=v.packCentralHeader();D.push(l),G.size+=l.length,R+=p+l.length,S++,k(b)})}else{R+=G.mainHeaderSize,G.offset=_,G.totalEntries=S,_=0;let v=Buffer.alloc(R);N.forEach(function(g){g.copy(v,_),_+=g.length}),D.forEach(function(g){g.copy(v,_),_+=g.length});let f=G.toBinary();if(Y)Y.copy(f,R7.Constants.ENDHDR);f.copy(v,_),$=v,Q=!1,M(v)}};k(Array.from(this.entries))}catch(N){F(N)}}}}});var ji=h((WG4,xg$)=>{var P9=mR(),S9=K0("path"),_g0=HH$(),Eg0=Zg$(),MO=(...$)=>P9.findLast($,(J)=>typeof J==="boolean"),fg$=(...$)=>P9.findLast($,(J)=>typeof J==="string"),Sg0=(...$)=>P9.findLast($,(J)=>typeof J==="function"),Pg0={noSort:!1,readEntries:!1,method:P9.Constants.NONE,fs:null};xg$.exports=function($,J){let X=null,W=Object.assign(Object.create(null),Pg0);if($&&typeof $==="object"){if(!($ instanceof Uint8Array)){if(Object.assign(W,$),$=W.input?W.input:void 0,W.input)delete W.input}if(Buffer.isBuffer($))X=$,W.method=P9.Constants.BUFFER,$=void 0}Object.assign(W,J);let Y=new P9(W);if(typeof W.decoder!=="object"||typeof W.decoder.encode!=="function"||typeof W.decoder.decode!=="function")W.decoder=P9.decoder;if($&&typeof $==="string")if(Y.fs.existsSync($))W.method=P9.Constants.FILE,W.filename=$,X=Y.fs.readFileSync($);else throw P9.Errors.INVALID_FILENAME();let G=new Eg0(X,W),{canonical:Q,sanitize:q,zipnamefix:H}=P9;function V(K){if(K&&G){var w;if(typeof K==="string")w=G.getEntry(S9.posix.normalize(K));if(typeof K==="object"&&typeof K.entryName<"u"&&typeof K.header<"u")w=G.getEntry(K.entryName);if(w)return w}return null}function j(K){let{join:w,normalize:L,sep:M}=S9.posix;return w(S9.isAbsolute(K)?"/":".",L(M+K.split("\\").join(M)+M))}function U(K){if(K instanceof RegExp)return function(w){return function(L){return w.test(L)}}(K);else if(typeof K!=="function")return()=>!0;return K}let z=(K,w)=>{let L=w.slice(-1);return L=L===Y.sep?Y.sep:"",S9.relative(K,w)+L};return{readFile:function(K,w){var L=V(K);return L&&L.getData(w)||null},childCount:function(K){let w=V(K);if(w)return G.getChildCount(w)},readFileAsync:function(K,w){var L=V(K);if(L)L.getDataAsync(w);else w(null,"getEntry failed for:"+K)},readAsText:function(K,w){var L=V(K);if(L){var M=L.getData();if(M&&M.length)return M.toString(w||"utf8")}return""},readAsTextAsync:function(K,w,L){var M=V(K);if(M)M.getDataAsync(function(F,A){if(A){w(F,A);return}if(F&&F.length)w(F.toString(L||"utf8"));else w("")});else w("")},deleteFile:function(K,w=!0){var L=V(K);if(L)G.deleteFile(L.entryName,w)},deleteEntry:function(K){var w=V(K);if(w)G.deleteEntry(w.entryName)},addZipComment:function(K){G.comment=K},getZipComment:function(){return G.comment||""},addZipEntryComment:function(K,w){var L=V(K);if(L)L.comment=w},getZipEntryComment:function(K){var w=V(K);if(w)return w.comment||"";return""},updateFile:function(K,w){var L=V(K);if(L)L.setData(w)},addLocalFile:function(K,w,L,M){if(Y.fs.existsSync(K)){w=w?j(w):"";let F=S9.win32.basename(S9.win32.normalize(K));w+=L?L:F;let A=Y.fs.statSync(K),O=A.isFile()?Y.fs.readFileSync(K):Buffer.alloc(0);if(A.isDirectory())w+=Y.sep;this.addFile(w,O,M,A)}else throw P9.Errors.FILE_NOT_FOUND(K)},addLocalFileAsync:function(K,w){K=typeof K==="object"?K:{localPath:K};let L=S9.resolve(K.localPath),{comment:M}=K,{zipPath:F,zipName:A}=K,O=this;Y.fs.stat(L,function(N,D){if(N)return w(N,!1);F=F?j(F):"";let R=S9.win32.basename(S9.win32.normalize(L));if(F+=A?A:R,D.isFile())Y.fs.readFile(L,function(_,S){if(_)return w(_,!1);return O.addFile(F,S,M,D),setImmediate(w,void 0,!0)});else if(D.isDirectory())return F+=Y.sep,O.addFile(F,Buffer.alloc(0),M,D),setImmediate(w,void 0,!0)})},addLocalFolder:function(K,w,L){if(L=U(L),w=w?j(w):"",K=S9.normalize(K),Y.fs.existsSync(K)){let M=Y.findFiles(K),F=this;if(M.length)for(let A of M){let O=S9.join(w,z(K,A));if(L(O))F.addLocalFile(A,S9.dirname(O))}}else throw P9.Errors.FILE_NOT_FOUND(K)},addLocalFolderAsync:function(K,w,L,M){M=U(M),L=L?j(L):"",K=S9.normalize(K);var F=this;Y.fs.open(K,"r",function(A){if(A&&A.code==="ENOENT")w(void 0,P9.Errors.FILE_NOT_FOUND(K));else if(A)w(void 0,A);else{var O=Y.findFiles(K),N=-1,D=function(){if(N+=1,N<O.length){var R=O[N],_=z(K,R).split("\\").join("/");if(_=_.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),M(_))Y.fs.stat(R,function(S,k){if(S)w(void 0,S);if(k.isFile())Y.fs.readFile(R,function(b,v){if(b)w(void 0,b);else F.addFile(L+_,v,"",k),D()});else F.addFile(L+_+"/",Buffer.alloc(0),"",k),D()});else process.nextTick(()=>{D()})}else w(!0,void 0)};D()}})},addLocalFolderAsync2:function(K,w){let L=this;K=typeof K==="object"?K:{localPath:K},localPath=S9.resolve(j(K.localPath));let{zipPath:M,filter:F,namefix:A}=K;if(F instanceof RegExp)F=function(D){return function(R){return D.test(R)}}(F);else if(typeof F!=="function")F=function(){return!0};if(M=M?j(M):"",A=="latin1")A=(D)=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof A!=="function")A=(D)=>D;let O=(D)=>S9.join(M,A(z(localPath,D))),N=(D)=>S9.win32.basename(S9.win32.normalize(A(D)));Y.fs.open(localPath,"r",function(D){if(D&&D.code==="ENOENT")w(void 0,P9.Errors.FILE_NOT_FOUND(localPath));else if(D)w(void 0,D);else Y.findFilesAsync(localPath,function(R,_){if(R)return w(R);if(_=_.filter((S)=>F(O(S))),!_.length)w(void 0,!1);setImmediate(_.reverse().reduce(function(S,k){return function(b,v){if(b||v===!1)return setImmediate(S,b,!1);L.addLocalFileAsync({localPath:k,zipPath:S9.dirname(O(k)),zipName:N(k)},S)}},w))})})},addLocalFolderPromise:function(K,w){return new Promise((L,M)=>{this.addLocalFolderAsync2(Object.assign({localPath:K},w),(F,A)=>{if(F)M(F);if(A)L(this)})})},addFile:function(K,w,L,M){K=H(K);let F=V(K),A=F!=null;if(!A)F=new _g0(W),F.entryName=K;F.comment=L||"";let O=typeof M==="object"&&M instanceof Y.fs.Stats;if(O)F.header.time=M.mtime;var N=F.isDirectory?16:0;let D=F.isDirectory?16384:32768;if(O)D|=4095&M.mode;else if(typeof M==="number")D|=4095&M;else D|=F.isDirectory?493:420;if(N=(N|D<<16)>>>0,F.attr=N,F.setData(w),!A)G.setEntry(F);return F},getEntries:function(K){return G.password=K,G?G.entries:[]},getEntry:function(K){return V(K)},getEntryCount:function(){return G.getEntryCount()},forEach:function(K){return G.forEach(K)},extractEntryTo:function(K,w,L,M,F,A){M=MO(!1,M),F=MO(!1,F),L=MO(!0,L),A=fg$(F,A);var O=V(K);if(!O)throw P9.Errors.NO_ENTRY();var N=Q(O.entryName),D=q(w,A&&!O.isDirectory?A:L?N:S9.basename(N));if(O.isDirectory){var R=G.getEntryChildren(O);return R.forEach(function(k){if(k.isDirectory)return;var b=k.getData();if(!b)throw P9.Errors.CANT_EXTRACT_FILE();var v=Q(k.entryName),f=q(w,L?v:S9.basename(v));let g=F?k.header.fileAttr:void 0;Y.writeFileTo(f,b,M,g)}),!0}var _=O.getData(G.password);if(!_)throw P9.Errors.CANT_EXTRACT_FILE();if(Y.fs.existsSync(D)&&!M)throw P9.Errors.CANT_OVERRIDE();let S=F?K.header.fileAttr:void 0;return Y.writeFileTo(D,_,M,S),!0},test:function(K){if(!G)return!1;for(var w in G.entries)try{if(w.isDirectory)continue;var L=G.entries[w].getData(K);if(!L)return!1}catch(M){return!1}return!0},extractAllTo:function(K,w,L,M){if(L=MO(!1,L),M=fg$(L,M),w=MO(!1,w),!G)throw P9.Errors.NO_ZIP();G.entries.forEach(function(F){var A=q(K,Q(F.entryName));if(F.isDirectory){Y.makeDir(A);return}var O=F.getData(M);if(!O)throw P9.Errors.CANT_EXTRACT_FILE();let N=L?F.header.fileAttr:void 0;Y.writeFileTo(A,O,w,N);try{Y.fs.utimesSync(A,F.header.time,F.header.time)}catch(D){throw P9.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(K,w,L,M){if(M=Sg0(w,L,M),L=MO(!1,L),w=MO(!1,w),!M)return new Promise((D,R)=>{this.extractAllToAsync(K,w,L,function(_){if(_)R(_);else D(this)})});if(!G){M(P9.Errors.NO_ZIP());return}K=S9.resolve(K);let F=(D)=>q(K,S9.normalize(Q(D.entryName))),A=(D,R)=>Error(D+': "'+R+'"'),O=[],N=[];G.entries.forEach((D)=>{if(D.isDirectory)O.push(D);else N.push(D)});for(let D of O){let R=F(D),_=L?D.header.fileAttr:void 0;try{if(Y.makeDir(R),_)Y.fs.chmodSync(R,_);Y.fs.utimesSync(R,D.header.time,D.header.time)}catch(S){M(A("Unable to create folder",R))}}N.reverse().reduce(function(D,R){return function(_){if(_)D(_);else{let S=S9.normalize(Q(R.entryName)),k=q(K,S);R.getDataAsync(function(b,v){if(v)D(v);else if(!b)D(P9.Errors.CANT_EXTRACT_FILE());else{let f=L?R.header.fileAttr:void 0;Y.writeFileToAsync(k,b,w,f,function(g){if(!g)D(A("Unable to write file",k));Y.fs.utimes(k,R.header.time,R.header.time,function(m){if(m)D(A("Unable to set times",k));else D()})})}})}}},M)()},writeZip:function(K,w){if(arguments.length===1){if(typeof K==="function")w=K,K=""}if(!K&&W.filename)K=W.filename;if(!K)return;var L=G.compressToBuffer();if(L){var M=Y.writeFileTo(K,L,!0);if(typeof w==="function")w(!M?Error("failed"):null,"")}},writeZipPromise:function(K,w){let{overwrite:L,perm:M}=Object.assign({overwrite:!0},w);return new Promise((F,A)=>{if(!K&&W.filename)K=W.filename;if(!K)A("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((O)=>{let N=(D)=>D?F(D):A("ADM-ZIP: Wasn't able to write zip file");Y.writeFileToAsync(K,O,L,M,N)},A)})},toBufferPromise:function(){return new Promise((K,w)=>{G.toAsyncBuffer(K,w)})},toBuffer:function(K,w,L,M){if(typeof K==="function")return G.toAsyncBuffer(K,w,L,M),null;return G.compressToBuffer()}}}});class hg${DEFAULT_TTL_MS=60000;cache;timer;constructor($=new vR){this.timer=$,this.cache=new GK($,{ttlMs:this.DEFAULT_TTL_MS})}async isAccessibilityEnabled($,J,X){if(X?.isEnabled("force-accessibility-mode"))return B.debug(`[AccessibilityDetector] Force-enabled via feature flag for device ${$}`),!0;if(X&&!X.isEnabled("accessibility-auto-detect"))return B.debug(`[AccessibilityDetector] Auto-detection disabled via feature flag for device ${$}`),!1;let G=this.cache.get($);if(G)return B.debug(`[AccessibilityDetector] Using cached result for device ${$}: enabled=${G.enabled}, service=${G.service}`),G.enabled;B.debug(`[AccessibilityDetector] Detecting accessibility state for device ${$}`);let Q=this.timer.now(),{enabled:q,service:H}=await this.detectAccessibilityState($,J),V=this.timer.now()-Q;if(V>50)B.warn(`[AccessibilityDetector] Detection took ${V}ms (target: <50ms) for device ${$}`);else B.debug(`[AccessibilityDetector] Detection completed in ${V}ms for device ${$}`);return this.cache.set($,{enabled:q,service:H}),q}async detectMethod($,J,X){if(X?.isEnabled("force-accessibility-mode"))return"talkback";if(X&&!X.isEnabled("accessibility-auto-detect"))return"unknown";let G=this.cache.get($);if(G)return G.service;let{enabled:Q,service:q}=await this.detectAccessibilityState($,J);return this.cache.set($,{enabled:Q,service:q}),q}invalidateCache($){B.debug(`[AccessibilityDetector] Invalidating cache for device ${$}`),this.cache.delete($)}clearAllCache(){B.debug("[AccessibilityDetector] Clearing all cached entries"),this.cache.clear()}async detectAccessibilityState($,J){try{let W=(await J.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(W.includes("com.google.android.marvin.talkback")||W.includes("TalkBackService"))return B.debug(`[AccessibilityDetector] TalkBack detected as enabled on device ${$}`),{enabled:!0,service:"talkback"};if(W!=="null"&&W.length>0&&!W.includes("null"))return B.debug(`[AccessibilityDetector] Unknown accessibility service detected on device ${$}: ${W}`),{enabled:!0,service:"unknown"};return B.debug(`[AccessibilityDetector] No accessibility services enabled on device ${$}`),{enabled:!1,service:"unknown"}}catch(X){return B.error(`[AccessibilityDetector] Failed to detect accessibility state for device ${$}:`,X),{enabled:!1,service:"unknown"}}}}var _7;var UK=E(()=>{e();E$();$i();_7=new hg$});import{execFile as Cg0}from"child_process";import{createWriteStream as Ig0}from"fs";import*as gg$ from"fs/promises";import vg0 from"http";import kg0 from"https";import*as ug$ from"path";import{promisify as bg0}from"util";class mZ{async download($,J){try{await this.downloadWithCurl($,J);return}catch(X){if(!this.isCommandUnavailable(X,"curl"))throw X;B.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;B.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 yg$("curl",["--fail","--location","--retry","3","--retry-delay","1","--silent","--show-error","-o",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithWget($,J){await yg$("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 gg$.mkdir(ug$.dirname(J),{recursive:!0}),await new Promise((W,Y)=>{let Q=($.startsWith("https:")?kg0:vg0).get($,{headers:{"User-Agent":"auto-mobile"}},(q)=>{let H=q.statusCode??0;if(H>=300&&H<400&&q.headers.location){q.resume();let j=new URL(q.headers.location,$).toString();this.downloadWithNodeHttp(j,J,X+1).then(W).catch(Y);return}if(H<200||H>=300){q.resume(),Y(Error(`Download failed with status ${H} from ${$}`));return}let V=Ig0(J);q.pipe(V),V.on("finish",()=>V.close(()=>W())),V.on("error",(j)=>{V.close(),Y(j)})});Q.setTimeout(30000,()=>{Q.destroy(Error(`Download request timed out for ${$}`))}),Q.on("error",Y)})}isCommandUnavailable($,J){if(!$||typeof $!=="object")return!1;let X=$,W=typeof X.code==="number"?X.code:Number(X.code);if(X.code==="ENOENT"||!Number.isNaN(W)&&W===127)return!0;let Y=`${X.message??""} ${X.stderr??""}`.toLowerCase();if(Y.includes("command not found")||Y.includes("not recognized as an internal or external command")||Y.includes(`${J}: not found`)||Y.includes(`not found: ${J}`))return!0;return!1}}var yg$;var VH$=E(()=>{e();yg$=bg0(Cg0)});import{execFile as Tg0}from"child_process";import{createReadStream as Zg0}from"fs";import fg0 from"crypto";import{promisify as xg0}from"util";class lZ{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 W=fg0.createHash("sha256");return await new Promise((Y,G)=>{let Q=Zg0($);Q.on("data",(q)=>W.update(q)),Q.on("error",G),Q.on("end",()=>Y())}),{checksum:W.digest("hex"),source:"node"}}async tryChecksumCommand($,J){try{let{stdout:X}=await hg0(J,$,{timeout:120000,maxBuffer:10485760}),W=X.trim().split(/\s+/)[0]?.replace(/^\\/,"");if(!W)return B.warn("[ChecksumCalculator] checksum tool returned no output",{tool:J}),null;return W}catch(X){return B.info("[ChecksumCalculator] checksum tool unavailable, falling back",{tool:J,error:X instanceof Error?X.message:String(X)}),null}}}var hg0;var jH$=E(()=>{e();hg0=xg0(Tg0)});import*as F5 from"fs/promises";import*as P5 from"path";import yg0 from"crypto";import Ui from"os";var UH$,M0;var pY=E(()=>{O6();e();LO();UK();c0();E$();VH$();jH$();UH$=W5(ji(),1);M0=class M0{device;adb;static PACKAGE="dev.jasonpearson.automobile.ctrlproxy";static ACTIVITY="dev.jasonpearson.automobile.ctrlproxy.MainActivity";static LEGACY_PACKAGE="dev.jasonpearson.automobile.accessibilityservice";static APK_URL=gR;cachedAvailability=null;static AVAILABILITY_CACHE_TTL=3600000;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=z$;timer;fileDownloader;checksumCalculator;static defaultFileDownloader=new mZ;static defaultChecksumCalculator=new lZ;constructor($,J,X=c,W=M0.defaultFileDownloader,Y=M0.defaultChecksumCalculator){if(!(process.env.HOME||K0("os").homedir()))throw Error("Home directory for current user not found");this.device=$,this.adb=J,this.timer=X,this.fileDownloader=W,this.checksumCalculator=Y}static getInstance($,J=z$){if(VK($,"AndroidCtrlProxyManager.getInstance"),!M0.instances.has($.deviceId)){let X,W;if(J&&typeof J.create==="function")W=J,X=W.create($);else if(J){let Y=J;X=Y,W={create:()=>Y}}else W=z$,X=W.create($);M0.adbFactory=W,M0.instances.set($.deviceId,new M0($,X))}return M0.instances.get($.deviceId)}static resetInstances(){M0.instances.clear()}static prefetchApk(){if(M0.prefetchPromise!==null){B.info("[CTRL_PROXY] APK prefetch already initiated, skipping");return}let $=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH?.trim();if($&&$.length>0){B.info("[CTRL_PROXY] Using local APK override, skipping prefetch");return}B.info("[CTRL_PROXY] Starting APK prefetch");let J=c.now();M0.prefetchPromise=M0.doPrefetch().then((X)=>{let W=c.now()-J;if(X)M0.prefetchedApkPath=X,B.info(`[CTRL_PROXY] APK prefetch completed in ${W}ms`,{path:X});return X}).catch((X)=>{let W=c.now()-J;return M0.prefetchError=X instanceof Error?X:Error(String(X)),B.warn(`[CTRL_PROXY] APK prefetch failed after ${W}ms`,{error:M0.prefetchError.message}),null})}static async doPrefetch(){let $=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-prefetch-")),J=P5.join($,"control-proxy.apk");B.info("[CTRL_PROXY] Prefetch: downloading APK",{url:gR,destination:J}),await M0.defaultFileDownloader.download(gR,J);let X=await F5.stat(J);if(X.size<1e4)throw Error(`Prefetched APK is too small (${X.size} bytes), likely invalid`);M0.verifyApkIntegrityStatic(J);let W=M0.expectedChecksumOverride??Xg$;if(W.length>0){let{checksum:Y}=await M0.defaultChecksumCalculator.computeFileSha256(J);if(Y.toLowerCase()!==W.toLowerCase())throw await F5.rm($,{recursive:!0,force:!0}).catch(()=>{}),Error(`APK checksum verification failed. Expected: ${W}, Got: ${Y}`);B.info("[CTRL_PROXY] Prefetch: checksum verified",{checksum:Y})}return B.info("[CTRL_PROXY] Prefetch: APK ready",{path:J,size:X.size}),J}static async getPrefetchedApkPath(){if(M0.prefetchPromise===null)return null;try{return await M0.prefetchPromise,M0.prefetchedApkPath}catch{return null}}static async consumePrefetchedApk($){let J=await M0.getPrefetchedApkPath();if(!J)return!1;try{return await F5.mkdir(P5.dirname($),{recursive:!0}),await F5.copyFile(J,$),B.info("[CTRL_PROXY] Copied prefetched APK",{source:J,destination:$}),!0}catch(X){return B.warn("[CTRL_PROXY] Failed to copy prefetched APK",{error:X instanceof Error?X.message:String(X)}),!1}}static async cleanupPrefetchedApk(){if(M0.prefetchedApkPath){try{let $=P5.dirname(M0.prefetchedApkPath);await F5.rm($,{recursive:!0,force:!0}),B.info("[CTRL_PROXY] Cleaned up prefetched APK",{path:$})}catch($){B.warn("[CTRL_PROXY] Failed to clean up prefetched APK",{error:$ instanceof Error?$.message:String($)})}M0.prefetchedApkPath=null}M0.prefetchPromise=null,M0.prefetchError=null}static verifyApkIntegrityStatic($){try{if(!new UH$.default($).getEntries().some((Y)=>Y.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($){M0.expectedChecksumOverride=$}static setAccessibilityDetectorForTesting($){M0.accessibilityDetectorOverride=$}getAccessibilityDetector(){return M0.accessibilityDetectorOverride||_7}clearAvailabilityCache(){this.cachedAvailability=null,this.cachedInstallation=null,this.cachedEnabled=null,this.cachedToggleCapabilities=null,B.info("[CTRL_PROXY] Cleared all availability caches")}resetSetupState(){this.attemptedAutomatedSetup=!1,this.clearAvailabilityCache(),B.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($<M0.STATUS_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached installation status (age: ${$}ms): ${this.cachedInstallation.isInstalled?"installed":"not installed"}`),this.cachedInstallation.isInstalled;else this.cachedInstallation=null}try{B.debug("[CTRL_PROXY] Checking if accessibility service is installed");let J=(await this.adb.executeCommand(`shell pm list packages | grep ${M0.PACKAGE}`,void 0,void 0,!0)).stdout.includes(M0.PACKAGE);return this.cachedInstallation={isInstalled:J,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Service installation status: ${J?"installed":"not installed"} (cached for ${M0.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return B.warn(`[CTRL_PROXY] Error checking installation status: ${$}`),!1}}async isEnabled(){if(this.cachedEnabled&&this.cachedEnabled.isEnabled){let $=this.timer.now()-this.cachedEnabled.timestamp;if($<M0.STATUS_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached enabled status (age: ${$}ms): ${this.cachedEnabled.isEnabled?"enabled":"disabled"}`),this.cachedEnabled.isEnabled;else this.cachedEnabled=null}try{B.debug("[CTRL_PROXY] Checking if accessibility service is enabled");let J=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.includes(M0.PACKAGE);return this.cachedEnabled={isEnabled:J,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Service enabled status: ${J?"enabled":"disabled"} (cached for ${M0.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return B.warn(`[CTRL_PROXY] Error checking enabled status: ${$}`),!1}}async isEnabledForUser($){try{B.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(M0.PACKAGE);return B.debug(`[CTRL_PROXY] Service enabled status for user ${$}: ${X?"enabled":"disabled"}`),X}catch(J){return B.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<M0.AVAILABILITY_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached overall availability (age: ${J}ms): ${this.cachedAvailability.isAvailable}`),this.cachedAvailability.isAvailable;else this.cachedAvailability=null}B.debug("[CTRL_PROXY] Checking availability (no cached result available)");try{let[J,X]=await Promise.all([this.isInstalled(),this.isEnabled()]),W=J&&X,Y=this.timer.now()-$;return this.cachedAvailability={isAvailable:W,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Availability check completed in ${Y}ms - Available: ${W} (cached for ${M0.AVAILABILITY_CACHE_TTL/1000/60} minutes)`),W}catch(J){let X=this.timer.now()-$;return B.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 B.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 $=w0();this.clearAvailabilityCache(),$.startOperation("uninstallLegacy"),await this.uninstallLegacyPackageIfPresent(),$.endOperation("uninstallLegacy");let J=this.getExpectedChecksum();if(J.length===0)return{status:"skipped",expectedSha256:J};$.startOperation("checkInstalled");let X=await this.isInstalled();if($.endOperation("checkInstalled"),X&&this.shouldSkipDownloadIfInstalled())return B.warn("[CTRL_PROXY] Skipping APK download/version check (preinstalled APK allowed)"),{status:"skipped",expectedSha256:J};let W={status:"compatible",expectedSha256:J},Y=!1;if(X){$.startOperation("getChecksum");let Q=await this.getInstalledApkSha256WithDetails();$.endOperation("getChecksum"),W.installedSha256=Q.sha256,W.installedShaSource=Q.source,W.installedApkPath=Q.apkPath;let q=Q.sha256;if(Y=!q,!q&&Q.error)B.warn("[CTRL_PROXY] Unable to determine installed APK checksum, forcing reinstall",{error:Q.error});if(q&&q.toLowerCase()===J.toLowerCase())return W;if(Y)B.warn("[CTRL_PROXY] Installed APK checksum unavailable, forcing reinstall");else B.info("[CTRL_PROXY] Installed APK SHA mismatch, attempting upgrade",{expected:J,actual:q})}else B.info("[CTRL_PROXY] Service not installed, downloading and installing");let G=null;try{if(W.attemptedDownload=!0,$.startOperation("downloadApk"),G=await this.downloadApk(),$.endOperation("downloadApk"),X&&!Y)try{return W.attemptedInstall=!0,$.startOperation("installApk"),await this.adb.executeCommand(`install -r -d "${G}"`),$.endOperation("installApk"),B.info("[CTRL_PROXY] APK upgraded successfully"),this.clearAvailabilityCache(),{...W,status:"upgraded"}}catch(Q){$.endOperation("installApk");let q=Q instanceof Error?Q.message:String(Q);B.warn("[CTRL_PROXY] Upgrade failed, attempting reinstall",{error:q}),W.upgradeError=q}try{if(W.attemptedReinstall=!0,X)await this.adb.executeCommand(`shell pm uninstall ${M0.PACKAGE}`);return $.startOperation("installApk"),await this.install(G),$.endOperation("installApk"),await this.enable(),B.info(`[CTRL_PROXY] APK ${X?"reinstalled":"installed"} and service enabled`),this.clearAvailabilityCache(),{...W,status:X?"reinstalled":"installed"}}catch(Q){let q=Q instanceof Error?Q.message:String(Q);return{...W,status:"failed",reinstallError:q}}}catch(Q){let q=Q instanceof Error?Q.message:String(Q),H=this.isNetworkError(q);return{...W,status:"failed",downloadUnavailable:H,error:H?"Unable to download the latest accessibility service APK while offline. Connect to the internet and retry.":q}}finally{if(G)await this.cleanupApk(G)}}async downloadApk(){let $=w0(),J=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-")),X=P5.join(J,"control-proxy.apk");try{let W=this.getApkPathOverride();if($.startOperation("httpDownload"),W){if(B.info("Using local accessibility service APK",{path:W}),!(await F5.stat(W)).isFile())throw Error(`Accessibility APK override is not a file: ${W}`);await F5.copyFile(W,X)}else if(await M0.consumePrefetchedApk(X))B.info("Using prefetched accessibility service APK",{path:X});else B.info("Downloading APK",{url:M0.APK_URL,destination:X}),await this.fileDownloader.download(M0.APK_URL,X);$.endOperation("httpDownload");let Y=await F5.stat(X);if(Y.size<1e4)throw Error(`Downloaded APK is too small (${Y.size} bytes), likely invalid`);this.verifyApkIntegrity(X);let G=this.getExpectedChecksum();if(G.length>0){$.startOperation("checksumVerify");let{checksum:Q,source:q}=await this.checksumCalculator.computeFileSha256(X),H=Q.toLowerCase(),V=G.toLowerCase();if(H!==V)throw B.warn("APK checksum verification failed",{expected:V,actual:H}),Error(`APK checksum verification failed. Expected: ${V}, Got: ${H}`);B.info("APK checksum verified successfully",{checksum:H,source:q}),$.endOperation("checksumVerify")}else B.warn("APK checksum verification SKIPPED - no checksum provided (development mode)",{apkUrl:M0.APK_URL});return B.info("APK downloaded successfully",{path:X,size:Y.size}),X}catch(W){try{await this.cleanupApk(X)}catch{}throw Error(`Failed to download APK: ${W instanceof Error?W.message:String(W)}`)}}verifyApkIntegrity($){try{if(!new UH$.default($).getEntries().some((Y)=>Y.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 ${M0.LEGACY_PACKAGE}`,void 0,void 0,!0)).stdout.includes(M0.LEGACY_PACKAGE))return;B.info(`[CTRL_PROXY] Found legacy package ${M0.LEGACY_PACKAGE}, uninstalling`),await this.adb.executeCommand(`shell pm uninstall ${M0.LEGACY_PACKAGE}`),B.info("[CTRL_PROXY] Legacy package uninstalled")}catch($){B.warn(`[CTRL_PROXY] Failed to check/uninstall legacy package: ${$}`)}}async install($){try{B.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"))B.warn("Installation result unclear",{result:J.toString()});B.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 B.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{B.info("Enabling Accessibility Service via settings commands");let J=w0();J.startOperation("readCurrentServices");let X=await this.adb.executeCommand("shell settings get secure enabled_accessibility_services");J.endOperation("readCurrentServices");let W=X.stdout.trim();if(W==="null"||W==="")W="";let Y=`${M0.PACKAGE}/${M0.PACKAGE}.CtrlProxy`;if(J.startOperation("writeServiceEnabled"),W.includes(Y))B.info("Accessibility Service is already enabled");else{let G=W?`${W}:${Y}`:Y;await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${G}"`),B.info("Added AutoMobile service to enabled_accessibility_services")}await this.adb.executeCommand("shell settings put secure accessibility_enabled 1"),J.endOperation("writeServiceEnabled"),B.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),W=X.toLowerCase();if(W.includes("permission denied")||W.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(W.includes("device not found")||W.includes("no devices")||W.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(W.includes("timeout")||W.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 B.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{B.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===""){B.info("No accessibility services enabled");return}let W=X.split(":"),Y=W.filter((G)=>!G.includes(M0.PACKAGE));if(Y.length===W.length)B.info("Accessibility Service was not enabled");else{let G=Y.join(":");if(await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${G}"`),B.info("Removed AutoMobile service from enabled_accessibility_services"),Y.length===0||Y.length===1&&Y[0]==="")await this.adb.executeCommand("shell settings put secure accessibility_enabled 0"),B.info("Disabled accessibility globally (no other services remain)")}B.info("Accessibility Service disabled successfully via settings"),this.clearAvailabilityCache()}catch(J){let X=J instanceof Error?J.message:String(J),W=X.toLowerCase();if(W.includes("permission denied")||W.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(W.includes("device not found")||W.includes("no devices")||W.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(W.includes("timeout")||W.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 B.error("[CTRL_PROXY] "+X,{capabilities:J}),Error(X)}try{B.info(`[CTRL_PROXY] Enabling Accessibility Service via settings commands for user ${$}`);let W=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.trim();if(W==="null"||W==="")W="";let Y=`${M0.PACKAGE}/${M0.PACKAGE}.CtrlProxy`;if(W.includes(Y))B.info(`[CTRL_PROXY] Accessibility Service is already enabled for user ${$}`);else{let G=W?`${W}:${Y}`:Y;await this.adb.executeCommand(`shell settings --user ${$} put secure enabled_accessibility_services "${G}"`),B.info(`[CTRL_PROXY] Added AutoMobile service to enabled_accessibility_services for user ${$}`)}await this.adb.executeCommand(`shell settings --user ${$} put secure accessibility_enabled 1`),B.info(`[CTRL_PROXY] Accessibility Service enabled successfully via settings for user ${$}`),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(X){let W=X instanceof Error?X.message:String(X),Y=W.toLowerCase();if(Y.includes("permission denied")||Y.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: ${W}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service for user ${$}. Ensure the device is connected and adb is responsive. Original error: ${W}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service for user ${$}. The device may be unresponsive. Original error: ${W}`);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: ${W}`)}}async cleanupApk($){try{let J=P5.resolve(Ui.tmpdir()),X=P5.resolve(P5.dirname($)),W=P5.basename(X),Y=P5.relative(J,X),G=Boolean(Y)&&!Y.startsWith("..")&&!P5.isAbsolute(Y)&&W.startsWith("auto-mobile-");if(await F5.rm($,{force:!0}),G)await F5.rm(X,{recursive:!0,force:!0}),B.info("Temporary APK directory cleaned up",{path:X});else B.info("Temporary APK file cleaned up",{path:$})}catch(J){B.warn("Failed to clean up temporary APK file",{path:$,error:J instanceof Error?J.message:String(J)})}}async setup($=!1,J=new N$){J.serial("a11yServiceSetup");let X=null;if(this.attemptedAutomatedSetup){try{let[W,Y]=await J.track("recheckStatus",async()=>{return Promise.all([this.isInstalled(),this.isEnabled()])});if(W&&Y)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()}}catch(W){B.warn(`[CTRL_PROXY] Failed to re-check service status: ${W}`)}return J.end(),{success:!1,message:"Setup already attempted",perfTiming:J.getTimings()}}try{let W=await J.track("ensureCompatibleVersion",()=>this.ensureCompatibleVersion());if(W.status==="failed")return J.end(),{success:!1,message:"Failed to ensure compatible Accessibility Service version",error:W.error||W.upgradeError||W.reinstallError,perfTiming:J.getTimings()};if(W.status==="upgraded"||W.status==="installed"||W.status==="reinstalled")return J.end(),{success:!0,message:"Accessibility Service upgraded to a compatible version",perfTiming:J.getTimings()};let Y=await J.track("checkInstalled",()=>this.isInstalled()),G=await J.track("checkEnabled",()=>this.isEnabled());if(!$&&Y&&G)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()};if(this.attemptedAutomatedSetup=!0,$||!Y)X=await J.track("downloadApk",()=>this.downloadApk()),await J.track("installApk",()=>this.install(X));if(!G)await J.track("enableService",()=>this.enable());return J.end(),{success:!0,message:"Accessibility Service installed and activated successfully",perfTiming:J.getTimings()}}catch(W){let Y=W instanceof Error?W.message:String(W),G=Y.toLowerCase(),Q="Failed to setup Accessibility Service";if(G.includes("permission denied")||G.includes("not permitted"))Q="Failed to setup Accessibility Service due to permission error";else if(G.includes("device not found")||G.includes("no devices")||G.includes("offline"))Q="Failed to setup Accessibility Service due to device connection issue";else if(G.includes("timeout")||G.includes("timed out"))Q="Failed to setup Accessibility Service due to timeout";else if(G.includes("download")||G.includes("network")||G.includes("unreachable"))Q="Failed to setup Accessibility Service due to network/download error";else if(G.includes("not supported"))Q="Failed to setup Accessibility Service - settings toggle not supported on this device";else if(G.includes("installation failed")||G.includes("install"))Q="Failed to setup Accessibility Service due to APK installation error";return J.end(),{success:!1,message:Q,error:Y,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 W=(await this.adb.executeCommand("shell getprop ro.product.model",void 0,void 0,!0)).stdout.trim().toLowerCase();return[W.includes("emulator")||W.includes("sdk"),!1]}catch($){return B.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 B.warn("[CTRL_PROXY] Error getting API level",{error:$}),[null,!0]}}async canUseSettingsToggle(){return(await this.getToggleCapabilities()).supportsSettingsToggle}async getToggleCapabilities(){if(this.cachedToggleCapabilities)return B.info("[CTRL_PROXY] Using cached toggle capabilities"),this.cachedToggleCapabilities;B.info("[CTRL_PROXY] Detecting toggle capabilities");let[$,J]=await this.isEmulator(),[X,W]=await this.getApiLevel(),Y=$?"emulator":"physical",G=!1,Q,q=J||W;if(q)G=!1,Q="Unable to detect device capabilities due to transient error. Retry may succeed.",B.warn("[CTRL_PROXY] Detection error - not caching result",{emulatorDetectionError:J,apiLevelDetectionError:W});else if($)G=!0,B.info("[CTRL_PROXY] Emulator detected - settings toggle supported");else G=!1,Q="Physical devices may require root, device owner status, or special shell permissions for programmatic accessibility toggle",B.info("[CTRL_PROXY] Physical device detected - settings toggle may not be supported",{reason:Q});if(!q&&X!==null&&X<16)G=!1,Q=`API level ${X} is too old (requires API 16+)`,B.warn("[CTRL_PROXY] API level too old for settings toggle",{apiLevel:X});let H={supportsSettingsToggle:G,deviceType:Y,apiLevel:X,reason:Q};if(!q)this.cachedToggleCapabilities=H,B.info("[CTRL_PROXY] Toggle capabilities detected and cached",H);else B.info("[CTRL_PROXY] Toggle capabilities detected but not cached due to detection errors",H);return H}async getInstalledApkSha256WithDetails(){let $=await this.getInstalledApkPath();if(!$)return{sha256:null,source:"none",error:"Installed APK path not found"};try{let G=(await this.adb.executeCommand(`shell sha256sum "${$}"`)).stdout.trim().split(/\s+/)[0];if(G)return{sha256:G,source:"device",apkPath:$}}catch(Y){B.warn("[CTRL_PROXY] sha256sum unavailable or failed, falling back to host hash",{error:Y instanceof Error?Y.message:String(Y)})}let J=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-apk-")),X=(this.device.deviceId||"device").replace(/[^a-zA-Z0-9_.-]/g,"_"),W=P5.join(J,`control-proxy-installed-${X}.apk`);try{await this.adb.executeCommand(`pull "${$}" "${W}"`);let Y=await F5.readFile(W);return{sha256:yg0.createHash("sha256").update(Y).digest("hex"),source:"host",apkPath:$}}catch(Y){return{sha256:null,source:"none",apkPath:$,error:Y instanceof Error?Y.message:String(Y)}}finally{try{await F5.rm(J,{recursive:!0,force:!0})}catch{}}}async getInstalledApkPath(){try{let J=(await this.adb.executeCommand(`shell pm path ${M0.PACKAGE}`,void 0,void 0,!0)).stdout.split(`
96
+ Suggestion: ${M.suggestion}`;q=new u(F)}else{let F=this.detectArchitecturePanic(L);if(F.isPanic)q=new u(`Emulator failed to start: ${F.message}`);else q=new u(`Emulator process exited with code ${w} while waiting for readiness`)}B.error(`Emulator process exited during readiness wait: ${q.message}`)}})}let H=!0,V=null;Y.startOperation("devicePolling");let U=(async()=>{while(H&&!V){try{B.debug(`Background polling iteration - checking for emulator '${$}'...`),B.debug("Checking for running local emulators...");let z=await this.getBootedDevices();if(B.debug(`Device scan complete - found ${z.length} running emulators`),z.length>0){B.debug(`Found ${z.length} running emulators: ${z.map((w)=>`${w.name}(${w.deviceId})`).join(", ")}`);let K=z.find((w)=>w.name===$);if(B.debug(`Exact name match for '${$}': ${K?`Found ${K.deviceId}`:"Not found"}`),!K)if(K=z.find((w)=>w.source==="local"),K)B.debug(`Found local emulator with deviceId ${K.deviceId}, but name mismatch. Expected: ${$}, Found: ${K.name}`);else B.debug("No local emulators found to use as fallback");if(K&&K.deviceId){B.debug(`Target emulator found: ${K.name} (${K.deviceId}) - starting readiness checks`),B.debug(`[PARALLEL] Running device state and package manager checks for ${K.deviceId}...`);let w=this.adbFactory.create(K);try{Y.startOperation("adbParallelChecks");let[L,M]=await Promise.allSettled([w.executeCommand("get-state"),w.executeCommand("shell pm list packages")]);if(Y.endOperation("adbParallelChecks"),L.status!=="fulfilled"||M.status!=="fulfilled")B.debug(`[PARALLEL] Checks not yet complete: deviceStatus: ${L.status}, packageManager: ${M.status}`);else{let F=L.value.stdout.trim();if(B.debug(`[PARALLEL] Package manager command completed for ${K.deviceId} - output: ${M.value.stdout.length} bytes`),!F.includes("device"))B.debug(`[PARALLEL] \u274C Device state check failed for ${K.deviceId}: state="${F}"`);else if(!M.value.stdout||!M.value.stdout.includes("package:"))B.debug(`[PARALLEL] \u274C Package manager returned no packages for ${K.deviceId} (${M.value.stdout.length} bytes output)`);else if(M.value.stderr||M.value.stderr.includes("Failure"))B.debug(`[PARALLEL] \u274C Package manager returned failure for ${K.deviceId}: ${M.value.stderr}`);else{B.debug(`[PARALLEL] \u2705 Device state check passed for ${K.deviceId}`),B.debug(`[PARALLEL] \u2705 Package manager is responsive for ${K.deviceId} - emulator is ready!`),B.debug("[PARALLEL] \u2705 No package manager errors detected - marking emulator as ready"),V=K.deviceId;return}}}catch(L){B.debug(`[PARALLEL] \u274C Parallel checks failed for ${K.deviceId}: ${L}`)}}else B.debug(`No suitable emulator found for '${$}' - will continue polling`)}else B.debug("No running emulators detected - will continue polling")}catch(z){B.debug(`Background polling error (will continue): ${z}`)}B.debug(`Background polling cycle complete - sleeping ${G}ms before next check`),await this.sleep(G)}B.debug(`Background polling stopped - pollingActive: ${H}, foundDeviceId: ${V}`)})();while(this.timer.now()-W<J){if(Q&&q)throw H=!1,await U,Y.endOperation("devicePolling"),q;if(V){H=!1,Y.endOperation("devicePolling"),B.info(`Emulator '${$}' is ready! Device ID: ${V}`);let z={name:$,platform:"android",deviceId:V};return Y.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(z),Y.endOperation("wakeAndUnlock"),z}await this.sleep(500)}if(H=!1,await U,Y.endOperation("devicePolling"),V){B.info(`Emulator '${$}' is ready! Device ID: ${V}`);let z={name:$,platform:"android",deviceId:V};return Y.startOperation("wakeAndUnlock"),await this.wakeAndUnlock(z),Y.endOperation("wakeAndUnlock"),z}throw new u(`Emulator '${$}' failed to become ready within ${J}ms`)}async wakeAndUnlock($){let J=this.adbFactory.create($);try{let X=await J.getWakefulness();if(B.info(`[WakeAndUnlock] Device wakefulness state: ${X}`),X!=="Awake")B.info("[WakeAndUnlock] Device not awake, sending KEYCODE_WAKEUP"),await J.executeCommand("shell input keyevent KEYCODE_WAKEUP"),await this.sleep(500);B.info("[WakeAndUnlock] Dismissing keyguard"),await J.executeCommand("shell wm dismiss-keyguard");let W=await J.getWakefulness();B.info(`[WakeAndUnlock] Final wakefulness state: ${W}`)}catch(X){B.warn(`[WakeAndUnlock] Failed to wake/unlock device: ${X}`)}}sleep($){return this.timer.sleep($)}}var oy0=async($)=>{let J=await ny0(cy0)($);return{stdout:J.stdout,stderr:J.stderr,toString(){return this.stdout},trim(){return this.stdout.trim()},includes(W){return this.stdout.includes(W)}}};var hR=E(()=>{e();C6();O6();TR();E$();c0();ry$()});class WW{adb;emulator;simctl;constructor($=null,J=null,X=null){this.adb=$||z$.create(null),this.simctl=J||new V1,this.emulator=X||new yG}async listDeviceImages($){switch($){case"android":return this.emulator.listAvds();case"ios":return this.simctl.listSimulatorImages();case"either":let J=await this.emulator.listAvds(),X=await this.simctl.listSimulatorImages();return[...J,...X]}}async isDeviceImageRunning($){switch($.platform){case"android":return this.emulator.isAvdRunning($.name);case"ios":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.simctl.getBootedSimulators();case"either":let J=await this.emulator.getBootedDevices(),X=await this.simctl.getBootedSimulators();return[...J,...X]}}async startDevice($){if(await this.isDeviceImageRunning($))throw new u(`${$.platform} device '${$.name}' is already running`);switch($.platform){case"android":return this.emulator.startEmulator($.name);case"ios":return this.simctl.startSimulator($.deviceId??$.name);default:throw new u("Unknown platform")}}async killDevice($){switch($.platform){case"android":return this.emulator.killDevice($);case"ios":return this.simctl.killSimulator($)}}async waitForDeviceReady($,J=120000,X){switch($.platform){case"android":return this.emulator.waitForEmulatorReady($.name,J,X);case"ios":return this.simctl.waitForSimulatorReady($.deviceId??$.name,J);default:throw new u("Unknown platform")}}}var KO=E(()=>{C6();O6();h5();hR()});import WH$ from"crypto";class $7{generateCacheKey($){return WH$.createHash("md5").update($).digest("hex")}verifyChecksum($,J){return WH$.createHash("sha256").update($).digest("hex").toLowerCase()===J.toLowerCase()}static generateCacheKey=($)=>new $7().generateCacheKey($);static verifyChecksum=($,J)=>new $7().verifyChecksum($,J)}var qK=()=>{};import ry0 from"fs";import ay0 from"os";import ay$ from"path";function hQ($){return ay$.join(ty0,$)}function ty$($){let J=hQ($);return ry0.mkdirSync(J,{recursive:!0,mode:sy0}),J}var ty0,sy0=448,gG;var wO=E(()=>{ty0=ay$.join(ay0.tmpdir(),"auto-mobile");gG={LOGS:"logs",TOOL_LOGS:"tool_logs",SCREENSHOTS:"screenshots",NAVIGATION_SCREENSHOTS:"navigation-screenshots",VIEW_HIERARCHY:"view_hierarchy",OBSERVE_RESULTS:"observe_results",WINDOW:"window",CACHE:"cache"}});import*as HK from"fs/promises";import*as $g$ from"path";class yQ{adb;cachedActiveWindow=null;device;cacheDir=hQ(gG.WINDOW);constructor($,J=z$){if(J&&typeof J.create==="function")this.adb=J.create($);else if(J)this.adb=J;else this.adb=z$.create($);this.device=$}getCacheFilePath(){let $=$7.generateCacheKey(this.device.deviceId);return $g$.join(this.cacheDir,$)}getDeviceId(){return this.device.deviceId}async writeCacheToDisk($){let J=this.getCacheFilePath();if(!J){B.info("[WINDOW] No device ID, skipping disk cache write");return}try{await HK.mkdir(this.cacheDir,{recursive:!0}),await HK.writeFile(J,JSON.stringify($),"utf-8"),B.debug(`Wrote active window cache to disk: ${J}`)}catch(X){B.error(`Failed to write cache to disk: ${X}`)}}async readCacheFromDisk(){let $=this.getCacheFilePath();if(!$)return B.info("[WINDOW] No device ID, skipping disk cache read"),null;try{let J=await HK.readFile($,"utf-8"),X=JSON.parse(J);return B.debug(`Read active window cache from disk: ${$}`),X}catch(J){return B.debug(`No disk cache found or error reading: ${J}`),null}}async setCachedActiveWindow($){this.cachedActiveWindow=$,await this.writeCacheToDisk($),B.info("[WINDOW] Cached active window from external source")}async clearCache(){this.cachedActiveWindow=null;let $=this.getCacheFilePath();if($)try{await HK.unlink($),B.info("[WINDOW] Cleared cached active window from disk")}catch(J){B.debug(`Could not remove disk cache: ${J}`)}B.info("[WINDOW] Cleared cached active window")}async getCachedActiveWindow(){if(!this.cachedActiveWindow){B.info("[WINDOW] Using disk cached active window");let $=await this.readCacheFromDisk();if($)return this.cachedActiveWindow=$,B.info("[WINDOW] Using disk cached active window"),$}return this.cachedActiveWindow}async getActive($=!1,J=new N$){if(!$&&this.cachedActiveWindow)return B.info("[WINDOW] Using memory cached active window"),this.cachedActiveWindow;if(!$&&!this.cachedActiveWindow){B.info("[WINDOW] Using disk cached active window");let X=await J.track("readDiskCache",()=>this.readCacheFromDisk());if(X)return this.cachedActiveWindow=X,B.info("[WINDOW] Using disk cached active window"),X}try{let{stdout:X}=await J.track("adbDumpsysWindowWindows",()=>this.adb.executeCommand('shell "dumpsys window windows"')),W=null;if(typeof this.adb.getAndroidApiLevel==="function")W=await this.adb.getAndroidApiLevel();let Y=null;if(W!==null&&W!==void 0&&W<=27){if(Y=ey$(X),!Y)Y=ey0(X);if(!Y)Y=await this.parseActiveWindowFromDumpsysWindow();if(!Y)Y=sy$(X)}else Y=sy$(X);let G=Y?.appId??"",Q=Y?.activityName??"",q=0,H=X.matchAll(/mLayoutSeq=([\d\.]+)/g);if(H)for(let j of H){let U=parseInt(j[1],10);if(!isNaN(U))q+=U}let V={appId:G,activityName:Q,layoutSeqSum:q};if(this.cachedActiveWindow=V,await this.writeCacheToDisk(V),B.info("[WINDOW] Cached new active window information"),!G||!Q){let j=X.trim().slice(0,200);B.warn(`[WINDOW] Failed to parse active window from dumpsys output. Sample: ${j||"<empty>"}`)}return V}catch(X){return B.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 ey$($)}catch($){return B.error(`Failed to get dumpsys window for legacy fallback: ${$}`),null}}async getActiveHash($=new N$){B.info("[WINDOW] Getting hash of active window");let J=await this.getActive(!0,$),X=JSON.stringify(J);return $7.generateCacheKey(X)}}function sy$($){let J="",X="",W=$.match(/imeControlTarget.*?Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}/);if(W&&W.length>=3)J=W[1],X=W[2];else{let Y=$.match(/imeControlTarget.*?Window\{([0-9a-f]+)\s+u\d+\s+Pop-Up Window\}/i);if(Y){let G=Y[1],Q=new RegExp(`Window #\\d+ Window\\{${G} u\\d+ Pop-Up Window\\}:([\\s\\S]*?)(?=Window #\\d+|$)`),q=$.match(Q);if(q){let H=q[1].match(/mActivityRecord=ActivityRecord\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)(?:\s+t\d+)?\}/);if(H&&H.length>=3)J=H[1],X=H[2]}}if(!J||!X){let G=$.matchAll(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?mViewVisibility=0x0[\s\S]*?isOnScreen=true[\s\S]*?isVisible=true/gs);for(let Q of G)if(Q[1]&&Q[2]&&!Q[1].includes("android.systemui")&&!Q[1].includes("nexuslauncher")){J=Q[1],X=Q[2];break}if(!J||!X){let Q=$.match(/Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:[\s\S]*?ty=BASE_APPLICATION/);if(Q&&Q.length>=3)J=Q[1],X=Q[2]}}if(!J||!X){let Q=/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(Q&&Q.length>=3)J=Q[1],X=Q[2]}}if(J&&X)return{appId:J,activityName:X};return null}function ey0($){let J=/Window #\d+ Window\{[^}]*?\s+u\d+\s+([^\s/]+)\/([^\s}]+)\}:([\s\S]*?)(?=Window #\d+|$)/g,X=[...$.matchAll(J)];for(let W of X){let Y=W[1],G=W[2],Q=W[3];if(!Y||!G)continue;if(Y.includes("android.systemui")||Y.includes("nexuslauncher"))continue;if(/\bty=1\b/.test(Q)&&/isReadyForDisplay\(\)=true/.test(Q))return{appId:Y,activityName:G}}return null}function ey$($){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 yR=E(()=>{O6();e();qK();c0();wO()});function VK($,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 ${$g0($)}`)}function $g0($){if(typeof $==="string")return`string "${$}"`;try{return JSON.stringify($)??String($)}catch{return Object.prototype.toString.call($)}}function EV($,J,X=YH$){if(X.length===0)return"";let Y=$.trim().toLowerCase()==="latest"?X[0]:X.find((G)=>G.version===$);if(!Y)return"";return J==="android"?Y.apkSha256:Y.ipaSha256}function Jg0(){if(YH$.length===0)return"latest";return YH$[0].version}function gZ($){if($==="latest")return Jg0();return $}function Jg$($,J){let X=gZ(J);if(X==="latest")return`https://github.com/kaeawc/auto-mobile/releases/latest/download/${$}`;return`https://github.com/kaeawc/auto-mobile/releases/download/${X}/${$}`}var Yi="latest",YH$,YW="latest",gR,Xg$,Jz,Gi,Wg$,Qi="",Yg$="";var LO=E(()=>{YH$=[{version:"0.0.34",apkSha256:"4dcee4f6a7359847d081c5e184c57ed100ad135af2e62f3abfc7b0defaa1153c",ipaSha256:"c2a26ca065c85e9f8d5cfcd6dbad1dbaf3ce38b18d770b0983f7bad62129e4a3"},{version:"0.0.33",apkSha256:"7289eba90b22890d3c36e05e99db72a545fa4becdf46df079885783a919e6aed",ipaSha256:"425dfa4db4ad5a4febc9f05ffc97df38f3a1098ccdd9330adff1c0b5c877697d"},{version:"0.0.32",apkSha256:"4c4a743af5d18ed58214e64b85986c9e2f2332b015edcf7d9d68a24cd6dfda21",ipaSha256:"40f4d9084d3368995b57c0e81c4fe85f38851353da9f789eaff93027aee456a0"},{version:"0.0.31",apkSha256:"0b5802ada8d9adccdb69ee140ae788b3251832c0605d2f6baa3e9b7a78260764",ipaSha256:"e60f8689fb6ddd5c06a5d2ff57569b264f407229afb986258d1ce20326dc24c7"},{version:"0.0.30",apkSha256:"a1be5e6240f204ee99540e99cc198f7c0b592dbaf3699330c14f6ded7d333ec3",ipaSha256:"5ac285dd5be16439d3a8a8973c98606920461acfce489830e54ee20759a7b235"},{version:"0.0.29",apkSha256:"b33a67c7efa84aca2b07faa965aecb3b1819b4defd441dcc8d3bf7e2af209cd8",ipaSha256:"d47c1aea4495270c1489cae361286ea1439c2ba4e7d5bcfd73f66e4580a6c45d"},{version:"0.0.28",apkSha256:"0f683d5939bc308afe038ea1259eb29997dff38af0795136a281ad305986e40e",ipaSha256:"eee7accfbca717bb8b89fafd0676f10d8bb08561c3fbd7a04750c9b12c2a7104"},{version:"0.0.27",apkSha256:"9966113ae44f38f3cf34544b1375d3c9a3706701edba45a1eec1f220b9c676cc",ipaSha256:"8620de6b014df18465876334f9ba8c106292f6c3059370eea2349f1e44db4f4d"},{version:"0.0.26",apkSha256:"2eb2f156fd27602c85003ab8f6e00d3e06850e84f5453d75b7494aa5bbed7be0",ipaSha256:"905df276d2224d31cbc5aa2258d2dcc60eaeb9813727081ddd32c95394fec411"},{version:"0.0.25",apkSha256:"f727079edb4906e3b7928dbb641e788543e86b11fff3fc1b76f0c51b9c8d6e5d",ipaSha256:"d8032cc1cebcb456b7232aa67fc42c89ff62729bacf141aa8f594ce6f8bcd980"},{version:"0.0.24",apkSha256:"9047795bc6098f4ec687c126123c73c423806a9fd52888af391d6fb5b94ac93f",ipaSha256:"1dd3e0370cb8ed01d8e1020558d8a2808f208bd947bafcf6688211eddc928bf8"},{version:"0.0.18",apkSha256:"fd3c8d9f0b8542eaad56c78b18cf8e5666367b04ae8c4af74d8aa6dd1c8d1834",ipaSha256:"2a5eec63bce2f9dfc227c0732fcce67378305e945604d5eedd0e3df48e37fd39"},{version:"0.0.17",apkSha256:"916033440931666644474f227c8e39d13d9c80c3515e4292cc5581fd5bd4cc2f",ipaSha256:"e4dcf064d024f2371b8fd79281000e2d49751ef95b8817d1494d685aeda746ac"}];gR=Jg$("control-proxy-debug.apk",YW),Xg$=EV(YW,"android"),Jz=YW,Gi=Jg$("control-proxy.ipa",Jz),Wg$=EV(Jz,"ios")});var GH$=h((lY4,Gg$)=>{Gg$.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 qi=h((qg$)=>{var Qg$={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 Xg0($){return function(...J){if(J.length)$=$.replace(/\{(\d)\}/g,(X,W)=>J[W]||"");return Error("ADM-ZIP: "+$)}}for(let $ of Object.keys(Qg$))qg$[$]=Xg0(Qg$[$])});var zg$=h((pY4,Ug$)=>{var Wg0=K0("fs"),y5=K0("path"),Hg$=GH$(),Yg0=qi(),Gg0=typeof process==="object"&&process.platform==="win32",Vg$=($)=>typeof $==="object"&&$!==null,jg$=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 q5($){if(this.sep=y5.sep,this.fs=Wg0,Vg$($)){if(Vg$($.fs)&&typeof $.fs.statSync==="function")this.fs=$.fs}}Ug$.exports=q5;q5.prototype.makeDir=function($){let J=this;function X(W){let Y=W.split(J.sep)[0];W.split(J.sep).forEach(function(G){if(!G||G.substr(-1,1)===":")return;Y+=J.sep+G;var Q;try{Q=J.fs.statSync(Y)}catch(q){if(q.message&&q.message.startsWith("ENOENT"))J.fs.mkdirSync(Y);else throw q}if(Q&&Q.isFile())throw Yg0.FILE_IN_THE_WAY(`"${Y}"`)})}X($)};q5.prototype.writeFileTo=function($,J,X,W){let Y=this;if(Y.fs.existsSync($)){if(!X)return!1;var G=Y.fs.statSync($);if(G.isDirectory())return!1}var Q=y5.dirname($);if(!Y.fs.existsSync(Q))Y.makeDir(Q);var q;try{q=Y.fs.openSync($,"w",438)}catch(H){Y.fs.chmodSync($,438),q=Y.fs.openSync($,"w",438)}if(q)try{Y.fs.writeSync(q,J,0,J.length,0)}finally{Y.fs.closeSync(q)}return Y.fs.chmodSync($,W||438),!0};q5.prototype.writeFileToAsync=function($,J,X,W,Y){if(typeof W==="function")Y=W,W=void 0;let G=this;G.fs.exists($,function(Q){if(Q&&!X)return Y(!1);G.fs.stat($,function(q,H){if(Q&&H.isDirectory())return Y(!1);var V=y5.dirname($);G.fs.exists(V,function(j){if(!j)G.makeDir(V);G.fs.open($,"w",438,function(U,z){if(U)G.fs.chmod($,438,function(){G.fs.open($,"w",438,function(K,w){G.fs.write(w,J,0,J.length,0,function(){G.fs.close(w,function(){G.fs.chmod($,W||438,function(){Y(!0)})})})})});else if(z)G.fs.write(z,J,0,J.length,0,function(){G.fs.close(z,function(){G.fs.chmod($,W||438,function(){Y(!0)})})});else G.fs.chmod($,W||438,function(){Y(!0)})})})})})};q5.prototype.findFiles=function($){let J=this;function X(W,Y,G){if(typeof Y==="boolean")G=Y,Y=void 0;let Q=[];return J.fs.readdirSync(W).forEach(function(q){let H=y5.join(W,q),V=J.fs.statSync(H);if(!Y||Y.test(H))Q.push(y5.normalize(H)+(V.isDirectory()?J.sep:""));if(V.isDirectory()&&G)Q=Q.concat(X(H,Y,G))}),Q}return X($,void 0,!0)};q5.prototype.findFilesAsync=function($,J){let X=this,W=[];X.fs.readdir($,function(Y,G){if(Y)return J(Y);let Q=G.length;if(!Q)return J(null,W);G.forEach(function(q){q=y5.join($,q),X.fs.stat(q,function(H,V){if(H)return J(H);if(V){if(W.push(y5.normalize(q)+(V.isDirectory()?X.sep:"")),V.isDirectory())X.findFilesAsync(q,function(j,U){if(j)return J(j);if(W=W.concat(U),!--Q)J(null,W)});else if(!--Q)J(null,W)}})})})};q5.prototype.getAttributes=function(){};q5.prototype.setAttributes=function(){};q5.crc32update=function($,J){return jg$[($^J)&255]^$>>>8};q5.crc32=function($){if(typeof $==="string")$=Buffer.from($,"utf8");let J=$.length,X=-1;for(let W=0;W<J;)X=q5.crc32update(X,$[W++]);return~X>>>0};q5.methodToString=function($){switch($){case Hg$.STORED:return"STORED ("+$+")";case Hg$.DEFLATED:return"DEFLATED ("+$+")";default:return"UNSUPPORTED ("+$+")"}};q5.canonical=function($){if(!$)return"";let J=y5.posix.normalize("/"+$.split("\\").join("/"));return y5.join(".",J)};q5.zipnamefix=function($){if(!$)return"";let J=y5.posix.normalize("/"+$.split("\\").join("/"));return y5.posix.join(".",J)};q5.findLast=function($,J){if(!Array.isArray($))throw TypeError("arr is not array");let X=$.length>>>0;for(let W=X-1;W>=0;W--)if(J($[W],W,$))return $[W];return};q5.sanitize=function($,J){$=y5.resolve(y5.normalize($));var X=J.split("/");for(var W=0,Y=X.length;W<Y;W++){var G=y5.normalize(y5.join($,X.slice(W,Y).join(y5.sep)));if(G.indexOf($)===0)return G}return y5.normalize(y5.join($,y5.basename(J)))};q5.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)};q5.readBigUInt64LE=function($,J){let X=$.readUInt32LE(J);return $.readUInt32LE(J+4)*4294967296+X};q5.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)};q5.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};q5.isWin=Gg0;q5.crcTable=jg$});var Kg$=h((nY4,Bg$)=>{var Qg0=K0("path");Bg$.exports=function($,{fs:J}){var X=$||"",W=G(),Y=null;function G(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}if(X&&J.existsSync(X))Y=J.statSync(X),W.directory=Y.isDirectory(),W.mtime=Y.mtime,W.atime=Y.atime,W.executable=(73&Y.mode)!==0,W.readonly=(128&Y.mode)===0,W.hidden=Qg0.basename(X)[0]===".";else console.warn("Invalid path: "+X);return{get directory(){return W.directory},get readOnly(){return W.readonly},get hidden(){return W.hidden},get mtime(){return W.mtime},get atime(){return W.atime},get executable(){return W.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:X,isDirectory:W.directory,isReadOnly:W.readonly,isHidden:W.hidden,isExecutable:W.executable,mTime:W.mtime,aTime:W.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Lg$=h((dY4,wg$)=>{wg$.exports={efs:!0,encode:($)=>Buffer.from($,"utf8"),decode:($)=>$.toString("utf8")}});var mR=h((iY4,uR)=>{uR.exports=zg$();uR.exports.Constants=GH$();uR.exports.Errors=qi();uR.exports.FileAttr=Kg$();uR.exports.decoder=Lg$()});var Og$=h((oY4,Mg$)=>{var jK=mR(),M6=jK.Constants;Mg$.exports=function(){var $=20,J=10,X=0,W=0,Y=0,G=0,Q=0,q=0,H=0,V=0,j=0,U=0,z=0,K=0,w=0;$|=jK.isWin?2560:768,X|=M6.FLG_EFS;let L={extraLen:0},M=(O)=>Math.max(0,O)>>>0,F=(O)=>Math.max(0,O)&65535,A=(O)=>Math.max(0,O)&255;return Y=jK.fromDate2DOS(new Date),{get made(){return $},set made(O){$=O},get version(){return J},set version(O){J=O},get flags(){return X},set flags(O){X=O},get flags_efs(){return(X&M6.FLG_EFS)>0},set flags_efs(O){if(O)X|=M6.FLG_EFS;else X&=~M6.FLG_EFS},get flags_desc(){return(X&M6.FLG_DESC)>0},set flags_desc(O){if(O)X|=M6.FLG_DESC;else X&=~M6.FLG_DESC},get method(){return W},set method(O){switch(O){case M6.STORED:this.version=10;case M6.DEFLATED:default:this.version=20}W=O},get time(){return jK.fromDOS2Date(this.timeval)},set time(O){O=new Date(O),this.timeval=jK.fromDate2DOS(O)},get timeval(){return Y},set timeval(O){Y=M(O)},get timeHighByte(){return A(Y>>>8)},get crc(){return G},set crc(O){G=M(O)},get compressedSize(){return Q},set compressedSize(O){Q=M(O)},get size(){return q},set size(O){q=M(O)},get fileNameLength(){return H},set fileNameLength(O){H=O},get extraLength(){return V},set extraLength(O){V=O},get extraLocalLength(){return L.extraLen},set extraLocalLength(O){L.extraLen=O},get commentLength(){return j},set commentLength(O){j=O},get diskNumStart(){return U},set diskNumStart(O){U=M(O)},get inAttr(){return z},set inAttr(O){z=M(O)},get attr(){return K},set attr(O){K=M(O)},get fileAttr(){return(K||0)>>16&4095},get offset(){return w},set offset(O){w=M(O)},get encrypted(){return(X&M6.FLG_ENC)===M6.FLG_ENC},get centralHeaderSize(){return M6.CENHDR+H+V+j},get realDataOffset(){return w+M6.LOCHDR+L.fnameLen+L.extraLen},get localHeader(){return L},loadLocalHeaderFromBinary:function(O){var N=O.slice(w,w+M6.LOCHDR);if(N.readUInt32LE(0)!==M6.LOCSIG)throw jK.Errors.INVALID_LOC();L.version=N.readUInt16LE(M6.LOCVER),L.flags=N.readUInt16LE(M6.LOCFLG),L.flags_desc=(L.flags&M6.FLG_DESC)>0,L.method=N.readUInt16LE(M6.LOCHOW),L.time=N.readUInt32LE(M6.LOCTIM),L.crc=N.readUInt32LE(M6.LOCCRC),L.compressedSize=N.readUInt32LE(M6.LOCSIZ),L.size=N.readUInt32LE(M6.LOCLEN),L.fnameLen=N.readUInt16LE(M6.LOCNAM),L.extraLen=N.readUInt16LE(M6.LOCEXT);let D=w+M6.LOCHDR+L.fnameLen,R=D+L.extraLen;return O.slice(D,R)},loadFromBinary:function(O){if(O.length!==M6.CENHDR||O.readUInt32LE(0)!==M6.CENSIG)throw jK.Errors.INVALID_CEN();$=O.readUInt16LE(M6.CENVEM),J=O.readUInt16LE(M6.CENVER),X=O.readUInt16LE(M6.CENFLG),W=O.readUInt16LE(M6.CENHOW),Y=O.readUInt32LE(M6.CENTIM),G=O.readUInt32LE(M6.CENCRC),Q=O.readUInt32LE(M6.CENSIZ),q=O.readUInt32LE(M6.CENLEN),H=O.readUInt16LE(M6.CENNAM),V=O.readUInt16LE(M6.CENEXT),j=O.readUInt16LE(M6.CENCOM),U=O.readUInt16LE(M6.CENDSK),z=O.readUInt16LE(M6.CENATT),K=O.readUInt32LE(M6.CENATX),w=O.readUInt32LE(M6.CENOFF)},localHeaderToBinary:function(){var O=Buffer.alloc(M6.LOCHDR);return O.writeUInt32LE(M6.LOCSIG,0),O.writeUInt16LE(J,M6.LOCVER),O.writeUInt16LE(X,M6.LOCFLG),O.writeUInt16LE(W,M6.LOCHOW),O.writeUInt32LE(Y,M6.LOCTIM),O.writeUInt32LE(G,M6.LOCCRC),O.writeUInt32LE(Q,M6.LOCSIZ),O.writeUInt32LE(q,M6.LOCLEN),O.writeUInt16LE(H,M6.LOCNAM),O.writeUInt16LE(L.extraLen,M6.LOCEXT),O},centralHeaderToBinary:function(){var O=Buffer.alloc(M6.CENHDR+H+V+j);return O.writeUInt32LE(M6.CENSIG,0),O.writeUInt16LE($,M6.CENVEM),O.writeUInt16LE(J,M6.CENVER),O.writeUInt16LE(X,M6.CENFLG),O.writeUInt16LE(W,M6.CENHOW),O.writeUInt32LE(Y,M6.CENTIM),O.writeUInt32LE(G,M6.CENCRC),O.writeUInt32LE(Q,M6.CENSIZ),O.writeUInt32LE(q,M6.CENLEN),O.writeUInt16LE(H,M6.CENNAM),O.writeUInt16LE(V,M6.CENEXT),O.writeUInt16LE(j,M6.CENCOM),O.writeUInt16LE(U,M6.CENDSK),O.writeUInt16LE(z,M6.CENATT),O.writeUInt32LE(K,M6.CENATX),O.writeUInt32LE(w,M6.CENOFF),O},toJSON:function(){let O=function(N){return N+" bytes"};return{made:$,version:J,flags:X,method:jK.methodToString(W),time:this.time,crc:"0x"+G.toString(16).toUpperCase(),compressedSize:O(Q),size:O(q),fileNameLength:O(H),extraLength:O(V),commentLength:O(j),diskNumStart:U,inAttr:z,attr:K,offset:w,centralHeaderSize:O(M6.CENHDR+H+V+j)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Fg$=h((rY4,Dg$)=>{var lR=mR(),E9=lR.Constants;Dg$.exports=function(){var $=0,J=0,X=0,W=0,Y=0;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 W},set offset(G){W=G},get commentLength(){return Y},set commentLength(G){Y=G},get mainHeaderSize(){return E9.ENDHDR+Y},loadFromBinary:function(G){if((G.length!==E9.ENDHDR||G.readUInt32LE(0)!==E9.ENDSIG)&&(G.length<E9.ZIP64HDR||G.readUInt32LE(0)!==E9.ZIP64SIG))throw lR.Errors.INVALID_END();if(G.readUInt32LE(0)===E9.ENDSIG)$=G.readUInt16LE(E9.ENDSUB),J=G.readUInt16LE(E9.ENDTOT),X=G.readUInt32LE(E9.ENDSIZ),W=G.readUInt32LE(E9.ENDOFF),Y=G.readUInt16LE(E9.ENDCOM);else $=lR.readBigUInt64LE(G,E9.ZIP64SUB),J=lR.readBigUInt64LE(G,E9.ZIP64TOT),X=lR.readBigUInt64LE(G,E9.ZIP64SIZE),W=lR.readBigUInt64LE(G,E9.ZIP64OFF),Y=0},toBinary:function(){var G=Buffer.alloc(E9.ENDHDR+Y);return G.writeUInt32LE(E9.ENDSIG,0),G.writeUInt32LE(0,4),G.writeUInt16LE($,E9.ENDSUB),G.writeUInt16LE(J,E9.ENDTOT),G.writeUInt32LE(X,E9.ENDSIZ),G.writeUInt32LE(W,E9.ENDOFF),G.writeUInt16LE(Y,E9.ENDCOM),G.fill(" ",E9.ENDHDR),G},toJSON:function(){let G=function(Q,q){let H=Q.toString(16).toUpperCase();while(H.length<q)H="0"+H;return"0x"+H};return{diskEntries:$,totalEntries:J,size:X+" bytes",offset:G(W,4),commentLength:Y}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var QH$=h((qg0)=>{qg0.EntryHeader=Og$();qg0.MainHeader=Fg$()});var Ag$=h((tY4,Ng$)=>{Ng$.exports=function($){var J=K0("zlib"),X={chunkSize:(parseInt($.length/1024)+1)*1024};return{deflate:function(){return J.deflateRawSync($,X)},deflateAsync:function(W){var Y=J.createDeflateRaw(X),G=[],Q=0;Y.on("data",function(q){G.push(q),Q+=q.length}),Y.on("end",function(){var q=Buffer.alloc(Q),H=0;q.fill(0);for(var V=0;V<G.length;V++){var j=G[V];j.copy(q,H),H+=j.length}W&&W(q)}),Y.end($)}}}});var _g$=h((sY4,Rg$)=>{var jg0=+(process.versions?process.versions.node:"").split(".")[0]||0;Rg$.exports=function($,J){var X=K0("zlib");let W=jg0>=15&&J>0?{maxOutputLength:J}:{};return{inflate:function(){return X.inflateRawSync($,W)},inflateAsync:function(Y){var G=X.createInflateRaw(W),Q=[],q=0;G.on("data",function(H){Q.push(H),q+=H.length}),G.on("end",function(){var H=Buffer.alloc(q),V=0;H.fill(0);for(var j=0;j<Q.length;j++){var U=Q[j];U.copy(H,V),V+=U.length}Y&&Y(H)}),G.end($)}}}});var Ig$=h((eY4,Cg$)=>{var{randomFillSync:Eg$}=K0("crypto"),Ug0=qi(),zg0=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}),Pg$=($,J)=>Math.imul($,J)>>>0,Sg$=($,J)=>{return zg0[($^J)&255]^$>>>8},uZ=()=>{if(typeof Eg$==="function")return Eg$(Buffer.alloc(12));else return uZ.node()};uZ.node=()=>{let $=Buffer.alloc(12),J=$.length;for(let X=0;X<J;X++)$[X]=Math.random()*256&255;return $};var Hi={genSalt:uZ};function Vi($){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])}Vi.prototype.updateKeys=function($){let J=this.keys;return J[0]=Sg$(J[0],$),J[1]+=J[0]&255,J[1]=Pg$(J[1],134775813)+1,J[2]=Sg$(J[2],J[1]>>>24),$};Vi.prototype.next=function(){let $=(this.keys[2]|2)>>>0;return Pg$($,$^1)>>8&255};function Bg0($){let J=new Vi($);return function(X){let W=Buffer.alloc(X.length),Y=0;for(let G of X)W[Y++]=J.updateKeys(G^J.next());return W}}function Kg0($){let J=new Vi($);return function(X,W,Y=0){if(!W)W=Buffer.alloc(X.length);for(let G of X){let Q=J.next();W[Y++]=G^Q,J.updateKeys(G)}return W}}function wg0($,J,X){if(!$||!Buffer.isBuffer($)||$.length<12)return Buffer.alloc(0);let W=Bg0(X),Y=W($.slice(0,12)),G=(J.flags&8)===8?J.timeHighByte:J.crc>>>24;if(Y[11]!==G)throw Ug0.WRONG_PASSWORD();return W($.slice(12))}function Lg0($){if(Buffer.isBuffer($)&&$.length>=12)Hi.genSalt=function(){return $.slice(0,12)};else if($==="node")Hi.genSalt=uZ.node;else Hi.genSalt=uZ}function Mg0($,J,X,W=!1){if($==null)$=Buffer.alloc(0);if(!Buffer.isBuffer($))$=Buffer.from($.toString());let Y=Kg0(X),G=Hi.genSalt();if(G[11]=J.crc>>>24&255,W)G[10]=J.crc>>>16&255;let Q=Buffer.alloc($.length+12);return Y(G,Q),Y($,Q,12)}Cg$.exports={decrypt:wg0,encrypt:Mg0,_salter:Lg0}});var vg$=h((Og0)=>{Og0.Deflater=Ag$();Og0.Inflater=_g$();Og0.ZipCrypto=Ig$()});var HH$=h((JG4,kg$)=>{var RJ=mR(),Ag0=QH$(),H5=RJ.Constants,qH$=vg$();kg$.exports=function($,J){var X=new Ag0.EntryHeader,W=Buffer.alloc(0),Y=Buffer.alloc(0),G=!1,Q=null,q=Buffer.alloc(0),H=Buffer.alloc(0),V=!0;let j=$,U=typeof j.decoder==="object"?j.decoder:RJ.decoder;V=U.hasOwnProperty("efs")?U.efs:!1;function z(){if(!J||!(J instanceof Uint8Array))return Buffer.alloc(0);return H=X.loadLocalHeaderFromBinary(J),J.slice(X.realDataOffset,X.realDataOffset+X.compressedSize)}function K(O){if(!X.flags_desc&&!X.localHeader.flags_desc){if(RJ.crc32(O)!==X.localHeader.crc)return!1}else{let N={},D=X.realDataOffset+X.compressedSize;if(J.readUInt32LE(D)==H5.LOCSIG||J.readUInt32LE(D)==H5.CENSIG)throw RJ.Errors.DESCRIPTOR_NOT_EXIST();if(J.readUInt32LE(D)==H5.EXTSIG)N.crc=J.readUInt32LE(D+H5.EXTCRC),N.compressedSize=J.readUInt32LE(D+H5.EXTSIZ),N.size=J.readUInt32LE(D+H5.EXTLEN);else if(J.readUInt16LE(D+12)===19280)N.crc=J.readUInt32LE(D+H5.EXTCRC-4),N.compressedSize=J.readUInt32LE(D+H5.EXTSIZ-4),N.size=J.readUInt32LE(D+H5.EXTLEN-4);else throw RJ.Errors.DESCRIPTOR_UNKNOWN();if(N.compressedSize!==X.compressedSize||N.size!==X.size||N.crc!==X.crc)throw RJ.Errors.DESCRIPTOR_FAULTY();if(RJ.crc32(O)!==N.crc)return!1}return!0}function w(O,N,D){if(typeof N>"u"&&typeof O==="string")D=O,O=void 0;if(G){if(O&&N)N(Buffer.alloc(0),RJ.Errors.DIRECTORY_CONTENT_ERROR());return Buffer.alloc(0)}var R=z();if(R.length===0){if(O&&N)N(R);return R}if(X.encrypted){if(typeof D!=="string"&&!Buffer.isBuffer(D))throw RJ.Errors.INVALID_PASS_PARAM();R=qH$.ZipCrypto.decrypt(R,X,D)}var _=Buffer.alloc(X.size);switch(X.method){case RJ.Constants.STORED:if(R.copy(_),!K(_)){if(O&&N)N(_,RJ.Errors.BAD_CRC());throw RJ.Errors.BAD_CRC()}else{if(O&&N)N(_);return _}case RJ.Constants.DEFLATED:var S=new qH$.Inflater(R,X.size);if(!O){if(S.inflate(_).copy(_,0),!K(_))throw RJ.Errors.BAD_CRC(`"${U.decode(W)}"`);return _}else S.inflateAsync(function(k){if(k.copy(k,0),N)if(!K(k))N(k,RJ.Errors.BAD_CRC());else N(k)});break;default:if(O&&N)N(Buffer.alloc(0),RJ.Errors.UNKNOWN_METHOD());throw RJ.Errors.UNKNOWN_METHOD()}}function L(O,N){if((!Q||!Q.length)&&Buffer.isBuffer(J)){if(O&&N)N(z());return z()}if(Q.length&&!G){var D;switch(X.method){case RJ.Constants.STORED:if(X.compressedSize=X.size,D=Buffer.alloc(Q.length),Q.copy(D),O&&N)N(D);return D;default:case RJ.Constants.DEFLATED:var R=new qH$.Deflater(Q);if(!O){var _=R.deflate();return X.compressedSize=_.length,_}else R.deflateAsync(function(S){D=Buffer.alloc(S.length),X.compressedSize=S.length,S.copy(D),N&&N(D)});R=null;break}}else if(O&&N)N(Buffer.alloc(0));else return Buffer.alloc(0)}function M(O,N){return RJ.readBigUInt64LE(O,N)}function F(O){try{var N=0,D,R,_;while(N+4<O.length)if(D=O.readUInt16LE(N),N+=2,R=O.readUInt16LE(N),N+=2,_=O.slice(N,N+R),N+=R,H5.ID_ZIP64===D)A(_)}catch(S){throw RJ.Errors.EXTRA_FIELD_PARSE_ERROR()}}function A(O){var N,D,R,_;if(O.length>=H5.EF_ZIP64_SCOMP){if(N=M(O,H5.EF_ZIP64_SUNCOMP),X.size===H5.EF_ZIP64_OR_32)X.size=N}if(O.length>=H5.EF_ZIP64_RHO){if(D=M(O,H5.EF_ZIP64_SCOMP),X.compressedSize===H5.EF_ZIP64_OR_32)X.compressedSize=D}if(O.length>=H5.EF_ZIP64_DSN){if(R=M(O,H5.EF_ZIP64_RHO),X.offset===H5.EF_ZIP64_OR_32)X.offset=R}if(O.length>=H5.EF_ZIP64_DSN+4){if(_=O.readUInt32LE(H5.EF_ZIP64_DSN),X.diskNumStart===H5.EF_ZIP64_OR_16)X.diskNumStart=_}}return{get entryName(){return U.decode(W)},get rawEntryName(){return W},set entryName(O){W=RJ.toBuffer(O,U.encode);var N=W[W.length-1];G=N===47||N===92,X.fileNameLength=W.length},get efs(){if(typeof V==="function")return V(this.entryName);else return V},get extra(){return q},set extra(O){q=O,X.extraLength=O.length,F(O)},get comment(){return U.decode(Y)},set comment(O){if(Y=RJ.toBuffer(O,U.encode),X.commentLength=Y.length,Y.length>65535)throw RJ.Errors.COMMENT_TOO_LONG()},get name(){var O=U.decode(W);return G?O.substr(O.length-1).split("/").pop():O.split("/").pop()},get isDirectory(){return G},getCompressedData:function(){return L(!1,null)},getCompressedDataAsync:function(O){L(!0,O)},setData:function(O){if(Q=RJ.toBuffer(O,RJ.decoder.encode),!G&&Q.length)X.size=Q.length,X.method=RJ.Constants.DEFLATED,X.crc=RJ.crc32(O),X.changed=!0;else X.method=RJ.Constants.STORED},getData:function(O){if(X.changed)return Q;else return w(!1,null,O)},getDataAsync:function(O,N){if(X.changed)O(Q);else w(!0,O,N)},set attr(O){X.attr=O},get attr(){return X.attr},set header(O){X.loadFromBinary(O)},get header(){return X},packCentralHeader:function(){X.flags_efs=this.efs,X.extraLength=q.length;var O=X.centralHeaderToBinary(),N=RJ.Constants.CENHDR;return W.copy(O,N),N+=W.length,q.copy(O,N),N+=X.extraLength,Y.copy(O,N),O},packLocalHeader:function(){let O=0;X.flags_efs=this.efs,X.extraLocalLength=H.length;let N=X.localHeaderToBinary(),D=Buffer.alloc(N.length+W.length+X.extraLocalLength);return N.copy(D,O),O+=N.length,W.copy(D,O),O+=W.length,H.copy(D,O),O+=H.length,D},toJSON:function(){let O=function(N){return"<"+(N&&N.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:X.toJSON(),compressedData:O(J),data:O(Q)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}});var Zg$=h((XG4,Tg$)=>{var bg$=HH$(),Rg0=QH$(),R7=mR();Tg$.exports=function($,J){var X=[],W={},Y=Buffer.alloc(0),G=new Rg0.MainHeader,Q=!1,q=null;let H=new Set,V=J,{noSort:j,decoder:U}=V;if($)w(V.readEntries);else Q=!0;function z(){let M=new Set;for(let F of Object.keys(W)){let A=F.split("/");if(A.pop(),!A.length)continue;for(let O=0;O<A.length;O++){let N=A.slice(0,O+1).join("/")+"/";M.add(N)}}for(let F of M)if(!(F in W)){let A=new bg$(V);A.entryName=F,A.attr=16,A.temporary=!0,X.push(A),W[A.entryName]=A,H.add(A)}}function K(){if(Q=!0,W={},G.diskEntries>($.length-G.offset)/R7.Constants.CENHDR)throw R7.Errors.DISK_ENTRY_TOO_LARGE();X=Array(G.diskEntries);var M=G.offset;for(var F=0;F<X.length;F++){var A=M,O=new bg$(V,$);if(O.header=$.slice(A,A+=R7.Constants.CENHDR),O.entryName=$.slice(A,A+=O.header.fileNameLength),O.header.extraLength)O.extra=$.slice(A,A+=O.header.extraLength);if(O.header.commentLength)O.comment=$.slice(A,A+O.header.commentLength);M+=O.header.centralHeaderSize,X[F]=O,W[O.entryName]=O}H.clear(),z()}function w(M){var F=$.length-R7.Constants.ENDHDR,A=Math.max(0,F-65535),O=A,N=$.length,D=-1,R=0;if(typeof V.trailingSpace==="boolean"?V.trailingSpace:!1)A=0;for(F;F>=O;F--){if($[F]!==80)continue;if($.readUInt32LE(F)===R7.Constants.ENDSIG){D=F,R=F,N=F+R7.Constants.ENDHDR,O=F-R7.Constants.END64HDR;continue}if($.readUInt32LE(F)===R7.Constants.END64SIG){O=A;continue}if($.readUInt32LE(F)===R7.Constants.ZIP64SIG){D=F,N=F+R7.readBigUInt64LE($,F+R7.Constants.ZIP64SIZE)+R7.Constants.ZIP64LEAD;break}}if(D==-1)throw R7.Errors.INVALID_FORMAT();if(G.loadFromBinary($.slice(D,N)),G.commentLength)Y=$.slice(R+R7.Constants.ENDHDR);if(M)K()}function L(){if(X.length>1&&!j)X.sort((M,F)=>M.entryName.toLowerCase().localeCompare(F.entryName.toLowerCase()))}return{get entries(){if(!Q)K();return X.filter((M)=>!H.has(M))},get comment(){return U.decode(Y)},set comment(M){Y=R7.toBuffer(M,U.encode),G.commentLength=Y.length},getEntryCount:function(){if(!Q)return G.diskEntries;return X.length},forEach:function(M){this.entries.forEach(M)},getEntry:function(M){if(!Q)K();return W[M]||null},setEntry:function(M){if(!Q)K();X.push(M),W[M.entryName]=M,G.totalEntries=X.length},deleteFile:function(M,F=!0){if(!Q)K();let A=W[M];this.getEntryChildren(A,F).map((N)=>N.entryName).forEach(this.deleteEntry)},deleteEntry:function(M){if(!Q)K();let F=W[M],A=X.indexOf(F);if(A>=0)X.splice(A,1),delete W[M],G.totalEntries=X.length},getEntryChildren:function(M,F=!0){if(!Q)K();if(typeof M==="object")if(M.isDirectory&&F){let A=[],O=M.entryName;for(let N of X)if(N.entryName.startsWith(O))A.push(N);return A}else return[M];return[]},getChildCount:function(M){if(M&&M.isDirectory){let F=this.getEntryChildren(M);return F.includes(M)?F.length-1:F.length}return 0},compressToBuffer:function(){if(!Q)K();L();let M=[],F=[],A=0,O=0;G.size=0,G.offset=0;let N=0;for(let _ of this.entries){let S=_.getCompressedData();_.header.offset=O;let k=_.packLocalHeader(),b=k.length+S.length;O+=b,M.push(k),M.push(S);let v=_.packCentralHeader();F.push(v),G.size+=v.length,A+=b+v.length,N++}A+=G.mainHeaderSize,G.offset=O,G.totalEntries=N,O=0;let D=Buffer.alloc(A);for(let _ of M)_.copy(D,O),O+=_.length;for(let _ of F)_.copy(D,O),O+=_.length;let R=G.toBinary();if(Y)Y.copy(R,R7.Constants.ENDHDR);return R.copy(D,O),$=D,Q=!1,D},toAsyncBuffer:function(M,F,A,O){try{if(!Q)K();L();let N=[],D=[],R=0,_=0,S=0;G.size=0,G.offset=0;let k=function(b){if(b.length>0){let v=b.shift(),f=v.entryName+v.extra.toString();if(A)A(f);v.getCompressedDataAsync(function(g){if(O)O(f);v.header.offset=_;let m=v.packLocalHeader(),p=m.length+g.length;_+=p,N.push(m),N.push(g);let l=v.packCentralHeader();D.push(l),G.size+=l.length,R+=p+l.length,S++,k(b)})}else{R+=G.mainHeaderSize,G.offset=_,G.totalEntries=S,_=0;let v=Buffer.alloc(R);N.forEach(function(g){g.copy(v,_),_+=g.length}),D.forEach(function(g){g.copy(v,_),_+=g.length});let f=G.toBinary();if(Y)Y.copy(f,R7.Constants.ENDHDR);f.copy(v,_),$=v,Q=!1,M(v)}};k(Array.from(this.entries))}catch(N){F(N)}}}}});var ji=h((WG4,xg$)=>{var P9=mR(),S9=K0("path"),_g0=HH$(),Eg0=Zg$(),MO=(...$)=>P9.findLast($,(J)=>typeof J==="boolean"),fg$=(...$)=>P9.findLast($,(J)=>typeof J==="string"),Sg0=(...$)=>P9.findLast($,(J)=>typeof J==="function"),Pg0={noSort:!1,readEntries:!1,method:P9.Constants.NONE,fs:null};xg$.exports=function($,J){let X=null,W=Object.assign(Object.create(null),Pg0);if($&&typeof $==="object"){if(!($ instanceof Uint8Array)){if(Object.assign(W,$),$=W.input?W.input:void 0,W.input)delete W.input}if(Buffer.isBuffer($))X=$,W.method=P9.Constants.BUFFER,$=void 0}Object.assign(W,J);let Y=new P9(W);if(typeof W.decoder!=="object"||typeof W.decoder.encode!=="function"||typeof W.decoder.decode!=="function")W.decoder=P9.decoder;if($&&typeof $==="string")if(Y.fs.existsSync($))W.method=P9.Constants.FILE,W.filename=$,X=Y.fs.readFileSync($);else throw P9.Errors.INVALID_FILENAME();let G=new Eg0(X,W),{canonical:Q,sanitize:q,zipnamefix:H}=P9;function V(K){if(K&&G){var w;if(typeof K==="string")w=G.getEntry(S9.posix.normalize(K));if(typeof K==="object"&&typeof K.entryName<"u"&&typeof K.header<"u")w=G.getEntry(K.entryName);if(w)return w}return null}function j(K){let{join:w,normalize:L,sep:M}=S9.posix;return w(S9.isAbsolute(K)?"/":".",L(M+K.split("\\").join(M)+M))}function U(K){if(K instanceof RegExp)return function(w){return function(L){return w.test(L)}}(K);else if(typeof K!=="function")return()=>!0;return K}let z=(K,w)=>{let L=w.slice(-1);return L=L===Y.sep?Y.sep:"",S9.relative(K,w)+L};return{readFile:function(K,w){var L=V(K);return L&&L.getData(w)||null},childCount:function(K){let w=V(K);if(w)return G.getChildCount(w)},readFileAsync:function(K,w){var L=V(K);if(L)L.getDataAsync(w);else w(null,"getEntry failed for:"+K)},readAsText:function(K,w){var L=V(K);if(L){var M=L.getData();if(M&&M.length)return M.toString(w||"utf8")}return""},readAsTextAsync:function(K,w,L){var M=V(K);if(M)M.getDataAsync(function(F,A){if(A){w(F,A);return}if(F&&F.length)w(F.toString(L||"utf8"));else w("")});else w("")},deleteFile:function(K,w=!0){var L=V(K);if(L)G.deleteFile(L.entryName,w)},deleteEntry:function(K){var w=V(K);if(w)G.deleteEntry(w.entryName)},addZipComment:function(K){G.comment=K},getZipComment:function(){return G.comment||""},addZipEntryComment:function(K,w){var L=V(K);if(L)L.comment=w},getZipEntryComment:function(K){var w=V(K);if(w)return w.comment||"";return""},updateFile:function(K,w){var L=V(K);if(L)L.setData(w)},addLocalFile:function(K,w,L,M){if(Y.fs.existsSync(K)){w=w?j(w):"";let F=S9.win32.basename(S9.win32.normalize(K));w+=L?L:F;let A=Y.fs.statSync(K),O=A.isFile()?Y.fs.readFileSync(K):Buffer.alloc(0);if(A.isDirectory())w+=Y.sep;this.addFile(w,O,M,A)}else throw P9.Errors.FILE_NOT_FOUND(K)},addLocalFileAsync:function(K,w){K=typeof K==="object"?K:{localPath:K};let L=S9.resolve(K.localPath),{comment:M}=K,{zipPath:F,zipName:A}=K,O=this;Y.fs.stat(L,function(N,D){if(N)return w(N,!1);F=F?j(F):"";let R=S9.win32.basename(S9.win32.normalize(L));if(F+=A?A:R,D.isFile())Y.fs.readFile(L,function(_,S){if(_)return w(_,!1);return O.addFile(F,S,M,D),setImmediate(w,void 0,!0)});else if(D.isDirectory())return F+=Y.sep,O.addFile(F,Buffer.alloc(0),M,D),setImmediate(w,void 0,!0)})},addLocalFolder:function(K,w,L){if(L=U(L),w=w?j(w):"",K=S9.normalize(K),Y.fs.existsSync(K)){let M=Y.findFiles(K),F=this;if(M.length)for(let A of M){let O=S9.join(w,z(K,A));if(L(O))F.addLocalFile(A,S9.dirname(O))}}else throw P9.Errors.FILE_NOT_FOUND(K)},addLocalFolderAsync:function(K,w,L,M){M=U(M),L=L?j(L):"",K=S9.normalize(K);var F=this;Y.fs.open(K,"r",function(A){if(A&&A.code==="ENOENT")w(void 0,P9.Errors.FILE_NOT_FOUND(K));else if(A)w(void 0,A);else{var O=Y.findFiles(K),N=-1,D=function(){if(N+=1,N<O.length){var R=O[N],_=z(K,R).split("\\").join("/");if(_=_.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),M(_))Y.fs.stat(R,function(S,k){if(S)w(void 0,S);if(k.isFile())Y.fs.readFile(R,function(b,v){if(b)w(void 0,b);else F.addFile(L+_,v,"",k),D()});else F.addFile(L+_+"/",Buffer.alloc(0),"",k),D()});else process.nextTick(()=>{D()})}else w(!0,void 0)};D()}})},addLocalFolderAsync2:function(K,w){let L=this;K=typeof K==="object"?K:{localPath:K},localPath=S9.resolve(j(K.localPath));let{zipPath:M,filter:F,namefix:A}=K;if(F instanceof RegExp)F=function(D){return function(R){return D.test(R)}}(F);else if(typeof F!=="function")F=function(){return!0};if(M=M?j(M):"",A=="latin1")A=(D)=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"");if(typeof A!=="function")A=(D)=>D;let O=(D)=>S9.join(M,A(z(localPath,D))),N=(D)=>S9.win32.basename(S9.win32.normalize(A(D)));Y.fs.open(localPath,"r",function(D){if(D&&D.code==="ENOENT")w(void 0,P9.Errors.FILE_NOT_FOUND(localPath));else if(D)w(void 0,D);else Y.findFilesAsync(localPath,function(R,_){if(R)return w(R);if(_=_.filter((S)=>F(O(S))),!_.length)w(void 0,!1);setImmediate(_.reverse().reduce(function(S,k){return function(b,v){if(b||v===!1)return setImmediate(S,b,!1);L.addLocalFileAsync({localPath:k,zipPath:S9.dirname(O(k)),zipName:N(k)},S)}},w))})})},addLocalFolderPromise:function(K,w){return new Promise((L,M)=>{this.addLocalFolderAsync2(Object.assign({localPath:K},w),(F,A)=>{if(F)M(F);if(A)L(this)})})},addFile:function(K,w,L,M){K=H(K);let F=V(K),A=F!=null;if(!A)F=new _g0(W),F.entryName=K;F.comment=L||"";let O=typeof M==="object"&&M instanceof Y.fs.Stats;if(O)F.header.time=M.mtime;var N=F.isDirectory?16:0;let D=F.isDirectory?16384:32768;if(O)D|=4095&M.mode;else if(typeof M==="number")D|=4095&M;else D|=F.isDirectory?493:420;if(N=(N|D<<16)>>>0,F.attr=N,F.setData(w),!A)G.setEntry(F);return F},getEntries:function(K){return G.password=K,G?G.entries:[]},getEntry:function(K){return V(K)},getEntryCount:function(){return G.getEntryCount()},forEach:function(K){return G.forEach(K)},extractEntryTo:function(K,w,L,M,F,A){M=MO(!1,M),F=MO(!1,F),L=MO(!0,L),A=fg$(F,A);var O=V(K);if(!O)throw P9.Errors.NO_ENTRY();var N=Q(O.entryName),D=q(w,A&&!O.isDirectory?A:L?N:S9.basename(N));if(O.isDirectory){var R=G.getEntryChildren(O);return R.forEach(function(k){if(k.isDirectory)return;var b=k.getData();if(!b)throw P9.Errors.CANT_EXTRACT_FILE();var v=Q(k.entryName),f=q(w,L?v:S9.basename(v));let g=F?k.header.fileAttr:void 0;Y.writeFileTo(f,b,M,g)}),!0}var _=O.getData(G.password);if(!_)throw P9.Errors.CANT_EXTRACT_FILE();if(Y.fs.existsSync(D)&&!M)throw P9.Errors.CANT_OVERRIDE();let S=F?K.header.fileAttr:void 0;return Y.writeFileTo(D,_,M,S),!0},test:function(K){if(!G)return!1;for(var w in G.entries)try{if(w.isDirectory)continue;var L=G.entries[w].getData(K);if(!L)return!1}catch(M){return!1}return!0},extractAllTo:function(K,w,L,M){if(L=MO(!1,L),M=fg$(L,M),w=MO(!1,w),!G)throw P9.Errors.NO_ZIP();G.entries.forEach(function(F){var A=q(K,Q(F.entryName));if(F.isDirectory){Y.makeDir(A);return}var O=F.getData(M);if(!O)throw P9.Errors.CANT_EXTRACT_FILE();let N=L?F.header.fileAttr:void 0;Y.writeFileTo(A,O,w,N);try{Y.fs.utimesSync(A,F.header.time,F.header.time)}catch(D){throw P9.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(K,w,L,M){if(M=Sg0(w,L,M),L=MO(!1,L),w=MO(!1,w),!M)return new Promise((D,R)=>{this.extractAllToAsync(K,w,L,function(_){if(_)R(_);else D(this)})});if(!G){M(P9.Errors.NO_ZIP());return}K=S9.resolve(K);let F=(D)=>q(K,S9.normalize(Q(D.entryName))),A=(D,R)=>Error(D+': "'+R+'"'),O=[],N=[];G.entries.forEach((D)=>{if(D.isDirectory)O.push(D);else N.push(D)});for(let D of O){let R=F(D),_=L?D.header.fileAttr:void 0;try{if(Y.makeDir(R),_)Y.fs.chmodSync(R,_);Y.fs.utimesSync(R,D.header.time,D.header.time)}catch(S){M(A("Unable to create folder",R))}}N.reverse().reduce(function(D,R){return function(_){if(_)D(_);else{let S=S9.normalize(Q(R.entryName)),k=q(K,S);R.getDataAsync(function(b,v){if(v)D(v);else if(!b)D(P9.Errors.CANT_EXTRACT_FILE());else{let f=L?R.header.fileAttr:void 0;Y.writeFileToAsync(k,b,w,f,function(g){if(!g)D(A("Unable to write file",k));Y.fs.utimes(k,R.header.time,R.header.time,function(m){if(m)D(A("Unable to set times",k));else D()})})}})}}},M)()},writeZip:function(K,w){if(arguments.length===1){if(typeof K==="function")w=K,K=""}if(!K&&W.filename)K=W.filename;if(!K)return;var L=G.compressToBuffer();if(L){var M=Y.writeFileTo(K,L,!0);if(typeof w==="function")w(!M?Error("failed"):null,"")}},writeZipPromise:function(K,w){let{overwrite:L,perm:M}=Object.assign({overwrite:!0},w);return new Promise((F,A)=>{if(!K&&W.filename)K=W.filename;if(!K)A("ADM-ZIP: ZIP File Name Missing");this.toBufferPromise().then((O)=>{let N=(D)=>D?F(D):A("ADM-ZIP: Wasn't able to write zip file");Y.writeFileToAsync(K,O,L,M,N)},A)})},toBufferPromise:function(){return new Promise((K,w)=>{G.toAsyncBuffer(K,w)})},toBuffer:function(K,w,L,M){if(typeof K==="function")return G.toAsyncBuffer(K,w,L,M),null;return G.compressToBuffer()}}}});class hg${DEFAULT_TTL_MS=60000;cache;timer;constructor($=new vR){this.timer=$,this.cache=new GK($,{ttlMs:this.DEFAULT_TTL_MS})}async isAccessibilityEnabled($,J,X){if(X?.isEnabled("force-accessibility-mode"))return B.debug(`[AccessibilityDetector] Force-enabled via feature flag for device ${$}`),!0;if(X&&!X.isEnabled("accessibility-auto-detect"))return B.debug(`[AccessibilityDetector] Auto-detection disabled via feature flag for device ${$}`),!1;let G=this.cache.get($);if(G)return B.debug(`[AccessibilityDetector] Using cached result for device ${$}: enabled=${G.enabled}, service=${G.service}`),G.enabled;B.debug(`[AccessibilityDetector] Detecting accessibility state for device ${$}`);let Q=this.timer.now(),{enabled:q,service:H}=await this.detectAccessibilityState($,J),V=this.timer.now()-Q;if(V>50)B.warn(`[AccessibilityDetector] Detection took ${V}ms (target: <50ms) for device ${$}`);else B.debug(`[AccessibilityDetector] Detection completed in ${V}ms for device ${$}`);return this.cache.set($,{enabled:q,service:H}),q}async detectMethod($,J,X){if(X?.isEnabled("force-accessibility-mode"))return"talkback";if(X&&!X.isEnabled("accessibility-auto-detect"))return"unknown";let G=this.cache.get($);if(G)return G.service;let{enabled:Q,service:q}=await this.detectAccessibilityState($,J);return this.cache.set($,{enabled:Q,service:q}),q}invalidateCache($){B.debug(`[AccessibilityDetector] Invalidating cache for device ${$}`),this.cache.delete($)}clearAllCache(){B.debug("[AccessibilityDetector] Clearing all cached entries"),this.cache.clear()}async detectAccessibilityState($,J){try{let W=(await J.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.trim();if(W.includes("com.google.android.marvin.talkback")||W.includes("TalkBackService"))return B.debug(`[AccessibilityDetector] TalkBack detected as enabled on device ${$}`),{enabled:!0,service:"talkback"};if(W!=="null"&&W.length>0&&!W.includes("null"))return B.debug(`[AccessibilityDetector] Unknown accessibility service detected on device ${$}: ${W}`),{enabled:!0,service:"unknown"};return B.debug(`[AccessibilityDetector] No accessibility services enabled on device ${$}`),{enabled:!1,service:"unknown"}}catch(X){return B.error(`[AccessibilityDetector] Failed to detect accessibility state for device ${$}:`,X),{enabled:!1,service:"unknown"}}}}var _7;var UK=E(()=>{e();E$();$i();_7=new hg$});import{execFile as Cg0}from"child_process";import{createWriteStream as Ig0}from"fs";import*as gg$ from"fs/promises";import vg0 from"http";import kg0 from"https";import*as ug$ from"path";import{promisify as bg0}from"util";class mZ{async download($,J){try{await this.downloadWithCurl($,J);return}catch(X){if(!this.isCommandUnavailable(X,"curl"))throw X;B.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;B.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 yg$("curl",["--fail","--location","--retry","3","--retry-delay","1","--silent","--show-error","-o",J,$],{timeout:120000,maxBuffer:10485760})}async downloadWithWget($,J){await yg$("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 gg$.mkdir(ug$.dirname(J),{recursive:!0}),await new Promise((W,Y)=>{let Q=($.startsWith("https:")?kg0:vg0).get($,{headers:{"User-Agent":"auto-mobile"}},(q)=>{let H=q.statusCode??0;if(H>=300&&H<400&&q.headers.location){q.resume();let j=new URL(q.headers.location,$).toString();this.downloadWithNodeHttp(j,J,X+1).then(W).catch(Y);return}if(H<200||H>=300){q.resume(),Y(Error(`Download failed with status ${H} from ${$}`));return}let V=Ig0(J);q.pipe(V),V.on("finish",()=>V.close(()=>W())),V.on("error",(j)=>{V.close(),Y(j)})});Q.setTimeout(30000,()=>{Q.destroy(Error(`Download request timed out for ${$}`))}),Q.on("error",Y)})}isCommandUnavailable($,J){if(!$||typeof $!=="object")return!1;let X=$,W=typeof X.code==="number"?X.code:Number(X.code);if(X.code==="ENOENT"||!Number.isNaN(W)&&W===127)return!0;let Y=`${X.message??""} ${X.stderr??""}`.toLowerCase();if(Y.includes("command not found")||Y.includes("not recognized as an internal or external command")||Y.includes(`${J}: not found`)||Y.includes(`not found: ${J}`))return!0;return!1}}var yg$;var VH$=E(()=>{e();yg$=bg0(Cg0)});import{execFile as Tg0}from"child_process";import{createReadStream as Zg0}from"fs";import fg0 from"crypto";import{promisify as xg0}from"util";class lZ{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 W=fg0.createHash("sha256");return await new Promise((Y,G)=>{let Q=Zg0($);Q.on("data",(q)=>W.update(q)),Q.on("error",G),Q.on("end",()=>Y())}),{checksum:W.digest("hex"),source:"node"}}async tryChecksumCommand($,J){try{let{stdout:X}=await hg0(J,$,{timeout:120000,maxBuffer:10485760}),W=X.trim().split(/\s+/)[0]?.replace(/^\\/,"");if(!W)return B.warn("[ChecksumCalculator] checksum tool returned no output",{tool:J}),null;return W}catch(X){return B.info("[ChecksumCalculator] checksum tool unavailable, falling back",{tool:J,error:X instanceof Error?X.message:String(X)}),null}}}var hg0;var jH$=E(()=>{e();hg0=xg0(Tg0)});import*as F5 from"fs/promises";import*as P5 from"path";import yg0 from"crypto";import Ui from"os";var UH$,M0;var pY=E(()=>{O6();e();LO();UK();c0();E$();VH$();jH$();UH$=W5(ji(),1);M0=class M0{device;adb;static PACKAGE="dev.jasonpearson.automobile.ctrlproxy";static ACTIVITY="dev.jasonpearson.automobile.ctrlproxy.MainActivity";static LEGACY_PACKAGE="dev.jasonpearson.automobile.accessibilityservice";static APK_URL=gR;cachedAvailability=null;static AVAILABILITY_CACHE_TTL=3600000;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=z$;timer;fileDownloader;checksumCalculator;static defaultFileDownloader=new mZ;static defaultChecksumCalculator=new lZ;constructor($,J,X=c,W=M0.defaultFileDownloader,Y=M0.defaultChecksumCalculator){if(!(process.env.HOME||K0("os").homedir()))throw Error("Home directory for current user not found");this.device=$,this.adb=J,this.timer=X,this.fileDownloader=W,this.checksumCalculator=Y}static getInstance($,J=z$){if(VK($,"AndroidCtrlProxyManager.getInstance"),!M0.instances.has($.deviceId)){let X,W;if(J&&typeof J.create==="function")W=J,X=W.create($);else if(J){let Y=J;X=Y,W={create:()=>Y}}else W=z$,X=W.create($);M0.adbFactory=W,M0.instances.set($.deviceId,new M0($,X))}return M0.instances.get($.deviceId)}static resetInstances(){M0.instances.clear()}static prefetchApk(){if(M0.prefetchPromise!==null){B.info("[CTRL_PROXY] APK prefetch already initiated, skipping");return}let $=process.env.AUTOMOBILE_CTRL_PROXY_APK_PATH?.trim();if($&&$.length>0){B.info("[CTRL_PROXY] Using local APK override, skipping prefetch");return}B.info("[CTRL_PROXY] Starting APK prefetch");let J=c.now();M0.prefetchPromise=M0.doPrefetch().then((X)=>{let W=c.now()-J;if(X)M0.prefetchedApkPath=X,B.info(`[CTRL_PROXY] APK prefetch completed in ${W}ms`,{path:X});return X}).catch((X)=>{let W=c.now()-J;return M0.prefetchError=X instanceof Error?X:Error(String(X)),B.warn(`[CTRL_PROXY] APK prefetch failed after ${W}ms`,{error:M0.prefetchError.message}),null})}static async doPrefetch(){let $=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-prefetch-")),J=P5.join($,"control-proxy.apk");B.info("[CTRL_PROXY] Prefetch: downloading APK",{url:gR,destination:J}),await M0.defaultFileDownloader.download(gR,J);let X=await F5.stat(J);if(X.size<1e4)throw Error(`Prefetched APK is too small (${X.size} bytes), likely invalid`);M0.verifyApkIntegrityStatic(J);let W=M0.expectedChecksumOverride??Xg$;if(W.length>0){let{checksum:Y}=await M0.defaultChecksumCalculator.computeFileSha256(J);if(Y.toLowerCase()!==W.toLowerCase())throw await F5.rm($,{recursive:!0,force:!0}).catch(()=>{}),Error(`APK checksum verification failed. Expected: ${W}, Got: ${Y}`);B.info("[CTRL_PROXY] Prefetch: checksum verified",{checksum:Y})}return B.info("[CTRL_PROXY] Prefetch: APK ready",{path:J,size:X.size}),J}static async getPrefetchedApkPath(){if(M0.prefetchPromise===null)return null;try{return await M0.prefetchPromise,M0.prefetchedApkPath}catch{return null}}static async consumePrefetchedApk($){let J=await M0.getPrefetchedApkPath();if(!J)return!1;try{return await F5.mkdir(P5.dirname($),{recursive:!0}),await F5.copyFile(J,$),B.info("[CTRL_PROXY] Copied prefetched APK",{source:J,destination:$}),!0}catch(X){return B.warn("[CTRL_PROXY] Failed to copy prefetched APK",{error:X instanceof Error?X.message:String(X)}),!1}}static async cleanupPrefetchedApk(){if(M0.prefetchedApkPath){try{let $=P5.dirname(M0.prefetchedApkPath);await F5.rm($,{recursive:!0,force:!0}),B.info("[CTRL_PROXY] Cleaned up prefetched APK",{path:$})}catch($){B.warn("[CTRL_PROXY] Failed to clean up prefetched APK",{error:$ instanceof Error?$.message:String($)})}M0.prefetchedApkPath=null}M0.prefetchPromise=null,M0.prefetchError=null}static verifyApkIntegrityStatic($){try{if(!new UH$.default($).getEntries().some((Y)=>Y.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($){M0.expectedChecksumOverride=$}static setAccessibilityDetectorForTesting($){M0.accessibilityDetectorOverride=$}getAccessibilityDetector(){return M0.accessibilityDetectorOverride||_7}clearAvailabilityCache(){this.cachedAvailability=null,this.cachedInstallation=null,this.cachedEnabled=null,this.cachedToggleCapabilities=null,B.info("[CTRL_PROXY] Cleared all availability caches")}resetSetupState(){this.attemptedAutomatedSetup=!1,this.clearAvailabilityCache(),B.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($<M0.STATUS_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached installation status (age: ${$}ms): ${this.cachedInstallation.isInstalled?"installed":"not installed"}`),this.cachedInstallation.isInstalled;else this.cachedInstallation=null}try{B.debug("[CTRL_PROXY] Checking if accessibility service is installed");let J=(await this.adb.executeCommand(`shell pm list packages | grep ${M0.PACKAGE}`,void 0,void 0,!0)).stdout.includes(M0.PACKAGE);return this.cachedInstallation={isInstalled:J,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Service installation status: ${J?"installed":"not installed"} (cached for ${M0.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return B.warn(`[CTRL_PROXY] Error checking installation status: ${$}`),!1}}async isEnabled(){if(this.cachedEnabled&&this.cachedEnabled.isEnabled){let $=this.timer.now()-this.cachedEnabled.timestamp;if($<M0.STATUS_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached enabled status (age: ${$}ms): ${this.cachedEnabled.isEnabled?"enabled":"disabled"}`),this.cachedEnabled.isEnabled;else this.cachedEnabled=null}try{B.debug("[CTRL_PROXY] Checking if accessibility service is enabled");let J=(await this.adb.executeCommand("shell settings get secure enabled_accessibility_services")).stdout.includes(M0.PACKAGE);return this.cachedEnabled={isEnabled:J,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Service enabled status: ${J?"enabled":"disabled"} (cached for ${M0.STATUS_CACHE_TTL/1000/60} minutes)`),J}catch($){return B.warn(`[CTRL_PROXY] Error checking enabled status: ${$}`),!1}}async isEnabledForUser($){try{B.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(M0.PACKAGE);return B.debug(`[CTRL_PROXY] Service enabled status for user ${$}: ${X?"enabled":"disabled"}`),X}catch(J){return B.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<M0.AVAILABILITY_CACHE_TTL)return B.debug(`[CTRL_PROXY] Using cached overall availability (age: ${J}ms): ${this.cachedAvailability.isAvailable}`),this.cachedAvailability.isAvailable;else this.cachedAvailability=null}B.debug("[CTRL_PROXY] Checking availability (no cached result available)");try{let[J,X]=await Promise.all([this.isInstalled(),this.isEnabled()]),W=J&&X,Y=this.timer.now()-$;return this.cachedAvailability={isAvailable:W,timestamp:this.timer.now()},B.debug(`[CTRL_PROXY] Availability check completed in ${Y}ms - Available: ${W} (cached for ${M0.AVAILABILITY_CACHE_TTL/1000/60} minutes)`),W}catch(J){let X=this.timer.now()-$;return B.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 B.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 $=w0();this.clearAvailabilityCache(),$.startOperation("uninstallLegacy"),await this.uninstallLegacyPackageIfPresent(),$.endOperation("uninstallLegacy");let J=this.getExpectedChecksum();if(J.length===0)return{status:"skipped",expectedSha256:J};$.startOperation("checkInstalled");let X=await this.isInstalled();if($.endOperation("checkInstalled"),X&&this.shouldSkipDownloadIfInstalled())return B.warn("[CTRL_PROXY] Skipping APK download/version check (preinstalled APK allowed)"),{status:"skipped",expectedSha256:J};let W={status:"compatible",expectedSha256:J},Y=!1;if(X){$.startOperation("getChecksum");let Q=await this.getInstalledApkSha256WithDetails();$.endOperation("getChecksum"),W.installedSha256=Q.sha256,W.installedShaSource=Q.source,W.installedApkPath=Q.apkPath;let q=Q.sha256;if(Y=!q,!q&&Q.error)B.warn("[CTRL_PROXY] Unable to determine installed APK checksum, forcing reinstall",{error:Q.error});if(q&&q.toLowerCase()===J.toLowerCase())return W;if(Y)B.warn("[CTRL_PROXY] Installed APK checksum unavailable, forcing reinstall");else B.info("[CTRL_PROXY] Installed APK SHA mismatch, attempting upgrade",{expected:J,actual:q})}else B.info("[CTRL_PROXY] Service not installed, downloading and installing");let G=null;try{if(W.attemptedDownload=!0,$.startOperation("downloadApk"),G=await this.downloadApk(),$.endOperation("downloadApk"),X&&!Y)try{return W.attemptedInstall=!0,$.startOperation("installApk"),await this.adb.executeCommand(`install -r -d "${G}"`),$.endOperation("installApk"),B.info("[CTRL_PROXY] APK upgraded successfully"),this.clearAvailabilityCache(),{...W,status:"upgraded"}}catch(Q){$.endOperation("installApk");let q=Q instanceof Error?Q.message:String(Q);B.warn("[CTRL_PROXY] Upgrade failed, attempting reinstall",{error:q}),W.upgradeError=q}try{if(W.attemptedReinstall=!0,X)await this.adb.executeCommand(`shell pm uninstall ${M0.PACKAGE}`);return $.startOperation("installApk"),await this.install(G),$.endOperation("installApk"),await this.enable(),B.info(`[CTRL_PROXY] APK ${X?"reinstalled":"installed"} and service enabled`),this.clearAvailabilityCache(),{...W,status:X?"reinstalled":"installed"}}catch(Q){let q=Q instanceof Error?Q.message:String(Q);return{...W,status:"failed",reinstallError:q}}}catch(Q){let q=Q instanceof Error?Q.message:String(Q),H=this.isNetworkError(q);return{...W,status:"failed",downloadUnavailable:H,error:H?"Unable to download the latest accessibility service APK while offline. Connect to the internet and retry.":q}}finally{if(G)await this.cleanupApk(G)}}async downloadApk(){let $=w0(),J=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-")),X=P5.join(J,"control-proxy.apk");try{let W=this.getApkPathOverride();if($.startOperation("httpDownload"),W){if(B.info("Using local accessibility service APK",{path:W}),!(await F5.stat(W)).isFile())throw Error(`Accessibility APK override is not a file: ${W}`);await F5.copyFile(W,X)}else if(await M0.consumePrefetchedApk(X))B.info("Using prefetched accessibility service APK",{path:X});else B.info("Downloading APK",{url:M0.APK_URL,destination:X}),await this.fileDownloader.download(M0.APK_URL,X);$.endOperation("httpDownload");let Y=await F5.stat(X);if(Y.size<1e4)throw Error(`Downloaded APK is too small (${Y.size} bytes), likely invalid`);this.verifyApkIntegrity(X);let G=this.getExpectedChecksum();if(G.length>0){$.startOperation("checksumVerify");let{checksum:Q,source:q}=await this.checksumCalculator.computeFileSha256(X),H=Q.toLowerCase(),V=G.toLowerCase();if(H!==V)throw B.warn("APK checksum verification failed",{expected:V,actual:H}),Error(`APK checksum verification failed. Expected: ${V}, Got: ${H}`);B.info("APK checksum verified successfully",{checksum:H,source:q}),$.endOperation("checksumVerify")}else B.warn("APK checksum verification SKIPPED - no checksum provided (development mode)",{apkUrl:M0.APK_URL});return B.info("APK downloaded successfully",{path:X,size:Y.size}),X}catch(W){try{await this.cleanupApk(X)}catch{}throw Error(`Failed to download APK: ${W instanceof Error?W.message:String(W)}`)}}verifyApkIntegrity($){try{if(!new UH$.default($).getEntries().some((Y)=>Y.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 ${M0.LEGACY_PACKAGE}`,void 0,void 0,!0)).stdout.includes(M0.LEGACY_PACKAGE))return;B.info(`[CTRL_PROXY] Found legacy package ${M0.LEGACY_PACKAGE}, uninstalling`),await this.adb.executeCommand(`shell pm uninstall ${M0.LEGACY_PACKAGE}`),B.info("[CTRL_PROXY] Legacy package uninstalled")}catch($){B.warn(`[CTRL_PROXY] Failed to check/uninstall legacy package: ${$}`)}}async install($){try{B.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"))B.warn("Installation result unclear",{result:J.toString()});B.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 B.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{B.info("Enabling Accessibility Service via settings commands");let J=w0();J.startOperation("readCurrentServices");let X=await this.adb.executeCommand("shell settings get secure enabled_accessibility_services");J.endOperation("readCurrentServices");let W=X.stdout.trim();if(W==="null"||W==="")W="";let Y=`${M0.PACKAGE}/${M0.PACKAGE}.CtrlProxy`;if(J.startOperation("writeServiceEnabled"),W.includes(Y))B.info("Accessibility Service is already enabled");else{let G=W?`${W}:${Y}`:Y;await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${G}"`),B.info("Added AutoMobile service to enabled_accessibility_services")}await this.adb.executeCommand("shell settings put secure accessibility_enabled 1"),J.endOperation("writeServiceEnabled"),B.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),W=X.toLowerCase();if(W.includes("permission denied")||W.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(W.includes("device not found")||W.includes("no devices")||W.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(W.includes("timeout")||W.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 B.error("[CTRL_PROXY] "+J,{capabilities:$}),Error(J)}try{B.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===""){B.info("No accessibility services enabled");return}let W=X.split(":"),Y=W.filter((G)=>!G.includes(M0.PACKAGE));if(Y.length===W.length)B.info("Accessibility Service was not enabled");else{let G=Y.join(":");if(await this.adb.executeCommand(`shell settings put secure enabled_accessibility_services "${G}"`),B.info("Removed AutoMobile service from enabled_accessibility_services"),Y.length===0||Y.length===1&&Y[0]==="")await this.adb.executeCommand("shell settings put secure accessibility_enabled 0"),B.info("Disabled accessibility globally (no other services remain)")}B.info("Accessibility Service disabled successfully via settings"),this.clearAvailabilityCache()}catch(J){let X=J instanceof Error?J.message:String(J),W=X.toLowerCase();if(W.includes("permission denied")||W.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(W.includes("device not found")||W.includes("no devices")||W.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(W.includes("timeout")||W.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 B.error("[CTRL_PROXY] "+X,{capabilities:J}),Error(X)}try{B.info(`[CTRL_PROXY] Enabling Accessibility Service via settings commands for user ${$}`);let W=(await this.adb.executeCommand(`shell settings --user ${$} get secure enabled_accessibility_services`)).stdout.trim();if(W==="null"||W==="")W="";let Y=`${M0.PACKAGE}/${M0.PACKAGE}.CtrlProxy`;if(W.includes(Y))B.info(`[CTRL_PROXY] Accessibility Service is already enabled for user ${$}`);else{let G=W?`${W}:${Y}`:Y;await this.adb.executeCommand(`shell settings --user ${$} put secure enabled_accessibility_services "${G}"`),B.info(`[CTRL_PROXY] Added AutoMobile service to enabled_accessibility_services for user ${$}`)}await this.adb.executeCommand(`shell settings --user ${$} put secure accessibility_enabled 1`),B.info(`[CTRL_PROXY] Accessibility Service enabled successfully via settings for user ${$}`),this.clearAvailabilityCache(),this.getAccessibilityDetector().invalidateCache(this.device.deviceId)}catch(X){let W=X instanceof Error?X.message:String(X),Y=W.toLowerCase();if(Y.includes("permission denied")||Y.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: ${W}`);else if(Y.includes("device not found")||Y.includes("no devices")||Y.includes("offline"))throw Error(`Device connection lost while enabling Accessibility Service for user ${$}. Ensure the device is connected and adb is responsive. Original error: ${W}`);else if(Y.includes("timeout")||Y.includes("timed out"))throw Error(`Timeout while enabling Accessibility Service for user ${$}. The device may be unresponsive. Original error: ${W}`);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: ${W}`)}}async cleanupApk($){try{let J=P5.resolve(Ui.tmpdir()),X=P5.resolve(P5.dirname($)),W=P5.basename(X),Y=P5.relative(J,X),G=Boolean(Y)&&!Y.startsWith("..")&&!P5.isAbsolute(Y)&&W.startsWith("auto-mobile-");if(await F5.rm($,{force:!0}),G)await F5.rm(X,{recursive:!0,force:!0}),B.info("Temporary APK directory cleaned up",{path:X});else B.info("Temporary APK file cleaned up",{path:$})}catch(J){B.warn("Failed to clean up temporary APK file",{path:$,error:J instanceof Error?J.message:String(J)})}}async setup($=!1,J=new N$){J.serial("a11yServiceSetup");let X=null;if(this.attemptedAutomatedSetup){try{let[W,Y]=await J.track("recheckStatus",async()=>{return Promise.all([this.isInstalled(),this.isEnabled()])});if(W&&Y)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()}}catch(W){B.warn(`[CTRL_PROXY] Failed to re-check service status: ${W}`)}return J.end(),{success:!1,message:"Setup already attempted",perfTiming:J.getTimings()}}try{let W=await J.track("ensureCompatibleVersion",()=>this.ensureCompatibleVersion());if(W.status==="failed")return J.end(),{success:!1,message:"Failed to ensure compatible Accessibility Service version",error:W.error||W.upgradeError||W.reinstallError,perfTiming:J.getTimings()};if(W.status==="upgraded"||W.status==="installed"||W.status==="reinstalled")return J.end(),{success:!0,message:"Accessibility Service upgraded to a compatible version",perfTiming:J.getTimings()};let Y=await J.track("checkInstalled",()=>this.isInstalled()),G=await J.track("checkEnabled",()=>this.isEnabled());if(!$&&Y&&G)return J.end(),{success:!0,message:"Accessibility Service was already installed and has been activated",perfTiming:J.getTimings()};if(this.attemptedAutomatedSetup=!0,$||!Y)X=await J.track("downloadApk",()=>this.downloadApk()),await J.track("installApk",()=>this.install(X));if(!G)await J.track("enableService",()=>this.enable());return J.end(),{success:!0,message:"Accessibility Service installed and activated successfully",perfTiming:J.getTimings()}}catch(W){let Y=W instanceof Error?W.message:String(W),G=Y.toLowerCase(),Q="Failed to setup Accessibility Service";if(G.includes("permission denied")||G.includes("not permitted"))Q="Failed to setup Accessibility Service due to permission error";else if(G.includes("device not found")||G.includes("no devices")||G.includes("offline"))Q="Failed to setup Accessibility Service due to device connection issue";else if(G.includes("timeout")||G.includes("timed out"))Q="Failed to setup Accessibility Service due to timeout";else if(G.includes("download")||G.includes("network")||G.includes("unreachable"))Q="Failed to setup Accessibility Service due to network/download error";else if(G.includes("not supported"))Q="Failed to setup Accessibility Service - settings toggle not supported on this device";else if(G.includes("installation failed")||G.includes("install"))Q="Failed to setup Accessibility Service due to APK installation error";return J.end(),{success:!1,message:Q,error:Y,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 W=(await this.adb.executeCommand("shell getprop ro.product.model",void 0,void 0,!0)).stdout.trim().toLowerCase();return[W.includes("emulator")||W.includes("sdk"),!1]}catch($){return B.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 B.warn("[CTRL_PROXY] Error getting API level",{error:$}),[null,!0]}}async canUseSettingsToggle(){return(await this.getToggleCapabilities()).supportsSettingsToggle}async getToggleCapabilities(){if(this.cachedToggleCapabilities)return B.info("[CTRL_PROXY] Using cached toggle capabilities"),this.cachedToggleCapabilities;B.info("[CTRL_PROXY] Detecting toggle capabilities");let[$,J]=await this.isEmulator(),[X,W]=await this.getApiLevel(),Y=$?"emulator":"physical",G=!1,Q,q=J||W;if(q)G=!1,Q="Unable to detect device capabilities due to transient error. Retry may succeed.",B.warn("[CTRL_PROXY] Detection error - not caching result",{emulatorDetectionError:J,apiLevelDetectionError:W});else if($)G=!0,B.info("[CTRL_PROXY] Emulator detected - settings toggle supported");else G=!1,Q="Physical devices may require root, device owner status, or special shell permissions for programmatic accessibility toggle",B.info("[CTRL_PROXY] Physical device detected - settings toggle may not be supported",{reason:Q});if(!q&&X!==null&&X<16)G=!1,Q=`API level ${X} is too old (requires API 16+)`,B.warn("[CTRL_PROXY] API level too old for settings toggle",{apiLevel:X});let H={supportsSettingsToggle:G,deviceType:Y,apiLevel:X,reason:Q};if(!q)this.cachedToggleCapabilities=H,B.info("[CTRL_PROXY] Toggle capabilities detected and cached",H);else B.info("[CTRL_PROXY] Toggle capabilities detected but not cached due to detection errors",H);return H}async getInstalledApkSha256WithDetails(){let $=await this.getInstalledApkPath();if(!$)return{sha256:null,source:"none",error:"Installed APK path not found"};try{let G=(await this.adb.executeCommand(`shell sha256sum "${$}"`)).stdout.trim().split(/\s+/)[0];if(G)return{sha256:G,source:"device",apkPath:$}}catch(Y){B.warn("[CTRL_PROXY] sha256sum unavailable or failed, falling back to host hash",{error:Y instanceof Error?Y.message:String(Y)})}let J=await F5.mkdtemp(P5.join(Ui.tmpdir(),"auto-mobile-apk-")),X=(this.device.deviceId||"device").replace(/[^a-zA-Z0-9_.-]/g,"_"),W=P5.join(J,`control-proxy-installed-${X}.apk`);try{await this.adb.executeCommand(`pull "${$}" "${W}"`);let Y=await F5.readFile(W);return{sha256:yg0.createHash("sha256").update(Y).digest("hex"),source:"host",apkPath:$}}catch(Y){return{sha256:null,source:"none",apkPath:$,error:Y instanceof Error?Y.message:String(Y)}}finally{try{await F5.rm(J,{recursive:!0,force:!0})}catch{}}}async getInstalledApkPath(){try{let J=(await this.adb.executeCommand(`shell pm path ${M0.PACKAGE}`,void 0,void 0,!0)).stdout.split(`
97
97
  `).map((X)=>X.trim()).find((X)=>X.startsWith("package:"));if(!J)return null;return J.replace("package:","").trim()||null}catch($){return B.warn("[CTRL_PROXY] Failed to resolve installed APK path",{error:$ instanceof Error?$.message:String($)}),null}}getExpectedChecksum(){if(this.shouldSkipChecksum())return"";return M0.expectedChecksumOverride??EV(YW,"android")}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?J:null}shouldSkipChecksum(){let $=process.env.AUTOMOBILE_SKIP_ACCESSIBILITY_CHECKSUM??process.env.AUTO_MOBILE_ACCESSIBILITY_SERVICE_SHA_SKIP_CHECK;if($&&($==="1"||$.toLowerCase()==="true"))return!0;return this.getApkPathOverride()!==null}shouldSkipDownloadIfInstalled(){let $=process.env.AUTOMOBILE_SKIP_ACCESSIBILITY_DOWNLOAD_IF_INSTALLED;return Boolean($&&($==="1"||$.toLowerCase()==="true"))}}});import*as zi from"fs/promises";class zH${fileDownloader;checksumCalculator;constructor($=new mZ,J=new lZ){this.fileDownloader=$,this.checksumCalculator=J}async download($,J){return this.fileDownloader.download($,J)}async computeFileSha256($){return this.checksumCalculator.computeFileSha256($)}async extractBundle($,J){await zi.rm(J,{recursive:!0,force:!0}),await zi.mkdir(J,{recursive:!0}),new mg$.default($).extractAllTo(J,!0)}}var mg$;var lg$=E(()=>{VH$();jH$();mg$=W5(ji(),1)});import{createHash as gg0}from"crypto";import{promises as BH$}from"fs";import{join as cg$,relative as ug0}from"path";var mg0,lg0=($)=>$==="_CodeSignature"||$==="SC_Info",cg0=($)=>$==="embedded.mobileprovision"||$==="PkgInfo"||$.endsWith(".xcent"),pg0=($)=>{let J=$.split("/").filter(Boolean);if(J.some((W)=>lg0(W)))return!0;let X=J[J.length-1]??"";return cg0(X)},pg$=async($,J,X,W)=>{let Y=await X.readDir(J);Y.sort();for(let G of Y){let Q=cg$(J,G),q=await X.stat(Q),H=ug0($,Q).replace(/\\/g,"/");if(pg0(H))continue;if(q.isDirectory())await pg$($,Q,X,W);else if(q.isFile())W.push(H)}},cZ=async($,J=mg0)=>{let X=gg0("sha256"),W=[];await pg$($,$,J,W),W.sort();for(let Y of W){let G=cg$($,Y);X.update(Y),X.update("\x00");let Q=await J.readFile(G);X.update(Q),X.update("\x00")}return X.digest("hex")};var KH$=E(()=>{mg0={readDir:async($)=>BH$.readdir($),stat:async($)=>BH$.stat($),readFile:async($)=>BH$.readFile($)}});import*as l8 from"fs/promises";import*as C9 from"path";import ng0 from"os";var j1;var wH$=E(()=>{e();E$();c0();LO();lg$();KH$();j1=class j1{static DEFAULT_PROJECT_ROOT=process.cwd();static DEFAULT_DERIVED_DATA_PATH="/tmp/automobile-ctrl-proxy";static DEFAULT_SCHEME="CtrlProxyApp";static DEFAULT_DESTINATION="generic/platform=iOS Simulator";static DEFAULT_BUNDLE_CACHE_DIR=C9.join(ng0.homedir(),".automobile","ctrl-proxy-ios");static DEFAULT_BUNDLE_FILENAME="control-proxy.ipa";static METADATA_FILENAME="ctrl-proxy-ios-bundle.json";static MIN_BUNDLE_SIZE_BYTES=1e4;static prefetchPromise=null;static prefetchResult=null;static prefetchError=null;static expectedChecksumOverride=null;static timer=c;static instances=new Map;config;downloader;cachedBuildProductsPath=new Map;cachedXctestrunPath=new Map;cachedAppBundleHash=new Map;constructor($={},J={}){this.config={projectRoot:$.projectRoot||process.env.AUTOMOBILE_PROJECT_ROOT||j1.DEFAULT_PROJECT_ROOT,derivedDataPath:$.derivedDataPath||process.env.AUTOMOBILE_CTRL_PROXY_IOS_DERIVED_DATA||j1.DEFAULT_DERIVED_DATA_PATH,scheme:$.scheme||j1.DEFAULT_SCHEME,destination:$.destination||j1.DEFAULT_DESTINATION,bundleCacheDir:$.bundleCacheDir||process.env.AUTOMOBILE_CTRL_PROXY_IOS_CACHE_DIR||j1.DEFAULT_BUNDLE_CACHE_DIR},this.downloader=J.downloader??new zH$}static getInstance($,J){let X=JSON.stringify({config:$||{},deps:J?.downloader?"custom":"default"});if(!j1.instances.has(X))j1.instances.set(X,new j1($,J));return j1.instances.get(X)}static resetInstances(){j1.instances.clear(),j1.prefetchPromise=null,j1.prefetchResult=null,j1.prefetchError=null,j1.expectedChecksumOverride=null,j1.timer=c}static setTimerForTesting($){j1.timer=$}static setExpectedChecksumForTesting($){j1.expectedChecksumOverride=$}async getBuildProductsPath($="simulator"){let J=this.cachedBuildProductsPath.get($);if(J)try{return await l8.access(J),J}catch{this.cachedBuildProductsPath.set($,null)}let X=C9.join(this.config.derivedDataPath,"Build","Products",$==="device"?"Debug-iphoneos":"Debug-iphonesimulator");try{return await l8.access(X),this.cachedBuildProductsPath.set($,X),X}catch{return null}}async getXctestrunPath($){let J=$||"any",X=this.cachedXctestrunPath.get(J);if(X)try{return await l8.access(X),X}catch{this.cachedXctestrunPath.set(J,null)}let W=C9.join(this.config.derivedDataPath,"Build","Products");try{let G=(await l8.readdir(W)).filter((j)=>j.endsWith(".xctestrun"));if(G.length===0)return null;let Q=$==="device"?"iphoneos":"iphonesimulator",q=$?G.filter((j)=>j.includes(Q)):G;if(q.length===0)return null;let H;if(q.length===1)H=q[0];else{let j=await Promise.all(q.map(async(U)=>{let z=C9.join(W,U),K=await l8.stat(z);return{file:U,mtime:K.mtimeMs}}));j.sort((U,z)=>z.mtime-U.mtime),H=j[0].file}let V=C9.join(W,H);return this.cachedXctestrunPath.set(J,V),V}catch{return null}}async cleanStaleXctestrunFiles(){let $=C9.join(this.config.derivedDataPath,"Build","Products");try{let X=(await l8.readdir($)).filter((W)=>W.endsWith(".xctestrun"));if(X.length<=1)return;for(let W of["iphonesimulator","iphoneos"]){let Y=X.filter((Q)=>Q.includes(W));if(Y.length<=1)continue;let G=await Promise.all(Y.map(async(Q)=>{let q=C9.join($,Q),H=await l8.stat(q);return{file:Q,filePath:q,mtime:H.mtimeMs}}));G.sort((Q,q)=>q.mtime-Q.mtime);for(let Q of G.slice(1))B.info(`[IOSCtrlProxyBuilder] Removing stale xctestrun file: ${Q.file}`),await l8.rm(Q.filePath)}}catch(J){B.warn(`[IOSCtrlProxyBuilder] Failed to clean stale xctestrun files: ${J instanceof Error?J.message:String(J)}`)}}async needsRebuild($){if(process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="true"||process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="1")return B.info("[IOSCtrlProxyBuilder] Download skipped via AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD"),!1;if(!await this.getXctestrunPath($))return B.info("[IOSCtrlProxyBuilder] CtrlProxy artifacts missing, need download"),!0;let X=await this.readBundleMetadata(),W=this.getExpectedChecksum();if(W.length>0){if(!X||X.checksum?.toLowerCase()!==W.toLowerCase())return B.info("[IOSCtrlProxyBuilder] CtrlProxy checksum mismatch, need download"),!0}else if(!X)return B.info("[IOSCtrlProxyBuilder] CtrlProxy metadata missing, need download"),!0;if($){let Y=this.getExpectedAppHash($);if(Y){let G=await this.getAppBundleHash($);if(!G||G.toLowerCase()!==Y.toLowerCase())return B.info("[IOSCtrlProxyBuilder] CtrlProxy app hash mismatch, need download"),!0;if(!X?.appHashes?.[$])return B.info("[IOSCtrlProxyBuilder] CtrlProxy app hash missing from metadata, need download"),!0}}return B.info("[IOSCtrlProxyBuilder] CtrlProxy artifacts are up to date"),!1}async build($,J=new N$){if(J.serial("xcTestServiceDownload"),process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="true"||process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="1")return J.end(),{success:!1,message:"CtrlProxy download skipped",error:"AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD is set"};try{let{bundlePath:X,usedCachedFallback:W}=await J.track("downloadBundle",()=>this.ensureBundleDownloaded());if(!W)await J.track("extractBundle",()=>this.extractBundle(X));this.cachedBuildProductsPath.clear(),this.cachedXctestrunPath.clear(),this.cachedAppBundleHash.clear(),await this.cleanStaleXctestrunFiles();let Y=await this.getBuildProductsPath($??"simulator"),G=await this.getXctestrunPath($);if(!G)return J.end(),{success:!1,message:"Downloaded CtrlProxy bundle missing xctestrun",error:"No .xctestrun file found after extraction"};return J.end(),{success:!0,message:"CtrlProxy downloaded and extracted successfully",buildPath:Y||void 0,xctestrunPath:G||void 0}}catch(X){let W=X instanceof Error?X.message:String(X);return B.error("[IOSCtrlProxyBuilder] Download failed:",W),J.end(),{success:!1,message:"CtrlProxy download failed",error:W}}}static prefetchBuild(){if(process.platform!=="darwin"){B.info("[IOSCtrlProxyBuilder] Prefetch skipped (not macOS)");return}if(j1.prefetchPromise!==null){B.info("[IOSCtrlProxyBuilder] Prefetch already initiated, skipping");return}if(process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="true"||process.env.AUTOMOBILE_SKIP_CTRL_PROXY_IOS_BUILD==="1"){B.info("[IOSCtrlProxyBuilder] Prefetch skipped via environment variable");return}B.info("[IOSCtrlProxyBuilder] Starting download prefetch");let $=j1.timer.now();j1.prefetchPromise=j1.doPrefetch().then((J)=>{let X=j1.timer.now()-$;if(J&&J.success)j1.prefetchResult=J,B.info(`[IOSCtrlProxyBuilder] Prefetch completed in ${X}ms`,{buildPath:J.buildPath});else B.info(`[IOSCtrlProxyBuilder] Prefetch skipped or failed in ${X}ms`,{message:J?.message});return J}).catch((J)=>{let X=j1.timer.now()-$;return j1.prefetchError=J instanceof Error?J:Error(String(J)),B.warn(`[IOSCtrlProxyBuilder] Prefetch failed after ${X}ms`,{error:j1.prefetchError.message}),null})}static async doPrefetch(){let $=j1.getInstance();if(!await $.needsRebuild()){let X=await $.getBuildProductsPath(),W=await $.getXctestrunPath();return{success:!0,message:"CtrlProxy artifacts are up to date",buildPath:X||void 0,xctestrunPath:W||void 0}}return $.build()}static async waitForPrefetch(){if(j1.prefetchPromise===null)return null;try{return await j1.prefetchPromise,j1.prefetchResult}catch{return null}}static getPrefetchedResult(){return j1.prefetchResult}static getPrefetchError(){return j1.prefetchError}async cleanBuildArtifacts(){try{await l8.rm(this.config.derivedDataPath,{recursive:!0,force:!0}),this.cachedBuildProductsPath.clear(),this.cachedXctestrunPath.clear(),this.cachedAppBundleHash.clear(),B.info("[IOSCtrlProxyBuilder] Build artifacts cleaned up")}catch($){B.warn("[IOSCtrlProxyBuilder] Failed to clean build artifacts:",$)}}getConfig(){return{...this.config}}async getAppBundlePath($="simulator"){let J=await this.getBuildProductsPath($);if(!J)return null;let X=C9.join(J,"CtrlProxyApp.app");try{return await l8.access(X),X}catch{return null}}async getAppBundleHash($="simulator"){let J=this.cachedAppBundleHash.get($);if(J)return J;let X=await this.getAppBundlePath($);if(!X)return null;try{let W=await cZ(X);return this.cachedAppBundleHash.set($,W),W}catch{return null}}async getRunnerBinaryPath($="simulator"){let J=await this.getBuildProductsPath($);if(!J)return null;let X=C9.join(J,"CtrlProxyUITests-Runner.app","CtrlProxyUITests-Runner");try{return await l8.access(X),X}catch{return null}}getBundlePath(){return C9.join(this.config.bundleCacheDir,j1.DEFAULT_BUNDLE_FILENAME)}getBundleUrl(){let $=process.env.AUTOMOBILE_CTRL_PROXY_IOS_BUNDLE_URL?.trim();if($)return $;return Gi}getBundlePathOverride(){let $=process.env.AUTOMOBILE_CTRL_PROXY_IOS_IPA_PATH?.trim()||process.env.AUTOMOBILE_CTRL_PROXY_IOS_BUNDLE_PATH?.trim();return $&&$.length>0?$:null}getExpectedChecksum(){let $=j1.expectedChecksumOverride;if($!==null)return $;return Wg$}getExpectedAppHash($){let J=$.toUpperCase(),X=process.env[`AUTOMOBILE_IOS_CTRL_PROXY_APP_HASH_${J}`];if(X&&X.trim().length>0)return X.trim();if($==="device"){let W=process.env.AUTOMOBILE_IOS_CTRL_PROXY_APP_HASH??process.env.AUTOMOBILE_IOS_IOS_CTRL_PROXY_APP_HASH;if(W&&W.trim().length>0)return W.trim();return Qi}return""}async ensureBundleDownloaded(){await l8.mkdir(this.config.bundleCacheDir,{recursive:!0});let $=this.getBundlePath(),J=this.getBundlePathOverride();if(J){if(B.info("[IOSCtrlProxyBuilder] Using local CtrlProxy bundle override",{path:J}),!(await l8.stat(J)).isFile())throw Error(`CtrlProxy bundle override is not a file: ${J}`);await l8.copyFile(J,$)}else{let X=this.getExpectedChecksum();if(!await this.isBundleValid($,X)){let Y=Jz.trim().toLowerCase()===Yi,G=await this.isBundleValid($,"");try{B.info("[IOSCtrlProxyBuilder] Downloading CtrlProxy bundle",{url:this.getBundleUrl(),destination:$,reason:"checksum-mismatch-or-missing"}),await this.downloader.download(this.getBundleUrl(),$)}catch(Q){if(Y&&G)return B.warn(`[IOSCtrlProxyBuilder] Download failed, using cached bundle: ${Q instanceof Error?Q.message:String(Q)}`),{bundlePath:$,usedCachedFallback:!0};throw Q}}}return await this.verifyBundle($),{bundlePath:$,usedCachedFallback:!1}}async isBundleValid($,J){try{let W=await l8.stat($);if(!W.isFile()||W.size<j1.MIN_BUNDLE_SIZE_BYTES)return!1}catch{return!1}if(!J)return!0;let{checksum:X}=await this.downloader.computeFileSha256($);return X.toLowerCase()===J.toLowerCase()}async verifyBundle($){let J=await l8.stat($);if(J.size<j1.MIN_BUNDLE_SIZE_BYTES)throw Error(`Downloaded bundle is too small (${J.size} bytes), likely invalid`);let X=this.getExpectedChecksum();if(X.length>0){let{checksum:W,source:Y}=await this.downloader.computeFileSha256($);if(W.toLowerCase()!==X.toLowerCase())throw Error(`CtrlProxy checksum verification failed. Expected: ${X}, Got: ${W}`);B.info("[IOSCtrlProxyBuilder] Bundle checksum verified",{checksum:W,source:Y})}else B.warn("[IOSCtrlProxyBuilder] Bundle checksum verification skipped (no checksum provided)")}async extractBundle($){await this.downloader.extractBundle($,this.config.derivedDataPath),await this.normalizeExtractedBundle(),await this.verifyExtractedArtifacts();let J=await this.computeAppHashes(),X={checksum:this.getExpectedChecksum()||null,version:gZ(Jz),extractedAt:new Date().toISOString(),appHashes:J};await l8.writeFile(this.getMetadataPath(),JSON.stringify(X,null,2),"utf-8")}async readBundleMetadata(){try{let $=await l8.readFile(this.getMetadataPath(),"utf-8");return JSON.parse($)}catch{return null}}getMetadataPath(){return C9.join(this.config.bundleCacheDir,j1.METADATA_FILENAME)}async normalizeExtractedBundle(){let $=await this.findXctestrunFiles(this.config.derivedDataPath);if($.length===0)throw Error("No .xctestrun file found in extracted CtrlProxy bundle");let J=this.resolveDerivedDataRoot($[0]);if(!J)return;if(J===this.config.derivedDataPath)return;let X=C9.join(J,"Build"),W=C9.join(this.config.derivedDataPath,"Build");await l8.rm(W,{recursive:!0,force:!0}),await l8.mkdir(this.config.derivedDataPath,{recursive:!0});try{await l8.rename(X,W)}catch{await l8.cp(X,W,{recursive:!0}),await l8.rm(X,{recursive:!0,force:!0})}}async verifyExtractedArtifacts(){let $=await this.getXctestrunPath("simulator"),J=await this.getXctestrunPath("device");if(!$&&!J)throw Error("Extracted CtrlProxy bundle missing .xctestrun file");if($)await this.verifyPlatformArtifacts("simulator");if(J)await this.verifyPlatformArtifacts("device")}async verifyPlatformArtifacts($){let J=await this.getBuildProductsPath($);if(!J)throw Error(`CtrlProxy build products missing for ${$}`);let X=[C9.join(J,"CtrlProxyApp.app"),C9.join(J,"CtrlProxyUITests-Runner.app"),C9.join(J,"CtrlProxyTests.xctest")];for(let Y of X)try{await l8.access(Y)}catch{throw Error(`CtrlProxy bundle missing required artifact: ${Y}`)}let W=this.getExpectedAppHash($);if(W){let Y=await this.getAppBundleHash($);if(!Y)throw Error(`CtrlProxy app hash unavailable for ${$}`);if(Y.toLowerCase()!==W.toLowerCase())throw Error(`CtrlProxy app hash mismatch for ${$}. Expected: ${W}, Got: ${Y}`);B.info("[IOSCtrlProxyBuilder] App bundle hash verified",{platform:$,hash:Y})}else B.warn(`[IOSCtrlProxyBuilder] App bundle hash verification skipped for ${$} (no hash provided)`);if($==="simulator"){let Y=Yg$;if(Y&&Y.length>0){let G=await this.getRunnerBinaryPath($);if(!G)throw Error(`CtrlProxy runner binary missing for ${$}`);let{checksum:Q}=await this.downloader.computeFileSha256(G);if(Q.toLowerCase()!==Y.toLowerCase())throw Error(`CtrlProxy runner binary SHA256 mismatch for ${$}. Expected: ${Y}, Got: ${Q}`);B.info("[IOSCtrlProxyBuilder] Runner binary SHA256 verified",{platform:$,checksum:Q})}else B.warn(`[IOSCtrlProxyBuilder] Runner binary SHA256 verification skipped for ${$} (no hash provided)`)}}async computeAppHashes(){let $={},J=await this.getAppBundleHash("simulator");if(J)$.simulator=J;let X=await this.getAppBundleHash("device");if(X)$.device=X;return $}resolveDerivedDataRoot($){let J=C9.resolve($).split(C9.sep);for(let X=0;X<J.length-1;X++)if(J[X]==="Build"&&J[X+1]==="Products")return J.slice(0,X).join(C9.sep);return null}async findXctestrunFiles($){let J=[],X=[$];while(X.length>0){let W=X.pop();if(!W)continue;let Y;try{Y=await l8.readdir(W,{withFileTypes:!0})}catch{continue}for(let G of Y){let Q=C9.join(W,G.name);if(G.isDirectory())X.push(Q);else if(G.isFile()&&G.name.endsWith(".xctestrun"))J.push(Q)}}return J}}});var HX;var Bi=E(()=>{e();HX=class HX{static allocatedPorts=new Map;static DEFAULT_BASE_PORT=8765;static DEFAULT_MAX_DEVICES=100;static basePort=HX.resolveBasePort();static maxDevices=HX.resolveMaxDevices();static allocate($){if(this.allocatedPorts.has($))return this.allocatedPorts.get($);let J=new Set(this.allocatedPorts.values());for(let X=0;X<this.maxDevices;X++){let W=this.basePort+X;if(!J.has(W))return this.allocatedPorts.set($,W),B.info(`[PortManager] Allocated port ${W} for device ${$}`),W}throw Error(`No available ports for device ${$}. All ${this.maxDevices} ports (${this.basePort}-${this.basePort+this.maxDevices-1}) are in use.`)}static release($){let J=this.allocatedPorts.get($);if(J!==void 0)this.allocatedPorts.delete($),B.info(`[PortManager] Released port ${J} for device ${$}`)}static getPort($){return this.allocatedPorts.get($)}static getWebSocketUrl($){return`ws://localhost:${this.allocate($)}/ws`}static getAllocatedCount(){return this.allocatedPorts.size}static getAllocations(){return new Map(this.allocatedPorts)}static reset(){let $=this.allocatedPorts.size;this.allocatedPorts.clear(),B.info(`[PortManager] Reset all port allocations (cleared ${$} allocations)`)}static getBasePort(){return this.basePort}static DEVICE_PORT=8765;static resolveBasePort(){let $=process.env.AUTOMOBILE_PORT_RANGE_START??process.env.AUTO_MOBILE_PORT_RANGE_START;if(!$)return this.DEFAULT_BASE_PORT;let J=Number.parseInt($,10);if(Number.isNaN(J)||J<=0)return B.warn(`[PortManager] Invalid port range start '${$}', using default ${this.DEFAULT_BASE_PORT}`),this.DEFAULT_BASE_PORT;return J}static resolveMaxDevices(){let $=process.env.AUTOMOBILE_PORT_RANGE_END??process.env.AUTO_MOBILE_PORT_RANGE_END;if($){let W=Number.parseInt($,10);if(!Number.isNaN(W)&&W>=this.basePort)return W-this.basePort+1;return B.warn(`[PortManager] Invalid port range end '${$}', using default ${this.DEFAULT_MAX_DEVICES}`),this.DEFAULT_MAX_DEVICES}let J=process.env.AUTOMOBILE_PORT_RANGE_SIZE??process.env.AUTO_MOBILE_PORT_RANGE_SIZE;if(!J)return this.DEFAULT_MAX_DEVICES;let X=Number.parseInt(J,10);if(Number.isNaN(X)||X<=0)return B.warn(`[PortManager] Invalid port range size '${J}', using default ${this.DEFAULT_MAX_DEVICES}`),this.DEFAULT_MAX_DEVICES;return X}}});import{exec as dg0,spawn as ig0}from"child_process";import{promisify as og0}from"util";class OO{async exec($,J={}){let{stdout:X,stderr:W}=await rg0($,{timeout:J.timeoutMs,maxBuffer:J.maxBuffer,cwd:J.cwd});return ag0(X,W)}spawn($,J,X){return ig0($,J,X)}}var rg0,ag0=($,J)=>{let X=typeof $==="string"?$:$.toString(),W=typeof J==="string"?J:J.toString();return{stdout:X,stderr:W,toString(){return X},trim(){return X.trim()},includes(Y){return X.includes(Y)}}};var Ki=E(()=>{rg0=og0(dg0)});var wi=h((ng$)=>{(function(){ng$.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:`
98
98
  `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(ng$)});var SV=h((dg$,zK)=>{(function(){var $,J,X,W,Y,G,Q,q=[].slice,H={}.hasOwnProperty;$=function(){var V,j,U,z,K,w;if(w=arguments[0],K=2<=arguments.length?q.call(arguments,1):[],Y(Object.assign))Object.assign.apply(null,arguments);else for(V=0,U=K.length;V<U;V++)if(z=K[V],z!=null)for(j in z){if(!H.call(z,j))continue;w[j]=z[j]}return w},Y=function(V){return!!V&&Object.prototype.toString.call(V)==="[object Function]"},G=function(V){var j;return!!V&&((j=typeof V)==="function"||j==="object")},X=function(V){if(Y(Array.isArray))return Array.isArray(V);else return Object.prototype.toString.call(V)==="[object Array]"},W=function(V){var j;if(X(V))return!V.length;else{for(j in V){if(!H.call(V,j))continue;return!1}return!0}},Q=function(V){var j,U;return G(V)&&(U=Object.getPrototypeOf(V))&&(j=U.constructor)&&typeof j==="function"&&j instanceof j&&Function.prototype.toString.call(j)===Function.prototype.toString.call(Object)},J=function(V){if(Y(V.valueOf))return V.valueOf();else return V},dg$.assign=$,dg$.isFunction=Y,dg$.isObject=G,dg$.isArray=X,dg$.isEmpty=W,dg$.isPlainObject=Q,dg$.getValue=J}).call(dg$)});var LH$=h((ig$,og$)=>{(function(){var $;og$.exports=$=function(){function J(){}return J.prototype.hasFeature=function(X,W){return!0},J.prototype.createDocumentType=function(X,W,Y){throw Error("This DOM method is not implemented.")},J.prototype.createDocument=function(X,W,Y){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,W){throw Error("This DOM method is not implemented.")},J}()}).call(ig$)});var tg$=h((rg$,ag$)=>{(function(){var $;ag$.exports=$=function(){function J(){}return J.prototype.handleError=function(X){throw Error(X)},J}()}).call(rg$)});var $u$=h((sg$,eg$)=>{(function(){var $;eg$.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(sg$)});var Wu$=h((Ju$,Xu$)=>{(function(){var $,J,X;J=tg$(),X=$u$(),Xu$.exports=$=function(){function W(){var Y;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=Y=Object.create(this.defaultParams)}return Object.defineProperty(W.prototype,"parameterNames",{get:function(){return new X(Object.keys(this.defaultParams))}}),W.prototype.getParameter=function(Y){if(this.params.hasOwnProperty(Y))return this.params[Y];else return null},W.prototype.canSetParameter=function(Y,G){return!0},W.prototype.setParameter=function(Y,G){if(G!=null)return this.params[Y]=G;else return delete this.params[Y]},W}()}).call(Ju$)});var N5=h((Yu$,Gu$)=>{(function(){Gu$.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(Yu$)});var MH$=h((Qu$,qu$)=>{(function(){var $,J,X;$=N5(),X=nY(),qu$.exports=J=function(){function W(Y,G,Q){if(this.parent=Y,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(G==null)throw Error("Missing attribute name. "+this.debugInfo(G));this.name=this.stringify.name(G),this.value=this.stringify.attValue(Q),this.type=$.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(W.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(W.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(W.prototype,"textContent",{get:function(){return this.value},set:function(Y){return this.value=Y||""}}),Object.defineProperty(W.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(W.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(W.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(W.prototype,"specified",{get:function(){return!0}}),W.prototype.clone=function(){return Object.create(this)},W.prototype.toString=function(Y){return this.options.writer.attribute(this,this.options.writer.filterOptions(Y))},W.prototype.debugInfo=function(Y){if(Y=Y||this.name,Y==null)return"parent: <"+this.parent.name+">";else return"attribute: {"+Y+"}, parent: <"+this.parent.name+">"},W.prototype.isEqualNode=function(Y){if(Y.namespaceURI!==this.namespaceURI)return!1;if(Y.prefix!==this.prefix)return!1;if(Y.localName!==this.localName)return!1;if(Y.value!==this.value)return!1;return!0},W}()}).call(Qu$)});var Li=h((Hu$,Vu$)=>{(function(){var $;Vu$.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 W=this.nodes[X.nodeName];return this.nodes[X.nodeName]=X,W||null},J.prototype.removeNamedItem=function(X){var W=this.nodes[X];return delete this.nodes[X],W||null},J.prototype.item=function(X){return this.nodes[Object.keys(this.nodes)[X]]||null},J.prototype.getNamedItemNS=function(X,W){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,W){throw Error("This DOM method is not implemented.")},J}()}).call(Hu$)});var Mi=h((ju$,Uu$)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V=function(U,z){for(var K in z)if(j.call(z,K))U[K]=z[K];function w(){this.constructor=U}return w.prototype=z.prototype,U.prototype=new w,U.__super__=z.prototype,U},j={}.hasOwnProperty;H=SV(),q=H.isObject,Q=H.isFunction,G=H.getValue,Y=nY(),$=N5(),J=MH$(),W=Li(),Uu$.exports=X=function(U){V(z,U);function z(K,w,L){var M,F,A,O;if(z.__super__.constructor.call(this,K),w==null)throw Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(w),this.type=$.Element,this.attribs={},this.schemaTypeInfo=null,L!=null)this.attribute(L);if(K.type===$.Document){if(this.isRoot=!0,this.documentObject=K,K.rootObject=this,K.children){O=K.children;for(F=0,A=O.length;F<A;F++)if(M=O[F],M.type===$.DocType){M.name=this.name;break}}}}return Object.defineProperty(z.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(z.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(z.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(z.prototype,"id",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"className",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"classList",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(z.prototype,"attributes",{get:function(){if(!this.attributeMap||!this.attributeMap.nodes)this.attributeMap=new W(this.attribs);return this.attributeMap}}),z.prototype.clone=function(){var K,w,L,M;if(L=Object.create(this),L.isRoot)L.documentObject=null;L.attribs={},M=this.attribs;for(w in M){if(!j.call(M,w))continue;K=M[w],L.attribs[w]=K.clone()}return L.children=[],this.children.forEach(function(F){var A=F.clone();return A.parent=L,L.children.push(A)}),L},z.prototype.attribute=function(K,w){var L,M;if(K!=null)K=G(K);if(q(K))for(L in K){if(!j.call(K,L))continue;M=K[L],this.attribute(L,M)}else{if(Q(w))w=w.apply();if(this.options.keepNullAttributes&&w==null)this.attribs[K]=new J(this,K,"");else if(w!=null)this.attribs[K]=new J(this,K,w)}return this},z.prototype.removeAttribute=function(K){var w,L,M;if(K==null)throw Error("Missing attribute name. "+this.debugInfo());if(K=G(K),Array.isArray(K))for(L=0,M=K.length;L<M;L++)w=K[L],delete this.attribs[w];else delete this.attribs[K];return this},z.prototype.toString=function(K){return this.options.writer.element(this,this.options.writer.filterOptions(K))},z.prototype.att=function(K,w){return this.attribute(K,w)},z.prototype.a=function(K,w){return this.attribute(K,w)},z.prototype.getAttribute=function(K){if(this.attribs.hasOwnProperty(K))return this.attribs[K].value;else return null},z.prototype.setAttribute=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNode=function(K){if(this.attribs.hasOwnProperty(K))return this.attribs[K];else return null},z.prototype.setAttributeNode=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNode=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNS=function(K,w,L){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.removeAttributeNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getAttributeNodeNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setAttributeNodeNS=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.hasAttribute=function(K){return this.attribs.hasOwnProperty(K)},z.prototype.hasAttributeNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttribute=function(K,w){if(this.attribs.hasOwnProperty(K))return this.attribs[K].isId;else return w},z.prototype.setIdAttributeNS=function(K,w,L){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.setIdAttributeNode=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagName=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByTagNameNS=function(K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.getElementsByClassName=function(K){throw Error("This DOM method is not implemented."+this.debugInfo())},z.prototype.isEqualNode=function(K){var w,L,M;if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(K))return!1;if(K.namespaceURI!==this.namespaceURI)return!1;if(K.prefix!==this.prefix)return!1;if(K.localName!==this.localName)return!1;if(K.attribs.length!==this.attribs.length)return!1;for(w=L=0,M=this.attribs.length-1;0<=M?L<=M:L>=M;w=0<=M?++L:--L)if(!this.attribs[w].isEqualNode(K.attribs[w]))return!1;return!0},z}(Y)}).call(ju$)});var pZ=h((zu$,Bu$)=>{(function(){var $,J,X=function(Y,G){for(var Q in G)if(W.call(G,Q))Y[Q]=G[Q];function q(){this.constructor=Y}return q.prototype=G.prototype,Y.prototype=new q,Y.__super__=G.prototype,Y},W={}.hasOwnProperty;J=nY(),Bu$.exports=$=function(Y){X(G,Y);function G(Q){G.__super__.constructor.call(this,Q),this.value=""}return Object.defineProperty(G.prototype,"data",{get:function(){return this.value},set:function(Q){return this.value=Q||""}}),Object.defineProperty(G.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(G.prototype,"textContent",{get:function(){return this.value},set:function(Q){return this.value=Q||""}}),G.prototype.clone=function(){return Object.create(this)},G.prototype.substringData=function(Q,q){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.appendData=function(Q){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.insertData=function(Q,q){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.deleteData=function(Q,q){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.replaceData=function(Q,q,H){throw Error("This DOM method is not implemented."+this.debugInfo())},G.prototype.isEqualNode=function(Q){if(!G.__super__.isEqualNode.apply(this,arguments).isEqualNode(Q))return!1;if(Q.data!==this.data)return!1;return!0},G}(J)}).call(zu$)});var Oi=h((Ku$,wu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;$=N5(),X=pZ(),wu$.exports=J=function(G){W(Q,G);function Q(q,H){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=$.CData,this.value=this.stringify.cdata(H)}return Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return this.options.writer.cdata(this,this.options.writer.filterOptions(q))},Q}(X)}).call(Ku$)});var Di=h((Lu$,Mu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;$=N5(),J=pZ(),Mu$.exports=X=function(G){W(Q,G);function Q(q,H){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=$.Comment,this.value=this.stringify.comment(H)}return Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return this.options.writer.comment(this,this.options.writer.filterOptions(q))},Q}(J)}).call(Lu$)});var Fi=h((Ou$,Du$)=>{(function(){var $,J,X,W,Y=function(Q,q){for(var H in q)if(G.call(q,H))Q[H]=q[H];function V(){this.constructor=Q}return V.prototype=q.prototype,Q.prototype=new V,Q.__super__=q.prototype,Q},G={}.hasOwnProperty;W=SV().isObject,X=nY(),$=N5(),Du$.exports=J=function(Q){Y(q,Q);function q(H,V,j,U){var z;if(q.__super__.constructor.call(this,H),W(V))z=V,V=z.version,j=z.encoding,U=z.standalone;if(!V)V="1.0";if(this.type=$.Declaration,this.version=this.stringify.xmlVersion(V),j!=null)this.encoding=this.stringify.xmlEncoding(j);if(U!=null)this.standalone=this.stringify.xmlStandalone(U)}return q.prototype.toString=function(H){return this.options.writer.declaration(this,this.options.writer.filterOptions(H))},q}(X)}).call(Ou$)});var Ni=h((Fu$,Nu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;X=nY(),$=N5(),Nu$.exports=J=function(G){W(Q,G);function Q(q,H,V,j,U,z){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing DTD element name. "+this.debugInfo());if(V==null)throw Error("Missing DTD attribute name. "+this.debugInfo(H));if(!j)throw Error("Missing DTD attribute type. "+this.debugInfo(H));if(!U)throw Error("Missing DTD attribute default. "+this.debugInfo(H));if(U.indexOf("#")!==0)U="#"+U;if(!U.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(H));if(z&&!U.match(/^(#FIXED|#DEFAULT)$/))throw Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(H));if(this.elementName=this.stringify.name(H),this.type=$.AttributeDeclaration,this.attributeName=this.stringify.name(V),this.attributeType=this.stringify.dtdAttType(j),z)this.defaultValue=this.stringify.dtdAttDefault(z);this.defaultValueType=U}return Q.prototype.toString=function(q){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(q))},Q}(X)}).call(Fu$)});var Ai=h((Au$,Ru$)=>{(function(){var $,J,X,W,Y=function(Q,q){for(var H in q)if(G.call(q,H))Q[H]=q[H];function V(){this.constructor=Q}return V.prototype=q.prototype,Q.prototype=new V,Q.__super__=q.prototype,Q},G={}.hasOwnProperty;W=SV().isObject,X=nY(),$=N5(),Ru$.exports=J=function(Q){Y(q,Q);function q(H,V,j,U){if(q.__super__.constructor.call(this,H),j==null)throw Error("Missing DTD entity name. "+this.debugInfo(j));if(U==null)throw Error("Missing DTD entity value. "+this.debugInfo(j));if(this.pe=!!V,this.name=this.stringify.name(j),this.type=$.EntityDeclaration,!W(U))this.value=this.stringify.dtdEntityValue(U),this.internal=!0;else{if(!U.pubID&&!U.sysID)throw Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(j));if(U.pubID&&!U.sysID)throw Error("System identifier is required for a public external entity. "+this.debugInfo(j));if(this.internal=!1,U.pubID!=null)this.pubID=this.stringify.dtdPubID(U.pubID);if(U.sysID!=null)this.sysID=this.stringify.dtdSysID(U.sysID);if(U.nData!=null)this.nData=this.stringify.dtdNData(U.nData);if(this.pe&&this.nData)throw Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(j))}}return Object.defineProperty(q.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(q.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(q.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(q.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(q.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(q.prototype,"xmlVersion",{get:function(){return null}}),q.prototype.toString=function(H){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(H))},q}(X)}).call(Au$)});var Ri=h((_u$,Eu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;X=nY(),$=N5(),Eu$.exports=J=function(G){W(Q,G);function Q(q,H,V){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing DTD element name. "+this.debugInfo());if(!V)V="(#PCDATA)";if(Array.isArray(V))V="("+V.join(",")+")";this.name=this.stringify.name(H),this.type=$.ElementDeclaration,this.value=this.stringify.dtdElementValue(V)}return Q.prototype.toString=function(q){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(q))},Q}(X)}).call(_u$)});var _i=h((Su$,Pu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;X=nY(),$=N5(),Pu$.exports=J=function(G){W(Q,G);function Q(q,H,V){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing DTD notation name. "+this.debugInfo(H));if(!V.pubID&&!V.sysID)throw Error("Public or system identifiers are required for an external entity. "+this.debugInfo(H));if(this.name=this.stringify.name(H),this.type=$.NotationDeclaration,V.pubID!=null)this.pubID=this.stringify.dtdPubID(V.pubID);if(V.sysID!=null)this.sysID=this.stringify.dtdSysID(V.sysID)}return Object.defineProperty(Q.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(Q.prototype,"systemId",{get:function(){return this.sysID}}),Q.prototype.toString=function(q){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(q))},Q}(X)}).call(Su$)});var Ei=h((Cu$,Iu$)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V=function(U,z){for(var K in z)if(j.call(z,K))U[K]=z[K];function w(){this.constructor=U}return w.prototype=z.prototype,U.prototype=new w,U.__super__=z.prototype,U},j={}.hasOwnProperty;H=SV().isObject,q=nY(),$=N5(),J=Ni(),W=Ai(),X=Ri(),Y=_i(),Q=Li(),Iu$.exports=G=function(U){V(z,U);function z(K,w,L){var M,F,A,O,N,D;if(z.__super__.constructor.call(this,K),this.type=$.DocType,K.children){O=K.children;for(F=0,A=O.length;F<A;F++)if(M=O[F],M.type===$.Element){this.name=M.name;break}}if(this.documentObject=K,H(w))N=w,w=N.pubID,L=N.sysID;if(L==null)D=[w,L],L=D[0],w=D[1];if(w!=null)this.pubID=this.stringify.dtdPubID(w);if(L!=null)this.sysID=this.stringify.dtdSysID(L)}return Object.defineProperty(z.prototype,"entities",{get:function(){var K,w,L,M,F;M={},F=this.children;for(w=0,L=F.length;w<L;w++)if(K=F[w],K.type===$.EntityDeclaration&&!K.pe)M[K.name]=K;return new Q(M)}}),Object.defineProperty(z.prototype,"notations",{get:function(){var K,w,L,M,F;M={},F=this.children;for(w=0,L=F.length;w<L;w++)if(K=F[w],K.type===$.NotationDeclaration)M[K.name]=K;return new Q(M)}}),Object.defineProperty(z.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(z.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(z.prototype,"internalSubset",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),z.prototype.element=function(K,w){var L=new X(this,K,w);return this.children.push(L),this},z.prototype.attList=function(K,w,L,M,F){var A=new J(this,K,w,L,M,F);return this.children.push(A),this},z.prototype.entity=function(K,w){var L=new W(this,!1,K,w);return this.children.push(L),this},z.prototype.pEntity=function(K,w){var L=new W(this,!0,K,w);return this.children.push(L),this},z.prototype.notation=function(K,w){var L=new Y(this,K,w);return this.children.push(L),this},z.prototype.toString=function(K){return this.options.writer.docType(this,this.options.writer.filterOptions(K))},z.prototype.ele=function(K,w){return this.element(K,w)},z.prototype.att=function(K,w,L,M,F){return this.attList(K,w,L,M,F)},z.prototype.ent=function(K,w){return this.entity(K,w)},z.prototype.pent=function(K,w){return this.pEntity(K,w)},z.prototype.not=function(K,w){return this.notation(K,w)},z.prototype.up=function(){return this.root()||this.documentObject},z.prototype.isEqualNode=function(K){if(!z.__super__.isEqualNode.apply(this,arguments).isEqualNode(K))return!1;if(K.name!==this.name)return!1;if(K.publicId!==this.publicId)return!1;if(K.systemId!==this.systemId)return!1;return!0},z}(q)}).call(Cu$)});var Si=h((vu$,ku$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;$=N5(),J=nY(),ku$.exports=X=function(G){W(Q,G);function Q(q,H){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing raw text. "+this.debugInfo());this.type=$.Raw,this.value=this.stringify.raw(H)}return Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return this.options.writer.raw(this,this.options.writer.filterOptions(q))},Q}(J)}).call(vu$)});var Pi=h((bu$,Tu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;$=N5(),J=pZ(),Tu$.exports=X=function(G){W(Q,G);function Q(q,H){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=$.Text,this.value=this.stringify.text(H)}return Object.defineProperty(Q.prototype,"isElementContentWhitespace",{get:function(){throw Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(Q.prototype,"wholeText",{get:function(){var q,H,V;V="",H=this.previousSibling;while(H)V=H.data+V,H=H.previousSibling;V+=this.data,q=this.nextSibling;while(q)V=V+q.data,q=q.nextSibling;return V}}),Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return this.options.writer.text(this,this.options.writer.filterOptions(q))},Q.prototype.splitText=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},Q.prototype.replaceWholeText=function(q){throw Error("This DOM method is not implemented."+this.debugInfo())},Q}(J)}).call(bu$)});var Ci=h((Zu$,fu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;$=N5(),J=pZ(),fu$.exports=X=function(G){W(Q,G);function Q(q,H,V){if(Q.__super__.constructor.call(this,q),H==null)throw Error("Missing instruction target. "+this.debugInfo());if(this.type=$.ProcessingInstruction,this.target=this.stringify.insTarget(H),this.name=this.target,V)this.value=this.stringify.insValue(V)}return Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(q))},Q.prototype.isEqualNode=function(q){if(!Q.__super__.isEqualNode.apply(this,arguments).isEqualNode(q))return!1;if(q.target!==this.target)return!1;return!0},Q}(J)}).call(Zu$)});var OH$=h((xu$,hu$)=>{(function(){var $,J,X,W=function(G,Q){for(var q in Q)if(Y.call(Q,q))G[q]=Q[q];function H(){this.constructor=G}return H.prototype=Q.prototype,G.prototype=new H,G.__super__=Q.prototype,G},Y={}.hasOwnProperty;X=nY(),$=N5(),hu$.exports=J=function(G){W(Q,G);function Q(q){Q.__super__.constructor.call(this,q),this.type=$.Dummy}return Q.prototype.clone=function(){return Object.create(this)},Q.prototype.toString=function(q){return""},Q}(X)}).call(xu$)});var uu$=h((yu$,gu$)=>{(function(){var $;gu$.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(yu$)});var cu$=h((mu$,lu$)=>{(function(){lu$.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(mu$)});var nY=h((pu$,nu$)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V,j,U,z,K,w,L,M,F,A,O={}.hasOwnProperty;A=SV(),F=A.isObject,M=A.isFunction,L=A.isEmpty,w=A.getValue,q=null,X=null,W=null,Y=null,G=null,z=null,K=null,U=null,Q=null,J=null,j=null,H=null,$=null,nu$.exports=V=function(){function N(D){if(this.parent=D,this.parent)this.options=this.parent.options,this.stringify=this.parent.stringify;if(this.value=null,this.children=[],this.baseURI=null,!q)q=Mi(),X=Oi(),W=Di(),Y=Fi(),G=Ei(),z=Si(),K=Pi(),U=Ci(),Q=OH$(),J=N5(),j=uu$(),H=Li(),$=cu$()}return Object.defineProperty(N.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(N.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(N.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(N.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(N.prototype,"childNodes",{get:function(){if(!this.childNodeList||!this.childNodeList.nodes)this.childNodeList=new j(this.children);return this.childNodeList}}),Object.defineProperty(N.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(N.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(N.prototype,"previousSibling",{get:function(){var D=this.parent.children.indexOf(this);return this.parent.children[D-1]||null}}),Object.defineProperty(N.prototype,"nextSibling",{get:function(){var D=this.parent.children.indexOf(this);return this.parent.children[D+1]||null}}),Object.defineProperty(N.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(N.prototype,"textContent",{get:function(){var D,R,_,S,k;if(this.nodeType===J.Element||this.nodeType===J.DocumentFragment){k="",S=this.children;for(R=0,_=S.length;R<_;R++)if(D=S[R],D.textContent)k+=D.textContent;return k}else return null},set:function(D){throw Error("This DOM method is not implemented."+this.debugInfo())}}),N.prototype.setParent=function(D){var R,_,S,k,b;if(this.parent=D,D)this.options=D.options,this.stringify=D.stringify;k=this.children,b=[];for(_=0,S=k.length;_<S;_++)R=k[_],b.push(R.setParent(this));return b},N.prototype.element=function(D,R,_){var S,k,b,v,f,g,m,p,l,X$,r;if(g=null,R===null&&_==null)l=[{},null],R=l[0],_=l[1];if(R==null)R={};if(R=w(R),!F(R))X$=[R,_],_=X$[0],R=X$[1];if(D!=null)D=w(D);if(Array.isArray(D))for(b=0,m=D.length;b<m;b++)k=D[b],g=this.element(k);else if(M(D))g=this.element(D.apply());else if(F(D))for(f in D){if(!O.call(D,f))continue;if(r=D[f],M(r))r=r.apply();if(!this.options.ignoreDecorators&&this.stringify.convertAttKey&&f.indexOf(this.stringify.convertAttKey)===0)g=this.attribute(f.substr(this.stringify.convertAttKey.length),r);else if(!this.options.separateArrayItems&&Array.isArray(r)&&L(r))g=this.dummy();else if(F(r)&&L(r))g=this.element(f);else if(!this.options.keepNullNodes&&r==null)g=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(r))for(v=0,p=r.length;v<p;v++)k=r[v],S={},S[f]=k,g=this.element(S);else if(F(r))if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&f.indexOf(this.stringify.convertTextKey)===0)g=this.element(r);else g=this.element(f),g.element(r);else g=this.element(f,r)}else if(!this.options.keepNullNodes&&_===null)g=this.dummy();else if(!this.options.ignoreDecorators&&this.stringify.convertTextKey&&D.indexOf(this.stringify.convertTextKey)===0)g=this.text(_);else if(!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&D.indexOf(this.stringify.convertCDataKey)===0)g=this.cdata(_);else if(!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&D.indexOf(this.stringify.convertCommentKey)===0)g=this.comment(_);else if(!this.options.ignoreDecorators&&this.stringify.convertRawKey&&D.indexOf(this.stringify.convertRawKey)===0)g=this.raw(_);else if(!this.options.ignoreDecorators&&this.stringify.convertPIKey&&D.indexOf(this.stringify.convertPIKey)===0)g=this.instruction(D.substr(this.stringify.convertPIKey.length),_);else g=this.node(D,R,_);if(g==null)throw Error("Could not create any elements with: "+D+". "+this.debugInfo());return g},N.prototype.insertBefore=function(D,R,_){var S,k,b,v,f;if(D!=null?D.type:void 0){if(b=D,v=R,b.setParent(this),v)k=children.indexOf(v),f=children.splice(k),children.push(b),Array.prototype.push.apply(children,f);else children.push(b);return b}else{if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(D));return k=this.parent.children.indexOf(this),f=this.parent.children.splice(k),S=this.parent.element(D,R,_),Array.prototype.push.apply(this.parent.children,f),S}},N.prototype.insertAfter=function(D,R,_){var S,k,b;if(this.isRoot)throw Error("Cannot insert elements at root level. "+this.debugInfo(D));return k=this.parent.children.indexOf(this),b=this.parent.children.splice(k+1),S=this.parent.element(D,R,_),Array.prototype.push.apply(this.parent.children,b),S},N.prototype.remove=function(){var D,R;if(this.isRoot)throw Error("Cannot remove the root element. "+this.debugInfo());return D=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[D,D-D+1].concat(R=[])),this.parent},N.prototype.node=function(D,R,_){var S,k;if(D!=null)D=w(D);if(R||(R={}),R=w(R),!F(R))k=[R,_],_=k[0],R=k[1];if(S=new q(this,D,R),_!=null)S.text(_);return this.children.push(S),S},N.prototype.text=function(D){var R;if(F(D))this.element(D);return R=new K(this,D),this.children.push(R),this},N.prototype.cdata=function(D){var R=new X(this,D);return this.children.push(R),this},N.prototype.comment=function(D){var R=new W(this,D);return this.children.push(R),this},N.prototype.commentBefore=function(D){var R,_,S;return _=this.parent.children.indexOf(this),S=this.parent.children.splice(_),R=this.parent.comment(D),Array.prototype.push.apply(this.parent.children,S),this},N.prototype.commentAfter=function(D){var R,_,S;return _=this.parent.children.indexOf(this),S=this.parent.children.splice(_+1),R=this.parent.comment(D),Array.prototype.push.apply(this.parent.children,S),this},N.prototype.raw=function(D){var R=new z(this,D);return this.children.push(R),this},N.prototype.dummy=function(){var D=new Q(this);return D},N.prototype.instruction=function(D,R){var _,S,k,b,v;if(D!=null)D=w(D);if(R!=null)R=w(R);if(Array.isArray(D))for(b=0,v=D.length;b<v;b++)_=D[b],this.instruction(_);else if(F(D))for(_ in D){if(!O.call(D,_))continue;S=D[_],this.instruction(_,S)}else{if(M(R))R=R.apply();k=new U(this,D,R),this.children.push(k)}return this},N.prototype.instructionBefore=function(D,R){var _,S,k;return S=this.parent.children.indexOf(this),k=this.parent.children.splice(S),_=this.parent.instruction(D,R),Array.prototype.push.apply(this.parent.children,k),this},N.prototype.instructionAfter=function(D,R){var _,S,k;return S=this.parent.children.indexOf(this),k=this.parent.children.splice(S+1),_=this.parent.instruction(D,R),Array.prototype.push.apply(this.parent.children,k),this},N.prototype.declaration=function(D,R,_){var S,k;if(S=this.document(),k=new Y(S,D,R,_),S.children.length===0)S.children.unshift(k);else if(S.children[0].type===J.Declaration)S.children[0]=k;else S.children.unshift(k);return S.root()||S},N.prototype.dtd=function(D,R){var _,S,k,b,v,f,g,m,p,l;S=this.document(),k=new G(S,D,R),p=S.children;for(b=v=0,g=p.length;v<g;b=++v)if(_=p[b],_.type===J.DocType)return S.children[b]=k,k;l=S.children;for(b=f=0,m=l.length;f<m;b=++f)if(_=l[b],_.isRoot)return S.children.splice(b,0,k),k;return S.children.push(k),k},N.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},N.prototype.root=function(){var D=this;while(D)if(D.type===J.Document)return D.rootObject;else if(D.isRoot)return D;else D=D.parent},N.prototype.document=function(){var D=this;while(D)if(D.type===J.Document)return D;else D=D.parent},N.prototype.end=function(D){return this.document().end(D)},N.prototype.prev=function(){var D=this.parent.children.indexOf(this);if(D<1)throw Error("Already at the first node. "+this.debugInfo());return this.parent.children[D-1]},N.prototype.next=function(){var D=this.parent.children.indexOf(this);if(D===-1||D===this.parent.children.length-1)throw Error("Already at the last node. "+this.debugInfo());return this.parent.children[D+1]},N.prototype.importDocument=function(D){var R=D.root().clone();return R.parent=this,R.isRoot=!1,this.children.push(R),this},N.prototype.debugInfo=function(D){var R,_;if(D=D||this.name,D==null&&!((R=this.parent)!=null?R.name:void 0))return"";else if(D==null)return"parent: <"+this.parent.name+">";else if(!((_=this.parent)!=null?_.name:void 0))return"node: <"+D+">";else return"node: <"+D+">, parent: <"+this.parent.name+">"},N.prototype.ele=function(D,R,_){return this.element(D,R,_)},N.prototype.nod=function(D,R,_){return this.node(D,R,_)},N.prototype.txt=function(D){return this.text(D)},N.prototype.dat=function(D){return this.cdata(D)},N.prototype.com=function(D){return this.comment(D)},N.prototype.ins=function(D,R){return this.instruction(D,R)},N.prototype.doc=function(){return this.document()},N.prototype.dec=function(D,R,_){return this.declaration(D,R,_)},N.prototype.e=function(D,R,_){return this.element(D,R,_)},N.prototype.n=function(D,R,_){return this.node(D,R,_)},N.prototype.t=function(D){return this.text(D)},N.prototype.d=function(D){return this.cdata(D)},N.prototype.c=function(D){return this.comment(D)},N.prototype.r=function(D){return this.raw(D)},N.prototype.i=function(D,R){return this.instruction(D,R)},N.prototype.u=function(){return this.up()},N.prototype.importXMLBuilder=function(D){return this.importDocument(D)},N.prototype.replaceChild=function(D,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.removeChild=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.appendChild=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.hasChildNodes=function(){return this.children.length!==0},N.prototype.cloneNode=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.normalize=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isSupported=function(D,R){return!0},N.prototype.hasAttributes=function(){return this.attribs.length!==0},N.prototype.compareDocumentPosition=function(D){var R,_;if(R=this,R===D)return 0;else if(this.document()!==D.document()){if(_=$.Disconnected|$.ImplementationSpecific,Math.random()<0.5)_|=$.Preceding;else _|=$.Following;return _}else if(R.isAncestor(D))return $.Contains|$.Preceding;else if(R.isDescendant(D))return $.Contains|$.Following;else if(R.isPreceding(D))return $.Preceding;else return $.Following},N.prototype.isSameNode=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupPrefix=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isDefaultNamespace=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.lookupNamespaceURI=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.isEqualNode=function(D){var R,_,S;if(D.nodeType!==this.nodeType)return!1;if(D.children.length!==this.children.length)return!1;for(R=_=0,S=this.children.length-1;0<=S?_<=S:_>=S;R=0<=S?++_:--_)if(!this.children[R].isEqualNode(D.children[R]))return!1;return!0},N.prototype.getFeature=function(D,R){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.setUserData=function(D,R,_){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.getUserData=function(D){throw Error("This DOM method is not implemented."+this.debugInfo())},N.prototype.contains=function(D){if(!D)return!1;return D===this||this.isDescendant(D)},N.prototype.isDescendant=function(D){var R,_,S,k,b;b=this.children;for(S=0,k=b.length;S<k;S++){if(R=b[S],D===R)return!0;if(_=R.isDescendant(D),_)return!0}return!1},N.prototype.isAncestor=function(D){return D.isDescendant(this)},N.prototype.isPreceding=function(D){var R,_;if(R=this.treePosition(D),_=this.treePosition(this),R===-1||_===-1)return!1;else return R<_},N.prototype.isFollowing=function(D){var R,_;if(R=this.treePosition(D),_=this.treePosition(this),R===-1||_===-1)return!1;else return R>_},N.prototype.treePosition=function(D){var R,_;if(_=0,R=!1,this.foreachTreeNode(this.document(),function(S){if(_++,!R&&S===D)return R=!0}),R)return _;else return-1},N.prototype.foreachTreeNode=function(D,R){var _,S,k,b,v;D||(D=this.document()),b=D.children;for(S=0,k=b.length;S<k;S++)if(_=b[S],v=R(_))return v;else if(v=this.foreachTreeNode(_,R),v)return v},N}()}).call(pu$)});var DH$=h((du$,iu$)=>{(function(){var $,J=function(W,Y){return function(){return W.apply(Y,arguments)}},X={}.hasOwnProperty;iu$.exports=$=function(){function W(Y){this.assertLegalName=J(this.assertLegalName,this),this.assertLegalChar=J(this.assertLegalChar,this);var G,Q,q;if(Y||(Y={}),this.options=Y,!this.options.version)this.options.version="1.0";Q=Y.stringify||{};for(G in Q){if(!X.call(Q,G))continue;q=Q[G],this[G]=q}}return W.prototype.name=function(Y){if(this.options.noValidation)return Y;return this.assertLegalName(""+Y||"")},W.prototype.text=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(this.textEscape(""+Y||""))},W.prototype.cdata=function(Y){if(this.options.noValidation)return Y;return Y=""+Y||"",Y=Y.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(Y)},W.prototype.comment=function(Y){if(this.options.noValidation)return Y;if(Y=""+Y||"",Y.match(/--/))throw Error("Comment text cannot contain double-hypen: "+Y);return this.assertLegalChar(Y)},W.prototype.raw=function(Y){if(this.options.noValidation)return Y;return""+Y||""},W.prototype.attValue=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(this.attEscape(Y=""+Y||""))},W.prototype.insTarget=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.insValue=function(Y){if(this.options.noValidation)return Y;if(Y=""+Y||"",Y.match(/\?>/))throw Error("Invalid processing instruction value: "+Y);return this.assertLegalChar(Y)},W.prototype.xmlVersion=function(Y){if(this.options.noValidation)return Y;if(Y=""+Y||"",!Y.match(/1\.[0-9]+/))throw Error("Invalid version number: "+Y);return Y},W.prototype.xmlEncoding=function(Y){if(this.options.noValidation)return Y;if(Y=""+Y||"",!Y.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw Error("Invalid encoding: "+Y);return this.assertLegalChar(Y)},W.prototype.xmlStandalone=function(Y){if(this.options.noValidation)return Y;if(Y)return"yes";else return"no"},W.prototype.dtdPubID=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdSysID=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdElementValue=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdAttType=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdAttDefault=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdEntityValue=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.dtdNData=function(Y){if(this.options.noValidation)return Y;return this.assertLegalChar(""+Y||"")},W.prototype.convertAttKey="@",W.prototype.convertPIKey="?",W.prototype.convertTextKey="#text",W.prototype.convertCDataKey="#cdata",W.prototype.convertCommentKey="#comment",W.prototype.convertRawKey="#raw",W.prototype.assertLegalChar=function(Y){var G,Q;if(this.options.noValidation)return Y;if(G="",this.options.version==="1.0"){if(G=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Q=Y.match(G))throw Error("Invalid character in string: "+Y+" at index "+Q.index)}else if(this.options.version==="1.1"){if(G=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Q=Y.match(G))throw Error("Invalid character in string: "+Y+" at index "+Q.index)}return Y},W.prototype.assertLegalName=function(Y){var G;if(this.options.noValidation)return Y;if(this.assertLegalChar(Y),G=/^([: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])*$/,!Y.match(G))throw Error("Invalid character in name");return Y},W.prototype.textEscape=function(Y){var G;if(this.options.noValidation)return Y;return G=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,Y.replace(G,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;")},W.prototype.attEscape=function(Y){var G;if(this.options.noValidation)return Y;return G=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,Y.replace(G,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;")},W}()}).call(du$)});var nZ=h((ou$,ru$)=>{(function(){ru$.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(ou$)});var FH$=h((au$,tu$)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V,j,U,z,K,w,L,M,F={}.hasOwnProperty;M=SV().assign,$=N5(),H=Fi(),V=Ei(),X=Oi(),W=Di(),U=Mi(),K=Si(),w=Pi(),z=Ci(),j=OH$(),Y=Ni(),G=Ri(),Q=Ai(),q=_i(),J=nZ(),tu$.exports=L=function(){function A(O){var N,D,R;O||(O={}),this.options=O,D=O.writer||{};for(N in D){if(!F.call(D,N))continue;R=D[N],this["_"+N]=this[N],this[N]=R}}return A.prototype.filterOptions=function(O){var N,D,R,_,S,k,b,v;if(O||(O={}),O=M({},this.options,O),N={writer:this},N.pretty=O.pretty||!1,N.allowEmpty=O.allowEmpty||!1,N.indent=(D=O.indent)!=null?D:" ",N.newline=(R=O.newline)!=null?R:`
99
99
  `,N.offset=(_=O.offset)!=null?_:0,N.dontPrettyTextNodes=(S=(k=O.dontPrettyTextNodes)!=null?k:O.dontprettytextnodes)!=null?S:0,N.spaceBeforeSlash=(b=(v=O.spaceBeforeSlash)!=null?v:O.spacebeforeslash)!=null?b:"",N.spaceBeforeSlash===!0)N.spaceBeforeSlash=" ";return N.suppressPrettyCount=0,N.user={},N.state=J.None,N},A.prototype.indent=function(O,N,D){var R;if(!N.pretty||N.suppressPrettyCount)return"";else if(N.pretty){if(R=(D||0)+N.offset+1,R>0)return Array(R).join(N.indent)}return""},A.prototype.endline=function(O,N,D){if(!N.pretty||N.suppressPrettyCount)return"";else return N.newline},A.prototype.attribute=function(O,N,D){var R;return this.openAttribute(O,N,D),R=" "+O.name+'="'+O.value+'"',this.closeAttribute(O,N,D),R},A.prototype.cdata=function(O,N,D){var R;return this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<![CDATA[",N.state=J.InsideTag,R+=O.value,N.state=J.CloseTag,R+="]]>"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.comment=function(O,N,D){var R;return this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<!-- ",N.state=J.InsideTag,R+=O.value,N.state=J.CloseTag,R+=" -->"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.declaration=function(O,N,D){var R;if(this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<?xml",N.state=J.InsideTag,R+=' version="'+O.version+'"',O.encoding!=null)R+=' encoding="'+O.encoding+'"';if(O.standalone!=null)R+=' standalone="'+O.standalone+'"';return N.state=J.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.docType=function(O,N,D){var R,_,S,k,b;if(D||(D=0),this.openNode(O,N,D),N.state=J.OpenTag,k=this.indent(O,N,D),k+="<!DOCTYPE "+O.root().name,O.pubID&&O.sysID)k+=' PUBLIC "'+O.pubID+'" "'+O.sysID+'"';else if(O.sysID)k+=' SYSTEM "'+O.sysID+'"';if(O.children.length>0){k+=" [",k+=this.endline(O,N,D),N.state=J.InsideTag,b=O.children;for(_=0,S=b.length;_<S;_++)R=b[_],k+=this.writeChildNode(R,N,D+1);N.state=J.CloseTag,k+="]"}return N.state=J.CloseTag,k+=N.spaceBeforeSlash+">",k+=this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),k},A.prototype.element=function(O,N,D){var R,_,S,k,b,v,f,g,m,p,l,X$,r,Y$;D||(D=0),p=!1,l="",this.openNode(O,N,D),N.state=J.OpenTag,l+=this.indent(O,N,D)+"<"+O.name,X$=O.attribs;for(m in X$){if(!F.call(X$,m))continue;R=X$[m],l+=this.attribute(R,N,D)}if(S=O.children.length,k=S===0?null:O.children[0],S===0||O.children.every(function(A$){return(A$.type===$.Text||A$.type===$.Raw)&&A$.value===""}))if(N.allowEmpty)l+=">",N.state=J.CloseTag,l+="</"+O.name+">"+this.endline(O,N,D);else N.state=J.CloseTag,l+=N.spaceBeforeSlash+"/>"+this.endline(O,N,D);else if(N.pretty&&S===1&&(k.type===$.Text||k.type===$.Raw)&&k.value!=null)l+=">",N.state=J.InsideTag,N.suppressPrettyCount++,p=!0,l+=this.writeChildNode(k,N,D+1),N.suppressPrettyCount--,p=!1,N.state=J.CloseTag,l+="</"+O.name+">"+this.endline(O,N,D);else{if(N.dontPrettyTextNodes){r=O.children;for(b=0,f=r.length;b<f;b++)if(_=r[b],(_.type===$.Text||_.type===$.Raw)&&_.value!=null){N.suppressPrettyCount++,p=!0;break}}l+=">"+this.endline(O,N,D),N.state=J.InsideTag,Y$=O.children;for(v=0,g=Y$.length;v<g;v++)_=Y$[v],l+=this.writeChildNode(_,N,D+1);if(N.state=J.CloseTag,l+=this.indent(O,N,D)+"</"+O.name+">",p)N.suppressPrettyCount--;l+=this.endline(O,N,D),N.state=J.None}return this.closeNode(O,N,D),l},A.prototype.writeChildNode=function(O,N,D){switch(O.type){case $.CData:return this.cdata(O,N,D);case $.Comment:return this.comment(O,N,D);case $.Element:return this.element(O,N,D);case $.Raw:return this.raw(O,N,D);case $.Text:return this.text(O,N,D);case $.ProcessingInstruction:return this.processingInstruction(O,N,D);case $.Dummy:return"";case $.Declaration:return this.declaration(O,N,D);case $.DocType:return this.docType(O,N,D);case $.AttributeDeclaration:return this.dtdAttList(O,N,D);case $.ElementDeclaration:return this.dtdElement(O,N,D);case $.EntityDeclaration:return this.dtdEntity(O,N,D);case $.NotationDeclaration:return this.dtdNotation(O,N,D);default:throw Error("Unknown XML node type: "+O.constructor.name)}},A.prototype.processingInstruction=function(O,N,D){var R;if(this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<?",N.state=J.InsideTag,R+=O.target,O.value)R+=" "+O.value;return N.state=J.CloseTag,R+=N.spaceBeforeSlash+"?>",R+=this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.raw=function(O,N,D){var R;return this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D),N.state=J.InsideTag,R+=O.value,N.state=J.CloseTag,R+=this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.text=function(O,N,D){var R;return this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D),N.state=J.InsideTag,R+=O.value,N.state=J.CloseTag,R+=this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.dtdAttList=function(O,N,D){var R;if(this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<!ATTLIST",N.state=J.InsideTag,R+=" "+O.elementName+" "+O.attributeName+" "+O.attributeType,O.defaultValueType!=="#DEFAULT")R+=" "+O.defaultValueType;if(O.defaultValue)R+=' "'+O.defaultValue+'"';return N.state=J.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.dtdElement=function(O,N,D){var R;return this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<!ELEMENT",N.state=J.InsideTag,R+=" "+O.name+" "+O.value,N.state=J.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.dtdEntity=function(O,N,D){var R;if(this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<!ENTITY",N.state=J.InsideTag,O.pe)R+=" %";if(R+=" "+O.name,O.value)R+=' "'+O.value+'"';else{if(O.pubID&&O.sysID)R+=' PUBLIC "'+O.pubID+'" "'+O.sysID+'"';else if(O.sysID)R+=' SYSTEM "'+O.sysID+'"';if(O.nData)R+=" NDATA "+O.nData}return N.state=J.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.dtdNotation=function(O,N,D){var R;if(this.openNode(O,N,D),N.state=J.OpenTag,R=this.indent(O,N,D)+"<!NOTATION",N.state=J.InsideTag,R+=" "+O.name,O.pubID&&O.sysID)R+=' PUBLIC "'+O.pubID+'" "'+O.sysID+'"';else if(O.pubID)R+=' PUBLIC "'+O.pubID+'"';else if(O.sysID)R+=' SYSTEM "'+O.sysID+'"';return N.state=J.CloseTag,R+=N.spaceBeforeSlash+">"+this.endline(O,N,D),N.state=J.None,this.closeNode(O,N,D),R},A.prototype.openNode=function(O,N,D){},A.prototype.closeNode=function(O,N,D){},A.prototype.openAttribute=function(O,N,D){},A.prototype.closeAttribute=function(O,N,D){},A}()}).call(au$)});var Ii=h((su$,eu$)=>{(function(){var $,J,X=function(Y,G){for(var Q in G)if(W.call(G,Q))Y[Q]=G[Q];function q(){this.constructor=Y}return q.prototype=G.prototype,Y.prototype=new q,Y.__super__=G.prototype,Y},W={}.hasOwnProperty;J=FH$(),eu$.exports=$=function(Y){X(G,Y);function G(Q){G.__super__.constructor.call(this,Q)}return G.prototype.document=function(Q,q){var H,V,j,U,z;q=this.filterOptions(q),U="",z=Q.children;for(V=0,j=z.length;V<j;V++)H=z[V],U+=this.writeChildNode(H,q,0);if(q.pretty&&U.slice(-q.newline.length)===q.newline)U=U.slice(0,-q.newline.length);return U},G}(J)}).call(su$)});var NH$=h(($m$,Jm$)=>{(function(){var $,J,X,W,Y,G,Q,q,H=function(j,U){for(var z in U)if(V.call(U,z))j[z]=U[z];function K(){this.constructor=j}return K.prototype=U.prototype,j.prototype=new K,j.__super__=U.prototype,j},V={}.hasOwnProperty;q=SV().isPlainObject,X=LH$(),J=Wu$(),Y=nY(),$=N5(),Q=DH$(),G=Ii(),Jm$.exports=W=function(j){H(U,j);function U(z){if(U.__super__.constructor.call(this,null),this.name="#document",this.type=$.Document,this.documentURI=null,this.domConfig=new J,z||(z={}),!z.writer)z.writer=new G;this.options=z,this.stringify=new Q(z)}return Object.defineProperty(U.prototype,"implementation",{value:new X}),Object.defineProperty(U.prototype,"doctype",{get:function(){var z,K,w,L;L=this.children;for(K=0,w=L.length;K<w;K++)if(z=L[K],z.type===$.DocType)return z;return null}}),Object.defineProperty(U.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(U.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(U.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(U.prototype,"xmlEncoding",{get:function(){if(this.children.length!==0&&this.children[0].type===$.Declaration)return this.children[0].encoding;else return null}}),Object.defineProperty(U.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(U.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(U.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(U.prototype,"origin",{get:function(){return null}}),Object.defineProperty(U.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(U.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(U.prototype,"contentType",{get:function(){return null}}),U.prototype.end=function(z){var K={};if(!z)z=this.options.writer;else if(q(z))K=z,z=this.options.writer;return z.document(this,z.filterOptions(K))},U.prototype.toString=function(z){return this.options.writer.document(this,this.options.writer.filterOptions(z))},U.prototype.createElement=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createDocumentFragment=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTextNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createComment=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createCDATASection=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createProcessingInstruction=function(z,K){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttribute=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEntityReference=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.importNode=function(z,K){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createElementNS=function(z,K){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createAttributeNS=function(z,K){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByTagNameNS=function(z,K){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementById=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.adoptNode=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.normalizeDocument=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.renameNode=function(z,K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.getElementsByClassName=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createEvent=function(z){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createRange=function(){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createNodeIterator=function(z,K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},U.prototype.createTreeWalker=function(z,K,w){throw Error("This DOM method is not implemented."+this.debugInfo())},U}(Y)}).call($m$)});var Ym$=h((Xm$,Wm$)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V,j,U,z,K,w,L,M,F,A,O,N,D,R,_,S={}.hasOwnProperty;_=SV(),D=_.isObject,N=_.isFunction,R=_.isPlainObject,O=_.getValue,$=N5(),U=NH$(),K=Mi(),W=Oi(),Y=Di(),L=Si(),A=Pi(),w=Ci(),V=Fi(),j=Ei(),G=Ni(),q=Ai(),Q=Ri(),H=_i(),X=MH$(),F=DH$(),M=Ii(),J=nZ(),Wm$.exports=z=function(){function k(b,v,f){var g;if(this.name="?xml",this.type=$.Document,b||(b={}),g={},!b.writer)b.writer=new M;else if(R(b.writer))g=b.writer,b.writer=new M;this.options=b,this.writer=b.writer,this.writerOptions=this.writer.filterOptions(g),this.stringify=new F(b),this.onDataCallback=v||function(){},this.onEndCallback=f||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return k.prototype.createChildNode=function(b){var v,f,g,m,p,l,X$,r;switch(b.type){case $.CData:this.cdata(b.value);break;case $.Comment:this.comment(b.value);break;case $.Element:g={},X$=b.attribs;for(f in X$){if(!S.call(X$,f))continue;v=X$[f],g[f]=v.value}this.node(b.name,g);break;case $.Dummy:this.dummy();break;case $.Raw:this.raw(b.value);break;case $.Text:this.text(b.value);break;case $.ProcessingInstruction:this.instruction(b.target,b.value);break;default:throw Error("This XML node type is not supported in a JS object: "+b.constructor.name)}r=b.children;for(p=0,l=r.length;p<l;p++)if(m=r[p],this.createChildNode(m),m.type===$.Element)this.up();return this},k.prototype.dummy=function(){return this},k.prototype.node=function(b,v,f){var g;if(b==null)throw Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw Error("Document can only have one root node. "+this.debugInfo(b));if(this.openCurrent(),b=O(b),v==null)v={};if(v=O(v),!D(v))g=[v,f],f=g[0],v=g[1];if(this.currentNode=new K(this,b,v),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,f!=null)this.text(f);return this},k.prototype.element=function(b,v,f){var g,m,p,l,X$,r;if(this.currentNode&&this.currentNode.type===$.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(b)||D(b)||N(b)){l=this.options.noValidation,this.options.noValidation=!0,r=new U(this.options).element("TEMP_ROOT"),r.element(b),this.options.noValidation=l,X$=r.children;for(m=0,p=X$.length;m<p;m++)if(g=X$[m],this.createChildNode(g),g.type===$.Element)this.up()}else this.node(b,v,f);return this},k.prototype.attribute=function(b,v){var f,g;if(!this.currentNode||this.currentNode.children)throw Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(b));if(b!=null)b=O(b);if(D(b))for(f in b){if(!S.call(b,f))continue;g=b[f],this.attribute(f,g)}else{if(N(v))v=v.apply();if(this.options.keepNullAttributes&&v==null)this.currentNode.attribs[b]=new X(this,b,"");else if(v!=null)this.currentNode.attribs[b]=new X(this,b,v)}return this},k.prototype.text=function(b){var v;return this.openCurrent(),v=new A(this,b),this.onData(this.writer.text(v,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.cdata=function(b){var v;return this.openCurrent(),v=new W(this,b),this.onData(this.writer.cdata(v,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.comment=function(b){var v;return this.openCurrent(),v=new Y(this,b),this.onData(this.writer.comment(v,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.raw=function(b){var v;return this.openCurrent(),v=new L(this,b),this.onData(this.writer.raw(v,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.instruction=function(b,v){var f,g,m,p,l;if(this.openCurrent(),b!=null)b=O(b);if(v!=null)v=O(v);if(Array.isArray(b))for(f=0,p=b.length;f<p;f++)g=b[f],this.instruction(g);else if(D(b))for(g in b){if(!S.call(b,g))continue;m=b[g],this.instruction(g,m)}else{if(N(v))v=v.apply();l=new w(this,b,v),this.onData(this.writer.processingInstruction(l,this.writerOptions,this.currentLevel+1),this.currentLevel+1)}return this},k.prototype.declaration=function(b,v,f){var g;if(this.openCurrent(),this.documentStarted)throw Error("declaration() must be the first node.");return g=new V(this,b,v,f),this.onData(this.writer.declaration(g,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.doctype=function(b,v,f){if(this.openCurrent(),b==null)throw Error("Missing root node name.");if(this.root)throw Error("dtd() must come before the root node.");return this.currentNode=new j(this,v,f),this.currentNode.rootNodeName=b,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},k.prototype.dtdElement=function(b,v){var f;return this.openCurrent(),f=new Q(this,b,v),this.onData(this.writer.dtdElement(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.attList=function(b,v,f,g,m){var p;return this.openCurrent(),p=new G(this,b,v,f,g,m),this.onData(this.writer.dtdAttList(p,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.entity=function(b,v){var f;return this.openCurrent(),f=new q(this,!1,b,v),this.onData(this.writer.dtdEntity(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.pEntity=function(b,v){var f;return this.openCurrent(),f=new q(this,!0,b,v),this.onData(this.writer.dtdEntity(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.notation=function(b,v){var f;return this.openCurrent(),f=new H(this,b,v),this.onData(this.writer.dtdNotation(f,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.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},k.prototype.end=function(){while(this.currentLevel>=0)this.up();return this.onEnd()},k.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},k.prototype.openNode=function(b){var v,f,g,m;if(!b.isOpen){if(!this.root&&this.currentLevel===0&&b.type===$.Element)this.root=b;if(f="",b.type===$.Element){this.writerOptions.state=J.OpenTag,f=this.writer.indent(b,this.writerOptions,this.currentLevel)+"<"+b.name,m=b.attribs;for(g in m){if(!S.call(m,g))continue;v=m[g],f+=this.writer.attribute(v,this.writerOptions,this.currentLevel)}f+=(b.children?">":"/>")+this.writer.endline(b,this.writerOptions,this.currentLevel),this.writerOptions.state=J.InsideTag}else{if(this.writerOptions.state=J.OpenTag,f=this.writer.indent(b,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+b.rootNodeName,b.pubID&&b.sysID)f+=' PUBLIC "'+b.pubID+'" "'+b.sysID+'"';else if(b.sysID)f+=' SYSTEM "'+b.sysID+'"';if(b.children)f+=" [",this.writerOptions.state=J.InsideTag;else this.writerOptions.state=J.CloseTag,f+=">";f+=this.writer.endline(b,this.writerOptions,this.currentLevel)}return this.onData(f,this.currentLevel),b.isOpen=!0}},k.prototype.closeNode=function(b){var v;if(!b.isClosed){if(v="",this.writerOptions.state=J.CloseTag,b.type===$.Element)v=this.writer.indent(b,this.writerOptions,this.currentLevel)+"</"+b.name+">"+this.writer.endline(b,this.writerOptions,this.currentLevel);else v=this.writer.indent(b,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(b,this.writerOptions,this.currentLevel);return this.writerOptions.state=J.None,this.onData(v,this.currentLevel),b.isClosed=!0}},k.prototype.onData=function(b,v){return this.documentStarted=!0,this.onDataCallback(b,v+1)},k.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},k.prototype.debugInfo=function(b){if(b==null)return"";else return"node: <"+b+">"},k.prototype.ele=function(){return this.element.apply(this,arguments)},k.prototype.nod=function(b,v,f){return this.node(b,v,f)},k.prototype.txt=function(b){return this.text(b)},k.prototype.dat=function(b){return this.cdata(b)},k.prototype.com=function(b){return this.comment(b)},k.prototype.ins=function(b,v){return this.instruction(b,v)},k.prototype.dec=function(b,v,f){return this.declaration(b,v,f)},k.prototype.dtd=function(b,v,f){return this.doctype(b,v,f)},k.prototype.e=function(b,v,f){return this.element(b,v,f)},k.prototype.n=function(b,v,f){return this.node(b,v,f)},k.prototype.t=function(b){return this.text(b)},k.prototype.d=function(b){return this.cdata(b)},k.prototype.c=function(b){return this.comment(b)},k.prototype.r=function(b){return this.raw(b)},k.prototype.i=function(b,v){return this.instruction(b,v)},k.prototype.att=function(){if(this.currentNode&&this.currentNode.type===$.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},k.prototype.a=function(){if(this.currentNode&&this.currentNode.type===$.DocType)return this.attList.apply(this,arguments);else return this.attribute.apply(this,arguments)},k.prototype.ent=function(b,v){return this.entity(b,v)},k.prototype.pent=function(b,v){return this.pEntity(b,v)},k.prototype.not=function(b,v){return this.notation(b,v)},k}()}).call(Xm$)});var qm$=h((Gm$,Qm$)=>{(function(){var $,J,X,W,Y=function(Q,q){for(var H in q)if(G.call(q,H))Q[H]=q[H];function V(){this.constructor=Q}return V.prototype=q.prototype,Q.prototype=new V,Q.__super__=q.prototype,Q},G={}.hasOwnProperty;$=N5(),W=FH$(),J=nZ(),Qm$.exports=X=function(Q){Y(q,Q);function q(H,V){this.stream=H,q.__super__.constructor.call(this,V)}return q.prototype.endline=function(H,V,j){if(H.isLastRootNode&&V.state===J.CloseTag)return"";else return q.__super__.endline.call(this,H,V,j)},q.prototype.document=function(H,V){var j,U,z,K,w,L,M,F,A;M=H.children;for(U=z=0,w=M.length;z<w;U=++z)j=M[U],j.isLastRootNode=U===H.children.length-1;V=this.filterOptions(V),F=H.children,A=[];for(K=0,L=F.length;K<L;K++)j=F[K],A.push(this.writeChildNode(j,V,0));return A},q.prototype.attribute=function(H,V,j){return this.stream.write(q.__super__.attribute.call(this,H,V,j))},q.prototype.cdata=function(H,V,j){return this.stream.write(q.__super__.cdata.call(this,H,V,j))},q.prototype.comment=function(H,V,j){return this.stream.write(q.__super__.comment.call(this,H,V,j))},q.prototype.declaration=function(H,V,j){return this.stream.write(q.__super__.declaration.call(this,H,V,j))},q.prototype.docType=function(H,V,j){var U,z,K,w;if(j||(j=0),this.openNode(H,V,j),V.state=J.OpenTag,this.stream.write(this.indent(H,V,j)),this.stream.write("<!DOCTYPE "+H.root().name),H.pubID&&H.sysID)this.stream.write(' PUBLIC "'+H.pubID+'" "'+H.sysID+'"');else if(H.sysID)this.stream.write(' SYSTEM "'+H.sysID+'"');if(H.children.length>0){this.stream.write(" ["),this.stream.write(this.endline(H,V,j)),V.state=J.InsideTag,w=H.children;for(z=0,K=w.length;z<K;z++)U=w[z],this.writeChildNode(U,V,j+1);V.state=J.CloseTag,this.stream.write("]")}return V.state=J.CloseTag,this.stream.write(V.spaceBeforeSlash+">"),this.stream.write(this.endline(H,V,j)),V.state=J.None,this.closeNode(H,V,j)},q.prototype.element=function(H,V,j){var U,z,K,w,L,M,F,A,O,N;j||(j=0),this.openNode(H,V,j),V.state=J.OpenTag,this.stream.write(this.indent(H,V,j)+"<"+H.name),O=H.attribs;for(F in O){if(!G.call(O,F))continue;U=O[F],this.attribute(U,V,j)}if(K=H.children.length,w=K===0?null:H.children[0],K===0||H.children.every(function(D){return(D.type===$.Text||D.type===$.Raw)&&D.value===""}))if(V.allowEmpty)this.stream.write(">"),V.state=J.CloseTag,this.stream.write("</"+H.name+">");else V.state=J.CloseTag,this.stream.write(V.spaceBeforeSlash+"/>");else if(V.pretty&&K===1&&(w.type===$.Text||w.type===$.Raw)&&w.value!=null)this.stream.write(">"),V.state=J.InsideTag,V.suppressPrettyCount++,A=!0,this.writeChildNode(w,V,j+1),V.suppressPrettyCount--,A=!1,V.state=J.CloseTag,this.stream.write("</"+H.name+">");else{this.stream.write(">"+this.endline(H,V,j)),V.state=J.InsideTag,N=H.children;for(L=0,M=N.length;L<M;L++)z=N[L],this.writeChildNode(z,V,j+1);V.state=J.CloseTag,this.stream.write(this.indent(H,V,j)+"</"+H.name+">")}return this.stream.write(this.endline(H,V,j)),V.state=J.None,this.closeNode(H,V,j)},q.prototype.processingInstruction=function(H,V,j){return this.stream.write(q.__super__.processingInstruction.call(this,H,V,j))},q.prototype.raw=function(H,V,j){return this.stream.write(q.__super__.raw.call(this,H,V,j))},q.prototype.text=function(H,V,j){return this.stream.write(q.__super__.text.call(this,H,V,j))},q.prototype.dtdAttList=function(H,V,j){return this.stream.write(q.__super__.dtdAttList.call(this,H,V,j))},q.prototype.dtdElement=function(H,V,j){return this.stream.write(q.__super__.dtdElement.call(this,H,V,j))},q.prototype.dtdEntity=function(H,V,j){return this.stream.write(q.__super__.dtdEntity.call(this,H,V,j))},q.prototype.dtdNotation=function(H,V,j){return this.stream.write(q.__super__.dtdNotation.call(this,H,V,j))},q}(W)}).call(Gm$)});var Vm$=h((Hm$,BK)=>{(function(){var $,J,X,W,Y,G,Q,q,H,V;V=SV(),q=V.assign,H=V.isFunction,X=LH$(),W=NH$(),Y=Ym$(),Q=Ii(),G=qm$(),$=N5(),J=nZ(),Hm$.create=function(j,U,z,K){var w,L;if(j==null)throw Error("Root element needs a name.");if(K=q({},U,z,K),w=new W(K),L=w.element(j),!K.headless){if(w.declaration(K),K.pubID!=null||K.sysID!=null)w.dtd(K)}return L},Hm$.begin=function(j,U,z){var K;if(H(j))K=[j,U],U=K[0],z=K[1],j={};if(U)return new Y(j,U,z);else return new W(j)},Hm$.stringWriter=function(j){return new Q(j)},Hm$.streamWriter=function(j,U){return new G(j,U)},Hm$.implementation=new X,Hm$.nodeType=$,Hm$.writerState=J}).call(Hm$)});var Um$=h((jm$)=>{(function(){var $,J,X,W,Y,G={}.hasOwnProperty;$=Vm$(),J=wi().defaults,W=function(Q){return typeof Q==="string"&&(Q.indexOf("&")>=0||Q.indexOf(">")>=0||Q.indexOf("<")>=0)},Y=function(Q){return"<![CDATA["+X(Q)+"]]>"},X=function(Q){return Q.replace("]]>","]]]]><![CDATA[>")},jm$.Builder=function(){function Q(q){var H,V,j;this.options={},V=J["0.2"];for(H in V){if(!G.call(V,H))continue;j=V[H],this.options[H]=j}for(H in q){if(!G.call(q,H))continue;j=q[H],this.options[H]=j}}return Q.prototype.buildObject=function(q){var H,V,j,U,z;if(H=this.options.attrkey,V=this.options.charkey,Object.keys(q).length===1&&this.options.rootName===J["0.2"].rootName)z=Object.keys(q)[0],q=q[z];else z=this.options.rootName;return j=function(K){return function(w,L){var M,F,A,O,N,D;if(typeof L!=="object")if(K.options.cdata&&W(L))w.raw(Y(L));else w.txt(L);else if(Array.isArray(L))for(O in L){if(!G.call(L,O))continue;F=L[O];for(N in F)A=F[N],w=j(w.ele(N),A).up()}else for(N in L){if(!G.call(L,N))continue;if(F=L[N],N===H){if(typeof F==="object")for(M in F)D=F[M],w=w.att(M,D)}else if(N===V)if(K.options.cdata&&W(F))w=w.raw(Y(F));else w=w.txt(F);else if(Array.isArray(F))for(O in F){if(!G.call(F,O))continue;if(A=F[O],typeof A==="string")if(K.options.cdata&&W(A))w=w.ele(N).raw(Y(A)).up();else w=w.ele(N,A).up();else w=j(w.ele(N),A).up()}else if(typeof F==="object")w=j(w.ele(N),F).up();else if(typeof F==="string"&&K.options.cdata&&W(F))w=w.ele(N).raw(Y(F)).up();else{if(F==null)F="";w=w.ele(N,F.toString()).up()}}return w}}(this),U=$.create(z,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),j(U,q).end(this.options.renderOpts)},Q}()}).call(jm$)});var zm$=h((vi)=>{(function($){$.parser=function(x,T){return new X(x,T)},$.SAXParser=X,$.SAXStream=V,$.createStream=H,$.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(x,T){if(!(this instanceof X))return new X(x,T);var $$=this;if(Y($$),$$.q=$$.c="",$$.bufferCheckPosition=$.MAX_BUFFER_LENGTH,$$.opt=T||{},$$.opt.lowercase=$$.opt.lowercase||$$.opt.lowercasetags,$$.looseCase=$$.opt.lowercase?"toLowerCase":"toUpperCase",$$.tags=[],$$.closed=$$.closedRoot=$$.sawRoot=!1,$$.tag=$$.error=null,$$.strict=!!x,$$.noscript=!!(x||$$.opt.noscript),$$.state=S.BEGIN,$$.strictEntities=$$.opt.strictEntities,$$.ENTITIES=$$.strictEntities?Object.create($.XML_ENTITIES):Object.create($.ENTITIES),$$.attribList=[],$$.opt.xmlns)$$.ns=Object.create(w);if($$.opt.unquotedAttributeValues===void 0)$$.opt.unquotedAttributeValues=!x;if($$.trackPosition=$$.opt.position!==!1,$$.trackPosition)$$.position=$$.line=$$.column=0;b($$,"onready")}if(!Object.create)Object.create=function(x){function T(){}T.prototype=x;var $$=new T;return $$};if(!Object.keys)Object.keys=function(x){var T=[];for(var $$ in x)if(x.hasOwnProperty($$))T.push($$);return T};function W(x){var T=Math.max($.MAX_BUFFER_LENGTH,10),$$=0;for(var n=0,D$=J.length;n<D$;n++){var U$=x[J[n]].length;if(U$>T)switch(J[n]){case"textNode":f(x);break;case"cdata":v(x,"oncdata",x.cdata),x.cdata="";break;case"script":v(x,"onscript",x.script),x.script="";break;default:m(x,"Max buffer length exceeded: "+J[n])}$$=Math.max($$,U$)}var t=$.MAX_BUFFER_LENGTH-$$;x.bufferCheckPosition=t+x.position}function Y(x){for(var T=0,$$=J.length;T<$$;T++)x[J[T]]=""}function G(x){if(f(x),x.cdata!=="")v(x,"oncdata",x.cdata),x.cdata="";if(x.script!=="")v(x,"onscript",x.script),x.script=""}X.prototype={end:function(){p(this)},write:a,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){G(this)}};var Q;try{Q=K0("stream").Stream}catch(x){Q=function(){}}if(!Q)Q=function(){};var q=$.EVENTS.filter(function(x){return x!=="error"&&x!=="end"});function H(x,T){return new V(x,T)}function V(x,T){if(!(this instanceof V))return new V(x,T);Q.apply(this),this._parser=new X(x,T),this.writable=!0,this.readable=!0;var $$=this;this._parser.onend=function(){$$.emit("end")},this._parser.onerror=function(n){$$.emit("error",n),$$._parser.error=null},this._decoder=null,q.forEach(function(n){Object.defineProperty($$,"on"+n,{get:function(){return $$._parser["on"+n]},set:function(D$){if(!D$)return $$.removeAllListeners(n),$$._parser["on"+n]=D$,D$;$$.on(n,D$)},enumerable:!0,configurable:!1})})}V.prototype=Object.create(Q.prototype,{constructor:{value:V}}),V.prototype.write=function(x){if(typeof Buffer==="function"&&typeof Buffer.isBuffer==="function"&&Buffer.isBuffer(x)){if(!this._decoder){var T=K0("string_decoder").StringDecoder;this._decoder=new T("utf8")}x=this._decoder.write(x)}return this._parser.write(x.toString()),this.emit("data",x),!0},V.prototype.end=function(x){if(x&&x.length)this.write(x);return this._parser.end(),!0},V.prototype.on=function(x,T){var $$=this;if(!$$._parser["on"+x]&&q.indexOf(x)!==-1)$$._parser["on"+x]=function(){var n=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);n.splice(0,0,x),$$.emit.apply($$,n)};return Q.prototype.on.call($$,x,T)};var j="[CDATA[",U="DOCTYPE",z="http://www.w3.org/XML/1998/namespace",K="http://www.w3.org/2000/xmlns/",w={xml:z,xmlns:K},L=/[:_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]/,M=/[:_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-]/,F=/[#:_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=/[#:_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 O(x){return x===" "||x===`
@@ -715,4 +715,4 @@ Options:
715
715
  `).slice(1);for(let W of X){let Y=W.trim().split(/\s+/);if(Y.length>=2&&Y[1]==="device")$.add(Y[0])}}catch(J){B.debug(`Failed to get device list: ${J}`)}return $}async function ao6($,J){let X=`${$}:${J}`;if(Pl.has(X))return!0;try{let W=await eA$(["connect",X],tK0),Y=W.stdout+W.stderr;if(Y.includes("connected to")||Y.includes("already connected"))return B.info(`Connected to host emulator at ${X}`),Pl.add(X),!0;return!1}catch(W){return!1}}async function aK0(){if(aA$)return;aA$=!0;try{let $=await ro6();for(let X of Pl)if(!$.has(X))B.debug(`Device ${X} disconnected, removing from tracked list`),Pl.delete(X);let J=[];for(let X=no6;X<=do6;X+=2){let W=`${tA$}:${X}`;if(Pl.has(W))continue;J.push(ao6(tA$,X).then((Y)=>{if(Y)B.debug(`Successfully connected to emulator on port ${X}`)}))}await Promise.race([Promise.allSettled(J),new Promise((X)=>c.setTimeout(X,30000))])}catch($){B.debug(`Scan error: ${$}`)}finally{aA$=!1}}async function eK0(){if(!po6){B.debug("External emulator mode not enabled, skipping auto-connect service");return}if(!hG()){B.debug("Not running in Docker, skipping auto-connect service");return}if(sK0){B.info(`Using ADB server tunnel to ${Cl}:${sA$}`);let $=await eA$(["devices"],5000);if($.stderr&&!$.stdout.includes("List of devices"))B.warn(`Failed to connect to ADB server at ${Cl}:${sA$}: ${$.stderr}`);else{let J=$.stdout.split(`
716
716
  `).filter((X)=>X.includes("\tdevice")).length;B.info(`ADB server tunnel active, ${J} device(s) visible`)}return}if(B.info(`Starting host emulator auto-connect service (gateway: ${tA$}, interval: ${rK0}ms)`),await aK0(),rk=c.setInterval(()=>{aK0().catch(($)=>{B.debug(`Periodic scan failed: ${$}`)})},rK0),rk.unref)rk.unref()}async function $R$(){if(rk)clearInterval(rk),rk=null;B.debug("Host emulator auto-connect service stopped")}$N();SJ();pY();wH$();UR$();w5.mark("processEntry");function to6(){let $=process.argv.slice(2),J,X,W=$.includes("--cli"),Y=$.includes("--daemon-mode"),G=$.includes("--no-proxy")||$.includes("--direct"),Q=$.includes("--no-daemon"),q=$.indexOf("--daemon"),H=q>=0?$[q+1]:void 0,V=q>=0?$.slice(q+2):[],j=$.includes("--debug-perf")||$.includes("--ui-perf-debug")||process.env.AUTOMOBILE_DEBUG_PERF==="1",U=$.includes("--debug")||process.env.AUTOMOBILE_DEBUG==="1",z=!$.includes("--no-ui-perf-mode"),K=$.includes("--mem-perf-audit"),w=$.includes("--accessibility-audit"),L,M,F,A=!1,O=$.includes("--predictive")||$.includes("--predictive-ui"),N=$.includes("--raw-element-search"),D=$.includes("--skip-ctrl-proxy-download")||$.includes("--skip-accessibility-download"),R=$.includes("--network-mockable"),_=$.includes("--dismiss-keyboard-after-input"),S=$.includes("--mcp-recording"),k=!$.includes("--no-navigation-screenshots"),b=$.includes("--no-waitfor-polling-overhead"),v=$.includes("--no-include-not-important-views"),f=$.includes("--no-report-view-ids"),g=$.includes("--no-retrieve-interactive-windows"),m="session",p={},l=(t,j$,K$)=>{if(!t)return;let P$=K$?Number(t):parseInt(t,10);if(!Number.isFinite(P$)||P$<=0){B.warn(`Invalid ${j$}: ${t}`);return}return K$?P$:Math.round(P$)},X$=new Set(["low","medium","high"]),r=new Set(["mp4"]),Y$=(t,j$)=>{if(!t)return;if(!X$.has(t)){B.warn(`Invalid video quality preset (${j$}): ${t}`);return}p.qualityPreset=t},A$=(t,j$)=>{if(!t)return;if(!r.has(t)){B.warn(`Invalid video format (${j$}): ${t}`);return}p.format=t};Y$(process.env.AUTOMOBILE_VIDEO_QUALITY_PRESET??process.env.AUTO_MOBILE_VIDEO_QUALITY_PRESET,"env");let H$=process.env.AUTOMOBILE_VIDEO_TARGET_BITRATE_KBPS??process.env.AUTO_MOBILE_VIDEO_TARGET_BITRATE_KBPS,R$=process.env.AUTOMOBILE_VIDEO_MAX_THROUGHPUT_MBPS??process.env.AUTO_MOBILE_VIDEO_MAX_THROUGHPUT_MBPS,W$=process.env.AUTOMOBILE_VIDEO_FPS??process.env.AUTO_MOBILE_VIDEO_FPS,o=process.env.AUTOMOBILE_VIDEO_MAX_ARCHIVE_MB??process.env.AUTO_MOBILE_VIDEO_MAX_ARCHIVE_MB,a=process.env.AUTOMOBILE_VIDEO_FORMAT??process.env.AUTO_MOBILE_VIDEO_FORMAT,x=l(H$,"video target bitrate",!1);if(x!==void 0)p.targetBitrateKbps=x;let T=l(R$,"video max throughput",!0);if(T!==void 0)p.maxThroughputMbps=T;let $$=l(W$,"video fps",!1);if($$!==void 0)p.fps=$$;let n=l(o,"video max archive size",!0);if(n!==void 0)p.maxArchiveSizeMb=n;A$(a,"env");let D$=$.indexOf("--cli"),U$=W?$.slice(D$+1):[];for(let t=0;t<$.length;t++){let j$=$[t];if(j$==="--cli")break;if(j$==="--port"){let K$=parseInt($[t+1],10);if(!isNaN(K$)&&K$>0&&K$<65536)J=K$,t++;else B.warn(`Invalid port: ${$[t+1]}`),t++}else if(j$==="--host"){let K$=$[t+1];if(K$&&!K$.startsWith("--"))X=K$,t++;else B.warn(`Invalid host: ${K$}`),t++}else if(j$==="--a11y-level")L=$[t+1],t++;else if(j$==="--a11y-failure-mode")M=$[t+1],t++;else if(j$==="--a11y-min-severity")F=$[t+1],t++;else if(j$==="--a11y-use-baseline")A=!0;else if(j$==="--plan-execution-lock-scope"){let K$=$[t+1];if(K$==="global"||K$==="session")m=K$;else B.warn(`Invalid plan execution lock scope: ${K$}. Using default: ${m}`);t++}else if(j$==="--video-quality"||j$==="--video-quality-preset"){let K$=$[t+1];Y$(K$,"cli"),t++}else if(j$==="--video-target-bitrate-kbps"){let K$=l($[t+1],"video target bitrate",!1);if(K$!==void 0)p.targetBitrateKbps=K$;t++}else if(j$==="--video-max-throughput-mbps"){let K$=l($[t+1],"video max throughput",!0);if(K$!==void 0)p.maxThroughputMbps=K$;t++}else if(j$==="--video-fps"){let K$=l($[t+1],"video fps",!1);if(K$!==void 0)p.fps=K$;t++}else if(j$==="--video-format"){let K$=$[t+1];A$(K$,"cli"),t++}else if(j$==="--video-archive-size-mb"){let K$=l($[t+1],"video max archive size",!0);if(K$!==void 0)p.maxArchiveSizeMb=K$;t++}}return{cliMode:W,cliArgs:U$,daemonPort:J,daemonHost:X,debugPerf:j,debug:U,uiPerfMode:z,memPerfAuditMode:K,a11yAuditMode:w,a11yLevel:L,a11yFailureMode:M,a11yMinSeverity:F,a11yUseBaseline:A,predictiveUi:O,rawElementSearch:N,planExecutionLockScope:m,videoRecordingDefaults:p,daemonMode:Y,daemonCommand:H,daemonArgs:V,skipCtrlProxyDownload:D,networkMockable:R,dismissKeyboardAfterInput:_,mcpRecording:S,navigationScreenshots:k,noWaitForPollingOverhead:b,noProxy:G,noDaemon:Q,noA11yIncludeNotImportantViews:v,noA11yReportViewIds:f,noA11yRetrieveInteractiveWindows:g}}process.on("SIGINT",async()=>{B.info("Received SIGINT signal, shutting down"),await $R$(),await Nl(),await Al(),await Rl(),await El(),_l(),await M0.cleanupPrefetchedApk(),B.close(),process.exit(0)});process.on("SIGTERM",async()=>{B.info("Received SIGTERM signal, shutting down"),await $R$(),await Nl(),await Al(),await Rl(),await El(),_l(),await M0.cleanupPrefetchedApk(),B.close(),process.exit(0)});process.on("uncaughtException",($)=>{B.info(`Uncaught exception: ${$.message}`),B.info(`Trace: ${$.stack}`)});process.on("unhandledRejection",($,J)=>{B.error("Unhandled rejection at:",J,"reason:",$)});async function so6(){try{let{cliMode:$,cliArgs:J,daemonPort:X,daemonHost:W,debugPerf:Y,debug:G,uiPerfMode:Q,memPerfAuditMode:q,a11yAuditMode:H,a11yLevel:V,a11yFailureMode:j,a11yMinSeverity:U,a11yUseBaseline:z,predictiveUi:K,rawElementSearch:w,planExecutionLockScope:L,videoRecordingDefaults:M,daemonMode:F,daemonCommand:A,daemonArgs:O,skipCtrlProxyDownload:N,networkMockable:D,dismissKeyboardAfterInput:R,mcpRecording:_,navigationScreenshots:S,noWaitForPollingOverhead:k,noProxy:b,noDaemon:v,noA11yIncludeNotImportantViews:f,noA11yReportViewIds:g,noA11yRetrieveInteractiveWindows:m}=to6();if(V0.setPlanExecutionLockScope(L),V0.setVideoRecordingDefaults(M),V0.setSkipCtrlProxyDownload(N),V0.setNetworkMockableEnabled(D),V0.setDismissKeyboardAfterInputEnabled(R),N)B.info("CtrlProxy APK download disabled (--skip-ctrl-proxy-download)");else M0.prefetchApk();if(process.platform==="darwin")j1.prefetchBuild();let p=p5.getInstance();await p.initialize();let X$=[["debug",G,"--debug"],["debug-perf",Y,"--debug-perf/--ui-perf-debug"],["ui-perf-mode",Q,"--ui-perf-mode"],["mem-perf-audit",q,"--mem-perf-audit"],["accessibility-audit",H,"--accessibility-audit",H?{level:V||"AA",failureMode:j||"report",minSeverity:U||(j==="strict"?"error":"warning"),useBaseline:z}:null],["predictive-ui",K,"--predictive/--predictive-ui"],["raw-element-search",w,"--raw-element-search"],["mcp-recording",_,"--mcp-recording"]];for(let[Y$,A$,H$,R$]of X$){if(!A$)continue;await p.setFlag(Y$,!0,R$),B.info(`Feature flag enabled (${H$})`)}if(!S)await p.setFlag("navigation-screenshots",!1),B.info("Navigation screenshots disabled (--no-navigation-screenshots)");if(k)V0.setWaitForPollingOverheadEnabled(!1),B.info("WaitFor polling overhead disabled (--no-waitfor-polling-overhead): screenshots and back stack skipped during observe waitFor polling");let r=[[!Q,"UI perf mode disabled (--no-ui-perf-mode): skipping selection-state visual capture on taps and UI perf auditing"],[R,"Dismiss keyboard after inputText enabled (--dismiss-keyboard-after-input)"],[f,"Accessibility includeNotImportantViews disabled (--no-include-not-important-views)"],[g,"Accessibility reportViewIds disabled (--no-report-view-ids)"],[m,"Accessibility retrieveInteractiveWindows disabled (--no-retrieve-interactive-windows)"]];for(let[Y$,A$]of r)if(Y$)B.info(A$);if(F){await oK0({port:X,...W!==void 0?{host:W}:{},debug:G,debugPerf:Y,planExecutionLockScope:L,videoQualityPreset:M.qualityPreset,videoTargetBitrateKbps:M.targetBitrateKbps,videoMaxThroughputMbps:M.maxThroughputMbps,videoFps:M.fps,videoFormat:M.format,videoMaxArchiveSizeMb:M.maxArchiveSizeMb,networkMockable:D,dismissKeyboardAfterInput:R,noUiPerfMode:!Q,memPerfAudit:q,accessibilityAudit:H,accessibilityLevel:V,accessibilityFailureMode:j,accessibilityMinSeverity:U,accessibilityUseBaseline:z,predictiveUi:K,rawElementSearch:w,skipCtrlProxyDownload:N,mcpRecording:_,noNavigationScreenshots:!S,noWaitForPollingOverhead:k,noA11yIncludeNotImportantViews:f,noA11yReportViewIds:g,noA11yRetrieveInteractiveWindows:m});return}if(A)await G30(A,O),B.close(),process.exit(0);if($)B.info("Running in CLI mode"),await YK0(J),B.close(),process.exit(0);else{let Y$=!b,A$={debug:G,debugPerf:Y,planExecutionLockScope:L,mcpRecording:_,videoQualityPreset:M.qualityPreset,videoTargetBitrateKbps:M.targetBitrateKbps,videoMaxThroughputMbps:M.maxThroughputMbps,videoFps:M.fps,videoFormat:M.format,videoMaxArchiveSizeMb:M.maxArchiveSizeMb,networkMockable:D,dismissKeyboardAfterInput:R,noUiPerfMode:!Q,memPerfAudit:q,accessibilityAudit:H,accessibilityLevel:V,accessibilityFailureMode:j,accessibilityMinSeverity:U,accessibilityUseBaseline:z,predictiveUi:K,rawElementSearch:w,skipCtrlProxyDownload:N,noNavigationScreenshots:!S,noWaitForPollingOverhead:k,noA11yIncludeNotImportantViews:f,noA11yReportViewIds:g,noA11yRetrieveInteractiveWindows:m};if(Y$)B.info("Starting MCP server in proxy mode (connecting to daemon)");else B.info("Starting MCP server in direct mode (--no-proxy flag)"),await eK0(),await t4$(),await s4$(),await e4$(),await J1$(),$1$();let H$=()=>{B.info("stdin closed \u2014 MCP client disconnected, shutting down"),B.close(),process.exit(0)};process.stdin.on("end",H$),process.stdin.on("error",H$),process.stdin.on("close",H$);let R$=new R9$,W$,o;try{if(Y$){let a=$K0({proxyConfig:{autoStartDaemon:!v,daemonOptions:A$}});W$=a.server,o=a.proxy}else W$=b4$({debug:G})}catch(a){throw B.error("Failed to create MCP server:",a),a}try{if(B.info("Connecting MCP server to stdio transport"),w5.startPhase("serverListening"),await W$.connect(R$),w5.endPhase("serverListening"),B.info("MCP server connected to stdio transport"),B.info(`AutoMobile MCP server running on stdio (${Y$?"proxy":"direct"} mode)`),w5.emit("mcp-server",{transport:"stdio",mode:Y$?"proxy":"direct"}),o){let a=async()=>{await o.close()};process.on("beforeExit",a)}}catch(a){throw B.error("MCP server connect failed:",a),a}}}catch($){throw B.error("Error initializing server:",$),$}}so6().catch(($)=>{console.error("Fatal error in main():",$),B.error("Fatal error in main():",$),B.close(),process.exit(1)});
717
717
 
718
- //# debugId=B7E07796AB013A5964756E2164756E21
718
+ //# debugId=77CDF7DEA077FEA364756E2164756E21