@expo/repack-app 0.2.1 → 0.2.2
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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ ${i}`),Object.assign(m,v),c(m)}else n(v)},z=K=>{_?r.removeListener("exit",w):r.r
|
|
|
15
15
|
`).replace(/[\r\u0085\u2028]/g,`
|
|
16
16
|
`)}function H_(t){this.options=t||{locator:{}}}H_.prototype.parseFromString=function(t,o){var e=this.options,s=new nO,i=e.domBuilder||new Me,r=e.errorHandler,a=e.locator,n=e.xmlns||{},c=/\/x?html?$/.test(o),_=c?R_.HTML_ENTITIES:R_.XML_ENTITIES;a&&i.setDocumentLocator(a),s.errorHandler=cO(r,i,a),s.domBuilder=e.domBuilder||i,c&&(n[""]=J_.HTML),n.xml=n.xml||J_.XML;var d=e.normalizeLineEndings||$_;return t&&typeof t=="string"?s.parse(d(t),n,_):s.errorHandler.error("invalid doc source"),i.doc};function cO(t,o,e){if(!t){if(o instanceof Me)return o;t=o}var s={},i=t instanceof Function;e=e||{};function r(a){var n=t[a];!n&&i&&(n=t.length==2?function(c){t(a,c)}:t),s[a]=n&&function(c){n("[xmldom "+a+"] "+c+Cr(e))}||function(){}}return r("warning"),r("error"),r("fatalError"),s}function Me(){this.cdata=!1}function At(t,o){o.lineNumber=t.lineNumber,o.columnNumber=t.columnNumber}Me.prototype={startDocument:function(){this.doc=new rO().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(t,o,e,s){var i=this.doc,r=i.createElementNS(t,e||o),a=s.length;ei(this,r),this.currentElement=r,this.locator&&At(this.locator,r);for(var n=0;n<a;n++){var t=s.getURI(n),c=s.getValue(n),e=s.getQName(n),_=i.createAttributeNS(t,e);this.locator&&At(s.getLocator(n),_),_.value=_.nodeValue=c,r.setAttributeNode(_)}},endElement:function(t,o,e){var s=this.currentElement,i=s.tagName;this.currentElement=s.parentNode},startPrefixMapping:function(t,o){},endPrefixMapping:function(t){},processingInstruction:function(t,o){var e=this.doc.createProcessingInstruction(t,o);this.locator&&At(this.locator,e),ei(this,e)},ignorableWhitespace:function(t,o,e){},characters:function(t,o,e){if(t=B_.apply(this,arguments),t){if(this.cdata)var s=this.doc.createCDATASection(t);else var s=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(s):/^\s*$/.test(t)&&this.doc.appendChild(s),this.locator&&At(this.locator,s)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){(this.locator=t)&&(t.lineNumber=0)},comment:function(t,o,e){t=B_.apply(this,arguments);var s=this.doc.createComment(t);this.locator&&At(this.locator,s),ei(this,s)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,o,e){var s=this.doc.implementation;if(s&&s.createDocumentType){var i=s.createDocumentType(t,o,e);this.locator&&At(this.locator,i),ei(this,i),this.doc.doctype=i}},warning:function(t){console.warn("[xmldom warning] "+t,Cr(this.locator))},error:function(t){console.error("[xmldom error] "+t,Cr(this.locator))},fatalError:function(t){throw new aO(t,this.locator)}};function Cr(t){if(t)return`
|
|
17
17
|
@`+(t.systemId||"")+"#[line:"+t.lineNumber+",col:"+t.columnNumber+"]"}function B_(t,o,e){return typeof t=="string"?t.substr(o,e):t.length>=o+e||o?new java.lang.String(t,o,e)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){Me.prototype[t]=function(){return null}});function ei(t,o){t.currentElement?t.currentElement.appendChild(o):t.doc.appendChild(o)}si.__DOMHandler=Me;si.normalizeLineEndings=$_;si.DOMParser=H_});var ex=V(ii=>{var tx=vr();ii.DOMImplementation=tx.DOMImplementation;ii.XMLSerializer=tx.XMLSerializer;ii.DOMParser=ox().DOMParser});var ix=V(Ve=>{"use strict";var lO=Ve&&Ve.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.parse=xO;var uO=ex(),jt=lO(require("assert")),ri=3,sx=4,_O=8;function Nr(t){return t.nodeType===ri||t.nodeType===_O||t.nodeType===sx}function Bo(t){return!t.childNodes||t.childNodes.length===0}function xO(t){let o=new uO.DOMParser({errorHandler(){}}).parseFromString(t);(0,jt.default)(o.documentElement.nodeName==="plist","malformed document. First element should be <plist>");let e=Rt(o.documentElement);return e.length===1&&(e=e[0]),e}function Rt(t){let o,e,s,i,r,a;if(!t)return null;if(t.nodeName==="plist"){if(i=[],Bo(t))return i;for(o=0;o<t.childNodes.length;o++)Nr(t.childNodes[o])||i.push(Rt(t.childNodes[o]));return i}else if(t.nodeName==="dict"){if(e={},s=null,a=0,Bo(t))return e;for(o=0;o<t.childNodes.length;o++)Nr(t.childNodes[o])||(a%2===0?((0,jt.default)(t.childNodes[o].nodeName==="key","Missing key while parsing <dict/>."),s=Rt(t.childNodes[o])):((0,jt.default)(t.childNodes[o].nodeName!=="key",'Unexpected key "'+Rt(t.childNodes[o])+'" while parsing <dict/>.'),e[s]=Rt(t.childNodes[o])),a+=1);if(a%2===1)throw new Error('Missing value for "'+s+'" while parsing <dict/>');return e}else if(t.nodeName==="array"){if(i=[],Bo(t))return i;for(o=0;o<t.childNodes.length;o++)Nr(t.childNodes[o])||(r=Rt(t.childNodes[o]),r!=null&&i.push(r));return i}else if(t.nodeName!=="#text"){if(t.nodeName==="key")return Bo(t)?"":t.childNodes[0].nodeValue;if(t.nodeName==="string"){if(r="",Bo(t))return r;for(o=0;o<t.childNodes.length;o++){let n=t.childNodes[o].nodeType;(n===ri||n===sx)&&(r+=t.childNodes[o].nodeValue)}return r}else{if(t.nodeName==="integer")return(0,jt.default)(!Bo(t),'Cannot parse "" as integer.'),parseInt(t.childNodes[0].nodeValue,10);if(t.nodeName==="real"){for((0,jt.default)(!Bo(t),'Cannot parse "" as real.'),r="",o=0;o<t.childNodes.length;o++)t.childNodes[o].nodeType===ri&&(r+=t.childNodes[o].nodeValue);return parseFloat(r)}else if(t.nodeName==="data"){if(r="",Bo(t))return Buffer.from(r,"base64");for(o=0;o<t.childNodes.length;o++)t.childNodes[o].nodeType===ri&&(r+=t.childNodes[o].nodeValue.replace(/\s+/g,""));return Buffer.from(r,"base64")}else{if(t.nodeName==="date")return(0,jt.default)(!Bo(t),'Cannot parse "" as Date.'),new Date(t.childNodes[0].nodeValue);if(t.nodeName==="true")return!0;if(t.nodeName==="false")return!1}}}}});var rx=V(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});var mO=c_(),gO=ix();Sr.default={parse:gO.parse,build:mO.build}});var wO={};yx(wO,{ConsoleLogger:()=>oe,repackAppAndroidAsync:()=>pc,repackAppIosAsync:()=>_x});module.exports=hx(wO);var Ii=I(require("node:assert")),mt=I(require("node:fs/promises")),Uo=I(require("node:path")),qc=I(_i());var No=I(require("fs/promises")),$t=I(require("node:assert")),ko=I(require("node:path")),ts=I(Ki());var ln="./apktool.jar";var un=ko.default.resolve(__dirname,ln);async function _n(t,o){let{spawnAsync:e,workingDirectory:s}=o,i="decoded-apk";return await e("java",["-jar",un,"decode",t,"-s","-o",i],{cwd:s}),ko.default.join(s,i)}async function xn(t,o){let{spawnAsync:e,workingDirectory:s}=o,r=ko.default.resolve(s,"apktool-packed.apk");return await e("java",["-jar",un,"build","-o",r,t]),r}async function mn({decodedApkRoot:t,assetRoot:o,bundleOutputPath:e}){await No.default.copyFile(e,ko.default.join(t,"assets","index.android.bundle"));let s=await On(o,ko.default.join(t,"res"));await Gx(t,s)}async function gn(t,o){let e=ko.default.join(t,"apktool.yml"),s=await No.default.readFile(e,"utf8");s=s.replace(/^(\s+renameManifestPackage:\s+)(.+)$/gm,`$1${o}`),await No.default.writeFile(e,s)}async function Gx(t,o){let e=ko.default.join(t,"res/values/public.xml"),s=await No.default.readFile(e,"utf8"),i=new ts.Parser,r=new Set,a=await i.parseStringPromise(s),n=0,c=0,_=0;for(let K of a.resources.public){let q=parseInt(K.$.id,16);K.$.type==="drawable"?(n=Math.max(n,q),r.add(K.$.name)):K.$.type==="raw"&&(c=Math.max(c,q),r.add(K.$.name)),_=Math.max(_,q)}(0,$t.default)(n!==0,"Drawable resources must be defined."),c===0&&(c=(_&4294901760)+65536);let d=(n&4294901760)+65536,O=(c&4294901760)+65536,g=new Set([...o.keys()].filter(K=>!r.has(K)));for(let K of g){let q=o.get(K);q!=null&&(q.type==="drawable"?(n+=1,(0,$t.default)(n<d,"Drawable resource ID boundary exceeded."),a.resources.public.push({$:{type:"drawable",name:q.name,id:`0x${n.toString(16)}`}})):q.type==="raw"&&(c+=1,(0,$t.default)(c<O,"Raw resource ID boundary exceeded."),a.resources.public.push({$:{type:"raw",name:q.name,id:`0x${c.toString(16)}`}})))}let z=new ts.Builder().buildObject(a);await No.default.writeFile(e,z)}function Wx(t){if(t.startsWith("drawable"))return"drawable";if(t==="raw")return"raw";throw new Error(`Unsupported asset type for ${t}`)}async function On(t,o,e=0,s=2,i=void 0,r=new Map){await No.default.mkdir(o,{recursive:!0});let a=await No.default.readdir(t,{withFileTypes:!0});return await Promise.all(a.map(async n=>{let c=ko.default.join(t,n.name),_=ko.default.join(o,n.name);if(n.isDirectory()){let d=i??Wx(n.name);e<s-1?await On(c,_,e+1,s,d,r):await No.default.mkdir(_,{recursive:!0})}else{await No.default.copyFile(c,_);let{name:d}=ko.default.parse(n.name);(0,$t.default)(i,"Asset type must be defined."),r.set(d,{name:d,type:i})}})),r}var Gi=I(require("node:assert")),wn=I(require("node:fs/promises")),To=I(require("node:path")),ki=null;async function dn(t){if(ki==null){let o=t?.androidBuildToolsDir??await bx(t);(0,Gi.default)(o!=null,"Unable to find the Android build-tools directory."),ki={aapt2Path:To.default.join(o,"aapt2"),apksignerPath:To.default.join(o,"apksigner"),dexdumpPath:To.default.join(o,"dexdump"),zipalignPath:To.default.join(o,"zipalign")}}return ki}async function yn(t,o,e){let{spawnAsync:s,workingDirectory:i}=o,{apksignerPath:r,zipalignPath:a}=await dn(o),n=To.default.join(i,"resigned.apk"),c=To.default.resolve(i,"resigned-unaligned.apk");await s("zip",["-r","-0",c,"lib","resources.arsc"],{cwd:t}),await s("zip",["-r",c,".","-x","lib/*","-x","resources.arsc"],{cwd:t}),await s(a,["-v","-p","4",c,n]);let _=["sign","--ks",e.keyStorePath,"--ks-pass",e.keyStorePassword];return e.keyAlias&&_.push("--ks-key-alias",e.keyAlias),e.keyPassword&&_.push("--key-pass",e.keyPassword),_.push(n),await s(r,_),n}async function bx(t){let{logger:o}=t,e=process.env.ANDROID_SDK_ROOT;(0,Gi.default)(e!=null,"ANDROID_SDK_ROOT environment variable is not set");let s=To.default.join(e,"build-tools");try{let r=(await wn.default.readdir(s,{withFileTypes:!0})).filter(a=>a.isDirectory()).map(a=>a.name).sort((a,n)=>{let c=a.split(".").map(Number),_=n.split(".").map(Number);for(let d=0;d<Math.min(c.length,_.length);d++)if(c[d]!==_[d])return _[d]-c[d];return _.length-c.length});return r.length>0?To.default.join(s,r[0]):(o.error("No build-tools directories found."),null)}catch(i){return o.error(`Failed to read the build-tools directory: ${i}`),null}}async function hn(t,o,e){let{logger:s,spawnAsync:i}=e,{dexdumpPath:r}=await dn(e),a=`"^ Class descriptor : 'L${o.replace(/\./g,"/")}\\/"`;try{let{stdout:n}=await i(r,["classes*.dex","|","grep",a],{cwd:t,shell:!0,stdio:"pipe"}),c=n.split(`
|
|
18
|
-
`).map(_=>_.match(/Class descriptor\s+?:\s+?'L(.+);'/)?.[1].replace(/\//g,".")).filter(Boolean);return new Set(c)}catch(n){return s.info(`Failed to search for classes in the APK - grepAppIdPattern[${o}]: ${n}`),null}}var xt=I(require("node:assert")),se=I(require("node:fs/promises")),Oc=I(require("node:path")),is=I(Ki());var xc=I(lc()),mc=I(require("node:assert")),_t=I(require("node:fs/promises")),Ht=I(require("node:path"));async function gc(t){return(await _t.default.stat(t).catch(()=>null))?.isFile()??!1}async function ss(t){return(await _t.default.stat(t).catch(()=>null))?.isDirectory()??!1}function te(t){return(0,mc.default)(t!=null,"Expected value to be non-null"),t}async function ee(t){let o=t.platform==="android"?".apk":".ipa";return{...t,workingDirectory:t.workingDirectory??await _t.default.mkdtemp(Ht.default.join(_c(),"repack-app-")),outputPath:t.outputPath??Ht.default.join(t.projectRoot,`repacked${o}`),logger:t.logger??new oe,spawnAsync:t.spawnAsync??im(!!t.verbose)}}var oe=class{debug(...o){console.debug(...o)}info(...o){console.log(...o)}warn(...o){console.warn(...o)}error(...o){console.error(...o)}time(o){console.time(o)}timeEnd(o){console.timeEnd(o)}};function im(t){return function(e,s,i){return(0,xc.default)(e,s,{stdio:t?"inherit":"pipe",...i})}}async function Gt(t,o){await _t.default.mkdir(o,{recursive:!0});let e=await _t.default.readdir(t,{withFileTypes:!0});for(let s of e){let i=Ht.default.join(t,s.name),r=Ht.default.join(o,s.name);s.isDirectory()?await Gt(i,r):s.isFile()&&await _t.default.copyFile(i,r)}}async function wc({config:t,decodedApkRoot:o}){let e=Oc.default.join(o,"res","values","strings.xml"),s=await se.default.readFile(e,"utf8");s=s.replace(/(<string name="app_name">)(.+)(<\/string>)/,`$1${t.name}$3`),await se.default.writeFile(e,s)}async function dc({config:t,androidManiestXml:o,dexClasses:e,originalAppId:s,originalAppIdFallback:i,updatesRuntimeVersion:r}){let a=te(t.android?.package);o.manifest.$.package=a,Xi(o,d=>d.startsWith(s)&&!e.has(d)?d.replace(s,a):d);let n=Ei("manifest",o.manifest,(d,O)=>d==="intent-filter"&&Ei(d,O,(g,w)=>g==="action"&&w[0].$?.["android:name"]==="android.intent.action.VIEW").length>0),c=Array.isArray(t.scheme)?t.scheme[0]:t.scheme;for(let d of n)Xi(d,O=>{let g=O.replace(s,a).replace(/^exp\+.+$/g,`exp+${te(t.slug)}`);return c&&(g=g.replace(/^myapp$/g,c)),i!=null&&(g=g.replace(i,a)),g});let _=o.manifest.application[0];(0,xt.default)(_.$?.["android:name"]?.endsWith(".MainApplication"),"Expected application node to be named as MainApplication"),r&&rm(_,t,r)}async function yc(t){let o=await se.default.readFile(t,"utf8");return await new is.Parser().parseStringPromise(o)}async function hc(t,o){let s=new is.Builder().buildObject(t);await se.default.writeFile(o,s)}function fc(t){let o=t.manifest.$.package;return(0,xt.default)(o!=null,"Expected package attribute to be present in AndroidManifest.xml"),o}function zc(t,o){let e=t.manifest.application?.[0]?.$?.["android:name"];if(e){let s=e.replace(/\.[^.]+$/,"");if(s!==e&&s!==o)return s}return null}function rm(t,o,e){let s=t["meta-data"]??[],i=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.ENABLED");i!=null?((0,xt.default)(i.$!=null),i.$["android:value"]="true"):s.push({$:{"android:name":"expo.modules.updates.ENABLED","android:value":"true"}});let r=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.EXPO_RUNTIME_VERSION");r!=null?((0,xt.default)(r.$!=null),r.$["android:value"]=e):s.push({$:{"android:name":"expo.modules.updates.EXPO_RUNTIME_VERSION","android:value":e}});let a=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.EXPO_UPDATE_URL"),n=o.updates?.url;(0,xt.default)(n),a!=null?((0,xt.default)(a.$!=null),a.$["android:value"]=n):s.push({$:{"android:name":"expo.modules.updates.EXPO_UPDATE_URL","android:value":n}})}function Ei(t,o,e){return o==null?[]:e(t,o)?[o]:Object.keys(o).filter(s=>s!=="$"&&s!=="_").flatMap(s=>{let i=o[s];return Ei(s,i,e)})}function Xi(t,o){if(t==null)return;let e=t.$??{};for(let[s,i]of Object.entries(e))e[s]=o(i);for(let[s,i]of Object.entries(t))s==="$"||s==="_"||Xi(i,o)}var Kc="./debug.keystore";var rs=I(require("node:assert")),Zi=I(require("node:fs/promises")),Go=I(require("node:path")),Wt=I(bc());async function as(t,o){let{workingDirectory:e}=t,s=Go.default.join(e,"app.config");return await Zi.default.writeFile(s,JSON.stringify(o)),s}async function ns(t){let{platform:o,projectRoot:e,spawnAsync:s,workingDirectory:i}=t,{stdout:r}=await s("node",["-e","require('expo/scripts/resolveAppEntry')",e,o,"absolute"],{cwd:e,stdio:"pipe"}),a=Wt.default.silent(t.projectRoot,"expo-updates/utils/build/createUpdatesResources.js");return(0,rs.default)(a,"Failed to resolve `createUpdatesResources.js` within expo-updates package"),await s("node",[a,o,e,i,"all",r.trim()],{cwd:e}),Go.default.join(i,"app.manifest")}function cs(t){let o=vc(t);(0,rs.default)(o,"Failed to resolve '@expo/config' package in the project");let{getPackageJson:e}=require(o),s=e(t);return!!(s.dependencies&&"expo-updates"in s.dependencies)}async function ls(t,o){let{projectRoot:e,spawnAsync:s}=t,i=Wt.default.silent(e,"expo-updates/bin/cli")??(0,Wt.default)(e,"expo-updates/bin/cli.js"),{stdout:r}=await s(i,["runtimeversion:resolve","--platform","android","--workflow","managed"],{cwd:e,stdio:"pipe"});return JSON.parse(r).runtimeVersion??o.version??"1.0.0"}function vc(t){let o=Wt.default.silent(t,"expo/package.json");return o?Wt.default.silent(Go.default.dirname(o),"@expo/config")??null:null}function us(t,o){let e=vc(t);(0,rs.default)(e,"Failed to resolve '@expo/config' package in the project");let{getConfig:s}=require(e);return s(t,o)}async function _s(t,o){let{projectRoot:e,platform:s,spawnAsync:i,workingDirectory:r}=o,a=Go.default.resolve(r,"bundles");await Zi.default.mkdir(a,{recursive:!0});let{stdout:n}=await i("node",["-e","require('expo/scripts/resolveAppEntry')",e,s,"absolute"],{cwd:e,stdio:"pipe"}),c=cm(t,s),_=s==="android"?"index.android.bundle":"main.bundle",d=Go.default.join(a,_),O=Go.default.join(a,"assets"),g=["expo","export:embed","--platform",s,"--entry-file",n.trim(),"--bundle-output",Go.default.join(a,_),"--assets-dest",Go.default.join(a,"assets"),"--dev","false","--reset-cache"];return c?(g.push("--minify","false"),g.push("--bytecode","true"),g.push("--unstable-transform-profile","hermes")):g.push("--minify","true"),o.exportEmbedOptions?.sourcemapOutput&&g.push("--sourcemap-output",o.exportEmbedOptions.sourcemapOutput),await i("npx",g,{cwd:e}),{bundleOutputPath:d,assetRoot:O}}async function xs({appWorkingDirectory:t,options:o}){if(o.exportEmbedOptions!=null)return!0;let e;return o.platform==="android"?e=Go.default.join(t,"assets","index.android.bundle"):e=Go.default.join(t,"main.jsbundle"),await gc(e)}function cm(t,o){switch(o){case"android":return(t.android?.jsEngine??t.jsEngine)!=="jsc";case"ios":return(t.ios?.jsEngine??t.jsEngine)!=="jsc";default:return!1}}var lm=Uo.default.resolve(__dirname,Kc);async function pc(t){let o=await ee(t),{logger:e,spawnAsync:s,workingDirectory:i}=o;await mt.default.mkdir(i,{recursive:!0});let{exp:r}=us(o.projectRoot,{isPublicConfig:!0,skipSDKVersionRequirement:!0}),a=await _n(Uo.default.resolve(o.sourceAppPath),o);(0,Ii.default)(r.android?.package,"Expected app ID (`android.package`) to be defined in app.json");let n=cs(o.projectRoot),c=n?await ls(o,r):null;if(e.info(qc.default.dim(`Resolved runtime version: ${c}`)),await xs({appWorkingDirectory:a,options:o})){e.time("Generating bundle");let{assetRoot:l,bundleOutputPath:x}=await _s(r,o);if(e.timeEnd("Generating bundle"),e.time("Adding bundled resources"),await mn({decodedApkRoot:a,assetRoot:l,bundleOutputPath:x}),e.timeEnd("Adding bundled resources"),n){e.time("Generating 'app.manifest' for expo-updates");let u=await ns(o),G=Uo.default.join(a,"assets");await mt.default.copyFile(u,Uo.default.join(G,Uo.default.basename(u))),e.timeEnd("Generating 'app.manifest' for expo-updates")}}e.time("Updating AndroidManifest.xml");let d=Uo.default.join(a,"AndroidManifest.xml"),O=await yc(d),g=fc(O),w=new Set([g]),z=zc(O,g);z!=null&&w.add(z);let K=await Promise.any(Array.from(w).map(l=>hn(a,l,o)));(0,Ii.default)(K!=null,"Failed to search for dex classes with appId in the APK"),await dc({config:r,androidManiestXml:O,dexClasses:K,originalAppId:g,originalAppIdFallback:z,options:o,updatesRuntimeVersion:c}),await gn(a,r.android?.package),await hc(O,d),e.timeEnd("Updating AndroidManifest.xml"),e.time("Updating resources"),await wc({config:r,decodedApkRoot:a}),e.timeEnd("Updating resources"),e.time("Generating app config");let q=await as(o,r);await mt.default.copyFile(q,Uo.default.join(a,"assets","app.config")),e.timeEnd("Generating app config"),e.time("Creating updated apk");let v=await xn(a,o),p=Uo.default.join(i,"unzip");await mt.default.mkdir(p,{recursive:!0}),await s("unzip",["-o",v,"-d",p]);let m=await yn(p,o,{keyStorePath:o.androidSigningOptions?.keyStorePath??lm,keyStorePassword:o.androidSigningOptions?.keyStorePassword??"android",keyAlias:o.androidSigningOptions?.keyAlias,keyPassword:o.androidSigningOptions?.keyPassword});if(e.timeEnd("Creating updated apk"),await mt.default.rename(m,o.outputPath),!o.skipWorkingDirCleanup)try{await mt.default.rm(i,{recursive:!0})}catch{}return o.outputPath}var ci=I(require("node:assert")),lt=I(require("node:fs/promises")),Do=I(require("node:path")),ux=I(_i());var Bc=I(Lc(),1);var re=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var dm={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ae=t=>t.replace(/[[\]\\-]/g,"\\$&"),ym=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Tc=t=>t.join(""),Uc=(t,o)=>{let e=o;if(t.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=e+1,a=!1,n=!1,c=!1,_=!1,d=e,O="";o:for(;r<t.length;){let K=t.charAt(r);if((K==="!"||K==="^")&&r===e+1){_=!0,r++;continue}if(K==="]"&&a&&!c){d=r+1;break}if(a=!0,K==="\\"&&!c){c=!0,r++;continue}if(K==="["&&!c){for(let[q,[v,p,m]]of Object.entries(dm))if(t.startsWith(q,r)){if(O)return["$.",!1,t.length-e,!0];r+=q.length,m?i.push(v):s.push(v),n=n||p;continue o}}if(c=!1,O){K>O?s.push(ae(O)+"-"+ae(K)):K===O&&s.push(ae(K)),O="",r++;continue}if(t.startsWith("-]",r+1)){s.push(ae(K+"-")),r+=2;continue}if(t.startsWith("-",r+1)){O=K,r+=2;continue}s.push(ae(K)),r++}if(d<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,t.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!_){let K=s[0].length===2?s[0].slice(-1):s[0];return[ym(K),!1,d-e,!1]}let g="["+(_?"^":"")+Tc(s)+"]",w="["+(_?"":"^")+Tc(i)+"]";return[s.length&&i.length?"("+g+"|"+w+")":s.length?g:w,n,d-e,!0]};var Wo=(t,{windowsPathsNoEscape:o=!1}={})=>o?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var hm=new Set(["!","?","+","*","@"]),Qc=t=>hm.has(t),fm="(?!(?:^|/)\\.\\.?(?:$|/))",ms="(?!\\.)",zm=new Set(["[","."]),Km=new Set(["..","."]),km=new Set("().*{}+?[]^$\\!"),Gm=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ti="[^/]",Ac=Ti+"*?",jc=Ti+"+?",bt=class t{type;#o;#t;#r=!1;#s=[];#a;#f;#l;#_=!1;#n;#c;#i=!1;constructor(o,e,s={}){this.type=o,o&&(this.#t=!0),this.#a=e,this.#o=this.#a?this.#a.#o:this,this.#n=this.#o===this?s:this.#o.#n,this.#l=this.#o===this?[]:this.#o.#l,o==="!"&&!this.#o.#_&&this.#l.push(this),this.#f=this.#a?this.#a.#s.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let o of this.#s)if(typeof o!="string"&&(o.type||o.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#s.map(o=>String(o)).join("|")+")":this.#c=this.#s.map(o=>String(o)).join("")}#w(){if(this!==this.#o)throw new Error("should only call on root");if(this.#_)return this;this.toString(),this.#_=!0;let o;for(;o=this.#l.pop();){if(o.type!=="!")continue;let e=o,s=e.#a;for(;s;){for(let i=e.#f+1;!s.type&&i<s.#s.length;i++)for(let r of o.#s){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(s.#s[i])}e=s,s=e.#a}}return this}push(...o){for(let e of o)if(e!==""){if(typeof e!="string"&&!(e instanceof t&&e.#a===this))throw new Error("invalid part: "+e);this.#s.push(e)}}toJSON(){let o=this.type===null?this.#s.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#s.map(e=>e.toJSON())];return this.isStart()&&!this.type&&o.unshift([]),this.isEnd()&&(this===this.#o||this.#o.#_&&this.#a?.type==="!")&&o.push({}),o}isStart(){if(this.#o===this)return!0;if(!this.#a?.isStart())return!1;if(this.#f===0)return!0;let o=this.#a;for(let e=0;e<this.#f;e++){let s=o.#s[e];if(!(s instanceof t&&s.type==="!"))return!1}return!0}isEnd(){if(this.#o===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let o=this.#a?this.#a.#s.length:0;return this.#f===o-1}copyIn(o){typeof o=="string"?this.push(o):this.push(o.clone(this))}clone(o){let e=new t(this.type,o);for(let s of this.#s)e.copyIn(s);return e}static#d(o,e,s,i){let r=!1,a=!1,n=-1,c=!1;if(e.type===null){let w=s,z="";for(;w<o.length;){let K=o.charAt(w++);if(r||K==="\\"){r=!r,z+=K;continue}if(a){w===n+1?(K==="^"||K==="!")&&(c=!0):K==="]"&&!(w===n+2&&c)&&(a=!1),z+=K;continue}else if(K==="["){a=!0,n=w,c=!1,z+=K;continue}if(!i.noext&&Qc(K)&&o.charAt(w)==="("){e.push(z),z="";let q=new t(K,e);w=t.#d(o,q,w,i),e.push(q);continue}z+=K}return e.push(z),w}let _=s+1,d=new t(null,e),O=[],g="";for(;_<o.length;){let w=o.charAt(_++);if(r||w==="\\"){r=!r,g+=w;continue}if(a){_===n+1?(w==="^"||w==="!")&&(c=!0):w==="]"&&!(_===n+2&&c)&&(a=!1),g+=w;continue}else if(w==="["){a=!0,n=_,c=!1,g+=w;continue}if(Qc(w)&&o.charAt(_)==="("){d.push(g),g="";let z=new t(w,d);d.push(z),_=t.#d(o,z,_,i);continue}if(w==="|"){d.push(g),g="",O.push(d),d=new t(null,e);continue}if(w===")")return g===""&&e.#s.length===0&&(e.#i=!0),d.push(g),g="",e.push(...O,d),_;g+=w}return e.type=null,e.#t=void 0,e.#s=[o.substring(s-1)],_}static fromGlob(o,e={}){let s=new t(null,void 0,e);return t.#d(o,s,0,e),s}toMMPattern(){if(this!==this.#o)return this.#o.toMMPattern();let o=this.toString(),[e,s,i,r]=this.toRegExpSource();if(!(i||this.#t||this.#n.nocase&&!this.#n.nocaseMagicOnly&&o.toUpperCase()!==o.toLowerCase()))return s;let n=(this.#n.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,n),{_src:e,_glob:o})}get options(){return this.#n}toRegExpSource(o){let e=o??!!this.#n.dot;if(this.#o===this&&this.#w(),!this.type){let c=this.isStart()&&this.isEnd(),_=this.#s.map(w=>{let[z,K,q,v]=typeof w=="string"?t.#x(w,this.#t,c):w.toRegExpSource(o);return this.#t=this.#t||q,this.#r=this.#r||v,z}).join(""),d="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Km.has(this.#s[0]))){let z=zm,K=e&&z.has(_.charAt(0))||_.startsWith("\\.")&&z.has(_.charAt(2))||_.startsWith("\\.\\.")&&z.has(_.charAt(4)),q=!e&&!o&&z.has(_.charAt(0));d=K?fm:q?ms:""}let O="";return this.isEnd()&&this.#o.#_&&this.#a?.type==="!"&&(O="(?:$|\\/)"),[d+_+O,Wo(_),this.#t=!!this.#t,this.#r]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#m(e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#t=void 0,[c,Wo(this.toString()),!1,!1]}let a=!s||o||e||!ms?"":this.#m(!0);a===r&&(a=""),a&&(r=`(?:${r})(?:${a})*?`);let n="";if(this.type==="!"&&this.#i)n=(this.isStart()&&!e?ms:"")+jc;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!o?ms:"")+Ac+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;n=i+r+c}return[n,Wo(r),this.#t=!!this.#t,this.#r]}#m(o){return this.#s.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,i,r,a]=e.toRegExpSource(o);return this.#r=this.#r||a,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#x(o,e,s=!1){let i=!1,r="",a=!1;for(let n=0;n<o.length;n++){let c=o.charAt(n);if(i){i=!1,r+=(km.has(c)?"\\":"")+c;continue}if(c==="\\"){n===o.length-1?r+="\\\\":i=!0;continue}if(c==="["){let[_,d,O,g]=Uc(o,n);if(O){r+=_,a=a||d,n+=O-1,e=e||g;continue}}if(c==="*"){s&&o==="*"?r+=jc:r+=Ac,e=!0;continue}if(c==="?"){r+=Ti,e=!0;continue}r+=Gm(c)}return[r,Wo(o),!!e,a]}};var vt=(t,{windowsPathsNoEscape:o=!1}={})=>o?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var ro=(t,o,e={})=>(re(o),!e.nocomment&&o.charAt(0)==="#"?!1:new mo(o,e).match(t)),Wm=/^\*+([^+@!?\*\[\(]*)$/,bm=t=>o=>!o.startsWith(".")&&o.endsWith(t),vm=t=>o=>o.endsWith(t),qm=t=>(t=t.toLowerCase(),o=>!o.startsWith(".")&&o.toLowerCase().endsWith(t)),pm=t=>(t=t.toLowerCase(),o=>o.toLowerCase().endsWith(t)),Cm=/^\*+\.\*+$/,Nm=t=>!t.startsWith(".")&&t.includes("."),Sm=t=>t!=="."&&t!==".."&&t.includes("."),Fm=/^\.\*+$/,Mm=t=>t!=="."&&t!==".."&&t.startsWith("."),Vm=/^\*+$/,Em=t=>t.length!==0&&!t.startsWith("."),Xm=t=>t.length!==0&&t!=="."&&t!=="..",Ym=/^\?+([^+@!?\*\[\(]*)?$/,Zm=([t,o=""])=>{let e=Dc([t]);return o?(o=o.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(o)):e},Im=([t,o=""])=>{let e=$c([t]);return o?(o=o.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(o)):e},Pm=([t,o=""])=>{let e=$c([t]);return o?s=>e(s)&&s.endsWith(o):e},Lm=([t,o=""])=>{let e=Dc([t]);return o?s=>e(s)&&s.endsWith(o):e},Dc=([t])=>{let o=t.length;return e=>e.length===o&&!e.startsWith(".")},$c=([t])=>{let o=t.length;return e=>e.length===o&&e!=="."&&e!==".."},Hc=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Rc={win32:{sep:"\\"},posix:{sep:"/"}},Tm=Hc==="win32"?Rc.win32.sep:Rc.posix.sep;ro.sep=Tm;var oo=Symbol("globstar **");ro.GLOBSTAR=oo;var Um="[^/]",Qm=Um+"*?",Am="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",jm="(?:(?!(?:\\/|^)\\.).)*?",Rm=(t,o={})=>e=>ro(e,t,o);ro.filter=Rm;var ho=(t,o={})=>Object.assign({},t,o),Jm=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return ro;let o=ro;return Object.assign((s,i,r={})=>o(s,i,ho(t,r)),{Minimatch:class extends o.Minimatch{constructor(i,r={}){super(i,ho(t,r))}static defaults(i){return o.defaults(ho(t,i)).Minimatch}},AST:class extends o.AST{constructor(i,r,a={}){super(i,r,ho(t,a))}static fromGlob(i,r={}){return o.AST.fromGlob(i,ho(t,r))}},unescape:(s,i={})=>o.unescape(s,ho(t,i)),escape:(s,i={})=>o.escape(s,ho(t,i)),filter:(s,i={})=>o.filter(s,ho(t,i)),defaults:s=>o.defaults(ho(t,s)),makeRe:(s,i={})=>o.makeRe(s,ho(t,i)),braceExpand:(s,i={})=>o.braceExpand(s,ho(t,i)),match:(s,i,r={})=>o.match(s,i,ho(t,r)),sep:o.sep,GLOBSTAR:oo})};ro.defaults=Jm;var ol=(t,o={})=>(re(t),o.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,Bc.default)(t));ro.braceExpand=ol;var Bm=(t,o={})=>new mo(t,o).makeRe();ro.makeRe=Bm;var Dm=(t,o,e={})=>{let s=new mo(o,e);return t=t.filter(i=>s.match(i)),s.options.nonull&&!t.length&&t.push(o),t};ro.match=Dm;var Jc=/[?*]|[+@!]\(.*?\)|\[|\]/,$m=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mo=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(o,e={}){re(o),e=e||{},this.options=e,this.pattern=o,this.platform=e.platform||Hc,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let o of this.set)for(let e of o)if(typeof e!="string")return!0;return!1}debug(...o){}make(){let o=this.pattern,e=this.options;if(!e.nocomment&&o.charAt(0)==="#"){this.comment=!0;return}if(!o){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,a,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=r[0]===""&&r[1]===""&&(r[2]==="?"||!Jc.test(r[2]))&&!Jc.test(r[3]),_=/^[a-z]:/i.test(r[0]);if(c)return[...r.slice(0,4),...r.slice(4).map(d=>this.parse(d))];if(_)return[r[0],...r.slice(1).map(d=>this.parse(d))]}return r.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let a=this.set[r];a[0]===""&&a[1]===""&&this.globParts[r][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(o){if(this.options.noglobstar)for(let s=0;s<o.length;s++)for(let i=0;i<o[s].length;i++)o[s][i]==="**"&&(o[s][i]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(o=this.firstPhasePreProcess(o),o=this.secondPhasePreProcess(o)):e>=1?o=this.levelOneOptimize(o):o=this.adjascentGlobstarOptimize(o),o}adjascentGlobstarOptimize(o){return o.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let i=s;for(;e[i+1]==="**";)i++;i!==s&&e.splice(s,i-s)}return e})}levelOneOptimize(o){return o.map(e=>(e=e.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(o){Array.isArray(o)||(o=this.slashSplit(o));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<o.length-1;i++){let r=o[i];i===1&&r===""&&o[0]===""||(r==="."||r==="")&&(e=!0,o.splice(i,1),i--)}o[0]==="."&&o.length===2&&(o[1]==="."||o[1]==="")&&(e=!0,o.pop())}let s=0;for(;(s=o.indexOf("..",s+1))!==-1;){let i=o[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,o.splice(s-1,2),s-=2)}}while(e);return o.length===0?[""]:o}firstPhasePreProcess(o){let e=!1;do{e=!1;for(let s of o){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let a=i;for(;s[a+1]==="**";)a++;a>i&&s.splice(i+1,a-i);let n=s[i+1],c=s[i+2],_=s[i+3];if(n!==".."||!c||c==="."||c===".."||!_||_==="."||_==="..")continue;e=!0,s.splice(i,1);let d=s.slice(0);d[i]="**",o.push(d),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<s.length-1;a++){let n=s[a];a===1&&n===""&&s[0]===""||(n==="."||n==="")&&(e=!0,s.splice(a,1),a--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let a=s[r-1];if(a&&a!=="."&&a!==".."&&a!=="**"){e=!0;let c=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...c),s.length===0&&s.push(""),r-=2}}}}while(e);return o}secondPhasePreProcess(o){for(let e=0;e<o.length-1;e++)for(let s=e+1;s<o.length;s++){let i=this.partsMatch(o[e],o[s],!this.preserveMultipleSlashes);if(i){o[e]=[],o[s]=i;break}}return o.filter(e=>e.length)}partsMatch(o,e,s=!1){let i=0,r=0,a=[],n="";for(;i<o.length&&r<e.length;)if(o[i]===e[r])a.push(n==="b"?e[r]:o[i]),i++,r++;else if(s&&o[i]==="**"&&e[r]===o[i+1])a.push(o[i]),i++;else if(s&&e[r]==="**"&&o[i]===e[r+1])a.push(e[r]),r++;else if(o[i]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(n==="b")return!1;n="a",a.push(o[i]),i++,r++}else if(e[r]==="*"&&o[i]&&(this.options.dot||!o[i].startsWith("."))&&o[i]!=="**"){if(n==="a")return!1;n="b",a.push(e[r]),i++,r++}else return!1;return o.length===e.length&&a}parseNegate(){if(this.nonegate)return;let o=this.pattern,e=!1,s=0;for(let i=0;i<o.length&&o.charAt(i)==="!";i++)e=!e,s++;s&&(this.pattern=o.slice(s)),this.negate=e}matchOne(o,e,s=!1){let i=this.options;if(this.isWindows){let K=typeof o[0]=="string"&&/^[a-z]:$/i.test(o[0]),q=!K&&o[0]===""&&o[1]===""&&o[2]==="?"&&/^[a-z]:$/i.test(o[3]),v=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),p=!v&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),m=q?3:K?0:void 0,l=p?3:v?0:void 0;if(typeof m=="number"&&typeof l=="number"){let[x,u]=[o[m],e[l]];x.toLowerCase()===u.toLowerCase()&&(e[l]=x,l>m?e=e.slice(l):m>l&&(o=o.slice(m)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(o=this.levelTwoFileOptimize(o)),this.debug("matchOne",this,{file:o,pattern:e}),this.debug("matchOne",o.length,e.length);for(var a=0,n=0,c=o.length,_=e.length;a<c&&n<_;a++,n++){this.debug("matchOne loop");var d=e[n],O=o[a];if(this.debug(e,d,O),d===!1)return!1;if(d===oo){this.debug("GLOBSTAR",[e,d,O]);var g=a,w=n+1;if(w===_){for(this.debug("** at the end");a<c;a++)if(o[a]==="."||o[a]===".."||!i.dot&&o[a].charAt(0)===".")return!1;return!0}for(;g<c;){var z=o[g];if(this.debug(`
|
|
18
|
+
`).map(_=>_.match(/Class descriptor\s+?:\s+?'L(.+);'/)?.[1].replace(/\//g,".")).filter(Boolean);return new Set(c)}catch(n){return s.info(`Failed to search for classes in the APK - grepAppIdPattern[${o}]: ${n}`),null}}var xt=I(require("node:assert")),se=I(require("node:fs/promises")),Oc=I(require("node:path")),is=I(Ki());var xc=I(lc()),mc=I(require("node:assert")),_t=I(require("node:fs/promises")),Ht=I(require("node:path"));async function gc(t){return(await _t.default.stat(t).catch(()=>null))?.isFile()??!1}async function ss(t){return(await _t.default.stat(t).catch(()=>null))?.isDirectory()??!1}function te(t){return(0,mc.default)(t!=null,"Expected value to be non-null"),t}async function ee(t){let o=t.platform==="android"?".apk":".ipa";return{...t,workingDirectory:t.workingDirectory??await _t.default.mkdtemp(Ht.default.join(_c(),"repack-app-")),outputPath:t.outputPath??Ht.default.join(t.projectRoot,`repacked${o}`),logger:t.logger??new oe,spawnAsync:t.spawnAsync??im(!!t.verbose)}}var oe=class{debug(...o){console.debug(...o)}info(...o){console.log(...o)}warn(...o){console.warn(...o)}error(...o){console.error(...o)}time(o){console.time(o)}timeEnd(o){console.timeEnd(o)}};function im(t){return function(e,s,i){return(0,xc.default)(e,s,{stdio:t?"inherit":"pipe",...i})}}async function Gt(t,o){await _t.default.mkdir(o,{recursive:!0});let e=await _t.default.readdir(t,{withFileTypes:!0});for(let s of e){let i=Ht.default.join(t,s.name),r=Ht.default.join(o,s.name);s.isDirectory()?await Gt(i,r):s.isFile()&&await _t.default.copyFile(i,r)}}async function wc({config:t,decodedApkRoot:o}){let e=Oc.default.join(o,"res","values","strings.xml"),s=await se.default.readFile(e,"utf8");s=s.replace(/(<string name="app_name">)(.+)(<\/string>)/,`$1${t.name}$3`),await se.default.writeFile(e,s)}async function dc({config:t,androidManiestXml:o,dexClasses:e,originalAppId:s,originalAppIdFallback:i,updatesRuntimeVersion:r}){let a=te(t.android?.package);o.manifest.$.package=a,Xi(o,d=>d.startsWith(s)&&!e.has(d)?d.replace(s,a):d);let n=Ei("manifest",o.manifest,(d,O)=>d==="intent-filter"&&Ei(d,O,(g,w)=>g==="action"&&w[0].$?.["android:name"]==="android.intent.action.VIEW").length>0),c=Array.isArray(t.scheme)?t.scheme[0]:t.scheme;for(let d of n)Xi(d,O=>{let g=O.replace(s,a).replace(/^exp\+.+$/g,`exp+${te(t.slug)}`);return c&&(g=g.replace(/^myapp$/g,c)),i!=null&&(g=g.replace(i,a)),g});let _=o.manifest.application[0];(0,xt.default)(_.$?.["android:name"]?.endsWith(".MainApplication"),"Expected application node to be named as MainApplication"),r&&rm(_,t,r)}async function yc(t){let o=await se.default.readFile(t,"utf8");return await new is.Parser().parseStringPromise(o)}async function hc(t,o){let s=new is.Builder().buildObject(t);await se.default.writeFile(o,s)}function fc(t){let o=t.manifest.$.package;return(0,xt.default)(o!=null,"Expected package attribute to be present in AndroidManifest.xml"),o}function zc(t,o){let e=t.manifest.application?.[0]?.$?.["android:name"];if(e){let s=e.replace(/\.[^.]+$/,"");if(s!==e&&s!==o)return s}return null}function rm(t,o,e){let s=t["meta-data"]??[],i=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.ENABLED");i!=null?((0,xt.default)(i.$!=null),i.$["android:value"]="true"):s.push({$:{"android:name":"expo.modules.updates.ENABLED","android:value":"true"}});let r=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.EXPO_RUNTIME_VERSION");r!=null?((0,xt.default)(r.$!=null),r.$["android:value"]=e):s.push({$:{"android:name":"expo.modules.updates.EXPO_RUNTIME_VERSION","android:value":e}});let a=s.find(c=>c.$?.["android:name"]==="expo.modules.updates.EXPO_UPDATE_URL"),n=o.updates?.url;(0,xt.default)(n),a!=null?((0,xt.default)(a.$!=null),a.$["android:value"]=n):s.push({$:{"android:name":"expo.modules.updates.EXPO_UPDATE_URL","android:value":n}})}function Ei(t,o,e){return o==null?[]:e(t,o)?[o]:Object.keys(o).filter(s=>s!=="$"&&s!=="_").flatMap(s=>{let i=o[s];return Ei(s,i,e)})}function Xi(t,o){if(t==null)return;let e=t.$??{};for(let[s,i]of Object.entries(e))e[s]=o(i);for(let[s,i]of Object.entries(t))s==="$"||s==="_"||Xi(i,o)}var Kc="./debug.keystore";var rs=I(require("node:assert")),Zi=I(require("node:fs/promises")),Go=I(require("node:path")),Wt=I(bc());async function as(t,o){let{workingDirectory:e}=t,s=Go.default.join(e,"app.config");return await Zi.default.writeFile(s,JSON.stringify(o)),s}async function ns(t){let{platform:o,projectRoot:e,spawnAsync:s,workingDirectory:i}=t,{stdout:r}=await s("node",["-e","require('expo/scripts/resolveAppEntry')",e,o,"absolute"],{cwd:e,stdio:"pipe"}),a=Wt.default.silent(t.projectRoot,"expo-updates/utils/build/createUpdatesResources.js");return(0,rs.default)(a,"Failed to resolve `createUpdatesResources.js` within expo-updates package"),await s("node",[a,o,e,i,"all",r.trim()],{cwd:e}),Go.default.join(i,"app.manifest")}function cs(t){let o=vc(t);(0,rs.default)(o,"Failed to resolve '@expo/config' package in the project");let{getPackageJson:e}=require(o),s=e(t);return!!(s.dependencies&&"expo-updates"in s.dependencies)}async function ls(t,o){let{projectRoot:e,spawnAsync:s}=t,i=Wt.default.silent(e,"expo-updates/bin/cli")??(0,Wt.default)(e,"expo-updates/bin/cli.js"),{stdout:r}=await s(i,["runtimeversion:resolve","--platform","android","--workflow","managed"],{cwd:e,stdio:"pipe"});return JSON.parse(r).runtimeVersion??o.version??"1.0.0"}function vc(t){let o=Wt.default.silent(t,"expo/package.json");return o?Wt.default.silent(Go.default.dirname(o),"@expo/config")??null:null}function us(t,o){let e=vc(t);(0,rs.default)(e,"Failed to resolve '@expo/config' package in the project");let{getConfig:s}=require(e);return s(t,o)}async function _s(t,o){let{projectRoot:e,platform:s,spawnAsync:i,workingDirectory:r}=o,a=Go.default.resolve(r,"bundles");await Zi.default.mkdir(a,{recursive:!0});let{stdout:n}=await i("node",["-e","require('expo/scripts/resolveAppEntry')",e,s,"absolute"],{cwd:e,stdio:"pipe"}),c=cm(t,s),_=s==="android"?"index.android.bundle":"main.bundle",d=Go.default.join(a,_),O=Go.default.join(a,"assets"),g=["expo","export:embed","--platform",s,"--entry-file",n.trim(),"--bundle-output",Go.default.join(a,_),"--assets-dest",Go.default.join(a,"assets"),"--dev","false","--reset-cache"];return c?(g.push("--minify","false"),g.push("--bytecode","true"),g.push("--unstable-transform-profile","hermes")):g.push("--minify","true"),o.exportEmbedOptions?.sourcemapOutput&&g.push("--sourcemap-output",o.exportEmbedOptions.sourcemapOutput),await i("npx",g,{cwd:e}),{bundleOutputPath:d,assetRoot:O}}async function xs({appWorkingDirectory:t,options:o}){if(o.exportEmbedOptions!=null)return!0;let e;return o.platform==="android"?e=Go.default.join(t,"assets","index.android.bundle"):e=Go.default.join(t,"main.jsbundle"),await gc(e)}function cm(t,o){switch(o){case"android":return(t.android?.jsEngine??t.jsEngine)!=="jsc";case"ios":return(t.ios?.jsEngine??t.jsEngine)!=="jsc";default:return!1}}var lm=Uo.default.resolve(__dirname,Kc);async function pc(t){let o=await ee(t),{logger:e,spawnAsync:s,workingDirectory:i}=o;await mt.default.mkdir(i,{recursive:!0});let{exp:r}=us(o.projectRoot,{isPublicConfig:!0,skipSDKVersionRequirement:!0}),a=await _n(Uo.default.resolve(o.sourceAppPath),o);(0,Ii.default)(r.android?.package,"Expected app ID (`android.package`) to be defined in app.json");let n=cs(o.projectRoot),c=n?await ls(o,r):null;if(e.info(qc.default.dim(`Resolved runtime version: ${c}`)),await xs({appWorkingDirectory:a,options:o})){e.time("Generating bundle");let{assetRoot:l,bundleOutputPath:x}=await _s(r,o);if(e.timeEnd("Generating bundle"),e.time("Adding bundled resources"),await mn({decodedApkRoot:a,assetRoot:l,bundleOutputPath:x}),e.timeEnd("Adding bundled resources"),n){e.time("Generating 'app.manifest' for expo-updates");let u=await ns(o),G=Uo.default.join(a,"assets");await mt.default.copyFile(u,Uo.default.join(G,Uo.default.basename(u))),e.timeEnd("Generating 'app.manifest' for expo-updates")}}e.time("Updating AndroidManifest.xml");let d=Uo.default.join(a,"AndroidManifest.xml"),O=await yc(d),g=fc(O),w=new Set([g]),z=zc(O,g);z!=null&&w.add(z);let K=await Promise.any(Array.from(w).map(l=>hn(a,l,o)));(0,Ii.default)(K!=null,"Failed to search for dex classes with appId in the APK"),await dc({config:r,androidManiestXml:O,dexClasses:K,originalAppId:g,originalAppIdFallback:z,options:o,updatesRuntimeVersion:c}),await gn(a,r.android?.package),await hc(O,d),e.timeEnd("Updating AndroidManifest.xml"),e.time("Updating resources"),await wc({config:r,decodedApkRoot:a}),e.timeEnd("Updating resources"),e.time("Generating app config");let q=await as(o,r);await mt.default.copyFile(q,Uo.default.join(a,"assets","app.config")),e.timeEnd("Generating app config"),e.time("Creating updated apk");let v=await xn(a,o),p=Uo.default.join(i,"unzip");await mt.default.mkdir(p,{recursive:!0}),await s("unzip",["-o",v,"-d",p]);let m=await yn(p,o,{keyStorePath:o.androidSigningOptions?.keyStorePath??lm,keyStorePassword:o.androidSigningOptions?.keyStorePassword??"pass:android",keyAlias:o.androidSigningOptions?.keyAlias,keyPassword:o.androidSigningOptions?.keyPassword});if(e.timeEnd("Creating updated apk"),await mt.default.rename(m,o.outputPath),!o.skipWorkingDirCleanup)try{await mt.default.rm(i,{recursive:!0})}catch{}return o.outputPath}var ci=I(require("node:assert")),lt=I(require("node:fs/promises")),Do=I(require("node:path")),ux=I(_i());var Bc=I(Lc(),1);var re=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var dm={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ae=t=>t.replace(/[[\]\\-]/g,"\\$&"),ym=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Tc=t=>t.join(""),Uc=(t,o)=>{let e=o;if(t.charAt(e)!=="[")throw new Error("not in a brace expression");let s=[],i=[],r=e+1,a=!1,n=!1,c=!1,_=!1,d=e,O="";o:for(;r<t.length;){let K=t.charAt(r);if((K==="!"||K==="^")&&r===e+1){_=!0,r++;continue}if(K==="]"&&a&&!c){d=r+1;break}if(a=!0,K==="\\"&&!c){c=!0,r++;continue}if(K==="["&&!c){for(let[q,[v,p,m]]of Object.entries(dm))if(t.startsWith(q,r)){if(O)return["$.",!1,t.length-e,!0];r+=q.length,m?i.push(v):s.push(v),n=n||p;continue o}}if(c=!1,O){K>O?s.push(ae(O)+"-"+ae(K)):K===O&&s.push(ae(K)),O="",r++;continue}if(t.startsWith("-]",r+1)){s.push(ae(K+"-")),r+=2;continue}if(t.startsWith("-",r+1)){O=K,r+=2;continue}s.push(ae(K)),r++}if(d<r)return["",!1,0,!1];if(!s.length&&!i.length)return["$.",!1,t.length-e,!0];if(i.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!_){let K=s[0].length===2?s[0].slice(-1):s[0];return[ym(K),!1,d-e,!1]}let g="["+(_?"^":"")+Tc(s)+"]",w="["+(_?"":"^")+Tc(i)+"]";return[s.length&&i.length?"("+g+"|"+w+")":s.length?g:w,n,d-e,!0]};var Wo=(t,{windowsPathsNoEscape:o=!1}={})=>o?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var hm=new Set(["!","?","+","*","@"]),Qc=t=>hm.has(t),fm="(?!(?:^|/)\\.\\.?(?:$|/))",ms="(?!\\.)",zm=new Set(["[","."]),Km=new Set(["..","."]),km=new Set("().*{}+?[]^$\\!"),Gm=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ti="[^/]",Ac=Ti+"*?",jc=Ti+"+?",bt=class t{type;#o;#t;#r=!1;#s=[];#a;#f;#l;#_=!1;#n;#c;#i=!1;constructor(o,e,s={}){this.type=o,o&&(this.#t=!0),this.#a=e,this.#o=this.#a?this.#a.#o:this,this.#n=this.#o===this?s:this.#o.#n,this.#l=this.#o===this?[]:this.#o.#l,o==="!"&&!this.#o.#_&&this.#l.push(this),this.#f=this.#a?this.#a.#s.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let o of this.#s)if(typeof o!="string"&&(o.type||o.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#s.map(o=>String(o)).join("|")+")":this.#c=this.#s.map(o=>String(o)).join("")}#w(){if(this!==this.#o)throw new Error("should only call on root");if(this.#_)return this;this.toString(),this.#_=!0;let o;for(;o=this.#l.pop();){if(o.type!=="!")continue;let e=o,s=e.#a;for(;s;){for(let i=e.#f+1;!s.type&&i<s.#s.length;i++)for(let r of o.#s){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(s.#s[i])}e=s,s=e.#a}}return this}push(...o){for(let e of o)if(e!==""){if(typeof e!="string"&&!(e instanceof t&&e.#a===this))throw new Error("invalid part: "+e);this.#s.push(e)}}toJSON(){let o=this.type===null?this.#s.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#s.map(e=>e.toJSON())];return this.isStart()&&!this.type&&o.unshift([]),this.isEnd()&&(this===this.#o||this.#o.#_&&this.#a?.type==="!")&&o.push({}),o}isStart(){if(this.#o===this)return!0;if(!this.#a?.isStart())return!1;if(this.#f===0)return!0;let o=this.#a;for(let e=0;e<this.#f;e++){let s=o.#s[e];if(!(s instanceof t&&s.type==="!"))return!1}return!0}isEnd(){if(this.#o===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let o=this.#a?this.#a.#s.length:0;return this.#f===o-1}copyIn(o){typeof o=="string"?this.push(o):this.push(o.clone(this))}clone(o){let e=new t(this.type,o);for(let s of this.#s)e.copyIn(s);return e}static#d(o,e,s,i){let r=!1,a=!1,n=-1,c=!1;if(e.type===null){let w=s,z="";for(;w<o.length;){let K=o.charAt(w++);if(r||K==="\\"){r=!r,z+=K;continue}if(a){w===n+1?(K==="^"||K==="!")&&(c=!0):K==="]"&&!(w===n+2&&c)&&(a=!1),z+=K;continue}else if(K==="["){a=!0,n=w,c=!1,z+=K;continue}if(!i.noext&&Qc(K)&&o.charAt(w)==="("){e.push(z),z="";let q=new t(K,e);w=t.#d(o,q,w,i),e.push(q);continue}z+=K}return e.push(z),w}let _=s+1,d=new t(null,e),O=[],g="";for(;_<o.length;){let w=o.charAt(_++);if(r||w==="\\"){r=!r,g+=w;continue}if(a){_===n+1?(w==="^"||w==="!")&&(c=!0):w==="]"&&!(_===n+2&&c)&&(a=!1),g+=w;continue}else if(w==="["){a=!0,n=_,c=!1,g+=w;continue}if(Qc(w)&&o.charAt(_)==="("){d.push(g),g="";let z=new t(w,d);d.push(z),_=t.#d(o,z,_,i);continue}if(w==="|"){d.push(g),g="",O.push(d),d=new t(null,e);continue}if(w===")")return g===""&&e.#s.length===0&&(e.#i=!0),d.push(g),g="",e.push(...O,d),_;g+=w}return e.type=null,e.#t=void 0,e.#s=[o.substring(s-1)],_}static fromGlob(o,e={}){let s=new t(null,void 0,e);return t.#d(o,s,0,e),s}toMMPattern(){if(this!==this.#o)return this.#o.toMMPattern();let o=this.toString(),[e,s,i,r]=this.toRegExpSource();if(!(i||this.#t||this.#n.nocase&&!this.#n.nocaseMagicOnly&&o.toUpperCase()!==o.toLowerCase()))return s;let n=(this.#n.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${e}$`,n),{_src:e,_glob:o})}get options(){return this.#n}toRegExpSource(o){let e=o??!!this.#n.dot;if(this.#o===this&&this.#w(),!this.type){let c=this.isStart()&&this.isEnd(),_=this.#s.map(w=>{let[z,K,q,v]=typeof w=="string"?t.#x(w,this.#t,c):w.toRegExpSource(o);return this.#t=this.#t||q,this.#r=this.#r||v,z}).join(""),d="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&Km.has(this.#s[0]))){let z=zm,K=e&&z.has(_.charAt(0))||_.startsWith("\\.")&&z.has(_.charAt(2))||_.startsWith("\\.\\.")&&z.has(_.charAt(4)),q=!e&&!o&&z.has(_.charAt(0));d=K?fm:q?ms:""}let O="";return this.isEnd()&&this.#o.#_&&this.#a?.type==="!"&&(O="(?:$|\\/)"),[d+_+O,Wo(_),this.#t=!!this.#t,this.#r]}let s=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#m(e);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#t=void 0,[c,Wo(this.toString()),!1,!1]}let a=!s||o||e||!ms?"":this.#m(!0);a===r&&(a=""),a&&(r=`(?:${r})(?:${a})*?`);let n="";if(this.type==="!"&&this.#i)n=(this.isStart()&&!e?ms:"")+jc;else{let c=this.type==="!"?"))"+(this.isStart()&&!e&&!o?ms:"")+Ac+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&a?")":this.type==="*"&&a?")?":`)${this.type}`;n=i+r+c}return[n,Wo(r),this.#t=!!this.#t,this.#r]}#m(o){return this.#s.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");let[s,i,r,a]=e.toRegExpSource(o);return this.#r=this.#r||a,s}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#x(o,e,s=!1){let i=!1,r="",a=!1;for(let n=0;n<o.length;n++){let c=o.charAt(n);if(i){i=!1,r+=(km.has(c)?"\\":"")+c;continue}if(c==="\\"){n===o.length-1?r+="\\\\":i=!0;continue}if(c==="["){let[_,d,O,g]=Uc(o,n);if(O){r+=_,a=a||d,n+=O-1,e=e||g;continue}}if(c==="*"){s&&o==="*"?r+=jc:r+=Ac,e=!0;continue}if(c==="?"){r+=Ti,e=!0;continue}r+=Gm(c)}return[r,Wo(o),!!e,a]}};var vt=(t,{windowsPathsNoEscape:o=!1}={})=>o?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var ro=(t,o,e={})=>(re(o),!e.nocomment&&o.charAt(0)==="#"?!1:new mo(o,e).match(t)),Wm=/^\*+([^+@!?\*\[\(]*)$/,bm=t=>o=>!o.startsWith(".")&&o.endsWith(t),vm=t=>o=>o.endsWith(t),qm=t=>(t=t.toLowerCase(),o=>!o.startsWith(".")&&o.toLowerCase().endsWith(t)),pm=t=>(t=t.toLowerCase(),o=>o.toLowerCase().endsWith(t)),Cm=/^\*+\.\*+$/,Nm=t=>!t.startsWith(".")&&t.includes("."),Sm=t=>t!=="."&&t!==".."&&t.includes("."),Fm=/^\.\*+$/,Mm=t=>t!=="."&&t!==".."&&t.startsWith("."),Vm=/^\*+$/,Em=t=>t.length!==0&&!t.startsWith("."),Xm=t=>t.length!==0&&t!=="."&&t!=="..",Ym=/^\?+([^+@!?\*\[\(]*)?$/,Zm=([t,o=""])=>{let e=Dc([t]);return o?(o=o.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(o)):e},Im=([t,o=""])=>{let e=$c([t]);return o?(o=o.toLowerCase(),s=>e(s)&&s.toLowerCase().endsWith(o)):e},Pm=([t,o=""])=>{let e=$c([t]);return o?s=>e(s)&&s.endsWith(o):e},Lm=([t,o=""])=>{let e=Dc([t]);return o?s=>e(s)&&s.endsWith(o):e},Dc=([t])=>{let o=t.length;return e=>e.length===o&&!e.startsWith(".")},$c=([t])=>{let o=t.length;return e=>e.length===o&&e!=="."&&e!==".."},Hc=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Rc={win32:{sep:"\\"},posix:{sep:"/"}},Tm=Hc==="win32"?Rc.win32.sep:Rc.posix.sep;ro.sep=Tm;var oo=Symbol("globstar **");ro.GLOBSTAR=oo;var Um="[^/]",Qm=Um+"*?",Am="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",jm="(?:(?!(?:\\/|^)\\.).)*?",Rm=(t,o={})=>e=>ro(e,t,o);ro.filter=Rm;var ho=(t,o={})=>Object.assign({},t,o),Jm=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return ro;let o=ro;return Object.assign((s,i,r={})=>o(s,i,ho(t,r)),{Minimatch:class extends o.Minimatch{constructor(i,r={}){super(i,ho(t,r))}static defaults(i){return o.defaults(ho(t,i)).Minimatch}},AST:class extends o.AST{constructor(i,r,a={}){super(i,r,ho(t,a))}static fromGlob(i,r={}){return o.AST.fromGlob(i,ho(t,r))}},unescape:(s,i={})=>o.unescape(s,ho(t,i)),escape:(s,i={})=>o.escape(s,ho(t,i)),filter:(s,i={})=>o.filter(s,ho(t,i)),defaults:s=>o.defaults(ho(t,s)),makeRe:(s,i={})=>o.makeRe(s,ho(t,i)),braceExpand:(s,i={})=>o.braceExpand(s,ho(t,i)),match:(s,i,r={})=>o.match(s,i,ho(t,r)),sep:o.sep,GLOBSTAR:oo})};ro.defaults=Jm;var ol=(t,o={})=>(re(t),o.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,Bc.default)(t));ro.braceExpand=ol;var Bm=(t,o={})=>new mo(t,o).makeRe();ro.makeRe=Bm;var Dm=(t,o,e={})=>{let s=new mo(o,e);return t=t.filter(i=>s.match(i)),s.options.nonull&&!t.length&&t.push(o),t};ro.match=Dm;var Jc=/[?*]|[+@!]\(.*?\)|\[|\]/,$m=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mo=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(o,e={}){re(o),e=e||{},this.options=e,this.pattern=o,this.platform=e.platform||Hc,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let o of this.set)for(let e of o)if(typeof e!="string")return!0;return!1}debug(...o){}make(){let o=this.pattern,e=this.options;if(!e.nocomment&&o.charAt(0)==="#"){this.comment=!0;return}if(!o){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,a,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=r[0]===""&&r[1]===""&&(r[2]==="?"||!Jc.test(r[2]))&&!Jc.test(r[3]),_=/^[a-z]:/i.test(r[0]);if(c)return[...r.slice(0,4),...r.slice(4).map(d=>this.parse(d))];if(_)return[r[0],...r.slice(1).map(d=>this.parse(d))]}return r.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let a=this.set[r];a[0]===""&&a[1]===""&&this.globParts[r][2]==="?"&&typeof a[3]=="string"&&/^[a-z]:$/i.test(a[3])&&(a[2]="?")}this.debug(this.pattern,this.set)}preprocess(o){if(this.options.noglobstar)for(let s=0;s<o.length;s++)for(let i=0;i<o[s].length;i++)o[s][i]==="**"&&(o[s][i]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(o=this.firstPhasePreProcess(o),o=this.secondPhasePreProcess(o)):e>=1?o=this.levelOneOptimize(o):o=this.adjascentGlobstarOptimize(o),o}adjascentGlobstarOptimize(o){return o.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let i=s;for(;e[i+1]==="**";)i++;i!==s&&e.splice(s,i-s)}return e})}levelOneOptimize(o){return o.map(e=>(e=e.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(o){Array.isArray(o)||(o=this.slashSplit(o));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<o.length-1;i++){let r=o[i];i===1&&r===""&&o[0]===""||(r==="."||r==="")&&(e=!0,o.splice(i,1),i--)}o[0]==="."&&o.length===2&&(o[1]==="."||o[1]==="")&&(e=!0,o.pop())}let s=0;for(;(s=o.indexOf("..",s+1))!==-1;){let i=o[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,o.splice(s-1,2),s-=2)}}while(e);return o.length===0?[""]:o}firstPhasePreProcess(o){let e=!1;do{e=!1;for(let s of o){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let a=i;for(;s[a+1]==="**";)a++;a>i&&s.splice(i+1,a-i);let n=s[i+1],c=s[i+2],_=s[i+3];if(n!==".."||!c||c==="."||c===".."||!_||_==="."||_==="..")continue;e=!0,s.splice(i,1);let d=s.slice(0);d[i]="**",o.push(d),i--}if(!this.preserveMultipleSlashes){for(let a=1;a<s.length-1;a++){let n=s[a];a===1&&n===""&&s[0]===""||(n==="."||n==="")&&(e=!0,s.splice(a,1),a--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let a=s[r-1];if(a&&a!=="."&&a!==".."&&a!=="**"){e=!0;let c=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...c),s.length===0&&s.push(""),r-=2}}}}while(e);return o}secondPhasePreProcess(o){for(let e=0;e<o.length-1;e++)for(let s=e+1;s<o.length;s++){let i=this.partsMatch(o[e],o[s],!this.preserveMultipleSlashes);if(i){o[e]=[],o[s]=i;break}}return o.filter(e=>e.length)}partsMatch(o,e,s=!1){let i=0,r=0,a=[],n="";for(;i<o.length&&r<e.length;)if(o[i]===e[r])a.push(n==="b"?e[r]:o[i]),i++,r++;else if(s&&o[i]==="**"&&e[r]===o[i+1])a.push(o[i]),i++;else if(s&&e[r]==="**"&&o[i]===e[r+1])a.push(e[r]),r++;else if(o[i]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(n==="b")return!1;n="a",a.push(o[i]),i++,r++}else if(e[r]==="*"&&o[i]&&(this.options.dot||!o[i].startsWith("."))&&o[i]!=="**"){if(n==="a")return!1;n="b",a.push(e[r]),i++,r++}else return!1;return o.length===e.length&&a}parseNegate(){if(this.nonegate)return;let o=this.pattern,e=!1,s=0;for(let i=0;i<o.length&&o.charAt(i)==="!";i++)e=!e,s++;s&&(this.pattern=o.slice(s)),this.negate=e}matchOne(o,e,s=!1){let i=this.options;if(this.isWindows){let K=typeof o[0]=="string"&&/^[a-z]:$/i.test(o[0]),q=!K&&o[0]===""&&o[1]===""&&o[2]==="?"&&/^[a-z]:$/i.test(o[3]),v=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),p=!v&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),m=q?3:K?0:void 0,l=p?3:v?0:void 0;if(typeof m=="number"&&typeof l=="number"){let[x,u]=[o[m],e[l]];x.toLowerCase()===u.toLowerCase()&&(e[l]=x,l>m?e=e.slice(l):m>l&&(o=o.slice(m)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(o=this.levelTwoFileOptimize(o)),this.debug("matchOne",this,{file:o,pattern:e}),this.debug("matchOne",o.length,e.length);for(var a=0,n=0,c=o.length,_=e.length;a<c&&n<_;a++,n++){this.debug("matchOne loop");var d=e[n],O=o[a];if(this.debug(e,d,O),d===!1)return!1;if(d===oo){this.debug("GLOBSTAR",[e,d,O]);var g=a,w=n+1;if(w===_){for(this.debug("** at the end");a<c;a++)if(o[a]==="."||o[a]===".."||!i.dot&&o[a].charAt(0)===".")return!1;return!0}for(;g<c;){var z=o[g];if(this.debug(`
|
|
19
19
|
globstar while`,o,g,e,w,z),this.matchOne(o.slice(g),e.slice(w),s))return this.debug("globstar found match!",g,c,z),!0;if(z==="."||z===".."||!i.dot&&z.charAt(0)==="."){this.debug("dot detected!",o,g,e,w);break}this.debug("globstar swallow a segment, and continue"),g++}return!!(s&&(this.debug(`
|
|
20
20
|
>>> no match, partial?`,o,g,e,w),g===c))}let K;if(typeof d=="string"?(K=O===d,this.debug("string match",d,O,K)):(K=d.test(O),this.debug("pattern match",d,O,K)),!K)return!1}if(a===c&&n===_)return!0;if(a===c)return s;if(n===_)return a===c-1&&o[a]==="";throw new Error("wtf?")}braceExpand(){return ol(this.pattern,this.options)}parse(o){re(o);let e=this.options;if(o==="**")return oo;if(o==="")return"";let s,i=null;(s=o.match(Vm))?i=e.dot?Xm:Em:(s=o.match(Wm))?i=(e.nocase?e.dot?pm:qm:e.dot?vm:bm)(s[1]):(s=o.match(Ym))?i=(e.nocase?e.dot?Im:Zm:e.dot?Pm:Lm)(s):(s=o.match(Cm))?i=e.dot?Sm:Nm:(s=o.match(Fm))&&(i=Mm);let r=bt.fromGlob(o,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let o=this.set;if(!o.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Qm:e.dot?Am:jm,i=new Set(e.nocase?["i"]:[]),r=o.map(c=>{let _=c.map(d=>{if(d instanceof RegExp)for(let O of d.flags.split(""))i.add(O);return typeof d=="string"?$m(d):d===oo?oo:d._src});return _.forEach((d,O)=>{let g=_[O+1],w=_[O-1];d!==oo||w===oo||(w===void 0?g!==void 0&&g!==oo?_[O+1]="(?:\\/|"+s+"\\/)?"+g:_[O]=s:g===void 0?_[O-1]=w+"(?:\\/|"+s+")?":g!==oo&&(_[O-1]=w+"(?:\\/|\\/"+s+"\\/)"+g,_[O+1]=oo))}),_.filter(d=>d!==oo).join("/")}).join("|"),[a,n]=o.length>1?["(?:",")"]:["",""];r="^"+a+r+n+"$",this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(o){return this.preserveMultipleSlashes?o.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(o)?["",...o.split(/\/+/)]:o.split(/\/+/)}match(o,e=this.partial){if(this.debug("match",o,this.pattern),this.comment)return!1;if(this.empty)return o==="";if(o==="/"&&e)return!0;let s=this.options;this.isWindows&&(o=o.split("\\").join("/"));let i=this.slashSplit(o);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let a=i[i.length-1];if(!a)for(let n=i.length-2;!a&&n>=0;n--)a=i[n];for(let n=0;n<r.length;n++){let c=r[n],_=i;if(s.matchBase&&c.length===1&&(_=[a]),this.matchOne(_,c,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(o){return ro.defaults(o).Minimatch}};ro.AST=bt;ro.Minimatch=mo;ro.escape=vt;ro.unescape=Wo;var Gl=require("node:url");var qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,el=new Set,Ui=typeof process=="object"&&process?process:{},sl=(t,o,e,s)=>{typeof Ui.emitWarning=="function"?Ui.emitWarning(t,o,e,s):console.error(`[${e}] ${o}: ${t}`)},gs=globalThis.AbortController,tl=globalThis.AbortSignal;if(typeof gs>"u"){tl=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},gs=class{constructor(){o()}signal=new tl;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let t=Ui.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",o=()=>{t&&(t=!1,sl("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",o))}}var Hm=t=>!el.has(t),bw=Symbol("type"),tt=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),il=t=>tt(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?pt:null:null,pt=class extends Array{constructor(o){super(o),this.fill(0)}},Qi=class t{heap;length;static#o=!1;static create(o){let e=il(o);if(!e)return[];t.#o=!0;let s=new t(o,e);return t.#o=!1,s}constructor(o,e){if(!t.#o)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(o),this.length=0}push(o){this.heap[this.length++]=o}pop(){return this.heap[--this.length]}},ne=class t{#o;#t;#r;#s;#a;#f;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#_;#n;#c;#i;#w;#d;#m;#x;#k;#O;#G;#W;#h;#z;#K;#g;static unsafeExposeInternals(o){return{starts:o.#W,ttls:o.#h,sizes:o.#G,keyMap:o.#n,keyList:o.#c,valList:o.#i,next:o.#w,prev:o.#d,get head(){return o.#m},get tail(){return o.#x},free:o.#k,isBackgroundFetch:e=>o.#u(e),backgroundFetch:(e,s,i,r)=>o.#Y(e,s,i,r),moveToTail:e=>o.#I(e),indexes:e=>o.#v(e),rindexes:e=>o.#q(e),isStale:e=>o.#y(e)}}get max(){return this.#o}get maxSize(){return this.#t}get calculatedSize(){return this.#_}get size(){return this.#l}get fetchMethod(){return this.#a}get memoMethod(){return this.#f}get dispose(){return this.#r}get disposeAfter(){return this.#s}constructor(o){let{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:n,allowStale:c,dispose:_,disposeAfter:d,noDisposeOnSet:O,noUpdateTTL:g,maxSize:w=0,maxEntrySize:z=0,sizeCalculation:K,fetchMethod:q,memoMethod:v,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:m,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:x,ignoreFetchAbort:u}=o;if(e!==0&&!tt(e))throw new TypeError("max option must be a nonnegative integer");let G=e?il(e):Array;if(!G)throw new Error("invalid max value: "+e);if(this.#o=e,this.#t=w,this.maxEntrySize=z||this.#t,this.sizeCalculation=K,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(v!==void 0&&typeof v!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#f=v,q!==void 0&&typeof q!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#a=q,this.#K=!!q,this.#n=new Map,this.#c=new Array(e).fill(void 0),this.#i=new Array(e).fill(void 0),this.#w=new G(e),this.#d=new G(e),this.#m=0,this.#x=0,this.#k=Qi.create(e),this.#l=0,this.#_=0,typeof _=="function"&&(this.#r=_),typeof d=="function"?(this.#s=d,this.#O=[]):(this.#s=void 0,this.#O=void 0),this.#z=!!this.#r,this.#g=!!this.#s,this.noDisposeOnSet=!!O,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!l,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!u,this.maxEntrySize!==0){if(this.#t!==0&&!tt(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#C()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!m,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!n,this.ttlResolution=tt(i)||i===0?i:1,this.ttlAutopurge=!!r,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#p()}if(this.#o===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#o&&!this.#t){let y="LRU_CACHE_UNBOUNDED";Hm(y)&&(el.add(y),sl("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",y,t))}}getRemainingTTL(o){return this.#n.has(o)?1/0:0}#p(){let o=new pt(this.#o),e=new pt(this.#o);this.#h=o,this.#W=e,this.#S=(r,a,n=qt.now())=>{if(e[r]=a!==0?n:0,o[r]=a,a!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#y(r)&&this.#N(this.#c[r],"expire")},a+1);c.unref&&c.unref()}},this.#b=r=>{e[r]=o[r]!==0?qt.now():0},this.#e=(r,a)=>{if(o[a]){let n=o[a],c=e[a];if(!n||!c)return;r.ttl=n,r.start=c,r.now=s||i();let _=r.now-c;r.remainingTTL=n-_}};let s=0,i=()=>{let r=qt.now();if(this.ttlResolution>0){s=r;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return r};this.getRemainingTTL=r=>{let a=this.#n.get(r);if(a===void 0)return 0;let n=o[a],c=e[a];if(!n||!c)return 1/0;let _=(s||i())-c;return n-_},this.#y=r=>{let a=e[r],n=o[r];return!!n&&!!a&&(s||i())-a>n}}#b=()=>{};#e=()=>{};#S=()=>{};#y=()=>!1;#C(){let o=new pt(this.#o);this.#_=0,this.#G=o,this.#F=e=>{this.#_-=o[e],o[e]=0},this.#V=(e,s,i,r)=>{if(this.#u(s))return 0;if(!tt(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(s,e),!tt(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#M=(e,s,i)=>{if(o[e]=s,this.#t){let r=this.#t-o[e];for(;this.#_>r;)this.#X(!0)}this.#_+=o[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#_)}}#F=o=>{};#M=(o,e,s)=>{};#V=(o,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#v({allowStale:o=this.allowStale}={}){if(this.#l)for(let e=this.#x;!(!this.#E(e)||((o||!this.#y(e))&&(yield e),e===this.#m));)e=this.#d[e]}*#q({allowStale:o=this.allowStale}={}){if(this.#l)for(let e=this.#m;!(!this.#E(e)||((o||!this.#y(e))&&(yield e),e===this.#x));)e=this.#w[e]}#E(o){return o!==void 0&&this.#n.get(this.#c[o])===o}*entries(){for(let o of this.#v())this.#i[o]!==void 0&&this.#c[o]!==void 0&&!this.#u(this.#i[o])&&(yield[this.#c[o],this.#i[o]])}*rentries(){for(let o of this.#q())this.#i[o]!==void 0&&this.#c[o]!==void 0&&!this.#u(this.#i[o])&&(yield[this.#c[o],this.#i[o]])}*keys(){for(let o of this.#v()){let e=this.#c[o];e!==void 0&&!this.#u(this.#i[o])&&(yield e)}}*rkeys(){for(let o of this.#q()){let e=this.#c[o];e!==void 0&&!this.#u(this.#i[o])&&(yield e)}}*values(){for(let o of this.#v())this.#i[o]!==void 0&&!this.#u(this.#i[o])&&(yield this.#i[o])}*rvalues(){for(let o of this.#q())this.#i[o]!==void 0&&!this.#u(this.#i[o])&&(yield this.#i[o])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(o,e={}){for(let s of this.#v()){let i=this.#i[s],r=this.#u(i)?i.__staleWhileFetching:i;if(r!==void 0&&o(r,this.#c[s],this))return this.get(this.#c[s],e)}}forEach(o,e=this){for(let s of this.#v()){let i=this.#i[s],r=this.#u(i)?i.__staleWhileFetching:i;r!==void 0&&o.call(e,r,this.#c[s],this)}}rforEach(o,e=this){for(let s of this.#q()){let i=this.#i[s],r=this.#u(i)?i.__staleWhileFetching:i;r!==void 0&&o.call(e,r,this.#c[s],this)}}purgeStale(){let o=!1;for(let e of this.#q({allowStale:!0}))this.#y(e)&&(this.#N(this.#c[e],"expire"),o=!0);return o}info(o){let e=this.#n.get(o);if(e===void 0)return;let s=this.#i[e],i=this.#u(s)?s.__staleWhileFetching:s;if(i===void 0)return;let r={value:i};if(this.#h&&this.#W){let a=this.#h[e],n=this.#W[e];if(a&&n){let c=a-(qt.now()-n);r.ttl=c,r.start=Date.now()}}return this.#G&&(r.size=this.#G[e]),r}dump(){let o=[];for(let e of this.#v({allowStale:!0})){let s=this.#c[e],i=this.#i[e],r=this.#u(i)?i.__staleWhileFetching:i;if(r===void 0||s===void 0)continue;let a={value:r};if(this.#h&&this.#W){a.ttl=this.#h[e];let n=qt.now()-this.#W[e];a.start=Math.floor(Date.now()-n)}this.#G&&(a.size=this.#G[e]),o.unshift([s,a])}return o}load(o){this.clear();for(let[e,s]of o){if(s.start){let i=Date.now()-s.start;s.start=qt.now()-i}this.set(e,s.value,s)}}set(o,e,s={}){if(e===void 0)return this.delete(o),this;let{ttl:i=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:n=this.sizeCalculation,status:c}=s,{noUpdateTTL:_=this.noUpdateTTL}=s,d=this.#V(o,e,s.size||0,n);if(this.maxEntrySize&&d>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#N(o,"set"),this;let O=this.#l===0?void 0:this.#n.get(o);if(O===void 0)O=this.#l===0?this.#x:this.#k.length!==0?this.#k.pop():this.#l===this.#o?this.#X(!1):this.#l,this.#c[O]=o,this.#i[O]=e,this.#n.set(o,O),this.#w[this.#x]=O,this.#d[O]=this.#x,this.#x=O,this.#l++,this.#M(O,d,c),c&&(c.set="add"),_=!1;else{this.#I(O);let g=this.#i[O];if(e!==g){if(this.#K&&this.#u(g)){g.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=g;w!==void 0&&!a&&(this.#z&&this.#r?.(w,o,"set"),this.#g&&this.#O?.push([w,o,"set"]))}else a||(this.#z&&this.#r?.(g,o,"set"),this.#g&&this.#O?.push([g,o,"set"]));if(this.#F(O),this.#M(O,d,c),this.#i[O]=e,c){c.set="replace";let w=g&&this.#u(g)?g.__staleWhileFetching:g;w!==void 0&&(c.oldValue=w)}}else c&&(c.set="update")}if(i!==0&&!this.#h&&this.#p(),this.#h&&(_||this.#S(O,i,r),c&&this.#e(c,O)),!a&&this.#g&&this.#O){let g=this.#O,w;for(;w=g?.shift();)this.#s?.(...w)}return this}pop(){try{for(;this.#l;){let o=this.#i[this.#m];if(this.#X(!0),this.#u(o)){if(o.__staleWhileFetching)return o.__staleWhileFetching}else if(o!==void 0)return o}}finally{if(this.#g&&this.#O){let o=this.#O,e;for(;e=o?.shift();)this.#s?.(...e)}}}#X(o){let e=this.#m,s=this.#c[e],i=this.#i[e];return this.#K&&this.#u(i)?i.__abortController.abort(new Error("evicted")):(this.#z||this.#g)&&(this.#z&&this.#r?.(i,s,"evict"),this.#g&&this.#O?.push([i,s,"evict"])),this.#F(e),o&&(this.#c[e]=void 0,this.#i[e]=void 0,this.#k.push(e)),this.#l===1?(this.#m=this.#x=0,this.#k.length=0):this.#m=this.#w[e],this.#n.delete(s),this.#l--,e}has(o,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,r=this.#n.get(o);if(r!==void 0){let a=this.#i[r];if(this.#u(a)&&a.__staleWhileFetching===void 0)return!1;if(this.#y(r))i&&(i.has="stale",this.#e(i,r));else return s&&this.#b(r),i&&(i.has="hit",this.#e(i,r)),!0}else i&&(i.has="miss");return!1}peek(o,e={}){let{allowStale:s=this.allowStale}=e,i=this.#n.get(o);if(i===void 0||!s&&this.#y(i))return;let r=this.#i[i];return this.#u(r)?r.__staleWhileFetching:r}#Y(o,e,s,i){let r=e===void 0?void 0:this.#i[e];if(this.#u(r))return r;let a=new gs,{signal:n}=s;n?.addEventListener("abort",()=>a.abort(n.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:i},_=(K,q=!1)=>{let{aborted:v}=a.signal,p=s.ignoreFetchAbort&&K!==void 0;if(s.status&&(v&&!q?(s.status.fetchAborted=!0,s.status.fetchError=a.signal.reason,p&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),v&&!p&&!q)return O(a.signal.reason);let m=w;return this.#i[e]===w&&(K===void 0?m.__staleWhileFetching?this.#i[e]=m.__staleWhileFetching:this.#N(o,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(o,K,c.options))),K},d=K=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=K),O(K)),O=K=>{let{aborted:q}=a.signal,v=q&&s.allowStaleOnFetchAbort,p=v||s.allowStaleOnFetchRejection,m=p||s.noDeleteOnFetchRejection,l=w;if(this.#i[e]===w&&(!m||l.__staleWhileFetching===void 0?this.#N(o,"fetch"):v||(this.#i[e]=l.__staleWhileFetching)),p)return s.status&&l.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw K},g=(K,q)=>{let v=this.#a?.(o,r,c);v&&v instanceof Promise&&v.then(p=>K(p===void 0?void 0:p),q),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(K(void 0),s.allowStaleOnFetchAbort&&(K=p=>_(p,!0)))})};s.status&&(s.status.fetchDispatched=!0);let w=new Promise(g).then(_,d),z=Object.assign(w,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(o,z,{...c.options,status:void 0}),e=this.#n.get(o)):this.#i[e]=z,z}#u(o){if(!this.#K)return!1;let e=o;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof gs}async fetch(o,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:n=this.noDisposeOnSet,size:c=0,sizeCalculation:_=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:O=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:g=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:K,forceRefresh:q=!1,status:v,signal:p}=e;if(!this.#K)return v&&(v.fetch="get"),this.get(o,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:v});let m={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:n,size:c,sizeCalculation:_,noUpdateTTL:d,noDeleteOnFetchRejection:O,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:z,ignoreFetchAbort:w,status:v,signal:p},l=this.#n.get(o);if(l===void 0){v&&(v.fetch="miss");let x=this.#Y(o,l,m,K);return x.__returned=x}else{let x=this.#i[l];if(this.#u(x)){let f=s&&x.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",f&&(v.returnedStale=!0)),f?x.__staleWhileFetching:x.__returned=x}let u=this.#y(l);if(!q&&!u)return v&&(v.fetch="hit"),this.#I(l),i&&this.#b(l),v&&this.#e(v,l),x;let G=this.#Y(o,l,m,K),h=G.__staleWhileFetching!==void 0&&s;return v&&(v.fetch=u?"stale":"refresh",h&&u&&(v.returnedStale=!0)),h?G.__staleWhileFetching:G.__returned=G}}async forceFetch(o,e={}){let s=await this.fetch(o,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(o,e={}){let s=this.#f;if(!s)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:r,...a}=e,n=this.get(o,a);if(!r&&n!==void 0)return n;let c=s(o,n,{options:a,context:i});return this.set(o,c,a),c}get(o,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,n=this.#n.get(o);if(n!==void 0){let c=this.#i[n],_=this.#u(c);return a&&this.#e(a,n),this.#y(n)?(a&&(a.get="stale"),_?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=!0),s?c.__staleWhileFetching:void 0):(r||this.#N(o,"expire"),a&&s&&(a.returnedStale=!0),s?c:void 0)):(a&&(a.get="hit"),_?c.__staleWhileFetching:(this.#I(n),i&&this.#b(n),c))}else a&&(a.get="miss")}#Z(o,e){this.#d[e]=o,this.#w[o]=e}#I(o){o!==this.#x&&(o===this.#m?this.#m=this.#w[o]:this.#Z(this.#d[o],this.#w[o]),this.#Z(this.#x,o),this.#x=o)}delete(o){return this.#N(o,"delete")}#N(o,e){let s=!1;if(this.#l!==0){let i=this.#n.get(o);if(i!==void 0)if(s=!0,this.#l===1)this.#P(e);else{this.#F(i);let r=this.#i[i];if(this.#u(r)?r.__abortController.abort(new Error("deleted")):(this.#z||this.#g)&&(this.#z&&this.#r?.(r,o,e),this.#g&&this.#O?.push([r,o,e])),this.#n.delete(o),this.#c[i]=void 0,this.#i[i]=void 0,i===this.#x)this.#x=this.#d[i];else if(i===this.#m)this.#m=this.#w[i];else{let a=this.#d[i];this.#w[a]=this.#w[i];let n=this.#w[i];this.#d[n]=this.#d[i]}this.#l--,this.#k.push(i)}}if(this.#g&&this.#O?.length){let i=this.#O,r;for(;r=i?.shift();)this.#s?.(...r)}return s}clear(){return this.#P("delete")}#P(o){for(let e of this.#q({allowStale:!0})){let s=this.#i[e];if(this.#u(s))s.__abortController.abort(new Error("deleted"));else{let i=this.#c[e];this.#z&&this.#r?.(s,i,o),this.#g&&this.#O?.push([s,i,o])}}if(this.#n.clear(),this.#i.fill(void 0),this.#c.fill(void 0),this.#h&&this.#W&&(this.#h.fill(0),this.#W.fill(0)),this.#G&&this.#G.fill(0),this.#m=0,this.#x=0,this.#k.length=0,this.#_=0,this.#l=0,this.#g&&this.#O){let e=this.#O,s;for(;s=e?.shift();)this.#s?.(...s)}}};var St=require("node:path"),gl=require("node:url"),Mo=require("fs"),lg=I(require("node:fs"),1),it=require("node:fs/promises");var zs=require("node:events"),$i=I(require("node:stream"),1),ll=require("node:string_decoder"),rl=typeof process=="object"&&process?process:{stdout:null,stderr:null},og=t=>!!t&&typeof t=="object"&&(t instanceof st||t instanceof $i.default||tg(t)||eg(t)),tg=t=>!!t&&typeof t=="object"&&t instanceof zs.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==$i.default.Writable.prototype.pipe,eg=t=>!!t&&typeof t=="object"&&t instanceof zs.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",Qo=Symbol("EOF"),Ao=Symbol("maybeEmitEnd"),et=Symbol("emittedEnd"),Os=Symbol("emittingEnd"),ce=Symbol("emittedError"),ws=Symbol("closed"),al=Symbol("read"),ds=Symbol("flush"),nl=Symbol("flushChunk"),bo=Symbol("encoding"),Ct=Symbol("decoder"),J=Symbol("flowing"),le=Symbol("paused"),Nt=Symbol("resume"),B=Symbol("buffer"),ao=Symbol("pipes"),D=Symbol("bufferLength"),Ai=Symbol("bufferPush"),ys=Symbol("bufferShift"),eo=Symbol("objectMode"),U=Symbol("destroyed"),ji=Symbol("error"),Ri=Symbol("emitData"),cl=Symbol("emitEnd"),Ji=Symbol("emitEnd2"),So=Symbol("async"),Bi=Symbol("abort"),hs=Symbol("aborted"),ue=Symbol("signal"),gt=Symbol("dataListeners"),go=Symbol("discarded"),_e=t=>Promise.resolve().then(t),sg=t=>t(),ig=t=>t==="end"||t==="finish"||t==="prefinish",rg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ag=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),fs=class{src;dest;opts;ondrain;constructor(o,e,s){this.src=o,this.dest=e,this.opts=s,this.ondrain=()=>o[Nt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(o){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Di=class extends fs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(o,e,s){super(o,e,s),this.proxyErrors=i=>e.emit("error",i),o.on("error",this.proxyErrors)}},ng=t=>!!t.objectMode,cg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",st=class extends zs.EventEmitter{[J]=!1;[le]=!1;[ao]=[];[B]=[];[eo];[bo];[So];[Ct];[Qo]=!1;[et]=!1;[Os]=!1;[ws]=!1;[ce]=null;[D]=0;[U]=!1;[ue];[hs]=!1;[gt]=0;[go]=!1;writable=!0;readable=!0;constructor(...o){let e=o[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");ng(e)?(this[eo]=!0,this[bo]=null):cg(e)?(this[bo]=e.encoding,this[eo]=!1):(this[eo]=!1,this[bo]=null),this[So]=!!e.async,this[Ct]=this[bo]?new ll.StringDecoder(this[bo]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[B]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[ao]});let{signal:s}=e;s&&(this[ue]=s,s.aborted?this[Bi]():s.addEventListener("abort",()=>this[Bi]()))}get bufferLength(){return this[D]}get encoding(){return this[bo]}set encoding(o){throw new Error("Encoding must be set at instantiation time")}setEncoding(o){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[eo]}set objectMode(o){throw new Error("objectMode must be set at instantiation time")}get async(){return this[So]}set async(o){this[So]=this[So]||!!o}[Bi](){this[hs]=!0,this.emit("abort",this[ue]?.reason),this.destroy(this[ue]?.reason)}get aborted(){return this[hs]}set aborted(o){}write(o,e,s){if(this[hs])return!1;if(this[Qo])throw new Error("write after end");if(this[U])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let i=this[So]?_e:sg;if(!this[eo]&&!Buffer.isBuffer(o)){if(ag(o))o=Buffer.from(o.buffer,o.byteOffset,o.byteLength);else if(rg(o))o=Buffer.from(o);else if(typeof o!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[eo]?(this[J]&&this[D]!==0&&this[ds](!0),this[J]?this.emit("data",o):this[Ai](o),this[D]!==0&&this.emit("readable"),s&&i(s),this[J]):o.length?(typeof o=="string"&&!(e===this[bo]&&!this[Ct]?.lastNeed)&&(o=Buffer.from(o,e)),Buffer.isBuffer(o)&&this[bo]&&(o=this[Ct].write(o)),this[J]&&this[D]!==0&&this[ds](!0),this[J]?this.emit("data",o):this[Ai](o),this[D]!==0&&this.emit("readable"),s&&i(s),this[J]):(this[D]!==0&&this.emit("readable"),s&&i(s),this[J])}read(o){if(this[U])return null;if(this[go]=!1,this[D]===0||o===0||o&&o>this[D])return this[Ao](),null;this[eo]&&(o=null),this[B].length>1&&!this[eo]&&(this[B]=[this[bo]?this[B].join(""):Buffer.concat(this[B],this[D])]);let e=this[al](o||null,this[B][0]);return this[Ao](),e}[al](o,e){if(this[eo])this[ys]();else{let s=e;o===s.length||o===null?this[ys]():typeof s=="string"?(this[B][0]=s.slice(o),e=s.slice(0,o),this[D]-=o):(this[B][0]=s.subarray(o),e=s.subarray(0,o),this[D]-=o)}return this.emit("data",e),!this[B].length&&!this[Qo]&&this.emit("drain"),e}end(o,e,s){return typeof o=="function"&&(s=o,o=void 0),typeof e=="function"&&(s=e,e="utf8"),o!==void 0&&this.write(o,e),s&&this.once("end",s),this[Qo]=!0,this.writable=!1,(this[J]||!this[le])&&this[Ao](),this}[Nt](){this[U]||(!this[gt]&&!this[ao].length&&(this[go]=!0),this[le]=!1,this[J]=!0,this.emit("resume"),this[B].length?this[ds]():this[Qo]?this[Ao]():this.emit("drain"))}resume(){return this[Nt]()}pause(){this[J]=!1,this[le]=!0,this[go]=!1}get destroyed(){return this[U]}get flowing(){return this[J]}get paused(){return this[le]}[Ai](o){this[eo]?this[D]+=1:this[D]+=o.length,this[B].push(o)}[ys](){return this[eo]?this[D]-=1:this[D]-=this[B][0].length,this[B].shift()}[ds](o=!1){do;while(this[nl](this[ys]())&&this[B].length);!o&&!this[B].length&&!this[Qo]&&this.emit("drain")}[nl](o){return this.emit("data",o),this[J]}pipe(o,e){if(this[U])return o;this[go]=!1;let s=this[et];return e=e||{},o===rl.stdout||o===rl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&o.end():(this[ao].push(e.proxyErrors?new Di(this,o,e):new fs(this,o,e)),this[So]?_e(()=>this[Nt]()):this[Nt]()),o}unpipe(o){let e=this[ao].find(s=>s.dest===o);e&&(this[ao].length===1?(this[J]&&this[gt]===0&&(this[J]=!1),this[ao]=[]):this[ao].splice(this[ao].indexOf(e),1),e.unpipe())}addListener(o,e){return this.on(o,e)}on(o,e){let s=super.on(o,e);if(o==="data")this[go]=!1,this[gt]++,!this[ao].length&&!this[J]&&this[Nt]();else if(o==="readable"&&this[D]!==0)super.emit("readable");else if(ig(o)&&this[et])super.emit(o),this.removeAllListeners(o);else if(o==="error"&&this[ce]){let i=e;this[So]?_e(()=>i.call(this,this[ce])):i.call(this,this[ce])}return s}removeListener(o,e){return this.off(o,e)}off(o,e){let s=super.off(o,e);return o==="data"&&(this[gt]=this.listeners("data").length,this[gt]===0&&!this[go]&&!this[ao].length&&(this[J]=!1)),s}removeAllListeners(o){let e=super.removeAllListeners(o);return(o==="data"||o===void 0)&&(this[gt]=0,!this[go]&&!this[ao].length&&(this[J]=!1)),e}get emittedEnd(){return this[et]}[Ao](){!this[Os]&&!this[et]&&!this[U]&&this[B].length===0&&this[Qo]&&(this[Os]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ws]&&this.emit("close"),this[Os]=!1)}emit(o,...e){let s=e[0];if(o!=="error"&&o!=="close"&&o!==U&&this[U])return!1;if(o==="data")return!this[eo]&&!s?!1:this[So]?(_e(()=>this[Ri](s)),!0):this[Ri](s);if(o==="end")return this[cl]();if(o==="close"){if(this[ws]=!0,!this[et]&&!this[U])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(o==="error"){this[ce]=s,super.emit(ji,s);let r=!this[ue]||this.listeners("error").length?super.emit("error",s):!1;return this[Ao](),r}else if(o==="resume"){let r=super.emit("resume");return this[Ao](),r}else if(o==="finish"||o==="prefinish"){let r=super.emit(o);return this.removeAllListeners(o),r}let i=super.emit(o,...e);return this[Ao](),i}[Ri](o){for(let s of this[ao])s.dest.write(o)===!1&&this.pause();let e=this[go]?!1:super.emit("data",o);return this[Ao](),e}[cl](){return this[et]?!1:(this[et]=!0,this.readable=!1,this[So]?(_e(()=>this[Ji]()),!0):this[Ji]())}[Ji](){if(this[Ct]){let e=this[Ct].end();if(e){for(let s of this[ao])s.dest.write(e);this[go]||super.emit("data",e)}}for(let e of this[ao])e.end();let o=super.emit("end");return this.removeAllListeners("end"),o}async collect(){let o=Object.assign([],{dataLength:0});this[eo]||(o.dataLength=0);let e=this.promise();return this.on("data",s=>{o.push(s),this[eo]||(o.dataLength+=s.length)}),await e,o}async concat(){if(this[eo])throw new Error("cannot concat in objectMode");let o=await this.collect();return this[bo]?o.join(""):Buffer.concat(o,o.dataLength)}async promise(){return new Promise((o,e)=>{this.on(U,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>o())})}[Symbol.asyncIterator](){this[go]=!1;let o=!1,e=async()=>(this.pause(),o=!0,{value:void 0,done:!0});return{next:()=>{if(o)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[Qo])return e();let r,a,n=O=>{this.off("data",c),this.off("end",_),this.off(U,d),e(),a(O)},c=O=>{this.off("error",n),this.off("end",_),this.off(U,d),this.pause(),r({value:O,done:!!this[Qo]})},_=()=>{this.off("error",n),this.off("data",c),this.off(U,d),e(),r({done:!0,value:void 0})},d=()=>n(new Error("stream destroyed"));return new Promise((O,g)=>{a=g,r=O,this.once(U,d),this.once("error",n),this.once("end",_),this.once("data",c)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[go]=!1;let o=!1,e=()=>(this.pause(),this.off(ji,e),this.off(U,e),this.off("end",e),o=!0,{done:!0,value:void 0}),s=()=>{if(o)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(ji,e),this.once(U,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(o){if(this[U])return o?this.emit("error",o):this.emit(U),this;this[U]=!0,this[go]=!0,this[B].length=0,this[D]=0;let e=this;return typeof e.close=="function"&&!this[ws]&&e.close(),o?this.emit("error",o):this.emit(U),this}static get isStream(){return og}};var ug=Mo.realpathSync.native,me={lstatSync:Mo.lstatSync,readdir:Mo.readdir,readdirSync:Mo.readdirSync,readlinkSync:Mo.readlinkSync,realpathSync:ug,promises:{lstat:it.lstat,readdir:it.readdir,readlink:it.readlink,realpath:it.realpath}},Ol=t=>!t||t===me||t===lg?me:{...me,...t,promises:{...me.promises,...t.promises||{}}},wl=/^\\\\\?\\([a-z]:)\\?$/i,_g=t=>t.replace(/\//g,"\\").replace(wl,"$1\\"),xg=/[\\\/]/,zo=0,dl=1,yl=2,Fo=4,hl=6,fl=8,Ot=10,zl=12,fo=15,xe=~fo,Hi=16,ul=32,ge=64,vo=128,Ks=256,Gs=512,_l=ge|vo|Gs,mg=1023,or=t=>t.isFile()?fl:t.isDirectory()?Fo:t.isSymbolicLink()?Ot:t.isCharacterDevice()?yl:t.isBlockDevice()?hl:t.isSocket()?zl:t.isFIFO()?dl:zo,xl=new Map,Oe=t=>{let o=xl.get(t);if(o)return o;let e=t.normalize("NFKD");return xl.set(t,e),e},ml=new Map,ks=t=>{let o=ml.get(t);if(o)return o;let e=Oe(t.toLowerCase());return ml.set(t,e),e},Ws=class extends ne{constructor(){super({max:256})}},tr=class extends ne{constructor(o=16*1024){super({maxSize:o,sizeCalculation:e=>e.length+1})}},Kl=Symbol("PathScurry setAsCwd"),so=class{name;root;roots;parent;nocase;isCWD=!1;#o;#t;get dev(){return this.#t}#r;get mode(){return this.#r}#s;get nlink(){return this.#s}#a;get uid(){return this.#a}#f;get gid(){return this.#f}#l;get rdev(){return this.#l}#_;get blksize(){return this.#_}#n;get ino(){return this.#n}#c;get size(){return this.#c}#i;get blocks(){return this.#i}#w;get atimeMs(){return this.#w}#d;get mtimeMs(){return this.#d}#m;get ctimeMs(){return this.#m}#x;get birthtimeMs(){return this.#x}#k;get atime(){return this.#k}#O;get mtime(){return this.#O}#G;get ctime(){return this.#G}#W;get birthtime(){return this.#W}#h;#z;#K;#g;#p;#b;#e;#S;#y;#C;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(o,e=zo,s,i,r,a,n){this.name=o,this.#h=r?ks(o):Oe(o),this.#e=e&mg,this.nocase=r,this.roots=i,this.root=s||this,this.#S=a,this.#K=n.fullpath,this.#p=n.relative,this.#b=n.relativePosix,this.parent=n.parent,this.parent?this.#o=this.parent.#o:this.#o=Ol(n.fs)}depth(){return this.#z!==void 0?this.#z:this.parent?this.#z=this.parent.depth()+1:this.#z=0}childrenCache(){return this.#S}resolve(o){if(!o)return this;let e=this.getRootString(o),i=o.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#F(i):this.#F(i)}#F(o){let e=this;for(let s of o)e=e.child(s);return e}children(){let o=this.#S.get(this);if(o)return o;let e=Object.assign([],{provisional:0});return this.#S.set(this,e),this.#e&=~Hi,e}child(o,e){if(o===""||o===".")return this;if(o==="..")return this.parent||this;let s=this.children(),i=this.nocase?ks(o):Oe(o);for(let c of s)if(c.#h===i)return c;let r=this.parent?this.sep:"",a=this.#K?this.#K+r+o:void 0,n=this.newChild(o,zo,{...e,parent:this,fullpath:a});return this.canReaddir()||(n.#e|=vo),s.push(n),n}relative(){if(this.isCWD)return"";if(this.#p!==void 0)return this.#p;let o=this.name,e=this.parent;if(!e)return this.#p=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+o}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#b!==void 0)return this.#b;let o=this.name,e=this.parent;if(!e)return this.#b=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+o}fullpath(){if(this.#K!==void 0)return this.#K;let o=this.name,e=this.parent;if(!e)return this.#K=this.name;let i=e.fullpath()+(e.parent?this.sep:"")+o;return this.#K=i}fullpathPosix(){if(this.#g!==void 0)return this.#g;if(this.sep==="/")return this.#g=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#g=`//?/${i}`:this.#g=i}let o=this.parent,e=o.fullpathPosix(),s=e+(!e||!o.parent?"":"/")+this.name;return this.#g=s}isUnknown(){return(this.#e&fo)===zo}isType(o){return this[`is${o}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#e&fo)===fl}isDirectory(){return(this.#e&fo)===Fo}isCharacterDevice(){return(this.#e&fo)===yl}isBlockDevice(){return(this.#e&fo)===hl}isFIFO(){return(this.#e&fo)===dl}isSocket(){return(this.#e&fo)===zl}isSymbolicLink(){return(this.#e&Ot)===Ot}lstatCached(){return this.#e&ul?this:void 0}readlinkCached(){return this.#y}realpathCached(){return this.#C}readdirCached(){let o=this.children();return o.slice(0,o.provisional)}canReadlink(){if(this.#y)return!0;if(!this.parent)return!1;let o=this.#e&fo;return!(o!==zo&&o!==Ot||this.#e&Ks||this.#e&vo)}calledReaddir(){return!!(this.#e&Hi)}isENOENT(){return!!(this.#e&vo)}isNamed(o){return this.nocase?this.#h===ks(o):this.#h===Oe(o)}async readlink(){let o=this.#y;if(o)return o;if(this.canReadlink()&&this.parent)try{let e=await this.#o.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#y=s}catch(e){this.#u(e.code);return}}readlinkSync(){let o=this.#y;if(o)return o;if(this.canReadlink()&&this.parent)try{let e=this.#o.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#y=s}catch(e){this.#u(e.code);return}}#M(o){this.#e|=Hi;for(let e=o.provisional;e<o.length;e++){let s=o[e];s&&s.#V()}}#V(){this.#e&vo||(this.#e=(this.#e|vo)&xe,this.#v())}#v(){let o=this.children();o.provisional=0;for(let e of o)e.#V()}#q(){this.#e|=Gs,this.#E()}#E(){if(this.#e&ge)return;let o=this.#e;(o&fo)===Fo&&(o&=xe),this.#e=o|ge,this.#v()}#X(o=""){o==="ENOTDIR"||o==="EPERM"?this.#E():o==="ENOENT"?this.#V():this.children().provisional=0}#Y(o=""){o==="ENOTDIR"?this.parent.#E():o==="ENOENT"&&this.#V()}#u(o=""){let e=this.#e;e|=Ks,o==="ENOENT"&&(e|=vo),(o==="EINVAL"||o==="UNKNOWN")&&(e&=xe),this.#e=e,o==="ENOTDIR"&&this.parent&&this.parent.#E()}#Z(o,e){return this.#N(o,e)||this.#I(o,e)}#I(o,e){let s=or(o),i=this.newChild(o.name,s,{parent:this}),r=i.#e&fo;return r!==Fo&&r!==Ot&&r!==zo&&(i.#e|=ge),e.unshift(i),e.provisional++,i}#N(o,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?ks(o.name):Oe(o.name))===i.#h)return this.#P(o,i,s,e)}}#P(o,e,s,i){let r=e.name;return e.#e=e.#e&xe|or(o),r!==o.name&&(e.name=o.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e}async lstat(){if((this.#e&vo)===0)try{return this.#Q(await this.#o.promises.lstat(this.fullpath())),this}catch(o){this.#Y(o.code)}}lstatSync(){if((this.#e&vo)===0)try{return this.#Q(this.#o.lstatSync(this.fullpath())),this}catch(o){this.#Y(o.code)}}#Q(o){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:a,blocks:n,ctime:c,ctimeMs:_,dev:d,gid:O,ino:g,mode:w,mtime:z,mtimeMs:K,nlink:q,rdev:v,size:p,uid:m}=o;this.#k=e,this.#w=s,this.#W=i,this.#x=r,this.#_=a,this.#i=n,this.#G=c,this.#m=_,this.#t=d,this.#f=O,this.#n=g,this.#r=w,this.#O=z,this.#d=K,this.#s=q,this.#l=v,this.#c=p,this.#a=m;let l=or(o);this.#e=this.#e&xe|l|ul,l!==zo&&l!==Fo&&l!==Ot&&(this.#e|=ge)}#T=[];#U=!1;#A(o){this.#U=!1;let e=this.#T.slice();this.#T.length=0,e.forEach(s=>s(null,o))}readdirCB(o,e=!1){if(!this.canReaddir()){e?o(null,[]):queueMicrotask(()=>o(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?o(null,r):queueMicrotask(()=>o(null,r));return}if(this.#T.push(o),this.#U)return;this.#U=!0;let i=this.fullpath();this.#o.readdir(i,{withFileTypes:!0},(r,a)=>{if(r)this.#X(r.code),s.provisional=0;else{for(let n of a)this.#Z(n,s);this.#M(s)}this.#A(s.slice(0,s.provisional))})}#L;async readdir(){if(!this.canReaddir())return[];let o=this.children();if(this.calledReaddir())return o.slice(0,o.provisional);let e=this.fullpath();if(this.#L)await this.#L;else{let s=()=>{};this.#L=new Promise(i=>s=i);try{for(let i of await this.#o.promises.readdir(e,{withFileTypes:!0}))this.#Z(i,o);this.#M(o)}catch(i){this.#X(i.code),o.provisional=0}this.#L=void 0,s()}return o.slice(0,o.provisional)}readdirSync(){if(!this.canReaddir())return[];let o=this.children();if(this.calledReaddir())return o.slice(0,o.provisional);let e=this.fullpath();try{for(let s of this.#o.readdirSync(e,{withFileTypes:!0}))this.#Z(s,o);this.#M(o)}catch(s){this.#X(s.code),o.provisional=0}return o.slice(0,o.provisional)}canReaddir(){if(this.#e&_l)return!1;let o=fo&this.#e;return o===zo||o===Fo||o===Ot}shouldWalk(o,e){return(this.#e&Fo)===Fo&&!(this.#e&_l)&&!o.has(this)&&(!e||e(this))}async realpath(){if(this.#C)return this.#C;if(!((Gs|Ks|vo)&this.#e))try{let o=await this.#o.promises.realpath(this.fullpath());return this.#C=this.resolve(o)}catch{this.#q()}}realpathSync(){if(this.#C)return this.#C;if(!((Gs|Ks|vo)&this.#e))try{let o=this.#o.realpathSync(this.fullpath());return this.#C=this.resolve(o)}catch{this.#q()}}[Kl](o){if(o===this)return;o.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),i.#p=s.join(this.sep),i.#b=s.join("/"),i=i.parent,s.push("..");for(i=o;i&&i.parent&&!e.has(i);)i.#p=void 0,i.#b=void 0,i=i.parent}},bs=class t extends so{sep="\\";splitSep=xg;constructor(o,e=zo,s,i,r,a,n){super(o,e,s,i,r,a,n)}newChild(o,e=zo,s={}){return new t(o,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(o){return St.win32.parse(o).root}getRoot(o){if(o=_g(o.toUpperCase()),o===this.root.name)return this.root;for(let[e,s]of Object.entries(this.roots))if(this.sameRoot(o,e))return this.roots[o]=s;return this.roots[o]=new Ft(o,this).root}sameRoot(o,e=this.root.name){return o=o.toUpperCase().replace(/\//g,"\\").replace(wl,"$1\\"),o===e}},vs=class t extends so{splitSep="/";sep="/";constructor(o,e=zo,s,i,r,a,n){super(o,e,s,i,r,a,n)}getRootString(o){return o.startsWith("/")?"/":""}getRoot(o){return this.root}newChild(o,e=zo,s={}){return new t(o,e,this.root,this.roots,this.nocase,this.childrenCache(),s)}},qs=class{root;rootPath;roots;cwd;#o;#t;#r;nocase;#s;constructor(o=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:a=me}={}){this.#s=Ol(a),(o instanceof URL||o.startsWith("file://"))&&(o=(0,gl.fileURLToPath)(o));let n=e.resolve(o);this.roots=Object.create(null),this.rootPath=this.parseRootPath(n),this.#o=new Ws,this.#t=new Ws,this.#r=new tr(r);let c=n.substring(this.rootPath.length).split(s);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let _=this.root,d=c.length-1,O=e.sep,g=this.rootPath,w=!1;for(let z of c){let K=d--;_=_.child(z,{relative:new Array(K).fill("..").join(O),relativePosix:new Array(K).fill("..").join("/"),fullpath:g+=(w?"":O)+z}),w=!0}this.cwd=_}depth(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.depth()}childrenCache(){return this.#r}resolve(...o){let e="";for(let r=o.length-1;r>=0;r--){let a=o[r];if(!(!a||a===".")&&(e=e?`${a}/${e}`:a,this.isAbsolute(a)))break}let s=this.#o.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return this.#o.set(e,i),i}resolvePosix(...o){let e="";for(let r=o.length-1;r>=0;r--){let a=o[r];if(!(!a||a===".")&&(e=e?`${a}/${e}`:a,this.isAbsolute(a)))break}let s=this.#t.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return this.#t.set(e,i),i}relative(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.relative()}relativePosix(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.relativePosix()}basename(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.name}dirname(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),(o.parent||o).fullpath()}async readdir(o=this.cwd,e={withFileTypes:!0}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s}=e;if(o.canReaddir()){let i=await o.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(o=this.cwd,e={withFileTypes:!0}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0}=e;return o.canReaddir()?s?o.readdirSync():o.readdirSync().map(i=>i.name):[]}async lstat(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.lstat()}lstatSync(o=this.cwd){return typeof o=="string"&&(o=this.cwd.resolve(o)),o.lstatSync()}async readlink(o=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o.withFileTypes,o=this.cwd);let s=await o.readlink();return e?s:s?.fullpath()}readlinkSync(o=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o.withFileTypes,o=this.cwd);let s=o.readlinkSync();return e?s:s?.fullpath()}async realpath(o=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o.withFileTypes,o=this.cwd);let s=await o.realpath();return e?s:s?.fullpath()}realpathSync(o=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o.withFileTypes,o=this.cwd);let s=o.realpathSync();return e?s:s?.fullpath()}async walk(o=this.cwd,e={}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:a}=e,n=[];(!r||r(o))&&n.push(s?o:o.fullpath());let c=new Set,_=(O,g)=>{c.add(O),O.readdirCB((w,z)=>{if(w)return g(w);let K=z.length;if(!K)return g();let q=()=>{--K===0&&g()};for(let v of z)(!r||r(v))&&n.push(s?v:v.fullpath()),i&&v.isSymbolicLink()?v.realpath().then(p=>p?.isUnknown()?p.lstat():p).then(p=>p?.shouldWalk(c,a)?_(p,q):q()):v.shouldWalk(c,a)?_(v,q):q()},!0)},d=o;return new Promise((O,g)=>{_(d,w=>{if(w)return g(w);O(n)})})}walkSync(o=this.cwd,e={}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:a}=e,n=[];(!r||r(o))&&n.push(s?o:o.fullpath());let c=new Set([o]);for(let _ of c){let d=_.readdirSync();for(let O of d){(!r||r(O))&&n.push(s?O:O.fullpath());let g=O;if(O.isSymbolicLink()){if(!(i&&(g=O.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(c,a)&&c.add(g)}}return n}[Symbol.asyncIterator](){return this.iterate()}iterate(o=this.cwd,e={}){return typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd),this.stream(o,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(o=this.cwd,e={}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:a}=e;(!r||r(o))&&(yield s?o:o.fullpath());let n=new Set([o]);for(let c of n){let _=c.readdirSync();for(let d of _){(!r||r(d))&&(yield s?d:d.fullpath());let O=d;if(d.isSymbolicLink()){if(!(i&&(O=d.realpathSync())))continue;O.isUnknown()&&O.lstatSync()}O.shouldWalk(n,a)&&n.add(O)}}}stream(o=this.cwd,e={}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:a}=e,n=new st({objectMode:!0});(!r||r(o))&&n.write(s?o:o.fullpath());let c=new Set,_=[o],d=0,O=()=>{let g=!1;for(;!g;){let w=_.shift();if(!w){d===0&&n.end();return}d++,c.add(w);let z=(q,v,p=!1)=>{if(q)return n.emit("error",q);if(i&&!p){let m=[];for(let l of v)l.isSymbolicLink()&&m.push(l.realpath().then(x=>x?.isUnknown()?x.lstat():x));if(m.length){Promise.all(m).then(()=>z(null,v,!0));return}}for(let m of v)m&&(!r||r(m))&&(n.write(s?m:m.fullpath())||(g=!0));d--;for(let m of v){let l=m.realpathCached()||m;l.shouldWalk(c,a)&&_.push(l)}g&&!n.flowing?n.once("drain",O):K||O()},K=!0;w.readdirCB(z,!0),K=!1}};return O(),n}streamSync(o=this.cwd,e={}){typeof o=="string"?o=this.cwd.resolve(o):o instanceof so||(e=o,o=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:a}=e,n=new st({objectMode:!0}),c=new Set;(!r||r(o))&&n.write(s?o:o.fullpath());let _=[o],d=0,O=()=>{let g=!1;for(;!g;){let w=_.shift();if(!w){d===0&&n.end();return}d++,c.add(w);let z=w.readdirSync();for(let K of z)(!r||r(K))&&(n.write(s?K:K.fullpath())||(g=!0));d--;for(let K of z){let q=K;if(K.isSymbolicLink()){if(!(i&&(q=K.realpathSync())))continue;q.isUnknown()&&q.lstatSync()}q.shouldWalk(c,a)&&_.push(q)}}g&&!n.flowing&&n.once("drain",O)};return O(),n}chdir(o=this.cwd){let e=this.cwd;this.cwd=typeof o=="string"?this.cwd.resolve(o):o,this.cwd[Kl](e)}},Ft=class extends qs{sep="\\";constructor(o=process.cwd(),e={}){let{nocase:s=!0}=e;super(o,St.win32,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(o){return St.win32.parse(o).root.toUpperCase()}newRoot(o){return new bs(this.rootPath,Fo,void 0,this.roots,this.nocase,this.childrenCache(),{fs:o})}isAbsolute(o){return o.startsWith("/")||o.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(o)}},Mt=class extends qs{sep="/";constructor(o=process.cwd(),e={}){let{nocase:s=!1}=e;super(o,St.posix,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(o){return"/"}newRoot(o){return new vs(this.rootPath,Fo,void 0,this.roots,this.nocase,this.childrenCache(),{fs:o})}isAbsolute(o){return o.startsWith("/")}},we=class extends Mt{constructor(o=process.cwd(),e={}){let{nocase:s=!0}=e;super(o,{...e,nocase:s})}},Nw=process.platform==="win32"?bs:vs,kl=process.platform==="win32"?Ft:process.platform==="darwin"?we:Mt;var gg=t=>t.length>=1,Og=t=>t.length>=1,Vt=class t{#o;#t;#r;length;#s;#a;#f;#l;#_;#n;#c=!0;constructor(o,e,s,i){if(!gg(o))throw new TypeError("empty pattern list");if(!Og(e))throw new TypeError("empty glob list");if(e.length!==o.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=o.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#o=o,this.#t=e,this.#r=s,this.#s=i,this.#r===0){if(this.isUNC()){let[r,a,n,c,..._]=this.#o,[d,O,g,w,...z]=this.#t;_[0]===""&&(_.shift(),z.shift());let K=[r,a,n,c,""].join("/"),q=[d,O,g,w,""].join("/");this.#o=[K,..._],this.#t=[q,...z],this.length=this.#o.length}else if(this.isDrive()||this.isAbsolute()){let[r,...a]=this.#o,[n,...c]=this.#t;a[0]===""&&(a.shift(),c.shift());let _=r+"/",d=n+"/";this.#o=[_,...a],this.#t=[d,...c],this.length=this.#o.length}}}pattern(){return this.#o[this.#r]}isString(){return typeof this.#o[this.#r]=="string"}isGlobstar(){return this.#o[this.#r]===oo}isRegExp(){return this.#o[this.#r]instanceof RegExp}globString(){return this.#f=this.#f||(this.#r===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#a!==void 0?this.#a:this.hasMore()?(this.#a=new t(this.#o,this.#t,this.#r+1,this.#s),this.#a.#n=this.#n,this.#a.#_=this.#_,this.#a.#l=this.#l,this.#a):this.#a=null}isUNC(){let o=this.#o;return this.#_!==void 0?this.#_:this.#_=this.#s==="win32"&&this.#r===0&&o[0]===""&&o[1]===""&&typeof o[2]=="string"&&!!o[2]&&typeof o[3]=="string"&&!!o[3]}isDrive(){let o=this.#o;return this.#l!==void 0?this.#l:this.#l=this.#s==="win32"&&this.#r===0&&this.length>1&&typeof o[0]=="string"&&/^[a-z]:$/i.test(o[0])}isAbsolute(){let o=this.#o;return this.#n!==void 0?this.#n:this.#n=o[0]===""&&o.length>1||this.isDrive()||this.isUNC()}root(){let o=this.#o[0];return typeof o=="string"&&this.isAbsolute()&&this.#r===0?o:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var wg=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Et=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(o,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:a=wg}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=a,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:a,nocomment:!0,nonegate:!0};for(let n of o)this.add(n)}add(o){let e=new mo(o,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],r=e.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let a=new Vt(i,r,0,this.platform),n=new mo(a.globString(),this.mmopts),c=r[r.length-1]==="**",_=a.isAbsolute();_?this.absolute.push(n):this.relative.push(n),c&&(_?this.absoluteChildren.push(n):this.relativeChildren.push(n))}}ignored(o){let e=o.fullpath(),s=`${e}/`,i=o.relative()||".",r=`${i}/`;for(let a of this.relative)if(a.match(i)||a.match(r))return!0;for(let a of this.absolute)if(a.match(e)||a.match(s))return!0;return!1}childrenIgnored(o){let e=o.fullpath()+"/",s=(o.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(e))return!0;return!1}};var er=class t{store;constructor(o=new Map){this.store=o}copy(){return new t(new Map(this.store))}hasWalked(o,e){return this.store.get(o.fullpath())?.has(e.globString())}storeWalked(o,e){let s=o.fullpath(),i=this.store.get(s);i?i.add(e.globString()):this.store.set(s,new Set([e.globString()]))}},sr=class{store=new Map;add(o,e,s){let i=(e?2:0)|(s?1:0),r=this.store.get(o);this.store.set(o,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([o,e])=>[o,!!(e&2),!!(e&1)])}},ir=class{store=new Map;add(o,e){if(!o.canReaddir())return;let s=this.store.get(o);s?s.find(i=>i.globString()===e.globString())||s.push(e):this.store.set(o,[e])}get(o){let e=this.store.get(o);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(o=>[o,this.store.get(o)])}keys(){return[...this.store.keys()].filter(o=>o.canReaddir())}},de=class t{hasWalkedCache;matches=new sr;subwalks=new ir;patterns;follow;dot;opts;constructor(o,e){this.opts=o,this.follow=!!o.follow,this.dot=!!o.dot,this.hasWalkedCache=e?e.copy():new er}processPatterns(o,e){this.patterns=e;let s=e.map(i=>[o,i]);for(let[i,r]of s){this.hasWalkedCache.storeWalked(i,r);let a=r.root(),n=r.isAbsolute()&&this.opts.absolute!==!1;if(a){i=i.resolve(a==="/"&&this.opts.root!==void 0?this.opts.root:a);let O=r.rest();if(O)r=O;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,_,d=!1;for(;typeof(c=r.pattern())=="string"&&(_=r.rest());)i=i.resolve(c),r=_,d=!0;if(c=r.pattern(),_=r.rest(),d){if(this.hasWalkedCache.hasWalked(i,r))continue;this.hasWalkedCache.storeWalked(i,r)}if(typeof c=="string"){let O=c===".."||c===""||c===".";this.matches.add(i.resolve(c),n,O);continue}else if(c===oo){(!i.isSymbolicLink()||this.follow||r.checkFollowGlobstar())&&this.subwalks.add(i,r);let O=_?.pattern(),g=_?.rest();if(!_||(O===""||O===".")&&!g)this.matches.add(i,n,O===""||O===".");else if(O===".."){let w=i.parent||i;g?this.hasWalkedCache.hasWalked(w,g)||this.subwalks.add(w,g):this.matches.add(w,n,!0)}}else c instanceof RegExp&&this.subwalks.add(i,r)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t(this.opts,this.hasWalkedCache)}filterEntries(o,e){let s=this.subwalks.get(o),i=this.child();for(let r of e)for(let a of s){let n=a.isAbsolute(),c=a.pattern(),_=a.rest();c===oo?i.testGlobstar(r,a,_,n):c instanceof RegExp?i.testRegExp(r,c,_,n):i.testString(r,c,_,n)}return i}testGlobstar(o,e,s,i){if((this.dot||!o.name.startsWith("."))&&(e.hasMore()||this.matches.add(o,i,!1),o.canReaddir()&&(this.follow||!o.isSymbolicLink()?this.subwalks.add(o,e):o.isSymbolicLink()&&(s&&e.checkFollowGlobstar()?this.subwalks.add(o,s):e.markFollowGlobstar()&&this.subwalks.add(o,e)))),s){let r=s.pattern();if(typeof r=="string"&&r!==".."&&r!==""&&r!==".")this.testString(o,r,s.rest(),i);else if(r===".."){let a=o.parent||o;this.subwalks.add(a,s)}else r instanceof RegExp&&this.testRegExp(o,r,s.rest(),i)}}testRegExp(o,e,s,i){e.test(o.name)&&(s?this.subwalks.add(o,s):this.matches.add(o,i,!1))}testString(o,e,s,i){o.isNamed(e)&&(s?this.subwalks.add(o,s):this.matches.add(o,i,!1))}};var dg=(t,o)=>typeof t=="string"?new Et([t],o):Array.isArray(t)?new Et(t,o):t,ps=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#o=[];#t;#r;signal;maxDepth;includeChildMatches;constructor(o,e,s){if(this.patterns=o,this.path=e,this.opts=s,this.#r=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#t=dg(s.ignore??[],s),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#o.length=0}))}#s(o){return this.seen.has(o)||!!this.#t?.ignored?.(o)}#a(o){return!!this.#t?.childrenIgnored?.(o)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let o;for(;!this.paused&&(o=this.#o.shift());)o()}onResume(o){this.signal?.aborted||(this.paused?this.#o.push(o):o())}async matchCheck(o,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=o.realpathCached()||await o.realpath(),!s)return;o=s}let r=o.isUnknown()||this.opts.stat?await o.lstat():o;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let a=await r.realpath();a&&(a.isUnknown()||this.opts.stat)&&await a.lstat()}return this.matchCheckTest(r,e)}matchCheckTest(o,e){return o&&(this.maxDepth===1/0||o.depth()<=this.maxDepth)&&(!e||o.canReaddir())&&(!this.opts.nodir||!o.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!o.isSymbolicLink()||!o.realpathCached()?.isDirectory())&&!this.#s(o)?o:void 0}matchCheckSync(o,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=o.realpathCached()||o.realpathSync(),!s)return;o=s}let r=o.isUnknown()||this.opts.stat?o.lstatSync():o;if(this.opts.follow&&this.opts.nodir&&r?.isSymbolicLink()){let a=r.realpathSync();a&&(a?.isUnknown()||this.opts.stat)&&a.lstatSync()}return this.matchCheckTest(r,e)}matchFinish(o,e){if(this.#s(o))return;if(!this.includeChildMatches&&this.#t?.add){let r=`${o.relativePosix()}/**`;this.#t.add(r)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(o);let i=this.opts.mark&&o.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(o);else if(s){let r=this.opts.posix?o.fullpathPosix():o.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?o.relativePosix():o.relative(),a=this.opts.dotRelative&&!r.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(r?a+r+i:"."+i)}}async match(o,e,s){let i=await this.matchCheck(o,s);i&&this.matchFinish(i,e)}matchSync(o,e,s){let i=this.matchCheckSync(o,s);i&&this.matchFinish(i,e)}walkCB(o,e,s){this.signal?.aborted&&s(),this.walkCB2(o,e,new de(this.opts),s)}walkCB2(o,e,s,i){if(this.#a(o))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(o,e,s,i));return}s.processPatterns(o,e);let r=1,a=()=>{--r===0&&i()};for(let[n,c,_]of s.matches.entries())this.#s(n)||(r++,this.match(n,c,_).then(()=>a()));for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let c=n.readdirCached();n.calledReaddir()?this.walkCB3(n,c,s,a):n.readdirCB((_,d)=>this.walkCB3(n,d,s,a),!0)}a()}walkCB3(o,e,s,i){s=s.filterEntries(o,e);let r=1,a=()=>{--r===0&&i()};for(let[n,c,_]of s.matches.entries())this.#s(n)||(r++,this.match(n,c,_).then(()=>a()));for(let[n,c]of s.subwalks.entries())r++,this.walkCB2(n,c,s.child(),a);a()}walkCBSync(o,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(o,e,new de(this.opts),s)}walkCB2Sync(o,e,s,i){if(this.#a(o))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(o,e,s,i));return}s.processPatterns(o,e);let r=1,a=()=>{--r===0&&i()};for(let[n,c,_]of s.matches.entries())this.#s(n)||this.matchSync(n,c,_);for(let n of s.subwalkTargets()){if(this.maxDepth!==1/0&&n.depth()>=this.maxDepth)continue;r++;let c=n.readdirSync();this.walkCB3Sync(n,c,s,a)}a()}walkCB3Sync(o,e,s,i){s=s.filterEntries(o,e);let r=1,a=()=>{--r===0&&i()};for(let[n,c,_]of s.matches.entries())this.#s(n)||this.matchSync(n,c,_);for(let[n,c]of s.subwalks.entries())r++,this.walkCB2Sync(n,c,s.child(),a);a()}},ye=class extends ps{matches=new Set;constructor(o,e,s){super(o,e,s)}matchEmit(o){this.matches.add(o)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((o,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):o(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},he=class extends ps{results;constructor(o,e,s){super(o,e,s),this.results=new st({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(o){this.results.write(o),this.results.flowing||this.pause()}stream(){let o=this.path;return o.isUnknown()?o.lstat().then(()=>{this.walkCB(o,this.patterns,()=>this.results.end())}):this.walkCB(o,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var yg=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",qo=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(o,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=(0,Gl.fileURLToPath)(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof o=="string"&&(o=[o]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(o=o.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");o=o.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=o,this.platform=e.platform||yg,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=e.platform==="win32"?Ft:e.platform==="darwin"?we:e.platform?Mt:kl;this.scurry=new c(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(c=>new mo(c,i)),[a,n]=r.reduce((c,_)=>(c[0].push(..._.set),c[1].push(..._.globParts),c),[[],[]]);this.patterns=a.map((c,_)=>{let d=n[_];if(!d)throw new Error("invalid pattern object");return new Vt(c,d,0,this.platform)})}async walk(){return[...await new ye(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new ye(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new he(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new he(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var rr=(t,o={})=>{Array.isArray(t)||(t=[t]);for(let e of t)if(new mo(e,o).hasMagic())return!0;return!1};function Ns(t,o={}){return new qo(t,o).streamSync()}function bl(t,o={}){return new qo(t,o).stream()}function vl(t,o={}){return new qo(t,o).walkSync()}async function Wl(t,o={}){return new qo(t,o).walk()}function Ss(t,o={}){return new qo(t,o).iterateSync()}function ql(t,o={}){return new qo(t,o).iterate()}var hg=Ns,fg=Object.assign(bl,{sync:Ns}),zg=Ss,Kg=Object.assign(ql,{sync:Ss}),kg=Object.assign(vl,{stream:Ns,iterate:Ss}),Cs=Object.assign(Wl,{glob:Wl,globSync:vl,sync:kg,globStream:bl,stream:fg,globStreamSync:Ns,streamSync:hg,globIterate:ql,iterate:Kg,globIterateSync:Ss,iterateSync:zg,Glob:qo,hasMagic:rr,escape:vt,unescape:Wo});Cs.glob=Cs;var Sl=I(require("node:assert")),Xt=I(require("node:fs/promises")),no=I(require("node:path"));var Nl=I(pl());function Fs(t){return Cl(t)||Cl((0,Nl.default)(t))||"app"}function Cl(t){return t.replace(/[\W_]+/g,"").normalize("NFD").replace(/[\u0300-\u036f]/g,"")}async function Fl(t){let{spawnAsync:o,sourceAppPath:e}=t,s=no.default.join(t.workingDirectory,"extracted");if(await Xt.default.mkdir(s,{recursive:!0}),e.endsWith(".zip")||e.endsWith(".ipa"))await o("unzip",[e,"-d",s]);else if(e.endsWith(".tar.gz"))await o("tar",["-xzf",e,"-C",s]);else if(e.endsWith(".app")){let a=no.default.basename(e);await Gt(e,no.default.join(s,a))}else throw new Error("Unsupported file type. Please provide a .zip, .tar.gz, or .app file.");let r=(await Cs("{Payload/*.app,*.app}",{cwd:s,absolute:!0}))[0];return(0,Sl.default)(r,`Failed to find the .app directory in the extracted artifact: ${s}`),r}async function Ml(t,o){let{dir:e,name:s}=no.default.parse(o),i=Fs(t.name),r=no.default.join(e,`${i}.app`);return await Xt.default.rename(no.default.join(e,`${s}.app`),r),await Xt.default.rename(no.default.join(r,s),no.default.join(r,i)),r}async function Vl(t,o){let e=no.default.resolve(t.workingDirectory,no.default.basename(o));return await Gt(o,e),e}async function El(t,o){let{spawnAsync:e,workingDirectory:s}=t;await Xt.default.mkdir(no.default.join(s,"Payload"),{recursive:!0}),await Xt.default.rename(o,no.default.join(s,"Payload",no.default.basename(o)));let i=no.default.resolve(s,"repacked.ipa");return await e("zip",["-r",i,"Payload"],{cwd:s}),i}function Xl(t,o,e){let s=e.keychainPath?`keychain_path: "${e.keychainPath}",`:"",i;if(typeof e.provisioningProfile=="string")i=`provisioning_profile: "${e.provisioningProfile}",`;else if(typeof e.provisioningProfile=="object"&&!Array.isArray(e.provisioningProfile)){let a="";for(let[n,c]of Object.entries(e.provisioningProfile))a+=` "${n}" => "${c}",
|
|
21
21
|
`;i=`provisioning_profile: {
|