@capgo/cli 4.27.7 → 4.27.8

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 CHANGED
@@ -20,7 +20,7 @@ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
20
20
  `),this.outputHelp({error:!0}));let n=r||{},i=n.exitCode||1,o=n.code||"commander.error";this._exit(i,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in We.env){let r=e.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,We.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new mB(this.options),r=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&r(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!r(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let r=`error: missing required argument '${e}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(e){let r=`error: option '${e.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let r=`error: required option '${e.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,r){let n=s=>{let a=s.attributeName(),u=this.getOptionValue(a),c=this.options.find(f=>f.negate&&a===f.attributeName()),l=this.options.find(f=>!f.negate&&a===f.attributeName());return c&&(c.presetArg===void 0&&u===!1||c.presetArg!==void 0&&u===c.presetArg)?c:l||s},i=s=>{let a=n(s),u=a.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},o=`error: ${i(e)} cannot be used with ${i(r)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let r="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],o=this;do{let s=o.createHelp().visibleOptions(o).filter(a=>a.long).map(a=>a.long);i=i.concat(s),o=o.parent}while(o&&!o._enablePositionalOptions);r=Dw(e,i)}let n=`error: unknown option '${e}'${r}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,n=r===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${n} but got ${e.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],r="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(o=>{i.push(o.name()),o.alias()&&i.push(o.alias())}),r=Dw(e,i)}let n=`error: unknown command '${e}'${r}`;this.error(n,{code:"commander.unknownCommand"})}version(e,r,n){if(e===void 0)return this._version;this._version=e,r=r||"-V, --version",n=n||"output the version number";let i=this.createOption(r,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
21
  `),this._exit(0,"commander.version",e)}),this}description(e,r){return e===void 0&&r===void 0?this._description:(this._description=e,r&&(this._argsDescription=r),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),e===r._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return r._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(r=>this.alias(r)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(n=>hB(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=gn.basename(e,gn.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let r=this.createHelp();return r.helpWidth===void 0&&(r.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),r.formatHelp(this,r)}_getHelpContext(e){e=e||{};let r={error:!!e.error},n;return r.error?n=i=>this._outputConfiguration.writeErr(i):n=i=>this._outputConfiguration.writeOut(i),r.write=e.write||n,r.command=this,r}outputHelp(e){let r;typeof e=="function"&&(r=e,e=void 0);let n=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let i=this.helpInformation(n);if(r&&(i=r(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(e,r){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",r=r??"display help for command",this._helpOption=this.createOption(e,r),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let r=We.exitCode||0;r===0&&e&&typeof e!="function"&&e.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(e,r){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
22
  Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,o=>{let s;typeof r=="function"?s=r({error:o.error,command:o.command}):s=r,s&&o.write(`${s}
23
- `)}),this}_outputHelpIfRequested(e){let r=this._getHelpOption();r&&e.find(i=>r.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function vw(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let r,n="127.0.0.1",i="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?r=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=o[1],/^\d+$/.test(o[3])?i=o[3]:n=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=o[1],n=o[3],i=o[4]),r&&i!=="0"?`${r}=${n}:${parseInt(i)+1}`:e})}bw.Command=Np});var Sw=D(hr=>{var{Argument:_w}=rl(),{Command:Lp}=ww(),{CommanderError:gB,InvalidArgumentError:Ew}=ja(),{Help:yB}=Ap(),{Option:Cw}=Rp();hr.program=new Lp;hr.createCommand=t=>new Lp(t);hr.createOption=(t,e)=>new Cw(t,e);hr.createArgument=(t,e)=>new _w(t,e);hr.Command=Lp;hr.Option=Cw;hr.Argument=_w;hr.Help=yB;hr.CommanderError=gB;hr.InvalidArgumentError=Ew;hr.InvalidOptionArgumentError=Ew});var Te=D((xce,Fw)=>{"use strict";var Bp="\x1B",Be=`${Bp}[`,vB="\x07",qp={to(t,e){return e?`${Be}${e+1};${t+1}H`:`${Be}${t+1}G`},move(t,e){let r="";return t<0?r+=`${Be}${-t}D`:t>0&&(r+=`${Be}${t}C`),e<0?r+=`${Be}${-e}A`:e>0&&(r+=`${Be}${e}B`),r},up:(t=1)=>`${Be}${t}A`,down:(t=1)=>`${Be}${t}B`,forward:(t=1)=>`${Be}${t}C`,backward:(t=1)=>`${Be}${t}D`,nextLine:(t=1)=>`${Be}E`.repeat(t),prevLine:(t=1)=>`${Be}F`.repeat(t),left:`${Be}G`,hide:`${Be}?25l`,show:`${Be}?25h`,save:`${Bp}7`,restore:`${Bp}8`},bB={up:(t=1)=>`${Be}S`.repeat(t),down:(t=1)=>`${Be}T`.repeat(t)},wB={screen:`${Be}2J`,up:(t=1)=>`${Be}1J`.repeat(t),down:(t=1)=>`${Be}J`.repeat(t),line:`${Be}2K`,lineEnd:`${Be}K`,lineStart:`${Be}1K`,lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?qp.up():"");return t&&(e+=qp.left),e}};Fw.exports={cursor:qp,scroll:bB,erase:wB,beep:vB}});var Up=D((Fce,Mp)=>{var il=process||{},Ow=il.argv||[],nl=il.env||{},_B=!(nl.NO_COLOR||Ow.includes("--no-color"))&&(!!nl.FORCE_COLOR||Ow.includes("--color")||il.platform==="win32"||(il.stdout||{}).isTTY&&nl.TERM!=="dumb"||!!nl.CI),EB=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+CB(i,e,r,o)+e:t+i+e},CB=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},Aw=(t=_B)=>{let e=t?EB:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Mp.exports=Aw();Mp.exports.createColors=Aw});var pl=D(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.isNXMonorepo=qt.isMonorepo=qt.findPackageRelativePathInMonorepo=qt.findPackagePath=qt.findNXMonorepoRoot=qt.findMonorepoRoot=void 0;var Ba=require("node:fs"),Wn=require("node:path");function hl(t){let e=(0,Wn.join)(t,"package.json"),r=(0,Wn.join)(t,"pnpm-workspace.yaml");if((0,Ba.existsSync)(r)||(0,Ba.existsSync)(e)&&JSON.parse((0,Ba.readFileSync)(e,"utf-8")).workspaces)return t;let n=(0,Wn.dirname)(t);if(n===t)throw new Error("Monorepo root not found");return hl(n)}qt.findMonorepoRoot=hl;function nm(t){let e=(0,Wn.join)(t,"nx.json");if((0,Ba.existsSync)(e))return t;let r=(0,Wn.dirname)(t);if(r===t)throw new Error("Monorepo root not found");return nm(r)}qt.findNXMonorepoRoot=nm;function im(t,e,r){let n=(0,Wn.join)(e,"node_modules",t);if((0,Ba.existsSync)(n))return n;if(e===r)return null;let i=(0,Wn.dirname)(e);return im(t,i,r)}qt.findPackagePath=im;function iq(t,e){let r=hl(e),n=im(t,e,r);return n?(0,Wn.relative)(e,n):null}qt.findPackageRelativePathInMonorepo=iq;function oq(t){try{return hl(t),!0}catch{return!1}}qt.isMonorepo=oq;function sq(t){try{return nm(t),!0}catch{return!1}}qt.isNXMonorepo=sq});var Si={};mn(Si,{default:()=>aq});var aq,xi=ut(()=>{aq={}});var Ww=D(jr=>{"use strict";var uq=jr&&jr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),cq=jr&&jr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),lq=jr&&jr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&uq(e,t,r);return cq(e,t),e};Object.defineProperty(jr,"__esModule",{value:!0});jr.resolveFetch=void 0;var fq=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>lq((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};jr.resolveFetch=fq});var um=D(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.FunctionRegion=ir.FunctionsHttpError=ir.FunctionsRelayError=ir.FunctionsFetchError=ir.FunctionsError=void 0;var Mo=class extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}};ir.FunctionsError=Mo;var om=class extends Mo{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}};ir.FunctionsFetchError=om;var sm=class extends Mo{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}};ir.FunctionsRelayError=sm;var am=class extends Mo{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}};ir.FunctionsHttpError=am;var dq;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(dq=ir.FunctionRegion||(ir.FunctionRegion={}))});var Kw=D(Uo=>{"use strict";var hq=Uo&&Uo.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.FunctionsClient=void 0;var pq=Ww(),gl=um(),cm=class{constructor(e,{headers:r={},customFetch:n,region:i=gl.FunctionRegion.Any}={}){this.url=e,this.headers=r,this.region=i,this.fetch=(0,pq.resolveFetch)(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return hq(this,void 0,void 0,function*(){try{let{headers:i,method:o,body:s}=r,a={},{region:u}=r;u||(u=this.region),u&&u!=="any"&&(a["x-region"]=u);let c;s&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&s instanceof Blob||s instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=s):typeof s=="string"?(a["Content-Type"]="text/plain",c=s):typeof FormData<"u"&&s instanceof FormData?c=s:(a["Content-Type"]="application/json",c=JSON.stringify(s)));let l=yield this.fetch(`${this.url}/${e}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),i),body:c}).catch(p=>{throw new gl.FunctionsFetchError(p)}),f=l.headers.get("x-relay-error");if(f&&f==="true")throw new gl.FunctionsRelayError(l);if(!l.ok)throw new gl.FunctionsHttpError(l);let h=((n=l.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),d;return h==="application/json"?d=yield l.json():h==="application/octet-stream"?d=yield l.blob():h==="text/event-stream"?d=l:h==="multipart/form-data"?d=yield l.formData():d=yield l.text(),{data:d,error:null}}catch(i){return{data:null,error:i}}})}};Uo.FunctionsClient=cm});var lm=D(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.FunctionRegion=Mt.FunctionsRelayError=Mt.FunctionsHttpError=Mt.FunctionsFetchError=Mt.FunctionsError=Mt.FunctionsClient=void 0;var mq=Kw();Object.defineProperty(Mt,"FunctionsClient",{enumerable:!0,get:function(){return mq.FunctionsClient}});var Ma=um();Object.defineProperty(Mt,"FunctionsError",{enumerable:!0,get:function(){return Ma.FunctionsError}});Object.defineProperty(Mt,"FunctionsFetchError",{enumerable:!0,get:function(){return Ma.FunctionsFetchError}});Object.defineProperty(Mt,"FunctionsHttpError",{enumerable:!0,get:function(){return Ma.FunctionsHttpError}});Object.defineProperty(Mt,"FunctionsRelayError",{enumerable:!0,get:function(){return Ma.FunctionsRelayError}});Object.defineProperty(Mt,"FunctionRegion",{enumerable:!0,get:function(){return Ma.FunctionRegion}})});var hm=D(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var fm=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};dm.default=fm});var mm=D(Ua=>{"use strict";var Yw=Ua&&Ua.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ua,"__esModule",{value:!0});var gq=Yw((xi(),ke(Si))),yq=Yw(hm()),pm=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=gq.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=Object.assign({},this.headers),this.headers[e]=r,this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var s,a,u;let c=null,l=null,f=null,h=o.status,d=o.statusText;if(o.ok){if(this.method!=="HEAD"){let w=await o.text();w===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?l=w:l=JSON.parse(w))}let b=(s=this.headers.Prefer)===null||s===void 0?void 0:s.match(/count=(exact|planned|estimated)/),g=(a=o.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");b&&g&&g.length>1&&(f=parseInt(g[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(l)&&(l.length>1?(c={code:"PGRST116",details:`Results contain ${l.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},l=null,f=null,h=406,d="Not Acceptable"):l.length===1?l=l[0]:l=null)}else{let b=await o.text();try{c=JSON.parse(b),Array.isArray(c)&&o.status===404&&(l=[],c=null,h=200,d="OK")}catch{o.status===404&&b===""?(h=204,d="No Content"):c={message:b}}if(c&&this.isMaybeSingle&&(!((u=c?.details)===null||u===void 0)&&u.includes("0 rows"))&&(c=null,h=200,d="OK"),c&&this.shouldThrowOnError)throw new yq.default(c)}return{error:c,data:l,count:f,status:h,statusText:d}});return this.shouldThrowOnError||(i=i.catch(o=>{var s,a,u;return{error:{message:`${(s=o?.name)!==null&&s!==void 0?s:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=o?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(e,r)}};Ua.default=pm});var ym=D(Ha=>{"use strict";var Dq=Ha&&Ha.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ha,"__esModule",{value:!0});var vq=Dq(mm()),gm=class extends vq.default{select(e){let r=!1,n=(e??"*").split("").map(i=>/\s/.test(i)&&!r?"":(i==='"'&&(r=!r),i)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:i,referencedTable:o=i}={}){let s=o?`${o}.order`:"order",a=this.url.searchParams.get(s);return this.url.searchParams.set(s,`${a?`${a},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:i=n}={}){let o=typeof i>"u"?"offset":`${i}.offset`,s=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(s,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:i=!1,wal:o=!1,format:s="text"}={}){var a;let u=[e?"analyze":null,r?"verbose":null,n?"settings":null,i?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${s}; for="${c}"; options=${u};`,s==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Ha.default=gm});var yl=D(Va=>{"use strict";var bq=Va&&Va.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Va,"__esModule",{value:!0});var wq=bq(ym()),Dm=class extends wq.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){let n=Array.from(new Set(r)).map(i=>typeof i=="string"&&new RegExp("[,()]").test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:i}={}){let o="";i==="plain"?o="pl":i==="phrase"?o="ph":i==="websearch"&&(o="w");let s=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${s}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){let i=n?`${n}.or`:"or";return this.url.searchParams.append(i,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};Va.default=Dm});var bm=D(Ga=>{"use strict";var _q=Ga&&Ga.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ga,"__esModule",{value:!0});var za=_q(yl()),vm=class{constructor(e,{headers:r={},schema:n,fetch:i}){this.url=e,this.headers=r,this.schema=n,this.fetch=i}select(e,{head:r=!1,count:n}={}){let i=r?"HEAD":"GET",o=!1,s=(e??"*").split("").map(a=>/\s/.test(a)&&!o?"":(a==='"'&&(o=!o),a)).join("");return this.url.searchParams.set("select",s),n&&(this.headers.Prefer=`count=${n}`),new za.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:r,defaultToNull:n=!0}={}){let i="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),n||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){let s=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(s.length>0){let a=[...new Set(s)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new za.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:i,defaultToNull:o=!0}={}){let s="POST",a=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&a.push(this.headers.Prefer),i&&a.push(`count=${i}`),o||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let u=e.reduce((c,l)=>c.concat(Object.keys(l)),[]);if(u.length>0){let c=[...new Set(u)].map(l=>`"${l}"`);this.url.searchParams.set("columns",c.join(","))}}return new za.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:r}={}){let n="PATCH",i=[];return this.headers.Prefer&&i.push(this.headers.Prefer),r&&i.push(`count=${r}`),this.headers.Prefer=i.join(","),new za.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let r="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new za.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Ga.default=vm});var Jw=D(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.version=void 0;Dl.version="0.0.0-automated"});var Xw=D(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.DEFAULT_HEADERS=void 0;var Eq=Jw();vl.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${Eq.version}`}});var Qw=D(Wa=>{"use strict";var Zw=Wa&&Wa.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Wa,"__esModule",{value:!0});var Cq=Zw(bm()),Sq=Zw(yl()),xq=Xw(),wm=class t{constructor(e,{headers:r={},schema:n,fetch:i}={}){this.url=e,this.headers=Object.assign(Object.assign({},xq.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=i}from(e){let r=new URL(`${this.url}/${e}`);return new Cq.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new t(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:i=!1,count:o}={}){let s,a=new URL(`${this.url}/rpc/${e}`),u;n||i?(s=n?"HEAD":"GET",Object.entries(r).filter(([l,f])=>f!==void 0).map(([l,f])=>[l,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([l,f])=>{a.searchParams.append(l,f)})):(s="POST",u=r);let c=Object.assign({},this.headers);return o&&(c.Prefer=`count=${o}`),new Sq.default({method:s,url:a,headers:c,schema:this.schemaName,body:u,fetch:this.fetch,allowEmpty:!1})}};Wa.default=wm});var s_=D(Dt=>{"use strict";var Ho=Dt&&Dt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.PostgrestError=Dt.PostgrestBuilder=Dt.PostgrestTransformBuilder=Dt.PostgrestFilterBuilder=Dt.PostgrestQueryBuilder=Dt.PostgrestClient=void 0;var e_=Ho(Qw());Dt.PostgrestClient=e_.default;var t_=Ho(bm());Dt.PostgrestQueryBuilder=t_.default;var r_=Ho(yl());Dt.PostgrestFilterBuilder=r_.default;var n_=Ho(ym());Dt.PostgrestTransformBuilder=n_.default;var i_=Ho(mm());Dt.PostgrestBuilder=i_.default;var o_=Ho(hm());Dt.PostgrestError=o_.default;Dt.default={PostgrestClient:e_.default,PostgrestQueryBuilder:t_.default,PostgrestFilterBuilder:r_.default,PostgrestTransformBuilder:n_.default,PostgrestBuilder:i_.default,PostgrestError:o_.default}});var Em={};mn(Em,{RealtimeClient:()=>_m});var _m,Cm=ut(()=>{_m=class{constructor(){}connect(){}disconnect(){}}});var Ya=D(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.StorageUnknownError=Nr.StorageApiError=Nr.isStorageError=Nr.StorageError=void 0;var Ka=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};Nr.StorageError=Ka;function Fq(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}Nr.isStorageError=Fq;var Sm=class extends Ka{constructor(e,r){super(e),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}};Nr.StorageApiError=Sm;var xm=class extends Ka{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}};Nr.StorageUnknownError=xm});var bl=D(ct=>{"use strict";var Oq=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Aq=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a_=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Oq(e,t,r);return Aq(e,t),e},kq=ct&&ct.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(ct,"__esModule",{value:!0});ct.recursiveToCamel=ct.resolveResponse=ct.resolveFetch=void 0;var Tq=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>a_((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};ct.resolveFetch=Tq;var Pq=()=>kq(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>a_((xi(),ke(Si))))).Response:Response});ct.resolveResponse=Pq;var Rq=t=>{if(Array.isArray(t))return t.map(r=>(0,ct.recursiveToCamel)(r));if(typeof t=="function"||t!==Object(t))return t;let e={};return Object.entries(t).forEach(([r,n])=>{let i=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));e[i]=(0,ct.recursiveToCamel)(n)}),e};ct.recursiveToCamel=Rq});var Am=D(Ut=>{"use strict";var Fi=Ut&&Ut.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Ut,"__esModule",{value:!0});Ut.remove=Ut.head=Ut.put=Ut.post=Ut.get=void 0;var Fm=Ya(),$q=bl(),Om=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Iq=(t,e,r)=>Fi(void 0,void 0,void 0,function*(){let n=yield(0,$q.resolveResponse)();t instanceof n&&!r?.noResolveJson?t.json().then(i=>{e(new Fm.StorageApiError(Om(i),t.status||500))}).catch(i=>{e(new Fm.StorageUnknownError(Om(i),i))}):e(new Fm.StorageUnknownError(Om(t),t))}),jq=(t,e,r,n)=>{let i={method:t,headers:e?.headers||{}};return t==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json"},e?.headers),n&&(i.body=JSON.stringify(n)),Object.assign(Object.assign({},i),r))};function Ja(t,e,r,n,i,o){return Fi(this,void 0,void 0,function*(){return new Promise((s,a)=>{t(r,jq(e,n,i,o)).then(u=>{if(!u.ok)throw u;return n?.noResolveJson?u:u.json()}).then(u=>s(u)).catch(u=>Iq(u,a,n))})})}function Nq(t,e,r,n){return Fi(this,void 0,void 0,function*(){return Ja(t,"GET",e,r,n)})}Ut.get=Nq;function Lq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"POST",e,n,i,r)})}Ut.post=Lq;function Bq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"PUT",e,n,i,r)})}Ut.put=Bq;function qq(t,e,r,n){return Fi(this,void 0,void 0,function*(){return Ja(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}Ut.head=qq;function Mq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"DELETE",e,n,i,r)})}Ut.remove=Mq});var l_=D(Xa=>{"use strict";var Ht=Xa&&Xa.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Xa,"__esModule",{value:!0});var Vt=Ya(),Lr=Am(),u_=bl(),Uq={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},c_={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},km=class{constructor(e,r={},n,i){this.url=e,this.headers=r,this.bucketId=n,this.fetch=(0,u_.resolveFetch)(i)}uploadOrUpdate(e,r,n,i){return Ht(this,void 0,void 0,function*(){try{let o,s=Object.assign(Object.assign({},c_),i),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(s.upsert)}),u=s.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",s.cacheControl),u&&o.append("metadata",this.encodeMetadata(u)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",s.cacheControl),u&&o.append("metadata",this.encodeMetadata(u))):(o=n,a["cache-control"]=`max-age=${s.cacheControl}`,a["content-type"]=s.contentType,u&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(u)))),i?.headers&&(a=Object.assign(Object.assign({},a),i.headers));let c=this._removeEmptyFolders(r),l=this._getFinalPath(c),f=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:o,headers:a},s?.duplex?{duplex:s.duplex}:{})),h=yield f.json();return f.ok?{data:{path:c,id:h.Id,fullPath:h.Key},error:null}:{data:null,error:h}}catch(o){if((0,Vt.isStorageError)(o))return{data:null,error:o};throw o}})}upload(e,r,n){return Ht(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,i){return Ht(this,void 0,void 0,function*(){let o=this._removeEmptyFolders(e),s=this._getFinalPath(o),a=new URL(this.url+`/object/upload/sign/${s}`);a.searchParams.set("token",r);try{let u,c=Object.assign({upsert:c_.upsert},i),l=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&n instanceof Blob?(u=new FormData,u.append("cacheControl",c.cacheControl),u.append("",n)):typeof FormData<"u"&&n instanceof FormData?(u=n,u.append("cacheControl",c.cacheControl)):(u=n,l["cache-control"]=`max-age=${c.cacheControl}`,l["content-type"]=c.contentType);let f=yield this.fetch(a.toString(),{method:"PUT",body:u,headers:l}),h=yield f.json();return f.ok?{data:{path:o,fullPath:h.Key},error:null}:{data:null,error:h}}catch(u){if((0,Vt.isStorageError)(u))return{data:null,error:u};throw u}})}createSignedUploadUrl(e,r){return Ht(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),i=Object.assign({},this.headers);r?.upsert&&(i["x-upsert"]="true");let o=yield(0,Lr.post)(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:i}),s=new URL(this.url+o.url),a=s.searchParams.get("token");if(!a)throw new Vt.StorageError("No token returned by API");return{data:{signedUrl:s.toString(),path:e,token:a},error:null}}catch(n){if((0,Vt.isStorageError)(n))return{data:null,error:n};throw n}})}update(e,r,n){return Ht(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return Ht(this,void 0,void 0,function*(){try{return{data:yield(0,Lr.post)(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n?.destinationBucket},{headers:this.headers}),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}copy(e,r,n){return Ht(this,void 0,void 0,function*(){try{return{data:{path:(yield(0,Lr.post)(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}createSignedUrl(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=this._getFinalPath(e),o=yield(0,Lr.post)(this.fetch,`${this.url}/object/sign/${i}`,Object.assign({expiresIn:r},n?.transform?{transform:n.transform}:{}),{headers:this.headers}),s=n?.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${s}`)},{data:o,error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}createSignedUrls(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=yield(0,Lr.post)(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),o=n?.download?`&download=${n.download===!0?"":n.download}`:"";return{data:i.map(s=>Object.assign(Object.assign({},s),{signedUrl:s.signedURL?encodeURI(`${this.url}${s.signedURL}${o}`):null})),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}download(e,r){return Ht(this,void 0,void 0,function*(){let i=typeof r?.transform<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString(r?.transform||{}),s=o?`?${o}`:"";try{let a=this._getFinalPath(e);return{data:yield(yield(0,Lr.get)(this.fetch,`${this.url}/${i}/${a}${s}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if((0,Vt.isStorageError)(a))return{data:null,error:a};throw a}})}info(e){return Ht(this,void 0,void 0,function*(){let r=this._getFinalPath(e);try{let n=yield(0,Lr.get)(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:(0,u_.recursiveToCamel)(n),error:null}}catch(n){if((0,Vt.isStorageError)(n))return{data:null,error:n};throw n}})}exists(e){return Ht(this,void 0,void 0,function*(){let r=this._getFinalPath(e);try{return yield(0,Lr.head)(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if((0,Vt.isStorageError)(n)&&n instanceof Vt.StorageUnknownError){let i=n.originalError;if([400,404].includes(i?.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){let n=this._getFinalPath(e),i=[],o=r?.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&i.push(o);let a=typeof r?.transform<"u"?"render/image":"object",u=this.transformOptsToQueryString(r?.transform||{});u!==""&&i.push(u);let c=i.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${c}`)}}}remove(e){return Ht(this,void 0,void 0,function*(){try{return{data:yield(0,Lr.remove)(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if((0,Vt.isStorageError)(r))return{data:null,error:r};throw r}})}list(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=Object.assign(Object.assign(Object.assign({},Uq),r),{prefix:e||""});return{data:yield(0,Lr.post)(this.fetch,`${this.url}/object/list/${this.bucketId}`,i,{headers:this.headers},n),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}};Xa.default=km});var f_=D(wl=>{"use strict";Object.defineProperty(wl,"__esModule",{value:!0});wl.version=void 0;wl.version="2.7.1"});var d_=D(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.DEFAULT_HEADERS=void 0;var Hq=f_();_l.DEFAULT_HEADERS={"X-Client-Info":`storage-js/${Hq.version}`}});var h_=D(Za=>{"use strict";var Vo=Za&&Za.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Za,"__esModule",{value:!0});var Vq=d_(),zo=Ya(),Go=Am(),zq=bl(),Tm=class{constructor(e,r={},n){this.url=e,this.headers=Object.assign(Object.assign({},Vq.DEFAULT_HEADERS),r),this.fetch=(0,zq.resolveFetch)(n)}listBuckets(){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.get)(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if((0,zo.isStorageError)(e))return{data:null,error:e};throw e}})}getBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.get)(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.post)(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if((0,zo.isStorageError)(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.put)(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if((0,zo.isStorageError)(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.post)(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.remove)(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}};Za.default=Tm});var m_=D(Wo=>{"use strict";var p_=Wo&&Wo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Wo,"__esModule",{value:!0});Wo.StorageClient=void 0;var Gq=p_(l_()),Wq=p_(h_()),Pm=class extends Wq.default{constructor(e,r={},n){super(e,r,n)}from(e){return new Gq.default(this.url,this.headers,e,this.fetch)}};Wo.StorageClient=Pm});var y_=D(g_=>{"use strict";Object.defineProperty(g_,"__esModule",{value:!0})});var v_=D(Br=>{"use strict";var Kq=Br&&Br.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),D_=Br&&Br.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Kq(e,t,r)};Object.defineProperty(Br,"__esModule",{value:!0});Br.StorageClient=void 0;var Yq=m_();Object.defineProperty(Br,"StorageClient",{enumerable:!0,get:function(){return Yq.StorageClient}});D_(y_(),Br);D_(Ya(),Br)});var b_=D(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});El.version=void 0;El.version="2.46.0"});var w_=D(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.DEFAULT_REALTIME_OPTIONS=or.DEFAULT_AUTH_OPTIONS=or.DEFAULT_DB_OPTIONS=or.DEFAULT_GLOBAL_OPTIONS=or.DEFAULT_HEADERS=void 0;var Jq=b_(),Qa="";typeof Deno<"u"?Qa="deno":typeof document<"u"?Qa="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Qa="react-native":Qa="node";or.DEFAULT_HEADERS={"X-Client-Info":`supabase-js-${Qa}/${Jq.version}`};or.DEFAULT_GLOBAL_OPTIONS={headers:or.DEFAULT_HEADERS};or.DEFAULT_DB_OPTIONS={schema:"public"};or.DEFAULT_AUTH_OPTIONS={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"};or.DEFAULT_REALTIME_OPTIONS={}});var E_=D(lt=>{"use strict";var Xq=lt&&lt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Zq=lt&&lt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Qq=lt&&lt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Xq(e,t,r);return Zq(e,t),e},eM=lt&&lt.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(lt,"__esModule",{value:!0});lt.fetchWithAuth=lt.resolveHeadersConstructor=lt.resolveFetch=void 0;var __=Qq((xi(),ke(Si))),tM=t=>{let e;return t?e=t:typeof fetch>"u"?e=__.default:e=fetch,(...r)=>e(...r)};lt.resolveFetch=tM;var rM=()=>typeof Headers>"u"?__.Headers:Headers;lt.resolveHeadersConstructor=rM;var nM=(t,e,r)=>{let n=(0,lt.resolveFetch)(r),i=(0,lt.resolveHeadersConstructor)();return(o,s)=>eM(void 0,void 0,void 0,function*(){var a;let u=(a=yield e())!==null&&a!==void 0?a:t,c=new i(s?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${u}`),n(o,Object.assign(Object.assign({},s),{headers:c}))})};lt.fetchWithAuth=nM});var C_=D(mr=>{"use strict";var iM=mr&&mr.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(mr,"__esModule",{value:!0});mr.applySettingDefaults=mr.isBrowser=mr.stripTrailingSlash=mr.uuid=void 0;function oM(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=Math.random()*16|0,r=t=="x"?e:e&3|8;return r.toString(16)})}mr.uuid=oM;function sM(t){return t.replace(/\/$/,"")}mr.stripTrailingSlash=sM;var aM=()=>typeof window<"u";mr.isBrowser=aM;function uM(t,e){let{db:r,auth:n,realtime:i,global:o}=t,{db:s,auth:a,realtime:u,global:c}=e,l={db:Object.assign(Object.assign({},s),r),auth:Object.assign(Object.assign({},a),n),realtime:Object.assign(Object.assign({},u),i),global:Object.assign(Object.assign({},c),o),accessToken:()=>iM(this,void 0,void 0,function*(){return""})};return t.accessToken?l.accessToken=t.accessToken:delete l.accessToken,l}mr.applySettingDefaults=uM});var Rm=D(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.version=void 0;Cl.version="2.65.1"});var Sl=D(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.API_VERSIONS=ft.API_VERSION_HEADER_NAME=ft.NETWORK_FAILURE=ft.EXPIRY_MARGIN=ft.DEFAULT_HEADERS=ft.AUDIENCE=ft.STORAGE_KEY=ft.GOTRUE_URL=void 0;var cM=Rm();ft.GOTRUE_URL="http://localhost:9999";ft.STORAGE_KEY="supabase.auth.token";ft.AUDIENCE="";ft.DEFAULT_HEADERS={"X-Client-Info":`gotrue-js/${cM.version}`};ft.EXPIRY_MARGIN=10;ft.NETWORK_FAILURE={MAX_RETRIES:10,RETRY_INTERVAL:2};ft.API_VERSION_HEADER_NAME="X-Supabase-Api-Version";ft.API_VERSIONS={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}}});var Ko=D(ee=>{"use strict";var lM=ee&&ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),fM=ee&&ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dM=ee&&ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&lM(e,t,r);return fM(e,t),e};Object.defineProperty(ee,"__esModule",{value:!0});ee.parseResponseAPIVersion=ee.getCodeChallengeAndMethod=ee.generatePKCEChallenge=ee.generatePKCEVerifier=ee.retryable=ee.sleep=ee.decodeJWTPayload=ee.Deferred=ee.decodeBase64URL=ee.removeItemAsync=ee.getItemAsync=ee.setItemAsync=ee.looksLikeFetchResponse=ee.resolveFetch=ee.parseParametersFromURL=ee.supportsLocalStorage=ee.isBrowser=ee.uuid=ee.expiresAt=void 0;var hM=Sl();function pM(t){return Math.round(Date.now()/1e3)+t}ee.expiresAt=pM;function mM(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}ee.uuid=mM;var gM=()=>typeof document<"u";ee.isBrowser=gM;var Oi={tested:!1,writable:!1},yM=()=>{if(!(0,ee.isBrowser)())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Oi.tested)return Oi.writable;let t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Oi.tested=!0,Oi.writable=!0}catch{Oi.tested=!0,Oi.writable=!1}return Oi.writable};ee.supportsLocalStorage=yM;function DM(t){let e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((i,o)=>{e[o]=i})}catch{}return r.searchParams.forEach((n,i)=>{e[i]=n}),e}ee.parseParametersFromURL=DM;var vM=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>dM((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};ee.resolveFetch=vM;var bM=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function";ee.looksLikeFetchResponse=bM;var wM=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))};ee.setItemAsync=wM;var _M=async(t,e)=>{let r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}};ee.getItemAsync=_M;var EM=async(t,e)=>{await t.removeItem(e)};ee.removeItemAsync=EM;function S_(t){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="",n,i,o,s,a,u,c,l=0;for(t=t.replace("-","+").replace("_","/");l<t.length;)s=e.indexOf(t.charAt(l++)),a=e.indexOf(t.charAt(l++)),u=e.indexOf(t.charAt(l++)),c=e.indexOf(t.charAt(l++)),n=s<<2|a>>4,i=(a&15)<<4|u>>2,o=(u&3)<<6|c,r=r+String.fromCharCode(n),u!=64&&i!=0&&(r=r+String.fromCharCode(i)),c!=64&&o!=0&&(r=r+String.fromCharCode(o));return r}ee.decodeBase64URL=S_;var xl=class t{constructor(){this.promise=new t.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}};ee.Deferred=xl;xl.promiseConstructor=Promise;function CM(t){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,r=t.split(".");if(r.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(r[1]))throw new Error("JWT is not valid: payload is not in base64url format");let n=r[1];return JSON.parse(S_(n))}ee.decodeJWTPayload=CM;async function SM(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}ee.sleep=SM;function xM(t,e){return new Promise((n,i)=>{(async()=>{for(let o=0;o<1/0;o++)try{let s=await t(o);if(!e(o,null,s)){n(s);return}}catch(s){if(!e(o,s)){i(s);return}}})()})}ee.retryable=xM;function FM(t){return("0"+t.toString(16)).substr(-2)}function x_(){let e=new Uint32Array(56);if(typeof crypto>"u"){let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length,i="";for(let o=0;o<56;o++)i+=r.charAt(Math.floor(Math.random()*n));return i}return crypto.getRandomValues(e),Array.from(e,FM).join("")}ee.generatePKCEVerifier=x_;async function OM(t){let r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),i=new Uint8Array(n);return Array.from(i).map(o=>String.fromCharCode(o)).join("")}function AM(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function F_(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;let r=await OM(t);return AM(r)}ee.generatePKCEChallenge=F_;async function kM(t,e,r=!1){let n=x_(),i=n;r&&(i+="/PASSWORD_RECOVERY"),await(0,ee.setItemAsync)(t,`${e}-code-verifier`,i);let o=await F_(n);return[o,n===o?"plain":"s256"]}ee.getCodeChallengeAndMethod=kM;var TM=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function PM(t){let e=t.headers.get(hM.API_VERSION_HEADER_NAME);if(!e||!e.match(TM))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}ee.parseResponseAPIVersion=PM});var tu=D(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.isAuthWeakPasswordError=he.AuthWeakPasswordError=he.isAuthRetryableFetchError=he.AuthRetryableFetchError=he.AuthPKCEGrantCodeExchangeError=he.AuthImplicitGrantRedirectError=he.AuthInvalidCredentialsError=he.AuthInvalidTokenResponseError=he.isAuthSessionMissingError=he.AuthSessionMissingError=he.CustomAuthError=he.AuthUnknownError=he.isAuthApiError=he.AuthApiError=he.isAuthError=he.AuthError=void 0;var Yo=class extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}};he.AuthError=Yo;function eu(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}he.isAuthError=eu;var $m=class extends Yo{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}};he.AuthApiError=$m;function RM(t){return eu(t)&&t.name==="AuthApiError"}he.isAuthApiError=RM;var Im=class extends Yo{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}};he.AuthUnknownError=Im;var qr=class extends Yo{constructor(e,r,n,i){super(e,n,i),this.name=r,this.status=n}};he.CustomAuthError=qr;var jm=class extends qr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};he.AuthSessionMissingError=jm;function $M(t){return eu(t)&&t.name==="AuthSessionMissingError"}he.isAuthSessionMissingError=$M;var Nm=class extends qr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}};he.AuthInvalidTokenResponseError=Nm;var Lm=class extends qr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}};he.AuthInvalidCredentialsError=Lm;var Bm=class extends qr{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};he.AuthImplicitGrantRedirectError=Bm;var qm=class extends qr{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};he.AuthPKCEGrantCodeExchangeError=qm;var Mm=class extends qr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}};he.AuthRetryableFetchError=Mm;function IM(t){return eu(t)&&t.name==="AuthRetryableFetchError"}he.isAuthRetryableFetchError=IM;var Um=class extends qr{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}};he.AuthWeakPasswordError=Um;function jM(t){return eu(t)&&t.name==="AuthWeakPasswordError"}he.isAuthWeakPasswordError=jM});var zm=D(rt=>{"use strict";var NM=rt&&rt.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(rt,"__esModule",{value:!0});rt._noResolveJsonResponse=rt._generateLinkResponse=rt._ssoResponse=rt._userResponse=rt._sessionResponsePassword=rt._sessionResponse=rt._request=rt.handleError=void 0;var Fl=Sl(),Hm=Ko(),Kn=tu(),Ai=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),LM=[502,503,504];async function Vm(t){var e;if(!(0,Hm.looksLikeFetchResponse)(t))throw new Kn.AuthRetryableFetchError(Ai(t),0);if(LM.includes(t.status))throw new Kn.AuthRetryableFetchError(Ai(t),t.status);let r;try{r=await t.json()}catch(o){throw new Kn.AuthUnknownError(Ai(o),o)}let n,i=(0,Hm.parseResponseAPIVersion)(t);if(i&&i.getTime()>=Fl.API_VERSIONS["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new Kn.AuthWeakPasswordError(Ai(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Kn.AuthSessionMissingError}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,s)=>o&&typeof s=="string",!0))throw new Kn.AuthWeakPasswordError(Ai(r),t.status,r.weak_password.reasons);throw new Kn.AuthApiError(Ai(r),t.status||500,n)}rt.handleError=Vm;var BM=(t,e,r,n)=>{let i={method:t,headers:e?.headers||{}};return t==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),i.body=JSON.stringify(n),Object.assign(Object.assign({},i),r))};async function qM(t,e,r,n){var i;let o=Object.assign({},n?.headers);o[Fl.API_VERSION_HEADER_NAME]||(o[Fl.API_VERSION_HEADER_NAME]=Fl.API_VERSIONS["2024-01-01"].name),n?.jwt&&(o.Authorization=`Bearer ${n.jwt}`);let s=(i=n?.query)!==null&&i!==void 0?i:{};n?.redirectTo&&(s.redirect_to=n.redirectTo);let a=Object.keys(s).length?"?"+new URLSearchParams(s).toString():"",u=await MM(t,e,r+a,{headers:o,noResolveJson:n?.noResolveJson},{},n?.body);return n?.xform?n?.xform(u):{data:Object.assign({},u),error:null}}rt._request=qM;async function MM(t,e,r,n,i,o){let s=BM(e,n,i,o),a;try{a=await t(r,Object.assign({},s))}catch(u){throw console.error(u),new Kn.AuthRetryableFetchError(Ai(u),0)}if(a.ok||await Vm(a),n?.noResolveJson)return a;try{return await a.json()}catch(u){await Vm(u)}}function O_(t){var e;let r=null;WM(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=(0,Hm.expiresAt)(t.expires_in)));let n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}rt._sessionResponse=O_;function UM(t){let e=O_(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}rt._sessionResponsePassword=UM;function HM(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}rt._userResponse=HM;function VM(t){return{data:t,error:null}}rt._ssoResponse=VM;function zM(t){let{action_link:e,email_otp:r,hashed_token:n,redirect_to:i,verification_type:o}=t,s=NM(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:i,verification_type:o},u=Object.assign({},s);return{data:{properties:a,user:u},error:null}}rt._generateLinkResponse=zM;function GM(t){return t}rt._noResolveJsonResponse=GM;function WM(t){return t.access_token&&t.refresh_token&&t.expires_in}});var Ol=D(ru=>{"use strict";var KM=ru&&ru.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(ru,"__esModule",{value:!0});var vt=zm(),YM=Ko(),Mr=tu(),Gm=class{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=(0,YM.resolveFetch)(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,r="global"){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if((0,Mr.isAuthError)(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{let{options:r}=e,n=KM(e,["options"]),i=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(i.new_email=n?.newEmail,delete i.newEmail),await(0,vt._request)(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:vt._generateLinkResponse,redirectTo:r?.redirectTo})}catch(r){if((0,Mr.isAuthError)(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:vt._userResponse})}catch(r){if((0,Mr.isAuthError)(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,i,o,s,a,u;try{let c={nextPage:null,lastPage:0,total:0},l=await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(i=e?.perPage)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""},xform:vt._noResolveJsonResponse});if(l.error)throw l.error;let f=await l.json(),h=(s=l.headers.get("x-total-count"))!==null&&s!==void 0?s:0,d=(u=(a=l.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&u!==void 0?u:[];return d.length>0&&(d.forEach(p=>{let b=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);c[`${g}Page`]=b}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},f),c),error:null}}catch(c){if((0,Mr.isAuthError)(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){try{return await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:vt._userResponse})}catch(r){if((0,Mr.isAuthError)(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){try{return await(0,vt._request)(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){try{return await(0,vt._request)(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{let{data:r,error:n}=await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:i=>({data:{factors:i},error:null})});return{data:r,error:n}}catch(r){if((0,Mr.isAuthError)(r))return{data:null,error:r};throw r}}async _deleteFactor(e){try{return{data:await(0,vt._request)(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if((0,Mr.isAuthError)(r))return{data:null,error:r};throw r}}};ru.default=Gm});var A_=D(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.memoryLocalStorageAdapter=Jo.localStorageAdapter=void 0;var Wm=Ko();Jo.localStorageAdapter={getItem:t=>(0,Wm.supportsLocalStorage)()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{(0,Wm.supportsLocalStorage)()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{(0,Wm.supportsLocalStorage)()&&globalThis.localStorage.removeItem(t)}};function JM(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}Jo.memoryLocalStorageAdapter=JM});var k_=D(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.polyfillGlobalThis=void 0;function XM(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}Al.polyfillGlobalThis=XM});var Km=D(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.navigatorLock=Ct.NavigatorLockAcquireTimeoutError=Ct.LockAcquireTimeoutError=Ct.internals=void 0;var ZM=Ko();Ct.internals={debug:!!(globalThis&&(0,ZM.supportsLocalStorage)()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};var kl=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}};Ct.LockAcquireTimeoutError=kl;var Tl=class extends kl{};Ct.NavigatorLockAcquireTimeoutError=Tl;async function QM(t,e,r){Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);let n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async i=>{if(i){Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Tl(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Ct.internals.debug)try{let o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}})}Ct.navigatorLock=QM});var Jm=D(ou=>{"use strict";var e4=ou&&ou.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ou,"__esModule",{value:!0});var t4=e4(Ol()),iu=Sl(),Z=tu(),ae=zm(),fe=Ko(),Ym=A_(),r4=k_(),n4=Rm(),T_=Km();(0,r4.polyfillGlobalThis)();var i4={url:iu.GOTRUE_URL,storageKey:iu.STORAGE_KEY,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:iu.DEFAULT_HEADERS,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},nu=30*1e3,P_=3;async function R_(t,e,r){return await r()}var Pl=class t{constructor(e){var r,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=t.nextInstanceID,t.nextInstanceID+=1,this.instanceID>0&&(0,fe.isBrowser)()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let i=Object.assign(Object.assign({},i4),e);if(this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.persistSession=i.persistSession,this.storageKey=i.storageKey,this.autoRefreshToken=i.autoRefreshToken,this.admin=new t4.default({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=(0,fe.resolveFetch)(i.fetch),this.lock=i.lock||R_,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,i.lock?this.lock=i.lock:(0,fe.isBrowser)()&&(!((r=globalThis?.navigator)===null||r===void 0)&&r.locks)?this.lock=T_.navigatorLock:this.lock=R_,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?i.storage?this.storage=i.storage:(0,fe.supportsLocalStorage)()?this.storage=Ym.localStorageAdapter:(this.memoryStorage={},this.storage=(0,Ym.memoryLocalStorageAdapter)(this.memoryStorage)):(this.memoryStorage={},this.storage=(0,Ym.memoryLocalStorageAdapter)(this.memoryStorage)),(0,fe.isBrowser)()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${n4.version}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){try{let e=(0,fe.isBrowser)()?await this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){let{data:r,error:n}=await this._getSessionFromURL(e);if(n)return this._debug("#_initialize()","error detecting session from URL",n),n?.code==="identity_already_exists"?{error:n}:(await this._removeSession(),{error:n});let{session:i,redirectType:o}=r;return this._debug("#_initialize()","detected session in URL",i,"redirect type",o),await this._saveSession(i),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return(0,Z.isAuthError)(e)?{error:e}:{error:new Z.AuthUnknownError("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,i;try{let o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e?.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(i=e?.options)===null||i===void 0?void 0:i.captchaToken}},xform:ae._sessionResponse}),{data:s,error:a}=o;if(a||!s)return{data:{user:null,session:null},error:a};let u=s.session,c=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(e){var r,n,i;try{let o;if("email"in e){let{email:l,password:f,options:h}=e,d=null,p=null;this.flowType==="pkce"&&([d,p]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey)),o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h?.emailRedirectTo,body:{email:l,password:f,data:(r=h?.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:d,code_challenge_method:p},xform:ae._sessionResponse})}else if("phone"in e){let{phone:l,password:f,options:h}=e;o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:l,password:f,data:(n=h?.data)!==null&&n!==void 0?n:{},channel:(i=h?.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:ae._sessionResponse})}else throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:s,error:a}=o;if(a||!s)return{data:{user:null,session:null},error:a};let u=s.session,c=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(e){try{let r;if("email"in e){let{email:o,password:s,options:a}=e;r=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:s,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ae._sessionResponsePassword})}else if("phone"in e){let{phone:o,password:s,options:a}=e;r=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:s,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ae._sessionResponsePassword})}else throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:n,error:i}=r;return i?{data:{user:null,session:null},error:i}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new Z.AuthInvalidTokenResponseError}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:i})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,i,o;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(i=e.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(o=e.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let r=await(0,fe.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`),[n,i]=(r??"").split("/");try{let{data:o,error:s}=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:ae._sessionResponse});if(await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),s)throw s;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new Z.AuthInvalidTokenResponseError}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:i??null}),error:s})}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(e){try{let{options:r,provider:n,token:i,access_token:o,nonce:s}=e,a=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:i,access_token:o,nonce:s,gotrue_meta_security:{captcha_token:r?.captchaToken}},xform:ae._sessionResponse}),{data:u,error:c}=a;return c?{data:{user:null,session:null},error:c}:!u||!u.session||!u.user?{data:{user:null,session:null},error:new Z.AuthInvalidTokenResponseError}:(u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),{data:u,error:c})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,i,o,s;try{if("email"in e){let{email:a,options:u}=e,c=null,l=null;this.flowType==="pkce"&&([c,l]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey));let{error:f}=await(0,ae._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=u?.data)!==null&&r!==void 0?r:{},create_user:(n=u?.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:u?.captchaToken},code_challenge:c,code_challenge_method:l},redirectTo:u?.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in e){let{phone:a,options:u}=e,{data:c,error:l}=await(0,ae._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(i=u?.data)!==null&&i!==void 0?i:{},create_user:(o=u?.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:u?.captchaToken},channel:(s=u?.channel)!==null&&s!==void 0?s:"sms"}});return{data:{user:null,session:null,messageId:c?.message_id},error:l}}throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number.")}catch(a){if((0,Z.isAuthError)(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var r,n;try{let i,o;"options"in e&&(i=(r=e.options)===null||r===void 0?void 0:r.redirectTo,o=(n=e.options)===null||n===void 0?void 0:n.captchaToken);let{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:i,xform:ae._sessionResponse});if(a)throw a;if(!s)throw new Error("An error occurred on token verification.");let u=s.session,c=s.user;return u?.access_token&&(await this._saveSession(u),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(i){if((0,Z.isAuthError)(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithSSO(e){var r,n,i;try{let o=null,s=null;return this.flowType==="pkce"&&([o,s]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey)),await(0,ae._request)(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((i=e?.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:s}),headers:this.headers,xform:ae._ssoResponse})}catch(o){if((0,Z.isAuthError)(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new Z.AuthSessionMissingError;let{error:i}=await(0,ae._request)(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:i}})}catch(e){if((0,Z.isAuthError)(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let r=`${this.url}/resend`;if("email"in e){let{email:n,type:i,options:o}=e,{error:s}=await(0,ae._request)(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},redirectTo:o?.emailRedirectTo});return{data:{user:null,session:null},error:s}}else if("phone"in e){let{phone:n,type:i,options:o}=e,{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:i,gotrue_meta_security:{captcha_token:o?.captchaToken}}});return{data:{user:null,session:null,messageId:s?.message_id},error:a}}throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a type")}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){let i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,r=await(0,fe.getItemAsync)(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let n=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.storage.isServer){let s=this.suppressGetSessionWarning;e=new Proxy(e,{get:(u,c,l)=>(!s&&c==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s=!0,this.suppressGetSessionWarning=!0),Reflect.get(u,c,l))})}return{data:{session:e},error:null}}let{session:i,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{session:null},error:o}:{data:{session:i},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await(0,ae._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ae._userResponse}):await this._useSession(async r=>{var n,i,o;let{data:s,error:a}=r;if(a)throw a;return!(!((n=s.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Z.AuthSessionMissingError}:await(0,ae._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(i=s.session)===null||i===void 0?void 0:i.access_token)!==null&&o!==void 0?o:void 0,xform:ae._userResponse})})}catch(r){if((0,Z.isAuthError)(r))return(0,Z.isAuthSessionMissingError)(r)&&(await this._removeSession(),await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{let{data:i,error:o}=n;if(o)throw o;if(!i.session)throw new Z.AuthSessionMissingError;let s=i.session,a=null,u=null;this.flowType==="pkce"&&e.email!=null&&([a,u]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey));let{data:c,error:l}=await(0,ae._request)(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:u}),jwt:s.access_token,xform:ae._userResponse});if(l)throw l;return s.user=c.user,await this._saveSession(s),await this._notifyAllSubscribers("USER_UPDATED",s),{data:{user:s.user},error:null}})}catch(n){if((0,Z.isAuthError)(n))return{data:{user:null},error:n};throw n}}_decodeJWT(e){return(0,fe.decodeJWTPayload)(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Z.AuthSessionMissingError;let r=Date.now()/1e3,n=r,i=!0,o=null,s=(0,fe.decodeJWTPayload)(e.access_token);if(s.exp&&(n=s.exp,i=n<=r),i){let{session:a,error:u}=await this._callRefreshToken(e.refresh_token);if(u)return{data:{user:null,session:null},error:u};if(!a)return{data:{user:null,session:null},error:null};o=a}else{let{data:a,error:u}=await this._getUser(e.access_token);if(u)throw u;o={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){let{data:s,error:a}=r;if(a)throw a;e=(n=s.session)!==null&&n!==void 0?n:void 0}if(!e?.refresh_token)throw new Z.AuthSessionMissingError;let{session:i,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{user:null,session:null},error:o}:i?{data:{user:i.user,session:i},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e){try{if(!(0,fe.isBrowser)())throw new Z.AuthImplicitGrantRedirectError("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new Z.AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new Z.AuthPKCEGrantCodeExchangeError("Not a valid PKCE flow url.");let r=(0,fe.parseParametersFromURL)(window.location.href);if(e){if(!r.code)throw new Z.AuthPKCEGrantCodeExchangeError("No code detected.");let{data:S,error:y}=await this._exchangeCodeForSession(r.code);if(y)throw y;let C=new URL(window.location.href);return C.searchParams.delete("code"),window.history.replaceState(window.history.state,"",C.toString()),{data:{session:S.session,redirectType:null},error:null}}if(r.error||r.error_description||r.error_code)throw new Z.AuthImplicitGrantRedirectError(r.error_description||"Error in URL with unspecified error_description",{error:r.error||"unspecified_error",code:r.error_code||"unspecified_code"});let{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:s,expires_in:a,expires_at:u,token_type:c}=r;if(!o||!a||!s||!c)throw new Z.AuthImplicitGrantRedirectError("No session defined in URL");let l=Math.round(Date.now()/1e3),f=parseInt(a),h=l+f;u&&(h=parseInt(u));let d=h-l;d*1e3<=nu&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${f}s`);let p=h-f;l-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,h,l):l-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,h,l);let{data:b,error:g}=await this._getUser(o);if(g)throw g;let w={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:h,refresh_token:s,token_type:c,user:b.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:w,redirectType:r.type},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantFlow(){let e=(0,fe.parseParametersFromURL)(window.location.href);return!!((0,fe.isBrowser)()&&(e.access_token||e.error_description))}async _isPKCEFlow(){let e=(0,fe.parseParametersFromURL)(window.location.href),r=await(0,fe.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;let{data:i,error:o}=r;if(o)return{error:o};let s=(n=i.session)===null||n===void 0?void 0:n.access_token;if(s){let{error:a}=await this.admin.signOut(s,e);if(a&&!((0,Z.isAuthApiError)(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let r=(0,fe.uuid)(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,i;try{let{data:{session:o},error:s}=r;if(s)throw s;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",e,"session",o)}catch(o){await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",o),console.error(o)}})}async resetPasswordForEmail(e,r={}){let n=null,i=null;this.flowType==="pkce"&&([n,i]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey,!0));try{return await(0,ae._request)(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:i,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if((0,Z.isAuthError)(o))return{data:null,error:o};throw o}}async getUserIdentities(){var e;try{let{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{let{data:n,error:i}=await this._useSession(async o=>{var s,a,u,c,l;let{data:f,error:h}=o;if(h)throw h;let d=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(u=e.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return await(0,ae._request)(this.fetch,"GET",d,{headers:this.headers,jwt:(l=(c=f.session)===null||c===void 0?void 0:c.access_token)!==null&&l!==void 0?l:void 0})});if(i)throw i;return(0,fe.isBrowser)()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n?.url),{data:{provider:e.provider,url:n?.url},error:null}}catch(n){if((0,Z.isAuthError)(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,i;let{data:o,error:s}=r;if(s)throw s;return await(0,ae._request)(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){let r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{let n=Date.now();return await(0,fe.retryable)(async i=>(i>0&&await(0,fe.sleep)(200*Math.pow(2,i-1)),this._debug(r,"refreshing attempt",i),await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ae._sessionResponse})),(i,o)=>{let s=200*Math.pow(2,i);return o&&(0,Z.isAuthRetryableFetchError)(o)&&Date.now()+s-n<nu})}catch(n){if(this._debug(r,"error",n),(0,Z.isAuthError)(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){let n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),(0,fe.isBrowser)()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let n=await(0,fe.getItemAsync)(this.storage,this.storageKey);if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}let i=Math.round(Date.now()/1e3),o=((e=n.expires_at)!==null&&e!==void 0?e:1/0)<i+iu.EXPIRY_MARGIN;if(this._debug(r,`session has${o?"":" not"} expired with margin of ${iu.EXPIRY_MARGIN}s`),o){if(this.autoRefreshToken&&n.refresh_token){let{error:s}=await this._callRefreshToken(n.refresh_token);s&&(console.error(s),(0,Z.isAuthRetryableFetchError)(s)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",s),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new Z.AuthSessionMissingError;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let i=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(i,"begin");try{this.refreshingDeferred=new fe.Deferred;let{data:o,error:s}=await this._refreshAccessToken(e);if(s)throw s;if(!o.session)throw new Z.AuthSessionMissingError;await this._saveSession(o.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);let a={session:o.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(o){if(this._debug(i,"error",o),(0,Z.isAuthError)(o)){let s={session:null,error:o};return(0,Z.isAuthRetryableFetchError)(o)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(s),s}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(o),o}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(e,r,n=!0){let i=`#_notifyAllSubscribers(${e})`;this._debug(i,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});let o=[],s=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,r)}catch(u){o.push(u)}});if(await Promise.all(s),o.length>0){for(let a=0;a<o.length;a+=1)console.error(o[a]);throw o[0]}}finally{this._debug(i,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await(0,fe.setItemAsync)(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await(0,fe.removeItemAsync)(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&(0,fe.isBrowser)()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),nu);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async r=>{let{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let i=Math.floor((n.expires_at*1e3-e)/nu);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${nu}ms, refresh threshold is ${P_} ticks`),i<=P_&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof T_.LockAcquireTimeoutError)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!(0,fe.isBrowser)()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){let i=[`provider=${encodeURIComponent(r)}`];if(n?.redirectTo&&i.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n?.scopes&&i.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){let[o,s]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(s)}`});i.push(a.toString())}if(n?.queryParams){let o=new URLSearchParams(n.queryParams);i.push(o.toString())}return n?.skipBrowserRedirect&&i.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${i.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;return o?{data:null,error:o}:await(0,ae._request)(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,i;let{data:o,error:s}=r;if(s)return{data:null,error:s};let a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:u,error:c}=await(0,ae._request)(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=o?.session)===null||n===void 0?void 0:n.access_token});return c?{data:null,error:c}:(e.factorType==="totp"&&(!((i=u?.totp)===null||i===void 0)&&i.qr_code)&&(u.totp.qr_code=`data:image/svg+xml;utf-8,${u.totp.qr_code}`),{data:u,error:null})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;if(o)return{data:null,error:o};let{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+s.expires_in},s)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",s),{data:s,error:a})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;return o?{data:null,error:o}:await(0,ae._request)(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){let{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){let{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};let n=e?.factors||[],i=n.filter(s=>s.factor_type==="totp"&&s.status==="verified"),o=n.filter(s=>s.factor_type==="phone"&&s.status==="verified");return{data:{all:n,totp:i,phone:o},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;let{data:{session:i},error:o}=e;if(o)return{data:null,error:o};if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let s=this._decodeJWT(i.access_token),a=null;s.aal&&(a=s.aal);let u=a;((n=(r=i.user.factors)===null||r===void 0?void 0:r.filter(f=>f.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(u="aal2");let l=s.amr||[];return{data:{currentLevel:a,nextLevel:u,currentAuthenticationMethods:l},error:null}}))}};ou.default=Pl;Pl.nextInstanceID=0});var $_=D(su=>{"use strict";var o4=su&&su.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(su,"__esModule",{value:!0});var s4=o4(Ol()),a4=s4.default;su.default=a4});var I_=D(au=>{"use strict";var u4=au&&au.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(au,"__esModule",{value:!0});var c4=u4(Jm()),l4=c4.default;au.default=l4});var N_=D(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0})});var Zm=D(Ie=>{"use strict";var f4=Ie&&Ie.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),L_=Ie&&Ie.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&f4(e,t,r)},Rl=Ie&&Ie.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.lockInternals=Ie.NavigatorLockAcquireTimeoutError=Ie.navigatorLock=Ie.AuthClient=Ie.AuthAdminApi=Ie.GoTrueClient=Ie.GoTrueAdminApi=void 0;var d4=Rl(Ol());Ie.GoTrueAdminApi=d4.default;var h4=Rl(Jm());Ie.GoTrueClient=h4.default;var p4=Rl($_());Ie.AuthAdminApi=p4.default;var m4=Rl(I_());Ie.AuthClient=m4.default;L_(N_(),Ie);L_(tu(),Ie);var Xm=Km();Object.defineProperty(Ie,"navigatorLock",{enumerable:!0,get:function(){return Xm.navigatorLock}});Object.defineProperty(Ie,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return Xm.NavigatorLockAcquireTimeoutError}});Object.defineProperty(Ie,"lockInternals",{enumerable:!0,get:function(){return Xm.internals}})});var B_=D($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.SupabaseAuthClient=void 0;var g4=Zm(),Qm=class extends g4.AuthClient{constructor(e){super(e)}};$l.SupabaseAuthClient=Qm});var tg=D(uu=>{"use strict";var y4=uu&&uu.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(uu,"__esModule",{value:!0});var D4=lm(),v4=s_(),b4=(Cm(),ke(Em)),w4=v_(),Il=w_(),_4=E_(),q_=C_(),E4=B_(),eg=class{constructor(e,r,n){var i,o,s;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");let a=(0,q_.stripTrailingSlash)(e);this.realtimeUrl=`${a}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${a}/auth/v1`,this.storageUrl=`${a}/storage/v1`,this.functionsUrl=`${a}/functions/v1`;let u=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,c={db:Il.DEFAULT_DB_OPTIONS,realtime:Il.DEFAULT_REALTIME_OPTIONS,auth:Object.assign(Object.assign({},Il.DEFAULT_AUTH_OPTIONS),{storageKey:u}),global:Il.DEFAULT_GLOBAL_OPTIONS},l=(0,q_.applySettingDefaults)(n??{},c);this.storageKey=(i=l.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(o=l.global.headers)!==null&&o!==void 0?o:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(f,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((s=l.auth)!==null&&s!==void 0?s:{},this.headers,l.global.fetch),this.fetch=(0,_4.fetchWithAuth)(r,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},l.realtime)),this.rest=new v4.PostgrestClient(`${a}/rest/v1`,{headers:this.headers,schema:l.db.schema,fetch:this.fetch}),l.accessToken||this._listenForAuthEvents()}get functions(){return new D4.FunctionsClient(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new w4.StorageClient(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return y4(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:i,storageKey:o,flowType:s,lock:a,debug:u},c,l){var f;let h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new E4.SupabaseAuthClient({url:this.authUrl,headers:Object.assign(Object.assign({},h),c),storageKey:o,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:i,flowType:s,lock:a,debug:u,fetch:l,hasCustomAuthorizationHeader:(f="Authorization"in this.headers)!==null&&f!==void 0?f:!1})}_initRealtimeClient(e){return new b4.RealtimeClient(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n?.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.realtime.setAuth(n??null),this.changedAccessToken=n):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};uu.default=eg});var H_=D(je=>{"use strict";var C4=je&&je.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),M_=je&&je.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&C4(e,t,r)},U_=je&&je.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(je,"__esModule",{value:!0});je.createClient=je.SupabaseClient=je.FunctionRegion=je.FunctionsError=je.FunctionsRelayError=je.FunctionsFetchError=je.FunctionsHttpError=void 0;var S4=U_(tg());M_(Zm(),je);var cu=lm();Object.defineProperty(je,"FunctionsHttpError",{enumerable:!0,get:function(){return cu.FunctionsHttpError}});Object.defineProperty(je,"FunctionsFetchError",{enumerable:!0,get:function(){return cu.FunctionsFetchError}});Object.defineProperty(je,"FunctionsRelayError",{enumerable:!0,get:function(){return cu.FunctionsRelayError}});Object.defineProperty(je,"FunctionsError",{enumerable:!0,get:function(){return cu.FunctionsError}});Object.defineProperty(je,"FunctionRegion",{enumerable:!0,get:function(){return cu.FunctionRegion}});M_((Cm(),ke(Em)),je);var x4=tg();Object.defineProperty(je,"SupabaseClient",{enumerable:!0,get:function(){return U_(x4).default}});var F4=(t,e,r)=>new S4.default(t,e,r);je.createClient=F4});var rg=D((Nle,V_)=>{V_.exports=require("stream")});var J_=D((Lle,Y_)=>{"use strict";function z_(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function G_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?z_(Object(r),!0).forEach(function(n){O4(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):z_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function O4(t,e,r){return e=K_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function A4(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function W_(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,K_(n.key),n)}}function k4(t,e,r){return e&&W_(t.prototype,e),r&&W_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function K_(t){var e=T4(t,"string");return typeof e=="symbol"?e:String(e)}function T4(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var P4=require("buffer"),jl=P4.Buffer,R4=require("util"),ng=R4.inspect,$4=ng&&ng.custom||"inspect";function I4(t,e,r){jl.prototype.copy.call(t,e,r)}Y_.exports=function(){function t(){A4(this,t),this.head=null,this.tail=null,this.length=0}return k4(t,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return jl.alloc(0);for(var n=jl.allocUnsafe(r>>>0),i=this.head,o=0;i;)I4(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=jl.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:$4,value:function(r,n){return ng(this,G_(G_({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var og=D((Ble,Z_)=>{"use strict";function j4(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(ig,this,t)):process.nextTick(ig,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?process.nextTick(Nl,r):(r._writableState.errorEmitted=!0,process.nextTick(X_,r,o)):process.nextTick(X_,r,o):e?(process.nextTick(Nl,r),e(o)):process.nextTick(Nl,r)}),this)}function X_(t,e){ig(t,e),Nl(t)}function Nl(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function N4(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function ig(t,e){t.emit("error",e)}function L4(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}Z_.exports={destroy:j4,undestroy:N4,errorOrDestroy:L4}});var Yn=D((qle,tE)=>{"use strict";var eE={};function gr(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}class i extends r{constructor(s,a,u){super(n(s,a,u))}}i.prototype.name=r.name,i.prototype.code=t,eE[t]=i}function Q_(t,e){if(Array.isArray(t)){let r=t.length;return t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}else return`of ${e} ${String(t)}`}function B4(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function q4(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function M4(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}gr("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);gr("ERR_INVALID_ARG_TYPE",function(t,e,r){let n;typeof e=="string"&&B4(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";let i;if(q4(t," argument"))i=`The ${t} ${n} ${Q_(e,"type")}`;else{let o=M4(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${Q_(e,"type")}`}return i+=`. Received type ${typeof r}`,i},TypeError);gr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");gr("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});gr("ERR_STREAM_PREMATURE_CLOSE","Premature close");gr("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});gr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");gr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");gr("ERR_STREAM_WRITE_AFTER_END","write after end");gr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);gr("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);gr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");tE.exports.codes=eE});var sg=D((Mle,rE)=>{"use strict";var U4=Yn().codes.ERR_INVALID_OPT_VALUE;function H4(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function V4(t,e,r,n){var i=H4(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new U4(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}rE.exports={getHighWaterMark:V4}});var nE=D((Ule,ag)=>{typeof Object.create=="function"?ag.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ag.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Xo=D((Hle,cg)=>{try{if(ug=require("util"),typeof ug.inherits!="function")throw"";cg.exports=ug.inherits}catch{cg.exports=nE()}var ug});var oE=D((Vle,iE)=>{iE.exports=require("util").deprecate});var dg=D((zle,fE)=>{"use strict";fE.exports=Ye;function aE(t){var e=this;this.next=null,this.entry=null,this.finish=function(){y5(e,t)}}var Zo;Ye.WritableState=fu;var z4={deprecate:oE()},uE=rg(),Bl=require("buffer").Buffer,G4=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function W4(t){return Bl.from(t)}function K4(t){return Bl.isBuffer(t)||t instanceof G4}var fg=og(),Y4=sg(),J4=Y4.getHighWaterMark,Jn=Yn().codes,X4=Jn.ERR_INVALID_ARG_TYPE,Z4=Jn.ERR_METHOD_NOT_IMPLEMENTED,Q4=Jn.ERR_MULTIPLE_CALLBACK,e5=Jn.ERR_STREAM_CANNOT_PIPE,t5=Jn.ERR_STREAM_DESTROYED,r5=Jn.ERR_STREAM_NULL_VALUES,n5=Jn.ERR_STREAM_WRITE_AFTER_END,i5=Jn.ERR_UNKNOWN_ENCODING,Qo=fg.errorOrDestroy;Xo()(Ye,uE);function o5(){}function fu(t,e,r){Zo=Zo||ki(),t=t||{},typeof r!="boolean"&&(r=e instanceof Zo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=J4(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){d5(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new aE(this)}fu.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(fu.prototype,"buffer",{get:z4.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Ll;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Ll=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ye,Symbol.hasInstance,{value:function(e){return Ll.call(this,e)?!0:this!==Ye?!1:e&&e._writableState instanceof fu}})):Ll=function(e){return e instanceof this};function Ye(t){Zo=Zo||ki();var e=this instanceof Zo;if(!e&&!Ll.call(Ye,this))return new Ye(t);this._writableState=new fu(t,this,e),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),uE.call(this)}Ye.prototype.pipe=function(){Qo(this,new e5)};function s5(t,e){var r=new n5;Qo(t,r),process.nextTick(e,r)}function a5(t,e,r,n){var i;return r===null?i=new r5:typeof r!="string"&&!e.objectMode&&(i=new X4("chunk",["string","Buffer"],r)),i?(Qo(t,i),process.nextTick(n,i),!1):!0}Ye.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&K4(t);return o&&!Bl.isBuffer(t)&&(t=W4(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=o5),n.ending?s5(this,r):(o||a5(this,n,t,r))&&(n.pendingcb++,i=c5(this,n,o,t,e,r)),i};Ye.prototype.cork=function(){this._writableState.corked++};Ye.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&cE(this,t))};Ye.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new i5(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(Ye.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function u5(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=Bl.from(e,r)),e}Object.defineProperty(Ye.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function c5(t,e,r,n,i,o){if(!r){var s=u5(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else lg(t,e,!1,a,n,i,o);return u}function lg(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new t5("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function l5(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(lu,t,e),t._writableState.errorEmitted=!0,Qo(t,n)):(i(n),t._writableState.errorEmitted=!0,Qo(t,n),lu(t,e))}function f5(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function d5(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new Q4;if(f5(r),e)l5(t,r,n,e,i);else{var o=lE(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&cE(t,r),n?process.nextTick(sE,t,r,o,i):sE(t,r,o,i)}}function sE(t,e,r,n){r||h5(t,e),e.pendingcb--,n(),lu(t,e)}function h5(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function cE(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,lg(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new aE(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,c=r.encoding,l=r.callback,f=e.objectMode?1:u.length;if(lg(t,e,!1,f,u,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}Ye.prototype._write=function(t,e,r){r(new Z4("_write()"))};Ye.prototype._writev=null;Ye.prototype.end=function(t,e,r){var n=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||g5(this,n,r),this};Object.defineProperty(Ye.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function lE(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function p5(t,e){t._final(function(r){e.pendingcb--,r&&Qo(t,r),e.prefinished=!0,t.emit("prefinish"),lu(t,e)})}function m5(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(p5,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function lu(t,e){var r=lE(e);if(r&&(m5(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}function g5(t,e,r){e.ending=!0,lu(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}function y5(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}Object.defineProperty(Ye.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Ye.prototype.destroy=fg.destroy;Ye.prototype._undestroy=fg.undestroy;Ye.prototype._destroy=function(t,e){e(t)}});var ki=D((Gle,hE)=>{"use strict";var D5=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};hE.exports=Ur;var dE=mg(),pg=dg();Xo()(Ur,dE);for(hg=D5(pg.prototype),ql=0;ql<hg.length;ql++)Ml=hg[ql],Ur.prototype[Ml]||(Ur.prototype[Ml]=pg.prototype[Ml]);var hg,Ml,ql;function Ur(t){if(!(this instanceof Ur))return new Ur(t);dE.call(this,t),pg.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",v5)))}Object.defineProperty(Ur.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Ur.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Ur.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function v5(){this._writableState.ended||process.nextTick(b5,this)}function b5(t){t.end()}Object.defineProperty(Ur.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})});var gE=D((gg,mE)=>{var Ul=require("buffer"),Hr=Ul.Buffer;function pE(t,e){for(var r in t)e[r]=t[r]}Hr.from&&Hr.alloc&&Hr.allocUnsafe&&Hr.allocUnsafeSlow?mE.exports=Ul:(pE(Ul,gg),gg.Buffer=Ti);function Ti(t,e,r){return Hr(t,e,r)}Ti.prototype=Object.create(Hr.prototype);pE(Hr,Ti);Ti.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Hr(t,e,r)};Ti.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Hr(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Ti.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Hr(t)};Ti.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ul.SlowBuffer(t)}});var vg=D(DE=>{"use strict";var Dg=gE().Buffer,yE=Dg.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function w5(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function _5(t){var e=w5(t);if(typeof e!="string"&&(Dg.isEncoding===yE||!yE(t)))throw new Error("Unknown encoding: "+t);return e||t}DE.StringDecoder=du;function du(t){this.encoding=_5(t);var e;switch(this.encoding){case"utf16le":this.text=O5,this.end=A5,e=4;break;case"utf8":this.fillLast=S5,e=4;break;case"base64":this.text=k5,this.end=T5,e=3;break;default:this.write=P5,this.end=R5;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Dg.allocUnsafe(e)}du.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};du.prototype.end=F5;du.prototype.text=x5;du.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function yg(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function E5(t,e,r){var n=e.length-1;if(n<r)return 0;var i=yg(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=yg(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=yg(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function C5(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function S5(t){var e=this.lastTotal-this.lastNeed,r=C5(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function x5(t,e){var r=E5(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function F5(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function O5(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function A5(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function k5(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function T5(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function P5(t){return t.toString(this.encoding)}function R5(t){return t&&t.length?this.write(t):""}});var Hl=D((Kle,wE)=>{"use strict";var vE=Yn().codes.ERR_STREAM_PREMATURE_CLOSE;function $5(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}function I5(){}function j5(t){return t.setHeader&&typeof t.abort=="function"}function bE(t,e,r){if(typeof e=="function")return bE(t,null,e);e||(e={}),r=$5(r||I5);var n=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,o=function(){t.writable||a()},s=t._writableState&&t._writableState.finished,a=function(){i=!1,s=!0,n||r.call(t)},u=t._readableState&&t._readableState.endEmitted,c=function(){n=!1,u=!0,i||r.call(t)},l=function(p){r.call(t,p)},f=function(){var p;if(n&&!u)return(!t._readableState||!t._readableState.ended)&&(p=new vE),r.call(t,p);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(p=new vE),r.call(t,p)},h=function(){t.req.on("finish",a)};return j5(t)?(t.on("complete",a),t.on("abort",f),t.req?h():t.on("request",h)):i&&!t._writableState&&(t.on("end",o),t.on("close",o)),t.on("end",c),t.on("finish",a),e.error!==!1&&t.on("error",l),t.on("close",f),function(){t.removeListener("complete",a),t.removeListener("abort",f),t.removeListener("request",h),t.req&&t.req.removeListener("finish",a),t.removeListener("end",o),t.removeListener("close",o),t.removeListener("finish",a),t.removeListener("end",c),t.removeListener("error",l),t.removeListener("close",f)}}wE.exports=bE});var EE=D((Yle,_E)=>{"use strict";var Vl;function Xn(t,e,r){return e=N5(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function N5(t){var e=L5(t,"string");return typeof e=="symbol"?e:String(e)}function L5(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var B5=Hl(),Zn=Symbol("lastResolve"),Pi=Symbol("lastReject"),hu=Symbol("error"),zl=Symbol("ended"),Ri=Symbol("lastPromise"),bg=Symbol("handlePromise"),$i=Symbol("stream");function Qn(t,e){return{value:t,done:e}}function q5(t){var e=t[Zn];if(e!==null){var r=t[$i].read();r!==null&&(t[Ri]=null,t[Zn]=null,t[Pi]=null,e(Qn(r,!1)))}}function M5(t){process.nextTick(q5,t)}function U5(t,e){return function(r,n){t.then(function(){if(e[zl]){r(Qn(void 0,!0));return}e[bg](r,n)},n)}}var H5=Object.getPrototypeOf(function(){}),V5=Object.setPrototypeOf((Vl={get stream(){return this[$i]},next:function(){var e=this,r=this[hu];if(r!==null)return Promise.reject(r);if(this[zl])return Promise.resolve(Qn(void 0,!0));if(this[$i].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[hu]?a(e[hu]):s(Qn(void 0,!0))})});var n=this[Ri],i;if(n)i=new Promise(U5(n,this));else{var o=this[$i].read();if(o!==null)return Promise.resolve(Qn(o,!1));i=new Promise(this[bg])}return this[Ri]=i,i}},Xn(Vl,Symbol.asyncIterator,function(){return this}),Xn(Vl,"return",function(){var e=this;return new Promise(function(r,n){e[$i].destroy(null,function(i){if(i){n(i);return}r(Qn(void 0,!0))})})}),Vl),H5),z5=function(e){var r,n=Object.create(V5,(r={},Xn(r,$i,{value:e,writable:!0}),Xn(r,Zn,{value:null,writable:!0}),Xn(r,Pi,{value:null,writable:!0}),Xn(r,hu,{value:null,writable:!0}),Xn(r,zl,{value:e._readableState.endEmitted,writable:!0}),Xn(r,bg,{value:function(o,s){var a=n[$i].read();a?(n[Ri]=null,n[Zn]=null,n[Pi]=null,o(Qn(a,!1))):(n[Zn]=o,n[Pi]=s)},writable:!0}),r));return n[Ri]=null,B5(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Pi];o!==null&&(n[Ri]=null,n[Zn]=null,n[Pi]=null,o(i)),n[hu]=i;return}var s=n[Zn];s!==null&&(n[Ri]=null,n[Zn]=null,n[Pi]=null,s(Qn(void 0,!0))),n[zl]=!0}),e.on("readable",M5.bind(null,n)),n};_E.exports=z5});var FE=D((Jle,xE)=>{"use strict";function CE(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function G5(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(u){CE(o,n,i,s,a,"next",u)}function a(u){CE(o,n,i,s,a,"throw",u)}s(void 0)})}}function SE(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function W5(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?SE(Object(r),!0).forEach(function(n){K5(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):SE(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function K5(t,e,r){return e=Y5(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Y5(t){var e=J5(t,"string");return typeof e=="symbol"?e:String(e)}function J5(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var X5=Yn().codes.ERR_INVALID_ARG_TYPE;function Z5(t,e,r){var n;if(e&&typeof e.next=="function")n=e;else if(e&&e[Symbol.asyncIterator])n=e[Symbol.asyncIterator]();else if(e&&e[Symbol.iterator])n=e[Symbol.iterator]();else throw new X5("iterable",["Iterable"],e);var i=new t(W5({objectMode:!0},r)),o=!1;i._read=function(){o||(o=!0,s())};function s(){return a.apply(this,arguments)}function a(){return a=G5(function*(){try{var u=yield n.next(),c=u.value,l=u.done;l?i.push(null):i.push(yield c)?s():o=!1}catch(f){i.destroy(f)}}),a.apply(this,arguments)}return i}xE.exports=Z5});var mg=D((Zle,NE)=>{"use strict";NE.exports=ye;var es;ye.ReadableState=TE;var Xle=require("events").EventEmitter,kE=function(e,r){return e.listeners(r).length},mu=rg(),Gl=require("buffer").Buffer,Q5=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function eU(t){return Gl.from(t)}function tU(t){return Gl.isBuffer(t)||t instanceof Q5}var wg=require("util"),ue;wg&&wg.debuglog?ue=wg.debuglog("stream"):ue=function(){};var rU=J_(),Og=og(),nU=sg(),iU=nU.getHighWaterMark,Wl=Yn().codes,oU=Wl.ERR_INVALID_ARG_TYPE,sU=Wl.ERR_STREAM_PUSH_AFTER_EOF,aU=Wl.ERR_METHOD_NOT_IMPLEMENTED,uU=Wl.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,ts,_g,Eg;Xo()(ye,mu);var pu=Og.errorOrDestroy,Cg=["error","close","destroy","pause","resume"];function cU(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function TE(t,e,r){es=es||ki(),t=t||{},typeof r!="boolean"&&(r=e instanceof es),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=iU(this,t,"readableHighWaterMark",r),this.buffer=new rU,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(ts||(ts=vg().StringDecoder),this.decoder=new ts(t.encoding),this.encoding=t.encoding)}function ye(t){if(es=es||ki(),!(this instanceof ye))return new ye(t);var e=this instanceof es;this._readableState=new TE(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),mu.call(this)}Object.defineProperty(ye.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});ye.prototype.destroy=Og.destroy;ye.prototype._undestroy=Og.undestroy;ye.prototype._destroy=function(t,e){e(t)};ye.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=Gl.from(t,e),e=""),n=!0),PE(this,t,e,!1,n)};ye.prototype.unshift=function(t){return PE(this,t,null,!0,!1)};function PE(t,e,r,n,i){ue("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,dU(t,o);else{var s;if(i||(s=lU(o,e)),s)pu(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==Gl.prototype&&(e=eU(e)),n)o.endEmitted?pu(t,new uU):Sg(t,o,e,!0);else if(o.ended)pu(t,new sU);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?Sg(t,o,e,!1):Fg(t,o)):Sg(t,o,e,!1)}else n||(o.reading=!1,Fg(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Sg(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&Kl(t)),Fg(t,e)}function lU(t,e){var r;return!tU(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new oU("chunk",["string","Buffer","Uint8Array"],e)),r}ye.prototype.isPaused=function(){return this._readableState.flowing===!1};ye.prototype.setEncoding=function(t){ts||(ts=vg().StringDecoder);var e=new ts(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var OE=1073741824;function fU(t){return t>=OE?t=OE:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function AE(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=fU(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}ye.prototype.read=function(t){ue("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return ue("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?xg(this):Kl(this),null;if(t=AE(t,e),t===0&&e.ended)return e.length===0&&xg(this),null;var n=e.needReadable;ue("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,ue("length less than watermark",n)),e.ended||e.reading?(n=!1,ue("reading or ended",n)):n&&(ue("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=AE(r,e)));var i;return t>0?i=IE(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&xg(this)),i!==null&&this.emit("data",i),i};function dU(t,e){if(ue("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?Kl(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,RE(t)))}}function Kl(t){var e=t._readableState;ue("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(ue("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(RE,t))}function RE(t){var e=t._readableState;ue("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ag(t)}function Fg(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(hU,t,e))}function hU(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(ue("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}ye.prototype._read=function(t){pu(this,new aU("_read()"))};ye.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t);break}n.pipesCount+=1,ue("pipe count=%d opts=%j",n.pipesCount,e);var i=(!e||e.end!==!1)&&t!==process.stdout&&t!==process.stderr,o=i?a:b;n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(g,w){ue("onunpipe"),g===r&&w&&w.hasUnpiped===!1&&(w.hasUnpiped=!0,l())}function a(){ue("onend"),t.end()}var u=pU(r);t.on("drain",u);var c=!1;function l(){ue("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",h),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",b),r.removeListener("data",f),c=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}r.on("data",f);function f(g){ue("ondata");var w=t.write(g);ue("dest.write",w),w===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&jE(n.pipes,t)!==-1)&&!c&&(ue("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(g){ue("onerror",g),b(),t.removeListener("error",h),kE(t,"error")===0&&pu(t,g)}cU(t,"error",h);function d(){t.removeListener("finish",p),b()}t.once("close",d);function p(){ue("onfinish"),t.removeListener("close",d),b()}t.once("finish",p);function b(){ue("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(ue("pipe resume"),r.resume()),t};function pU(t){return function(){var r=t._readableState;ue("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&kE(t,"data")&&(r.flowing=!0,Ag(t))}}ye.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=jE(e.pipes,t);return s===-1?this:(e.pipes.splice(s,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};ye.prototype.on=function(t,e){var r=mu.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,ue("on readable",n.length,n.reading),n.length?Kl(this):n.reading||process.nextTick(mU,this)),r};ye.prototype.addListener=ye.prototype.on;ye.prototype.removeListener=function(t,e){var r=mu.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick($E,this),r};ye.prototype.removeAllListeners=function(t){var e=mu.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick($E,this),e};function $E(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function mU(t){ue("readable nexttick read 0"),t.read(0)}ye.prototype.resume=function(){var t=this._readableState;return t.flowing||(ue("resume"),t.flowing=!t.readableListening,gU(this,t)),t.paused=!1,this};function gU(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(yU,t,e))}function yU(t,e){ue("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ag(t),e.flowing&&!e.reading&&t.read(0)}ye.prototype.pause=function(){return ue("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ue("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ag(t){var e=t._readableState;for(ue("flow",e.flowing);e.flowing&&t.read()!==null;);}ye.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(ue("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(ue("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=function(a){return function(){return t[a].apply(t,arguments)}}(i));for(var o=0;o<Cg.length;o++)t.on(Cg[o],this.emit.bind(this,Cg[o]));return this._read=function(s){ue("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(ye.prototype[Symbol.asyncIterator]=function(){return _g===void 0&&(_g=EE()),_g(this)});Object.defineProperty(ye.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(ye.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(ye.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});ye._fromList=IE;Object.defineProperty(ye.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function IE(t,e){if(e.length===0)return null;var r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function xg(t){var e=t._readableState;ue("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(DU,e,t))}function DU(t,e){if(ue("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(ye.from=function(t,e){return Eg===void 0&&(Eg=FE()),Eg(ye,t,e)});function jE(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}});var kg=D((Qle,BE)=>{"use strict";BE.exports=Dn;var Yl=Yn().codes,vU=Yl.ERR_METHOD_NOT_IMPLEMENTED,bU=Yl.ERR_MULTIPLE_CALLBACK,wU=Yl.ERR_TRANSFORM_ALREADY_TRANSFORMING,_U=Yl.ERR_TRANSFORM_WITH_LENGTH_0,Jl=ki();Xo()(Dn,Jl);function EU(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new bU);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Dn(t){if(!(this instanceof Dn))return new Dn(t);Jl.call(this,t),this._transformState={afterTransform:EU.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",CU)}function CU(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){LE(t,e,r)}):LE(this,null,null)}Dn.prototype.push=function(t,e){return this._transformState.needTransform=!1,Jl.prototype.push.call(this,t,e)};Dn.prototype._transform=function(t,e,r){r(new vU("_transform()"))};Dn.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Dn.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};Dn.prototype._destroy=function(t,e){Jl.prototype._destroy.call(this,t,function(r){e(r)})};function LE(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new _U;if(t._transformState.transforming)throw new wU;return t.push(null)}});var UE=D((efe,ME)=>{"use strict";ME.exports=gu;var qE=kg();Xo()(gu,qE);function gu(t){if(!(this instanceof gu))return new gu(t);qE.call(this,t)}gu.prototype._transform=function(t,e,r){r(null,t)}});var WE=D((tfe,GE)=>{"use strict";var Tg;function SU(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var zE=Yn().codes,xU=zE.ERR_MISSING_ARGS,FU=zE.ERR_STREAM_DESTROYED;function HE(t){if(t)throw t}function OU(t){return t.setHeader&&typeof t.abort=="function"}function AU(t,e,r,n){n=SU(n);var i=!1;t.on("close",function(){i=!0}),Tg===void 0&&(Tg=Hl()),Tg(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,OU(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new FU("pipe"))}}}function VE(t){t()}function kU(t,e){return t.pipe(e)}function TU(t){return!t.length||typeof t[t.length-1]!="function"?HE:t.pop()}function PU(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=TU(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new xU("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,c=a>0;return AU(s,u,c,function(l){i||(i=l),l&&o.forEach(VE),!u&&(o.forEach(VE),n(i))})});return e.reduce(kU)}GE.exports=PU});var KE=D((yr,Du)=>{var yu=require("stream");process.env.READABLE_STREAM==="disable"&&yu?(Du.exports=yu.Readable,Object.assign(Du.exports,yu),Du.exports.Stream=yu):(yr=Du.exports=mg(),yr.Stream=yu||yr,yr.Readable=yr,yr.Writable=dg(),yr.Duplex=ki(),yr.Transform=kg(),yr.PassThrough=UE(),yr.finished=Hl(),yr.pipeline=WE())});var Rg=D(Pg=>{var YE;(function(t){typeof DO_NOT_EXPORT_CRC>"u"?typeof Pg=="object"?t(Pg):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(YE={}):t(YE={})})(function(t){t.version="1.2.2";function e(){for(var F=0,L=new Array(256),x=0;x!=256;++x)F=x,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,L[x]=F;return typeof Int32Array<"u"?new Int32Array(L):L}var r=e();function n(F){var L=0,x=0,I=0,R=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(I=0;I!=256;++I)R[I]=F[I];for(I=0;I!=256;++I)for(x=F[I],L=256+I;L<4096;L+=256)x=R[L]=x>>>8^F[x&255];var B=[];for(I=1;I!=16;++I)B[I-1]=typeof Int32Array<"u"?R.subarray(I*256,I*256+256):R.slice(I*256,I*256+256);return B}var i=n(r),o=i[0],s=i[1],a=i[2],u=i[3],c=i[4],l=i[5],f=i[6],h=i[7],d=i[8],p=i[9],b=i[10],g=i[11],w=i[12],S=i[13],y=i[14];function C(F,L){for(var x=L^-1,I=0,R=F.length;I<R;)x=x>>>8^r[(x^F.charCodeAt(I++))&255];return~x}function k(F,L){for(var x=L^-1,I=F.length-15,R=0;R<I;)x=y[F[R++]^x&255]^S[F[R++]^x>>8&255]^w[F[R++]^x>>16&255]^g[F[R++]^x>>>24]^b[F[R++]]^p[F[R++]]^d[F[R++]]^h[F[R++]]^f[F[R++]]^l[F[R++]]^c[F[R++]]^u[F[R++]]^a[F[R++]]^s[F[R++]]^o[F[R++]]^r[F[R++]];for(I+=15;R<I;)x=x>>>8^r[(x^F[R++])&255];return~x}function $(F,L){for(var x=L^-1,I=0,R=F.length,B=0,q=0;I<R;)B=F.charCodeAt(I++),B<128?x=x>>>8^r[(x^B)&255]:B<2048?(x=x>>>8^r[(x^(192|B>>6&31))&255],x=x>>>8^r[(x^(128|B&63))&255]):B>=55296&&B<57344?(B=(B&1023)+64,q=F.charCodeAt(I++)&1023,x=x>>>8^r[(x^(240|B>>8&7))&255],x=x>>>8^r[(x^(128|B>>2&63))&255],x=x>>>8^r[(x^(128|q>>6&15|(B&3)<<4))&255],x=x>>>8^r[(x^(128|q&63))&255]):(x=x>>>8^r[(x^(224|B>>12&15))&255],x=x>>>8^r[(x^(128|B>>6&63))&255],x=x>>>8^r[(x^(128|B&63))&255]);return~x}t.table=r,t.bstr=C,t.buf=k,t.str=$})});var XE=D((nfe,JE)=>{"use strict";var{Transform:RU}=KE(),$U=Rg(),$g=class extends RU{constructor(e){super(e),this.checksum=Buffer.allocUnsafe(4),this.checksum.writeInt32BE(0,0),this.rawSize=0}_transform(e,r,n){e&&(this.checksum=$U.buf(e,this.checksum)>>>0,this.rawSize+=e.length),n(null,e)}digest(e){let r=Buffer.allocUnsafe(4);return r.writeUInt32BE(this.checksum>>>0,0),e?r.toString(e):r}hex(){return this.digest("hex").toUpperCase()}size(){return this.rawSize}};JE.exports=$g});var QE=D((ife,ZE)=>{"use strict";var{DeflateRaw:IU}=require("zlib"),jU=Rg(),Ig=class extends IU{constructor(e){super(e),this.checksum=Buffer.allocUnsafe(4),this.checksum.writeInt32BE(0,0),this.rawSize=0,this.compressedSize=0}push(e,r){return e&&(this.compressedSize+=e.length),super.push(e,r)}_transform(e,r,n){e&&(this.checksum=jU.buf(e,this.checksum)>>>0,this.rawSize+=e.length),super._transform(e,r,n)}digest(e){let r=Buffer.allocUnsafe(4);return r.writeUInt32BE(this.checksum>>>0,0),e?r.toString(e):r}hex(){return this.digest("hex").toUpperCase()}size(e=!1){return e?this.compressedSize:this.rawSize}};ZE.exports=Ig});var tC=D((ofe,eC)=>{"use strict";eC.exports={CRC32Stream:XE(),DeflateCRC32Stream:QE()}});var vu=D(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.checksum=rs.checksumFile=void 0;var NU=require("fs"),LU=require("crypto"),nC=require("stream"),BU=require("util"),{CRC32Stream:qU}=tC(),rC=(0,BU.promisify)(nC.pipeline),MU=(t,e,r)=>iC(NU.createReadStream(t),e,r);rs.checksumFile=MU;async function iC(t,e,r="hex"){let n=HU(t);if(e==="crc32"){let o=new qU,s=rC(n,o);return o.resume(),await s,o.end(),Buffer.from(o.digest()).toString(r)}let i=(0,LU.createHash)(e);return await rC(n,i),i.end(),i.digest(r)}rs.checksum=iC;function UU(t){return t!=null&&typeof t=="object"&&typeof t.read=="function"&&typeof t.pipe=="function"}var HU=t=>UU(t)?t:new nC.Readable({read(){this.push(t),this.push(null)}})});var jg=D((afe,oC)=>{oC.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Xl=D(aC=>{var sC={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function VU(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,n)=>e[n]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(sC))aC[t]=VU(sC[t])});var dC=D((cfe,fC)=>{var zU=require("fs"),at=require("path"),uC=jg(),GU=Xl(),WU=typeof process=="object"&&process.platform==="win32",cC=t=>typeof t=="object"&&t!==null,lC=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)e&1?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Je(t){this.sep=at.sep,this.fs=zU,cC(t)&&cC(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}fC.exports=Je;Je.prototype.makeDir=function(t){let e=this;function r(n){let i=n.split(e.sep)[0];n.split(e.sep).forEach(function(o){if(!(!o||o.substr(-1,1)===":")){i+=e.sep+o;var s;try{s=e.fs.statSync(i)}catch{e.fs.mkdirSync(i)}if(s&&s.isFile())throw GU.FILE_IN_THE_WAY(`"${i}"`)}})}r(t)};Je.prototype.writeFileTo=function(t,e,r,n){let i=this;if(i.fs.existsSync(t)){if(!r)return!1;var o=i.fs.statSync(t);if(o.isDirectory())return!1}var s=at.dirname(t);i.fs.existsSync(s)||i.makeDir(s);var a;try{a=i.fs.openSync(t,"w",438)}catch{i.fs.chmodSync(t,438),a=i.fs.openSync(t,"w",438)}if(a)try{i.fs.writeSync(a,e,0,e.length,0)}finally{i.fs.closeSync(a)}return i.fs.chmodSync(t,n||438),!0};Je.prototype.writeFileToAsync=function(t,e,r,n,i){typeof n=="function"&&(i=n,n=void 0);let o=this;o.fs.exists(t,function(s){if(s&&!r)return i(!1);o.fs.stat(t,function(a,u){if(s&&u.isDirectory())return i(!1);var c=at.dirname(t);o.fs.exists(c,function(l){l||o.makeDir(c),o.fs.open(t,"w",438,function(f,h){f?o.fs.chmod(t,438,function(){o.fs.open(t,"w",438,function(d,p){o.fs.write(p,e,0,e.length,0,function(){o.fs.close(p,function(){o.fs.chmod(t,n||438,function(){i(!0)})})})})}):h?o.fs.write(h,e,0,e.length,0,function(){o.fs.close(h,function(){o.fs.chmod(t,n||438,function(){i(!0)})})}):o.fs.chmod(t,n||438,function(){i(!0)})})})})})};Je.prototype.findFiles=function(t){let e=this;function r(n,i,o){typeof i=="boolean"&&(o=i,i=void 0);let s=[];return e.fs.readdirSync(n).forEach(function(a){let u=at.join(n,a),c=e.fs.statSync(u);(!i||i.test(u))&&s.push(at.normalize(u)+(c.isDirectory()?e.sep:"")),c.isDirectory()&&o&&(s=s.concat(r(u,i,o)))}),s}return r(t,void 0,!0)};Je.prototype.findFilesAsync=function(t,e){let r=this,n=[];r.fs.readdir(t,function(i,o){if(i)return e(i);let s=o.length;if(!s)return e(null,n);o.forEach(function(a){a=at.join(t,a),r.fs.stat(a,function(u,c){if(u)return e(u);c&&(n.push(at.normalize(a)+(c.isDirectory()?r.sep:"")),c.isDirectory()?r.findFilesAsync(a,function(l,f){if(l)return e(l);n=n.concat(f),--s||e(null,n)}):--s||e(null,n))})})})};Je.prototype.getAttributes=function(){};Je.prototype.setAttributes=function(){};Je.crc32update=function(t,e){return lC[(t^e)&255]^t>>>8};Je.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let n=0;n<e;)r=Je.crc32update(r,t[n++]);return~r>>>0};Je.methodToString=function(t){switch(t){case uC.STORED:return"STORED ("+t+")";case uC.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Je.canonical=function(t){if(!t)return"";let e=at.posix.normalize("/"+t.split("\\").join("/"));return at.join(".",e)};Je.zipnamefix=function(t){if(!t)return"";let e=at.posix.normalize("/"+t.split("\\").join("/"));return at.posix.join(".",e)};Je.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let n=r-1;n>=0;n--)if(e(t[n],n,t))return t[n]};Je.sanitize=function(t,e){t=at.resolve(at.normalize(t));for(var r=e.split("/"),n=0,i=r.length;n<i;n++){var o=at.normalize(at.join(t,r.slice(n,i).join(at.sep)));if(o.indexOf(t)===0)return o}return at.normalize(at.join(t,at.basename(e)))};Je.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Je.readBigUInt64LE=function(t,e){var r=Buffer.from(t.slice(e,e+8));return r.swap64(),parseInt(`0x${r.toString("hex")}`)};Je.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Je.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Je.isWin=WU;Je.crcTable=lC});var pC=D((lfe,hC)=>{var KU=require("path");hC.exports=function(t,{fs:e}){var r=t||"",n=o(),i=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(i=e.statSync(r),n.directory=i.isDirectory(),n.mtime=i.mtime,n.atime=i.atime,n.executable=(73&i.mode)!==0,n.readonly=(128&i.mode)===0,n.hidden=KU.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var gC=D((ffe,mC)=>{mC.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var is=D((dfe,ns)=>{ns.exports=dC();ns.exports.Constants=jg();ns.exports.Errors=Xl();ns.exports.FileAttr=pC();ns.exports.decoder=gC()});var DC=D((hfe,yC)=>{var ei=is(),H=ei.Constants;yC.exports=function(){var t=20,e=10,r=0,n=0,i=0,o=0,s=0,a=0,u=0,c=0,l=0,f=0,h=0,d=0,p=0;t|=ei.isWin?2560:768,r|=H.FLG_EFS;let b={extraLen:0},g=y=>Math.max(0,y)>>>0,w=y=>Math.max(0,y)&65535,S=y=>Math.max(0,y)&255;return i=ei.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&H.FLG_EFS)>0},set flags_efs(y){y?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(y){y?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return n},set method(y){switch(y){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}n=y},get time(){return ei.fromDOS2Date(this.timeval)},set time(y){this.timeval=ei.fromDate2DOS(y)},get timeval(){return i},set timeval(y){i=g(y)},get timeHighByte(){return S(i>>>8)},get crc(){return o},set crc(y){o=g(y)},get compressedSize(){return s},set compressedSize(y){s=g(y)},get size(){return a},set size(y){a=g(y)},get fileNameLength(){return u},set fileNameLength(y){u=y},get extraLength(){return c},set extraLength(y){c=y},get extraLocalLength(){return b.extraLen},set extraLocalLength(y){b.extraLen=y},get commentLength(){return l},set commentLength(y){l=y},get diskNumStart(){return f},set diskNumStart(y){f=g(y)},get inAttr(){return h},set inAttr(y){h=g(y)},get attr(){return d},set attr(y){d=g(y)},get fileAttr(){return(d||0)>>16&4095},get offset(){return p},set offset(y){p=g(y)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+u+c+l},get realDataOffset(){return p+H.LOCHDR+b.fnameLen+b.extraLen},get localHeader(){return b},loadLocalHeaderFromBinary:function(y){var C=y.slice(p,p+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw ei.Errors.INVALID_LOC();b.version=C.readUInt16LE(H.LOCVER),b.flags=C.readUInt16LE(H.LOCFLG),b.method=C.readUInt16LE(H.LOCHOW),b.time=C.readUInt32LE(H.LOCTIM),b.crc=C.readUInt32LE(H.LOCCRC),b.compressedSize=C.readUInt32LE(H.LOCSIZ),b.size=C.readUInt32LE(H.LOCLEN),b.fnameLen=C.readUInt16LE(H.LOCNAM),b.extraLen=C.readUInt16LE(H.LOCEXT);let k=p+H.LOCHDR+b.fnameLen,$=k+b.extraLen;return y.slice(k,$)},loadFromBinary:function(y){if(y.length!==H.CENHDR||y.readUInt32LE(0)!==H.CENSIG)throw ei.Errors.INVALID_CEN();t=y.readUInt16LE(H.CENVEM),e=y.readUInt16LE(H.CENVER),r=y.readUInt16LE(H.CENFLG),n=y.readUInt16LE(H.CENHOW),i=y.readUInt32LE(H.CENTIM),o=y.readUInt32LE(H.CENCRC),s=y.readUInt32LE(H.CENSIZ),a=y.readUInt32LE(H.CENLEN),u=y.readUInt16LE(H.CENNAM),c=y.readUInt16LE(H.CENEXT),l=y.readUInt16LE(H.CENCOM),f=y.readUInt16LE(H.CENDSK),h=y.readUInt16LE(H.CENATT),d=y.readUInt32LE(H.CENATX),p=y.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(H.LOCHDR);return y.writeUInt32LE(H.LOCSIG,0),y.writeUInt16LE(e,H.LOCVER),y.writeUInt16LE(r,H.LOCFLG),y.writeUInt16LE(n,H.LOCHOW),y.writeUInt32LE(i,H.LOCTIM),y.writeUInt32LE(o,H.LOCCRC),y.writeUInt32LE(s,H.LOCSIZ),y.writeUInt32LE(a,H.LOCLEN),y.writeUInt16LE(u,H.LOCNAM),y.writeUInt16LE(b.extraLen,H.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(H.CENHDR+u+c+l);return y.writeUInt32LE(H.CENSIG,0),y.writeUInt16LE(t,H.CENVEM),y.writeUInt16LE(e,H.CENVER),y.writeUInt16LE(r,H.CENFLG),y.writeUInt16LE(n,H.CENHOW),y.writeUInt32LE(i,H.CENTIM),y.writeUInt32LE(o,H.CENCRC),y.writeUInt32LE(s,H.CENSIZ),y.writeUInt32LE(a,H.CENLEN),y.writeUInt16LE(u,H.CENNAM),y.writeUInt16LE(c,H.CENEXT),y.writeUInt16LE(l,H.CENCOM),y.writeUInt16LE(f,H.CENDSK),y.writeUInt16LE(h,H.CENATT),y.writeUInt32LE(d,H.CENATX),y.writeUInt32LE(p,H.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:ei.methodToString(n),time:this.time,crc:"0x"+o.toString(16).toUpperCase(),compressedSize:y(s),size:y(a),fileNameLength:y(u),extraLength:y(c),commentLength:y(l),diskNumStart:f,inAttr:h,attr:d,offset:p,centralHeaderSize:y(H.CENHDR+u+c+l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bC=D((pfe,vC)=>{var os=is(),Me=os.Constants;vC.exports=function(){var t=0,e=0,r=0,n=0,i=0;return{get diskEntries(){return t},set diskEntries(o){t=e=o},get totalEntries(){return e},set totalEntries(o){e=t=o},get size(){return r},set size(o){r=o},get offset(){return n},set offset(o){n=o},get commentLength(){return i},set commentLength(o){i=o},get mainHeaderSize(){return Me.ENDHDR+i},loadFromBinary:function(o){if((o.length!==Me.ENDHDR||o.readUInt32LE(0)!==Me.ENDSIG)&&(o.length<Me.ZIP64HDR||o.readUInt32LE(0)!==Me.ZIP64SIG))throw os.Errors.INVALID_END();o.readUInt32LE(0)===Me.ENDSIG?(t=o.readUInt16LE(Me.ENDSUB),e=o.readUInt16LE(Me.ENDTOT),r=o.readUInt32LE(Me.ENDSIZ),n=o.readUInt32LE(Me.ENDOFF),i=o.readUInt16LE(Me.ENDCOM)):(t=os.readBigUInt64LE(o,Me.ZIP64SUB),e=os.readBigUInt64LE(o,Me.ZIP64TOT),r=os.readBigUInt64LE(o,Me.ZIP64SIZE),n=os.readBigUInt64LE(o,Me.ZIP64OFF),i=0)},toBinary:function(){var o=Buffer.alloc(Me.ENDHDR+i);return o.writeUInt32LE(Me.ENDSIG,0),o.writeUInt32LE(0,4),o.writeUInt16LE(t,Me.ENDSUB),o.writeUInt16LE(e,Me.ENDTOT),o.writeUInt32LE(r,Me.ENDSIZ),o.writeUInt32LE(n,Me.ENDOFF),o.writeUInt16LE(i,Me.ENDCOM),o.fill(" ",Me.ENDHDR),o},toJSON:function(){let o=function(s,a){let u=s.toString(16).toUpperCase();for(;u.length<a;)u="0"+u;return"0x"+u};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:o(n,4),commentLength:i}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Lg=D(Ng=>{Ng.EntryHeader=DC();Ng.MainHeader=bC()});var _C=D((gfe,wC)=>{wC.exports=function(t){var e=require("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(n){var i=e.createDeflateRaw(r),o=[],s=0;i.on("data",function(a){o.push(a),s+=a.length}),i.on("end",function(){var a=Buffer.alloc(s),u=0;a.fill(0);for(var c=0;c<o.length;c++){var l=o[c];l.copy(a,u),u+=l.length}n&&n(a)}),i.end(t)}}}});var CC=D((yfe,EC)=>{var YU=+(process.versions?process.versions.node:"").split(".")[0]||0;EC.exports=function(t,e){var r=require("zlib");let n=YU>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,n)},inflateAsync:function(i){var o=r.createInflateRaw(n),s=[],a=0;o.on("data",function(u){s.push(u),a+=u.length}),o.on("end",function(){var u=Buffer.alloc(a),c=0;u.fill(0);for(var l=0;l<s.length;l++){var f=s[l];f.copy(u,c),c+=f.length}i&&i(u)}),o.end(t)}}}});var AC=D((Dfe,OC)=>{"use strict";var{randomFillSync:SC}=require("crypto"),JU=Xl(),XU=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)e&1?e=e>>>1^3988292384:e>>>=1;return e>>>0}),FC=(t,e)=>Math.imul(t,e)>>>0,xC=(t,e)=>XU[(t^e)&255]^t>>>8,bu=()=>typeof SC=="function"?SC(Buffer.alloc(12)):bu.node();bu.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var Zl={genSalt:bu};function Ql(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}Ql.prototype.updateKeys=function(t){let e=this.keys;return e[0]=xC(e[0],t),e[1]+=e[0]&255,e[1]=FC(e[1],134775813)+1,e[2]=xC(e[2],e[1]>>>24),t};Ql.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return FC(t,t^1)>>8&255};function ZU(t){let e=new Ql(t);return function(r){let n=Buffer.alloc(r.length),i=0;for(let o of r)n[i++]=e.updateKeys(o^e.next());return n}}function QU(t){let e=new Ql(t);return function(r,n,i=0){n||(n=Buffer.alloc(r.length));for(let o of r){let s=e.next();n[i++]=o^s,e.updateKeys(o)}return n}}function e9(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let n=ZU(r),i=n(t.slice(0,12)),o=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(i[11]!==o)throw JU.WRONG_PASSWORD();return n(t.slice(12))}function t9(t){Buffer.isBuffer(t)&&t.length>=12?Zl.genSalt=function(){return t.slice(0,12)}:t==="node"?Zl.genSalt=bu.node:Zl.genSalt=bu}function r9(t,e,r,n=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let i=QU(r),o=Zl.genSalt();o[11]=e.crc>>>24&255,n&&(o[10]=e.crc>>>16&255);let s=Buffer.alloc(t.length+12);return i(o,s),i(t,s,12)}OC.exports={decrypt:e9,encrypt:r9,_salter:t9}});var kC=D(ef=>{ef.Deflater=_C();ef.Inflater=CC();ef.ZipCrypto=AC()});var qg=D((bfe,TC)=>{var be=is(),n9=Lg(),Xe=be.Constants,Bg=kC();TC.exports=function(t,e){var r=new n9.EntryHeader,n=Buffer.alloc(0),i=Buffer.alloc(0),o=!1,s=null,a=Buffer.alloc(0),u=Buffer.alloc(0),c=!0;let l=t,f=typeof l.decoder=="object"?l.decoder:be.decoder;c=f.hasOwnProperty("efs")?f.efs:!1;function h(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(u=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function d(y){if(r.flags_desc){let C={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Xe.LOCSIG||e.readUInt32LE(k)==Xe.CENSIG)throw be.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Xe.EXTSIG)C.crc=e.readUInt32LE(k+Xe.EXTCRC),C.compressedSize=e.readUInt32LE(k+Xe.EXTSIZ),C.size=e.readUInt32LE(k+Xe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)C.crc=e.readUInt32LE(k+Xe.EXTCRC-4),C.compressedSize=e.readUInt32LE(k+Xe.EXTSIZ-4),C.size=e.readUInt32LE(k+Xe.EXTLEN-4);else throw be.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw be.Errors.DESCRIPTOR_FAULTY();if(be.crc32(y)!==C.crc)return!1}else if(be.crc32(y)!==r.localHeader.crc)return!1;return!0}function p(y,C,k){if(typeof C>"u"&&typeof y=="string"&&(k=y,y=void 0),o)return y&&C&&C(Buffer.alloc(0),be.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var $=h();if($.length===0)return y&&C&&C($),$;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw be.Errors.INVALID_PASS_PARAM();$=Bg.ZipCrypto.decrypt($,r,k)}var F=Buffer.alloc(r.size);switch(r.method){case be.Constants.STORED:if($.copy(F),d(F))return y&&C&&C(F),F;throw y&&C&&C(F,be.Errors.BAD_CRC()),be.Errors.BAD_CRC();case be.Constants.DEFLATED:var L=new Bg.Inflater($,r.size);if(y)L.inflateAsync(function(x){x.copy(x,0),C&&(d(x)?C(x):C(x,be.Errors.BAD_CRC()))});else{if(L.inflate(F).copy(F,0),!d(F))throw be.Errors.BAD_CRC(`"${f.decode(n)}"`);return F}break;default:throw y&&C&&C(Buffer.alloc(0),be.Errors.UNKNOWN_METHOD()),be.Errors.UNKNOWN_METHOD()}}function b(y,C){if((!s||!s.length)&&Buffer.isBuffer(e))return y&&C&&C(h()),h();if(s.length&&!o){var k;switch(r.method){case be.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(s.length),s.copy(k),y&&C&&C(k),k;default:case be.Constants.DEFLATED:var $=new Bg.Deflater(s);if(y)$.deflateAsync(function(L){k=Buffer.alloc(L.length),r.compressedSize=L.length,L.copy(k),C&&C(k)});else{var F=$.deflate();return r.compressedSize=F.length,F}$=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function g(y,C){return(y.readUInt32LE(C+4)<<4)+y.readUInt32LE(C)}function w(y){try{for(var C=0,k,$,F;C+4<y.length;)k=y.readUInt16LE(C),C+=2,$=y.readUInt16LE(C),C+=2,F=y.slice(C,C+$),C+=$,Xe.ID_ZIP64===k&&S(F)}catch{throw be.Errors.EXTRA_FIELD_PARSE_ERROR()}}function S(y){var C,k,$,F;y.length>=Xe.EF_ZIP64_SCOMP&&(C=g(y,Xe.EF_ZIP64_SUNCOMP),r.size===Xe.EF_ZIP64_OR_32&&(r.size=C)),y.length>=Xe.EF_ZIP64_RHO&&(k=g(y,Xe.EF_ZIP64_SCOMP),r.compressedSize===Xe.EF_ZIP64_OR_32&&(r.compressedSize=k)),y.length>=Xe.EF_ZIP64_DSN&&($=g(y,Xe.EF_ZIP64_RHO),r.offset===Xe.EF_ZIP64_OR_32&&(r.offset=$)),y.length>=Xe.EF_ZIP64_DSN+4&&(F=y.readUInt32LE(Xe.EF_ZIP64_DSN),r.diskNumStart===Xe.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return f.decode(n)},get rawEntryName(){return n},set entryName(y){n=be.toBuffer(y,f.encode);var C=n[n.length-1];o=C===47||C===92,r.fileNameLength=n.length},get efs(){return typeof c=="function"?c(this.entryName):c},get extra(){return a},set extra(y){a=y,r.extraLength=y.length,w(y)},get comment(){return f.decode(i)},set comment(y){if(i=be.toBuffer(y,f.encode),r.commentLength=i.length,i.length>65535)throw be.Errors.COMMENT_TOO_LONG()},get name(){var y=f.decode(n);return o?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return o},getCompressedData:function(){return b(!1,null)},getCompressedDataAsync:function(y){b(!0,y)},setData:function(y){s=be.toBuffer(y,be.decoder.encode),!o&&s.length?(r.size=s.length,r.method=be.Constants.DEFLATED,r.crc=be.crc32(y),r.changed=!0):r.method=be.Constants.STORED},getData:function(y){return r.changed?s:p(!1,null,y)},getDataAsync:function(y,C){r.changed?y(s):p(!0,y,C)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=a.length;var y=r.centralHeaderToBinary(),C=be.Constants.CENHDR;return n.copy(y,C),C+=n.length,a.copy(y,C),C+=r.extraLength,i.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=u.length;let C=r.localHeaderToBinary(),k=Buffer.alloc(C.length+n.length+r.extraLocalLength);return C.copy(k,y),y+=C.length,n.copy(k,y),y+=n.length,u.copy(k,y),y+=u.length,k},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(s)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var $C=D((wfe,RC)=>{var PC=qg(),i9=Lg(),bt=is();RC.exports=function(t,e){var r=[],n={},i=Buffer.alloc(0),o=new i9.MainHeader,s=!1,a=null;let u=new Set,c=e,{noSort:l,decoder:f}=c;t?p(c.readEntries):s=!0;function h(){let g=new Set;for(let w of Object.keys(n)){let S=w.split("/");if(S.pop(),!!S.length)for(let y=0;y<S.length;y++){let C=S.slice(0,y+1).join("/")+"/";g.add(C)}}for(let w of g)if(!(w in n)){let S=new PC(c);S.entryName=w,S.attr=16,S.temporary=!0,r.push(S),n[S.entryName]=S,u.add(S)}}function d(){if(s=!0,n={},o.diskEntries>(t.length-o.offset)/bt.Constants.CENHDR)throw bt.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(o.diskEntries);for(var g=o.offset,w=0;w<r.length;w++){var S=g,y=new PC(c,t);y.header=t.slice(S,S+=bt.Constants.CENHDR),y.entryName=t.slice(S,S+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(S,S+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(S,S+y.header.commentLength)),g+=y.header.centralHeaderSize,r[w]=y,n[y.entryName]=y}u.clear(),h()}function p(g){var w=t.length-bt.Constants.ENDHDR,S=Math.max(0,w-65535),y=S,C=t.length,k=-1,$=0;for((typeof c.trailingSpace=="boolean"?c.trailingSpace:!1)&&(S=0),w;w>=y;w--)if(t[w]===80){if(t.readUInt32LE(w)===bt.Constants.ENDSIG){k=w,$=w,C=w+bt.Constants.ENDHDR,y=w-bt.Constants.END64HDR;continue}if(t.readUInt32LE(w)===bt.Constants.END64SIG){y=S;continue}if(t.readUInt32LE(w)===bt.Constants.ZIP64SIG){k=w,C=w+bt.readBigUInt64LE(t,w+bt.Constants.ZIP64SIZE)+bt.Constants.ZIP64LEAD;break}}if(k==-1)throw bt.Errors.INVALID_FORMAT();o.loadFromBinary(t.slice(k,C)),o.commentLength&&(i=t.slice($+bt.Constants.ENDHDR)),g&&d()}function b(){r.length>1&&!l&&r.sort((g,w)=>g.entryName.toLowerCase().localeCompare(w.entryName.toLowerCase()))}return{get entries(){return s||d(),r.filter(g=>!u.has(g))},get comment(){return f.decode(i)},set comment(g){i=bt.toBuffer(g,f.encode),o.commentLength=i.length},getEntryCount:function(){return s?r.length:o.diskEntries},forEach:function(g){this.entries.forEach(g)},getEntry:function(g){return s||d(),n[g]||null},setEntry:function(g){s||d(),r.push(g),n[g.entryName]=g,o.totalEntries=r.length},deleteFile:function(g,w=!0){s||d();let S=n[g];this.getEntryChildren(S,w).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(g){s||d();let w=n[g],S=r.indexOf(w);S>=0&&(r.splice(S,1),delete n[g],o.totalEntries=r.length)},getEntryChildren:function(g,w=!0){if(s||d(),typeof g=="object")if(g.isDirectory&&w){let S=[],y=g.entryName;for(let C of r)C.entryName.startsWith(y)&&S.push(C);return S}else return[g];return[]},getChildCount:function(g){if(g&&g.isDirectory){let w=this.getEntryChildren(g);return w.includes(g)?w.length-1:w.length}return 0},compressToBuffer:function(){s||d(),b();let g=[],w=[],S=0,y=0;o.size=0,o.offset=0;let C=0;for(let F of this.entries){let L=F.getCompressedData();F.header.offset=y;let x=F.packLocalHeader(),I=x.length+L.length;y+=I,g.push(x),g.push(L);let R=F.packCentralHeader();w.push(R),o.size+=R.length,S+=I+R.length,C++}S+=o.mainHeaderSize,o.offset=y,o.totalEntries=C,y=0;let k=Buffer.alloc(S);for(let F of g)F.copy(k,y),y+=F.length;for(let F of w)F.copy(k,y),y+=F.length;let $=o.toBinary();return i&&i.copy($,bt.Constants.ENDHDR),$.copy(k,y),t=k,s=!1,k},toAsyncBuffer:function(g,w,S,y){try{s||d(),b();let C=[],k=[],$=0,F=0,L=0;o.size=0,o.offset=0;let x=function(I){if(I.length>0){let R=I.shift(),B=R.entryName+R.extra.toString();S&&S(B),R.getCompressedDataAsync(function(q){y&&y(B),R.header.offset=F;let K=R.packLocalHeader(),M=K.length+q.length;F+=M,C.push(K),C.push(q);let E=R.packCentralHeader();k.push(E),o.size+=E.length,$+=M+E.length,L++,x(I)})}else{$+=o.mainHeaderSize,o.offset=F,o.totalEntries=L,F=0;let R=Buffer.alloc($);C.forEach(function(q){q.copy(R,F),F+=q.length}),k.forEach(function(q){q.copy(R,F),F+=q.length});let B=o.toBinary();i&&i.copy(B,bt.Constants.ENDHDR),B.copy(R,F),t=R,s=!1,g(R)}};x(Array.from(this.entries))}catch(C){w(C)}}}}});var NC=D((_fe,jC)=>{var Ue=is(),Ze=require("path"),o9=qg(),s9=$C(),Ii=(...t)=>Ue.findLast(t,e=>typeof e=="boolean"),IC=(...t)=>Ue.findLast(t,e=>typeof e=="string"),a9=(...t)=>Ue.findLast(t,e=>typeof e=="function"),u9={noSort:!1,readEntries:!1,method:Ue.Constants.NONE,fs:null};jC.exports=function(t,e){let r=null,n=Object.assign(Object.create(null),u9);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(n,t),t=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(t)&&(r=t,n.method=Ue.Constants.BUFFER,t=void 0)),Object.assign(n,e);let i=new Ue(n);if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=Ue.decoder),t&&typeof t=="string")if(i.fs.existsSync(t))n.method=Ue.Constants.FILE,n.filename=t,r=i.fs.readFileSync(t);else throw Ue.Errors.INVALID_FILENAME();let o=new s9(r,n),{canonical:s,sanitize:a,zipnamefix:u}=Ue;function c(d){if(d&&o){var p;if(typeof d=="string"&&(p=o.getEntry(Ze.posix.normalize(d))),typeof d=="object"&&typeof d.entryName<"u"&&typeof d.header<"u"&&(p=o.getEntry(d.entryName)),p)return p}return null}function l(d){let{join:p,normalize:b,sep:g}=Ze.posix;return p(".",b(g+d.split("\\").join(g)+g))}function f(d){return d instanceof RegExp?function(p){return function(b){return p.test(b)}}(d):typeof d!="function"?()=>!0:d}let h=(d,p)=>{let b=p.slice(-1);return b=b===i.sep?i.sep:"",Ze.relative(d,p)+b};return{readFile:function(d,p){var b=c(d);return b&&b.getData(p)||null},childCount:function(d){let p=c(d);if(p)return o.getChildCount(p)},readFileAsync:function(d,p){var b=c(d);b?b.getDataAsync(p):p(null,"getEntry failed for:"+d)},readAsText:function(d,p){var b=c(d);if(b){var g=b.getData();if(g&&g.length)return g.toString(p||"utf8")}return""},readAsTextAsync:function(d,p,b){var g=c(d);g?g.getDataAsync(function(w,S){if(S){p(w,S);return}w&&w.length?p(w.toString(b||"utf8")):p("")}):p("")},deleteFile:function(d,p=!0){var b=c(d);b&&o.deleteFile(b.entryName,p)},deleteEntry:function(d){var p=c(d);p&&o.deleteEntry(p.entryName)},addZipComment:function(d){o.comment=d},getZipComment:function(){return o.comment||""},addZipEntryComment:function(d,p){var b=c(d);b&&(b.comment=p)},getZipEntryComment:function(d){var p=c(d);return p&&p.comment||""},updateFile:function(d,p){var b=c(d);b&&b.setData(p)},addLocalFile:function(d,p,b,g){if(i.fs.existsSync(d)){p=p?l(p):"";let w=Ze.win32.basename(Ze.win32.normalize(d));p+=b||w;let S=i.fs.statSync(d),y=S.isFile()?i.fs.readFileSync(d):Buffer.alloc(0);S.isDirectory()&&(p+=i.sep),this.addFile(p,y,g,S)}else throw Ue.Errors.FILE_NOT_FOUND(d)},addLocalFileAsync:function(d,p){d=typeof d=="object"?d:{localPath:d};let b=Ze.resolve(d.localPath),{comment:g}=d,{zipPath:w,zipName:S}=d,y=this;i.fs.stat(b,function(C,k){if(C)return p(C,!1);w=w?l(w):"";let $=Ze.win32.basename(Ze.win32.normalize(b));if(w+=S||$,k.isFile())i.fs.readFile(b,function(F,L){return F?p(F,!1):(y.addFile(w,L,g,k),setImmediate(p,void 0,!0))});else if(k.isDirectory())return w+=i.sep,y.addFile(w,Buffer.alloc(0),g,k),setImmediate(p,void 0,!0)})},addLocalFolder:function(d,p,b){if(b=f(b),p=p?l(p):"",d=Ze.normalize(d),i.fs.existsSync(d)){let g=i.findFiles(d),w=this;if(g.length)for(let S of g){let y=Ze.join(p,h(d,S));b(y)&&w.addLocalFile(S,Ze.dirname(y))}}else throw Ue.Errors.FILE_NOT_FOUND(d)},addLocalFolderAsync:function(d,p,b,g){g=f(g),b=b?l(b):"",d=Ze.normalize(d);var w=this;i.fs.open(d,"r",function(S){if(S&&S.code==="ENOENT")p(void 0,Ue.Errors.FILE_NOT_FOUND(d));else if(S)p(void 0,S);else{var y=i.findFiles(d),C=-1,k=function(){if(C+=1,C<y.length){var $=y[C],F=h(d,$).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),g(F)?i.fs.stat($,function(L,x){L&&p(void 0,L),x.isFile()?i.fs.readFile($,function(I,R){I?p(void 0,I):(w.addFile(b+F,R,"",x),k())}):(w.addFile(b+F+"/",Buffer.alloc(0),"",x),k())}):process.nextTick(()=>{k()})}else p(!0,void 0)};k()}})},addLocalFolderAsync2:function(d,p){let b=this;d=typeof d=="object"?d:{localPath:d},localPath=Ze.resolve(l(d.localPath));let{zipPath:g,filter:w,namefix:S}=d;w instanceof RegExp?w=function(k){return function($){return k.test($)}}(w):typeof w!="function"&&(w=function(){return!0}),g=g?l(g):"",S=="latin1"&&(S=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof S!="function"&&(S=k=>k);let y=k=>Ze.join(g,S(h(localPath,k))),C=k=>Ze.win32.basename(Ze.win32.normalize(S(k)));i.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?p(void 0,Ue.Errors.FILE_NOT_FOUND(localPath)):k?p(void 0,k):i.findFilesAsync(localPath,function($,F){if($)return p($);F=F.filter(L=>w(y(L))),F.length||p(void 0,!1),setImmediate(F.reverse().reduce(function(L,x){return function(I,R){if(I||R===!1)return setImmediate(L,I,!1);b.addLocalFileAsync({localPath:x,zipPath:Ze.dirname(y(x)),zipName:C(x)},L)}},p))})})},addLocalFolderPromise:function(d,p){return new Promise((b,g)=>{this.addLocalFolderAsync2(Object.assign({localPath:d},p),(w,S)=>{w&&g(w),S&&b(this)})})},addFile:function(d,p,b,g){d=u(d);let w=c(d),S=w!=null;S||(w=new o9(n),w.entryName=d),w.comment=b||"";let y=typeof g=="object"&&g instanceof i.fs.Stats;y&&(w.header.time=g.mtime);var C=w.isDirectory?16:0;let k=w.isDirectory?16384:32768;return y?k|=4095&g.mode:typeof g=="number"?k|=4095&g:k|=w.isDirectory?493:420,C=(C|k<<16)>>>0,w.attr=C,w.setData(p),S||o.setEntry(w),w},getEntries:function(d){return o.password=d,o?o.entries:[]},getEntry:function(d){return c(d)},getEntryCount:function(){return o.getEntryCount()},forEach:function(d){return o.forEach(d)},extractEntryTo:function(d,p,b,g,w,S){g=Ii(!1,g),w=Ii(!1,w),b=Ii(!0,b),S=IC(w,S);var y=c(d);if(!y)throw Ue.Errors.NO_ENTRY();var C=s(y.entryName),k=a(p,S&&!y.isDirectory?S:b?C:Ze.basename(C));if(y.isDirectory){var $=o.getEntryChildren(y);return $.forEach(function(x){if(x.isDirectory)return;var I=x.getData();if(!I)throw Ue.Errors.CANT_EXTRACT_FILE();var R=s(x.entryName),B=a(p,b?R:Ze.basename(R));let q=w?x.header.fileAttr:void 0;i.writeFileTo(B,I,g,q)}),!0}var F=y.getData(o.password);if(!F)throw Ue.Errors.CANT_EXTRACT_FILE();if(i.fs.existsSync(k)&&!g)throw Ue.Errors.CANT_OVERRIDE();let L=w?d.header.fileAttr:void 0;return i.writeFileTo(k,F,g,L),!0},test:function(d){if(!o)return!1;for(var p in o.entries)try{if(p.isDirectory)continue;var b=o.entries[p].getData(d);if(!b)return!1}catch{return!1}return!0},extractAllTo:function(d,p,b,g){if(b=Ii(!1,b),g=IC(b,g),p=Ii(!1,p),!o)throw Ue.Errors.NO_ZIP();o.entries.forEach(function(w){var S=a(d,s(w.entryName));if(w.isDirectory){i.makeDir(S);return}var y=w.getData(g);if(!y)throw Ue.Errors.CANT_EXTRACT_FILE();let C=b?w.header.fileAttr:void 0;i.writeFileTo(S,y,p,C);try{i.fs.utimesSync(S,w.header.time,w.header.time)}catch{throw Ue.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(d,p,b,g){if(g=a9(p,b,g),b=Ii(!1,b),p=Ii(!1,p),!g)return new Promise((k,$)=>{this.extractAllToAsync(d,p,b,function(F){F?$(F):k(this)})});if(!o){g(Ue.Errors.NO_ZIP());return}d=Ze.resolve(d);let w=k=>a(d,Ze.normalize(s(k.entryName))),S=(k,$)=>new Error(k+': "'+$+'"'),y=[],C=[];o.entries.forEach(k=>{k.isDirectory?y.push(k):C.push(k)});for(let k of y){let $=w(k),F=b?k.header.fileAttr:void 0;try{i.makeDir($),F&&i.fs.chmodSync($,F),i.fs.utimesSync($,k.header.time,k.header.time)}catch{g(S("Unable to create folder",$))}}C.reverse().reduce(function(k,$){return function(F){if(F)k(F);else{let L=Ze.normalize(s($.entryName)),x=a(d,L);$.getDataAsync(function(I,R){if(R)k(R);else if(!I)k(Ue.Errors.CANT_EXTRACT_FILE());else{let B=b?$.header.fileAttr:void 0;i.writeFileToAsync(x,I,p,B,function(q){q||k(S("Unable to write file",x)),i.fs.utimes(x,$.header.time,$.header.time,function(K){K?k(S("Unable to set times",x)):k()})})}})}}},g)()},writeZip:function(d,p){if(arguments.length===1&&typeof d=="function"&&(p=d,d=""),!d&&n.filename&&(d=n.filename),!!d){var b=o.compressToBuffer();if(b){var g=i.writeFileTo(d,b,!0);typeof p=="function"&&p(g?null:new Error("failed"),"")}}},writeZipPromise:function(d,p){let{overwrite:b,perm:g}=Object.assign({overwrite:!0},p);return new Promise((w,S)=>{!d&&n.filename&&(d=n.filename),d||S("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=k=>k?w(k):S("ADM-ZIP: Wasn't able to write zip file");i.writeFileToAsync(d,y,b,g,C)},S)})},toBufferPromise:function(){return new Promise((d,p)=>{o.toAsyncBuffer(d,p)})},toBuffer:function(d,p,b,g){return typeof d=="function"?(o.toAsyncBuffer(d,p,b,g),null):o.compressToBuffer()}}}});var ZC=D((Jfe,XC)=>{var JC={};XC.exports=JC;var YC={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(YC).forEach(function(t){var e=YC[t],r=JC[t]=[];r.open="\x1B["+e[0]+"m",r.close="\x1B["+e[1]+"m"})});var eS=D((Xfe,QC)=>{"use strict";QC.exports=function(t,e){e=e||process.argv;var r=e.indexOf("--"),n=/^-{1,2}/.test(t)?"":"--",i=e.indexOf(n+t);return i!==-1&&(r===-1?!0:i<r)}});var rS=D((Zfe,tS)=>{"use strict";var p9=require("os"),Ar=eS(),Tt=process.env,us=void 0;Ar("no-color")||Ar("no-colors")||Ar("color=false")?us=!1:(Ar("color")||Ar("colors")||Ar("color=true")||Ar("color=always"))&&(us=!0);"FORCE_COLOR"in Tt&&(us=Tt.FORCE_COLOR.length===0||parseInt(Tt.FORCE_COLOR,10)!==0);function m9(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function g9(t){if(us===!1)return 0;if(Ar("color=16m")||Ar("color=full")||Ar("color=truecolor"))return 3;if(Ar("color=256"))return 2;if(t&&!t.isTTY&&us!==!0)return 0;var e=us?1:0;if(process.platform==="win32"){var r=p9.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in Tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(i){return i in Tt})||Tt.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in Tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Tt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in Tt){var n=parseInt((Tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Tt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Tt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(Tt.TERM)||"COLORTERM"in Tt?1:(Tt.TERM==="dumb",e)}function Wg(t){var e=g9(t);return m9(e)}tS.exports={supportsColor:Wg,stdout:Wg(process.stdout),stderr:Wg(process.stderr)}});var iS=D((Qfe,nS)=>{nS.exports=function(e,r){var n="";e=e||"Run the trap, drop the bass",e=e.split("");var i={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(o){o=o.toLowerCase();var s=i[o]||[" "],a=Math.floor(Math.random()*s.length);typeof i[o]<"u"?n+=i[o][a]:n+=o}),n}});var sS=D((ede,oS)=>{oS.exports=function(e,r){e=e||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},i=[].concat(n.up,n.down,n.mid);function o(u){var c=Math.floor(Math.random()*u);return c}function s(u){var c=!1;return i.filter(function(l){c=l===u}),c}function a(u,c){var l="",f,h;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",u=u.split("");for(h in u)if(!s(h)){switch(l=l+u[h],f={up:0,down:0,mid:0},c.size){case"mini":f.up=o(8),f.mid=o(2),f.down=o(8);break;case"maxi":f.up=o(16)+3,f.mid=o(4)+1,f.down=o(64)+3;break;default:f.up=o(8)+1,f.mid=o(6)/2,f.down=o(8)+1;break}var d=["up","mid","down"];for(var p in d)for(var b=d[p],g=0;g<=f[b];g++)c[b]&&(l=l+n[b][o(n[b].length)])}return l}return a(e,r)}});var uS=D((tde,aS)=>{aS.exports=function(t){return function(e,r,n){if(e===" ")return e;switch(r%3){case 0:return t.red(e);case 1:return t.white(e);case 2:return t.blue(e)}}}});var lS=D((rde,cS)=>{cS.exports=function(t){return function(e,r,n){return r%2===0?e:t.inverse(e)}}});var dS=D((nde,fS)=>{fS.exports=function(t){var e=["red","yellow","green","blue","magenta"];return function(r,n,i){return r===" "?r:t[e[n++%e.length]](r)}}});var pS=D((ide,hS)=>{hS.exports=function(t){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,i){return r===" "?r:t[e[Math.round(Math.random()*(e.length-2))]](r)}}});var bS=D((sde,vS)=>{var le={};vS.exports=le;le.themes={};var y9=require("util"),ji=le.styles=ZC(),gS=Object.defineProperties,D9=new RegExp(/[\r\n]+/g);le.supportsColor=rS().supportsColor;typeof le.enabled>"u"&&(le.enabled=le.supportsColor()!==!1);le.enable=function(){le.enabled=!0};le.disable=function(){le.enabled=!1};le.stripColors=le.strip=function(t){return(""+t).replace(/\x1B\[\d+m/g,"")};var ode=le.stylize=function(e,r){if(!le.enabled)return e+"";var n=ji[r];return!n&&r in le?le[r](e):n.open+e+n.close},v9=/[|\\{}()[\]^$+*?.]/g,b9=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(v9,"\\$&")};function yS(t){var e=function r(){return _9.apply(r,arguments)};return e._styles=t,e.__proto__=w9,e}var DS=function(){var t={};return ji.grey=ji.gray,Object.keys(ji).forEach(function(e){ji[e].closeRe=new RegExp(b9(ji[e].close),"g"),t[e]={get:function(){return yS(this._styles.concat(e))}}}),t}(),w9=gS(function(){},DS);function _9(){var t=Array.prototype.slice.call(arguments),e=t.map(function(s){return s!=null&&s.constructor===String?s:y9.inspect(s)}).join(" ");if(!le.enabled||!e)return e;for(var r=e.indexOf(`
23
+ `)}),this}_outputHelpIfRequested(e){let r=this._getHelpOption();r&&e.find(i=>r.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function vw(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let r,n="127.0.0.1",i="9229",o;return(o=e.match(/^(--inspect(-brk)?)$/))!==null?r=o[1]:(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=o[1],/^\d+$/.test(o[3])?i=o[3]:n=o[3]):(o=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=o[1],n=o[3],i=o[4]),r&&i!=="0"?`${r}=${n}:${parseInt(i)+1}`:e})}bw.Command=Np});var Sw=D(hr=>{var{Argument:_w}=rl(),{Command:Lp}=ww(),{CommanderError:gB,InvalidArgumentError:Ew}=ja(),{Help:yB}=Ap(),{Option:Cw}=Rp();hr.program=new Lp;hr.createCommand=t=>new Lp(t);hr.createOption=(t,e)=>new Cw(t,e);hr.createArgument=(t,e)=>new _w(t,e);hr.Command=Lp;hr.Option=Cw;hr.Argument=_w;hr.Help=yB;hr.CommanderError=gB;hr.InvalidArgumentError=Ew;hr.InvalidOptionArgumentError=Ew});var Te=D((xce,Fw)=>{"use strict";var Bp="\x1B",Be=`${Bp}[`,vB="\x07",qp={to(t,e){return e?`${Be}${e+1};${t+1}H`:`${Be}${t+1}G`},move(t,e){let r="";return t<0?r+=`${Be}${-t}D`:t>0&&(r+=`${Be}${t}C`),e<0?r+=`${Be}${-e}A`:e>0&&(r+=`${Be}${e}B`),r},up:(t=1)=>`${Be}${t}A`,down:(t=1)=>`${Be}${t}B`,forward:(t=1)=>`${Be}${t}C`,backward:(t=1)=>`${Be}${t}D`,nextLine:(t=1)=>`${Be}E`.repeat(t),prevLine:(t=1)=>`${Be}F`.repeat(t),left:`${Be}G`,hide:`${Be}?25l`,show:`${Be}?25h`,save:`${Bp}7`,restore:`${Bp}8`},bB={up:(t=1)=>`${Be}S`.repeat(t),down:(t=1)=>`${Be}T`.repeat(t)},wB={screen:`${Be}2J`,up:(t=1)=>`${Be}1J`.repeat(t),down:(t=1)=>`${Be}J`.repeat(t),line:`${Be}2K`,lineEnd:`${Be}K`,lineStart:`${Be}1K`,lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?qp.up():"");return t&&(e+=qp.left),e}};Fw.exports={cursor:qp,scroll:bB,erase:wB,beep:vB}});var Up=D((Fce,Mp)=>{var il=process||{},Ow=il.argv||[],nl=il.env||{},_B=!(nl.NO_COLOR||Ow.includes("--no-color"))&&(!!nl.FORCE_COLOR||Ow.includes("--color")||il.platform==="win32"||(il.stdout||{}).isTTY&&nl.TERM!=="dumb"||!!nl.CI),EB=(t,e,r=t)=>n=>{let i=""+n,o=i.indexOf(e,t.length);return~o?t+CB(i,e,r,o)+e:t+i+e},CB=(t,e,r,n)=>{let i="",o=0;do i+=t.substring(o,n)+r,o=n+e.length,n=t.indexOf(e,o);while(~n);return i+t.substring(o)},Aw=(t=_B)=>{let e=t?EB:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Mp.exports=Aw();Mp.exports.createColors=Aw});var pl=D(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.isNXMonorepo=qt.isMonorepo=qt.findPackageRelativePathInMonorepo=qt.findPackagePath=qt.findNXMonorepoRoot=qt.findMonorepoRoot=void 0;var Ba=require("node:fs"),Wn=require("node:path");function hl(t){let e=(0,Wn.join)(t,"package.json"),r=(0,Wn.join)(t,"pnpm-workspace.yaml");if((0,Ba.existsSync)(r)||(0,Ba.existsSync)(e)&&JSON.parse((0,Ba.readFileSync)(e,"utf-8")).workspaces)return t;let n=(0,Wn.dirname)(t);if(n===t)throw new Error("Monorepo root not found");return hl(n)}qt.findMonorepoRoot=hl;function nm(t){let e=(0,Wn.join)(t,"nx.json");if((0,Ba.existsSync)(e))return t;let r=(0,Wn.dirname)(t);if(r===t)throw new Error("Monorepo root not found");return nm(r)}qt.findNXMonorepoRoot=nm;function im(t,e,r){let n=(0,Wn.join)(e,"node_modules",t);if((0,Ba.existsSync)(n))return n;if(e===r)return null;let i=(0,Wn.dirname)(e);return im(t,i,r)}qt.findPackagePath=im;function iq(t,e){let r=hl(e),n=im(t,e,r);return n?(0,Wn.relative)(e,n):null}qt.findPackageRelativePathInMonorepo=iq;function oq(t){try{return hl(t),!0}catch{return!1}}qt.isMonorepo=oq;function sq(t){try{return nm(t),!0}catch{return!1}}qt.isNXMonorepo=sq});var Si={};mn(Si,{default:()=>aq});var aq,xi=ut(()=>{aq={}});var Ww=D(jr=>{"use strict";var uq=jr&&jr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),cq=jr&&jr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),lq=jr&&jr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&uq(e,t,r);return cq(e,t),e};Object.defineProperty(jr,"__esModule",{value:!0});jr.resolveFetch=void 0;var fq=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>lq((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};jr.resolveFetch=fq});var um=D(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.FunctionRegion=ir.FunctionsHttpError=ir.FunctionsRelayError=ir.FunctionsFetchError=ir.FunctionsError=void 0;var Mo=class extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}};ir.FunctionsError=Mo;var om=class extends Mo{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}};ir.FunctionsFetchError=om;var sm=class extends Mo{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}};ir.FunctionsRelayError=sm;var am=class extends Mo{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}};ir.FunctionsHttpError=am;var dq;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(dq=ir.FunctionRegion||(ir.FunctionRegion={}))});var Kw=D(Uo=>{"use strict";var hq=Uo&&Uo.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.FunctionsClient=void 0;var pq=Ww(),gl=um(),cm=class{constructor(e,{headers:r={},customFetch:n,region:i=gl.FunctionRegion.Any}={}){this.url=e,this.headers=r,this.region=i,this.fetch=(0,pq.resolveFetch)(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return hq(this,void 0,void 0,function*(){try{let{headers:i,method:o,body:s}=r,a={},{region:u}=r;u||(u=this.region),u&&u!=="any"&&(a["x-region"]=u);let c;s&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)&&(typeof Blob<"u"&&s instanceof Blob||s instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=s):typeof s=="string"?(a["Content-Type"]="text/plain",c=s):typeof FormData<"u"&&s instanceof FormData?c=s:(a["Content-Type"]="application/json",c=JSON.stringify(s)));let l=yield this.fetch(`${this.url}/${e}`,{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),i),body:c}).catch(p=>{throw new gl.FunctionsFetchError(p)}),f=l.headers.get("x-relay-error");if(f&&f==="true")throw new gl.FunctionsRelayError(l);if(!l.ok)throw new gl.FunctionsHttpError(l);let h=((n=l.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),d;return h==="application/json"?d=yield l.json():h==="application/octet-stream"?d=yield l.blob():h==="text/event-stream"?d=l:h==="multipart/form-data"?d=yield l.formData():d=yield l.text(),{data:d,error:null}}catch(i){return{data:null,error:i}}})}};Uo.FunctionsClient=cm});var lm=D(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.FunctionRegion=Mt.FunctionsRelayError=Mt.FunctionsHttpError=Mt.FunctionsFetchError=Mt.FunctionsError=Mt.FunctionsClient=void 0;var mq=Kw();Object.defineProperty(Mt,"FunctionsClient",{enumerable:!0,get:function(){return mq.FunctionsClient}});var Ma=um();Object.defineProperty(Mt,"FunctionsError",{enumerable:!0,get:function(){return Ma.FunctionsError}});Object.defineProperty(Mt,"FunctionsFetchError",{enumerable:!0,get:function(){return Ma.FunctionsFetchError}});Object.defineProperty(Mt,"FunctionsHttpError",{enumerable:!0,get:function(){return Ma.FunctionsHttpError}});Object.defineProperty(Mt,"FunctionsRelayError",{enumerable:!0,get:function(){return Ma.FunctionsRelayError}});Object.defineProperty(Mt,"FunctionRegion",{enumerable:!0,get:function(){return Ma.FunctionRegion}})});var hm=D(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});var fm=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};dm.default=fm});var mm=D(Ua=>{"use strict";var Yw=Ua&&Ua.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ua,"__esModule",{value:!0});var gq=Yw((xi(),ke(Si))),yq=Yw(hm()),pm=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=gq.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=Object.assign({},this.headers),this.headers[e]=r,this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{var s,a,u;let c=null,l=null,f=null,h=o.status,d=o.statusText;if(o.ok){if(this.method!=="HEAD"){let w=await o.text();w===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?l=w:l=JSON.parse(w))}let b=(s=this.headers.Prefer)===null||s===void 0?void 0:s.match(/count=(exact|planned|estimated)/),g=(a=o.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");b&&g&&g.length>1&&(f=parseInt(g[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(l)&&(l.length>1?(c={code:"PGRST116",details:`Results contain ${l.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},l=null,f=null,h=406,d="Not Acceptable"):l.length===1?l=l[0]:l=null)}else{let b=await o.text();try{c=JSON.parse(b),Array.isArray(c)&&o.status===404&&(l=[],c=null,h=200,d="OK")}catch{o.status===404&&b===""?(h=204,d="No Content"):c={message:b}}if(c&&this.isMaybeSingle&&(!((u=c?.details)===null||u===void 0)&&u.includes("0 rows"))&&(c=null,h=200,d="OK"),c&&this.shouldThrowOnError)throw new yq.default(c)}return{error:c,data:l,count:f,status:h,statusText:d}});return this.shouldThrowOnError||(i=i.catch(o=>{var s,a,u;return{error:{message:`${(s=o?.name)!==null&&s!==void 0?s:"FetchError"}: ${o?.message}`,details:`${(a=o?.stack)!==null&&a!==void 0?a:""}`,hint:"",code:`${(u=o?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(e,r)}};Ua.default=pm});var ym=D(Ha=>{"use strict";var Dq=Ha&&Ha.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ha,"__esModule",{value:!0});var vq=Dq(mm()),gm=class extends vq.default{select(e){let r=!1,n=(e??"*").split("").map(i=>/\s/.test(i)&&!r?"":(i==='"'&&(r=!r),i)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:i,referencedTable:o=i}={}){let s=o?`${o}.order`:"order",a=this.url.searchParams.get(s);return this.url.searchParams.set(s,`${a?`${a},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:i=n}={}){let o=typeof i>"u"?"offset":`${i}.offset`,s=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(o,`${e}`),this.url.searchParams.set(s,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:i=!1,wal:o=!1,format:s="text"}={}){var a;let u=[e?"analyze":null,r?"verbose":null,n?"settings":null,i?"buffers":null,o?"wal":null].filter(Boolean).join("|"),c=(a=this.headers.Accept)!==null&&a!==void 0?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${s}; for="${c}"; options=${u};`,s==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Ha.default=gm});var yl=D(Va=>{"use strict";var bq=Va&&Va.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Va,"__esModule",{value:!0});var wq=bq(ym()),Dm=class extends wq.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){let n=Array.from(new Set(r)).map(i=>typeof i=="string"&&new RegExp("[,()]").test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:i}={}){let o="";i==="plain"?o="pl":i==="phrase"?o="ph":i==="websearch"&&(o="w");let s=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${o}fts${s}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){let i=n?`${n}.or`:"or";return this.url.searchParams.append(i,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};Va.default=Dm});var bm=D(Ga=>{"use strict";var _q=Ga&&Ga.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ga,"__esModule",{value:!0});var za=_q(yl()),vm=class{constructor(e,{headers:r={},schema:n,fetch:i}){this.url=e,this.headers=r,this.schema=n,this.fetch=i}select(e,{head:r=!1,count:n}={}){let i=r?"HEAD":"GET",o=!1,s=(e??"*").split("").map(a=>/\s/.test(a)&&!o?"":(a==='"'&&(o=!o),a)).join("");return this.url.searchParams.set("select",s),n&&(this.headers.Prefer=`count=${n}`),new za.default({method:i,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:r,defaultToNull:n=!0}={}){let i="POST",o=[];if(this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),n||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){let s=e.reduce((a,u)=>a.concat(Object.keys(u)),[]);if(s.length>0){let a=[...new Set(s)].map(u=>`"${u}"`);this.url.searchParams.set("columns",a.join(","))}}return new za.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:i,defaultToNull:o=!0}={}){let s="POST",a=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&a.push(this.headers.Prefer),i&&a.push(`count=${i}`),o||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let u=e.reduce((c,l)=>c.concat(Object.keys(l)),[]);if(u.length>0){let c=[...new Set(u)].map(l=>`"${l}"`);this.url.searchParams.set("columns",c.join(","))}}return new za.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:r}={}){let n="PATCH",i=[];return this.headers.Prefer&&i.push(this.headers.Prefer),r&&i.push(`count=${r}`),this.headers.Prefer=i.join(","),new za.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let r="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new za.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Ga.default=vm});var Jw=D(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.version=void 0;Dl.version="0.0.0-automated"});var Xw=D(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.DEFAULT_HEADERS=void 0;var Eq=Jw();vl.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${Eq.version}`}});var Qw=D(Wa=>{"use strict";var Zw=Wa&&Wa.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Wa,"__esModule",{value:!0});var Cq=Zw(bm()),Sq=Zw(yl()),xq=Xw(),wm=class t{constructor(e,{headers:r={},schema:n,fetch:i}={}){this.url=e,this.headers=Object.assign(Object.assign({},xq.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=i}from(e){let r=new URL(`${this.url}/${e}`);return new Cq.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new t(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:i=!1,count:o}={}){let s,a=new URL(`${this.url}/rpc/${e}`),u;n||i?(s=n?"HEAD":"GET",Object.entries(r).filter(([l,f])=>f!==void 0).map(([l,f])=>[l,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([l,f])=>{a.searchParams.append(l,f)})):(s="POST",u=r);let c=Object.assign({},this.headers);return o&&(c.Prefer=`count=${o}`),new Sq.default({method:s,url:a,headers:c,schema:this.schemaName,body:u,fetch:this.fetch,allowEmpty:!1})}};Wa.default=wm});var s_=D(Dt=>{"use strict";var Ho=Dt&&Dt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.PostgrestError=Dt.PostgrestBuilder=Dt.PostgrestTransformBuilder=Dt.PostgrestFilterBuilder=Dt.PostgrestQueryBuilder=Dt.PostgrestClient=void 0;var e_=Ho(Qw());Dt.PostgrestClient=e_.default;var t_=Ho(bm());Dt.PostgrestQueryBuilder=t_.default;var r_=Ho(yl());Dt.PostgrestFilterBuilder=r_.default;var n_=Ho(ym());Dt.PostgrestTransformBuilder=n_.default;var i_=Ho(mm());Dt.PostgrestBuilder=i_.default;var o_=Ho(hm());Dt.PostgrestError=o_.default;Dt.default={PostgrestClient:e_.default,PostgrestQueryBuilder:t_.default,PostgrestFilterBuilder:r_.default,PostgrestTransformBuilder:n_.default,PostgrestBuilder:i_.default,PostgrestError:o_.default}});var Em={};mn(Em,{RealtimeClient:()=>_m});var _m,Cm=ut(()=>{_m=class{constructor(){}connect(){}disconnect(){}}});var Ya=D(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.StorageUnknownError=Nr.StorageApiError=Nr.isStorageError=Nr.StorageError=void 0;var Ka=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};Nr.StorageError=Ka;function Fq(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}Nr.isStorageError=Fq;var Sm=class extends Ka{constructor(e,r){super(e),this.name="StorageApiError",this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}};Nr.StorageApiError=Sm;var xm=class extends Ka{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}};Nr.StorageUnknownError=xm});var bl=D(ct=>{"use strict";var Oq=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Aq=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a_=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Oq(e,t,r);return Aq(e,t),e},kq=ct&&ct.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(ct,"__esModule",{value:!0});ct.recursiveToCamel=ct.resolveResponse=ct.resolveFetch=void 0;var Tq=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>a_((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};ct.resolveFetch=Tq;var Pq=()=>kq(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>a_((xi(),ke(Si))))).Response:Response});ct.resolveResponse=Pq;var Rq=t=>{if(Array.isArray(t))return t.map(r=>(0,ct.recursiveToCamel)(r));if(typeof t=="function"||t!==Object(t))return t;let e={};return Object.entries(t).forEach(([r,n])=>{let i=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));e[i]=(0,ct.recursiveToCamel)(n)}),e};ct.recursiveToCamel=Rq});var Am=D(Ut=>{"use strict";var Fi=Ut&&Ut.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Ut,"__esModule",{value:!0});Ut.remove=Ut.head=Ut.put=Ut.post=Ut.get=void 0;var Fm=Ya(),$q=bl(),Om=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Iq=(t,e,r)=>Fi(void 0,void 0,void 0,function*(){let n=yield(0,$q.resolveResponse)();t instanceof n&&!r?.noResolveJson?t.json().then(i=>{e(new Fm.StorageApiError(Om(i),t.status||500))}).catch(i=>{e(new Fm.StorageUnknownError(Om(i),i))}):e(new Fm.StorageUnknownError(Om(t),t))}),jq=(t,e,r,n)=>{let i={method:t,headers:e?.headers||{}};return t==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json"},e?.headers),n&&(i.body=JSON.stringify(n)),Object.assign(Object.assign({},i),r))};function Ja(t,e,r,n,i,o){return Fi(this,void 0,void 0,function*(){return new Promise((s,a)=>{t(r,jq(e,n,i,o)).then(u=>{if(!u.ok)throw u;return n?.noResolveJson?u:u.json()}).then(u=>s(u)).catch(u=>Iq(u,a,n))})})}function Nq(t,e,r,n){return Fi(this,void 0,void 0,function*(){return Ja(t,"GET",e,r,n)})}Ut.get=Nq;function Lq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"POST",e,n,i,r)})}Ut.post=Lq;function Bq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"PUT",e,n,i,r)})}Ut.put=Bq;function qq(t,e,r,n){return Fi(this,void 0,void 0,function*(){return Ja(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}Ut.head=qq;function Mq(t,e,r,n,i){return Fi(this,void 0,void 0,function*(){return Ja(t,"DELETE",e,n,i,r)})}Ut.remove=Mq});var l_=D(Xa=>{"use strict";var Ht=Xa&&Xa.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Xa,"__esModule",{value:!0});var Vt=Ya(),Lr=Am(),u_=bl(),Uq={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},c_={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},km=class{constructor(e,r={},n,i){this.url=e,this.headers=r,this.bucketId=n,this.fetch=(0,u_.resolveFetch)(i)}uploadOrUpdate(e,r,n,i){return Ht(this,void 0,void 0,function*(){try{let o,s=Object.assign(Object.assign({},c_),i),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(s.upsert)}),u=s.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",s.cacheControl),u&&o.append("metadata",this.encodeMetadata(u)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",s.cacheControl),u&&o.append("metadata",this.encodeMetadata(u))):(o=n,a["cache-control"]=`max-age=${s.cacheControl}`,a["content-type"]=s.contentType,u&&(a["x-metadata"]=this.toBase64(this.encodeMetadata(u)))),i?.headers&&(a=Object.assign(Object.assign({},a),i.headers));let c=this._removeEmptyFolders(r),l=this._getFinalPath(c),f=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:o,headers:a},s?.duplex?{duplex:s.duplex}:{})),h=yield f.json();return f.ok?{data:{path:c,id:h.Id,fullPath:h.Key},error:null}:{data:null,error:h}}catch(o){if((0,Vt.isStorageError)(o))return{data:null,error:o};throw o}})}upload(e,r,n){return Ht(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,i){return Ht(this,void 0,void 0,function*(){let o=this._removeEmptyFolders(e),s=this._getFinalPath(o),a=new URL(this.url+`/object/upload/sign/${s}`);a.searchParams.set("token",r);try{let u,c=Object.assign({upsert:c_.upsert},i),l=Object.assign(Object.assign({},this.headers),{"x-upsert":String(c.upsert)});typeof Blob<"u"&&n instanceof Blob?(u=new FormData,u.append("cacheControl",c.cacheControl),u.append("",n)):typeof FormData<"u"&&n instanceof FormData?(u=n,u.append("cacheControl",c.cacheControl)):(u=n,l["cache-control"]=`max-age=${c.cacheControl}`,l["content-type"]=c.contentType);let f=yield this.fetch(a.toString(),{method:"PUT",body:u,headers:l}),h=yield f.json();return f.ok?{data:{path:o,fullPath:h.Key},error:null}:{data:null,error:h}}catch(u){if((0,Vt.isStorageError)(u))return{data:null,error:u};throw u}})}createSignedUploadUrl(e,r){return Ht(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),i=Object.assign({},this.headers);r?.upsert&&(i["x-upsert"]="true");let o=yield(0,Lr.post)(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:i}),s=new URL(this.url+o.url),a=s.searchParams.get("token");if(!a)throw new Vt.StorageError("No token returned by API");return{data:{signedUrl:s.toString(),path:e,token:a},error:null}}catch(n){if((0,Vt.isStorageError)(n))return{data:null,error:n};throw n}})}update(e,r,n){return Ht(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return Ht(this,void 0,void 0,function*(){try{return{data:yield(0,Lr.post)(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n?.destinationBucket},{headers:this.headers}),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}copy(e,r,n){return Ht(this,void 0,void 0,function*(){try{return{data:{path:(yield(0,Lr.post)(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n?.destinationBucket},{headers:this.headers})).Key},error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}createSignedUrl(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=this._getFinalPath(e),o=yield(0,Lr.post)(this.fetch,`${this.url}/object/sign/${i}`,Object.assign({expiresIn:r},n?.transform?{transform:n.transform}:{}),{headers:this.headers}),s=n?.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${s}`)},{data:o,error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}createSignedUrls(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=yield(0,Lr.post)(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),o=n?.download?`&download=${n.download===!0?"":n.download}`:"";return{data:i.map(s=>Object.assign(Object.assign({},s),{signedUrl:s.signedURL?encodeURI(`${this.url}${s.signedURL}${o}`):null})),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}download(e,r){return Ht(this,void 0,void 0,function*(){let i=typeof r?.transform<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString(r?.transform||{}),s=o?`?${o}`:"";try{let a=this._getFinalPath(e);return{data:yield(yield(0,Lr.get)(this.fetch,`${this.url}/${i}/${a}${s}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if((0,Vt.isStorageError)(a))return{data:null,error:a};throw a}})}info(e){return Ht(this,void 0,void 0,function*(){let r=this._getFinalPath(e);try{let n=yield(0,Lr.get)(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:(0,u_.recursiveToCamel)(n),error:null}}catch(n){if((0,Vt.isStorageError)(n))return{data:null,error:n};throw n}})}exists(e){return Ht(this,void 0,void 0,function*(){let r=this._getFinalPath(e);try{return yield(0,Lr.head)(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if((0,Vt.isStorageError)(n)&&n instanceof Vt.StorageUnknownError){let i=n.originalError;if([400,404].includes(i?.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){let n=this._getFinalPath(e),i=[],o=r?.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&i.push(o);let a=typeof r?.transform<"u"?"render/image":"object",u=this.transformOptsToQueryString(r?.transform||{});u!==""&&i.push(u);let c=i.join("&");return c!==""&&(c=`?${c}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${c}`)}}}remove(e){return Ht(this,void 0,void 0,function*(){try{return{data:yield(0,Lr.remove)(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if((0,Vt.isStorageError)(r))return{data:null,error:r};throw r}})}list(e,r,n){return Ht(this,void 0,void 0,function*(){try{let i=Object.assign(Object.assign(Object.assign({},Uq),r),{prefix:e||""});return{data:yield(0,Lr.post)(this.fetch,`${this.url}/object/list/${this.bucketId}`,i,{headers:this.headers},n),error:null}}catch(i){if((0,Vt.isStorageError)(i))return{data:null,error:i};throw i}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}};Xa.default=km});var f_=D(wl=>{"use strict";Object.defineProperty(wl,"__esModule",{value:!0});wl.version=void 0;wl.version="2.7.1"});var d_=D(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.DEFAULT_HEADERS=void 0;var Hq=f_();_l.DEFAULT_HEADERS={"X-Client-Info":`storage-js/${Hq.version}`}});var h_=D(Za=>{"use strict";var Vo=Za&&Za.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(Za,"__esModule",{value:!0});var Vq=d_(),zo=Ya(),Go=Am(),zq=bl(),Tm=class{constructor(e,r={},n){this.url=e,this.headers=Object.assign(Object.assign({},Vq.DEFAULT_HEADERS),r),this.fetch=(0,zq.resolveFetch)(n)}listBuckets(){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.get)(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if((0,zo.isStorageError)(e))return{data:null,error:e};throw e}})}getBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.get)(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.post)(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if((0,zo.isStorageError)(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.put)(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if((0,zo.isStorageError)(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.post)(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Vo(this,void 0,void 0,function*(){try{return{data:yield(0,Go.remove)(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if((0,zo.isStorageError)(r))return{data:null,error:r};throw r}})}};Za.default=Tm});var m_=D(Wo=>{"use strict";var p_=Wo&&Wo.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Wo,"__esModule",{value:!0});Wo.StorageClient=void 0;var Gq=p_(l_()),Wq=p_(h_()),Pm=class extends Wq.default{constructor(e,r={},n){super(e,r,n)}from(e){return new Gq.default(this.url,this.headers,e,this.fetch)}};Wo.StorageClient=Pm});var y_=D(g_=>{"use strict";Object.defineProperty(g_,"__esModule",{value:!0})});var v_=D(Br=>{"use strict";var Kq=Br&&Br.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),D_=Br&&Br.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Kq(e,t,r)};Object.defineProperty(Br,"__esModule",{value:!0});Br.StorageClient=void 0;var Yq=m_();Object.defineProperty(Br,"StorageClient",{enumerable:!0,get:function(){return Yq.StorageClient}});D_(y_(),Br);D_(Ya(),Br)});var b_=D(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});El.version=void 0;El.version="2.46.0"});var w_=D(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.DEFAULT_REALTIME_OPTIONS=or.DEFAULT_AUTH_OPTIONS=or.DEFAULT_DB_OPTIONS=or.DEFAULT_GLOBAL_OPTIONS=or.DEFAULT_HEADERS=void 0;var Jq=b_(),Qa="";typeof Deno<"u"?Qa="deno":typeof document<"u"?Qa="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Qa="react-native":Qa="node";or.DEFAULT_HEADERS={"X-Client-Info":`supabase-js-${Qa}/${Jq.version}`};or.DEFAULT_GLOBAL_OPTIONS={headers:or.DEFAULT_HEADERS};or.DEFAULT_DB_OPTIONS={schema:"public"};or.DEFAULT_AUTH_OPTIONS={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"};or.DEFAULT_REALTIME_OPTIONS={}});var E_=D(lt=>{"use strict";var Xq=lt&&lt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Zq=lt&&lt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Qq=lt&&lt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Xq(e,t,r);return Zq(e,t),e},eM=lt&&lt.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(lt,"__esModule",{value:!0});lt.fetchWithAuth=lt.resolveHeadersConstructor=lt.resolveFetch=void 0;var __=Qq((xi(),ke(Si))),tM=t=>{let e;return t?e=t:typeof fetch>"u"?e=__.default:e=fetch,(...r)=>e(...r)};lt.resolveFetch=tM;var rM=()=>typeof Headers>"u"?__.Headers:Headers;lt.resolveHeadersConstructor=rM;var nM=(t,e,r)=>{let n=(0,lt.resolveFetch)(r),i=(0,lt.resolveHeadersConstructor)();return(o,s)=>eM(void 0,void 0,void 0,function*(){var a;let u=(a=yield e())!==null&&a!==void 0?a:t,c=new i(s?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${u}`),n(o,Object.assign(Object.assign({},s),{headers:c}))})};lt.fetchWithAuth=nM});var C_=D(mr=>{"use strict";var iM=mr&&mr.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(mr,"__esModule",{value:!0});mr.applySettingDefaults=mr.isBrowser=mr.stripTrailingSlash=mr.uuid=void 0;function oM(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=Math.random()*16|0,r=t=="x"?e:e&3|8;return r.toString(16)})}mr.uuid=oM;function sM(t){return t.replace(/\/$/,"")}mr.stripTrailingSlash=sM;var aM=()=>typeof window<"u";mr.isBrowser=aM;function uM(t,e){let{db:r,auth:n,realtime:i,global:o}=t,{db:s,auth:a,realtime:u,global:c}=e,l={db:Object.assign(Object.assign({},s),r),auth:Object.assign(Object.assign({},a),n),realtime:Object.assign(Object.assign({},u),i),global:Object.assign(Object.assign({},c),o),accessToken:()=>iM(this,void 0,void 0,function*(){return""})};return t.accessToken?l.accessToken=t.accessToken:delete l.accessToken,l}mr.applySettingDefaults=uM});var Rm=D(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});Cl.version=void 0;Cl.version="2.65.1"});var Sl=D(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.API_VERSIONS=ft.API_VERSION_HEADER_NAME=ft.NETWORK_FAILURE=ft.EXPIRY_MARGIN=ft.DEFAULT_HEADERS=ft.AUDIENCE=ft.STORAGE_KEY=ft.GOTRUE_URL=void 0;var cM=Rm();ft.GOTRUE_URL="http://localhost:9999";ft.STORAGE_KEY="supabase.auth.token";ft.AUDIENCE="";ft.DEFAULT_HEADERS={"X-Client-Info":`gotrue-js/${cM.version}`};ft.EXPIRY_MARGIN=10;ft.NETWORK_FAILURE={MAX_RETRIES:10,RETRY_INTERVAL:2};ft.API_VERSION_HEADER_NAME="X-Supabase-Api-Version";ft.API_VERSIONS={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}}});var Ko=D(te=>{"use strict";var lM=te&&te.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),fM=te&&te.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dM=te&&te.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&lM(e,t,r);return fM(e,t),e};Object.defineProperty(te,"__esModule",{value:!0});te.parseResponseAPIVersion=te.getCodeChallengeAndMethod=te.generatePKCEChallenge=te.generatePKCEVerifier=te.retryable=te.sleep=te.decodeJWTPayload=te.Deferred=te.decodeBase64URL=te.removeItemAsync=te.getItemAsync=te.setItemAsync=te.looksLikeFetchResponse=te.resolveFetch=te.parseParametersFromURL=te.supportsLocalStorage=te.isBrowser=te.uuid=te.expiresAt=void 0;var hM=Sl();function pM(t){return Math.round(Date.now()/1e3)+t}te.expiresAt=pM;function mM(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}te.uuid=mM;var gM=()=>typeof document<"u";te.isBrowser=gM;var Oi={tested:!1,writable:!1},yM=()=>{if(!(0,te.isBrowser)())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Oi.tested)return Oi.writable;let t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Oi.tested=!0,Oi.writable=!0}catch{Oi.tested=!0,Oi.writable=!1}return Oi.writable};te.supportsLocalStorage=yM;function DM(t){let e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((i,o)=>{e[o]=i})}catch{}return r.searchParams.forEach((n,i)=>{e[i]=n}),e}te.parseParametersFromURL=DM;var vM=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>Promise.resolve().then(()=>dM((xi(),ke(Si)))).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};te.resolveFetch=vM;var bM=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function";te.looksLikeFetchResponse=bM;var wM=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))};te.setItemAsync=wM;var _M=async(t,e)=>{let r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}};te.getItemAsync=_M;var EM=async(t,e)=>{await t.removeItem(e)};te.removeItemAsync=EM;function S_(t){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="",n,i,o,s,a,u,c,l=0;for(t=t.replace("-","+").replace("_","/");l<t.length;)s=e.indexOf(t.charAt(l++)),a=e.indexOf(t.charAt(l++)),u=e.indexOf(t.charAt(l++)),c=e.indexOf(t.charAt(l++)),n=s<<2|a>>4,i=(a&15)<<4|u>>2,o=(u&3)<<6|c,r=r+String.fromCharCode(n),u!=64&&i!=0&&(r=r+String.fromCharCode(i)),c!=64&&o!=0&&(r=r+String.fromCharCode(o));return r}te.decodeBase64URL=S_;var xl=class t{constructor(){this.promise=new t.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}};te.Deferred=xl;xl.promiseConstructor=Promise;function CM(t){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,r=t.split(".");if(r.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(r[1]))throw new Error("JWT is not valid: payload is not in base64url format");let n=r[1];return JSON.parse(S_(n))}te.decodeJWTPayload=CM;async function SM(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}te.sleep=SM;function xM(t,e){return new Promise((n,i)=>{(async()=>{for(let o=0;o<1/0;o++)try{let s=await t(o);if(!e(o,null,s)){n(s);return}}catch(s){if(!e(o,s)){i(s);return}}})()})}te.retryable=xM;function FM(t){return("0"+t.toString(16)).substr(-2)}function x_(){let e=new Uint32Array(56);if(typeof crypto>"u"){let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length,i="";for(let o=0;o<56;o++)i+=r.charAt(Math.floor(Math.random()*n));return i}return crypto.getRandomValues(e),Array.from(e,FM).join("")}te.generatePKCEVerifier=x_;async function OM(t){let r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),i=new Uint8Array(n);return Array.from(i).map(o=>String.fromCharCode(o)).join("")}function AM(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function F_(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;let r=await OM(t);return AM(r)}te.generatePKCEChallenge=F_;async function kM(t,e,r=!1){let n=x_(),i=n;r&&(i+="/PASSWORD_RECOVERY"),await(0,te.setItemAsync)(t,`${e}-code-verifier`,i);let o=await F_(n);return[o,n===o?"plain":"s256"]}te.getCodeChallengeAndMethod=kM;var TM=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function PM(t){let e=t.headers.get(hM.API_VERSION_HEADER_NAME);if(!e||!e.match(TM))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}te.parseResponseAPIVersion=PM});var tu=D(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.isAuthWeakPasswordError=he.AuthWeakPasswordError=he.isAuthRetryableFetchError=he.AuthRetryableFetchError=he.AuthPKCEGrantCodeExchangeError=he.AuthImplicitGrantRedirectError=he.AuthInvalidCredentialsError=he.AuthInvalidTokenResponseError=he.isAuthSessionMissingError=he.AuthSessionMissingError=he.CustomAuthError=he.AuthUnknownError=he.isAuthApiError=he.AuthApiError=he.isAuthError=he.AuthError=void 0;var Yo=class extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}};he.AuthError=Yo;function eu(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}he.isAuthError=eu;var $m=class extends Yo{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}};he.AuthApiError=$m;function RM(t){return eu(t)&&t.name==="AuthApiError"}he.isAuthApiError=RM;var Im=class extends Yo{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}};he.AuthUnknownError=Im;var qr=class extends Yo{constructor(e,r,n,i){super(e,n,i),this.name=r,this.status=n}};he.CustomAuthError=qr;var jm=class extends qr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};he.AuthSessionMissingError=jm;function $M(t){return eu(t)&&t.name==="AuthSessionMissingError"}he.isAuthSessionMissingError=$M;var Nm=class extends qr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}};he.AuthInvalidTokenResponseError=Nm;var Lm=class extends qr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}};he.AuthInvalidCredentialsError=Lm;var Bm=class extends qr{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};he.AuthImplicitGrantRedirectError=Bm;var qm=class extends qr{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};he.AuthPKCEGrantCodeExchangeError=qm;var Mm=class extends qr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}};he.AuthRetryableFetchError=Mm;function IM(t){return eu(t)&&t.name==="AuthRetryableFetchError"}he.isAuthRetryableFetchError=IM;var Um=class extends qr{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}};he.AuthWeakPasswordError=Um;function jM(t){return eu(t)&&t.name==="AuthWeakPasswordError"}he.isAuthWeakPasswordError=jM});var zm=D(rt=>{"use strict";var NM=rt&&rt.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(rt,"__esModule",{value:!0});rt._noResolveJsonResponse=rt._generateLinkResponse=rt._ssoResponse=rt._userResponse=rt._sessionResponsePassword=rt._sessionResponse=rt._request=rt.handleError=void 0;var Fl=Sl(),Hm=Ko(),Kn=tu(),Ai=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),LM=[502,503,504];async function Vm(t){var e;if(!(0,Hm.looksLikeFetchResponse)(t))throw new Kn.AuthRetryableFetchError(Ai(t),0);if(LM.includes(t.status))throw new Kn.AuthRetryableFetchError(Ai(t),t.status);let r;try{r=await t.json()}catch(o){throw new Kn.AuthUnknownError(Ai(o),o)}let n,i=(0,Hm.parseResponseAPIVersion)(t);if(i&&i.getTime()>=Fl.API_VERSIONS["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new Kn.AuthWeakPasswordError(Ai(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Kn.AuthSessionMissingError}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,s)=>o&&typeof s=="string",!0))throw new Kn.AuthWeakPasswordError(Ai(r),t.status,r.weak_password.reasons);throw new Kn.AuthApiError(Ai(r),t.status||500,n)}rt.handleError=Vm;var BM=(t,e,r,n)=>{let i={method:t,headers:e?.headers||{}};return t==="GET"?i:(i.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),i.body=JSON.stringify(n),Object.assign(Object.assign({},i),r))};async function qM(t,e,r,n){var i;let o=Object.assign({},n?.headers);o[Fl.API_VERSION_HEADER_NAME]||(o[Fl.API_VERSION_HEADER_NAME]=Fl.API_VERSIONS["2024-01-01"].name),n?.jwt&&(o.Authorization=`Bearer ${n.jwt}`);let s=(i=n?.query)!==null&&i!==void 0?i:{};n?.redirectTo&&(s.redirect_to=n.redirectTo);let a=Object.keys(s).length?"?"+new URLSearchParams(s).toString():"",u=await MM(t,e,r+a,{headers:o,noResolveJson:n?.noResolveJson},{},n?.body);return n?.xform?n?.xform(u):{data:Object.assign({},u),error:null}}rt._request=qM;async function MM(t,e,r,n,i,o){let s=BM(e,n,i,o),a;try{a=await t(r,Object.assign({},s))}catch(u){throw console.error(u),new Kn.AuthRetryableFetchError(Ai(u),0)}if(a.ok||await Vm(a),n?.noResolveJson)return a;try{return await a.json()}catch(u){await Vm(u)}}function O_(t){var e;let r=null;WM(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=(0,Hm.expiresAt)(t.expires_in)));let n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}rt._sessionResponse=O_;function UM(t){let e=O_(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}rt._sessionResponsePassword=UM;function HM(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}rt._userResponse=HM;function VM(t){return{data:t,error:null}}rt._ssoResponse=VM;function zM(t){let{action_link:e,email_otp:r,hashed_token:n,redirect_to:i,verification_type:o}=t,s=NM(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:i,verification_type:o},u=Object.assign({},s);return{data:{properties:a,user:u},error:null}}rt._generateLinkResponse=zM;function GM(t){return t}rt._noResolveJsonResponse=GM;function WM(t){return t.access_token&&t.refresh_token&&t.expires_in}});var Ol=D(ru=>{"use strict";var KM=ru&&ru.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(ru,"__esModule",{value:!0});var vt=zm(),YM=Ko(),Mr=tu(),Gm=class{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=(0,YM.resolveFetch)(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,r="global"){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if((0,Mr.isAuthError)(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{let{options:r}=e,n=KM(e,["options"]),i=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(i.new_email=n?.newEmail,delete i.newEmail),await(0,vt._request)(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:vt._generateLinkResponse,redirectTo:r?.redirectTo})}catch(r){if((0,Mr.isAuthError)(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await(0,vt._request)(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:vt._userResponse})}catch(r){if((0,Mr.isAuthError)(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,i,o,s,a,u;try{let c={nextPage:null,lastPage:0,total:0},l=await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(i=e?.perPage)===null||i===void 0?void 0:i.toString())!==null&&o!==void 0?o:""},xform:vt._noResolveJsonResponse});if(l.error)throw l.error;let f=await l.json(),h=(s=l.headers.get("x-total-count"))!==null&&s!==void 0?s:0,d=(u=(a=l.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&u!==void 0?u:[];return d.length>0&&(d.forEach(p=>{let b=parseInt(p.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(p.split(";")[1].split("=")[1]);c[`${g}Page`]=b}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},f),c),error:null}}catch(c){if((0,Mr.isAuthError)(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){try{return await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:vt._userResponse})}catch(r){if((0,Mr.isAuthError)(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){try{return await(0,vt._request)(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){try{return await(0,vt._request)(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:vt._userResponse})}catch(n){if((0,Mr.isAuthError)(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{let{data:r,error:n}=await(0,vt._request)(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:i=>({data:{factors:i},error:null})});return{data:r,error:n}}catch(r){if((0,Mr.isAuthError)(r))return{data:null,error:r};throw r}}async _deleteFactor(e){try{return{data:await(0,vt._request)(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if((0,Mr.isAuthError)(r))return{data:null,error:r};throw r}}};ru.default=Gm});var A_=D(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.memoryLocalStorageAdapter=Jo.localStorageAdapter=void 0;var Wm=Ko();Jo.localStorageAdapter={getItem:t=>(0,Wm.supportsLocalStorage)()?globalThis.localStorage.getItem(t):null,setItem:(t,e)=>{(0,Wm.supportsLocalStorage)()&&globalThis.localStorage.setItem(t,e)},removeItem:t=>{(0,Wm.supportsLocalStorage)()&&globalThis.localStorage.removeItem(t)}};function JM(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}Jo.memoryLocalStorageAdapter=JM});var k_=D(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});Al.polyfillGlobalThis=void 0;function XM(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}Al.polyfillGlobalThis=XM});var Km=D(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.navigatorLock=Ct.NavigatorLockAcquireTimeoutError=Ct.LockAcquireTimeoutError=Ct.internals=void 0;var ZM=Ko();Ct.internals={debug:!!(globalThis&&(0,ZM.supportsLocalStorage)()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};var kl=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}};Ct.LockAcquireTimeoutError=kl;var Tl=class extends kl{};Ct.NavigatorLockAcquireTimeoutError=Tl;async function QM(t,e,r){Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);let n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async i=>{if(i){Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw Ct.internals.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Tl(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Ct.internals.debug)try{let o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}})}Ct.navigatorLock=QM});var Jm=D(ou=>{"use strict";var e4=ou&&ou.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ou,"__esModule",{value:!0});var t4=e4(Ol()),iu=Sl(),Z=tu(),ae=zm(),fe=Ko(),Ym=A_(),r4=k_(),n4=Rm(),T_=Km();(0,r4.polyfillGlobalThis)();var i4={url:iu.GOTRUE_URL,storageKey:iu.STORAGE_KEY,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:iu.DEFAULT_HEADERS,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},nu=30*1e3,P_=3;async function R_(t,e,r){return await r()}var Pl=class t{constructor(e){var r,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=t.nextInstanceID,t.nextInstanceID+=1,this.instanceID>0&&(0,fe.isBrowser)()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let i=Object.assign(Object.assign({},i4),e);if(this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.persistSession=i.persistSession,this.storageKey=i.storageKey,this.autoRefreshToken=i.autoRefreshToken,this.admin=new t4.default({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=(0,fe.resolveFetch)(i.fetch),this.lock=i.lock||R_,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,i.lock?this.lock=i.lock:(0,fe.isBrowser)()&&(!((r=globalThis?.navigator)===null||r===void 0)&&r.locks)?this.lock=T_.navigatorLock:this.lock=R_,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?i.storage?this.storage=i.storage:(0,fe.supportsLocalStorage)()?this.storage=Ym.localStorageAdapter:(this.memoryStorage={},this.storage=(0,Ym.memoryLocalStorageAdapter)(this.memoryStorage)):(this.memoryStorage={},this.storage=(0,Ym.memoryLocalStorageAdapter)(this.memoryStorage)),(0,fe.isBrowser)()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${n4.version}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){try{let e=(0,fe.isBrowser)()?await this._isPKCEFlow():!1;if(this._debug("#_initialize()","begin","is PKCE flow",e),e||this.detectSessionInUrl&&this._isImplicitGrantFlow()){let{data:r,error:n}=await this._getSessionFromURL(e);if(n)return this._debug("#_initialize()","error detecting session from URL",n),n?.code==="identity_already_exists"?{error:n}:(await this._removeSession(),{error:n});let{session:i,redirectType:o}=r;return this._debug("#_initialize()","detected session in URL",i,"redirect type",o),await this._saveSession(i),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(e){return(0,Z.isAuthError)(e)?{error:e}:{error:new Z.AuthUnknownError("Unexpected error during initialization",e)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,i;try{let o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e?.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(i=e?.options)===null||i===void 0?void 0:i.captchaToken}},xform:ae._sessionResponse}),{data:s,error:a}=o;if(a||!s)return{data:{user:null,session:null},error:a};let u=s.session,c=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(e){var r,n,i;try{let o;if("email"in e){let{email:l,password:f,options:h}=e,d=null,p=null;this.flowType==="pkce"&&([d,p]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey)),o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h?.emailRedirectTo,body:{email:l,password:f,data:(r=h?.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:d,code_challenge_method:p},xform:ae._sessionResponse})}else if("phone"in e){let{phone:l,password:f,options:h}=e;o=await(0,ae._request)(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:l,password:f,data:(n=h?.data)!==null&&n!==void 0?n:{},channel:(i=h?.channel)!==null&&i!==void 0?i:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:ae._sessionResponse})}else throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:s,error:a}=o;if(a||!s)return{data:{user:null,session:null},error:a};let u=s.session,c=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(e){try{let r;if("email"in e){let{email:o,password:s,options:a}=e;r=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:s,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ae._sessionResponsePassword})}else if("phone"in e){let{phone:o,password:s,options:a}=e;r=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:s,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ae._sessionResponsePassword})}else throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a password");let{data:n,error:i}=r;return i?{data:{user:null,session:null},error:i}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new Z.AuthInvalidTokenResponseError}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:i})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,i,o;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(i=e.options)===null||i===void 0?void 0:i.queryParams,skipBrowserRedirect:(o=e.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let r=await(0,fe.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`),[n,i]=(r??"").split("/");try{let{data:o,error:s}=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:ae._sessionResponse});if(await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`),s)throw s;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new Z.AuthInvalidTokenResponseError}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:i??null}),error:s})}catch(o){if((0,Z.isAuthError)(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(e){try{let{options:r,provider:n,token:i,access_token:o,nonce:s}=e,a=await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:i,access_token:o,nonce:s,gotrue_meta_security:{captcha_token:r?.captchaToken}},xform:ae._sessionResponse}),{data:u,error:c}=a;return c?{data:{user:null,session:null},error:c}:!u||!u.session||!u.user?{data:{user:null,session:null},error:new Z.AuthInvalidTokenResponseError}:(u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),{data:u,error:c})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,i,o,s;try{if("email"in e){let{email:a,options:u}=e,c=null,l=null;this.flowType==="pkce"&&([c,l]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey));let{error:f}=await(0,ae._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=u?.data)!==null&&r!==void 0?r:{},create_user:(n=u?.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:u?.captchaToken},code_challenge:c,code_challenge_method:l},redirectTo:u?.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in e){let{phone:a,options:u}=e,{data:c,error:l}=await(0,ae._request)(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(i=u?.data)!==null&&i!==void 0?i:{},create_user:(o=u?.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:u?.captchaToken},channel:(s=u?.channel)!==null&&s!==void 0?s:"sms"}});return{data:{user:null,session:null,messageId:c?.message_id},error:l}}throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number.")}catch(a){if((0,Z.isAuthError)(a))return{data:{user:null,session:null},error:a};throw a}}async verifyOtp(e){var r,n;try{let i,o;"options"in e&&(i=(r=e.options)===null||r===void 0?void 0:r.redirectTo,o=(n=e.options)===null||n===void 0?void 0:n.captchaToken);let{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:i,xform:ae._sessionResponse});if(a)throw a;if(!s)throw new Error("An error occurred on token verification.");let u=s.session,c=s.user;return u?.access_token&&(await this._saveSession(u),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u)),{data:{user:c,session:u},error:null}}catch(i){if((0,Z.isAuthError)(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithSSO(e){var r,n,i;try{let o=null,s=null;return this.flowType==="pkce"&&([o,s]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey)),await(0,ae._request)(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((i=e?.options)===null||i===void 0)&&i.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:s}),headers:this.headers,xform:ae._ssoResponse})}catch(o){if((0,Z.isAuthError)(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new Z.AuthSessionMissingError;let{error:i}=await(0,ae._request)(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:i}})}catch(e){if((0,Z.isAuthError)(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let r=`${this.url}/resend`;if("email"in e){let{email:n,type:i,options:o}=e,{error:s}=await(0,ae._request)(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},redirectTo:o?.emailRedirectTo});return{data:{user:null,session:null},error:s}}else if("phone"in e){let{phone:n,type:i,options:o}=e,{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:i,gotrue_meta_security:{captcha_token:o?.captchaToken}}});return{data:{user:null,session:null,messageId:s?.message_id},error:a}}throw new Z.AuthInvalidCredentialsError("You must provide either an email or phone number and a type")}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),i=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await i}catch{}})()),i}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){let i=[...this.pendingInLock];await Promise.all(i),this.pendingInLock.splice(0,i.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,r=await(0,fe.getItemAsync)(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let n=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.storage.isServer){let s=this.suppressGetSessionWarning;e=new Proxy(e,{get:(u,c,l)=>(!s&&c==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s=!0,this.suppressGetSessionWarning=!0),Reflect.get(u,c,l))})}return{data:{session:e},error:null}}let{session:i,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{session:null},error:o}:{data:{session:i},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await(0,ae._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ae._userResponse}):await this._useSession(async r=>{var n,i,o;let{data:s,error:a}=r;if(a)throw a;return!(!((n=s.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Z.AuthSessionMissingError}:await(0,ae._request)(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(i=s.session)===null||i===void 0?void 0:i.access_token)!==null&&o!==void 0?o:void 0,xform:ae._userResponse})})}catch(r){if((0,Z.isAuthError)(r))return(0,Z.isAuthSessionMissingError)(r)&&(await this._removeSession(),await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{let{data:i,error:o}=n;if(o)throw o;if(!i.session)throw new Z.AuthSessionMissingError;let s=i.session,a=null,u=null;this.flowType==="pkce"&&e.email!=null&&([a,u]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey));let{data:c,error:l}=await(0,ae._request)(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:u}),jwt:s.access_token,xform:ae._userResponse});if(l)throw l;return s.user=c.user,await this._saveSession(s),await this._notifyAllSubscribers("USER_UPDATED",s),{data:{user:s.user},error:null}})}catch(n){if((0,Z.isAuthError)(n))return{data:{user:null},error:n};throw n}}_decodeJWT(e){return(0,fe.decodeJWTPayload)(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Z.AuthSessionMissingError;let r=Date.now()/1e3,n=r,i=!0,o=null,s=(0,fe.decodeJWTPayload)(e.access_token);if(s.exp&&(n=s.exp,i=n<=r),i){let{session:a,error:u}=await this._callRefreshToken(e.refresh_token);if(u)return{data:{user:null,session:null},error:u};if(!a)return{data:{user:null,session:null},error:null};o=a}else{let{data:a,error:u}=await this._getUser(e.access_token);if(u)throw u;o={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){let{data:s,error:a}=r;if(a)throw a;e=(n=s.session)!==null&&n!==void 0?n:void 0}if(!e?.refresh_token)throw new Z.AuthSessionMissingError;let{session:i,error:o}=await this._callRefreshToken(e.refresh_token);return o?{data:{user:null,session:null},error:o}:i?{data:{user:i.user,session:i},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if((0,Z.isAuthError)(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e){try{if(!(0,fe.isBrowser)())throw new Z.AuthImplicitGrantRedirectError("No browser detected.");if(this.flowType==="implicit"&&!this._isImplicitGrantFlow())throw new Z.AuthImplicitGrantRedirectError("Not a valid implicit grant flow url.");if(this.flowType=="pkce"&&!e)throw new Z.AuthPKCEGrantCodeExchangeError("Not a valid PKCE flow url.");let r=(0,fe.parseParametersFromURL)(window.location.href);if(e){if(!r.code)throw new Z.AuthPKCEGrantCodeExchangeError("No code detected.");let{data:S,error:y}=await this._exchangeCodeForSession(r.code);if(y)throw y;let C=new URL(window.location.href);return C.searchParams.delete("code"),window.history.replaceState(window.history.state,"",C.toString()),{data:{session:S.session,redirectType:null},error:null}}if(r.error||r.error_description||r.error_code)throw new Z.AuthImplicitGrantRedirectError(r.error_description||"Error in URL with unspecified error_description",{error:r.error||"unspecified_error",code:r.error_code||"unspecified_code"});let{provider_token:n,provider_refresh_token:i,access_token:o,refresh_token:s,expires_in:a,expires_at:u,token_type:c}=r;if(!o||!a||!s||!c)throw new Z.AuthImplicitGrantRedirectError("No session defined in URL");let l=Math.round(Date.now()/1e3),f=parseInt(a),h=l+f;u&&(h=parseInt(u));let d=h-l;d*1e3<=nu&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${d}s, should have been closer to ${f}s`);let p=h-f;l-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,h,l):l-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,h,l);let{data:b,error:g}=await this._getUser(o);if(g)throw g;let w={provider_token:n,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:h,refresh_token:s,token_type:c,user:b.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:w,redirectType:r.type},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:{session:null,redirectType:null},error:r};throw r}}_isImplicitGrantFlow(){let e=(0,fe.parseParametersFromURL)(window.location.href);return!!((0,fe.isBrowser)()&&(e.access_token||e.error_description))}async _isPKCEFlow(){let e=(0,fe.parseParametersFromURL)(window.location.href),r=await(0,fe.getItemAsync)(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;let{data:i,error:o}=r;if(o)return{error:o};let s=(n=i.session)===null||n===void 0?void 0:n.access_token;if(s){let{error:a}=await this.admin.signOut(s,e);if(a&&!((0,Z.isAuthApiError)(a)&&(a.status===404||a.status===401||a.status===403)))return{error:a}}return e!=="others"&&(await this._removeSession(),await(0,fe.removeItemAsync)(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let r=(0,fe.uuid)(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,i;try{let{data:{session:o},error:s}=r;if(s)throw s;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",e,"session",o)}catch(o){await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",o),console.error(o)}})}async resetPasswordForEmail(e,r={}){let n=null,i=null;this.flowType==="pkce"&&([n,i]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey,!0));try{return await(0,ae._request)(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:i,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if((0,Z.isAuthError)(o))return{data:null,error:o};throw o}}async getUserIdentities(){var e;try{let{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{let{data:n,error:i}=await this._useSession(async o=>{var s,a,u,c,l;let{data:f,error:h}=o;if(h)throw h;let d=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(u=e.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return await(0,ae._request)(this.fetch,"GET",d,{headers:this.headers,jwt:(l=(c=f.session)===null||c===void 0?void 0:c.access_token)!==null&&l!==void 0?l:void 0})});if(i)throw i;return(0,fe.isBrowser)()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n?.url),{data:{provider:e.provider,url:n?.url},error:null}}catch(n){if((0,Z.isAuthError)(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,i;let{data:o,error:s}=r;if(s)throw s;return await(0,ae._request)(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){let r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{let n=Date.now();return await(0,fe.retryable)(async i=>(i>0&&await(0,fe.sleep)(200*Math.pow(2,i-1)),this._debug(r,"refreshing attempt",i),await(0,ae._request)(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:ae._sessionResponse})),(i,o)=>{let s=200*Math.pow(2,i);return o&&(0,Z.isAuthRetryableFetchError)(o)&&Date.now()+s-n<nu})}catch(n){if(this._debug(r,"error",n),(0,Z.isAuthError)(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){let n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),(0,fe.isBrowser)()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e;let r="#_recoverAndRefresh()";this._debug(r,"begin");try{let n=await(0,fe.getItemAsync)(this.storage,this.storageKey);if(this._debug(r,"session from storage",n),!this._isValidSession(n)){this._debug(r,"session is not valid"),n!==null&&await this._removeSession();return}let i=Math.round(Date.now()/1e3),o=((e=n.expires_at)!==null&&e!==void 0?e:1/0)<i+iu.EXPIRY_MARGIN;if(this._debug(r,`session has${o?"":" not"} expired with margin of ${iu.EXPIRY_MARGIN}s`),o){if(this.autoRefreshToken&&n.refresh_token){let{error:s}=await this._callRefreshToken(n.refresh_token);s&&(console.error(s),(0,Z.isAuthRetryableFetchError)(s)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",s),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(r,"error",n),console.error(n);return}finally{this._debug(r,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new Z.AuthSessionMissingError;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let i=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(i,"begin");try{this.refreshingDeferred=new fe.Deferred;let{data:o,error:s}=await this._refreshAccessToken(e);if(s)throw s;if(!o.session)throw new Z.AuthSessionMissingError;await this._saveSession(o.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);let a={session:o.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(o){if(this._debug(i,"error",o),(0,Z.isAuthError)(o)){let s={session:null,error:o};return(0,Z.isAuthRetryableFetchError)(o)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(s),s}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(o),o}finally{this.refreshingDeferred=null,this._debug(i,"end")}}async _notifyAllSubscribers(e,r,n=!0){let i=`#_notifyAllSubscribers(${e})`;this._debug(i,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});let o=[],s=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,r)}catch(u){o.push(u)}});if(await Promise.all(s),o.length>0){for(let a=0;a<o.length;a+=1)console.error(o[a]);throw o[0]}}finally{this._debug(i,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await(0,fe.setItemAsync)(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await(0,fe.removeItemAsync)(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&(0,fe.isBrowser)()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),nu);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async r=>{let{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let i=Math.floor((n.expires_at*1e3-e)/nu);this._debug("#_autoRefreshTokenTick()",`access token expires in ${i} ticks, a tick lasts ${nu}ms, refresh threshold is ${P_} ticks`),i<=P_&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof T_.LockAcquireTimeoutError)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!(0,fe.isBrowser)()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){let i=[`provider=${encodeURIComponent(r)}`];if(n?.redirectTo&&i.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n?.scopes&&i.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){let[o,s]=await(0,fe.getCodeChallengeAndMethod)(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(s)}`});i.push(a.toString())}if(n?.queryParams){let o=new URLSearchParams(n.queryParams);i.push(o.toString())}return n?.skipBrowserRedirect&&i.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${i.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;return o?{data:null,error:o}:await(0,ae._request)(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,i;let{data:o,error:s}=r;if(s)return{data:null,error:s};let a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:u,error:c}=await(0,ae._request)(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=o?.session)===null||n===void 0?void 0:n.access_token});return c?{data:null,error:c}:(e.factorType==="totp"&&(!((i=u?.totp)===null||i===void 0)&&i.qr_code)&&(u.totp.qr_code=`data:image/svg+xml;utf-8,${u.totp.qr_code}`),{data:u,error:null})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;if(o)return{data:null,error:o};let{data:s,error:a}=await(0,ae._request)(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token});return a?{data:null,error:a}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+s.expires_in},s)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",s),{data:s,error:a})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;let{data:i,error:o}=r;return o?{data:null,error:o}:await(0,ae._request)(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=i?.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if((0,Z.isAuthError)(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){let{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){let{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};let n=e?.factors||[],i=n.filter(s=>s.factor_type==="totp"&&s.status==="verified"),o=n.filter(s=>s.factor_type==="phone"&&s.status==="verified");return{data:{all:n,totp:i,phone:o},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;let{data:{session:i},error:o}=e;if(o)return{data:null,error:o};if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let s=this._decodeJWT(i.access_token),a=null;s.aal&&(a=s.aal);let u=a;((n=(r=i.user.factors)===null||r===void 0?void 0:r.filter(f=>f.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(u="aal2");let l=s.amr||[];return{data:{currentLevel:a,nextLevel:u,currentAuthenticationMethods:l},error:null}}))}};ou.default=Pl;Pl.nextInstanceID=0});var $_=D(su=>{"use strict";var o4=su&&su.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(su,"__esModule",{value:!0});var s4=o4(Ol()),a4=s4.default;su.default=a4});var I_=D(au=>{"use strict";var u4=au&&au.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(au,"__esModule",{value:!0});var c4=u4(Jm()),l4=c4.default;au.default=l4});var N_=D(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0})});var Zm=D(Ie=>{"use strict";var f4=Ie&&Ie.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),L_=Ie&&Ie.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&f4(e,t,r)},Rl=Ie&&Ie.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.lockInternals=Ie.NavigatorLockAcquireTimeoutError=Ie.navigatorLock=Ie.AuthClient=Ie.AuthAdminApi=Ie.GoTrueClient=Ie.GoTrueAdminApi=void 0;var d4=Rl(Ol());Ie.GoTrueAdminApi=d4.default;var h4=Rl(Jm());Ie.GoTrueClient=h4.default;var p4=Rl($_());Ie.AuthAdminApi=p4.default;var m4=Rl(I_());Ie.AuthClient=m4.default;L_(N_(),Ie);L_(tu(),Ie);var Xm=Km();Object.defineProperty(Ie,"navigatorLock",{enumerable:!0,get:function(){return Xm.navigatorLock}});Object.defineProperty(Ie,"NavigatorLockAcquireTimeoutError",{enumerable:!0,get:function(){return Xm.NavigatorLockAcquireTimeoutError}});Object.defineProperty(Ie,"lockInternals",{enumerable:!0,get:function(){return Xm.internals}})});var B_=D($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.SupabaseAuthClient=void 0;var g4=Zm(),Qm=class extends g4.AuthClient{constructor(e){super(e)}};$l.SupabaseAuthClient=Qm});var tg=D(uu=>{"use strict";var y4=uu&&uu.__awaiter||function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function a(l){try{c(n.next(l))}catch(f){s(f)}}function u(l){try{c(n.throw(l))}catch(f){s(f)}}function c(l){l.done?o(l.value):i(l.value).then(a,u)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(uu,"__esModule",{value:!0});var D4=lm(),v4=s_(),b4=(Cm(),ke(Em)),w4=v_(),Il=w_(),_4=E_(),q_=C_(),E4=B_(),eg=class{constructor(e,r,n){var i,o,s;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");let a=(0,q_.stripTrailingSlash)(e);this.realtimeUrl=`${a}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${a}/auth/v1`,this.storageUrl=`${a}/storage/v1`,this.functionsUrl=`${a}/functions/v1`;let u=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,c={db:Il.DEFAULT_DB_OPTIONS,realtime:Il.DEFAULT_REALTIME_OPTIONS,auth:Object.assign(Object.assign({},Il.DEFAULT_AUTH_OPTIONS),{storageKey:u}),global:Il.DEFAULT_GLOBAL_OPTIONS},l=(0,q_.applySettingDefaults)(n??{},c);this.storageKey=(i=l.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(o=l.global.headers)!==null&&o!==void 0?o:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(f,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((s=l.auth)!==null&&s!==void 0?s:{},this.headers,l.global.fetch),this.fetch=(0,_4.fetchWithAuth)(r,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},l.realtime)),this.rest=new v4.PostgrestClient(`${a}/rest/v1`,{headers:this.headers,schema:l.db.schema,fetch:this.fetch}),l.accessToken||this._listenForAuthEvents()}get functions(){return new D4.FunctionsClient(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new w4.StorageClient(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return y4(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:i,storageKey:o,flowType:s,lock:a,debug:u},c,l){var f;let h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new E4.SupabaseAuthClient({url:this.authUrl,headers:Object.assign(Object.assign({},h),c),storageKey:o,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:i,flowType:s,lock:a,debug:u,fetch:l,hasCustomAuthorizationHeader:(f="Authorization"in this.headers)!==null&&f!==void 0?f:!1})}_initRealtimeClient(e){return new b4.RealtimeClient(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n?.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.realtime.setAuth(n??null),this.changedAccessToken=n):e==="SIGNED_OUT"&&(this.realtime.setAuth(this.supabaseKey),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};uu.default=eg});var H_=D(je=>{"use strict";var C4=je&&je.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),M_=je&&je.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&C4(e,t,r)},U_=je&&je.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(je,"__esModule",{value:!0});je.createClient=je.SupabaseClient=je.FunctionRegion=je.FunctionsError=je.FunctionsRelayError=je.FunctionsFetchError=je.FunctionsHttpError=void 0;var S4=U_(tg());M_(Zm(),je);var cu=lm();Object.defineProperty(je,"FunctionsHttpError",{enumerable:!0,get:function(){return cu.FunctionsHttpError}});Object.defineProperty(je,"FunctionsFetchError",{enumerable:!0,get:function(){return cu.FunctionsFetchError}});Object.defineProperty(je,"FunctionsRelayError",{enumerable:!0,get:function(){return cu.FunctionsRelayError}});Object.defineProperty(je,"FunctionsError",{enumerable:!0,get:function(){return cu.FunctionsError}});Object.defineProperty(je,"FunctionRegion",{enumerable:!0,get:function(){return cu.FunctionRegion}});M_((Cm(),ke(Em)),je);var x4=tg();Object.defineProperty(je,"SupabaseClient",{enumerable:!0,get:function(){return U_(x4).default}});var F4=(t,e,r)=>new S4.default(t,e,r);je.createClient=F4});var rg=D((Nle,V_)=>{V_.exports=require("stream")});var J_=D((Lle,Y_)=>{"use strict";function z_(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function G_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?z_(Object(r),!0).forEach(function(n){O4(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):z_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function O4(t,e,r){return e=K_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function A4(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function W_(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,K_(n.key),n)}}function k4(t,e,r){return e&&W_(t.prototype,e),r&&W_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function K_(t){var e=T4(t,"string");return typeof e=="symbol"?e:String(e)}function T4(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var P4=require("buffer"),jl=P4.Buffer,R4=require("util"),ng=R4.inspect,$4=ng&&ng.custom||"inspect";function I4(t,e,r){jl.prototype.copy.call(t,e,r)}Y_.exports=function(){function t(){A4(this,t),this.head=null,this.tail=null,this.length=0}return k4(t,[{key:"push",value:function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length}},{key:"unshift",value:function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length}},{key:"shift",value:function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i}},{key:"concat",value:function(r){if(this.length===0)return jl.alloc(0);for(var n=jl.allocUnsafe(r>>>0),i=this.head,o=0;i;)I4(i.data,n,o),o+=i.data.length,i=i.next;return n}},{key:"consume",value:function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o}},{key:"_getBuffer",value:function(r){var n=jl.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n}},{key:$4,value:function(r,n){return ng(this,G_(G_({},n),{},{depth:0,customInspect:!1}))}}]),t}()});var og=D((Ble,Z_)=>{"use strict";function j4(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(ig,this,t)):process.nextTick(ig,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?process.nextTick(Nl,r):(r._writableState.errorEmitted=!0,process.nextTick(X_,r,o)):process.nextTick(X_,r,o):e?(process.nextTick(Nl,r),e(o)):process.nextTick(Nl,r)}),this)}function X_(t,e){ig(t,e),Nl(t)}function Nl(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function N4(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function ig(t,e){t.emit("error",e)}function L4(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}Z_.exports={destroy:j4,undestroy:N4,errorOrDestroy:L4}});var Yn=D((qle,tE)=>{"use strict";var eE={};function gr(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}class i extends r{constructor(s,a,u){super(n(s,a,u))}}i.prototype.name=r.name,i.prototype.code=t,eE[t]=i}function Q_(t,e){if(Array.isArray(t)){let r=t.length;return t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}else return`of ${e} ${String(t)}`}function B4(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function q4(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function M4(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}gr("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);gr("ERR_INVALID_ARG_TYPE",function(t,e,r){let n;typeof e=="string"&&B4(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";let i;if(q4(t," argument"))i=`The ${t} ${n} ${Q_(e,"type")}`;else{let o=M4(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${Q_(e,"type")}`}return i+=`. Received type ${typeof r}`,i},TypeError);gr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");gr("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});gr("ERR_STREAM_PREMATURE_CLOSE","Premature close");gr("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});gr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");gr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");gr("ERR_STREAM_WRITE_AFTER_END","write after end");gr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);gr("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);gr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");tE.exports.codes=eE});var sg=D((Mle,rE)=>{"use strict";var U4=Yn().codes.ERR_INVALID_OPT_VALUE;function H4(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function V4(t,e,r,n){var i=H4(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new U4(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}rE.exports={getHighWaterMark:V4}});var nE=D((Ule,ag)=>{typeof Object.create=="function"?ag.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ag.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}});var Xo=D((Hle,cg)=>{try{if(ug=require("util"),typeof ug.inherits!="function")throw"";cg.exports=ug.inherits}catch{cg.exports=nE()}var ug});var oE=D((Vle,iE)=>{iE.exports=require("util").deprecate});var dg=D((zle,fE)=>{"use strict";fE.exports=Ye;function aE(t){var e=this;this.next=null,this.entry=null,this.finish=function(){y5(e,t)}}var Zo;Ye.WritableState=fu;var z4={deprecate:oE()},uE=rg(),Bl=require("buffer").Buffer,G4=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function W4(t){return Bl.from(t)}function K4(t){return Bl.isBuffer(t)||t instanceof G4}var fg=og(),Y4=sg(),J4=Y4.getHighWaterMark,Jn=Yn().codes,X4=Jn.ERR_INVALID_ARG_TYPE,Z4=Jn.ERR_METHOD_NOT_IMPLEMENTED,Q4=Jn.ERR_MULTIPLE_CALLBACK,e5=Jn.ERR_STREAM_CANNOT_PIPE,t5=Jn.ERR_STREAM_DESTROYED,r5=Jn.ERR_STREAM_NULL_VALUES,n5=Jn.ERR_STREAM_WRITE_AFTER_END,i5=Jn.ERR_UNKNOWN_ENCODING,Qo=fg.errorOrDestroy;Xo()(Ye,uE);function o5(){}function fu(t,e,r){Zo=Zo||ki(),t=t||{},typeof r!="boolean"&&(r=e instanceof Zo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=J4(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){d5(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new aE(this)}fu.prototype.getBuffer=function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r};(function(){try{Object.defineProperty(fu.prototype,"buffer",{get:z4.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var Ll;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(Ll=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ye,Symbol.hasInstance,{value:function(e){return Ll.call(this,e)?!0:this!==Ye?!1:e&&e._writableState instanceof fu}})):Ll=function(e){return e instanceof this};function Ye(t){Zo=Zo||ki();var e=this instanceof Zo;if(!e&&!Ll.call(Ye,this))return new Ye(t);this._writableState=new fu(t,this,e),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),uE.call(this)}Ye.prototype.pipe=function(){Qo(this,new e5)};function s5(t,e){var r=new n5;Qo(t,r),process.nextTick(e,r)}function a5(t,e,r,n){var i;return r===null?i=new r5:typeof r!="string"&&!e.objectMode&&(i=new X4("chunk",["string","Buffer"],r)),i?(Qo(t,i),process.nextTick(n,i),!1):!0}Ye.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&K4(t);return o&&!Bl.isBuffer(t)&&(t=W4(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=o5),n.ending?s5(this,r):(o||a5(this,n,t,r))&&(n.pendingcb++,i=c5(this,n,o,t,e,r)),i};Ye.prototype.cork=function(){this._writableState.corked++};Ye.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&cE(this,t))};Ye.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new i5(e);return this._writableState.defaultEncoding=e,this};Object.defineProperty(Ye.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function u5(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=Bl.from(e,r)),e}Object.defineProperty(Ye.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function c5(t,e,r,n,i,o){if(!r){var s=u5(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else lg(t,e,!1,a,n,i,o);return u}function lg(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new t5("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function l5(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(lu,t,e),t._writableState.errorEmitted=!0,Qo(t,n)):(i(n),t._writableState.errorEmitted=!0,Qo(t,n),lu(t,e))}function f5(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function d5(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new Q4;if(f5(r),e)l5(t,r,n,e,i);else{var o=lE(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&cE(t,r),n?process.nextTick(sE,t,r,o,i):sE(t,r,o,i)}}function sE(t,e,r,n){r||h5(t,e),e.pendingcb--,n(),lu(t,e)}function h5(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function cE(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,lg(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new aE(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,c=r.encoding,l=r.callback,f=e.objectMode?1:u.length;if(lg(t,e,!1,f,u,c,l),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}Ye.prototype._write=function(t,e,r){r(new Z4("_write()"))};Ye.prototype._writev=null;Ye.prototype.end=function(t,e,r){var n=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||g5(this,n,r),this};Object.defineProperty(Ye.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function lE(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}function p5(t,e){t._final(function(r){e.pendingcb--,r&&Qo(t,r),e.prefinished=!0,t.emit("prefinish"),lu(t,e)})}function m5(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(p5,t,e)):(e.prefinished=!0,t.emit("prefinish")))}function lu(t,e){var r=lE(e);if(r&&(m5(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}function g5(t,e,r){e.ending=!0,lu(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}function y5(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}Object.defineProperty(Ye.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Ye.prototype.destroy=fg.destroy;Ye.prototype._undestroy=fg.undestroy;Ye.prototype._destroy=function(t,e){e(t)}});var ki=D((Gle,hE)=>{"use strict";var D5=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};hE.exports=Ur;var dE=mg(),pg=dg();Xo()(Ur,dE);for(hg=D5(pg.prototype),ql=0;ql<hg.length;ql++)Ml=hg[ql],Ur.prototype[Ml]||(Ur.prototype[Ml]=pg.prototype[Ml]);var hg,Ml,ql;function Ur(t){if(!(this instanceof Ur))return new Ur(t);dE.call(this,t),pg.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",v5)))}Object.defineProperty(Ur.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});Object.defineProperty(Ur.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});Object.defineProperty(Ur.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function v5(){this._writableState.ended||process.nextTick(b5,this)}function b5(t){t.end()}Object.defineProperty(Ur.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})});var gE=D((gg,mE)=>{var Ul=require("buffer"),Hr=Ul.Buffer;function pE(t,e){for(var r in t)e[r]=t[r]}Hr.from&&Hr.alloc&&Hr.allocUnsafe&&Hr.allocUnsafeSlow?mE.exports=Ul:(pE(Ul,gg),gg.Buffer=Ti);function Ti(t,e,r){return Hr(t,e,r)}Ti.prototype=Object.create(Hr.prototype);pE(Hr,Ti);Ti.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Hr(t,e,r)};Ti.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Hr(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Ti.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Hr(t)};Ti.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ul.SlowBuffer(t)}});var vg=D(DE=>{"use strict";var Dg=gE().Buffer,yE=Dg.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function w5(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function _5(t){var e=w5(t);if(typeof e!="string"&&(Dg.isEncoding===yE||!yE(t)))throw new Error("Unknown encoding: "+t);return e||t}DE.StringDecoder=du;function du(t){this.encoding=_5(t);var e;switch(this.encoding){case"utf16le":this.text=O5,this.end=A5,e=4;break;case"utf8":this.fillLast=S5,e=4;break;case"base64":this.text=k5,this.end=T5,e=3;break;default:this.write=P5,this.end=R5;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Dg.allocUnsafe(e)}du.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};du.prototype.end=F5;du.prototype.text=x5;du.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function yg(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function E5(t,e,r){var n=e.length-1;if(n<r)return 0;var i=yg(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=yg(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=yg(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function C5(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function S5(t){var e=this.lastTotal-this.lastNeed,r=C5(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function x5(t,e){var r=E5(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function F5(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function O5(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function A5(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function k5(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function T5(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function P5(t){return t.toString(this.encoding)}function R5(t){return t&&t.length?this.write(t):""}});var Hl=D((Kle,wE)=>{"use strict";var vE=Yn().codes.ERR_STREAM_PREMATURE_CLOSE;function $5(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}function I5(){}function j5(t){return t.setHeader&&typeof t.abort=="function"}function bE(t,e,r){if(typeof e=="function")return bE(t,null,e);e||(e={}),r=$5(r||I5);var n=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,o=function(){t.writable||a()},s=t._writableState&&t._writableState.finished,a=function(){i=!1,s=!0,n||r.call(t)},u=t._readableState&&t._readableState.endEmitted,c=function(){n=!1,u=!0,i||r.call(t)},l=function(p){r.call(t,p)},f=function(){var p;if(n&&!u)return(!t._readableState||!t._readableState.ended)&&(p=new vE),r.call(t,p);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(p=new vE),r.call(t,p)},h=function(){t.req.on("finish",a)};return j5(t)?(t.on("complete",a),t.on("abort",f),t.req?h():t.on("request",h)):i&&!t._writableState&&(t.on("end",o),t.on("close",o)),t.on("end",c),t.on("finish",a),e.error!==!1&&t.on("error",l),t.on("close",f),function(){t.removeListener("complete",a),t.removeListener("abort",f),t.removeListener("request",h),t.req&&t.req.removeListener("finish",a),t.removeListener("end",o),t.removeListener("close",o),t.removeListener("finish",a),t.removeListener("end",c),t.removeListener("error",l),t.removeListener("close",f)}}wE.exports=bE});var EE=D((Yle,_E)=>{"use strict";var Vl;function Xn(t,e,r){return e=N5(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function N5(t){var e=L5(t,"string");return typeof e=="symbol"?e:String(e)}function L5(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var B5=Hl(),Zn=Symbol("lastResolve"),Pi=Symbol("lastReject"),hu=Symbol("error"),zl=Symbol("ended"),Ri=Symbol("lastPromise"),bg=Symbol("handlePromise"),$i=Symbol("stream");function Qn(t,e){return{value:t,done:e}}function q5(t){var e=t[Zn];if(e!==null){var r=t[$i].read();r!==null&&(t[Ri]=null,t[Zn]=null,t[Pi]=null,e(Qn(r,!1)))}}function M5(t){process.nextTick(q5,t)}function U5(t,e){return function(r,n){t.then(function(){if(e[zl]){r(Qn(void 0,!0));return}e[bg](r,n)},n)}}var H5=Object.getPrototypeOf(function(){}),V5=Object.setPrototypeOf((Vl={get stream(){return this[$i]},next:function(){var e=this,r=this[hu];if(r!==null)return Promise.reject(r);if(this[zl])return Promise.resolve(Qn(void 0,!0));if(this[$i].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[hu]?a(e[hu]):s(Qn(void 0,!0))})});var n=this[Ri],i;if(n)i=new Promise(U5(n,this));else{var o=this[$i].read();if(o!==null)return Promise.resolve(Qn(o,!1));i=new Promise(this[bg])}return this[Ri]=i,i}},Xn(Vl,Symbol.asyncIterator,function(){return this}),Xn(Vl,"return",function(){var e=this;return new Promise(function(r,n){e[$i].destroy(null,function(i){if(i){n(i);return}r(Qn(void 0,!0))})})}),Vl),H5),z5=function(e){var r,n=Object.create(V5,(r={},Xn(r,$i,{value:e,writable:!0}),Xn(r,Zn,{value:null,writable:!0}),Xn(r,Pi,{value:null,writable:!0}),Xn(r,hu,{value:null,writable:!0}),Xn(r,zl,{value:e._readableState.endEmitted,writable:!0}),Xn(r,bg,{value:function(o,s){var a=n[$i].read();a?(n[Ri]=null,n[Zn]=null,n[Pi]=null,o(Qn(a,!1))):(n[Zn]=o,n[Pi]=s)},writable:!0}),r));return n[Ri]=null,B5(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[Pi];o!==null&&(n[Ri]=null,n[Zn]=null,n[Pi]=null,o(i)),n[hu]=i;return}var s=n[Zn];s!==null&&(n[Ri]=null,n[Zn]=null,n[Pi]=null,s(Qn(void 0,!0))),n[zl]=!0}),e.on("readable",M5.bind(null,n)),n};_E.exports=z5});var FE=D((Jle,xE)=>{"use strict";function CE(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function G5(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(u){CE(o,n,i,s,a,"next",u)}function a(u){CE(o,n,i,s,a,"throw",u)}s(void 0)})}}function SE(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function W5(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?SE(Object(r),!0).forEach(function(n){K5(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):SE(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function K5(t,e,r){return e=Y5(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Y5(t){var e=J5(t,"string");return typeof e=="symbol"?e:String(e)}function J5(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var X5=Yn().codes.ERR_INVALID_ARG_TYPE;function Z5(t,e,r){var n;if(e&&typeof e.next=="function")n=e;else if(e&&e[Symbol.asyncIterator])n=e[Symbol.asyncIterator]();else if(e&&e[Symbol.iterator])n=e[Symbol.iterator]();else throw new X5("iterable",["Iterable"],e);var i=new t(W5({objectMode:!0},r)),o=!1;i._read=function(){o||(o=!0,s())};function s(){return a.apply(this,arguments)}function a(){return a=G5(function*(){try{var u=yield n.next(),c=u.value,l=u.done;l?i.push(null):i.push(yield c)?s():o=!1}catch(f){i.destroy(f)}}),a.apply(this,arguments)}return i}xE.exports=Z5});var mg=D((Zle,NE)=>{"use strict";NE.exports=ye;var es;ye.ReadableState=TE;var Xle=require("events").EventEmitter,kE=function(e,r){return e.listeners(r).length},mu=rg(),Gl=require("buffer").Buffer,Q5=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function eU(t){return Gl.from(t)}function tU(t){return Gl.isBuffer(t)||t instanceof Q5}var wg=require("util"),ue;wg&&wg.debuglog?ue=wg.debuglog("stream"):ue=function(){};var rU=J_(),Og=og(),nU=sg(),iU=nU.getHighWaterMark,Wl=Yn().codes,oU=Wl.ERR_INVALID_ARG_TYPE,sU=Wl.ERR_STREAM_PUSH_AFTER_EOF,aU=Wl.ERR_METHOD_NOT_IMPLEMENTED,uU=Wl.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,ts,_g,Eg;Xo()(ye,mu);var pu=Og.errorOrDestroy,Cg=["error","close","destroy","pause","resume"];function cU(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}function TE(t,e,r){es=es||ki(),t=t||{},typeof r!="boolean"&&(r=e instanceof es),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=iU(this,t,"readableHighWaterMark",r),this.buffer=new rU,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(ts||(ts=vg().StringDecoder),this.decoder=new ts(t.encoding),this.encoding=t.encoding)}function ye(t){if(es=es||ki(),!(this instanceof ye))return new ye(t);var e=this instanceof es;this._readableState=new TE(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),mu.call(this)}Object.defineProperty(ye.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});ye.prototype.destroy=Og.destroy;ye.prototype._undestroy=Og.undestroy;ye.prototype._destroy=function(t,e){e(t)};ye.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=Gl.from(t,e),e=""),n=!0),PE(this,t,e,!1,n)};ye.prototype.unshift=function(t){return PE(this,t,null,!0,!1)};function PE(t,e,r,n,i){ue("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,dU(t,o);else{var s;if(i||(s=lU(o,e)),s)pu(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==Gl.prototype&&(e=eU(e)),n)o.endEmitted?pu(t,new uU):Sg(t,o,e,!0);else if(o.ended)pu(t,new sU);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?Sg(t,o,e,!1):Fg(t,o)):Sg(t,o,e,!1)}else n||(o.reading=!1,Fg(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}function Sg(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&Kl(t)),Fg(t,e)}function lU(t,e){var r;return!tU(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new oU("chunk",["string","Buffer","Uint8Array"],e)),r}ye.prototype.isPaused=function(){return this._readableState.flowing===!1};ye.prototype.setEncoding=function(t){ts||(ts=vg().StringDecoder);var e=new ts(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var OE=1073741824;function fU(t){return t>=OE?t=OE:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function AE(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=fU(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}ye.prototype.read=function(t){ue("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return ue("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?xg(this):Kl(this),null;if(t=AE(t,e),t===0&&e.ended)return e.length===0&&xg(this),null;var n=e.needReadable;ue("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,ue("length less than watermark",n)),e.ended||e.reading?(n=!1,ue("reading or ended",n)):n&&(ue("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=AE(r,e)));var i;return t>0?i=IE(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&xg(this)),i!==null&&this.emit("data",i),i};function dU(t,e){if(ue("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?Kl(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,RE(t)))}}function Kl(t){var e=t._readableState;ue("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(ue("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(RE,t))}function RE(t){var e=t._readableState;ue("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ag(t)}function Fg(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(hU,t,e))}function hU(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(ue("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}ye.prototype._read=function(t){pu(this,new aU("_read()"))};ye.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t);break}n.pipesCount+=1,ue("pipe count=%d opts=%j",n.pipesCount,e);var i=(!e||e.end!==!1)&&t!==process.stdout&&t!==process.stderr,o=i?a:b;n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(g,w){ue("onunpipe"),g===r&&w&&w.hasUnpiped===!1&&(w.hasUnpiped=!0,l())}function a(){ue("onend"),t.end()}var u=pU(r);t.on("drain",u);var c=!1;function l(){ue("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",h),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",b),r.removeListener("data",f),c=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}r.on("data",f);function f(g){ue("ondata");var w=t.write(g);ue("dest.write",w),w===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&jE(n.pipes,t)!==-1)&&!c&&(ue("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(g){ue("onerror",g),b(),t.removeListener("error",h),kE(t,"error")===0&&pu(t,g)}cU(t,"error",h);function d(){t.removeListener("finish",p),b()}t.once("close",d);function p(){ue("onfinish"),t.removeListener("close",d),b()}t.once("finish",p);function b(){ue("unpipe"),r.unpipe(t)}return t.emit("pipe",r),n.flowing||(ue("pipe resume"),r.resume()),t};function pU(t){return function(){var r=t._readableState;ue("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&kE(t,"data")&&(r.flowing=!0,Ag(t))}}ye.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=jE(e.pipes,t);return s===-1?this:(e.pipes.splice(s,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};ye.prototype.on=function(t,e){var r=mu.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,ue("on readable",n.length,n.reading),n.length?Kl(this):n.reading||process.nextTick(mU,this)),r};ye.prototype.addListener=ye.prototype.on;ye.prototype.removeListener=function(t,e){var r=mu.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick($E,this),r};ye.prototype.removeAllListeners=function(t){var e=mu.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick($E,this),e};function $E(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function mU(t){ue("readable nexttick read 0"),t.read(0)}ye.prototype.resume=function(){var t=this._readableState;return t.flowing||(ue("resume"),t.flowing=!t.readableListening,gU(this,t)),t.paused=!1,this};function gU(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(yU,t,e))}function yU(t,e){ue("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ag(t),e.flowing&&!e.reading&&t.read(0)}ye.prototype.pause=function(){return ue("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ue("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Ag(t){var e=t._readableState;for(ue("flow",e.flowing);e.flowing&&t.read()!==null;);}ye.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(ue("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(ue("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=function(a){return function(){return t[a].apply(t,arguments)}}(i));for(var o=0;o<Cg.length;o++)t.on(Cg[o],this.emit.bind(this,Cg[o]));return this._read=function(s){ue("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(ye.prototype[Symbol.asyncIterator]=function(){return _g===void 0&&(_g=EE()),_g(this)});Object.defineProperty(ye.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});Object.defineProperty(ye.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}});Object.defineProperty(ye.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}});ye._fromList=IE;Object.defineProperty(ye.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function IE(t,e){if(e.length===0)return null;var r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function xg(t){var e=t._readableState;ue("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(DU,e,t))}function DU(t,e){if(ue("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}typeof Symbol=="function"&&(ye.from=function(t,e){return Eg===void 0&&(Eg=FE()),Eg(ye,t,e)});function jE(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}});var kg=D((Qle,BE)=>{"use strict";BE.exports=Dn;var Yl=Yn().codes,vU=Yl.ERR_METHOD_NOT_IMPLEMENTED,bU=Yl.ERR_MULTIPLE_CALLBACK,wU=Yl.ERR_TRANSFORM_ALREADY_TRANSFORMING,_U=Yl.ERR_TRANSFORM_WITH_LENGTH_0,Jl=ki();Xo()(Dn,Jl);function EU(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new bU);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Dn(t){if(!(this instanceof Dn))return new Dn(t);Jl.call(this,t),this._transformState={afterTransform:EU.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",CU)}function CU(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){LE(t,e,r)}):LE(this,null,null)}Dn.prototype.push=function(t,e){return this._transformState.needTransform=!1,Jl.prototype.push.call(this,t,e)};Dn.prototype._transform=function(t,e,r){r(new vU("_transform()"))};Dn.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Dn.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};Dn.prototype._destroy=function(t,e){Jl.prototype._destroy.call(this,t,function(r){e(r)})};function LE(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new _U;if(t._transformState.transforming)throw new wU;return t.push(null)}});var UE=D((efe,ME)=>{"use strict";ME.exports=gu;var qE=kg();Xo()(gu,qE);function gu(t){if(!(this instanceof gu))return new gu(t);qE.call(this,t)}gu.prototype._transform=function(t,e,r){r(null,t)}});var WE=D((tfe,GE)=>{"use strict";var Tg;function SU(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var zE=Yn().codes,xU=zE.ERR_MISSING_ARGS,FU=zE.ERR_STREAM_DESTROYED;function HE(t){if(t)throw t}function OU(t){return t.setHeader&&typeof t.abort=="function"}function AU(t,e,r,n){n=SU(n);var i=!1;t.on("close",function(){i=!0}),Tg===void 0&&(Tg=Hl()),Tg(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,OU(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new FU("pipe"))}}}function VE(t){t()}function kU(t,e){return t.pipe(e)}function TU(t){return!t.length||typeof t[t.length-1]!="function"?HE:t.pop()}function PU(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=TU(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new xU("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,c=a>0;return AU(s,u,c,function(l){i||(i=l),l&&o.forEach(VE),!u&&(o.forEach(VE),n(i))})});return e.reduce(kU)}GE.exports=PU});var KE=D((yr,Du)=>{var yu=require("stream");process.env.READABLE_STREAM==="disable"&&yu?(Du.exports=yu.Readable,Object.assign(Du.exports,yu),Du.exports.Stream=yu):(yr=Du.exports=mg(),yr.Stream=yu||yr,yr.Readable=yr,yr.Writable=dg(),yr.Duplex=ki(),yr.Transform=kg(),yr.PassThrough=UE(),yr.finished=Hl(),yr.pipeline=WE())});var Rg=D(Pg=>{var YE;(function(t){typeof DO_NOT_EXPORT_CRC>"u"?typeof Pg=="object"?t(Pg):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(YE={}):t(YE={})})(function(t){t.version="1.2.2";function e(){for(var F=0,L=new Array(256),x=0;x!=256;++x)F=x,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,F=F&1?-306674912^F>>>1:F>>>1,L[x]=F;return typeof Int32Array<"u"?new Int32Array(L):L}var r=e();function n(F){var L=0,x=0,I=0,R=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(I=0;I!=256;++I)R[I]=F[I];for(I=0;I!=256;++I)for(x=F[I],L=256+I;L<4096;L+=256)x=R[L]=x>>>8^F[x&255];var B=[];for(I=1;I!=16;++I)B[I-1]=typeof Int32Array<"u"?R.subarray(I*256,I*256+256):R.slice(I*256,I*256+256);return B}var i=n(r),o=i[0],s=i[1],a=i[2],u=i[3],c=i[4],l=i[5],f=i[6],h=i[7],d=i[8],p=i[9],b=i[10],g=i[11],w=i[12],S=i[13],y=i[14];function C(F,L){for(var x=L^-1,I=0,R=F.length;I<R;)x=x>>>8^r[(x^F.charCodeAt(I++))&255];return~x}function k(F,L){for(var x=L^-1,I=F.length-15,R=0;R<I;)x=y[F[R++]^x&255]^S[F[R++]^x>>8&255]^w[F[R++]^x>>16&255]^g[F[R++]^x>>>24]^b[F[R++]]^p[F[R++]]^d[F[R++]]^h[F[R++]]^f[F[R++]]^l[F[R++]]^c[F[R++]]^u[F[R++]]^a[F[R++]]^s[F[R++]]^o[F[R++]]^r[F[R++]];for(I+=15;R<I;)x=x>>>8^r[(x^F[R++])&255];return~x}function $(F,L){for(var x=L^-1,I=0,R=F.length,B=0,q=0;I<R;)B=F.charCodeAt(I++),B<128?x=x>>>8^r[(x^B)&255]:B<2048?(x=x>>>8^r[(x^(192|B>>6&31))&255],x=x>>>8^r[(x^(128|B&63))&255]):B>=55296&&B<57344?(B=(B&1023)+64,q=F.charCodeAt(I++)&1023,x=x>>>8^r[(x^(240|B>>8&7))&255],x=x>>>8^r[(x^(128|B>>2&63))&255],x=x>>>8^r[(x^(128|q>>6&15|(B&3)<<4))&255],x=x>>>8^r[(x^(128|q&63))&255]):(x=x>>>8^r[(x^(224|B>>12&15))&255],x=x>>>8^r[(x^(128|B>>6&63))&255],x=x>>>8^r[(x^(128|B&63))&255]);return~x}t.table=r,t.bstr=C,t.buf=k,t.str=$})});var XE=D((nfe,JE)=>{"use strict";var{Transform:RU}=KE(),$U=Rg(),$g=class extends RU{constructor(e){super(e),this.checksum=Buffer.allocUnsafe(4),this.checksum.writeInt32BE(0,0),this.rawSize=0}_transform(e,r,n){e&&(this.checksum=$U.buf(e,this.checksum)>>>0,this.rawSize+=e.length),n(null,e)}digest(e){let r=Buffer.allocUnsafe(4);return r.writeUInt32BE(this.checksum>>>0,0),e?r.toString(e):r}hex(){return this.digest("hex").toUpperCase()}size(){return this.rawSize}};JE.exports=$g});var QE=D((ife,ZE)=>{"use strict";var{DeflateRaw:IU}=require("zlib"),jU=Rg(),Ig=class extends IU{constructor(e){super(e),this.checksum=Buffer.allocUnsafe(4),this.checksum.writeInt32BE(0,0),this.rawSize=0,this.compressedSize=0}push(e,r){return e&&(this.compressedSize+=e.length),super.push(e,r)}_transform(e,r,n){e&&(this.checksum=jU.buf(e,this.checksum)>>>0,this.rawSize+=e.length),super._transform(e,r,n)}digest(e){let r=Buffer.allocUnsafe(4);return r.writeUInt32BE(this.checksum>>>0,0),e?r.toString(e):r}hex(){return this.digest("hex").toUpperCase()}size(e=!1){return e?this.compressedSize:this.rawSize}};ZE.exports=Ig});var tC=D((ofe,eC)=>{"use strict";eC.exports={CRC32Stream:XE(),DeflateCRC32Stream:QE()}});var vu=D(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.checksum=rs.checksumFile=void 0;var NU=require("fs"),LU=require("crypto"),nC=require("stream"),BU=require("util"),{CRC32Stream:qU}=tC(),rC=(0,BU.promisify)(nC.pipeline),MU=(t,e,r)=>iC(NU.createReadStream(t),e,r);rs.checksumFile=MU;async function iC(t,e,r="hex"){let n=HU(t);if(e==="crc32"){let o=new qU,s=rC(n,o);return o.resume(),await s,o.end(),Buffer.from(o.digest()).toString(r)}let i=(0,LU.createHash)(e);return await rC(n,i),i.end(),i.digest(r)}rs.checksum=iC;function UU(t){return t!=null&&typeof t=="object"&&typeof t.read=="function"&&typeof t.pipe=="function"}var HU=t=>UU(t)?t:new nC.Readable({read(){this.push(t),this.push(null)}})});var jg=D((afe,oC)=>{oC.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Xl=D(aC=>{var sC={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function VU(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,n)=>e[n]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(sC))aC[t]=VU(sC[t])});var dC=D((cfe,fC)=>{var zU=require("fs"),at=require("path"),uC=jg(),GU=Xl(),WU=typeof process=="object"&&process.platform==="win32",cC=t=>typeof t=="object"&&t!==null,lC=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)e&1?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Je(t){this.sep=at.sep,this.fs=zU,cC(t)&&cC(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}fC.exports=Je;Je.prototype.makeDir=function(t){let e=this;function r(n){let i=n.split(e.sep)[0];n.split(e.sep).forEach(function(o){if(!(!o||o.substr(-1,1)===":")){i+=e.sep+o;var s;try{s=e.fs.statSync(i)}catch{e.fs.mkdirSync(i)}if(s&&s.isFile())throw GU.FILE_IN_THE_WAY(`"${i}"`)}})}r(t)};Je.prototype.writeFileTo=function(t,e,r,n){let i=this;if(i.fs.existsSync(t)){if(!r)return!1;var o=i.fs.statSync(t);if(o.isDirectory())return!1}var s=at.dirname(t);i.fs.existsSync(s)||i.makeDir(s);var a;try{a=i.fs.openSync(t,"w",438)}catch{i.fs.chmodSync(t,438),a=i.fs.openSync(t,"w",438)}if(a)try{i.fs.writeSync(a,e,0,e.length,0)}finally{i.fs.closeSync(a)}return i.fs.chmodSync(t,n||438),!0};Je.prototype.writeFileToAsync=function(t,e,r,n,i){typeof n=="function"&&(i=n,n=void 0);let o=this;o.fs.exists(t,function(s){if(s&&!r)return i(!1);o.fs.stat(t,function(a,u){if(s&&u.isDirectory())return i(!1);var c=at.dirname(t);o.fs.exists(c,function(l){l||o.makeDir(c),o.fs.open(t,"w",438,function(f,h){f?o.fs.chmod(t,438,function(){o.fs.open(t,"w",438,function(d,p){o.fs.write(p,e,0,e.length,0,function(){o.fs.close(p,function(){o.fs.chmod(t,n||438,function(){i(!0)})})})})}):h?o.fs.write(h,e,0,e.length,0,function(){o.fs.close(h,function(){o.fs.chmod(t,n||438,function(){i(!0)})})}):o.fs.chmod(t,n||438,function(){i(!0)})})})})})};Je.prototype.findFiles=function(t){let e=this;function r(n,i,o){typeof i=="boolean"&&(o=i,i=void 0);let s=[];return e.fs.readdirSync(n).forEach(function(a){let u=at.join(n,a),c=e.fs.statSync(u);(!i||i.test(u))&&s.push(at.normalize(u)+(c.isDirectory()?e.sep:"")),c.isDirectory()&&o&&(s=s.concat(r(u,i,o)))}),s}return r(t,void 0,!0)};Je.prototype.findFilesAsync=function(t,e){let r=this,n=[];r.fs.readdir(t,function(i,o){if(i)return e(i);let s=o.length;if(!s)return e(null,n);o.forEach(function(a){a=at.join(t,a),r.fs.stat(a,function(u,c){if(u)return e(u);c&&(n.push(at.normalize(a)+(c.isDirectory()?r.sep:"")),c.isDirectory()?r.findFilesAsync(a,function(l,f){if(l)return e(l);n=n.concat(f),--s||e(null,n)}):--s||e(null,n))})})})};Je.prototype.getAttributes=function(){};Je.prototype.setAttributes=function(){};Je.crc32update=function(t,e){return lC[(t^e)&255]^t>>>8};Je.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let n=0;n<e;)r=Je.crc32update(r,t[n++]);return~r>>>0};Je.methodToString=function(t){switch(t){case uC.STORED:return"STORED ("+t+")";case uC.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Je.canonical=function(t){if(!t)return"";let e=at.posix.normalize("/"+t.split("\\").join("/"));return at.join(".",e)};Je.zipnamefix=function(t){if(!t)return"";let e=at.posix.normalize("/"+t.split("\\").join("/"));return at.posix.join(".",e)};Je.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let n=r-1;n>=0;n--)if(e(t[n],n,t))return t[n]};Je.sanitize=function(t,e){t=at.resolve(at.normalize(t));for(var r=e.split("/"),n=0,i=r.length;n<i;n++){var o=at.normalize(at.join(t,r.slice(n,i).join(at.sep)));if(o.indexOf(t)===0)return o}return at.normalize(at.join(t,at.basename(e)))};Je.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Je.readBigUInt64LE=function(t,e){var r=Buffer.from(t.slice(e,e+8));return r.swap64(),parseInt(`0x${r.toString("hex")}`)};Je.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Je.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Je.isWin=WU;Je.crcTable=lC});var pC=D((lfe,hC)=>{var KU=require("path");hC.exports=function(t,{fs:e}){var r=t||"",n=o(),i=null;function o(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(i=e.statSync(r),n.directory=i.isDirectory(),n.mtime=i.mtime,n.atime=i.atime,n.executable=(73&i.mode)!==0,n.readonly=(128&i.mode)===0,n.hidden=KU.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return n.directory},get readOnly(){return n.readonly},get hidden(){return n.hidden},get mtime(){return n.mtime},get atime(){return n.atime},get executable(){return n.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:n.directory,isReadOnly:n.readonly,isHidden:n.hidden,isExecutable:n.executable,mTime:n.mtime,aTime:n.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var gC=D((ffe,mC)=>{mC.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var is=D((dfe,ns)=>{ns.exports=dC();ns.exports.Constants=jg();ns.exports.Errors=Xl();ns.exports.FileAttr=pC();ns.exports.decoder=gC()});var DC=D((hfe,yC)=>{var ei=is(),H=ei.Constants;yC.exports=function(){var t=20,e=10,r=0,n=0,i=0,o=0,s=0,a=0,u=0,c=0,l=0,f=0,h=0,d=0,p=0;t|=ei.isWin?2560:768,r|=H.FLG_EFS;let b={extraLen:0},g=y=>Math.max(0,y)>>>0,w=y=>Math.max(0,y)&65535,S=y=>Math.max(0,y)&255;return i=ei.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&H.FLG_EFS)>0},set flags_efs(y){y?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(y){y?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return n},set method(y){switch(y){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}n=y},get time(){return ei.fromDOS2Date(this.timeval)},set time(y){this.timeval=ei.fromDate2DOS(y)},get timeval(){return i},set timeval(y){i=g(y)},get timeHighByte(){return S(i>>>8)},get crc(){return o},set crc(y){o=g(y)},get compressedSize(){return s},set compressedSize(y){s=g(y)},get size(){return a},set size(y){a=g(y)},get fileNameLength(){return u},set fileNameLength(y){u=y},get extraLength(){return c},set extraLength(y){c=y},get extraLocalLength(){return b.extraLen},set extraLocalLength(y){b.extraLen=y},get commentLength(){return l},set commentLength(y){l=y},get diskNumStart(){return f},set diskNumStart(y){f=g(y)},get inAttr(){return h},set inAttr(y){h=g(y)},get attr(){return d},set attr(y){d=g(y)},get fileAttr(){return(d||0)>>16&4095},get offset(){return p},set offset(y){p=g(y)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+u+c+l},get realDataOffset(){return p+H.LOCHDR+b.fnameLen+b.extraLen},get localHeader(){return b},loadLocalHeaderFromBinary:function(y){var C=y.slice(p,p+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw ei.Errors.INVALID_LOC();b.version=C.readUInt16LE(H.LOCVER),b.flags=C.readUInt16LE(H.LOCFLG),b.method=C.readUInt16LE(H.LOCHOW),b.time=C.readUInt32LE(H.LOCTIM),b.crc=C.readUInt32LE(H.LOCCRC),b.compressedSize=C.readUInt32LE(H.LOCSIZ),b.size=C.readUInt32LE(H.LOCLEN),b.fnameLen=C.readUInt16LE(H.LOCNAM),b.extraLen=C.readUInt16LE(H.LOCEXT);let k=p+H.LOCHDR+b.fnameLen,$=k+b.extraLen;return y.slice(k,$)},loadFromBinary:function(y){if(y.length!==H.CENHDR||y.readUInt32LE(0)!==H.CENSIG)throw ei.Errors.INVALID_CEN();t=y.readUInt16LE(H.CENVEM),e=y.readUInt16LE(H.CENVER),r=y.readUInt16LE(H.CENFLG),n=y.readUInt16LE(H.CENHOW),i=y.readUInt32LE(H.CENTIM),o=y.readUInt32LE(H.CENCRC),s=y.readUInt32LE(H.CENSIZ),a=y.readUInt32LE(H.CENLEN),u=y.readUInt16LE(H.CENNAM),c=y.readUInt16LE(H.CENEXT),l=y.readUInt16LE(H.CENCOM),f=y.readUInt16LE(H.CENDSK),h=y.readUInt16LE(H.CENATT),d=y.readUInt32LE(H.CENATX),p=y.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(H.LOCHDR);return y.writeUInt32LE(H.LOCSIG,0),y.writeUInt16LE(e,H.LOCVER),y.writeUInt16LE(r,H.LOCFLG),y.writeUInt16LE(n,H.LOCHOW),y.writeUInt32LE(i,H.LOCTIM),y.writeUInt32LE(o,H.LOCCRC),y.writeUInt32LE(s,H.LOCSIZ),y.writeUInt32LE(a,H.LOCLEN),y.writeUInt16LE(u,H.LOCNAM),y.writeUInt16LE(b.extraLen,H.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(H.CENHDR+u+c+l);return y.writeUInt32LE(H.CENSIG,0),y.writeUInt16LE(t,H.CENVEM),y.writeUInt16LE(e,H.CENVER),y.writeUInt16LE(r,H.CENFLG),y.writeUInt16LE(n,H.CENHOW),y.writeUInt32LE(i,H.CENTIM),y.writeUInt32LE(o,H.CENCRC),y.writeUInt32LE(s,H.CENSIZ),y.writeUInt32LE(a,H.CENLEN),y.writeUInt16LE(u,H.CENNAM),y.writeUInt16LE(c,H.CENEXT),y.writeUInt16LE(l,H.CENCOM),y.writeUInt16LE(f,H.CENDSK),y.writeUInt16LE(h,H.CENATT),y.writeUInt32LE(d,H.CENATX),y.writeUInt32LE(p,H.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:ei.methodToString(n),time:this.time,crc:"0x"+o.toString(16).toUpperCase(),compressedSize:y(s),size:y(a),fileNameLength:y(u),extraLength:y(c),commentLength:y(l),diskNumStart:f,inAttr:h,attr:d,offset:p,centralHeaderSize:y(H.CENHDR+u+c+l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bC=D((pfe,vC)=>{var os=is(),Me=os.Constants;vC.exports=function(){var t=0,e=0,r=0,n=0,i=0;return{get diskEntries(){return t},set diskEntries(o){t=e=o},get totalEntries(){return e},set totalEntries(o){e=t=o},get size(){return r},set size(o){r=o},get offset(){return n},set offset(o){n=o},get commentLength(){return i},set commentLength(o){i=o},get mainHeaderSize(){return Me.ENDHDR+i},loadFromBinary:function(o){if((o.length!==Me.ENDHDR||o.readUInt32LE(0)!==Me.ENDSIG)&&(o.length<Me.ZIP64HDR||o.readUInt32LE(0)!==Me.ZIP64SIG))throw os.Errors.INVALID_END();o.readUInt32LE(0)===Me.ENDSIG?(t=o.readUInt16LE(Me.ENDSUB),e=o.readUInt16LE(Me.ENDTOT),r=o.readUInt32LE(Me.ENDSIZ),n=o.readUInt32LE(Me.ENDOFF),i=o.readUInt16LE(Me.ENDCOM)):(t=os.readBigUInt64LE(o,Me.ZIP64SUB),e=os.readBigUInt64LE(o,Me.ZIP64TOT),r=os.readBigUInt64LE(o,Me.ZIP64SIZE),n=os.readBigUInt64LE(o,Me.ZIP64OFF),i=0)},toBinary:function(){var o=Buffer.alloc(Me.ENDHDR+i);return o.writeUInt32LE(Me.ENDSIG,0),o.writeUInt32LE(0,4),o.writeUInt16LE(t,Me.ENDSUB),o.writeUInt16LE(e,Me.ENDTOT),o.writeUInt32LE(r,Me.ENDSIZ),o.writeUInt32LE(n,Me.ENDOFF),o.writeUInt16LE(i,Me.ENDCOM),o.fill(" ",Me.ENDHDR),o},toJSON:function(){let o=function(s,a){let u=s.toString(16).toUpperCase();for(;u.length<a;)u="0"+u;return"0x"+u};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:o(n,4),commentLength:i}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Lg=D(Ng=>{Ng.EntryHeader=DC();Ng.MainHeader=bC()});var _C=D((gfe,wC)=>{wC.exports=function(t){var e=require("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(n){var i=e.createDeflateRaw(r),o=[],s=0;i.on("data",function(a){o.push(a),s+=a.length}),i.on("end",function(){var a=Buffer.alloc(s),u=0;a.fill(0);for(var c=0;c<o.length;c++){var l=o[c];l.copy(a,u),u+=l.length}n&&n(a)}),i.end(t)}}}});var CC=D((yfe,EC)=>{var YU=+(process.versions?process.versions.node:"").split(".")[0]||0;EC.exports=function(t,e){var r=require("zlib");let n=YU>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,n)},inflateAsync:function(i){var o=r.createInflateRaw(n),s=[],a=0;o.on("data",function(u){s.push(u),a+=u.length}),o.on("end",function(){var u=Buffer.alloc(a),c=0;u.fill(0);for(var l=0;l<s.length;l++){var f=s[l];f.copy(u,c),c+=f.length}i&&i(u)}),o.end(t)}}}});var AC=D((Dfe,OC)=>{"use strict";var{randomFillSync:SC}=require("crypto"),JU=Xl(),XU=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)e&1?e=e>>>1^3988292384:e>>>=1;return e>>>0}),FC=(t,e)=>Math.imul(t,e)>>>0,xC=(t,e)=>XU[(t^e)&255]^t>>>8,bu=()=>typeof SC=="function"?SC(Buffer.alloc(12)):bu.node();bu.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var Zl={genSalt:bu};function Ql(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}Ql.prototype.updateKeys=function(t){let e=this.keys;return e[0]=xC(e[0],t),e[1]+=e[0]&255,e[1]=FC(e[1],134775813)+1,e[2]=xC(e[2],e[1]>>>24),t};Ql.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return FC(t,t^1)>>8&255};function ZU(t){let e=new Ql(t);return function(r){let n=Buffer.alloc(r.length),i=0;for(let o of r)n[i++]=e.updateKeys(o^e.next());return n}}function QU(t){let e=new Ql(t);return function(r,n,i=0){n||(n=Buffer.alloc(r.length));for(let o of r){let s=e.next();n[i++]=o^s,e.updateKeys(o)}return n}}function e9(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let n=ZU(r),i=n(t.slice(0,12)),o=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(i[11]!==o)throw JU.WRONG_PASSWORD();return n(t.slice(12))}function t9(t){Buffer.isBuffer(t)&&t.length>=12?Zl.genSalt=function(){return t.slice(0,12)}:t==="node"?Zl.genSalt=bu.node:Zl.genSalt=bu}function r9(t,e,r,n=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let i=QU(r),o=Zl.genSalt();o[11]=e.crc>>>24&255,n&&(o[10]=e.crc>>>16&255);let s=Buffer.alloc(t.length+12);return i(o,s),i(t,s,12)}OC.exports={decrypt:e9,encrypt:r9,_salter:t9}});var kC=D(ef=>{ef.Deflater=_C();ef.Inflater=CC();ef.ZipCrypto=AC()});var qg=D((bfe,TC)=>{var be=is(),n9=Lg(),Xe=be.Constants,Bg=kC();TC.exports=function(t,e){var r=new n9.EntryHeader,n=Buffer.alloc(0),i=Buffer.alloc(0),o=!1,s=null,a=Buffer.alloc(0),u=Buffer.alloc(0),c=!0;let l=t,f=typeof l.decoder=="object"?l.decoder:be.decoder;c=f.hasOwnProperty("efs")?f.efs:!1;function h(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(u=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function d(y){if(r.flags_desc){let C={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Xe.LOCSIG||e.readUInt32LE(k)==Xe.CENSIG)throw be.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Xe.EXTSIG)C.crc=e.readUInt32LE(k+Xe.EXTCRC),C.compressedSize=e.readUInt32LE(k+Xe.EXTSIZ),C.size=e.readUInt32LE(k+Xe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)C.crc=e.readUInt32LE(k+Xe.EXTCRC-4),C.compressedSize=e.readUInt32LE(k+Xe.EXTSIZ-4),C.size=e.readUInt32LE(k+Xe.EXTLEN-4);else throw be.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw be.Errors.DESCRIPTOR_FAULTY();if(be.crc32(y)!==C.crc)return!1}else if(be.crc32(y)!==r.localHeader.crc)return!1;return!0}function p(y,C,k){if(typeof C>"u"&&typeof y=="string"&&(k=y,y=void 0),o)return y&&C&&C(Buffer.alloc(0),be.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var $=h();if($.length===0)return y&&C&&C($),$;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw be.Errors.INVALID_PASS_PARAM();$=Bg.ZipCrypto.decrypt($,r,k)}var F=Buffer.alloc(r.size);switch(r.method){case be.Constants.STORED:if($.copy(F),d(F))return y&&C&&C(F),F;throw y&&C&&C(F,be.Errors.BAD_CRC()),be.Errors.BAD_CRC();case be.Constants.DEFLATED:var L=new Bg.Inflater($,r.size);if(y)L.inflateAsync(function(x){x.copy(x,0),C&&(d(x)?C(x):C(x,be.Errors.BAD_CRC()))});else{if(L.inflate(F).copy(F,0),!d(F))throw be.Errors.BAD_CRC(`"${f.decode(n)}"`);return F}break;default:throw y&&C&&C(Buffer.alloc(0),be.Errors.UNKNOWN_METHOD()),be.Errors.UNKNOWN_METHOD()}}function b(y,C){if((!s||!s.length)&&Buffer.isBuffer(e))return y&&C&&C(h()),h();if(s.length&&!o){var k;switch(r.method){case be.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(s.length),s.copy(k),y&&C&&C(k),k;default:case be.Constants.DEFLATED:var $=new Bg.Deflater(s);if(y)$.deflateAsync(function(L){k=Buffer.alloc(L.length),r.compressedSize=L.length,L.copy(k),C&&C(k)});else{var F=$.deflate();return r.compressedSize=F.length,F}$=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function g(y,C){return(y.readUInt32LE(C+4)<<4)+y.readUInt32LE(C)}function w(y){try{for(var C=0,k,$,F;C+4<y.length;)k=y.readUInt16LE(C),C+=2,$=y.readUInt16LE(C),C+=2,F=y.slice(C,C+$),C+=$,Xe.ID_ZIP64===k&&S(F)}catch{throw be.Errors.EXTRA_FIELD_PARSE_ERROR()}}function S(y){var C,k,$,F;y.length>=Xe.EF_ZIP64_SCOMP&&(C=g(y,Xe.EF_ZIP64_SUNCOMP),r.size===Xe.EF_ZIP64_OR_32&&(r.size=C)),y.length>=Xe.EF_ZIP64_RHO&&(k=g(y,Xe.EF_ZIP64_SCOMP),r.compressedSize===Xe.EF_ZIP64_OR_32&&(r.compressedSize=k)),y.length>=Xe.EF_ZIP64_DSN&&($=g(y,Xe.EF_ZIP64_RHO),r.offset===Xe.EF_ZIP64_OR_32&&(r.offset=$)),y.length>=Xe.EF_ZIP64_DSN+4&&(F=y.readUInt32LE(Xe.EF_ZIP64_DSN),r.diskNumStart===Xe.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return f.decode(n)},get rawEntryName(){return n},set entryName(y){n=be.toBuffer(y,f.encode);var C=n[n.length-1];o=C===47||C===92,r.fileNameLength=n.length},get efs(){return typeof c=="function"?c(this.entryName):c},get extra(){return a},set extra(y){a=y,r.extraLength=y.length,w(y)},get comment(){return f.decode(i)},set comment(y){if(i=be.toBuffer(y,f.encode),r.commentLength=i.length,i.length>65535)throw be.Errors.COMMENT_TOO_LONG()},get name(){var y=f.decode(n);return o?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return o},getCompressedData:function(){return b(!1,null)},getCompressedDataAsync:function(y){b(!0,y)},setData:function(y){s=be.toBuffer(y,be.decoder.encode),!o&&s.length?(r.size=s.length,r.method=be.Constants.DEFLATED,r.crc=be.crc32(y),r.changed=!0):r.method=be.Constants.STORED},getData:function(y){return r.changed?s:p(!1,null,y)},getDataAsync:function(y,C){r.changed?y(s):p(!0,y,C)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=a.length;var y=r.centralHeaderToBinary(),C=be.Constants.CENHDR;return n.copy(y,C),C+=n.length,a.copy(y,C),C+=r.extraLength,i.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=u.length;let C=r.localHeaderToBinary(),k=Buffer.alloc(C.length+n.length+r.extraLocalLength);return C.copy(k,y),y+=C.length,n.copy(k,y),y+=n.length,u.copy(k,y),y+=u.length,k},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(s)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var $C=D((wfe,RC)=>{var PC=qg(),i9=Lg(),bt=is();RC.exports=function(t,e){var r=[],n={},i=Buffer.alloc(0),o=new i9.MainHeader,s=!1,a=null;let u=new Set,c=e,{noSort:l,decoder:f}=c;t?p(c.readEntries):s=!0;function h(){let g=new Set;for(let w of Object.keys(n)){let S=w.split("/");if(S.pop(),!!S.length)for(let y=0;y<S.length;y++){let C=S.slice(0,y+1).join("/")+"/";g.add(C)}}for(let w of g)if(!(w in n)){let S=new PC(c);S.entryName=w,S.attr=16,S.temporary=!0,r.push(S),n[S.entryName]=S,u.add(S)}}function d(){if(s=!0,n={},o.diskEntries>(t.length-o.offset)/bt.Constants.CENHDR)throw bt.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(o.diskEntries);for(var g=o.offset,w=0;w<r.length;w++){var S=g,y=new PC(c,t);y.header=t.slice(S,S+=bt.Constants.CENHDR),y.entryName=t.slice(S,S+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(S,S+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(S,S+y.header.commentLength)),g+=y.header.centralHeaderSize,r[w]=y,n[y.entryName]=y}u.clear(),h()}function p(g){var w=t.length-bt.Constants.ENDHDR,S=Math.max(0,w-65535),y=S,C=t.length,k=-1,$=0;for((typeof c.trailingSpace=="boolean"?c.trailingSpace:!1)&&(S=0),w;w>=y;w--)if(t[w]===80){if(t.readUInt32LE(w)===bt.Constants.ENDSIG){k=w,$=w,C=w+bt.Constants.ENDHDR,y=w-bt.Constants.END64HDR;continue}if(t.readUInt32LE(w)===bt.Constants.END64SIG){y=S;continue}if(t.readUInt32LE(w)===bt.Constants.ZIP64SIG){k=w,C=w+bt.readBigUInt64LE(t,w+bt.Constants.ZIP64SIZE)+bt.Constants.ZIP64LEAD;break}}if(k==-1)throw bt.Errors.INVALID_FORMAT();o.loadFromBinary(t.slice(k,C)),o.commentLength&&(i=t.slice($+bt.Constants.ENDHDR)),g&&d()}function b(){r.length>1&&!l&&r.sort((g,w)=>g.entryName.toLowerCase().localeCompare(w.entryName.toLowerCase()))}return{get entries(){return s||d(),r.filter(g=>!u.has(g))},get comment(){return f.decode(i)},set comment(g){i=bt.toBuffer(g,f.encode),o.commentLength=i.length},getEntryCount:function(){return s?r.length:o.diskEntries},forEach:function(g){this.entries.forEach(g)},getEntry:function(g){return s||d(),n[g]||null},setEntry:function(g){s||d(),r.push(g),n[g.entryName]=g,o.totalEntries=r.length},deleteFile:function(g,w=!0){s||d();let S=n[g];this.getEntryChildren(S,w).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(g){s||d();let w=n[g],S=r.indexOf(w);S>=0&&(r.splice(S,1),delete n[g],o.totalEntries=r.length)},getEntryChildren:function(g,w=!0){if(s||d(),typeof g=="object")if(g.isDirectory&&w){let S=[],y=g.entryName;for(let C of r)C.entryName.startsWith(y)&&S.push(C);return S}else return[g];return[]},getChildCount:function(g){if(g&&g.isDirectory){let w=this.getEntryChildren(g);return w.includes(g)?w.length-1:w.length}return 0},compressToBuffer:function(){s||d(),b();let g=[],w=[],S=0,y=0;o.size=0,o.offset=0;let C=0;for(let F of this.entries){let L=F.getCompressedData();F.header.offset=y;let x=F.packLocalHeader(),I=x.length+L.length;y+=I,g.push(x),g.push(L);let R=F.packCentralHeader();w.push(R),o.size+=R.length,S+=I+R.length,C++}S+=o.mainHeaderSize,o.offset=y,o.totalEntries=C,y=0;let k=Buffer.alloc(S);for(let F of g)F.copy(k,y),y+=F.length;for(let F of w)F.copy(k,y),y+=F.length;let $=o.toBinary();return i&&i.copy($,bt.Constants.ENDHDR),$.copy(k,y),t=k,s=!1,k},toAsyncBuffer:function(g,w,S,y){try{s||d(),b();let C=[],k=[],$=0,F=0,L=0;o.size=0,o.offset=0;let x=function(I){if(I.length>0){let R=I.shift(),B=R.entryName+R.extra.toString();S&&S(B),R.getCompressedDataAsync(function(q){y&&y(B),R.header.offset=F;let K=R.packLocalHeader(),M=K.length+q.length;F+=M,C.push(K),C.push(q);let E=R.packCentralHeader();k.push(E),o.size+=E.length,$+=M+E.length,L++,x(I)})}else{$+=o.mainHeaderSize,o.offset=F,o.totalEntries=L,F=0;let R=Buffer.alloc($);C.forEach(function(q){q.copy(R,F),F+=q.length}),k.forEach(function(q){q.copy(R,F),F+=q.length});let B=o.toBinary();i&&i.copy(B,bt.Constants.ENDHDR),B.copy(R,F),t=R,s=!1,g(R)}};x(Array.from(this.entries))}catch(C){w(C)}}}}});var NC=D((_fe,jC)=>{var Ue=is(),Ze=require("path"),o9=qg(),s9=$C(),Ii=(...t)=>Ue.findLast(t,e=>typeof e=="boolean"),IC=(...t)=>Ue.findLast(t,e=>typeof e=="string"),a9=(...t)=>Ue.findLast(t,e=>typeof e=="function"),u9={noSort:!1,readEntries:!1,method:Ue.Constants.NONE,fs:null};jC.exports=function(t,e){let r=null,n=Object.assign(Object.create(null),u9);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(n,t),t=n.input?n.input:void 0,n.input&&delete n.input),Buffer.isBuffer(t)&&(r=t,n.method=Ue.Constants.BUFFER,t=void 0)),Object.assign(n,e);let i=new Ue(n);if((typeof n.decoder!="object"||typeof n.decoder.encode!="function"||typeof n.decoder.decode!="function")&&(n.decoder=Ue.decoder),t&&typeof t=="string")if(i.fs.existsSync(t))n.method=Ue.Constants.FILE,n.filename=t,r=i.fs.readFileSync(t);else throw Ue.Errors.INVALID_FILENAME();let o=new s9(r,n),{canonical:s,sanitize:a,zipnamefix:u}=Ue;function c(d){if(d&&o){var p;if(typeof d=="string"&&(p=o.getEntry(Ze.posix.normalize(d))),typeof d=="object"&&typeof d.entryName<"u"&&typeof d.header<"u"&&(p=o.getEntry(d.entryName)),p)return p}return null}function l(d){let{join:p,normalize:b,sep:g}=Ze.posix;return p(".",b(g+d.split("\\").join(g)+g))}function f(d){return d instanceof RegExp?function(p){return function(b){return p.test(b)}}(d):typeof d!="function"?()=>!0:d}let h=(d,p)=>{let b=p.slice(-1);return b=b===i.sep?i.sep:"",Ze.relative(d,p)+b};return{readFile:function(d,p){var b=c(d);return b&&b.getData(p)||null},childCount:function(d){let p=c(d);if(p)return o.getChildCount(p)},readFileAsync:function(d,p){var b=c(d);b?b.getDataAsync(p):p(null,"getEntry failed for:"+d)},readAsText:function(d,p){var b=c(d);if(b){var g=b.getData();if(g&&g.length)return g.toString(p||"utf8")}return""},readAsTextAsync:function(d,p,b){var g=c(d);g?g.getDataAsync(function(w,S){if(S){p(w,S);return}w&&w.length?p(w.toString(b||"utf8")):p("")}):p("")},deleteFile:function(d,p=!0){var b=c(d);b&&o.deleteFile(b.entryName,p)},deleteEntry:function(d){var p=c(d);p&&o.deleteEntry(p.entryName)},addZipComment:function(d){o.comment=d},getZipComment:function(){return o.comment||""},addZipEntryComment:function(d,p){var b=c(d);b&&(b.comment=p)},getZipEntryComment:function(d){var p=c(d);return p&&p.comment||""},updateFile:function(d,p){var b=c(d);b&&b.setData(p)},addLocalFile:function(d,p,b,g){if(i.fs.existsSync(d)){p=p?l(p):"";let w=Ze.win32.basename(Ze.win32.normalize(d));p+=b||w;let S=i.fs.statSync(d),y=S.isFile()?i.fs.readFileSync(d):Buffer.alloc(0);S.isDirectory()&&(p+=i.sep),this.addFile(p,y,g,S)}else throw Ue.Errors.FILE_NOT_FOUND(d)},addLocalFileAsync:function(d,p){d=typeof d=="object"?d:{localPath:d};let b=Ze.resolve(d.localPath),{comment:g}=d,{zipPath:w,zipName:S}=d,y=this;i.fs.stat(b,function(C,k){if(C)return p(C,!1);w=w?l(w):"";let $=Ze.win32.basename(Ze.win32.normalize(b));if(w+=S||$,k.isFile())i.fs.readFile(b,function(F,L){return F?p(F,!1):(y.addFile(w,L,g,k),setImmediate(p,void 0,!0))});else if(k.isDirectory())return w+=i.sep,y.addFile(w,Buffer.alloc(0),g,k),setImmediate(p,void 0,!0)})},addLocalFolder:function(d,p,b){if(b=f(b),p=p?l(p):"",d=Ze.normalize(d),i.fs.existsSync(d)){let g=i.findFiles(d),w=this;if(g.length)for(let S of g){let y=Ze.join(p,h(d,S));b(y)&&w.addLocalFile(S,Ze.dirname(y))}}else throw Ue.Errors.FILE_NOT_FOUND(d)},addLocalFolderAsync:function(d,p,b,g){g=f(g),b=b?l(b):"",d=Ze.normalize(d);var w=this;i.fs.open(d,"r",function(S){if(S&&S.code==="ENOENT")p(void 0,Ue.Errors.FILE_NOT_FOUND(d));else if(S)p(void 0,S);else{var y=i.findFiles(d),C=-1,k=function(){if(C+=1,C<y.length){var $=y[C],F=h(d,$).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),g(F)?i.fs.stat($,function(L,x){L&&p(void 0,L),x.isFile()?i.fs.readFile($,function(I,R){I?p(void 0,I):(w.addFile(b+F,R,"",x),k())}):(w.addFile(b+F+"/",Buffer.alloc(0),"",x),k())}):process.nextTick(()=>{k()})}else p(!0,void 0)};k()}})},addLocalFolderAsync2:function(d,p){let b=this;d=typeof d=="object"?d:{localPath:d},localPath=Ze.resolve(l(d.localPath));let{zipPath:g,filter:w,namefix:S}=d;w instanceof RegExp?w=function(k){return function($){return k.test($)}}(w):typeof w!="function"&&(w=function(){return!0}),g=g?l(g):"",S=="latin1"&&(S=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof S!="function"&&(S=k=>k);let y=k=>Ze.join(g,S(h(localPath,k))),C=k=>Ze.win32.basename(Ze.win32.normalize(S(k)));i.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?p(void 0,Ue.Errors.FILE_NOT_FOUND(localPath)):k?p(void 0,k):i.findFilesAsync(localPath,function($,F){if($)return p($);F=F.filter(L=>w(y(L))),F.length||p(void 0,!1),setImmediate(F.reverse().reduce(function(L,x){return function(I,R){if(I||R===!1)return setImmediate(L,I,!1);b.addLocalFileAsync({localPath:x,zipPath:Ze.dirname(y(x)),zipName:C(x)},L)}},p))})})},addLocalFolderPromise:function(d,p){return new Promise((b,g)=>{this.addLocalFolderAsync2(Object.assign({localPath:d},p),(w,S)=>{w&&g(w),S&&b(this)})})},addFile:function(d,p,b,g){d=u(d);let w=c(d),S=w!=null;S||(w=new o9(n),w.entryName=d),w.comment=b||"";let y=typeof g=="object"&&g instanceof i.fs.Stats;y&&(w.header.time=g.mtime);var C=w.isDirectory?16:0;let k=w.isDirectory?16384:32768;return y?k|=4095&g.mode:typeof g=="number"?k|=4095&g:k|=w.isDirectory?493:420,C=(C|k<<16)>>>0,w.attr=C,w.setData(p),S||o.setEntry(w),w},getEntries:function(d){return o.password=d,o?o.entries:[]},getEntry:function(d){return c(d)},getEntryCount:function(){return o.getEntryCount()},forEach:function(d){return o.forEach(d)},extractEntryTo:function(d,p,b,g,w,S){g=Ii(!1,g),w=Ii(!1,w),b=Ii(!0,b),S=IC(w,S);var y=c(d);if(!y)throw Ue.Errors.NO_ENTRY();var C=s(y.entryName),k=a(p,S&&!y.isDirectory?S:b?C:Ze.basename(C));if(y.isDirectory){var $=o.getEntryChildren(y);return $.forEach(function(x){if(x.isDirectory)return;var I=x.getData();if(!I)throw Ue.Errors.CANT_EXTRACT_FILE();var R=s(x.entryName),B=a(p,b?R:Ze.basename(R));let q=w?x.header.fileAttr:void 0;i.writeFileTo(B,I,g,q)}),!0}var F=y.getData(o.password);if(!F)throw Ue.Errors.CANT_EXTRACT_FILE();if(i.fs.existsSync(k)&&!g)throw Ue.Errors.CANT_OVERRIDE();let L=w?d.header.fileAttr:void 0;return i.writeFileTo(k,F,g,L),!0},test:function(d){if(!o)return!1;for(var p in o.entries)try{if(p.isDirectory)continue;var b=o.entries[p].getData(d);if(!b)return!1}catch{return!1}return!0},extractAllTo:function(d,p,b,g){if(b=Ii(!1,b),g=IC(b,g),p=Ii(!1,p),!o)throw Ue.Errors.NO_ZIP();o.entries.forEach(function(w){var S=a(d,s(w.entryName));if(w.isDirectory){i.makeDir(S);return}var y=w.getData(g);if(!y)throw Ue.Errors.CANT_EXTRACT_FILE();let C=b?w.header.fileAttr:void 0;i.writeFileTo(S,y,p,C);try{i.fs.utimesSync(S,w.header.time,w.header.time)}catch{throw Ue.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(d,p,b,g){if(g=a9(p,b,g),b=Ii(!1,b),p=Ii(!1,p),!g)return new Promise((k,$)=>{this.extractAllToAsync(d,p,b,function(F){F?$(F):k(this)})});if(!o){g(Ue.Errors.NO_ZIP());return}d=Ze.resolve(d);let w=k=>a(d,Ze.normalize(s(k.entryName))),S=(k,$)=>new Error(k+': "'+$+'"'),y=[],C=[];o.entries.forEach(k=>{k.isDirectory?y.push(k):C.push(k)});for(let k of y){let $=w(k),F=b?k.header.fileAttr:void 0;try{i.makeDir($),F&&i.fs.chmodSync($,F),i.fs.utimesSync($,k.header.time,k.header.time)}catch{g(S("Unable to create folder",$))}}C.reverse().reduce(function(k,$){return function(F){if(F)k(F);else{let L=Ze.normalize(s($.entryName)),x=a(d,L);$.getDataAsync(function(I,R){if(R)k(R);else if(!I)k(Ue.Errors.CANT_EXTRACT_FILE());else{let B=b?$.header.fileAttr:void 0;i.writeFileToAsync(x,I,p,B,function(q){q||k(S("Unable to write file",x)),i.fs.utimes(x,$.header.time,$.header.time,function(K){K?k(S("Unable to set times",x)):k()})})}})}}},g)()},writeZip:function(d,p){if(arguments.length===1&&typeof d=="function"&&(p=d,d=""),!d&&n.filename&&(d=n.filename),!!d){var b=o.compressToBuffer();if(b){var g=i.writeFileTo(d,b,!0);typeof p=="function"&&p(g?null:new Error("failed"),"")}}},writeZipPromise:function(d,p){let{overwrite:b,perm:g}=Object.assign({overwrite:!0},p);return new Promise((w,S)=>{!d&&n.filename&&(d=n.filename),d||S("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=k=>k?w(k):S("ADM-ZIP: Wasn't able to write zip file");i.writeFileToAsync(d,y,b,g,C)},S)})},toBufferPromise:function(){return new Promise((d,p)=>{o.toAsyncBuffer(d,p)})},toBuffer:function(d,p,b,g){return typeof d=="function"?(o.toAsyncBuffer(d,p,b,g),null):o.compressToBuffer()}}}});var ZC=D((Jfe,XC)=>{var JC={};XC.exports=JC;var YC={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(YC).forEach(function(t){var e=YC[t],r=JC[t]=[];r.open="\x1B["+e[0]+"m",r.close="\x1B["+e[1]+"m"})});var eS=D((Xfe,QC)=>{"use strict";QC.exports=function(t,e){e=e||process.argv;var r=e.indexOf("--"),n=/^-{1,2}/.test(t)?"":"--",i=e.indexOf(n+t);return i!==-1&&(r===-1?!0:i<r)}});var rS=D((Zfe,tS)=>{"use strict";var p9=require("os"),Ar=eS(),Tt=process.env,us=void 0;Ar("no-color")||Ar("no-colors")||Ar("color=false")?us=!1:(Ar("color")||Ar("colors")||Ar("color=true")||Ar("color=always"))&&(us=!0);"FORCE_COLOR"in Tt&&(us=Tt.FORCE_COLOR.length===0||parseInt(Tt.FORCE_COLOR,10)!==0);function m9(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function g9(t){if(us===!1)return 0;if(Ar("color=16m")||Ar("color=full")||Ar("color=truecolor"))return 3;if(Ar("color=256"))return 2;if(t&&!t.isTTY&&us!==!0)return 0;var e=us?1:0;if(process.platform==="win32"){var r=p9.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in Tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(i){return i in Tt})||Tt.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in Tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Tt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in Tt){var n=parseInt((Tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Tt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Tt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(Tt.TERM)||"COLORTERM"in Tt?1:(Tt.TERM==="dumb",e)}function Wg(t){var e=g9(t);return m9(e)}tS.exports={supportsColor:Wg,stdout:Wg(process.stdout),stderr:Wg(process.stderr)}});var iS=D((Qfe,nS)=>{nS.exports=function(e,r){var n="";e=e||"Run the trap, drop the bass",e=e.split("");var i={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(o){o=o.toLowerCase();var s=i[o]||[" "],a=Math.floor(Math.random()*s.length);typeof i[o]<"u"?n+=i[o][a]:n+=o}),n}});var sS=D((ede,oS)=>{oS.exports=function(e,r){e=e||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},i=[].concat(n.up,n.down,n.mid);function o(u){var c=Math.floor(Math.random()*u);return c}function s(u){var c=!1;return i.filter(function(l){c=l===u}),c}function a(u,c){var l="",f,h;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",u=u.split("");for(h in u)if(!s(h)){switch(l=l+u[h],f={up:0,down:0,mid:0},c.size){case"mini":f.up=o(8),f.mid=o(2),f.down=o(8);break;case"maxi":f.up=o(16)+3,f.mid=o(4)+1,f.down=o(64)+3;break;default:f.up=o(8)+1,f.mid=o(6)/2,f.down=o(8)+1;break}var d=["up","mid","down"];for(var p in d)for(var b=d[p],g=0;g<=f[b];g++)c[b]&&(l=l+n[b][o(n[b].length)])}return l}return a(e,r)}});var uS=D((tde,aS)=>{aS.exports=function(t){return function(e,r,n){if(e===" ")return e;switch(r%3){case 0:return t.red(e);case 1:return t.white(e);case 2:return t.blue(e)}}}});var lS=D((rde,cS)=>{cS.exports=function(t){return function(e,r,n){return r%2===0?e:t.inverse(e)}}});var dS=D((nde,fS)=>{fS.exports=function(t){var e=["red","yellow","green","blue","magenta"];return function(r,n,i){return r===" "?r:t[e[n++%e.length]](r)}}});var pS=D((ide,hS)=>{hS.exports=function(t){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,i){return r===" "?r:t[e[Math.round(Math.random()*(e.length-2))]](r)}}});var bS=D((sde,vS)=>{var le={};vS.exports=le;le.themes={};var y9=require("util"),ji=le.styles=ZC(),gS=Object.defineProperties,D9=new RegExp(/[\r\n]+/g);le.supportsColor=rS().supportsColor;typeof le.enabled>"u"&&(le.enabled=le.supportsColor()!==!1);le.enable=function(){le.enabled=!0};le.disable=function(){le.enabled=!1};le.stripColors=le.strip=function(t){return(""+t).replace(/\x1B\[\d+m/g,"")};var ode=le.stylize=function(e,r){if(!le.enabled)return e+"";var n=ji[r];return!n&&r in le?le[r](e):n.open+e+n.close},v9=/[|\\{}()[\]^$+*?.]/g,b9=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(v9,"\\$&")};function yS(t){var e=function r(){return _9.apply(r,arguments)};return e._styles=t,e.__proto__=w9,e}var DS=function(){var t={};return ji.grey=ji.gray,Object.keys(ji).forEach(function(e){ji[e].closeRe=new RegExp(b9(ji[e].close),"g"),t[e]={get:function(){return yS(this._styles.concat(e))}}}),t}(),w9=gS(function(){},DS);function _9(){var t=Array.prototype.slice.call(arguments),e=t.map(function(s){return s!=null&&s.constructor===String?s:y9.inspect(s)}).join(" ");if(!le.enabled||!e)return e;for(var r=e.indexOf(`
24
24
  `)!=-1,n=this._styles,i=n.length;i--;){var o=ji[n[i]];e=o.open+e.replace(o.closeRe,o.open)+o.close,r&&(e=e.replace(D9,function(s){return o.close+s+o.open}))}return e}le.setTheme=function(t){if(typeof t=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var e in t)(function(r){le[r]=function(n){if(typeof t[r]=="object"){var i=n;for(var o in t[r])i=le[t[r][o]](i);return i}return le[t[r]](n)}})(e)};function E9(){var t={};return Object.keys(DS).forEach(function(e){t[e]={get:function(){return yS([e])}}}),t}var C9=function(e,r){var n=r.split("");return n=n.map(e),n.join("")};le.trap=iS();le.zalgo=sS();le.maps={};le.maps.america=uS()(le);le.maps.zebra=lS()(le);le.maps.rainbow=dS()(le);le.maps.random=pS()(le);for(mS in le.maps)(function(t){le[t]=function(e){return C9(le.maps[t],e)}})(mS);var mS;gS(le,E9())});var _S=D((ade,wS)=>{var S9=bS();wS.exports=S9});var ES=D(Kg=>{"use strict";Kg.indent=function(e){return new Array(e+1).join(" ")};Kg.getMaxIndexLength=function(t){var e=0;return Object.getOwnPropertyNames(t).forEach(function(r){t[r]!==void 0&&(e=Math.max(e,r.length))}),e}});var CS=D((cde,x9)=>{x9.exports={author:"Rafael de Oleza <rafeca@gmail.com> (https://github.com/rafeca)",name:"prettyjson",description:"Package for formatting JSON data in a coloured YAML-style, perfect for CLI output",version:"1.2.5",homepage:"http://rafeca.com/prettyjson",keywords:["json","cli","formatting","colors"],repository:{type:"git",url:"https://github.com/rafeca/prettyjson.git"},bugs:{url:"https://github.com/rafeca/prettyjson/issues"},main:"./lib/prettyjson",files:["bin/prettyjson","lib/*.js"],license:"MIT",scripts:{test:"npm run jshint && mocha --reporter spec",testwin:"node ./node_modules/mocha/bin/mocha --reporter spec",jshint:"jshint lib/*.js test/*.js",coverage:"istanbul cover _mocha --report lcovonly -- -R spec",coveralls:"npm run coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",changelog:"git log $(git describe --tags --abbrev=0)..HEAD --pretty='* %s' --first-parent"},bin:{prettyjson:"./bin/prettyjson"},dependencies:{colors:"1.4.0",minimist:"^1.2.0"},devDependencies:{coveralls:"^2.11.15",istanbul:"^0.4.5",jshint:"^2.9.4",mocha:"^3.1.2","mocha-lcov-reporter":"^1.2.0",should:"^11.1.1"}}});var SS=D(Eu=>{"use strict";var zr=_S(),ri=ES(),F9=/[^\w\s\n\r\v\t\.,]/i;Eu.version=CS().version;var Yg=function(t,e){return t!==void 0||e.renderUndefined},sf=function(t,e,r){return!!(typeof t=="boolean"||typeof t=="number"||typeof t=="function"||t===null||t===void 0||t instanceof Date||typeof t=="string"&&t.indexOf(`
25
25
  `)===-1||r.inlineArrays&&!e&&Array.isArray(t)&&sf(t[0],!0,r))},O9=function(t,e){if(e.noColor)return t;if(typeof t=="string")return e.stringColor?zr[e.stringColor](t):t;var r=t+"";return t===!0?zr.green(r):t===!1?zr.red(r):t==null?zr.grey(r):typeof t=="number"?t>=0?zr[e.positiveNumberColor](r):zr[e.negativeNumberColor](r):typeof t=="function"?"function() {}":Array.isArray(t)?t.join(", "):r},Jg=function(t,e){return t.multilineStringColor===null||t.noColor?e:zr[t.multilineStringColor](e)},A9=function(t,e,r){var n=t.split(`
26
26
  `);return n=n.map(function(i){return ri.indent(e)+Jg(r,i)}),n.join(`
@@ -197,7 +197,7 @@ tell application "System Events" to get value of property list item "CFBundleNam
197
197
  GFS4: `),console.error(t)});Ge[_t]||(zj=global[_t]||[],Wj(Ge,zj),Ge.close=function(t){function e(r,n){return t.call(Ge,r,function(i){i||Gj(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,qh,{value:t}),e}(Ge.close),Ge.closeSync=function(t){function e(r){t.apply(Ge,arguments),Gj()}return Object.defineProperty(e,qh,{value:t}),e}(Ge.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Eo(Ge[_t]),require("assert").equal(Ge[_t].length,0)}));var zj;global[_t]||Wj(global,Ge[_t]);vb.exports=yb(Jse(Ge));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Ge.__patched&&(vb.exports=yb(Ge),Ge.__patched=!0);function yb(t){Kse(t),t.gracefulify=yb,t.createReadStream=k,t.createWriteStream=$;var e=t.readFile;t.readFile=r;function r(x,I,R){return typeof I=="function"&&(R=I,I=null),B(x,I,R);function B(q,K,M,E){return e(q,K,function(v){v&&(v.code==="EMFILE"||v.code==="ENFILE")?ba([B,[q,K,M],v,E||Date.now(),Date.now()]):typeof M=="function"&&M.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=i;function i(x,I,R,B){return typeof R=="function"&&(B=R,R=null),q(x,I,R,B);function q(K,M,E,v,_){return n(K,M,E,function(O){O&&(O.code==="EMFILE"||O.code==="ENFILE")?ba([q,[K,M,E,v],O,_||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var o=t.appendFile;o&&(t.appendFile=s);function s(x,I,R,B){return typeof R=="function"&&(B=R,R=null),q(x,I,R,B);function q(K,M,E,v,_){return o(K,M,E,function(O){O&&(O.code==="EMFILE"||O.code==="ENFILE")?ba([q,[K,M,E,v],O,_||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=u);function u(x,I,R,B){return typeof R=="function"&&(B=R,R=0),q(x,I,R,B);function q(K,M,E,v,_){return a(K,M,E,function(O){O&&(O.code==="EMFILE"||O.code==="ENFILE")?ba([q,[K,M,E,v],O,_||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}var c=t.readdir;t.readdir=f;var l=/^v[0-5]\./;function f(x,I,R){typeof I=="function"&&(R=I,I=null);var B=l.test(process.version)?function(M,E,v,_){return c(M,q(M,E,v,_))}:function(M,E,v,_){return c(M,E,q(M,E,v,_))};return B(x,I,R);function q(K,M,E,v){return function(_,O){_&&(_.code==="EMFILE"||_.code==="ENFILE")?ba([B,[K,M,E],_,v||Date.now(),Date.now()]):(O&&O.sort&&O.sort(),typeof E=="function"&&E.call(this,_,O))}}}if(process.version.substr(0,4)==="v0.8"){var h=Yse(t);w=h.ReadStream,y=h.WriteStream}var d=t.ReadStream;d&&(w.prototype=Object.create(d.prototype),w.prototype.open=S);var p=t.WriteStream;p&&(y.prototype=Object.create(p.prototype),y.prototype.open=C),Object.defineProperty(t,"ReadStream",{get:function(){return w},set:function(x){w=x},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return y},set:function(x){y=x},enumerable:!0,configurable:!0});var b=w;Object.defineProperty(t,"FileReadStream",{get:function(){return b},set:function(x){b=x},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(t,"FileWriteStream",{get:function(){return g},set:function(x){g=x},enumerable:!0,configurable:!0});function w(x,I){return this instanceof w?(d.apply(this,arguments),this):w.apply(Object.create(w.prototype),arguments)}function S(){var x=this;L(x.path,x.flags,x.mode,function(I,R){I?(x.autoClose&&x.destroy(),x.emit("error",I)):(x.fd=R,x.emit("open",R),x.read())})}function y(x,I){return this instanceof y?(p.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function C(){var x=this;L(x.path,x.flags,x.mode,function(I,R){I?(x.destroy(),x.emit("error",I)):(x.fd=R,x.emit("open",R))})}function k(x,I){return new t.ReadStream(x,I)}function $(x,I){return new t.WriteStream(x,I)}var F=t.open;t.open=L;function L(x,I,R,B){return typeof R=="function"&&(B=R,R=null),q(x,I,R,B);function q(K,M,E,v,_){return F(K,M,E,function(O,j){O&&(O.code==="EMFILE"||O.code==="ENFILE")?ba([q,[K,M,E,v],O,_||Date.now(),Date.now()]):typeof v=="function"&&v.apply(this,arguments)})}}return t}function ba(t){Eo("ENQUEUE",t[0].name,t[1]),Ge[_t].push(t),Db()}var Bh;function Gj(){for(var t=Date.now(),e=0;e<Ge[_t].length;++e)Ge[_t][e].length>2&&(Ge[_t][e][3]=t,Ge[_t][e][4]=t);Db()}function Db(){if(clearTimeout(Bh),Bh=void 0,Ge[_t].length!==0){var t=Ge[_t].shift(),e=t[0],r=t[1],n=t[2],i=t[3],o=t[4];if(i===void 0)Eo("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-i>=6e4){Eo("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-o,u=Math.max(o-i,1),c=Math.min(u*1.2,100);a>=c?(Eo("RETRY",e.name,r),e.apply(null,r.concat([i]))):Ge[_t].push(t)}Bh===void 0&&(Bh=setTimeout(Db,0))}}});var Yj=D(wa=>{"use strict";var Zse=wa&&wa.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(wa,"__esModule",{value:!0});wa.readCAFileSync=void 0;var Qse=Zse(Kj());function eae(t){try{let e=Qse.default.readFileSync(t,"utf8"),r="-----END CERTIFICATE-----";return e.split(r).filter(i=>!!i.trim()).map(i=>`${i.trimLeft()}${r}`)}catch(e){if(e.code==="ENOENT")return;throw e}}wa.readCAFileSync=eae});var Jj=D(Co=>{"use strict";var tae=Co&&Co.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),rae=Co&&Co.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&tae(e,t,r)};Object.defineProperty(Co,"__esModule",{value:!0});rae(Yj(),Co)});var Qj=D((bye,Zj)=>{Zj.exports=Xj;function So(t,e){if(typeof Object.setPrototypeOf=="function")return Object.setPrototypeOf(t,e);t.__proto__=e}function Xj(){this.list=[];var t=null;Object.defineProperty(this,"root",{get:function(){return t},set:function(e){t=e,this.list.length&&So(this.list[this.list.length-1],e)},enumerable:!0,configurable:!0})}Xj.prototype={get length(){return this.list.length},get keys(){var t=[];for(var e in this.list[0])t.push(e);return t},get snapshot(){var t={};return this.keys.forEach(function(e){t[e]=this.get(e)},this),t},get store(){return this.list[0]},push:function(t){return typeof t!="object"&&(t={valueOf:t}),this.list.length>=1&&So(this.list[this.list.length-1],t),So(t,this.root),this.list.push(t)},pop:function(){return this.list.length>=2&&So(this.list[this.list.length-2],this.root),this.list.pop()},unshift:function(t){return So(t,this.list[0]||this.root),this.list.unshift(t)},shift:function(){return this.list.length===1&&So(this.list[0],this.root),this.list.shift()},get:function(t){return this.list[0][t]},set:function(t,e,r){return this.length||this.push({}),r&&this.list[0].hasOwnProperty(t)&&this.push({}),this.list[0][t]=e},forEach:function(t,e){for(var r in this.list[0])t.call(e,r,this.list[0][r])},slice:function(){return this.list.slice.apply(this.list,arguments)},splice:function(){for(var t=this.list.splice.apply(this.list,arguments),e=0,r=this.list.length;e<r;e++)So(this.list[e],this.list[e+1]||this.root);return t}}});var n8=D(xo=>{xo.parse=xo.decode=nae;xo.stringify=xo.encode=e8;xo.safe=_a;xo.unsafe=Mh;var bb=typeof process<"u"&&process.platform==="win32"?`\r
198
198
  `:`
199
199
  `;function e8(t,e){var r=[],n="";typeof e=="string"?e={section:e,whitespace:!1}:(e=e||{},e.whitespace=e.whitespace===!0);var i=e.whitespace?" = ":"=";return Object.keys(t).forEach(function(o,s,a){var u=t[o];u&&Array.isArray(u)?u.forEach(function(c){n+=_a(o+"[]")+i+_a(c)+`
200
- `}):u&&typeof u=="object"?r.push(o):n+=_a(o)+i+_a(u)+bb}),e.section&&n.length&&(n="["+_a(e.section)+"]"+bb+n),r.forEach(function(o,s,a){var u=t8(o).join("\\."),c=(e.section?e.section+".":"")+u,l=e8(t[o],{section:c,whitespace:e.whitespace});n.length&&l.length&&(n+=bb),n+=l}),n}function t8(t){return t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(function(e){return e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")})}function nae(t){var e={},r=e,n=null,i=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=t.split(/[\r\n]+/g);return o.forEach(function(s,a,u){if(!(!s||s.match(/^\s*[;#]/))){var c=s.match(i);if(c){if(c[1]!==void 0){if(n=Mh(c[1]),n==="__proto__"){r={};return}r=e[n]=e[n]||{};return}var l=Mh(c[2]);if(l!=="__proto__"){var f=c[3]?Mh(c[4]):!0;switch(f){case"true":case"false":case"null":f=JSON.parse(f)}if(l.length>2&&l.slice(-2)==="[]"){if(l=l.substring(0,l.length-2),l==="__proto__")return;r[l]?Array.isArray(r[l])||(r[l]=[r[l]]):r[l]=[]}Array.isArray(r[l])?r[l].push(f):r[l]=f}}}}),Object.keys(e).filter(function(s,a,u){if(!e[s]||typeof e[s]!="object"||Array.isArray(e[s]))return!1;var c=t8(s),l=e,f=c.pop(),h=f.replace(/\\\./g,".");return c.forEach(function(d,p,b){d!=="__proto__"&&((!l[d]||typeof l[d]!="object")&&(l[d]={}),l=l[d])}),l===e&&h===f?!1:(l[h]=e[s],!0)}).forEach(function(s,a,u){delete e[s]}),e}function r8(t){return t.charAt(0)==='"'&&t.slice(-1)==='"'||t.charAt(0)==="'"&&t.slice(-1)==="'"}function _a(t){return typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&r8(t)||t!==t.trim()?JSON.stringify(t):t.replace(/;/g,"\\;").replace(/#/g,"\\#")}function Mh(t,e){if(t=(t||"").trim(),r8(t)){t.charAt(0)==="'"&&(t=t.substr(1,t.length-2));try{t=JSON.parse(t)}catch{}}else{for(var r=!1,n="",i=0,o=t.length;i<o;i++){var s=t.charAt(i);if(r)"\\;#".indexOf(s)!==-1?n+=s:n+="\\"+s,r=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?r=!0:n+=s}}return r&&(n+="\\"),n.trim()}return t}});var a8=D((Nn,s8)=>{var i8=Qj(),Lc=require("path"),Uh=require("fs"),wb=n8(),_b=require("events").EventEmitter,iae=require("url"),oae=require("http"),Nn=s8.exports=function(){for(var t=[].slice.call(arguments),e=new Ot;t.length;){var r=t.shift();r&&e.push(typeof r=="string"?aae(r):r)}return e},_ye=Nn.find=function(){var t=Lc.join.apply(null,[].slice.call(arguments));function e(r,n){var i=Lc.join(r,n);try{return Uh.statSync(i),i}catch{if(Lc.dirname(r)!==r)return e(Lc.dirname(r),n)}}return e(__dirname,t)},sae=Nn.parse=function(t,e,r){if(t=""+t,r)if(r==="json")if(this.emit)try{return JSON.parse(t)}catch(n){this.emit("error",n)}else return JSON.parse(t);else return wb.parse(t);else try{return JSON.parse(t)}catch{return wb.parse(t)}},aae=Nn.json=function(){var t=[].slice.call(arguments).filter(function(n){return n!=null}),e=Lc.join.apply(null,t),r;try{r=Uh.readFileSync(e,"utf-8")}catch{return}return sae(r,e,"json")},Eye=Nn.env=function(t,e){e=e||process.env;var r={},n=t.length;for(var i in e)i.indexOf(t)===0&&(r[i.substring(n)]=e[i]);return r};Nn.ConfigChain=Ot;function Ot(){_b.apply(this),i8.apply(this,arguments),this._awaiting=0,this._saving=0,this.sources={}}var o8={constructor:{value:Ot}};Object.keys(_b.prototype).forEach(function(t){o8[t]=Object.getOwnPropertyDescriptor(_b.prototype,t)});Ot.prototype=Object.create(i8.prototype,o8);Ot.prototype.del=function(t,e){if(e){var r=this.sources[e];if(r=r&&r.data,!r)return this.emit("error",new Error("not found "+e));delete r[t]}else for(var n=0,i=this.list.length;n<i;n++)delete this.list[n][t];return this};Ot.prototype.set=function(t,e,r){var n;if(r){if(n=this.sources[r],n=n&&n.data,!n)return this.emit("error",new Error("not found "+r))}else if(n=this.list[0],!n)return this.emit("error",new Error("cannot set, no confs!"));return n[t]=e,this};Ot.prototype.get=function(t,e){return e?(e=this.sources[e],e&&(e=e.data),e&&Object.hasOwnProperty.call(e,t)?e[t]:void 0):this.list[0][t]};Ot.prototype.save=function(t,o,r){typeof o=="function"&&(r=o,o=null);var n=this.sources[t];if(!n||!(n.path||n.source)||!n.data)return this.emit("error",new Error("bad save target: "+t));if(n.source){var i=n.prefix||"";return Object.keys(n.data).forEach(function(a){n.source[i+a]=n.data[a]}),this}var o=o||n.type,s=n.data;return n.type==="json"?s=JSON.stringify(s):s=wb.stringify(s),this._saving++,Uh.writeFile(n.path,s,"utf8",function(a){if(this._saving--,a)return r?r(a):this.emit("error",a);this._saving===0&&(r&&r(),this.emit("save"))}.bind(this)),this};Ot.prototype.addFile=function(t,e,r){r=r||t;var n={__source__:r};return this.sources[r]={path:t,type:e},this.push(n),this._await(),Uh.readFile(t,"utf8",function(i,o){i&&this.emit("error",i),this.addString(o,t,e,n)}.bind(this)),this};Ot.prototype.addEnv=function(t,e,r){r=r||"env";var n=Nn.env(t,e);return this.sources[r]={data:n,source:e,prefix:t},this.add(n,r)};Ot.prototype.addUrl=function(t,e,r){this._await();var n=iae.format(t);r=r||n;var i={__source__:r};return this.sources[r]={href:n,type:e},this.push(i),oae.request(t,function(o){var s=[],a=o.headers["content-type"];e||(e=a.indexOf("json")!==-1?"json":a.indexOf("ini")!==-1?"ini":n.match(/\.json$/)?"json":n.match(/\.ini$/)?"ini":null,i.type=e),o.on("data",s.push.bind(s)).on("end",function(){this.addString(Buffer.concat(s),n,e,i)}.bind(this)).on("error",this.emit.bind(this,"error"))}.bind(this)).on("error",this.emit.bind(this,"error")).end(),this};Ot.prototype.addString=function(t,e,r,n){return t=this.parse(t,e,r),this.add(t,n),this};Ot.prototype.add=function(t,e){if(e&&typeof e=="object"){var r=this.list.indexOf(e);if(r===-1)return this.emit("error",new Error("bad marker"));this.splice(r,1,t),e=e.__source__,this.sources[e]=this.sources[e]||{},this.sources[e].data=t,this._resolve()}else typeof e=="string"&&(this.sources[e]=this.sources[e]||{},this.sources[e].data=t),this._await(),this.push(t),process.nextTick(this._resolve.bind(this));return this};Ot.prototype.parse=Nn.parse;Ot.prototype._await=function(){this._awaiting++};Ot.prototype._resolve=function(){this._awaiting--,this._awaiting===0&&this.emit("load",this)}});var c8=D((Cye,u8)=>{u8.exports=function(t){let e=t.indexOf(":");if(e===-1)return Eb(t);let r=t.substr(0,e),n=t.substr(e+1);return`${Eb(r)}:${Eb(n)}`};function Eb(t){if(t=t.toLowerCase(),t==="_authtoken")return"_authToken";let e=t[0];for(let r=1;r<t.length;r++)e+=t[r]==="_"?"-":t[r];return e}});var l8=D(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});Hh.envReplace=void 0;var uae=/(?<!\\)(\\*)\$\{([^${}]+)\}/g;function cae(t,e){return t.replace(uae,lae.bind(null,e))}Hh.envReplace=cae;function lae(t,e,r,n){if(r.length%2)return e.slice((r.length+1)/2);let i=dae(t,n);if(i===void 0)throw new Error(`Failed to replace env in config: ${e}`);return`${r.slice(r.length/2)}${i}`}var fae=/([^:-]+)(:?)-(.+)/;function dae(t,e){let r=e.match(fae);if(!r)return t[e];let[,n,i,o]=r;return Object.prototype.hasOwnProperty.call(t,n)?!t[n]&&i?o:t[n]:o}});var f8=D(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});Vh.envReplace=void 0;var hae=l8();Object.defineProperty(Vh,"envReplace",{enumerable:!0,get:function(){return hae.envReplace}})});var h8=D(zh=>{"use strict";var pae=require("fs"),Fo=require("path"),{envReplace:d8}=f8(),mae=(t,e,r)=>{if(typeof e!="string")return e;let n=[].concat(t[r]),i=n.indexOf(Fo)!==-1,o=n.indexOf(Boolean)!==-1,s=n.indexOf(String)!==-1,a=n.indexOf(Number)!==-1;if(e=`${e}`.trim(),/^".*"$/.test(e))try{e=JSON.parse(e)}catch{throw new Error(`Failed parsing JSON config key ${r}: ${e}`)}if(o&&!s&&e==="")return!0;switch(e){case"true":return!0;case"false":return!1;case"null":return null;case"undefined":return}return e=d8(e,process.env),i&&((process.platform==="win32"?/^~(\/|\\)/:/^~\//).test(e)&&process.env.HOME&&(e=Fo.resolve(process.env.HOME,e.substr(2))),e=Fo.resolve(e)),a&&!isNaN(e)&&(e=Number(e)),e},gae=t=>{t=Fo.resolve(t);let e=!1;for(;Fo.basename(t)==="node_modules";)t=Fo.dirname(t),e=!0;if(e)return t;let r=(n,i)=>{let o=/^[a-zA-Z]:(\\|\/)?$/;if(n==="/"||process.platform==="win32"&&o.test(n))return i;try{let s=pae.readdirSync(n);if(s.includes("node_modules")||s.includes("package.json")||s.includes("package.json5")||s.includes("package.yaml")||s.includes("pnpm-workspace.yaml"))return n;let a=Fo.dirname(n);return a===n?i:r(a,i)}catch(s){if(n===i){if(s.code==="ENOENT")return i;throw s}return i}};return r(t,t)};zh.envReplace=d8;zh.findPrefix=gae;zh.parseField=mae});var g8=D(m8=>{"use strict";var Oo=require("path"),yae=require("stream").Stream,Gh=require("url"),Dae=()=>{},vae=()=>[],p8=()=>{};m8.types={access:[null,"restricted","public"],"allow-same-version":Boolean,"always-auth":Boolean,also:[null,"dev","development"],audit:Boolean,"auth-type":["legacy","sso","saml","oauth"],"bin-links":Boolean,browser:[null,String],ca:[null,String,Array],cafile:Oo,cache:Oo,"cache-lock-stale":Number,"cache-lock-retries":Number,"cache-lock-wait":Number,"cache-max":Number,"cache-min":Number,cert:[null,String],cidr:[null,String,Array],color:["always",Boolean],depth:Number,description:Boolean,dev:Boolean,"dry-run":Boolean,editor:String,"engine-strict":Boolean,force:Boolean,"fetch-retries":Number,"fetch-retry-factor":Number,"fetch-retry-mintimeout":Number,"fetch-retry-maxtimeout":Number,git:String,"git-tag-version":Boolean,"commit-hooks":Boolean,global:Boolean,globalconfig:Oo,"global-style":Boolean,group:[Number,String],"https-proxy":[null,Gh],"user-agent":String,"ham-it-up":Boolean,heading:String,"if-present":Boolean,"ignore-prepublish":Boolean,"ignore-scripts":Boolean,"init-module":Oo,"init-author-name":String,"init-author-email":String,"init-author-url":["",Gh],"init-license":String,"init-version":p8,json:Boolean,key:[null,String],"legacy-bundling":Boolean,link:Boolean,"local-address":vae(),loglevel:["silent","error","warn","notice","http","timing","info","verbose","silly"],logstream:yae,"logs-max":Number,long:Boolean,maxsockets:Number,message:String,"metrics-registry":[null,String],"node-options":[null,String],"node-version":[null,p8],"no-proxy":[null,String,Array],offline:Boolean,"onload-script":[null,String],only:[null,"dev","development","prod","production"],optional:Boolean,"package-lock":Boolean,otp:[null,String],"package-lock-only":Boolean,parseable:Boolean,"prefer-offline":Boolean,"prefer-online":Boolean,prefix:Oo,production:Boolean,progress:Boolean,proxy:[null,!1,Gh],provenance:Boolean,"read-only":Boolean,"rebuild-bundle":Boolean,registry:[null,Gh],rollback:Boolean,save:Boolean,"save-bundle":Boolean,"save-dev":Boolean,"save-exact":Boolean,"save-optional":Boolean,"save-prefix":String,"save-prod":Boolean,scope:String,"script-shell":[null,String],"scripts-prepend-node-path":[!1,!0,"auto","warn-only"],searchopts:String,searchexclude:[null,String],searchlimit:Number,searchstaleness:Number,"send-metrics":Boolean,shell:String,shrinkwrap:Boolean,"sign-git-tag":Boolean,"sso-poll-frequency":Number,"sso-type":[null,"oauth","saml"],"strict-ssl":Boolean,tag:String,timing:Boolean,tmp:Oo,unicode:Boolean,"unsafe-perm":Boolean,usage:Boolean,user:[Number,String],userconfig:Oo,umask:Dae,version:Boolean,"tag-version-prefix":String,versions:Boolean,viewer:String,_exit:Boolean}});var b8=D((Aye,v8)=>{"use strict";var{readCAFileSync:bae}=Jj(),y8=require("fs"),Cb=require("path"),{ConfigChain:wae}=a8(),_ae=c8(),D8=h8(),Sb=class extends wae{constructor(e,r){super(e),this.root=e,this._parseField=D8.parseField.bind(null,r||g8())}add(e,r){try{for(let n of Object.keys(e))e[n]=this._parseField(e[n],n)}catch(n){throw n}return super.add(e,r)}addFile(e,r){r=r||e;let n={__source__:r};this.sources[r]={path:e,type:"ini"},this.push(n),this._await();try{let i=y8.readFileSync(e,"utf8");this.addString(i,e,"ini",n)}catch(i){if(i.code==="ENOENT")this.add({},n);else return`Issue while reading "${e}". ${i.message}`}}addEnv(e){e=e||process.env;let r={};return Object.keys(e).filter(n=>/^npm_config_/i.test(n)).forEach(n=>{e[n]&&(r[_ae(n.substr(11))]=e[n])}),super.addEnv("",r,"env")}loadPrefix(){let e=this.list[0];Object.defineProperty(this,"prefix",{enumerable:!0,set:n=>{let i=this.get("global");this[i?"globalPrefix":"localPrefix"]=n},get:()=>this.get("global")?this.globalPrefix:this.localPrefix}),Object.defineProperty(this,"globalPrefix",{enumerable:!0,set:n=>{this.set("prefix",n)},get:()=>Cb.resolve(this.get("prefix"))});let r;if(Object.defineProperty(this,"localPrefix",{enumerable:!0,set:n=>{r=n},get:()=>r}),Object.prototype.hasOwnProperty.call(e,"prefix"))r=Cb.resolve(e.prefix);else try{r=D8.findPrefix(process.cwd())}catch(n){throw n}return r}loadCAFile(e){if(!e)return;let r=bae(e);r&&this.set("ca",r)}loadUser(){let e=this.root;if(this.get("global"))return;if(process.env.SUDO_UID){e.user=Number(process.env.SUDO_UID);return}let r=Cb.resolve(this.get("prefix"));try{let n=y8.statSync(r);e.user=n.uid}catch(n){if(n.code==="ENOENT")return;throw n}}};v8.exports=Sb});var x8=D(S8=>{"use strict";var E8=require("os"),Ln=require("path"),C8=E8.tmpdir(),Eae=process.getuid?process.getuid():process.pid,Cae=()=>!0,w8=process.platform==="win32",_8={editor:()=>process.env.EDITOR||process.env.VISUAL||(w8?"notepad.exe":"vi"),shell:()=>w8?process.env.COMSPEC||"cmd.exe":process.env.SHELL||"/bin/bash"},Sae={fromString:()=>process.umask()},Ea=E8.homedir();Ea?process.env.HOME=Ea:Ea=Ln.resolve(C8,"npm-"+Eae);var xae=process.platform==="win32"?"npm-cache":".npm",Fae=process.platform==="win32"&&process.env.APPDATA||Ea,Oae=Ln.resolve(Fae,xae),Wh,Ao;Object.defineProperty(S8,"defaults",{get:function(){return Wh||(process.env.PREFIX?Ao=process.env.PREFIX:process.platform==="win32"?Ao=Ln.dirname(process.execPath):(Ao=Ln.dirname(Ln.dirname(process.execPath)),process.env.DESTDIR&&(Ao=Ln.join(process.env.DESTDIR,Ao))),Wh={access:null,"allow-same-version":!1,"always-auth":!1,also:null,audit:!0,"auth-type":"legacy","bin-links":!0,browser:null,ca:null,cafile:null,cache:Oae,"cache-lock-stale":6e4,"cache-lock-retries":10,"cache-lock-wait":1e4,"cache-max":1/0,"cache-min":10,cert:null,cidr:null,color:process.env.NO_COLOR==null,depth:1/0,description:!0,dev:!1,"dry-run":!1,editor:_8.editor(),"engine-strict":!1,force:!1,"fetch-retries":2,"fetch-retry-factor":10,"fetch-retry-mintimeout":1e4,"fetch-retry-maxtimeout":6e4,git:"git","git-tag-version":!0,"commit-hooks":!0,global:!1,globalconfig:Ln.resolve(Ao,"etc","npmrc"),"global-style":!1,group:process.platform==="win32"?0:process.env.SUDO_GID||process.getgid&&process.getgid(),"ham-it-up":!1,heading:"npm","if-present":!1,"ignore-prepublish":!1,"ignore-scripts":!1,"init-module":Ln.resolve(Ea,".npm-init.js"),"init-author-name":"","init-author-email":"","init-author-url":"","init-version":"1.0.0","init-license":"ISC",json:!1,key:null,"legacy-bundling":!1,link:!1,"local-address":void 0,loglevel:"notice",logstream:process.stderr,"logs-max":10,long:!1,maxsockets:50,message:"%s","metrics-registry":null,"node-options":null,offline:!1,"onload-script":!1,only:null,optional:!0,otp:null,"package-lock":!0,"package-lock-only":!1,parseable:!1,"prefer-offline":!1,"prefer-online":!1,prefix:Ao,production:process.env.NODE_ENV==="production",progress:!process.env.TRAVIS&&!process.env.CI,provenance:!1,proxy:null,"https-proxy":null,"no-proxy":null,"user-agent":"npm/{npm-version} node/{node-version} {platform} {arch}","read-only":!1,"rebuild-bundle":!0,registry:"https://registry.npmjs.org/",rollback:!0,save:!0,"save-bundle":!1,"save-dev":!1,"save-exact":!1,"save-optional":!1,"save-prefix":"^","save-prod":!1,scope:"","script-shell":null,"scripts-prepend-node-path":"warn-only",searchopts:"",searchexclude:null,searchlimit:20,searchstaleness:15*60,"send-metrics":!1,shell:_8.shell(),shrinkwrap:!0,"sign-git-tag":!1,"sso-poll-frequency":500,"sso-type":"oauth","strict-ssl":!0,tag:"latest","tag-version-prefix":"v",timing:!1,tmp:C8,unicode:Cae(),"unsafe-perm":process.platform==="win32"||process.platform==="cygwin"||!(process.getuid&&process.setuid&&process.getgid&&process.setgid)||process.getuid()!==0,usage:!1,user:process.platform==="win32"?0:"nobody",userconfig:Ln.resolve(Ea,".npmrc"),umask:process.umask?process.umask():Sae.fromString("022"),version:!1,versions:!1,viewer:process.platform==="win32"?"browser":"man",_exit:!0},Wh)}})});var O8=D((Tye,xb)=>{"use strict";var ko=require("path"),Aae=b8(),F8=x8();xb.exports=(t,e,r)=>{let n=new Aae(Object.assign({},F8.defaults,r),e);n.add(Object.assign({},t),"cli");let i=[],o=!1;if(require.resolve.paths){let c=require.resolve.paths("npm"),l;try{l=require.resolve("npm",{paths:c.slice(-1)})}catch{o=!0}l&&i.push(n.addFile(ko.resolve(ko.dirname(l),"..","npmrc"),"builtin"))}n.addEnv(),n.loadPrefix();let s=ko.resolve(n.localPrefix,".npmrc"),a=n.get("userconfig");if(!n.get("global")&&s!==a?i.push(n.addFile(s,"project")):n.add({},"project"),n.get("workspace-prefix")&&n.get("workspace-prefix")!==s){let c=ko.resolve(n.get("workspace-prefix"),".npmrc");i.push(n.addFile(c,"workspace"))}if(i.push(n.addFile(n.get("userconfig"),"user")),n.get("prefix")){let c=ko.resolve(n.get("prefix"),"etc");n.root.globalconfig=ko.resolve(c,"npmrc"),n.root.globalignorefile=ko.resolve(c,"npmignore")}i.push(n.addFile(n.get("globalconfig"),"global")),n.loadUser();let u=n.get("cafile");return u&&n.loadCAFile(u),{config:n,warnings:i.filter(Boolean),failedToLoadBuiltInConfig:o}};Object.defineProperty(xb.exports,"defaults",{get(){return F8.defaults},enumerable:!0})});var j8=D((Pye,I8)=>{var Fb=require("url"),A8=O8(),k8=":_authToken",T8=":_auth",P8=":username",R8=":_password";I8.exports=function(){let e,r;arguments.length>=2?(e=arguments[0],r=Object.assign({},arguments[1])):typeof arguments[0]=="string"?e=arguments[0]:r=Object.assign({},arguments[0]),r=r||{};let n=r.npmrc;return r.npmrc=(r.npmrc?{config:{get:i=>n[i]}}:A8()).config,e=e||r.npmrc.get("registry")||A8.defaults.registry,$8(e,r)||kae(r.npmrc)};function $8(t,e){let r=Fb.parse(t,!1,!0),n;for(;n!=="/"&&r.pathname!==n;){n=r.pathname||"/";let i="//"+r.host+n.replace(/\/$/,""),o=Pae(i,e.npmrc);if(o)return o;if(!e.recursive)return/\/$/.test(t)?void 0:$8(Fb.resolve(t,"."),e);r.pathname=Fb.resolve(Tae(n),"..")||"/"}}function kae(t){return t.get("_auth")?{token:Kh(t.get("_auth")),type:"Basic"}:void 0}function Tae(t){return t[t.length-1]==="/"?t:t+"/"}function Pae(t,e){let r=Rae(e.get(t+k8)||e.get(t+"/"+k8));if(r)return r;let n=e.get(t+P8)||e.get(t+"/"+P8),i=e.get(t+R8)||e.get(t+"/"+R8),o=$ae(n,i);if(o)return o;let s=Iae(e.get(t+T8)||e.get(t+"/"+T8));if(s)return s}function Kh(t){return t.replace(/^\$\{?([^}]*)\}?$/,function(e,r){return process.env[r]})}function Rae(t){return t?{token:Kh(t),type:"Bearer"}:void 0}function $ae(t,e){if(!t||!e)return;let r=Buffer.from(Kh(e),"base64").toString("utf8");return{token:Buffer.from(t+":"+r,"utf8").toString("base64"),type:"Basic",password:r,username:t}}function Iae(t){return t?{token:Kh(t),type:"Basic"}:void 0}});var IL=D((Pwe,Hn)=>{var ot=require("fs"),nw=require("os"),dr=require("path"),bL=require("crypto"),ln={fs:ot.constants,os:nw.constants},wL="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",EL=/XXXXXX/,wue=3,CL=(ln.O_CREAT||ln.fs.O_CREAT)|(ln.O_EXCL||ln.fs.O_EXCL)|(ln.O_RDWR||ln.fs.O_RDWR),_ue=nw.platform()==="win32",Eue=ln.EBADF||ln.os.errno.EBADF,Cue=ln.ENOENT||ln.os.errno.ENOENT,SL=448,xL=384,Sue="exit",Pa=[],FL=ot.rmdirSync.bind(ot),OL=!1;function xue(t,e){return ot.rm(t,{recursive:!0},e)}function AL(t){return ot.rmSync(t,{recursive:!0})}function iw(t,e){let r=Ra(t,e),n=r[0],i=r[1];try{PL(n)}catch(s){return i(s)}let o=n.tries;(function s(){try{let a=TL(n);ot.stat(a,function(u){if(!u)return o-- >0?s():i(new Error("Could not get a unique tmp filename, max tries reached "+a));i(null,a)})}catch(a){i(a)}})()}function ow(t){let e=Ra(t),r=e[0];PL(r);let n=r.tries;do{let i=TL(r);try{ot.statSync(i)}catch{return i}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function Fue(t,e){let r=Ra(t,e),n=r[0],i=r[1];iw(n,function(s,a){if(s)return i(s);ot.open(a,CL,n.mode||xL,function(c,l){if(c)return i(c);if(n.discardDescriptor)return ot.close(l,function(h){return i(h,a,void 0,ew(a,-1,n,!1))});{let f=n.discardDescriptor||n.detachDescriptor;i(null,a,l,ew(a,f?-1:l,n,!1))}})})}function Oue(t){let e=Ra(t),r=e[0],n=r.discardDescriptor||r.detachDescriptor,i=ow(r);var o=ot.openSync(i,CL,r.mode||xL);return r.discardDescriptor&&(ot.closeSync(o),o=void 0),{name:i,fd:o,removeCallback:ew(i,n?-1:o,r,!0)}}function Aue(t,e){let r=Ra(t,e),n=r[0],i=r[1];iw(n,function(s,a){if(s)return i(s);ot.mkdir(a,n.mode||SL,function(c){if(c)return i(c);i(null,a,kL(a,n,!1))})})}function kue(t){let e=Ra(t),r=e[0],n=ow(r);return ot.mkdirSync(n,r.mode||SL),{name:n,removeCallback:kL(n,r,!0)}}function Tue(t,e){let r=function(n){if(n&&!rw(n))return e(n);e()};0<=t[0]?ot.close(t[0],function(){ot.unlink(t[1],r)}):ot.unlink(t[1],r)}function Pue(t){let e=null;try{0<=t[0]&&ot.closeSync(t[0])}catch(r){if(!Iue(r)&&!rw(r))throw r}finally{try{ot.unlinkSync(t[1])}catch(r){rw(r)||(e=r)}}if(e!==null)throw e}function ew(t,e,r,n){let i=vp(Pue,[e,t],n),o=vp(Tue,[e,t],n,i);return r.keep||Pa.unshift(i),n?i:o}function kL(t,e,r){let n=e.unsafeCleanup?xue:ot.rmdir.bind(ot),i=e.unsafeCleanup?AL:FL,o=vp(i,t,r),s=vp(n,t,r,o);return e.keep||Pa.unshift(o),r?o:s}function vp(t,e,r,n){let i=!1;return function o(s){if(!i){let a=n||o,u=Pa.indexOf(a);return u>=0&&Pa.splice(u,1),i=!0,r||t===FL||t===AL?t(e):t(e,s||function(){})}}}function Rue(){if(OL)for(;Pa.length;)try{Pa[0]()}catch{}}function _L(t){let e=[],r=null;try{r=bL.randomBytes(t)}catch{r=bL.pseudoRandomBytes(t)}for(var n=0;n<t;n++)e.push(wL[r[n]%wL.length]);return e.join("")}function $ue(t){return t===null||tr(t)||!t.trim()}function tr(t){return typeof t>"u"}function Ra(t,e){if(typeof t=="function")return[{},t];if(tr(t))return[{},e];let r={};for(let n of Object.getOwnPropertyNames(t))r[n]=t[n];return[r,e]}function TL(t){let e=t.tmpdir;if(!tr(t.name))return dr.join(e,t.dir,t.name);if(!tr(t.template))return dr.join(e,t.dir,t.template).replace(EL,_L(6));let r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",_L(12),t.postfix?"-"+t.postfix:""].join("");return dr.join(e,t.dir,r)}function PL(t){t.tmpdir=$L(t);let e=t.tmpdir;if(tr(t.name)||Qb(t.name,"name",e),tr(t.dir)||Qb(t.dir,"dir",e),!tr(t.template)&&(Qb(t.template,"template",e),!t.template.match(EL)))throw new Error(`Invalid template, found "${t.template}".`);if(!tr(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=tr(t.name)?t.tries||wue:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.dir=tr(t.dir)?"":dr.relative(e,tw(t.dir,e)),t.template=tr(t.template)?void 0:dr.relative(e,tw(t.template,e)),t.template=$ue(t.template)?void 0:dr.relative(t.dir,t.template),t.name=tr(t.name)?void 0:t.name,t.prefix=tr(t.prefix)?"":t.prefix,t.postfix=tr(t.postfix)?"":t.postfix}function tw(t,e){return t.startsWith(e)?dr.resolve(t):dr.resolve(dr.join(e,t))}function Qb(t,e,r){if(e==="name"){if(dr.isAbsolute(t))throw new Error(`${e} option must not contain an absolute path, found "${t}".`);let n=dr.basename(t);if(n===".."||n==="."||n!==t)throw new Error(`${e} option must not contain a path, found "${t}".`)}else{if(dr.isAbsolute(t)&&!t.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${t}".`);let n=tw(t,r);if(!n.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${n}".`)}}function Iue(t){return RL(t,-Eue,"EBADF")}function rw(t){return RL(t,-Cue,"ENOENT")}function RL(t,e,r){return _ue?t.code===r:t.code===r&&t.errno===e}function jue(){OL=!0}function $L(t){return dr.resolve(t&&t.tmpdir||nw.tmpdir())}process.addListener(Sue,Rue);Object.defineProperty(Hn.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return $L()}});Hn.exports.dir=Aue;Hn.exports.dirSync=kue;Hn.exports.file=Fue;Hn.exports.fileSync=Oue;Hn.exports.tmpName=iw;Hn.exports.tmpNameSync=ow;Hn.exports.setGracefulCleanup=jue});var xw=ce(Sw(),1),{program:A,createCommand:pce,createArgument:mce,createOption:gce,CommanderError:yce,InvalidArgumentError:Dce,InvalidOptionArgumentError:vce,Command:bce,Argument:wce,Option:_ce,Help:Ece}=xw.default;var Ir={name:"@capgo/cli",version:"4.27.7",description:"A CLI to upload to capgo servers",author:"github.com/riderx",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLIl#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli"],main:"dist/index.js",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && node build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js",test:"npx --yes ts-node -T src/index.ts","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",test_rls:"ts-node ./test/test_headers_rls.ts",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js"},devDependencies:{"@antfu/eslint-config":"^3.9.2","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client","@capacitor/cli":"^6.2.0","@capgo/find-package-manager":"^0.0.17","@clack/prompts":"^0.9.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver","@supabase/supabase-js":"^2.46.0","@tomasklaen/checksum":"^1.1.0","@types/adm-zip":"^0.5.6","@types/node":"^22.8.4","@types/prettyjson":"^0.0.33","@types/semver":"7.5.8","@types/tmp":"^0.2.6","@typescript-eslint/eslint-plugin":"^8.15.0","@typescript-eslint/parser":"^8.15.0","@vercel/ncc":"^0.38.3","adm-zip":"^0.5.16","ci-info":"^4.1.0",commander:"12.1.0",esbuild:"^0.24.0",eslint:"9.17.0","git-format-staged":"3.1.1",husky:"^9.1.7","is-wsl":"^3.1.0",ky:"^1.7.2","latest-version":"^9.0.0",open:"^10.1.0",pkg:"5.8.1",prettyjson:"^1.2.5",semver:"^7.6.3",tmp:"^0.2.3","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"4.2.0","tus-js-client":"^4.2.3",typescript:"5.7.2"}};var Ca=require("node:fs"),B8=require("node:process");var Et=ce(Te(),1),Lo=require("node:process"),Gn=ce(require("node:readline"),1),zp=ce(require("node:readline"),1),Nw=require("node:tty"),sl=ce(Up(),1);function SB({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}var xB=SB();function Lw(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(xB,"")}function Bw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qw={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(n){var i=n.charCodeAt(0),o=n.length==2?n.charCodeAt(1):0,s=i;return 55296<=i&&i<=56319&&56320<=o&&o<=57343&&(i&=1023,o&=1023,s=i<<10|o,s+=65536),s==12288||65281<=s&&s<=65376||65504<=s&&s<=65510?"F":s==8361||65377<=s&&s<=65470||65474<=s&&s<=65479||65482<=s&&s<=65487||65490<=s&&s<=65495||65498<=s&&s<=65500||65512<=s&&s<=65518?"H":4352<=s&&s<=4447||4515<=s&&s<=4519||4602<=s&&s<=4607||9001<=s&&s<=9002||11904<=s&&s<=11929||11931<=s&&s<=12019||12032<=s&&s<=12245||12272<=s&&s<=12283||12289<=s&&s<=12350||12353<=s&&s<=12438||12441<=s&&s<=12543||12549<=s&&s<=12589||12593<=s&&s<=12686||12688<=s&&s<=12730||12736<=s&&s<=12771||12784<=s&&s<=12830||12832<=s&&s<=12871||12880<=s&&s<=13054||13056<=s&&s<=19903||19968<=s&&s<=42124||42128<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||55216<=s&&s<=55238||55243<=s&&s<=55291||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65106||65108<=s&&s<=65126||65128<=s&&s<=65131||110592<=s&&s<=110593||127488<=s&&s<=127490||127504<=s&&s<=127546||127552<=s&&s<=127560||127568<=s&&s<=127569||131072<=s&&s<=194367||177984<=s&&s<=196605||196608<=s&&s<=262141?"W":32<=s&&s<=126||162<=s&&s<=163||165<=s&&s<=166||s==172||s==175||10214<=s&&s<=10221||10629<=s&&s<=10630?"Na":s==161||s==164||167<=s&&s<=168||s==170||173<=s&&s<=174||176<=s&&s<=180||182<=s&&s<=186||188<=s&&s<=191||s==198||s==208||215<=s&&s<=216||222<=s&&s<=225||s==230||232<=s&&s<=234||236<=s&&s<=237||s==240||242<=s&&s<=243||247<=s&&s<=250||s==252||s==254||s==257||s==273||s==275||s==283||294<=s&&s<=295||s==299||305<=s&&s<=307||s==312||319<=s&&s<=322||s==324||328<=s&&s<=331||s==333||338<=s&&s<=339||358<=s&&s<=359||s==363||s==462||s==464||s==466||s==468||s==470||s==472||s==474||s==476||s==593||s==609||s==708||s==711||713<=s&&s<=715||s==717||s==720||728<=s&&s<=731||s==733||s==735||768<=s&&s<=879||913<=s&&s<=929||931<=s&&s<=937||945<=s&&s<=961||963<=s&&s<=969||s==1025||1040<=s&&s<=1103||s==1105||s==8208||8211<=s&&s<=8214||8216<=s&&s<=8217||8220<=s&&s<=8221||8224<=s&&s<=8226||8228<=s&&s<=8231||s==8240||8242<=s&&s<=8243||s==8245||s==8251||s==8254||s==8308||s==8319||8321<=s&&s<=8324||s==8364||s==8451||s==8453||s==8457||s==8467||s==8470||8481<=s&&s<=8482||s==8486||s==8491||8531<=s&&s<=8532||8539<=s&&s<=8542||8544<=s&&s<=8555||8560<=s&&s<=8569||s==8585||8592<=s&&s<=8601||8632<=s&&s<=8633||s==8658||s==8660||s==8679||s==8704||8706<=s&&s<=8707||8711<=s&&s<=8712||s==8715||s==8719||s==8721||s==8725||s==8730||8733<=s&&s<=8736||s==8739||s==8741||8743<=s&&s<=8748||s==8750||8756<=s&&s<=8759||8764<=s&&s<=8765||s==8776||s==8780||s==8786||8800<=s&&s<=8801||8804<=s&&s<=8807||8810<=s&&s<=8811||8814<=s&&s<=8815||8834<=s&&s<=8835||8838<=s&&s<=8839||s==8853||s==8857||s==8869||s==8895||s==8978||9312<=s&&s<=9449||9451<=s&&s<=9547||9552<=s&&s<=9587||9600<=s&&s<=9615||9618<=s&&s<=9621||9632<=s&&s<=9633||9635<=s&&s<=9641||9650<=s&&s<=9651||9654<=s&&s<=9655||9660<=s&&s<=9661||9664<=s&&s<=9665||9670<=s&&s<=9672||s==9675||9678<=s&&s<=9681||9698<=s&&s<=9701||s==9711||9733<=s&&s<=9734||s==9737||9742<=s&&s<=9743||9748<=s&&s<=9749||s==9756||s==9758||s==9792||s==9794||9824<=s&&s<=9825||9827<=s&&s<=9829||9831<=s&&s<=9834||9836<=s&&s<=9837||s==9839||9886<=s&&s<=9887||9918<=s&&s<=9919||9924<=s&&s<=9933||9935<=s&&s<=9953||s==9955||9960<=s&&s<=9983||s==10045||s==10071||10102<=s&&s<=10111||11093<=s&&s<=11097||12872<=s&&s<=12879||57344<=s&&s<=63743||65024<=s&&s<=65039||s==65533||127232<=s&&s<=127242||127248<=s&&s<=127277||127280<=s&&s<=127337||127344<=s&&s<=127386||917760<=s&&s<=917999||983040<=s&&s<=1048573||1048576<=s&&s<=1114109?"A":"N"},e.characterLength=function(n){var i=this.eastAsianWidth(n);return i=="F"||i=="W"||i=="A"?2:1};function r(n){return n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(n){for(var i=r(n),o=0,s=0;s<i.length;s++)o=o+this.characterLength(i[s]);return o},e.slice=function(n,i,o){textLen=e.length(n),i=i||0,o=o||1,i<0&&(i=textLen+i),o<0&&(o=textLen+o);for(var s="",a=0,u=r(n),c=0;c<u.length;c++){var l=u[c],f=e.length(l);if(a>=i-(f==2?1:0))if(a+f<=o)s+=l;else break;a+=f}return s}})(qw);var FB=qw.exports,OB=Bw(FB),AB=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},kB=Bw(AB);function Na(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=Lw(t),t.length===0))return 0;t=t.replace(kB()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(OB.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}var Hp=10,kw=(t=0)=>e=>`\x1B[${e+t}m`,Tw=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,Pw=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,$e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys($e.modifier);var TB=Object.keys($e.color),PB=Object.keys($e.bgColor);[...TB,...PB];function RB(){let t=new Map;for(let[e,r]of Object.entries($e)){for(let[n,i]of Object.entries(r))$e[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=$e[n],t.set(i[0],i[1]);Object.defineProperty($e,e,{value:r,enumerable:!1})}return Object.defineProperty($e,"codes",{value:t,enumerable:!1}),$e.color.close="\x1B[39m",$e.bgColor.close="\x1B[49m",$e.color.ansi=kw(),$e.color.ansi256=Tw(),$e.color.ansi16m=Pw(),$e.bgColor.ansi=kw(Hp),$e.bgColor.ansi256=Tw(Hp),$e.bgColor.ansi16m=Pw(Hp),Object.defineProperties($e,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>$e.rgbToAnsi256(...$e.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>$e.ansi256ToAnsi($e.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>$e.ansi256ToAnsi($e.hexToAnsi256(e)),enumerable:!1}}),$e}var $B=RB(),fl=new Set(["\x1B","\x9B"]),IB=39,Wp="\x07",Mw="[",jB="]",Uw="m",Kp=`${jB}8;;`,Rw=t=>`${fl.values().next().value}${Mw}${t}${Uw}`,$w=t=>`${fl.values().next().value}${Kp}${t}${Wp}`,NB=t=>t.split(" ").map(e=>Na(e)),Vp=(t,e,r)=>{let n=[...e],i=!1,o=!1,s=Na(Lw(t[t.length-1]));for(let[a,u]of n.entries()){let c=Na(u);if(s+c<=r?t[t.length-1]+=u:(t.push(u),s=0),fl.has(u)&&(i=!0,o=n.slice(a+1).join("").startsWith(Kp)),i){o?u===Wp&&(i=!1,o=!1):u===Uw&&(i=!1);continue}s+=c,s===r&&a<n.length-1&&(t.push(""),s=0)}!s&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},LB=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(Na(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},BB=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let n="",i,o,s=NB(t),a=[""];for(let[c,l]of t.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let f=Na(a[a.length-1]);if(c!==0&&(f>=e&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),f=0),(f>0||r.trim===!1)&&(a[a.length-1]+=" ",f++)),r.hard&&s[c]>e){let h=e-f,d=1+Math.floor((s[c]-h-1)/e);Math.floor((s[c]-1)/e)<d&&a.push(""),Vp(a,l,e);continue}if(f+s[c]>e&&f>0&&s[c]>0){if(r.wordWrap===!1&&f<e){Vp(a,l,e);continue}a.push("")}if(f+s[c]>e&&r.wordWrap===!1){Vp(a,l,e);continue}a[a.length-1]+=l}r.trim!==!1&&(a=a.map(c=>LB(c)));let u=[...a.join(`
200
+ `}):u&&typeof u=="object"?r.push(o):n+=_a(o)+i+_a(u)+bb}),e.section&&n.length&&(n="["+_a(e.section)+"]"+bb+n),r.forEach(function(o,s,a){var u=t8(o).join("\\."),c=(e.section?e.section+".":"")+u,l=e8(t[o],{section:c,whitespace:e.whitespace});n.length&&l.length&&(n+=bb),n+=l}),n}function t8(t){return t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(function(e){return e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")})}function nae(t){var e={},r=e,n=null,i=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=t.split(/[\r\n]+/g);return o.forEach(function(s,a,u){if(!(!s||s.match(/^\s*[;#]/))){var c=s.match(i);if(c){if(c[1]!==void 0){if(n=Mh(c[1]),n==="__proto__"){r={};return}r=e[n]=e[n]||{};return}var l=Mh(c[2]);if(l!=="__proto__"){var f=c[3]?Mh(c[4]):!0;switch(f){case"true":case"false":case"null":f=JSON.parse(f)}if(l.length>2&&l.slice(-2)==="[]"){if(l=l.substring(0,l.length-2),l==="__proto__")return;r[l]?Array.isArray(r[l])||(r[l]=[r[l]]):r[l]=[]}Array.isArray(r[l])?r[l].push(f):r[l]=f}}}}),Object.keys(e).filter(function(s,a,u){if(!e[s]||typeof e[s]!="object"||Array.isArray(e[s]))return!1;var c=t8(s),l=e,f=c.pop(),h=f.replace(/\\\./g,".");return c.forEach(function(d,p,b){d!=="__proto__"&&((!l[d]||typeof l[d]!="object")&&(l[d]={}),l=l[d])}),l===e&&h===f?!1:(l[h]=e[s],!0)}).forEach(function(s,a,u){delete e[s]}),e}function r8(t){return t.charAt(0)==='"'&&t.slice(-1)==='"'||t.charAt(0)==="'"&&t.slice(-1)==="'"}function _a(t){return typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&r8(t)||t!==t.trim()?JSON.stringify(t):t.replace(/;/g,"\\;").replace(/#/g,"\\#")}function Mh(t,e){if(t=(t||"").trim(),r8(t)){t.charAt(0)==="'"&&(t=t.substr(1,t.length-2));try{t=JSON.parse(t)}catch{}}else{for(var r=!1,n="",i=0,o=t.length;i<o;i++){var s=t.charAt(i);if(r)"\\;#".indexOf(s)!==-1?n+=s:n+="\\"+s,r=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?r=!0:n+=s}}return r&&(n+="\\"),n.trim()}return t}});var a8=D((Nn,s8)=>{var i8=Qj(),Lc=require("path"),Uh=require("fs"),wb=n8(),_b=require("events").EventEmitter,iae=require("url"),oae=require("http"),Nn=s8.exports=function(){for(var t=[].slice.call(arguments),e=new Ot;t.length;){var r=t.shift();r&&e.push(typeof r=="string"?aae(r):r)}return e},_ye=Nn.find=function(){var t=Lc.join.apply(null,[].slice.call(arguments));function e(r,n){var i=Lc.join(r,n);try{return Uh.statSync(i),i}catch{if(Lc.dirname(r)!==r)return e(Lc.dirname(r),n)}}return e(__dirname,t)},sae=Nn.parse=function(t,e,r){if(t=""+t,r)if(r==="json")if(this.emit)try{return JSON.parse(t)}catch(n){this.emit("error",n)}else return JSON.parse(t);else return wb.parse(t);else try{return JSON.parse(t)}catch{return wb.parse(t)}},aae=Nn.json=function(){var t=[].slice.call(arguments).filter(function(n){return n!=null}),e=Lc.join.apply(null,t),r;try{r=Uh.readFileSync(e,"utf-8")}catch{return}return sae(r,e,"json")},Eye=Nn.env=function(t,e){e=e||process.env;var r={},n=t.length;for(var i in e)i.indexOf(t)===0&&(r[i.substring(n)]=e[i]);return r};Nn.ConfigChain=Ot;function Ot(){_b.apply(this),i8.apply(this,arguments),this._awaiting=0,this._saving=0,this.sources={}}var o8={constructor:{value:Ot}};Object.keys(_b.prototype).forEach(function(t){o8[t]=Object.getOwnPropertyDescriptor(_b.prototype,t)});Ot.prototype=Object.create(i8.prototype,o8);Ot.prototype.del=function(t,e){if(e){var r=this.sources[e];if(r=r&&r.data,!r)return this.emit("error",new Error("not found "+e));delete r[t]}else for(var n=0,i=this.list.length;n<i;n++)delete this.list[n][t];return this};Ot.prototype.set=function(t,e,r){var n;if(r){if(n=this.sources[r],n=n&&n.data,!n)return this.emit("error",new Error("not found "+r))}else if(n=this.list[0],!n)return this.emit("error",new Error("cannot set, no confs!"));return n[t]=e,this};Ot.prototype.get=function(t,e){return e?(e=this.sources[e],e&&(e=e.data),e&&Object.hasOwnProperty.call(e,t)?e[t]:void 0):this.list[0][t]};Ot.prototype.save=function(t,o,r){typeof o=="function"&&(r=o,o=null);var n=this.sources[t];if(!n||!(n.path||n.source)||!n.data)return this.emit("error",new Error("bad save target: "+t));if(n.source){var i=n.prefix||"";return Object.keys(n.data).forEach(function(a){n.source[i+a]=n.data[a]}),this}var o=o||n.type,s=n.data;return n.type==="json"?s=JSON.stringify(s):s=wb.stringify(s),this._saving++,Uh.writeFile(n.path,s,"utf8",function(a){if(this._saving--,a)return r?r(a):this.emit("error",a);this._saving===0&&(r&&r(),this.emit("save"))}.bind(this)),this};Ot.prototype.addFile=function(t,e,r){r=r||t;var n={__source__:r};return this.sources[r]={path:t,type:e},this.push(n),this._await(),Uh.readFile(t,"utf8",function(i,o){i&&this.emit("error",i),this.addString(o,t,e,n)}.bind(this)),this};Ot.prototype.addEnv=function(t,e,r){r=r||"env";var n=Nn.env(t,e);return this.sources[r]={data:n,source:e,prefix:t},this.add(n,r)};Ot.prototype.addUrl=function(t,e,r){this._await();var n=iae.format(t);r=r||n;var i={__source__:r};return this.sources[r]={href:n,type:e},this.push(i),oae.request(t,function(o){var s=[],a=o.headers["content-type"];e||(e=a.indexOf("json")!==-1?"json":a.indexOf("ini")!==-1?"ini":n.match(/\.json$/)?"json":n.match(/\.ini$/)?"ini":null,i.type=e),o.on("data",s.push.bind(s)).on("end",function(){this.addString(Buffer.concat(s),n,e,i)}.bind(this)).on("error",this.emit.bind(this,"error"))}.bind(this)).on("error",this.emit.bind(this,"error")).end(),this};Ot.prototype.addString=function(t,e,r,n){return t=this.parse(t,e,r),this.add(t,n),this};Ot.prototype.add=function(t,e){if(e&&typeof e=="object"){var r=this.list.indexOf(e);if(r===-1)return this.emit("error",new Error("bad marker"));this.splice(r,1,t),e=e.__source__,this.sources[e]=this.sources[e]||{},this.sources[e].data=t,this._resolve()}else typeof e=="string"&&(this.sources[e]=this.sources[e]||{},this.sources[e].data=t),this._await(),this.push(t),process.nextTick(this._resolve.bind(this));return this};Ot.prototype.parse=Nn.parse;Ot.prototype._await=function(){this._awaiting++};Ot.prototype._resolve=function(){this._awaiting--,this._awaiting===0&&this.emit("load",this)}});var c8=D((Cye,u8)=>{u8.exports=function(t){let e=t.indexOf(":");if(e===-1)return Eb(t);let r=t.substr(0,e),n=t.substr(e+1);return`${Eb(r)}:${Eb(n)}`};function Eb(t){if(t=t.toLowerCase(),t==="_authtoken")return"_authToken";let e=t[0];for(let r=1;r<t.length;r++)e+=t[r]==="_"?"-":t[r];return e}});var l8=D(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});Hh.envReplace=void 0;var uae=/(?<!\\)(\\*)\$\{([^${}]+)\}/g;function cae(t,e){return t.replace(uae,lae.bind(null,e))}Hh.envReplace=cae;function lae(t,e,r,n){if(r.length%2)return e.slice((r.length+1)/2);let i=dae(t,n);if(i===void 0)throw new Error(`Failed to replace env in config: ${e}`);return`${r.slice(r.length/2)}${i}`}var fae=/([^:-]+)(:?)-(.+)/;function dae(t,e){let r=e.match(fae);if(!r)return t[e];let[,n,i,o]=r;return Object.prototype.hasOwnProperty.call(t,n)?!t[n]&&i?o:t[n]:o}});var f8=D(Vh=>{"use strict";Object.defineProperty(Vh,"__esModule",{value:!0});Vh.envReplace=void 0;var hae=l8();Object.defineProperty(Vh,"envReplace",{enumerable:!0,get:function(){return hae.envReplace}})});var h8=D(zh=>{"use strict";var pae=require("fs"),Fo=require("path"),{envReplace:d8}=f8(),mae=(t,e,r)=>{if(typeof e!="string")return e;let n=[].concat(t[r]),i=n.indexOf(Fo)!==-1,o=n.indexOf(Boolean)!==-1,s=n.indexOf(String)!==-1,a=n.indexOf(Number)!==-1;if(e=`${e}`.trim(),/^".*"$/.test(e))try{e=JSON.parse(e)}catch{throw new Error(`Failed parsing JSON config key ${r}: ${e}`)}if(o&&!s&&e==="")return!0;switch(e){case"true":return!0;case"false":return!1;case"null":return null;case"undefined":return}return e=d8(e,process.env),i&&((process.platform==="win32"?/^~(\/|\\)/:/^~\//).test(e)&&process.env.HOME&&(e=Fo.resolve(process.env.HOME,e.substr(2))),e=Fo.resolve(e)),a&&!isNaN(e)&&(e=Number(e)),e},gae=t=>{t=Fo.resolve(t);let e=!1;for(;Fo.basename(t)==="node_modules";)t=Fo.dirname(t),e=!0;if(e)return t;let r=(n,i)=>{let o=/^[a-zA-Z]:(\\|\/)?$/;if(n==="/"||process.platform==="win32"&&o.test(n))return i;try{let s=pae.readdirSync(n);if(s.includes("node_modules")||s.includes("package.json")||s.includes("package.json5")||s.includes("package.yaml")||s.includes("pnpm-workspace.yaml"))return n;let a=Fo.dirname(n);return a===n?i:r(a,i)}catch(s){if(n===i){if(s.code==="ENOENT")return i;throw s}return i}};return r(t,t)};zh.envReplace=d8;zh.findPrefix=gae;zh.parseField=mae});var g8=D(m8=>{"use strict";var Oo=require("path"),yae=require("stream").Stream,Gh=require("url"),Dae=()=>{},vae=()=>[],p8=()=>{};m8.types={access:[null,"restricted","public"],"allow-same-version":Boolean,"always-auth":Boolean,also:[null,"dev","development"],audit:Boolean,"auth-type":["legacy","sso","saml","oauth"],"bin-links":Boolean,browser:[null,String],ca:[null,String,Array],cafile:Oo,cache:Oo,"cache-lock-stale":Number,"cache-lock-retries":Number,"cache-lock-wait":Number,"cache-max":Number,"cache-min":Number,cert:[null,String],cidr:[null,String,Array],color:["always",Boolean],depth:Number,description:Boolean,dev:Boolean,"dry-run":Boolean,editor:String,"engine-strict":Boolean,force:Boolean,"fetch-retries":Number,"fetch-retry-factor":Number,"fetch-retry-mintimeout":Number,"fetch-retry-maxtimeout":Number,git:String,"git-tag-version":Boolean,"commit-hooks":Boolean,global:Boolean,globalconfig:Oo,"global-style":Boolean,group:[Number,String],"https-proxy":[null,Gh],"user-agent":String,"ham-it-up":Boolean,heading:String,"if-present":Boolean,"ignore-prepublish":Boolean,"ignore-scripts":Boolean,"init-module":Oo,"init-author-name":String,"init-author-email":String,"init-author-url":["",Gh],"init-license":String,"init-version":p8,json:Boolean,key:[null,String],"legacy-bundling":Boolean,link:Boolean,"local-address":vae(),loglevel:["silent","error","warn","notice","http","timing","info","verbose","silly"],logstream:yae,"logs-max":Number,long:Boolean,maxsockets:Number,message:String,"metrics-registry":[null,String],"node-options":[null,String],"node-version":[null,p8],"no-proxy":[null,String,Array],offline:Boolean,"onload-script":[null,String],only:[null,"dev","development","prod","production"],optional:Boolean,"package-lock":Boolean,otp:[null,String],"package-lock-only":Boolean,parseable:Boolean,"prefer-offline":Boolean,"prefer-online":Boolean,prefix:Oo,production:Boolean,progress:Boolean,proxy:[null,!1,Gh],provenance:Boolean,"read-only":Boolean,"rebuild-bundle":Boolean,registry:[null,Gh],rollback:Boolean,save:Boolean,"save-bundle":Boolean,"save-dev":Boolean,"save-exact":Boolean,"save-optional":Boolean,"save-prefix":String,"save-prod":Boolean,scope:String,"script-shell":[null,String],"scripts-prepend-node-path":[!1,!0,"auto","warn-only"],searchopts:String,searchexclude:[null,String],searchlimit:Number,searchstaleness:Number,"send-metrics":Boolean,shell:String,shrinkwrap:Boolean,"sign-git-tag":Boolean,"sso-poll-frequency":Number,"sso-type":[null,"oauth","saml"],"strict-ssl":Boolean,tag:String,timing:Boolean,tmp:Oo,unicode:Boolean,"unsafe-perm":Boolean,usage:Boolean,user:[Number,String],userconfig:Oo,umask:Dae,version:Boolean,"tag-version-prefix":String,versions:Boolean,viewer:String,_exit:Boolean}});var b8=D((Aye,v8)=>{"use strict";var{readCAFileSync:bae}=Jj(),y8=require("fs"),Cb=require("path"),{ConfigChain:wae}=a8(),_ae=c8(),D8=h8(),Sb=class extends wae{constructor(e,r){super(e),this.root=e,this._parseField=D8.parseField.bind(null,r||g8())}add(e,r){try{for(let n of Object.keys(e))e[n]=this._parseField(e[n],n)}catch(n){throw n}return super.add(e,r)}addFile(e,r){r=r||e;let n={__source__:r};this.sources[r]={path:e,type:"ini"},this.push(n),this._await();try{let i=y8.readFileSync(e,"utf8");this.addString(i,e,"ini",n)}catch(i){if(i.code==="ENOENT")this.add({},n);else return`Issue while reading "${e}". ${i.message}`}}addEnv(e){e=e||process.env;let r={};return Object.keys(e).filter(n=>/^npm_config_/i.test(n)).forEach(n=>{e[n]&&(r[_ae(n.substr(11))]=e[n])}),super.addEnv("",r,"env")}loadPrefix(){let e=this.list[0];Object.defineProperty(this,"prefix",{enumerable:!0,set:n=>{let i=this.get("global");this[i?"globalPrefix":"localPrefix"]=n},get:()=>this.get("global")?this.globalPrefix:this.localPrefix}),Object.defineProperty(this,"globalPrefix",{enumerable:!0,set:n=>{this.set("prefix",n)},get:()=>Cb.resolve(this.get("prefix"))});let r;if(Object.defineProperty(this,"localPrefix",{enumerable:!0,set:n=>{r=n},get:()=>r}),Object.prototype.hasOwnProperty.call(e,"prefix"))r=Cb.resolve(e.prefix);else try{r=D8.findPrefix(process.cwd())}catch(n){throw n}return r}loadCAFile(e){if(!e)return;let r=bae(e);r&&this.set("ca",r)}loadUser(){let e=this.root;if(this.get("global"))return;if(process.env.SUDO_UID){e.user=Number(process.env.SUDO_UID);return}let r=Cb.resolve(this.get("prefix"));try{let n=y8.statSync(r);e.user=n.uid}catch(n){if(n.code==="ENOENT")return;throw n}}};v8.exports=Sb});var x8=D(S8=>{"use strict";var E8=require("os"),Ln=require("path"),C8=E8.tmpdir(),Eae=process.getuid?process.getuid():process.pid,Cae=()=>!0,w8=process.platform==="win32",_8={editor:()=>process.env.EDITOR||process.env.VISUAL||(w8?"notepad.exe":"vi"),shell:()=>w8?process.env.COMSPEC||"cmd.exe":process.env.SHELL||"/bin/bash"},Sae={fromString:()=>process.umask()},Ea=E8.homedir();Ea?process.env.HOME=Ea:Ea=Ln.resolve(C8,"npm-"+Eae);var xae=process.platform==="win32"?"npm-cache":".npm",Fae=process.platform==="win32"&&process.env.APPDATA||Ea,Oae=Ln.resolve(Fae,xae),Wh,Ao;Object.defineProperty(S8,"defaults",{get:function(){return Wh||(process.env.PREFIX?Ao=process.env.PREFIX:process.platform==="win32"?Ao=Ln.dirname(process.execPath):(Ao=Ln.dirname(Ln.dirname(process.execPath)),process.env.DESTDIR&&(Ao=Ln.join(process.env.DESTDIR,Ao))),Wh={access:null,"allow-same-version":!1,"always-auth":!1,also:null,audit:!0,"auth-type":"legacy","bin-links":!0,browser:null,ca:null,cafile:null,cache:Oae,"cache-lock-stale":6e4,"cache-lock-retries":10,"cache-lock-wait":1e4,"cache-max":1/0,"cache-min":10,cert:null,cidr:null,color:process.env.NO_COLOR==null,depth:1/0,description:!0,dev:!1,"dry-run":!1,editor:_8.editor(),"engine-strict":!1,force:!1,"fetch-retries":2,"fetch-retry-factor":10,"fetch-retry-mintimeout":1e4,"fetch-retry-maxtimeout":6e4,git:"git","git-tag-version":!0,"commit-hooks":!0,global:!1,globalconfig:Ln.resolve(Ao,"etc","npmrc"),"global-style":!1,group:process.platform==="win32"?0:process.env.SUDO_GID||process.getgid&&process.getgid(),"ham-it-up":!1,heading:"npm","if-present":!1,"ignore-prepublish":!1,"ignore-scripts":!1,"init-module":Ln.resolve(Ea,".npm-init.js"),"init-author-name":"","init-author-email":"","init-author-url":"","init-version":"1.0.0","init-license":"ISC",json:!1,key:null,"legacy-bundling":!1,link:!1,"local-address":void 0,loglevel:"notice",logstream:process.stderr,"logs-max":10,long:!1,maxsockets:50,message:"%s","metrics-registry":null,"node-options":null,offline:!1,"onload-script":!1,only:null,optional:!0,otp:null,"package-lock":!0,"package-lock-only":!1,parseable:!1,"prefer-offline":!1,"prefer-online":!1,prefix:Ao,production:process.env.NODE_ENV==="production",progress:!process.env.TRAVIS&&!process.env.CI,provenance:!1,proxy:null,"https-proxy":null,"no-proxy":null,"user-agent":"npm/{npm-version} node/{node-version} {platform} {arch}","read-only":!1,"rebuild-bundle":!0,registry:"https://registry.npmjs.org/",rollback:!0,save:!0,"save-bundle":!1,"save-dev":!1,"save-exact":!1,"save-optional":!1,"save-prefix":"^","save-prod":!1,scope:"","script-shell":null,"scripts-prepend-node-path":"warn-only",searchopts:"",searchexclude:null,searchlimit:20,searchstaleness:15*60,"send-metrics":!1,shell:_8.shell(),shrinkwrap:!0,"sign-git-tag":!1,"sso-poll-frequency":500,"sso-type":"oauth","strict-ssl":!0,tag:"latest","tag-version-prefix":"v",timing:!1,tmp:C8,unicode:Cae(),"unsafe-perm":process.platform==="win32"||process.platform==="cygwin"||!(process.getuid&&process.setuid&&process.getgid&&process.setgid)||process.getuid()!==0,usage:!1,user:process.platform==="win32"?0:"nobody",userconfig:Ln.resolve(Ea,".npmrc"),umask:process.umask?process.umask():Sae.fromString("022"),version:!1,versions:!1,viewer:process.platform==="win32"?"browser":"man",_exit:!0},Wh)}})});var O8=D((Tye,xb)=>{"use strict";var ko=require("path"),Aae=b8(),F8=x8();xb.exports=(t,e,r)=>{let n=new Aae(Object.assign({},F8.defaults,r),e);n.add(Object.assign({},t),"cli");let i=[],o=!1;if(require.resolve.paths){let c=require.resolve.paths("npm"),l;try{l=require.resolve("npm",{paths:c.slice(-1)})}catch{o=!0}l&&i.push(n.addFile(ko.resolve(ko.dirname(l),"..","npmrc"),"builtin"))}n.addEnv(),n.loadPrefix();let s=ko.resolve(n.localPrefix,".npmrc"),a=n.get("userconfig");if(!n.get("global")&&s!==a?i.push(n.addFile(s,"project")):n.add({},"project"),n.get("workspace-prefix")&&n.get("workspace-prefix")!==s){let c=ko.resolve(n.get("workspace-prefix"),".npmrc");i.push(n.addFile(c,"workspace"))}if(i.push(n.addFile(n.get("userconfig"),"user")),n.get("prefix")){let c=ko.resolve(n.get("prefix"),"etc");n.root.globalconfig=ko.resolve(c,"npmrc"),n.root.globalignorefile=ko.resolve(c,"npmignore")}i.push(n.addFile(n.get("globalconfig"),"global")),n.loadUser();let u=n.get("cafile");return u&&n.loadCAFile(u),{config:n,warnings:i.filter(Boolean),failedToLoadBuiltInConfig:o}};Object.defineProperty(xb.exports,"defaults",{get(){return F8.defaults},enumerable:!0})});var j8=D((Pye,I8)=>{var Fb=require("url"),A8=O8(),k8=":_authToken",T8=":_auth",P8=":username",R8=":_password";I8.exports=function(){let e,r;arguments.length>=2?(e=arguments[0],r=Object.assign({},arguments[1])):typeof arguments[0]=="string"?e=arguments[0]:r=Object.assign({},arguments[0]),r=r||{};let n=r.npmrc;return r.npmrc=(r.npmrc?{config:{get:i=>n[i]}}:A8()).config,e=e||r.npmrc.get("registry")||A8.defaults.registry,$8(e,r)||kae(r.npmrc)};function $8(t,e){let r=Fb.parse(t,!1,!0),n;for(;n!=="/"&&r.pathname!==n;){n=r.pathname||"/";let i="//"+r.host+n.replace(/\/$/,""),o=Pae(i,e.npmrc);if(o)return o;if(!e.recursive)return/\/$/.test(t)?void 0:$8(Fb.resolve(t,"."),e);r.pathname=Fb.resolve(Tae(n),"..")||"/"}}function kae(t){return t.get("_auth")?{token:Kh(t.get("_auth")),type:"Basic"}:void 0}function Tae(t){return t[t.length-1]==="/"?t:t+"/"}function Pae(t,e){let r=Rae(e.get(t+k8)||e.get(t+"/"+k8));if(r)return r;let n=e.get(t+P8)||e.get(t+"/"+P8),i=e.get(t+R8)||e.get(t+"/"+R8),o=$ae(n,i);if(o)return o;let s=Iae(e.get(t+T8)||e.get(t+"/"+T8));if(s)return s}function Kh(t){return t.replace(/^\$\{?([^}]*)\}?$/,function(e,r){return process.env[r]})}function Rae(t){return t?{token:Kh(t),type:"Bearer"}:void 0}function $ae(t,e){if(!t||!e)return;let r=Buffer.from(Kh(e),"base64").toString("utf8");return{token:Buffer.from(t+":"+r,"utf8").toString("base64"),type:"Basic",password:r,username:t}}function Iae(t){return t?{token:Kh(t),type:"Basic"}:void 0}});var IL=D((Pwe,Hn)=>{var ot=require("fs"),nw=require("os"),dr=require("path"),bL=require("crypto"),ln={fs:ot.constants,os:nw.constants},wL="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",EL=/XXXXXX/,wue=3,CL=(ln.O_CREAT||ln.fs.O_CREAT)|(ln.O_EXCL||ln.fs.O_EXCL)|(ln.O_RDWR||ln.fs.O_RDWR),_ue=nw.platform()==="win32",Eue=ln.EBADF||ln.os.errno.EBADF,Cue=ln.ENOENT||ln.os.errno.ENOENT,SL=448,xL=384,Sue="exit",Pa=[],FL=ot.rmdirSync.bind(ot),OL=!1;function xue(t,e){return ot.rm(t,{recursive:!0},e)}function AL(t){return ot.rmSync(t,{recursive:!0})}function iw(t,e){let r=Ra(t,e),n=r[0],i=r[1];try{PL(n)}catch(s){return i(s)}let o=n.tries;(function s(){try{let a=TL(n);ot.stat(a,function(u){if(!u)return o-- >0?s():i(new Error("Could not get a unique tmp filename, max tries reached "+a));i(null,a)})}catch(a){i(a)}})()}function ow(t){let e=Ra(t),r=e[0];PL(r);let n=r.tries;do{let i=TL(r);try{ot.statSync(i)}catch{return i}}while(n-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function Fue(t,e){let r=Ra(t,e),n=r[0],i=r[1];iw(n,function(s,a){if(s)return i(s);ot.open(a,CL,n.mode||xL,function(c,l){if(c)return i(c);if(n.discardDescriptor)return ot.close(l,function(h){return i(h,a,void 0,ew(a,-1,n,!1))});{let f=n.discardDescriptor||n.detachDescriptor;i(null,a,l,ew(a,f?-1:l,n,!1))}})})}function Oue(t){let e=Ra(t),r=e[0],n=r.discardDescriptor||r.detachDescriptor,i=ow(r);var o=ot.openSync(i,CL,r.mode||xL);return r.discardDescriptor&&(ot.closeSync(o),o=void 0),{name:i,fd:o,removeCallback:ew(i,n?-1:o,r,!0)}}function Aue(t,e){let r=Ra(t,e),n=r[0],i=r[1];iw(n,function(s,a){if(s)return i(s);ot.mkdir(a,n.mode||SL,function(c){if(c)return i(c);i(null,a,kL(a,n,!1))})})}function kue(t){let e=Ra(t),r=e[0],n=ow(r);return ot.mkdirSync(n,r.mode||SL),{name:n,removeCallback:kL(n,r,!0)}}function Tue(t,e){let r=function(n){if(n&&!rw(n))return e(n);e()};0<=t[0]?ot.close(t[0],function(){ot.unlink(t[1],r)}):ot.unlink(t[1],r)}function Pue(t){let e=null;try{0<=t[0]&&ot.closeSync(t[0])}catch(r){if(!Iue(r)&&!rw(r))throw r}finally{try{ot.unlinkSync(t[1])}catch(r){rw(r)||(e=r)}}if(e!==null)throw e}function ew(t,e,r,n){let i=vp(Pue,[e,t],n),o=vp(Tue,[e,t],n,i);return r.keep||Pa.unshift(i),n?i:o}function kL(t,e,r){let n=e.unsafeCleanup?xue:ot.rmdir.bind(ot),i=e.unsafeCleanup?AL:FL,o=vp(i,t,r),s=vp(n,t,r,o);return e.keep||Pa.unshift(o),r?o:s}function vp(t,e,r,n){let i=!1;return function o(s){if(!i){let a=n||o,u=Pa.indexOf(a);return u>=0&&Pa.splice(u,1),i=!0,r||t===FL||t===AL?t(e):t(e,s||function(){})}}}function Rue(){if(OL)for(;Pa.length;)try{Pa[0]()}catch{}}function _L(t){let e=[],r=null;try{r=bL.randomBytes(t)}catch{r=bL.pseudoRandomBytes(t)}for(var n=0;n<t;n++)e.push(wL[r[n]%wL.length]);return e.join("")}function $ue(t){return t===null||tr(t)||!t.trim()}function tr(t){return typeof t>"u"}function Ra(t,e){if(typeof t=="function")return[{},t];if(tr(t))return[{},e];let r={};for(let n of Object.getOwnPropertyNames(t))r[n]=t[n];return[r,e]}function TL(t){let e=t.tmpdir;if(!tr(t.name))return dr.join(e,t.dir,t.name);if(!tr(t.template))return dr.join(e,t.dir,t.template).replace(EL,_L(6));let r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",_L(12),t.postfix?"-"+t.postfix:""].join("");return dr.join(e,t.dir,r)}function PL(t){t.tmpdir=$L(t);let e=t.tmpdir;if(tr(t.name)||Qb(t.name,"name",e),tr(t.dir)||Qb(t.dir,"dir",e),!tr(t.template)&&(Qb(t.template,"template",e),!t.template.match(EL)))throw new Error(`Invalid template, found "${t.template}".`);if(!tr(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=tr(t.name)?t.tries||wue:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.dir=tr(t.dir)?"":dr.relative(e,tw(t.dir,e)),t.template=tr(t.template)?void 0:dr.relative(e,tw(t.template,e)),t.template=$ue(t.template)?void 0:dr.relative(t.dir,t.template),t.name=tr(t.name)?void 0:t.name,t.prefix=tr(t.prefix)?"":t.prefix,t.postfix=tr(t.postfix)?"":t.postfix}function tw(t,e){return t.startsWith(e)?dr.resolve(t):dr.resolve(dr.join(e,t))}function Qb(t,e,r){if(e==="name"){if(dr.isAbsolute(t))throw new Error(`${e} option must not contain an absolute path, found "${t}".`);let n=dr.basename(t);if(n===".."||n==="."||n!==t)throw new Error(`${e} option must not contain a path, found "${t}".`)}else{if(dr.isAbsolute(t)&&!t.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${t}".`);let n=tw(t,r);if(!n.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${n}".`)}}function Iue(t){return RL(t,-Eue,"EBADF")}function rw(t){return RL(t,-Cue,"ENOENT")}function RL(t,e,r){return _ue?t.code===r:t.code===r&&t.errno===e}function jue(){OL=!0}function $L(t){return dr.resolve(t&&t.tmpdir||nw.tmpdir())}process.addListener(Sue,Rue);Object.defineProperty(Hn.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return $L()}});Hn.exports.dir=Aue;Hn.exports.dirSync=kue;Hn.exports.file=Fue;Hn.exports.fileSync=Oue;Hn.exports.tmpName=iw;Hn.exports.tmpNameSync=ow;Hn.exports.setGracefulCleanup=jue});var xw=ce(Sw(),1),{program:A,createCommand:pce,createArgument:mce,createOption:gce,CommanderError:yce,InvalidArgumentError:Dce,InvalidOptionArgumentError:vce,Command:bce,Argument:wce,Option:_ce,Help:Ece}=xw.default;var Ir={name:"@capgo/cli",version:"4.27.8",description:"A CLI to upload to capgo servers",author:"github.com/riderx",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLIl#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli"],main:"dist/index.js",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && node build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js",test:"npx --yes ts-node -T src/index.ts","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",test_rls:"ts-node ./test/test_headers_rls.ts",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js"},devDependencies:{"@antfu/eslint-config":"^3.9.2","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client","@capacitor/cli":"^6.2.0","@capgo/find-package-manager":"^0.0.17","@clack/prompts":"^0.9.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver","@supabase/supabase-js":"^2.46.0","@tomasklaen/checksum":"^1.1.0","@types/adm-zip":"^0.5.6","@types/node":"^22.8.4","@types/prettyjson":"^0.0.33","@types/semver":"7.5.8","@types/tmp":"^0.2.6","@typescript-eslint/eslint-plugin":"^8.15.0","@typescript-eslint/parser":"^8.15.0","@vercel/ncc":"^0.38.3","adm-zip":"^0.5.16","ci-info":"^4.1.0",commander:"12.1.0",esbuild:"^0.24.0",eslint:"9.17.0","git-format-staged":"3.1.1",husky:"^9.1.7","is-wsl":"^3.1.0",ky:"^1.7.2","latest-version":"^9.0.0",open:"^10.1.0",pkg:"5.8.1",prettyjson:"^1.2.5",semver:"^7.6.3",tmp:"^0.2.3","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"4.2.0","tus-js-client":"^4.2.3",typescript:"5.7.2"}};var Ca=require("node:fs"),B8=require("node:process");var Et=ce(Te(),1),Lo=require("node:process"),Gn=ce(require("node:readline"),1),zp=ce(require("node:readline"),1),Nw=require("node:tty"),sl=ce(Up(),1);function SB({onlyFirst:t=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}var xB=SB();function Lw(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(xB,"")}function Bw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qw={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(n){var i=n.charCodeAt(0),o=n.length==2?n.charCodeAt(1):0,s=i;return 55296<=i&&i<=56319&&56320<=o&&o<=57343&&(i&=1023,o&=1023,s=i<<10|o,s+=65536),s==12288||65281<=s&&s<=65376||65504<=s&&s<=65510?"F":s==8361||65377<=s&&s<=65470||65474<=s&&s<=65479||65482<=s&&s<=65487||65490<=s&&s<=65495||65498<=s&&s<=65500||65512<=s&&s<=65518?"H":4352<=s&&s<=4447||4515<=s&&s<=4519||4602<=s&&s<=4607||9001<=s&&s<=9002||11904<=s&&s<=11929||11931<=s&&s<=12019||12032<=s&&s<=12245||12272<=s&&s<=12283||12289<=s&&s<=12350||12353<=s&&s<=12438||12441<=s&&s<=12543||12549<=s&&s<=12589||12593<=s&&s<=12686||12688<=s&&s<=12730||12736<=s&&s<=12771||12784<=s&&s<=12830||12832<=s&&s<=12871||12880<=s&&s<=13054||13056<=s&&s<=19903||19968<=s&&s<=42124||42128<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||55216<=s&&s<=55238||55243<=s&&s<=55291||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65106||65108<=s&&s<=65126||65128<=s&&s<=65131||110592<=s&&s<=110593||127488<=s&&s<=127490||127504<=s&&s<=127546||127552<=s&&s<=127560||127568<=s&&s<=127569||131072<=s&&s<=194367||177984<=s&&s<=196605||196608<=s&&s<=262141?"W":32<=s&&s<=126||162<=s&&s<=163||165<=s&&s<=166||s==172||s==175||10214<=s&&s<=10221||10629<=s&&s<=10630?"Na":s==161||s==164||167<=s&&s<=168||s==170||173<=s&&s<=174||176<=s&&s<=180||182<=s&&s<=186||188<=s&&s<=191||s==198||s==208||215<=s&&s<=216||222<=s&&s<=225||s==230||232<=s&&s<=234||236<=s&&s<=237||s==240||242<=s&&s<=243||247<=s&&s<=250||s==252||s==254||s==257||s==273||s==275||s==283||294<=s&&s<=295||s==299||305<=s&&s<=307||s==312||319<=s&&s<=322||s==324||328<=s&&s<=331||s==333||338<=s&&s<=339||358<=s&&s<=359||s==363||s==462||s==464||s==466||s==468||s==470||s==472||s==474||s==476||s==593||s==609||s==708||s==711||713<=s&&s<=715||s==717||s==720||728<=s&&s<=731||s==733||s==735||768<=s&&s<=879||913<=s&&s<=929||931<=s&&s<=937||945<=s&&s<=961||963<=s&&s<=969||s==1025||1040<=s&&s<=1103||s==1105||s==8208||8211<=s&&s<=8214||8216<=s&&s<=8217||8220<=s&&s<=8221||8224<=s&&s<=8226||8228<=s&&s<=8231||s==8240||8242<=s&&s<=8243||s==8245||s==8251||s==8254||s==8308||s==8319||8321<=s&&s<=8324||s==8364||s==8451||s==8453||s==8457||s==8467||s==8470||8481<=s&&s<=8482||s==8486||s==8491||8531<=s&&s<=8532||8539<=s&&s<=8542||8544<=s&&s<=8555||8560<=s&&s<=8569||s==8585||8592<=s&&s<=8601||8632<=s&&s<=8633||s==8658||s==8660||s==8679||s==8704||8706<=s&&s<=8707||8711<=s&&s<=8712||s==8715||s==8719||s==8721||s==8725||s==8730||8733<=s&&s<=8736||s==8739||s==8741||8743<=s&&s<=8748||s==8750||8756<=s&&s<=8759||8764<=s&&s<=8765||s==8776||s==8780||s==8786||8800<=s&&s<=8801||8804<=s&&s<=8807||8810<=s&&s<=8811||8814<=s&&s<=8815||8834<=s&&s<=8835||8838<=s&&s<=8839||s==8853||s==8857||s==8869||s==8895||s==8978||9312<=s&&s<=9449||9451<=s&&s<=9547||9552<=s&&s<=9587||9600<=s&&s<=9615||9618<=s&&s<=9621||9632<=s&&s<=9633||9635<=s&&s<=9641||9650<=s&&s<=9651||9654<=s&&s<=9655||9660<=s&&s<=9661||9664<=s&&s<=9665||9670<=s&&s<=9672||s==9675||9678<=s&&s<=9681||9698<=s&&s<=9701||s==9711||9733<=s&&s<=9734||s==9737||9742<=s&&s<=9743||9748<=s&&s<=9749||s==9756||s==9758||s==9792||s==9794||9824<=s&&s<=9825||9827<=s&&s<=9829||9831<=s&&s<=9834||9836<=s&&s<=9837||s==9839||9886<=s&&s<=9887||9918<=s&&s<=9919||9924<=s&&s<=9933||9935<=s&&s<=9953||s==9955||9960<=s&&s<=9983||s==10045||s==10071||10102<=s&&s<=10111||11093<=s&&s<=11097||12872<=s&&s<=12879||57344<=s&&s<=63743||65024<=s&&s<=65039||s==65533||127232<=s&&s<=127242||127248<=s&&s<=127277||127280<=s&&s<=127337||127344<=s&&s<=127386||917760<=s&&s<=917999||983040<=s&&s<=1048573||1048576<=s&&s<=1114109?"A":"N"},e.characterLength=function(n){var i=this.eastAsianWidth(n);return i=="F"||i=="W"||i=="A"?2:1};function r(n){return n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(n){for(var i=r(n),o=0,s=0;s<i.length;s++)o=o+this.characterLength(i[s]);return o},e.slice=function(n,i,o){textLen=e.length(n),i=i||0,o=o||1,i<0&&(i=textLen+i),o<0&&(o=textLen+o);for(var s="",a=0,u=r(n),c=0;c<u.length;c++){var l=u[c],f=e.length(l);if(a>=i-(f==2?1:0))if(a+f<=o)s+=l;else break;a+=f}return s}})(qw);var FB=qw.exports,OB=Bw(FB),AB=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},kB=Bw(AB);function Na(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=Lw(t),t.length===0))return 0;t=t.replace(kB()," ");let r=e.ambiguousIsNarrow?1:2,n=0;for(let i of t){let o=i.codePointAt(0);if(!(o<=31||o>=127&&o<=159||o>=768&&o<=879))switch(OB.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}var Hp=10,kw=(t=0)=>e=>`\x1B[${e+t}m`,Tw=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,Pw=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,$e={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys($e.modifier);var TB=Object.keys($e.color),PB=Object.keys($e.bgColor);[...TB,...PB];function RB(){let t=new Map;for(let[e,r]of Object.entries($e)){for(let[n,i]of Object.entries(r))$e[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=$e[n],t.set(i[0],i[1]);Object.defineProperty($e,e,{value:r,enumerable:!1})}return Object.defineProperty($e,"codes",{value:t,enumerable:!1}),$e.color.close="\x1B[39m",$e.bgColor.close="\x1B[49m",$e.color.ansi=kw(),$e.color.ansi256=Tw(),$e.color.ansi16m=Pw(),$e.bgColor.ansi=kw(Hp),$e.bgColor.ansi256=Tw(Hp),$e.bgColor.ansi16m=Pw(Hp),Object.defineProperties($e,{rgbToAnsi256:{value:(e,r,n)=>e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>$e.rgbToAnsi256(...$e.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>$e.ansi256ToAnsi($e.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>$e.ansi256ToAnsi($e.hexToAnsi256(e)),enumerable:!1}}),$e}var $B=RB(),fl=new Set(["\x1B","\x9B"]),IB=39,Wp="\x07",Mw="[",jB="]",Uw="m",Kp=`${jB}8;;`,Rw=t=>`${fl.values().next().value}${Mw}${t}${Uw}`,$w=t=>`${fl.values().next().value}${Kp}${t}${Wp}`,NB=t=>t.split(" ").map(e=>Na(e)),Vp=(t,e,r)=>{let n=[...e],i=!1,o=!1,s=Na(Lw(t[t.length-1]));for(let[a,u]of n.entries()){let c=Na(u);if(s+c<=r?t[t.length-1]+=u:(t.push(u),s=0),fl.has(u)&&(i=!0,o=n.slice(a+1).join("").startsWith(Kp)),i){o?u===Wp&&(i=!1,o=!1):u===Uw&&(i=!1);continue}s+=c,s===r&&a<n.length-1&&(t.push(""),s=0)}!s&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},LB=t=>{let e=t.split(" "),r=e.length;for(;r>0&&!(Na(e[r-1])>0);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},BB=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let n="",i,o,s=NB(t),a=[""];for(let[c,l]of t.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let f=Na(a[a.length-1]);if(c!==0&&(f>=e&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),f=0),(f>0||r.trim===!1)&&(a[a.length-1]+=" ",f++)),r.hard&&s[c]>e){let h=e-f,d=1+Math.floor((s[c]-h-1)/e);Math.floor((s[c]-1)/e)<d&&a.push(""),Vp(a,l,e);continue}if(f+s[c]>e&&f>0&&s[c]>0){if(r.wordWrap===!1&&f<e){Vp(a,l,e);continue}a.push("")}if(f+s[c]>e&&r.wordWrap===!1){Vp(a,l,e);continue}a[a.length-1]+=l}r.trim!==!1&&(a=a.map(c=>LB(c)));let u=[...a.join(`
201
201
  `)];for(let[c,l]of u.entries()){if(n+=l,fl.has(l)){let{groups:h}=new RegExp(`(?:\\${Mw}(?<code>\\d+)m|\\${Kp}(?<uri>.*)${Wp})`).exec(u.slice(c).join(""))||{groups:{}};if(h.code!==void 0){let d=Number.parseFloat(h.code);i=d===IB?void 0:d}else h.uri!==void 0&&(o=h.uri.length===0?void 0:h.uri)}let f=$B.codes.get(Number(i));u[c+1]===`
202
202
  `?(o&&(n+=$w("")),i&&f&&(n+=Rw(f))):l===`
203
203
  `&&(i&&f&&(n+=Rw(i)),o&&(n+=$w(o)))}return n};function Iw(t,e,r){return String(t).normalize().replace(/\r\n/g,`
@@ -242,20 +242,20 @@ ${V.default.gray(Bo)} ${t}
242
242
  `);let w=a.split(`
243
243
  `);process.stdout.write(dl.cursor.move(-999,w.length-1)),process.stdout.write(dl.erase.down(w.length))},p=w=>w.replace(/\.+$/,""),b=(w="")=>{o=!0,n=Hw(),s=p(w),process.stdout.write(`${V.default.gray(Ke)}
244
244
  `);let S=0,y=0;f(),i=setInterval(()=>{if(r&&s===a)return;d(),a=s;let C=V.default.magenta(t[S]),k=r?"...":".".repeat(Math.floor(y)).slice(0,3);process.stdout.write(`${C} ${s}${k}`),S=S+1<t.length?S+1:0,y=y<t.length?y+.125:0},e)},g=(w="",S=0)=>{o=!1,clearInterval(i),d();let y=S===0?V.default.green(Qp):S===1?V.default.red(Vw):V.default.red(zw);s=p(w??s),process.stdout.write(`${y} ${s}
245
- `),h(),n()};return{start:b,stop:g,message:(w="")=>{s=p(w??s)}}};var it=require("node:fs"),Th=require("node:os"),tt=ce(require("node:path")),ur=require("node:process"),vi=ce(pl());var yn=require("fs"),qa=(t=".",e="unknown")=>{let r=`${t}/bun.lockb`,n=`${t}/pnpm-lock.yaml`,i=`${t}/yarn.lock`,o=`${t}/package-lock.json`;return(0,yn.existsSync)(r)?"bun":(0,yn.existsSync)(n)?"pnpm":(0,yn.existsSync)(i)?"yarn":(0,yn.existsSync)(o)?"npm":e},ml=(t=qa(),e=!1)=>{switch(t){case"bun":return e?"bun install":"install";case"pnpm":return e?"pnpm install":"install";case"yarn":return e?"yarn install":"install";case"npm":return e?"npm install":"install";case"unknown":return e?"unknown unknown":"unknown";default:return e?"npm install":"install"}},Gw=(t=".",e="npx")=>{let r=`${t}/bun.lockb`,n=`${t}/pnpm-lock.yaml`,i=`${t}/yarn.lock`,o=`${t}/package-lock.json`;return(0,yn.existsSync)(r)?"bunx":(0,yn.existsSync)(n)?"pnpm exec":(0,yn.existsSync)(i)?"yarn dlx":(0,yn.existsSync)(o)?"npx":e};var fa=ce(H_()),J6=ce(vu()),ob=ce(NC());var ti=class extends Error{response;request;options;constructor(e,r,n){let i=e.status||e.status===0?e.status:"",o=e.statusText||"",s=`${i} ${o}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=e,this.request=r,this.options=n}};var ss=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};var as=t=>t!==null&&typeof t=="object";var wu=(...t)=>{for(let e of t)if((!as(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Hg({},...t)},Mg=(t={},e={})=>{let r=new globalThis.Headers(t),n=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(let[o,s]of i.entries())n&&s==="undefined"||s===void 0?r.delete(o):r.set(o,s);return r};function tf(t,e,r){return Object.hasOwn(e,r)&&e[r]===void 0?[]:Hg(t[r]??[],e[r]??[])}var Ug=(t={},e={})=>({beforeRequest:tf(t,e,"beforeRequest"),beforeRetry:tf(t,e,"beforeRetry"),afterResponse:tf(t,e,"afterResponse"),beforeError:tf(t,e,"beforeError")}),Hg=(...t)=>{let e={},r={},n={};for(let i of t)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(as(i)){for(let[o,s]of Object.entries(i))as(s)&&o in e&&(s=Hg(e[o],s)),e={...e,[o]:s};as(i.hooks)&&(n=Ug(n,i.hooks),e.hooks=n),as(i.headers)&&(r=Mg(r,i.headers),e.headers=r)}return e};var LC=(()=>{let t=!1,e=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),BC=typeof globalThis.AbortController=="function",qC=typeof globalThis.ReadableStream=="function",MC=typeof globalThis.FormData=="function",rf=["get","post","put","patch","head","delete"],c9=()=>{};c9();var UC={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},nf=2147483647,of=Symbol("stop"),HC={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},VC={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var GC=t=>rf.includes(t)?t.toUpperCase():t,l9=["get","put","head","delete","options","trace"],f9=[408,413,429,500,502,503,504],d9=[413,429,503],zC={limit:2,methods:l9,statusCodes:f9,afterStatusCodes:d9,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},WC=(t={})=>{if(typeof t=="number")return{...zC,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...zC,...t}};async function Vg(t,e,r,n){return new Promise((i,o)=>{let s=setTimeout(()=>{r&&r.abort(),o(new ss(t))},n.timeout);n.fetch(t,e).then(i).catch(o).then(()=>{clearTimeout(s)})})}async function zg(t,{signal:e}){return new Promise((r,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(o),n(e.reason)}let o=setTimeout(()=>{e?.removeEventListener("abort",i),r()},t)})}var KC=(t,e)=>{let r={};for(let n in e)!(n in VC)&&!(n in HC)&&!(n in t)&&(r[n]=e[n]);return r};var _u=class t{static create(e,r){let n=new t(e,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>nf)throw new RangeError(`The \`timeout\` option cannot be greater than ${nf}`);await Promise.resolve();let a=await n._fetch();for(let u of n._options.hooks.afterResponse){let c=await u(n.request,n._options,n._decorateResponse(a.clone()));c instanceof globalThis.Response&&(a=c)}if(n._decorateResponse(a),!a.ok&&n._options.throwHttpErrors){let u=new ti(a,n.request,n._options);for(let c of n._options.hooks.beforeError)u=await c(u);throw u}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!qC)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(a.clone(),n._options.onDownloadProgress)}return a},s=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[a,u]of Object.entries(UC))s[a]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||u);let l=(await s).clone();if(a==="json"){if(l.status===204||(await l.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await l.text())}return l[a]()};return s}request;abortController;_retryCount=0;_input;_options;constructor(e,r={}){if(this._input=e,this._options={...r,headers:Mg(this._input.headers,r.headers),hooks:Ug({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:GC(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:WC(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(BC){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(LC&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(MC&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(o,{...this.request}),this._options)}}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof ss)throw e;if(e instanceof ti){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;let n=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(e.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let o=this._options.retry.maxRetryAfter??i;return i<o?i:o}if(e.response.status===413)throw e}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(r){let n=Math.min(this._calculateRetryDelay(r),nf);if(this._retryCount<1)throw r;await zg(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===of)return;return this._retry(e)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let e=KC(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,e):Vg(r,e,this.abortController,this._options)}_stream(e,r){let n=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(o){let s=e.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function a(){let{done:u,value:c}=await s.read();if(u){o.close();return}if(r){i+=c.byteLength;let l=n===0?0:i/n;r({percent:l,transferredBytes:i,totalBytes:n},c)}o.enqueue(c),await a()}await a()}}),{status:e.status,statusText:e.statusText,headers:e.headers})}};var Gg=t=>{let e=(r,n)=>_u.create(r,wu(t,n));for(let r of rf)e[r]=(n,i)=>_u.create(n,wu(t,i,{method:r}));return e.create=r=>Gg(wu(r)),e.extend=r=>(typeof r=="function"&&(r=r(t??{})),Gg(wu(t,r))),e.stop=of,e},h9=Gg(),Vr=h9;var X6=ce(SS()),Ph=ce(aD());var kc=ce(f6());async function d6(){let t=await(0,kc.loadConfig)();return{config:t.app.extConfig,path:t.app.extConfigFilePath}}async function on(t,e=!1){let r=await(0,kc.loadConfig)(),{extConfig:n}=r.app;n&&(n.plugins||(n.plugins={extConfig:{},CapacitorUpdater:{}}),n.plugins.CapacitorUpdater||(n.plugins.CapacitorUpdater={}),e?n=t.config:n.plugins.CapacitorUpdater=t.config.plugins?.CapacitorUpdater,(0,kc.writeConfig)(n,r.app.extConfigFilePath))}var er=".capgo_key",cr=".capgo_key_v2",lr=`${er}.pub`,jn=`${cr}.pub`;var V6="https://capgo.app",z6="https://files.capgo.app",G6="https://api.capgo.app",W6="https://web.capgo.app",Z6=20,Q6=12e4,_se="package.json",da=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i,te=t=>t?`
246
- ${X6.default.render(t)}`:"";function K6(t){return new Promise(e=>{setTimeout(e,t)})}function sb(t){return(0,vi.isMonorepo)(t)?(0,vi.findMonorepoRoot)(t):(0,vi.isNXMonorepo)(t)?(0,vi.findNXMonorepoRoot)(t):t}async function jt(t=sb((0,ur.cwd)()),e=void 0){e&&((0,it.existsSync)(e)||(m.error(`Package.json at ${e} does not exist`),(0,ur.exit)(1)));let r=(0,it.readFileSync)(e||(0,tt.join)(t,_se));return JSON.parse(r)}async function Q(){try{let t=await d6();return t||(m.error("No capacitor config file found, run `cap init` first"),A.error("")),t}catch(t){m.error(`No capacitor config file found, run \`cap init\` first ${te(t)}`),A.error("")}}async function bo(t){let e=await Q();return e?.config&&(e.config.plugins||(e.config.plugins={extConfig:{},CapacitorUpdater:{}}),e.config.plugins.CapacitorUpdater||(e.config.plugins.CapacitorUpdater={}),e.config.plugins.CapacitorUpdater={...e.config.plugins.CapacitorUpdater,...t},on(e)),e}async function Cr(){try{let t=await Q(),e={host:t?.config?.plugins?.CapacitorUpdater?.localHost||V6,hostWeb:t?.config?.plugins?.CapacitorUpdater?.localWebHost||W6,hostFilesApi:t?.config?.plugins?.CapacitorUpdater?.localApiFiles||z6,hostApi:t?.config?.plugins?.CapacitorUpdater?.localApi||G6};return t?.config?.plugins?.CapacitorUpdater?.localSupa&&t?.config?.plugins?.CapacitorUpdater?.localSupaAnon&&(m.info("Using custom supabase instance from capacitor.config.json"),e.supaKey=t?.config?.plugins?.CapacitorUpdater?.localSupaAnon,e.supaHost=t?.config?.plugins?.CapacitorUpdater?.localSupa),e}catch{return{host:V6,hostWeb:W6,hostFilesApi:z6,hostApi:G6}}}var Ese=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/;async function ab(){let t=await Cr();return Vr.get(`${t.hostApi}/private/config`).then(e=>e.json()).then(e=>({...e,...t})).catch(()=>(m.info(`Local config ${te(t)}`),t))}async function ej(){let t=await Cr();return Vr.get(`${t.hostFilesApi}/files/config`).then(e=>e.json()).catch(()=>({partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1}))}async function de(t){let e=await ab();return(!e.supaHost||!e.supaKey)&&(m.error("Cannot connect to server please try again later"),A.error("")),(0,fa.createClient)(e.supaHost,e.supaKey,{auth:{persistSession:!1},global:{headers:{capgkey:t}}})}async function Cse(t,e,r){let{data:n}=await t.rpc("is_allowed_capgkey",{apikey:e,keymode:r}).single();if(!n){m.error("Invalid API key or insufficient permissions.");let i=r.map((o,s)=>r.length===1?`"${o}"`:s===r.length-1?`or "${o}"`:`"${o}", `).join("");m.error(`Your key should be: ${i} mode.`),A.error("")}}async function Sse(t,e){let{data:r}=await t.rpc("is_paying_org",{orgid:e}).single();return r||!1}async function xse(t,e){let{data:r}=await t.rpc("is_trial_org",{orgid:e}).single();return r||0}async function Fse(t,e){let{data:r}=await t.rpc("is_allowed_action_org",{orgid:e}).single();return!!r}async function Ose(t,e,r){let{data:n}=await t.rpc("is_allowed_action",{apikey:r,appid:e}).single();return!!n}var Ft=(s=>(s[s.none=0]="none",s[s.read=1]="read",s[s.upload=2]="upload",s[s.write=3]="write",s[s.admin=4]="admin",s[s.super_admin=5]="super_admin",s))(Ft||{}),tj=(t,e)=>t>=e;async function rj(t,e,r){let{data:n,error:i}=await t.rpc("get_org_perm_for_apikey",{apikey:e,app_id:r}).single();if(i&&(m.error("Cannot get permissions for organization!"),console.error(i),(0,ur.exit)(1)),n.includes("perm")){let a=null;switch(n){case"perm_none":{a=0;break}case"perm_read":{a=1;break}case"perm_upload":{a=2;break}case"perm_write":{a=3;break}case"perm_admin":{a=4;break}case"perm_owner":{a=5;break}default:n.includes("invite")&&(m.info("Please accept/deny the organization invitation before trying to access the app"),(0,ur.exit)(1)),m.error(`Invalid output when fetching organization permission. Response: ${n}`),(0,ur.exit)(1)}return{okay:!0,data:a}}let s=null;switch(n){case"INVALID_APIKEY":{s="INVALID_APIKEY";break}case"NO_APP":{s="NO_APP";break}case"NO_ORG":{s="NO_ORG";break}default:m.error(`Invalid error when fetching organization permission. Response: ${n}`),(0,ur.exit)(1)}return{okay:!1,error:s}}async function ha(t,e,r,n,i=!0){let o=await ab();await(n?Ose(t,n,r):Fse(t,e))||(m.error(`You need to upgrade your plan to continue to use capgo.
245
+ `),h(),n()};return{start:b,stop:g,message:(w="")=>{s=p(w??s)}}};var it=require("node:fs"),Th=require("node:os"),tt=ce(require("node:path")),ur=require("node:process"),vi=ce(pl());var yn=require("fs"),qa=(t=".",e="unknown")=>{let r=`${t}/bun.lockb`,n=`${t}/pnpm-lock.yaml`,i=`${t}/yarn.lock`,o=`${t}/package-lock.json`;return(0,yn.existsSync)(r)?"bun":(0,yn.existsSync)(n)?"pnpm":(0,yn.existsSync)(i)?"yarn":(0,yn.existsSync)(o)?"npm":e},ml=(t=qa(),e=!1)=>{switch(t){case"bun":return e?"bun install":"install";case"pnpm":return e?"pnpm install":"install";case"yarn":return e?"yarn install":"install";case"npm":return e?"npm install":"install";case"unknown":return e?"unknown unknown":"unknown";default:return e?"npm install":"install"}},Gw=(t=".",e="npx")=>{let r=`${t}/bun.lockb`,n=`${t}/pnpm-lock.yaml`,i=`${t}/yarn.lock`,o=`${t}/package-lock.json`;return(0,yn.existsSync)(r)?"bunx":(0,yn.existsSync)(n)?"pnpm exec":(0,yn.existsSync)(i)?"yarn dlx":(0,yn.existsSync)(o)?"npx":e};var fa=ce(H_()),J6=ce(vu()),ob=ce(NC());var ti=class extends Error{response;request;options;constructor(e,r,n){let i=e.status||e.status===0?e.status:"",o=e.statusText||"",s=`${i} ${o}`.trim(),a=s?`status code ${s}`:"an unknown error";super(`Request failed with ${a}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=e,this.request=r,this.options=n}};var ss=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};var as=t=>t!==null&&typeof t=="object";var wu=(...t)=>{for(let e of t)if((!as(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Hg({},...t)},Mg=(t={},e={})=>{let r=new globalThis.Headers(t),n=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(let[o,s]of i.entries())n&&s==="undefined"||s===void 0?r.delete(o):r.set(o,s);return r};function tf(t,e,r){return Object.hasOwn(e,r)&&e[r]===void 0?[]:Hg(t[r]??[],e[r]??[])}var Ug=(t={},e={})=>({beforeRequest:tf(t,e,"beforeRequest"),beforeRetry:tf(t,e,"beforeRetry"),afterResponse:tf(t,e,"afterResponse"),beforeError:tf(t,e,"beforeError")}),Hg=(...t)=>{let e={},r={},n={};for(let i of t)if(Array.isArray(i))Array.isArray(e)||(e=[]),e=[...e,...i];else if(as(i)){for(let[o,s]of Object.entries(i))as(s)&&o in e&&(s=Hg(e[o],s)),e={...e,[o]:s};as(i.hooks)&&(n=Ug(n,i.hooks),e.hooks=n),as(i.headers)&&(r=Mg(r,i.headers),e.headers=r)}return e};var LC=(()=>{let t=!1,e=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),BC=typeof globalThis.AbortController=="function",qC=typeof globalThis.ReadableStream=="function",MC=typeof globalThis.FormData=="function",rf=["get","post","put","patch","head","delete"],c9=()=>{};c9();var UC={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},nf=2147483647,of=Symbol("stop"),HC={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},VC={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var GC=t=>rf.includes(t)?t.toUpperCase():t,l9=["get","put","head","delete","options","trace"],f9=[408,413,429,500,502,503,504],d9=[413,429,503],zC={limit:2,methods:l9,statusCodes:f9,afterStatusCodes:d9,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},WC=(t={})=>{if(typeof t=="number")return{...zC,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...zC,...t}};async function Vg(t,e,r,n){return new Promise((i,o)=>{let s=setTimeout(()=>{r&&r.abort(),o(new ss(t))},n.timeout);n.fetch(t,e).then(i).catch(o).then(()=>{clearTimeout(s)})})}async function zg(t,{signal:e}){return new Promise((r,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(o),n(e.reason)}let o=setTimeout(()=>{e?.removeEventListener("abort",i),r()},t)})}var KC=(t,e)=>{let r={};for(let n in e)!(n in VC)&&!(n in HC)&&!(n in t)&&(r[n]=e[n]);return r};var _u=class t{static create(e,r){let n=new t(e,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>nf)throw new RangeError(`The \`timeout\` option cannot be greater than ${nf}`);await Promise.resolve();let a=await n._fetch();for(let u of n._options.hooks.afterResponse){let c=await u(n.request,n._options,n._decorateResponse(a.clone()));c instanceof globalThis.Response&&(a=c)}if(n._decorateResponse(a),!a.ok&&n._options.throwHttpErrors){let u=new ti(a,n.request,n._options);for(let c of n._options.hooks.beforeError)u=await c(u);throw u}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!qC)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(a.clone(),n._options.onDownloadProgress)}return a},s=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[a,u]of Object.entries(UC))s[a]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||u);let l=(await s).clone();if(a==="json"){if(l.status===204||(await l.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await l.text())}return l[a]()};return s}request;abortController;_retryCount=0;_input;_options;constructor(e,r={}){if(this._input=e,this._options={...r,headers:Mg(this._input.headers,r.headers),hooks:Ug({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:GC(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:WC(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(BC){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(LC&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(MC&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(o,{...this.request}),this._options)}}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof ss)throw e;if(e instanceof ti){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;let n=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(e.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let o=this._options.retry.maxRetryAfter??i;return i<o?i:o}if(e.response.status===413)throw e}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(r){let n=Math.min(this._calculateRetryDelay(r),nf);if(this._retryCount<1)throw r;await zg(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===of)return;return this._retry(e)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let e=KC(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,e):Vg(r,e,this.abortController,this._options)}_stream(e,r){let n=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(o){let s=e.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function a(){let{done:u,value:c}=await s.read();if(u){o.close();return}if(r){i+=c.byteLength;let l=n===0?0:i/n;r({percent:l,transferredBytes:i,totalBytes:n},c)}o.enqueue(c),await a()}await a()}}),{status:e.status,statusText:e.statusText,headers:e.headers})}};var Gg=t=>{let e=(r,n)=>_u.create(r,wu(t,n));for(let r of rf)e[r]=(n,i)=>_u.create(n,wu(t,i,{method:r}));return e.create=r=>Gg(wu(r)),e.extend=r=>(typeof r=="function"&&(r=r(t??{})),Gg(wu(t,r))),e.stop=of,e},h9=Gg(),Vr=h9;var X6=ce(SS()),Ph=ce(aD());var kc=ce(f6());async function d6(){let t=await(0,kc.loadConfig)();return{config:t.app.extConfig,path:t.app.extConfigFilePath}}async function on(t,e=!1){let r=await(0,kc.loadConfig)(),{extConfig:n}=r.app;n&&(n.plugins||(n.plugins={extConfig:{},CapacitorUpdater:{}}),n.plugins.CapacitorUpdater||(n.plugins.CapacitorUpdater={}),e?n=t.config:n.plugins.CapacitorUpdater=t.config.plugins?.CapacitorUpdater,(0,kc.writeConfig)(n,r.app.extConfigFilePath))}var er=".capgo_key",cr=".capgo_key_v2",lr=`${er}.pub`,jn=`${cr}.pub`;var V6="https://capgo.app",z6="https://files.capgo.app",G6="https://api.capgo.app",W6="https://web.capgo.app",Z6=20,Q6=12e4,_se="package.json",da=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i,ee=t=>t?`
246
+ ${X6.default.render(t)}`:"";function K6(t){return new Promise(e=>{setTimeout(e,t)})}function sb(t){return(0,vi.isMonorepo)(t)?(0,vi.findMonorepoRoot)(t):(0,vi.isNXMonorepo)(t)?(0,vi.findNXMonorepoRoot)(t):t}async function jt(t=sb((0,ur.cwd)()),e=void 0){e&&((0,it.existsSync)(e)||(m.error(`Package.json at ${e} does not exist`),(0,ur.exit)(1)));let r=(0,it.readFileSync)(e||(0,tt.join)(t,_se));return JSON.parse(r)}async function Q(){try{let t=await d6();return t||(m.error("No capacitor config file found, run `cap init` first"),A.error("")),t}catch(t){m.error(`No capacitor config file found, run \`cap init\` first ${ee(t)}`),A.error("")}}async function bo(t){let e=await Q();return e?.config&&(e.config.plugins||(e.config.plugins={extConfig:{},CapacitorUpdater:{}}),e.config.plugins.CapacitorUpdater||(e.config.plugins.CapacitorUpdater={}),e.config.plugins.CapacitorUpdater={...e.config.plugins.CapacitorUpdater,...t},on(e)),e}async function Cr(){try{let t=await Q(),e={host:t?.config?.plugins?.CapacitorUpdater?.localHost||V6,hostWeb:t?.config?.plugins?.CapacitorUpdater?.localWebHost||W6,hostFilesApi:t?.config?.plugins?.CapacitorUpdater?.localApiFiles||z6,hostApi:t?.config?.plugins?.CapacitorUpdater?.localApi||G6};return t?.config?.plugins?.CapacitorUpdater?.localSupa&&t?.config?.plugins?.CapacitorUpdater?.localSupaAnon&&(m.info("Using custom supabase instance from capacitor.config.json"),e.supaKey=t?.config?.plugins?.CapacitorUpdater?.localSupaAnon,e.supaHost=t?.config?.plugins?.CapacitorUpdater?.localSupa),e}catch{return{host:V6,hostWeb:W6,hostFilesApi:z6,hostApi:G6}}}var Ese=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/;async function ab(){let t=await Cr();return Vr.get(`${t.hostApi}/private/config`).then(e=>e.json()).then(e=>({...e,...t})).catch(()=>(m.info(`Local config ${ee(t)}`),t))}async function ej(){let t=await Cr();return Vr.get(`${t.hostFilesApi}/files/config`).then(e=>e.json()).catch(()=>({partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1}))}async function de(t){let e=await ab();return(!e.supaHost||!e.supaKey)&&(m.error("Cannot connect to server please try again later"),A.error("")),(0,fa.createClient)(e.supaHost,e.supaKey,{auth:{persistSession:!1},global:{headers:{capgkey:t}}})}async function Cse(t,e,r){let{data:n}=await t.rpc("is_allowed_capgkey",{apikey:e,keymode:r}).single();if(!n){m.error("Invalid API key or insufficient permissions.");let i=r.map((o,s)=>r.length===1?`"${o}"`:s===r.length-1?`or "${o}"`:`"${o}", `).join("");m.error(`Your key should be: ${i} mode.`),A.error("")}}async function Sse(t,e){let{data:r}=await t.rpc("is_paying_org",{orgid:e}).single();return r||!1}async function xse(t,e){let{data:r}=await t.rpc("is_trial_org",{orgid:e}).single();return r||0}async function Fse(t,e){let{data:r}=await t.rpc("is_allowed_action_org",{orgid:e}).single();return!!r}async function Ose(t,e,r){let{data:n}=await t.rpc("is_allowed_action",{apikey:r,appid:e}).single();return!!n}var Ft=(s=>(s[s.none=0]="none",s[s.read=1]="read",s[s.upload=2]="upload",s[s.write=3]="write",s[s.admin=4]="admin",s[s.super_admin=5]="super_admin",s))(Ft||{}),tj=(t,e)=>t>=e;async function rj(t,e,r){let{data:n,error:i}=await t.rpc("get_org_perm_for_apikey",{apikey:e,app_id:r}).single();if(i&&(m.error("Cannot get permissions for organization!"),console.error(i),(0,ur.exit)(1)),n.includes("perm")){let a=null;switch(n){case"perm_none":{a=0;break}case"perm_read":{a=1;break}case"perm_upload":{a=2;break}case"perm_write":{a=3;break}case"perm_admin":{a=4;break}case"perm_owner":{a=5;break}default:n.includes("invite")&&(m.info("Please accept/deny the organization invitation before trying to access the app"),(0,ur.exit)(1)),m.error(`Invalid output when fetching organization permission. Response: ${n}`),(0,ur.exit)(1)}return{okay:!0,data:a}}let s=null;switch(n){case"INVALID_APIKEY":{s="INVALID_APIKEY";break}case"NO_APP":{s="NO_APP";break}case"NO_ORG":{s="NO_ORG";break}default:m.error(`Invalid error when fetching organization permission. Response: ${n}`),(0,ur.exit)(1)}return{okay:!1,error:s}}async function ha(t,e,r,n,i=!0){let o=await ab();await(n?Ose(t,n,r):Fse(t,e))||(m.error(`You need to upgrade your plan to continue to use capgo.
247
247
  Upgrade here: ${o.hostWeb}/dashboard/settings/plans
248
248
  `),K6(100),Promise.resolve().then(()=>(H6(),U6)).then(c=>{c.default(`${o.hostWeb}/dashboard/settings/plans`)}),K6(500),A.error(""));let[a,u]=await Promise.all([xse(t,e),Sse(t,e)]);a>0&&i&&!u&&m.warn(`WARNING !!
249
249
  Trial expires in ${a} days, upgrade here: ${o.hostWeb}/dashboard/settings/plans
250
- `)}function pe(t=!1){let e=(0,Th.homedir)(),r,n=`${e}/.capgo`;return(0,it.existsSync)(n)&&(t||m.info(`Use global API key ${n}`),r=(0,it.readFileSync)(n,"utf8").trim()),n=".capgo",!r&&(0,it.existsSync)(n)&&(t||m.info(`Use local API key ${n}`),r=(0,it.readFileSync)(n,"utf8").trim()),r||(m.error(`Cannot find API key in local folder or global, please login first with ${Nt().runner} @capacitor/cli login`),A.error("")),r}async function*ub(t){let e=await(0,it.readdirSync)(t,{withFileTypes:!0});for(let r of e){let n=(0,tt.resolve)(t,r.name);r.isDirectory()&&!r.name.startsWith(".")&&!r.name.startsWith("node_modules")&&!r.name.startsWith("dist")?yield*ub(n):yield n}}function pa(t){let e=/\.(jpg|jpeg|png|gif|bmp|webp)$/i,r=t.match(e);if(r)switch(r[1].toLowerCase()){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp"}return null}async function cb(){let t=(0,ur.cwd)(),e=!1,r=(0,tt.resolve)(t,"tsconfig.json");(0,it.existsSync)(r)&&(e=!0);for await(let n of ub(t)){if(n.includes("angular.json"))return m.info("Found angular project"),e?"angular-ts":"angular-js";if(n.includes("nuxt.config.js")||n.includes("nuxt.config.ts"))return m.info("Found nuxtjs project"),e?"nuxtjs-ts":"nuxtjs-js";if(n.includes("next.config.js")||n.includes("next.config.mjs"))return m.info("Found nextjs project"),e?"nextjs-ts":"nextjs-js";if(n.includes("svelte.config.js"))return m.info("Found sveltekit project"),e?"sveltekit-ts":"sveltekit-js";if(n.includes("rolluconfig.js"))return m.info("Found svelte project"),e?"svelte-ts":"svelte-js";if(n.includes("vue.config.js"))return m.info("Found vue project"),e?"vue-ts":"vue-js";if(n.includes("package.json")){let i=(0,tt.dirname)(n),o=await jt(i);if(o.dependencies){if(o.dependencies.react)return m.info("Found react project test"),e?"react-ts":"react-js";if(o.dependencies.vue)return m.info("Found vue project"),e?"vue-ts":"vue-js"}}}return"unknown"}function nj(t,e){return t==="angular-js"||t==="angular-ts"?e?"src/main.ts":"src/main.js":t==="nextjs-js"||t==="nextjs-ts"?e?"src/app/layout.tsx":"src/app/layout.js":t==="svelte-js"||t==="svelte-ts"||t==="vue-js"||t==="vue-ts"?e?"src/main.ts":"src/main.js":t==="react-js"||t==="react-ts"?e?"src/index.tsx":"src/index.js":null}async function ij(t){return t==="angular"?(m.info("Angular project detected"),"build"):t==="nuxtjs"?(m.info("Nuxtjs project detected"),"generate"):t==="nextjs"?(m.info("Nextjs project detected"),m.warn("Please make sure you have configured static export in your next.config.js: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports"),m.warn("Please make sure you have the output: 'export' and distDir: 'dist' in your next.config.js"),await qe({message:"Do you want to continue?"})||(m.error("Aborted"),A.error("")),"build"):(t==="sveltekit"&&(m.info("Sveltekit project detected"),m.warn("Please make sure you have the adapter-static installed: https://kit.svelte.dev/docs/adapter-static"),m.warn("Please make sure you have the pages: 'dist' and assets: 'dest', in your svelte.config.js adaptater"),await qe({message:"Do you want to continue?"})||(m.error("Aborted"),A.error(""))),"build")}async function oj(){let t=/(main|index)\.(ts|tsx|js|jsx)$/,e="",r=(0,ur.cwd)(),n=r.split("/").length;for await(let i of ub(r))if(i.split("/").length-n<=2&&t.test(i)){e=i,m.info(`Found main file here ${i}`);break}return e}async function lb(t,e){return t.from("app_versions").upsert(e,{onConflict:"name,app_id"}).eq("app_id",e.app_id).eq("name",e.name)}async function sj(t,e,r){let n={app_id:e,name:r,version:0};try{let o=await t.functions.invoke("private/upload_link",{body:JSON.stringify(n)});if(o.error){if(o.error instanceof fa.FunctionsHttpError){let s=await o.error.context.json();m.error(`Upload URL error: ${s.status||JSON.stringify(s)}`)}else m.error(`Cannot get upload url: ${o.error.message}`);return""}return o.data.url}catch(i){m.error(`Cannot get upload url ${te(i)}`)}return""}async function*aj(t){let e=(0,it.readdirSync)(t,{withFileTypes:!0});for(let r of e){let n=(0,tt.join)(t,r.name);r.isDirectory()?yield*aj(n):yield n}}async function uj(t){let e=[];for await(let r of aj(t)){let n=(0,it.readFileSync)(r),i=await(0,J6.checksum)(n,"sha256"),o=(0,tt.relative)(t,r);o.startsWith("/")&&(o=o.substring(1)),e.push({file:o,hash:i})}return e}async function Rh(t){return(0,Th.platform)()==="win32"?kse(t):Ase(t)}function Ase(t){let e=new ob.default;return e.addLocalFolder(t),e.toBuffer()}async function kse(t){m.info("Zipping file windows mode");let e=new ob.default,r=(n,i)=>{let o=(0,it.readdirSync)(n);for(let s of o){let a=(0,tt.join)(n,s),u=(0,it.statSync)(a);if(u.isFile()){let c=(0,it.readFileSync)(a);e.addFile((0,tt.join)(i,s).split(tt.sep).join("/"),c)}else u.isDirectory()&&r(a,(0,tt.join)(i,s))}};return r(t,""),e.toBuffer()}async function cj(t,e,r,n,i,o,s){return new Promise((a,u)=>{Fe(t,{channel:"app",event:"App TUS upload",icon:"\u23EB",user_id:r,tags:{"app-id":n},notify:!1}),new Ph.Upload(e,{endpoint:`${s.hostFilesApi}/files/upload/attachments/`,metadataForPartialUploads:{filename:`orgs/${r}/apps/${n}/${i}.zip`,filetype:"application/gzip"},metadata:{filename:`orgs/${r}/apps/${n}/${i}.zip`,filetype:"application/zip"},headers:{Authorization:t},onError(l){if(l instanceof Ph.DetailedError){let f=l.originalResponse?.getBody(),h=JSON.parse(f||'{"error": "unknown error"}');u(h.status||h.error||h.message||"unknown error")}else u(l.message||l.toString()||"unknown error")},onProgress(l,f){let h=(l/f*100).toFixed(2);o.message(`Uploaded ${h}%`)},async onSuccess(){await Fe(t,{channel:"app",event:"App TUS done",icon:"\u23EB",user_id:r,tags:{"app-id":n},notify:!1}).catch(),a(!0)}}).start()})}async function lj(t,e,r){let n={app_id:e,name:r};try{let o=await t.functions.invoke("private/delete_failed_version",{body:JSON.stringify(n),method:"DELETE"});if(o.error){if(o.error instanceof fa.FunctionsHttpError){let s=await o.error.context.json();m.error(`Cannot delete failed version: ${s.status||JSON.stringify(s)}`)}else m.error(`Cannot delete failed version: ${o.error.message}`);return}return o.data?.status}catch(i){if(i instanceof fa.FunctionsHttpError){let o=await i.context.json();m.error(`Cannot delete failed version: ${o.message||JSON.stringify(o)}`)}else m.error(`Cannot delete failed version: ${te(i)}`)}}async function $h(t,e){if(!e.app_id||!e.name||!e.created_by)return m.error("missing app_id, name, or created_by"),Promise.reject(new Error("missing app_id, name, or created_by"));let{data:r,error:n}=await t.from("channels").select().eq("app_id",e.app_id).eq("name",e.name).single();return r&&!n?t.from("channels").update(e).eq("app_id",e.app_id).eq("name",e.name).select().single():t.from("channels").insert(e).select().single()}async function Fe(t,e){try{let r=await ab(),n=await Vr.post(`${r.host}/private/events`,{json:e,headers:{capgkey:t},timeout:1e4,retry:3}).json();n.error&&m.error(`Failed to send LogSnag event: ${n.error}`)}catch{}}async function ma(t,e){let{error:r,data:n}=await t.rpc("get_orgs_v5");r&&(m.error("Cannot get the list of organizations - exiting"),m.error(`Error ${JSON.stringify(r)}`),A.error(""));let i=n.filter(u=>!!e.find(c=>c===u.role));i.length===0&&(m.error(`Could not get organization with roles: ${e.join(" or ")} because the user does not have any org`),A.error(""));let o=i.length>1?await qo({message:"Please pick the organization that you want to insert to",options:i.map(u=>({value:u.gid,label:u.name}))}):i[0].gid;kt(o)&&(m.error("Canceled organization selection, exiting"),A.error(""));let s=o,a=n.find(u=>u.gid===s);return m.info(`Using the organization "${a.name}" as the app owner`),a}var wo=t=>t.replace(/\./g,"--");async function me(t,e,r=["all"]){await Cse(t,e,r);let{data:n,error:i}=await t.rpc("get_user_id",{apikey:e}).single(),o=(n||"").toString();return(!o||i)&&(m.error("Cannot auth user with apikey"),A.error("")),o}async function Sr(t,e){let{data:r,error:n}=await t.from("apps").select("owner_org").eq("app_id",e).single();return(!r||n)&&(m.error(`Cannot get organization id for app id ${e}`),te(n),A.error("")),r.owner_org}function ga(t){return new Date(t||"").toLocaleString()}var Y6=!1,la="npm",$c="install",ib="npx";function Nt(){if(Y6)return{pm:la,command:$c,installCommand:`${la} ${$c}`,runner:ib};let t=sb((0,ur.cwd)());return la=qa(t,"npm"),$c=ml(la),Y6=!0,ib=Gw(t),{pm:la,command:$c,installCommand:`${la} ${$c}`,runner:ib}}function fj(t){return(0,it.readdirSync)(t,{withFileTypes:!0}).flatMap(n=>{let i=(0,tt.join)(t,n.name);return n.isDirectory()?fj(i):i.split(`node_modules${tt.sep}`)[1]||i})}async function fb(t,e){let r=e?e.split(","):[],n;try{n=await jt("",t)}catch(l){m.error("Invalid package.json, JSON parsing failed"),console.error("json parse error: ",l),A.error("")}let i=t?tt.default.resolve(t).replace("package.json",""):sb((0,ur.cwd)()),{dependencies:o}=n;o||(m.error("Missing dependencies section in package.json"),A.error(""));for(let[l,f]of Object.entries(o))typeof f!="string"&&(m.error(`Invalid dependency ${l}: ${f}, expected string, got ${typeof f}`),A.error(""));let s=r.length===0?[(0,tt.join)((0,ur.cwd)(),"node_modules")]:r;if(!s.some(l=>(0,it.existsSync)(l))){let l=qa(i,"npm"),f=ml(l);m.error(`Missing node_modules folder at ${s.join(", ")}, please run ${l} ${f}`),A.error("")}let u=!1,c=await Promise.all(Object.entries(o).map(async([l,f])=>{let h=!1,d=!1;for(let p of s){let b=(0,tt.join)(p,l);if((0,it.existsSync)(b)){h=!0;try{if(fj(b).some(w=>Ese.test(w))){d=!0;break}}catch(g){m.error(`Error reading node_modules files for ${l} package in ${p}`),console.error(g),A.error("")}}}if(!h){u=!0;let p=qa(i,"npm"),b=ml(p);return m.error(`Missing dependency ${l}, please run ${p} ${b}`),{name:l,version:f}}return{name:l,version:f,native:d}})).catch(()=>[]);return(u||c.find(l=>l.native===void 0))&&A.error(""),c}async function Tse(t,e,r){let{data:n,error:i}=await t.from("channels").select("version(checksum)").eq("name",r).eq("app_id",e).single(),o=n;return i||o===null||!o.version||!o.version.checksum?null:o.version.checksum}async function Pse(t,e,r){let{data:n,error:i}=await t.from("channels").select(`version (
250
+ `)}function pe(t=!1){let e=(0,Th.homedir)(),r,n=`${e}/.capgo`;return(0,it.existsSync)(n)&&(t||m.info(`Use global API key ${n}`),r=(0,it.readFileSync)(n,"utf8").trim()),n=".capgo",!r&&(0,it.existsSync)(n)&&(t||m.info(`Use local API key ${n}`),r=(0,it.readFileSync)(n,"utf8").trim()),r||(m.error(`Cannot find API key in local folder or global, please login first with ${Nt().runner} @capacitor/cli login`),A.error("")),r}async function*ub(t){let e=await(0,it.readdirSync)(t,{withFileTypes:!0});for(let r of e){let n=(0,tt.resolve)(t,r.name);r.isDirectory()&&!r.name.startsWith(".")&&!r.name.startsWith("node_modules")&&!r.name.startsWith("dist")?yield*ub(n):yield n}}function pa(t){let e=/\.(jpg|jpeg|png|gif|bmp|webp)$/i,r=t.match(e);if(r)switch(r[1].toLowerCase()){case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp"}return null}async function cb(){let t=(0,ur.cwd)(),e=!1,r=(0,tt.resolve)(t,"tsconfig.json");(0,it.existsSync)(r)&&(e=!0);for await(let n of ub(t)){if(n.includes("angular.json"))return m.info("Found angular project"),e?"angular-ts":"angular-js";if(n.includes("nuxt.config.js")||n.includes("nuxt.config.ts"))return m.info("Found nuxtjs project"),e?"nuxtjs-ts":"nuxtjs-js";if(n.includes("next.config.js")||n.includes("next.config.mjs"))return m.info("Found nextjs project"),e?"nextjs-ts":"nextjs-js";if(n.includes("svelte.config.js"))return m.info("Found sveltekit project"),e?"sveltekit-ts":"sveltekit-js";if(n.includes("rolluconfig.js"))return m.info("Found svelte project"),e?"svelte-ts":"svelte-js";if(n.includes("vue.config.js"))return m.info("Found vue project"),e?"vue-ts":"vue-js";if(n.includes("package.json")){let i=(0,tt.dirname)(n),o=await jt(i);if(o.dependencies){if(o.dependencies.react)return m.info("Found react project test"),e?"react-ts":"react-js";if(o.dependencies.vue)return m.info("Found vue project"),e?"vue-ts":"vue-js"}}}return"unknown"}function nj(t,e){return t==="angular-js"||t==="angular-ts"?e?"src/main.ts":"src/main.js":t==="nextjs-js"||t==="nextjs-ts"?e?"src/app/layout.tsx":"src/app/layout.js":t==="svelte-js"||t==="svelte-ts"||t==="vue-js"||t==="vue-ts"?e?"src/main.ts":"src/main.js":t==="react-js"||t==="react-ts"?e?"src/index.tsx":"src/index.js":null}async function ij(t){return t==="angular"?(m.info("Angular project detected"),"build"):t==="nuxtjs"?(m.info("Nuxtjs project detected"),"generate"):t==="nextjs"?(m.info("Nextjs project detected"),m.warn("Please make sure you have configured static export in your next.config.js: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports"),m.warn("Please make sure you have the output: 'export' and distDir: 'dist' in your next.config.js"),await qe({message:"Do you want to continue?"})||(m.error("Aborted"),A.error("")),"build"):(t==="sveltekit"&&(m.info("Sveltekit project detected"),m.warn("Please make sure you have the adapter-static installed: https://kit.svelte.dev/docs/adapter-static"),m.warn("Please make sure you have the pages: 'dist' and assets: 'dest', in your svelte.config.js adaptater"),await qe({message:"Do you want to continue?"})||(m.error("Aborted"),A.error(""))),"build")}async function oj(){let t=/(main|index)\.(ts|tsx|js|jsx)$/,e="",r=(0,ur.cwd)(),n=r.split("/").length;for await(let i of ub(r))if(i.split("/").length-n<=2&&t.test(i)){e=i,m.info(`Found main file here ${i}`);break}return e}async function lb(t,e){return t.from("app_versions").upsert(e,{onConflict:"name,app_id"}).eq("app_id",e.app_id).eq("name",e.name)}async function sj(t,e,r){let n={app_id:e,name:r,version:0};try{let o=await t.functions.invoke("private/upload_link",{body:JSON.stringify(n)});if(o.error){if(o.error instanceof fa.FunctionsHttpError){let s=await o.error.context.json();m.error(`Upload URL error: ${s.status||JSON.stringify(s)}`)}else m.error(`Cannot get upload url: ${o.error.message}`);return""}return o.data.url}catch(i){m.error(`Cannot get upload url ${ee(i)}`)}return""}async function*aj(t){let e=(0,it.readdirSync)(t,{withFileTypes:!0});for(let r of e){let n=(0,tt.join)(t,r.name);r.isDirectory()?yield*aj(n):yield n}}async function uj(t){let e=[];for await(let r of aj(t)){let n=(0,it.readFileSync)(r),i=await(0,J6.checksum)(n,"sha256"),o=(0,tt.relative)(t,r);o.startsWith("/")&&(o=o.substring(1)),e.push({file:o,hash:i})}return e}async function Rh(t){return(0,Th.platform)()==="win32"?kse(t):Ase(t)}function Ase(t){let e=new ob.default;return e.addLocalFolder(t),e.toBuffer()}async function kse(t){m.info("Zipping file windows mode");let e=new ob.default,r=(n,i)=>{let o=(0,it.readdirSync)(n);for(let s of o){let a=(0,tt.join)(n,s),u=(0,it.statSync)(a);if(u.isFile()){let c=(0,it.readFileSync)(a);e.addFile((0,tt.join)(i,s).split(tt.sep).join("/"),c)}else u.isDirectory()&&r(a,(0,tt.join)(i,s))}};return r(t,""),e.toBuffer()}async function cj(t,e,r,n,i,o,s){return new Promise((a,u)=>{Fe(t,{channel:"app",event:"App TUS upload",icon:"\u23EB",user_id:r,tags:{"app-id":n},notify:!1}),new Ph.Upload(e,{endpoint:`${s.hostFilesApi}/files/upload/attachments/`,metadataForPartialUploads:{filename:`orgs/${r}/apps/${n}/${i}.zip`,filetype:"application/gzip"},metadata:{filename:`orgs/${r}/apps/${n}/${i}.zip`,filetype:"application/zip"},headers:{Authorization:t},onError(l){if(l instanceof Ph.DetailedError){let f=l.originalResponse?.getBody(),h=JSON.parse(f||'{"error": "unknown error"}');u(h.status||h.error||h.message||"unknown error")}else u(l.message||l.toString()||"unknown error")},onProgress(l,f){let h=(l/f*100).toFixed(2);o.message(`Uploaded ${h}%`)},async onSuccess(){await Fe(t,{channel:"app",event:"App TUS done",icon:"\u23EB",user_id:r,tags:{"app-id":n},notify:!1}).catch(),a(!0)}}).start()})}async function lj(t,e,r){let n={app_id:e,name:r};try{let o=await t.functions.invoke("private/delete_failed_version",{body:JSON.stringify(n),method:"DELETE"});if(o.error){if(o.error instanceof fa.FunctionsHttpError){let s=await o.error.context.json();m.error(`Cannot delete failed version: ${s.status||JSON.stringify(s)}`)}else m.error(`Cannot delete failed version: ${o.error.message}`);return}return o.data?.status}catch(i){if(i instanceof fa.FunctionsHttpError){let o=await i.context.json();m.error(`Cannot delete failed version: ${o.message||JSON.stringify(o)}`)}else m.error(`Cannot delete failed version: ${ee(i)}`)}}async function $h(t,e){if(!e.app_id||!e.name||!e.created_by)return m.error("missing app_id, name, or created_by"),Promise.reject(new Error("missing app_id, name, or created_by"));let{data:r,error:n}=await t.from("channels").select().eq("app_id",e.app_id).eq("name",e.name).single();return r&&!n?t.from("channels").update(e).eq("app_id",e.app_id).eq("name",e.name).select().single():t.from("channels").insert(e).select().single()}async function Fe(t,e){try{let r=await ab(),n=await Vr.post(`${r.host}/private/events`,{json:e,headers:{capgkey:t},timeout:1e4,retry:3}).json();n.error&&m.error(`Failed to send LogSnag event: ${n.error}`)}catch{}}async function ma(t,e){let{error:r,data:n}=await t.rpc("get_orgs_v5");r&&(m.error("Cannot get the list of organizations - exiting"),m.error(`Error ${JSON.stringify(r)}`),A.error(""));let i=n.filter(u=>!!e.find(c=>c===u.role));i.length===0&&(m.error(`Could not get organization with roles: ${e.join(" or ")} because the user does not have any org`),A.error(""));let o=i.length>1?await qo({message:"Please pick the organization that you want to insert to",options:i.map(u=>({value:u.gid,label:u.name}))}):i[0].gid;kt(o)&&(m.error("Canceled organization selection, exiting"),A.error(""));let s=o,a=n.find(u=>u.gid===s);return m.info(`Using the organization "${a.name}" as the app owner`),a}var wo=t=>t.replace(/\./g,"--");async function me(t,e,r=["all"]){await Cse(t,e,r);let{data:n,error:i}=await t.rpc("get_user_id",{apikey:e}).single(),o=(n||"").toString();return(!o||i)&&(m.error("Cannot auth user with apikey"),A.error("")),o}async function Sr(t,e){let{data:r,error:n}=await t.from("apps").select("owner_org").eq("app_id",e).single();return(!r||n)&&(m.error(`Cannot get organization id for app id ${e}`),ee(n),A.error("")),r.owner_org}function ga(t){return new Date(t||"").toLocaleString()}var Y6=!1,la="npm",$c="install",ib="npx";function Nt(){if(Y6)return{pm:la,command:$c,installCommand:`${la} ${$c}`,runner:ib};let t=sb((0,ur.cwd)());return la=qa(t,"npm"),$c=ml(la),Y6=!0,ib=Gw(t),{pm:la,command:$c,installCommand:`${la} ${$c}`,runner:ib}}function fj(t){return(0,it.readdirSync)(t,{withFileTypes:!0}).flatMap(n=>{let i=(0,tt.join)(t,n.name);return n.isDirectory()?fj(i):i.split(`node_modules${tt.sep}`)[1]||i})}async function fb(t,e){let r=e?e.split(","):[],n;try{n=await jt("",t)}catch(l){m.error("Invalid package.json, JSON parsing failed"),console.error("json parse error: ",l),A.error("")}let i=t?tt.default.resolve(t).replace("package.json",""):sb((0,ur.cwd)()),{dependencies:o}=n;o||(m.error("Missing dependencies section in package.json"),A.error(""));for(let[l,f]of Object.entries(o))typeof f!="string"&&(m.error(`Invalid dependency ${l}: ${f}, expected string, got ${typeof f}`),A.error(""));let s=r.length===0?[(0,tt.join)((0,ur.cwd)(),"node_modules")]:r;if(!s.some(l=>(0,it.existsSync)(l))){let l=qa(i,"npm"),f=ml(l);m.error(`Missing node_modules folder at ${s.join(", ")}, please run ${l} ${f}`),A.error("")}let u=!1,c=await Promise.all(Object.entries(o).map(async([l,f])=>{let h=!1,d=!1;for(let p of s){let b=(0,tt.join)(p,l);if((0,it.existsSync)(b)){h=!0;try{if(fj(b).some(w=>Ese.test(w))){d=!0;break}}catch(g){m.error(`Error reading node_modules files for ${l} package in ${p}`),console.error(g),A.error("")}}}if(!h){u=!0;let p=qa(i,"npm"),b=ml(p);return m.error(`Missing dependency ${l}, please run ${p} ${b}`),{name:l,version:f}}return{name:l,version:f,native:d}})).catch(()=>[]);return(u||c.find(l=>l.native===void 0))&&A.error(""),c}async function Tse(t,e,r){let{data:n,error:i}=await t.from("channels").select("version(checksum)").eq("name",r).eq("app_id",e).single(),o=n;return i||o===null||!o.version||!o.version.checksum?null:o.version.checksum}async function Pse(t,e,r){let{data:n,error:i}=await t.from("channels").select(`version (
251
251
  native_packages
252
252
  )`).eq("name",r).eq("app_id",e).single();i&&(m.error(`Error fetching native packages: ${i.message}`),A.error(""));let o;try{o=n.version.native_packages}catch{m.error("Error parsing native packages"),A.error("")}return o||(m.error("Error parsing native packages, perhaps the metadata does not exist?"),A.error("")),o.forEach(a=>{typeof a!="object"&&(m.error(`Invalid remote native package data: ${a}, expected object, got ${typeof a}`),A.error(""));let{name:u,version:c}=a;(!u||typeof u!="string")&&(m.error(`Invalid remote native package name: ${u}, expected string, got ${typeof u}`),A.error("")),(!c||typeof c!="string")&&(m.error(`Invalid remote native package version: ${c}, expected string, got ${typeof c}`),A.error(""))}),new Map(o.map(a=>[a.name,a]))}async function dj(t,e,r,n){let i=Ee();i.start(`Checking bundle checksum compatibility with channel ${r}`);let o=await Tse(t,e,r);if(!o){i.stop(`No checksum found for channel ${r}, the bundle will be uploaded`);return}o&&o===n&&(m.error(`Cannot upload the same bundle content.
253
253
  Current bundle checksum matches remote bundle for channel ${r}
254
254
  Did you builded your app before uploading?
255
255
  PS: You can ignore this check with "--ignore-checksum-check"`),A.error("")),i.stop(`Checksum compatible with ${r} channel`)}function ge(t,e){return t||e?.plugins?.CapacitorUpdater?.appId||e?.appId}async function Ih(t,e,r,n,i){let o=await fb(n,i),s=await Pse(t,e,r),a=o.filter(c=>!!c.native).map(c=>{let l=s.get(c.name);return l?{name:c.name,localVersion:c.version,remoteVersion:l.version}:{name:c.name,localVersion:c.version,remoteVersion:void 0}}),u=[...s].filter(([c])=>o.find(l=>l.name===c)===void 0).map(([c,l])=>({name:c,localVersion:void 0,remoteVersion:l.version}));return a.push(...u),{finalCompatibility:a,localDependencies:o}}async function hj(t,e){let{data:r}=await t.rpc("exist_app_v2",{appid:e}).single();return!!r}async function Le(t,e,r,n){let i=Nt(),o=await rj(t,e,r);if(!o.okay)switch(o.error){case"INVALID_APIKEY":{m.error("Invalid apikey, such apikey does not exists!"),A.error("");break}case"NO_APP":{m.error(`App ${r} does not exist, run first \`${i.runner} @capgo/cli app add ${r}\` to create it`),A.error("");break}case"NO_ORG":{m.error("Could not find organization, please contact support to resolve this!"),A.error("");break}}let s=o.data;return n>s&&(m.error(`Insuficcent permissions for app ${r}. Current permission: ${Ft[o.data]}, required for this action: ${Ft[n]}.`),A.error("")),o.data}var xr="assets/icon.png";var Nj=ce(jj(),1);function mb(t){let e=(0,Nj.default)("npm",{registry:"https://registry.npmjs.org/"}),r=e[`${t}:registry`]||e.config_registry||e.registry;return r.slice(-1)==="/"?r:`${r}/`}var N8=ce(j8(),1),L8=ce(Nv(),1),Ob=class extends Error{constructor(e){super(`Package \`${e}\` could not be found`),this.name="PackageNotFoundError"}},Ab=class extends Error{constructor(e,r){super(`Version \`${r}\` for package \`${e}\` could not be found`),this.name="VersionNotFoundError"}};async function kb(t,e={}){let{version:r="latest"}=e,{omitDeprecated:n=!0}=e,i=t.split("/")[0],o=e.registryUrl??mb(i),s=new URL(encodeURIComponent(t).replace(/^%40/,"@"),o),a=(0,N8.default)(o.toString(),{recursive:!0}),u={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};e.fullMetadata&&delete u.accept,a&&(u.authorization=`${a.type} ${a.token}`);let c;try{c=await Vr(s,{headers:u,keepalive:!0}).json()}catch(f){throw f?.response?.status===404?new Ob(t):f}if(e.allVersions)return c;let l=new Ab(t,r);if(c["dist-tags"][r]){let{time:f}=c;c=c.versions[c["dist-tags"][r]],c.time=f}else if(r){let f=!!c.versions[r];if(n&&!f)for(let[d,p]of Object.entries(c.versions))p.deprecated&&delete c.versions[d];if(!f){let d=Object.keys(c.versions);if(r=L8.default.maxSatisfying(d,r),!r)throw l}let{time:h}=c;if(c=c.versions[r],c.time=h,!c)throw l}return c}async function Bc(t,e){let{version:r}=await kb(t.toLowerCase(),e);return r}async function De(){let t=await Bc("@capgo/cli").catch(()=>""),e=t?.split(".")[0];t!==Ir.version&&m.warning(`\u{1F6A8} You are using @capgo/cli@${Ir.version} it's not the latest version.
256
- Please use @capgo/cli@${t}" or @capgo/cli@${e} to keep up to date with the latest features and bug fixes.`)}async function jae(t,e,r=!0){await Tb(t,e,void 0,r)}async function Tb(t,e,r,n=!0){n&&X("Adding"),await De(),e.apikey=e.apikey||pe();let i=await Q();t=ge(t,i?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error("")),t.includes("--")&&(m.error('The app id includes illegal symbols. You cannot use "--" in the app id'),A.error(""));let o=await de(e.apikey);await me(o,e.apikey,["write","all"]),await hj(o,t)&&(t==="io.ionic.starter"?m.error(`This appId ${t} cannot be used it's reserved, please change it in your capacitor config.`):m.error(`App ${t} already exist`),A.error("")),r||(r=await ma(o,["admin","super_admin"]));let a=r.gid;await ha(o,a,e.apikey,void 0,!1);let{name:u,icon:c}=e;u=u||i.config?.appName||"Unknown",c=c||"resources/icon.png",(!c||!u)&&(m.error("Missing argument, you need to provide a appId and a name, or be in a capacitor project"),A.error("")),n&&m.info(`Adding ${t} to Capgo`);let l=null,f=null;c&&(0,Ca.existsSync)(c)?(l=(0,Ca.readFileSync)(c),f=pa(c)||"image/png",m.warn(`Found app icon ${c}`)):(0,Ca.existsSync)(xr)?(l=(0,Ca.readFileSync)(xr),f=pa(xr)||"image/png",m.warn(`Found app icon ${xr}`)):m.warn(`Cannot find app icon in any of the following locations: ${c}, ${xr}`);let h="icon",d="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(l&&f){let{error:g}=await o.storage.from(`images/org/${a}/${t}`).upload(h,l,{contentType:f});g&&(console.error(g),m.error(`Could not add app ${te(g)}`),A.error(""));let{data:w}=await o.storage.from(`images/org/${a}/${t}`).getPublicUrl(h);d=w?.publicUrl||d}let{error:p}=await o.from("apps").insert({icon_url:d,owner_org:a,name:u,app_id:t});p&&(m.error(`Could not add app ${te(p)}`),A.error(""));let{error:b}=await o.from("app_versions").insert([{owner_org:a,deleted:!0,name:"unknown",app_id:t},{owner_org:a,deleted:!0,name:"builtin",app_id:t}]);return b&&(m.error(`Could not add app ${te(b)}`),A.error("")),m.success(`App ${t} added to Capgo. ${n?"You can upload a bundle now":""}`),n&&(J("Done \u2705"),(0,B8.exit)()),!0}async function q8(t,e){jae(t,e,!0)}var M8=require("node:process");async function U8(t,e){X("Deleting"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),i=await me(n,e.apikey,["write","all"]);await Le(n,e.apikey,t,5);let{data:o,error:s}=await n.from("apps").select("owner_org ( created_by, id )").eq("app_id",t).single(),a=o;if(!s&&(a?.owner_org.created_by??"")!==i){m.warn("Deleting the app is not recomended for users that are not the organization owner"),m.warn("You are invited as a super_admin but your are not the owner"),m.warn("It's strongly recomended that you do not continue!");let h=await qo({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});(kt(h)||h==="no")&&(m.error("Canceled deleting the app, exiting"),A.error(""))}else s&&m.warn(`Cannot get the app owner ${te(s)}`);let{error:u}=await n.storage.from("images").remove([`org/${a?.owner_org.id}/${t}/icon`]);u&&(console.error(u,`images/org/${a?.owner_org.id}/${t}`),m.error("Could not delete app logo"));let{error:c}=await n.storage.from(`apps/${t}/${i}`).remove(["versions"]);c&&m.error("Could not delete app version");let{error:l}=await n.from("apps").delete().eq("app_id",t);l&&(m.error("Could not delete app"),A.error(""));let f=await Sr(n,t);await Fe(e.apikey,{channel:"app",event:"App Deleted",icon:"\u{1F5D1}\uFE0F",user_id:f,tags:{"app-id":t},notify:!1}).catch(),m.success("App deleted in Capgo"),J("Done \u2705"),(0,M8.exit)()}var Yh=require("node:os"),Sa=require("node:process");async function Nae(t){let e={},r=[];for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.push(Bc(n));return await Promise.all(r).then(n=>{let i=Object.keys(t);for(let o=0;o<n.length;o+=1){let s=n[o];s&&(e[i[o]]=s)}}),e}async function Lae(){let{dependencies:t}=await jt(),e={"@capgo/cli":Ir.version};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&r.startsWith("@capgo/")&&r.startsWith("@capawesome/")&&r.startsWith("capacitor")){let n=t[r].replace("^","").replace("~","");e[r]=n}return e}async function H8(t){m.warn(" \u{1F48A} Capgo Doctor \u{1F48A}");let e=await Q(),r=await jt("",t.packageJson),n=e?.config?.plugins?.CapacitorUpdater?.version||r?.version,i=e?.config?.appName||"";m.info(` App Name: ${i}`);let o=ge("",e?.config);m.info(` App ID: ${o}`),m.info(` App Version: ${n}`);let s=e?.config?.webDir||"";m.info(` Web Dir: ${s}`),m.info(` OS: ${(0,Yh.platform)()} ${(0,Yh.version)()}`),m.info(` Node: ${Sa.version}`),m.info(" Installed Dependencies:");let a=await Lae();Object.keys(a).length===0&&(m.warning("\x1B[31m%s\x1B[0m \u{1F6A8} No dependencies found"),(0,Sa.exit)(1));for(let l in a)if(Object.prototype.hasOwnProperty.call(a,l)){let f=a[l];m.info(` ${l}: ${f}`)}let u=Ee();u.start("Running: Loading latest dependencies");let c=await Nae(a);u.stop("Latest Dependencies:");for(let l in c)if(Object.prototype.hasOwnProperty.call(c,l)){let f=c[l];m.info(` ${l}: ${f}`)}JSON.stringify(a)!==JSON.stringify(c)&&(m.warn("\x1B[31m\u{1F6A8} Some dependencies are not up to date\x1B[0m"),(0,Sa.exit)(1)),m.success("\x1B[32m\u2705 All dependencies are up to date\x1B[0m"),(0,Sa.exit)()}var Pb=require("node:process");function V8(t,e){let n=["normal","bold","dim","italic","underline","strikethrough"].indexOf(t),i="\x1B[";return i+n+"m"+e+i+"0m"}var fr=class t{title=null;headers=[];rows=[];static narrowTheme={top:["\u2554","\u2550","\u2564","\u2557"],row:["\u2551"," ","\u2502","\u2551"],div:["\u255F","\u2500","\u253C","\u2562"],bot:["\u255A","\u2550","\u2567","\u255D"]};static wideTheme={top:["\u2554\u2550","\u2550","\u2550\u2564\u2550","\u2550\u2557"],row:["\u2551 "," "," \u2502 "," \u2551"],div:["\u255F\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2562"],bot:["\u255A\u2550","\u2550","\u2550\u2567\u2550","\u2550\u255D"]};static roundTheme={top:["\u256D\u2500","\u2500","\u2500\u252C\u2500","\u2500\u256E"],row:["\u2502 "," "," \u2502 "," \u2502"],div:["\u251C\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2524"],bot:["\u2570\u2500","\u2500","\u2500\u2534\u2500","\u2500\u256F"]};theme=t.wideTheme;columnWidth(){let e=[this.headers,...this.rows].filter(n=>n.length>0),r=e[0].map(n=>this.cast(n).length);for(let n of e.slice(1))for(let i=0;i<r.length;i++){let o=this.cast(n[i]).length;o>r[i]&&(r[i]=o)}return r}cast(e){return typeof e=="object"?"obj":e!==void 0&&typeof e.toString=="function"?e.toString():""}renderTitle(){return"[ "+this.title+" ]"}renderLine(e){let r=this.columnWidth();return e[0]+r.map(n=>e[1].repeat(n)).join(e[2])+e[3]}renderCell(e,r,n=!1){let i=this.cast(e),o=n?V8("bold",i):i,s=r-i.length,a=this.theme.row[1];switch(typeof e){case"number":return a.repeat(s)+o;case"string":return o+a.repeat(s);case"boolean":case"object":return a.repeat(Math.ceil(s/2))+V8("italic",i)+a.repeat(Math.floor(s/2));default:return a.repeat(s)}}renderRow(e,r=!1){let n=this.theme.row,i=this.columnWidth();return n[0]+e.map((o,s)=>this.renderCell(o,i[s],r)).join(n[2])+n[3]}toString(){let e=this.theme,r=this.headers.length>0,n=this.rows.length>0;return[this.title?this.renderTitle():"",r||n?this.renderLine(e.top):"",r?this.renderRow(this.headers,!0):"",r&&n?this.renderLine(e.div):"",...this.rows.map(i=>this.renderRow(i)),r||n?this.renderLine(e.bot):""].filter(i=>i.length>0).join(`
257
- `)}};function Bae(t){t.length||(m.error("No apps found"),(0,Pb.exit)(1));let e=new fr;e.headers=["Name","id","Created"],e.rows=[],t.reverse().forEach(r=>{e.rows.push([r.name??"",r.app_id,ga(r.created_at)])}),m.success("Apps"),m.success(e.toString())}async function qae(t){let{data:e,error:r}=await t.from("apps").select().order("created_at",{ascending:!1});return r&&(m.error("Apps not found"),A.error("")),e}async function z8(t){X("List apps in Capgo"),await De(),t.apikey=t.apikey||pe();let e=await de(t.apikey);await me(e,t.apikey,["write","all","read","upload"]),m.info("Getting active bundle in Capgo");let r=await qae(e);m.info(`Active app in Capgo: ${r?.length}`),Bae(r),J("Done \u2705"),(0,Pb.exit)()}var G8=require("node:crypto"),xa=require("node:fs"),W8=require("node:process");async function K8(t,e){X("Set app"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),o=(await ma(n,["admin","super_admin"])).gid,s=await me(n,e.apikey,["write","all"]);await Le(n,e.apikey,t,4);let{name:a,icon:u,retention:c}=e;c&&Number.isNaN(Number(c))?(m.error("retention value must be a number"),A.error("")):c&&c<0&&(m.error("retention value cannot be less than 0"),A.error(""));let l,f,h=`icon_${(0,G8.randomUUID)()}`,d="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(u&&(0,xa.existsSync)(u)?(l=(0,xa.readFileSync)(u),f=pa(u)||"image/png",m.warn(`Found app icon ${u}`)):(0,xa.existsSync)(xr)?(l=(0,xa.readFileSync)(xr),f=pa(xr)||"image/png",m.warn(`Found app icon ${xr}`)):m.warn(`Cannot find app icon in any of the following locations: ${u}, ${xr}`),l&&f){let{error:b}=await n.storage.from(`images/org/${o}/${t}`).upload(h,l,{contentType:f});b&&(m.error(`Could not set app ${te(b)}`),A.error(""));let{data:g}=await n.storage.from(`images/org/${o}/${t}`).getPublicUrl(h);d=g?.publicUrl||d}let{error:p}=await n.from("apps").update({icon_url:d,name:a,retention:c?c*24*60*60:void 0}).eq("app_id",t).eq("user_id",s);p&&(m.error(`Could not set app ${te(p)}`),A.error("")),J("Done \u2705"),(0,W8.exit)()}var Fa=require("node:process");async function Y8(t,e){X("Set a specific setting in capacitor config"),e.bool&&e.string&&(m.error("Bool and string CANNOT be set at the same time"),(0,Fa.exit)(1)),!e.bool&&!e.string&&(m.error("You MUST provide either bool or string as the value"),(0,Fa.exit)(1)),e.bool&&e.bool!=="true"&&e.bool!=="false"&&(m.error("Invalid bool"),(0,Fa.exit)(1));try{let r=await Q(),n=r.config,i=t.split(".");i.length===0&&(m.error("Invalid path"),(0,Fa.exit)(1));for(let s of i.slice(0,-1))Object.prototype.hasOwnProperty.call(n,s)||(n[s]={}),n=n[s];let o=e.bool?e.bool==="true":e.string;n[i.at(-1)]=o,await on(r,!0),m.success(`Set "${t}" to "${o}"`)}catch(r){m.error(`Cannot set config in capacitor settings ${te(r)}`),(0,Fa.exit)(1)}J("Done \u2705")}var Ub=require("node:process");function Jh(t,e){if(isNaN(t)||isNaN(e))throw new Error("Cannot compare against non-numbers");return t===e?0:t<e?-1:1}function Z8(t=[],e=[]){return t.length&&!e.length?-1:!t.length&&e.length?1:0}function $b(t=[],e=[]){let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[n],o=e[n];if(i===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(i===void 0)return-1;if(typeof i=="string"&&typeof o=="number")return 1;if(typeof i=="number"&&typeof o=="string"||i<o)return-1;if(i>o)return 1}return 0}var Oa="0|[1-9]\\d*",Mae="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Uae=`(?<major>${Oa})\\.(?<minor>${Oa})\\.(?<patch>${Oa})`,J8=`(?:${Oa}|${Mae})`,Q8=`(?:-(?<prerelease>${J8}(?:\\.${J8})*))`,X8="[0-9A-Za-z-]+",eN=`(?:\\+(?<buildmetadata>${X8}(?:\\.${X8})*))`,tN=`v?${Uae}${Q8}?${eN}?`,rN=new RegExp(`^${tN}$`),nN="(?:<|>)?=?",Hae="x|X|\\*",Rb=`${Oa}|${Hae}`,iN=`[v=\\s]*(?<major>${Rb})(?:\\.(?<minor>${Rb})(?:\\.(?<patch>${Rb})${Q8}?${eN}?)?)?`,Vae=new RegExp(`^(?<operator>~>?|\\^|${nN})\\s*${iN}$`),zae=new RegExp(`^(?<operator>${nN})\\s*(${tN})$|^$`);function Ib(t){return typeof t=="number"&&!Number.isNaN(t)&&(!Number.isFinite(t)||0<=t&&t<=Number.MAX_SAFE_INTEGER)}var jb=256;var Gae=new RegExp(`^${Oa}$`);function Nb(t){return t.split(".").filter(Boolean).map(e=>{if(Gae.test(e)){let r=Number(e);if(Ib(r))return r}return e})}function qc(t){return t.split(".").filter(Boolean)}function Mc(t,e){let r=Number(t);if(!Ib(r))throw new TypeError(e);return r}function Fr(t,e){return t===e?0:Jh(t.major,e.major)||Jh(t.minor,e.minor)||Jh(t.patch,e.patch)||Z8(t.prerelease,e.prerelease)||$b(t.prerelease,e.prerelease)}function Lb(t){return t.toFixed(0)}function Aa(t){let e=Lb(t.major),r=Lb(t.minor),n=Lb(t.patch),i=t.prerelease?.join(".")??"",o=t.build?.join(".")??"";return[[`${e}.${r}.${n}`,i].filter(u=>u).join("-"),o].filter(u=>u).join("+")}function Wae(t=[]){let e=[...t],r=e.length;for(;r>=0;){let n=e[r];if(typeof n=="number"){e[r]=n+1;break}r-=1}return r===-1&&e.push(0),e}function Uc(t=[],e){let r=Wae(t);return e&&(r[0]!==e||isNaN(r[1]))&&(r=[e,0]),r}function sN(t,e,r={}){let n=r.build!==void 0?qc(r.build):t.build??[];switch(e){case"premajor":return{major:t.major+1,minor:0,patch:0,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"preminor":return{major:t.major,minor:t.minor+1,patch:0,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"prepatch":return{major:t.major,minor:t.minor,patch:t.patch+1,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"prerelease":{let o=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:o,prerelease:Uc(t.prerelease,r.prerelease),build:n}}case"major":return{major:(t.prerelease??[]).length===0||t.minor!==0||t.patch!==0?t.major+1:t.major,minor:0,patch:0,prerelease:[],build:n};case"minor":{let o=(t.prerelease??[]).length===0||t.patch!==0?t.minor+1:t.minor;return{major:t.major,minor:o,patch:0,prerelease:[],build:n}}case"patch":{let o=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:o,prerelease:[],build:n}}case"pre":return{major:t.major,minor:t.minor,patch:t.patch,prerelease:Uc(t.prerelease,r.prerelease),build:n};default:throw new TypeError(`Cannot increment version: invalid argument ${e}`)}}var Bb={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},aN={operator:void 0,...Bb};function qb(t,e){return Fr(t,e)>0}function ka(t,e){return Fr(t,e)<0}function Bn(t){if(typeof t!="string")throw new TypeError(`Cannot parse version as version must be a string: received ${typeof t}`);if(t.length>jb)throw new TypeError(`Cannot parse version as version length is too long: length is ${t.length}, max length is ${jb}`);t=t.trim();let e=t.match(rN)?.groups;if(!e)throw new TypeError(`Cannot parse version: ${t}`);let r=Mc(e.major,`Cannot parse version ${t}: invalid major version`),n=Mc(e.minor,`Cannot parse version ${t}: invalid minor version`),i=Mc(e.patch,`Cannot parse version ${t}: invalid patch version`),o=e.prerelease?Nb(e.prerelease):[],s=e.buildmetadata?qc(e.buildmetadata):[];return{major:r,minor:n,patch:i,prerelease:o,build:s}}var mN=require("node:process");var cN=require("node:process");async function lN(t,e,r){let{data:n,error:i}=await t.from("channels").select().eq("app_id",e).eq("version",r.id);if(i&&(m.error(`Cannot check Version ${e}@${r.name}`),A.error("")),n&&n.length>0){if(X(`\u274C Version ${e}@${r.name} is used in ${n.length} channel`),await qe({message:"unlink it?"}))for(let o of n){let s=Ee();s.start(`Unlinking channel ${o.name}`);let{error:a}=await t.from("channels").update({version:(await Mb(t,e))?.id}).eq("id",o.id);a&&(s.stop(`Cannot update channel ${o.name} ${te(a)}`),(0,cN.exit)(1)),s.stop(`\u2705 Channel ${o.name} unlinked`)}else m.error("Unlink it first"),A.error("");J(`Version unlinked from ${n.length} channel`)}}function Mb(t,e){return t.from("app_versions").select("id").eq("app_id",e).eq("name","unknown").throwOnError().single().then(({data:r,error:n})=>(n&&(m.error(`Cannot call findUnknownVersion as it returned an error.
258
- ${te(n)}`),A.error("")),r))}function fN(t,e){return t.from("channels").insert(e).select().single()}function dN(t,e,r,n){return t.from("channels").delete().eq("name",e).eq("app_id",r).single()}function hN(t){let e=new fr;e.theme=fr.roundTheme,e.headers=["Name","Version","Public","iOS","Android","Auto Update","Native Auto Update","Device Self Set","Progressive Deploy","Secondary Version","Secondary Version Percentage","AB Testing","AB Testing Version","AB Testing Percentage","Emulator","Dev"],e.rows=[["a",0,!0],["bb",10,!1]],t.reverse().forEach(r=>{e.rows.push([r.name,r.version?.name,r.public?"\u2705":"\u274C",r.ios?"\u2705":"\u274C",r.android?"\u2705":"\u274C",r.disable_auto_update,r.disable_auto_update_under_native?"\u274C":"\u2705",r.allow_device_self_set?"\u2705":"\u274C",r.allow_emulator?"\u2705":"\u274C",r.allow_dev?"\u2705":"\u274C"])}),m.success("Channels"),m.success(e.toString())}async function pN(t,e){let{data:r,error:n}=await t.from("channels").select(`
256
+ Please use @capgo/cli@${t}" or @capgo/cli@${e} to keep up to date with the latest features and bug fixes.`)}async function jae(t,e,r=!0){await Tb(t,e,void 0,r)}async function Tb(t,e,r,n=!0){n&&X("Adding"),await De(),e.apikey=e.apikey||pe();let i=await Q();t=ge(t,i?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error("")),t.includes("--")&&(m.error('The app id includes illegal symbols. You cannot use "--" in the app id'),A.error(""));let o=await de(e.apikey);await me(o,e.apikey,["write","all"]),await hj(o,t)&&(t==="io.ionic.starter"?m.error(`This appId ${t} cannot be used it's reserved, please change it in your capacitor config.`):m.error(`App ${t} already exist`),A.error("")),r||(r=await ma(o,["admin","super_admin"]));let a=r.gid;await ha(o,a,e.apikey,void 0,!1);let{name:u,icon:c}=e;u=u||i.config?.appName||"Unknown",c=c||"resources/icon.png",(!c||!u)&&(m.error("Missing argument, you need to provide a appId and a name, or be in a capacitor project"),A.error("")),n&&m.info(`Adding ${t} to Capgo`);let l=null,f=null;c&&(0,Ca.existsSync)(c)?(l=(0,Ca.readFileSync)(c),f=pa(c)||"image/png",m.warn(`Found app icon ${c}`)):(0,Ca.existsSync)(xr)?(l=(0,Ca.readFileSync)(xr),f=pa(xr)||"image/png",m.warn(`Found app icon ${xr}`)):m.warn(`Cannot find app icon in any of the following locations: ${c}, ${xr}`);let h="icon",d="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(l&&f){let{error:g}=await o.storage.from(`images/org/${a}/${t}`).upload(h,l,{contentType:f});g&&(console.error(g),m.error(`Could not add app ${ee(g)}`),A.error(""));let{data:w}=await o.storage.from(`images/org/${a}/${t}`).getPublicUrl(h);d=w?.publicUrl||d}let{error:p}=await o.from("apps").insert({icon_url:d,owner_org:a,name:u,app_id:t});p&&(m.error(`Could not add app ${ee(p)}`),A.error(""));let{error:b}=await o.from("app_versions").insert([{owner_org:a,deleted:!0,name:"unknown",app_id:t},{owner_org:a,deleted:!0,name:"builtin",app_id:t}]);return b&&(m.error(`Could not add app ${ee(b)}`),A.error("")),m.success(`App ${t} added to Capgo. ${n?"You can upload a bundle now":""}`),n&&(J("Done \u2705"),(0,B8.exit)()),!0}async function q8(t,e){jae(t,e,!0)}var M8=require("node:process");async function U8(t,e){X("Deleting"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),i=await me(n,e.apikey,["write","all"]);await Le(n,e.apikey,t,5);let{data:o,error:s}=await n.from("apps").select("owner_org ( created_by, id )").eq("app_id",t).single(),a=o;if(!s&&(a?.owner_org.created_by??"")!==i){m.warn("Deleting the app is not recomended for users that are not the organization owner"),m.warn("You are invited as a super_admin but your are not the owner"),m.warn("It's strongly recomended that you do not continue!");let h=await qo({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});(kt(h)||h==="no")&&(m.error("Canceled deleting the app, exiting"),A.error(""))}else s&&m.warn(`Cannot get the app owner ${ee(s)}`);let{error:u}=await n.storage.from("images").remove([`org/${a?.owner_org.id}/${t}/icon`]);u&&(console.error(u,`images/org/${a?.owner_org.id}/${t}`),m.error("Could not delete app logo"));let{error:c}=await n.storage.from(`apps/${t}/${i}`).remove(["versions"]);c&&m.error("Could not delete app version");let{error:l}=await n.from("apps").delete().eq("app_id",t);l&&(m.error("Could not delete app"),A.error(""));let f=await Sr(n,t);await Fe(e.apikey,{channel:"app",event:"App Deleted",icon:"\u{1F5D1}\uFE0F",user_id:f,tags:{"app-id":t},notify:!1}).catch(),m.success("App deleted in Capgo"),J("Done \u2705"),(0,M8.exit)()}var Yh=require("node:os"),Sa=require("node:process");async function Nae(t){let e={},r=[];for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&r.push(Bc(n));return await Promise.all(r).then(n=>{let i=Object.keys(t);for(let o=0;o<n.length;o+=1){let s=n[o];s&&(e[i[o]]=s)}}),e}async function Lae(){let{dependencies:t}=await jt(),e={"@capgo/cli":Ir.version};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&r.startsWith("@capgo/")&&r.startsWith("@capawesome/")&&r.startsWith("capacitor")){let n=t[r].replace("^","").replace("~","");e[r]=n}return e}async function H8(t){m.warn(" \u{1F48A} Capgo Doctor \u{1F48A}");let e=await Q(),r=await jt("",t.packageJson),n=e?.config?.plugins?.CapacitorUpdater?.version||r?.version,i=e?.config?.appName||"";m.info(` App Name: ${i}`);let o=ge("",e?.config);m.info(` App ID: ${o}`),m.info(` App Version: ${n}`);let s=e?.config?.webDir||"";m.info(` Web Dir: ${s}`),m.info(` OS: ${(0,Yh.platform)()} ${(0,Yh.version)()}`),m.info(` Node: ${Sa.version}`),m.info(" Installed Dependencies:");let a=await Lae();Object.keys(a).length===0&&(m.warning("\x1B[31m%s\x1B[0m \u{1F6A8} No dependencies found"),(0,Sa.exit)(1));for(let l in a)if(Object.prototype.hasOwnProperty.call(a,l)){let f=a[l];m.info(` ${l}: ${f}`)}let u=Ee();u.start("Running: Loading latest dependencies");let c=await Nae(a);u.stop("Latest Dependencies:");for(let l in c)if(Object.prototype.hasOwnProperty.call(c,l)){let f=c[l];m.info(` ${l}: ${f}`)}JSON.stringify(a)!==JSON.stringify(c)&&(m.warn("\x1B[31m\u{1F6A8} Some dependencies are not up to date\x1B[0m"),(0,Sa.exit)(1)),m.success("\x1B[32m\u2705 All dependencies are up to date\x1B[0m"),(0,Sa.exit)()}var Pb=require("node:process");function V8(t,e){let n=["normal","bold","dim","italic","underline","strikethrough"].indexOf(t),i="\x1B[";return i+n+"m"+e+i+"0m"}var fr=class t{title=null;headers=[];rows=[];static narrowTheme={top:["\u2554","\u2550","\u2564","\u2557"],row:["\u2551"," ","\u2502","\u2551"],div:["\u255F","\u2500","\u253C","\u2562"],bot:["\u255A","\u2550","\u2567","\u255D"]};static wideTheme={top:["\u2554\u2550","\u2550","\u2550\u2564\u2550","\u2550\u2557"],row:["\u2551 "," "," \u2502 "," \u2551"],div:["\u255F\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2562"],bot:["\u255A\u2550","\u2550","\u2550\u2567\u2550","\u2550\u255D"]};static roundTheme={top:["\u256D\u2500","\u2500","\u2500\u252C\u2500","\u2500\u256E"],row:["\u2502 "," "," \u2502 "," \u2502"],div:["\u251C\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2524"],bot:["\u2570\u2500","\u2500","\u2500\u2534\u2500","\u2500\u256F"]};theme=t.wideTheme;columnWidth(){let e=[this.headers,...this.rows].filter(n=>n.length>0),r=e[0].map(n=>this.cast(n).length);for(let n of e.slice(1))for(let i=0;i<r.length;i++){let o=this.cast(n[i]).length;o>r[i]&&(r[i]=o)}return r}cast(e){return typeof e=="object"?"obj":e!==void 0&&typeof e.toString=="function"?e.toString():""}renderTitle(){return"[ "+this.title+" ]"}renderLine(e){let r=this.columnWidth();return e[0]+r.map(n=>e[1].repeat(n)).join(e[2])+e[3]}renderCell(e,r,n=!1){let i=this.cast(e),o=n?V8("bold",i):i,s=r-i.length,a=this.theme.row[1];switch(typeof e){case"number":return a.repeat(s)+o;case"string":return o+a.repeat(s);case"boolean":case"object":return a.repeat(Math.ceil(s/2))+V8("italic",i)+a.repeat(Math.floor(s/2));default:return a.repeat(s)}}renderRow(e,r=!1){let n=this.theme.row,i=this.columnWidth();return n[0]+e.map((o,s)=>this.renderCell(o,i[s],r)).join(n[2])+n[3]}toString(){let e=this.theme,r=this.headers.length>0,n=this.rows.length>0;return[this.title?this.renderTitle():"",r||n?this.renderLine(e.top):"",r?this.renderRow(this.headers,!0):"",r&&n?this.renderLine(e.div):"",...this.rows.map(i=>this.renderRow(i)),r||n?this.renderLine(e.bot):""].filter(i=>i.length>0).join(`
257
+ `)}};function Bae(t){t.length||(m.error("No apps found"),(0,Pb.exit)(1));let e=new fr;e.headers=["Name","id","Created"],e.rows=[],t.reverse().forEach(r=>{e.rows.push([r.name??"",r.app_id,ga(r.created_at)])}),m.success("Apps"),m.success(e.toString())}async function qae(t){let{data:e,error:r}=await t.from("apps").select().order("created_at",{ascending:!1});return r&&(m.error("Apps not found"),A.error("")),e}async function z8(t){X("List apps in Capgo"),await De(),t.apikey=t.apikey||pe();let e=await de(t.apikey);await me(e,t.apikey,["write","all","read","upload"]),m.info("Getting active bundle in Capgo");let r=await qae(e);m.info(`Active app in Capgo: ${r?.length}`),Bae(r),J("Done \u2705"),(0,Pb.exit)()}var G8=require("node:crypto"),xa=require("node:fs"),W8=require("node:process");async function K8(t,e){X("Set app"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),o=(await ma(n,["admin","super_admin"])).gid,s=await me(n,e.apikey,["write","all"]);await Le(n,e.apikey,t,4);let{name:a,icon:u,retention:c}=e;c&&Number.isNaN(Number(c))?(m.error("retention value must be a number"),A.error("")):c&&c<0&&(m.error("retention value cannot be less than 0"),A.error(""));let l,f,h=`icon_${(0,G8.randomUUID)()}`,d="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(u&&(0,xa.existsSync)(u)?(l=(0,xa.readFileSync)(u),f=pa(u)||"image/png",m.warn(`Found app icon ${u}`)):(0,xa.existsSync)(xr)?(l=(0,xa.readFileSync)(xr),f=pa(xr)||"image/png",m.warn(`Found app icon ${xr}`)):m.warn(`Cannot find app icon in any of the following locations: ${u}, ${xr}`),l&&f){let{error:b}=await n.storage.from(`images/org/${o}/${t}`).upload(h,l,{contentType:f});b&&(m.error(`Could not set app ${ee(b)}`),A.error(""));let{data:g}=await n.storage.from(`images/org/${o}/${t}`).getPublicUrl(h);d=g?.publicUrl||d}let{error:p}=await n.from("apps").update({icon_url:d,name:a,retention:c?c*24*60*60:void 0}).eq("app_id",t).eq("user_id",s);p&&(m.error(`Could not set app ${ee(p)}`),A.error("")),J("Done \u2705"),(0,W8.exit)()}var Fa=require("node:process");async function Y8(t,e){X("Set a specific setting in capacitor config"),e.bool&&e.string&&(m.error("Bool and string CANNOT be set at the same time"),(0,Fa.exit)(1)),!e.bool&&!e.string&&(m.error("You MUST provide either bool or string as the value"),(0,Fa.exit)(1)),e.bool&&e.bool!=="true"&&e.bool!=="false"&&(m.error("Invalid bool"),(0,Fa.exit)(1));try{let r=await Q(),n=r.config,i=t.split(".");i.length===0&&(m.error("Invalid path"),(0,Fa.exit)(1));for(let s of i.slice(0,-1))Object.prototype.hasOwnProperty.call(n,s)||(n[s]={}),n=n[s];let o=e.bool?e.bool==="true":e.string;n[i.at(-1)]=o,await on(r,!0),m.success(`Set "${t}" to "${o}"`)}catch(r){m.error(`Cannot set config in capacitor settings ${ee(r)}`),(0,Fa.exit)(1)}J("Done \u2705")}var Ub=require("node:process");function Jh(t,e){if(isNaN(t)||isNaN(e))throw new Error("Cannot compare against non-numbers");return t===e?0:t<e?-1:1}function Z8(t=[],e=[]){return t.length&&!e.length?-1:!t.length&&e.length?1:0}function $b(t=[],e=[]){let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[n],o=e[n];if(i===void 0&&o===void 0)return 0;if(o===void 0)return 1;if(i===void 0)return-1;if(typeof i=="string"&&typeof o=="number")return 1;if(typeof i=="number"&&typeof o=="string"||i<o)return-1;if(i>o)return 1}return 0}var Oa="0|[1-9]\\d*",Mae="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Uae=`(?<major>${Oa})\\.(?<minor>${Oa})\\.(?<patch>${Oa})`,J8=`(?:${Oa}|${Mae})`,Q8=`(?:-(?<prerelease>${J8}(?:\\.${J8})*))`,X8="[0-9A-Za-z-]+",eN=`(?:\\+(?<buildmetadata>${X8}(?:\\.${X8})*))`,tN=`v?${Uae}${Q8}?${eN}?`,rN=new RegExp(`^${tN}$`),nN="(?:<|>)?=?",Hae="x|X|\\*",Rb=`${Oa}|${Hae}`,iN=`[v=\\s]*(?<major>${Rb})(?:\\.(?<minor>${Rb})(?:\\.(?<patch>${Rb})${Q8}?${eN}?)?)?`,Vae=new RegExp(`^(?<operator>~>?|\\^|${nN})\\s*${iN}$`),zae=new RegExp(`^(?<operator>${nN})\\s*(${tN})$|^$`);function Ib(t){return typeof t=="number"&&!Number.isNaN(t)&&(!Number.isFinite(t)||0<=t&&t<=Number.MAX_SAFE_INTEGER)}var jb=256;var Gae=new RegExp(`^${Oa}$`);function Nb(t){return t.split(".").filter(Boolean).map(e=>{if(Gae.test(e)){let r=Number(e);if(Ib(r))return r}return e})}function qc(t){return t.split(".").filter(Boolean)}function Mc(t,e){let r=Number(t);if(!Ib(r))throw new TypeError(e);return r}function Fr(t,e){return t===e?0:Jh(t.major,e.major)||Jh(t.minor,e.minor)||Jh(t.patch,e.patch)||Z8(t.prerelease,e.prerelease)||$b(t.prerelease,e.prerelease)}function Lb(t){return t.toFixed(0)}function Aa(t){let e=Lb(t.major),r=Lb(t.minor),n=Lb(t.patch),i=t.prerelease?.join(".")??"",o=t.build?.join(".")??"";return[[`${e}.${r}.${n}`,i].filter(u=>u).join("-"),o].filter(u=>u).join("+")}function Wae(t=[]){let e=[...t],r=e.length;for(;r>=0;){let n=e[r];if(typeof n=="number"){e[r]=n+1;break}r-=1}return r===-1&&e.push(0),e}function Uc(t=[],e){let r=Wae(t);return e&&(r[0]!==e||isNaN(r[1]))&&(r=[e,0]),r}function sN(t,e,r={}){let n=r.build!==void 0?qc(r.build):t.build??[];switch(e){case"premajor":return{major:t.major+1,minor:0,patch:0,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"preminor":return{major:t.major,minor:t.minor+1,patch:0,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"prepatch":return{major:t.major,minor:t.minor,patch:t.patch+1,prerelease:Uc(t.prerelease,r.prerelease),build:n};case"prerelease":{let o=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:o,prerelease:Uc(t.prerelease,r.prerelease),build:n}}case"major":return{major:(t.prerelease??[]).length===0||t.minor!==0||t.patch!==0?t.major+1:t.major,minor:0,patch:0,prerelease:[],build:n};case"minor":{let o=(t.prerelease??[]).length===0||t.patch!==0?t.minor+1:t.minor;return{major:t.major,minor:o,patch:0,prerelease:[],build:n}}case"patch":{let o=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:o,prerelease:[],build:n}}case"pre":return{major:t.major,minor:t.minor,patch:t.patch,prerelease:Uc(t.prerelease,r.prerelease),build:n};default:throw new TypeError(`Cannot increment version: invalid argument ${e}`)}}var Bb={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},aN={operator:void 0,...Bb};function qb(t,e){return Fr(t,e)>0}function ka(t,e){return Fr(t,e)<0}function Bn(t){if(typeof t!="string")throw new TypeError(`Cannot parse version as version must be a string: received ${typeof t}`);if(t.length>jb)throw new TypeError(`Cannot parse version as version length is too long: length is ${t.length}, max length is ${jb}`);t=t.trim();let e=t.match(rN)?.groups;if(!e)throw new TypeError(`Cannot parse version: ${t}`);let r=Mc(e.major,`Cannot parse version ${t}: invalid major version`),n=Mc(e.minor,`Cannot parse version ${t}: invalid minor version`),i=Mc(e.patch,`Cannot parse version ${t}: invalid patch version`),o=e.prerelease?Nb(e.prerelease):[],s=e.buildmetadata?qc(e.buildmetadata):[];return{major:r,minor:n,patch:i,prerelease:o,build:s}}var mN=require("node:process");var cN=require("node:process");async function lN(t,e,r){let{data:n,error:i}=await t.from("channels").select().eq("app_id",e).eq("version",r.id);if(i&&(m.error(`Cannot check Version ${e}@${r.name}`),A.error("")),n&&n.length>0){if(X(`\u274C Version ${e}@${r.name} is used in ${n.length} channel`),await qe({message:"unlink it?"}))for(let o of n){let s=Ee();s.start(`Unlinking channel ${o.name}`);let{error:a}=await t.from("channels").update({version:(await Mb(t,e))?.id}).eq("id",o.id);a&&(s.stop(`Cannot update channel ${o.name} ${ee(a)}`),(0,cN.exit)(1)),s.stop(`\u2705 Channel ${o.name} unlinked`)}else m.error("Unlink it first"),A.error("");J(`Version unlinked from ${n.length} channel`)}}function Mb(t,e){return t.from("app_versions").select("id").eq("app_id",e).eq("name","unknown").throwOnError().single().then(({data:r,error:n})=>(n&&(m.error(`Cannot call findUnknownVersion as it returned an error.
258
+ ${ee(n)}`),A.error("")),r))}function fN(t,e){return t.from("channels").insert(e).select().single()}function dN(t,e,r,n){return t.from("channels").delete().eq("name",e).eq("app_id",r).single()}function hN(t){let e=new fr;e.theme=fr.roundTheme,e.headers=["Name","Version","Public","iOS","Android","Auto Update","Native Auto Update","Device Self Set","Progressive Deploy","Secondary Version","Secondary Version Percentage","AB Testing","AB Testing Version","AB Testing Percentage","Emulator","Dev"],e.rows=[["a",0,!0],["bb",10,!1]],t.reverse().forEach(r=>{e.rows.push([r.name,r.version?.name,r.public?"\u2705":"\u274C",r.ios?"\u2705":"\u274C",r.android?"\u2705":"\u274C",r.disable_auto_update,r.disable_auto_update_under_native?"\u274C":"\u2705",r.allow_device_self_set?"\u2705":"\u274C",r.allow_emulator?"\u2705":"\u274C",r.allow_dev?"\u2705":"\u274C"])}),m.success("Channels"),m.success(e.toString())}async function pN(t,e){let{data:r,error:n}=await t.from("channels").select(`
259
259
  id,
260
260
  name,
261
261
  public,
@@ -270,7 +270,7 @@ ${te(n)}`),A.error("")),r))}function fN(t,e){return t.from("channels").insert(e)
270
270
  created_by,
271
271
  app_id,
272
272
  version (id, name)
273
- `).eq("app_id",e).order("created_at",{ascending:!1});return n&&(m.error(`App ${e} not found in database`),A.error("")),r}async function Kae(t,e,r){let{error:n}=await t.from("app_versions").update({deleted:!0}).eq("app_id",e).eq("deleted",!1).eq("name",r);n&&(m.error(`App Version ${e}@${r} not found in database`),A.error(""))}async function Zh(t,e,r){let n=await Yae(t,e,r);await lN(t,e,n),await Kae(t,e,r)}function Qh(t){t.length||(m.error("No bundle found"),(0,mN.exit)(1));let e=new fr;e.theme=fr.roundTheme,e.headers=["Version","Created","Keep"],t.reverse().forEach(r=>{e.rows.push([r.name,ga(r.created_at),r.keep!=null?r.keep:""])}),m.success("Bundles"),m.success(e.toString())}async function ep(t,e){let{data:r,error:n}=await t.from("app_versions").select().eq("app_id",e).eq("deleted",!1).order("created_at",{ascending:!1});return n&&(m.error(`App ${e} not found in database`),A.error("")),r}async function gN(t,e){let{data:r,error:n}=await t.from("channels").select("version").eq("app_id",e);return n&&(m.error(`App ${e} not found in database`),A.error("")),r.map(i=>i.version)}async function Yae(t,e,r){let{data:n,error:i}=await t.from("app_versions").select().eq("app_id",e).eq("name",r).eq("deleted",!1).single();return(!n||i)&&(m.error(`App Version ${e}@${r} doesn't exist`),A.error("")),n}async function Jae(t,e,r){for await(let n of t)m.warn(`Removing ${n.name} created on ${ga(n.created_at)}`),await Zh(e,r,n.name)}function Xae(t,e,r){let n=[];return t?.forEach(i=>{let o=Bn(i.name);qb(o,e)&&ka(o,r)&&n.push(i)}),n}async function yN(t,e){X("Cleanup versions in Capgo"),await De(),e.apikey=e.apikey||pe();let{bundle:r,keep:n=4}=e,i=e.force||!1,o=await Q();t=ge(t,o?.config),e.apikey||(m.error("Missing API key, you need to provide an API key to delete your app"),A.error("")),t||(m.error("Missing argument, you need to provide a appid, or be in a capacitor project"),A.error(""));let s=await de(e.apikey);await me(s,e.apikey,["write","all"]),await Le(s,e.apikey,t,3),m.info("Querying all available versions in Capgo");let a=await ep(s,t),u=await gN(s,t);if(m.info(`Total active versions in Capgo: ${a?.length}`),a?.length===0){m.error("No versions found, aborting cleanup");return}if(r){let f=Bn(r),h=sN(f,"major");m.info(`Querying available versions in Capgo between ${Aa(f)} and ${Aa(h)}`),a=Xae(a,f,h),m.info(`Active versions in Capgo between ${Aa(f)} and ${Aa(h)}: ${a?.length}`)}let c=[],l=0;if(a.forEach(f=>{let h=u.find(d=>d===f.id);l<n||h?(h?f.keep="\u2705 (Linked to channel)":f.keep="\u2705",l+=1):(f.keep="\u274C",c.push(f))}),c.length===0){m.warn("Nothing to be removed, aborting removal...");return}if(Qh(a),!i){let f=await qe({message:"Do you want to continue removing the versions specified?"});(kt(f)||!f)&&(m.warn("Not confirmed, aborting removal..."),(0,Ub.exit)())}m.success("You have confirmed removal, removing versions now"),await Jae(c,s,t),J("Done \u2705"),(0,Ub.exit)()}var sn=require("node:fs"),_N=require("node:process");var Hc=require("node:buffer"),Lt=require("node:crypto"),DN="aes-128-cbc",vN="sha256",tp="base64",bN=Lt.constants.RSA_PKCS1_OAEP_PADDING;function wN(t,e,r){let[n,i]=e.split(":"),o=(0,Lt.privateDecrypt)({key:r,padding:bN,oaepHash:vN},Hc.Buffer.from(i,tp)),s=Hc.Buffer.from(n,tp),a=(0,Lt.createDecipheriv)(DN,o,s);return a.setAutoPadding(!0),Hc.Buffer.concat([a.update(t),a.final()])}function rp(t,e){let r=(0,Lt.randomBytes)(16),n=(0,Lt.randomBytes)(16),i=(0,Lt.createCipheriv)(DN,n,r);i.setAutoPadding(!0);let o=r.toString(tp),s=(0,Lt.publicEncrypt)({key:e,padding:bN,oaepHash:vN},n).toString(tp),a=`${o}:${s}`;return{encryptedData:Hc.Buffer.concat([i.update(t),i.final()]),ivSessionKey:a}}function np(t="pem",e=2048){let{publicKey:r,privateKey:n}=(0,Lt.generateKeyPairSync)("rsa",{modulusLength:e});return t==="pem"?{publicKey:r.export({type:"pkcs1",format:"pem"}),privateKey:n.export({type:"pkcs1",format:"pem"})}:{publicKey:r.export({type:"spki",format:"der"}).toString("base64"),privateKey:n.export({type:"pkcs1",format:"pem"}).toString("base64")}}async function EN(t,e,r){X("Decrypt zip file"),await De(),(0,sn.existsSync)(t)||(m.error(`Zip not found at the path ${t}`),A.error(""));let n=await Q();!r.key&&!(0,sn.existsSync)(er)&&!n.config.plugins?.CapacitorUpdater?.privateKey&&(m.error(`Private Key not found at the path ${er} or in ${n.path}`),A.error(""));let i=r.key||er,o=n.config.plugins?.CapacitorUpdater?.privateKey;!(0,sn.existsSync)(i)&&!o?(m.error(`Cannot find public key ${i} or as keyData option or in ${n.path}`),A.error("")):(0,sn.existsSync)(i)&&(o=(0,sn.readFileSync)(i).toString());let s=(0,sn.readFileSync)(t),a=wN(s,e,r.keyData??o??"");(0,sn.writeFileSync)(`${t}_decrypted.zip`,a),J(`Decrypted zip file at ${t}_decrypted.zip`),(0,_N.exit)()}var an=require("node:fs"),FN=require("node:process");var ON=ce(vu());var To=require("node:buffer"),At=require("node:crypto"),CN="aes-128-cbc",wi="base64",ip=At.constants.RSA_PKCS1_PADDING;function SN(t,e,r){let[n,i]=e.split(":"),o=(0,At.publicDecrypt)({key:r,padding:ip},To.Buffer.from(i,wi)),s=To.Buffer.from(n,wi),a=(0,At.createDecipheriv)(CN,o,s);return a.setAutoPadding(!0),To.Buffer.concat([a.update(t),a.final()])}function op(t,e){return(0,At.privateEncrypt)({key:e,padding:ip},To.Buffer.from(t,wi)).toString(wi)}function xN(t,e){return(0,At.publicDecrypt)({key:e,padding:ip},To.Buffer.from(t,wi)).toString(wi)}function sp(t,e){let r=(0,At.randomBytes)(16),n=(0,At.randomBytes)(16),i=(0,At.createCipheriv)(CN,n,r);i.setAutoPadding(!0);let o=r.toString(wi),s=(0,At.privateEncrypt)({key:e,padding:ip},n).toString(wi),a=`${o}:${s}`;return{encryptedData:To.Buffer.concat([i.update(t),i.final()]),ivSessionKey:a}}async function AN(t,e,r){X("Decrypt zip file"),await De(),(0,an.existsSync)(t)||(m.error(`Zip not found at the path ${t}`),A.error(""));let n=await Q();!r.key&&!(0,an.existsSync)(jn)&&!n.config.plugins?.CapacitorUpdater?.privateKey&&(m.error(`Private Key not found at the path ${jn} or in ${n.path}`),A.error(""));let i=r.key||jn,o=n.config.plugins?.CapacitorUpdater?.publicKey;!(0,an.existsSync)(i)&&!o?(m.error(`Cannot find public key ${i} or as keyData option or in ${n.path}`),A.error("")):(0,an.existsSync)(i)&&(o=(0,an.readFileSync)(i).toString());let s=(0,an.readFileSync)(t),a=SN(s,e,r.keyData??o??"");if((0,an.writeFileSync)(`${t}_decrypted.zip`,a),m.info(`Decrypted zip file at ${t}_decrypted.zip`),r.checksum){let u=await(0,ON.checksum)(a,"sha256"),c=xN(r.checksum,r.keyData??o??"");u!==c?(m.error(`Checksum does not match ${u} !== ${c}`),A.error("")):m.info("Checksum matches")}J("\u2705 done"),(0,FN.exit)()}var kN=require("node:process");async function TN(t,e,r){X("Delete bundle"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey);await me(i,r.apikey,["write","all"]),await Le(i,r.apikey,e,3),r.apikey||(m.error("Missing API key, you need to provide an API key to delete your app"),A.error("")),t||(m.error("Missing argument, you need to provide a bundleId, or be in a capacitor project"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error("")),m.info(`Deleting bundle ${e}@${t} from Capgo`),m.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever"),await Zh(i,e,t),m.success(`Bundle ${e}@${t} deleted in Capgo`),J("Done"),(0,kN.exit)()}var _i=require("node:fs"),PN=require("node:process");async function RN(t,e){X("Encryption"),await De(),(0,_i.existsSync)(t)||(m.error(`Error: Zip not found at the path ${t}`),A.error(""));let r=e.key||lr,n=e.keyData||"";(0,_i.existsSync)(r)&&(n=(0,_i.readFileSync)(r).toString());let i=(0,_i.readFileSync)(t),o=rp(i,n);m.success(`ivSessionKey: ${o.ivSessionKey}`),(0,_i.writeFileSync)(`${t}_encrypted.zip`,o.encryptedData),m.success(`Encrypted zip saved at ${t}_encrypted.zip`),J("Done \u2705"),(0,PN.exit)()}var qn=require("node:fs"),$N=require("node:process");async function IN(t,e,r){let{json:n}=r;n||(X("Encryption"),await De());let i=await Q(),o=!!i.config.plugins?.CapacitorUpdater?.privateKey,s=!!i.config.plugins?.CapacitorUpdater?.publicKey;o&&!n&&m.warning("There is still a privateKey in the config"),(0,qn.existsSync)(t)||(n?console.error(te({error:"zip_not_found"})):m.error(`Error: Zip not found at the path ${t}`),A.error("")),s||(n?console.error(te({error:"missing_public_key"})):m.warning("Warning: Missing Public Key in config"),A.error(""));let a=r.key||cr,u=r.keyData||"";!(0,qn.existsSync)(a)&&!u?(n?console.error(te({error:"missing_key"})):(m.warning(`Cannot find a private key at ${a} or as a keyData option`),m.error("Error: Missing key")),A.error("")):(0,qn.existsSync)(a)&&(u=(0,qn.readFileSync)(a).toString()),u&&!u.startsWith("-----BEGIN RSA PRIVATE KEY-----")&&(n?console.error(te({error:"invalid_private_key"})):m.error("the private key provided is not a valid RSA Private key"),A.error(""));let c=(0,qn.readFileSync)(t),l=sp(c,u),f=op(e,u),h=`${t}_encrypted.zip`;n?console.log(JSON.stringify({checksum:f,filename:h,ivSessionKey:l.ivSessionKey},null,2)):(m.success(`Encoded Checksum: ${f}`),m.success(`ivSessionKey: ${l.ivSessionKey}`)),(0,qn.writeFileSync)(h,l.encryptedData),n||(m.success(`Encrypted zip saved at ${h}`),J("Done \u2705")),(0,$N.exit)()}var jN=require("node:process");async function NN(t,e){X("List bundles"),await De(),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appid, or be in a capacitor project"),A.error(""));let n=await de(e.apikey);await me(n,e.apikey,["write","all","read","upload"]),m.info(`Querying available versions of: ${t} in Capgo`),await Le(n,e.apikey,t,1);let i=await ep(n,t);m.info(`Active versions in Capgo: ${i?.length}`),Qh(i),J("Done \u2705"),(0,jN.exit)()}var tL=require("node:crypto"),cn=require("node:fs"),rL=require("node:process");function Vc(t,e,r=0){r=Math.max(0,Math.min(r,e.byteLength));let n=e.byteLength-r;return t.byteLength>n&&(t=t.subarray(0,n)),e.set(t,r),t.byteLength}var ap=32*1024,Hb=2**32-2,up=class{#e;#t=0;constructor(e){this.#e=e===void 0?new Uint8Array(0):new Uint8Array(e)}bytes(e={copy:!0}){return e.copy===!1?this.#e.subarray(this.#t):this.#e.slice(this.#t)}empty(){return this.#e.byteLength<=this.#t}get length(){return this.#e.byteLength-this.#t}get capacity(){return this.#e.buffer.byteLength}truncate(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this.#r(this.#t+e)}reset(){this.#r(0),this.#t=0}#i(e){let r=this.#e.byteLength;return e<=this.capacity-r?(this.#r(r+e),r):-1}#r(e){if(e>this.#e.buffer.byteLength)throw new RangeError("Length is greater than buffer capacity");this.#e=new Uint8Array(this.#e.buffer,0,e)}readSync(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;let r=Vc(this.#e.subarray(this.#t),e);return this.#t+=r,r}read(e){let r=this.readSync(e);return Promise.resolve(r)}writeSync(e){let r=this.#n(e.byteLength);return Vc(e,this.#e,r)}write(e){let r=this.writeSync(e);return Promise.resolve(r)}#n(e){let r=this.length;r===0&&this.#t!==0&&this.reset();let n=this.#i(e);if(n>=0)return n;let i=this.capacity;if(e<=Math.floor(i/2)-r)Vc(this.#e.subarray(this.#t),this.#e);else{if(i+e>Hb)throw new Error("The buffer cannot be grown beyond the maximum size.");{let o=new Uint8Array(Math.min(2*i+e,Hb));Vc(this.#e.subarray(this.#t),o),this.#e=o}}return this.#t=0,this.#r(Math.min(r+e,Hb)),r}grow(e){if(e<0)throw Error("Buffer.grow: negative count");let r=this.#n(e);this.#r(r)}async readFrom(e){let r=0,n=new Uint8Array(ap);for(;;){let i=this.capacity-this.length<ap,o=i?n:new Uint8Array(this.#e.buffer,this.length),s=await e.read(o);if(s===null)return r;i?this.writeSync(o.subarray(0,s)):this.#r(this.length+s),r+=s}}readFromSync(e){let r=0,n=new Uint8Array(ap);for(;;){let i=this.capacity-this.length<ap,o=i?n:new Uint8Array(this.#e.buffer,this.length),s=e.readSync(o);if(s===null)return r;i?this.writeSync(o.subarray(0,s)):this.#r(this.length+s),r+=s}}};var cp=class extends TransformStream{constructor(e){let r=new up;r.grow(e),super({start(){},async transform(n,i){for(r.write(n);r.length>=e;){let o=new Uint8Array(e),s=await r.read(o);if(s!==e)throw new Error(`Unexpectedly read ${s} bytes from transform buffer when trying to read ${e} bytes.`);i.enqueue(o)}},flush(n){r.length&&n.enqueue(r.bytes())}})}};function Ei(t){return t=t.trim(),t=t.replace(/<!--[\s\S]*?-->/g,""),e();function e(){return{declaration:r(),root:n()}}function r(){if(!u(/^<\?xml\s*/))return;let h={attributes:{}};for(;!(c()||l("?>"));){let d=o();if(!d)return h;h.attributes[d.name]=d.value}return u(/\?>\s*/),h}function n(){let f=u(/^<([\w-:.]+)\s*/);if(!f)return;let h={name:f[1],attributes:{},children:[]};for(;!(c()||l(">")||l("?>")||l("/>"));){let p=o();if(!p)return h;h.attributes[p.name]=p.value}if(u(/^\s*\/>\s*/))return h;u(/\??>\s*/),h.content=i();let d;for(;d=n();)h.children.push(d);return u(/^<\/[\w-:.]+>\s*/),h}function i(){let f=u(/^([^<]*)/);return f?a(f[1]):""}function o(){let f=u(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(f)return{name:f[1],value:a(s(f[2]))}}function s(f){return f.replace(/^['"]|['"]$/g,"")}function a(f){return f.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}function u(f){let h=t.match(f);if(h)return t=t.slice(h[0].length),h}function c(){return t.length==0}function l(f){return t.indexOf(f)==0}}var un=class extends Error{constructor(e){super(e)}};var Or=class extends un{},lp=class extends un{},fp=class extends un{},Mn=class extends un{},Po=class extends un{},zc=class extends un{},Gc=class extends un{},Un=class extends un{statusCode;code;key;bucketName;resource;region;constructor(e,r,n,i={}){super(n),this.statusCode=e,this.code=r,this.key=i.key,this.bucketName=i.bucketName,this.resource=i.resource,this.region=i.region}};async function LN(t){try{let r=Ei(await t.text()).root;if(r?.name!=="Error")throw new Error("Invalid root, expected <Error>");let n=r.children.find(c=>c.name==="Code")?.content??"UnknownErrorCode",i=r.children.find(c=>c.name==="Message")?.content??"The error message could not be determined.",o=r.children.find(c=>c.name==="Key")?.content,s=r.children.find(c=>c.name==="BucketName")?.content,a=r.children.find(c=>c.name==="Resource")?.content,u=r.children.find(c=>c.name==="Region")?.content;return new Un(t.status,n,i,{key:o,bucketName:s,resource:a,region:u})}catch{return new Un(t.status,"UnrecognizedError",`Error: Unexpected response code ${t.status} ${t.statusText}. Unable to parse response as XML.`)}}function BN(t){return typeof t!="number"||isNaN(t)||t<=0?!1:t>=1&&t<=65535}function qN(t){return typeof t!="string"||t.length<3||t.length>63||t.indexOf("..")>-1||t.match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)?!1:!!t.match(/^[a-z0-9][a-z0-9.-]+[a-z0-9]$/)}function Ro(t){return!(!Zae(t)||t.length===0)}function Zae(t){return!(typeof t!="string"||t.length>1024)}function dp(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function $o(t=""){let e={'"':"","&quot;":"","&#34;":"","&QUOT;":"","&#x00022":""};return t.replace(/^("|&quot;|&#34;)|("|&quot;|&#34;)$/g,r=>e[r])}function zb(t){return t.get("x-amz-version-id")??null}function Wc(t){t=t||new Date;let e=t.toISOString();return e.substr(0,4)+e.substr(5,2)+e.substr(8,5)+e.substr(14,2)+e.substr(17,2)+"Z"}function Gb(t){t=t||new Date;let e=t.toISOString();return e.substr(0,4)+e.substr(5,2)+e.substr(8,2)}function Wb(t,e){return`${Gb(e)}/${t}/s3/aws4_request`}async function hp(t){return t instanceof Uint8Array||(t=new TextEncoder().encode(t)),dp(new Uint8Array(await crypto.subtle.digest("SHA-256",t)))}var Qae=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"],pp=class extends WritableStream{getResult;constructor({client:e,bucketName:r,objectName:n,partSize:i,metadata:o}){let s,a=1,u,c=[],l=[];super({start(){},async write(f,h){let d="PUT",p=a++;try{if(p==1&&f.length<i){let w=await e.makeRequest({method:d,headers:new Headers({...o,"Content-Length":String(f.length)}),bucketName:r,objectName:n,payload:f});s={etag:$o(w.headers.get("etag")??void 0),versionId:zb(w.headers)};return}p===1&&(u=(await eue({client:e,bucketName:r,objectName:n,metadata:o})).uploadId);let b={"Content-Length":String(f.length)};for(let w of Qae){let S=o[w];S&&(b[w]=S)}let g=e.makeRequest({method:d,query:{partNumber:p.toString(),uploadId:u},headers:new Headers(b),bucketName:r,objectName:n,payload:f});g.then(w=>{let S=w.headers.get("etag")??"";S&&(S=S.replace(/^"/,"").replace(/"$/,"")),c.push({part:p,etag:S})}),l.push(g)}catch(b){throw b}},async close(){if(!s)if(u)await Promise.all(l),c.sort((f,h)=>f.part>h.part?1:-1),s=await tue({client:e,bucketName:r,objectName:n,uploadId:u,etags:c});else throw new Error("Stream was closed without uploading any data.")}}),this.getResult=()=>{if(s===void 0)throw new Error("Result is not ready. await the stream first.");return s}}};async function eue(t){let e="POST",r=new Headers(t.metadata),o=await(await t.client.makeRequest({method:e,bucketName:t.bucketName,objectName:t.objectName,query:"uploads",headers:r,returnBody:!0})).text(),s=Ei(o).root;if(!s||s.name!=="InitiateMultipartUploadResult")throw new Error(`Unexpected response: ${o}`);let a=s.children.find(u=>u.name==="UploadId")?.content;if(!a)throw new Error(`Unable to get UploadId from response: ${o}`);return{uploadId:a}}async function tue({client:t,bucketName:e,objectName:r,uploadId:n,etags:i}){let o=`
273
+ `).eq("app_id",e).order("created_at",{ascending:!1});return n&&(m.error(`App ${e} not found in database`),A.error("")),r}async function Kae(t,e,r){let{error:n}=await t.from("app_versions").update({deleted:!0}).eq("app_id",e).eq("deleted",!1).eq("name",r);n&&(m.error(`App Version ${e}@${r} not found in database`),A.error(""))}async function Zh(t,e,r){let n=await Yae(t,e,r);await lN(t,e,n),await Kae(t,e,r)}function Qh(t){t.length||(m.error("No bundle found"),(0,mN.exit)(1));let e=new fr;e.theme=fr.roundTheme,e.headers=["Version","Created","Keep"],t.reverse().forEach(r=>{e.rows.push([r.name,ga(r.created_at),r.keep!=null?r.keep:""])}),m.success("Bundles"),m.success(e.toString())}async function ep(t,e){let{data:r,error:n}=await t.from("app_versions").select().eq("app_id",e).eq("deleted",!1).order("created_at",{ascending:!1});return n&&(m.error(`App ${e} not found in database`),A.error("")),r}async function gN(t,e){let{data:r,error:n}=await t.from("channels").select("version").eq("app_id",e);return n&&(m.error(`App ${e} not found in database`),A.error("")),r.map(i=>i.version)}async function Yae(t,e,r){let{data:n,error:i}=await t.from("app_versions").select().eq("app_id",e).eq("name",r).eq("deleted",!1).single();return(!n||i)&&(m.error(`App Version ${e}@${r} doesn't exist`),A.error("")),n}async function Jae(t,e,r){for await(let n of t)m.warn(`Removing ${n.name} created on ${ga(n.created_at)}`),await Zh(e,r,n.name)}function Xae(t,e,r){let n=[];return t?.forEach(i=>{let o=Bn(i.name);qb(o,e)&&ka(o,r)&&n.push(i)}),n}async function yN(t,e){X("Cleanup versions in Capgo"),await De(),e.apikey=e.apikey||pe();let{bundle:r,keep:n=4}=e,i=e.force||!1,o=await Q();t=ge(t,o?.config),e.apikey||(m.error("Missing API key, you need to provide an API key to delete your app"),A.error("")),t||(m.error("Missing argument, you need to provide a appid, or be in a capacitor project"),A.error(""));let s=await de(e.apikey);await me(s,e.apikey,["write","all"]),await Le(s,e.apikey,t,3),m.info("Querying all available versions in Capgo");let a=await ep(s,t),u=await gN(s,t);if(m.info(`Total active versions in Capgo: ${a?.length}`),a?.length===0){m.error("No versions found, aborting cleanup");return}if(r){let f=Bn(r),h=sN(f,"major");m.info(`Querying available versions in Capgo between ${Aa(f)} and ${Aa(h)}`),a=Xae(a,f,h),m.info(`Active versions in Capgo between ${Aa(f)} and ${Aa(h)}: ${a?.length}`)}let c=[],l=0;if(a.forEach(f=>{let h=u.find(d=>d===f.id);l<n||h?(h?f.keep="\u2705 (Linked to channel)":f.keep="\u2705",l+=1):(f.keep="\u274C",c.push(f))}),c.length===0){m.warn("Nothing to be removed, aborting removal...");return}if(Qh(a),!i){let f=await qe({message:"Do you want to continue removing the versions specified?"});(kt(f)||!f)&&(m.warn("Not confirmed, aborting removal..."),(0,Ub.exit)())}m.success("You have confirmed removal, removing versions now"),await Jae(c,s,t),J("Done \u2705"),(0,Ub.exit)()}var sn=require("node:fs"),_N=require("node:process");var Hc=require("node:buffer"),Lt=require("node:crypto"),DN="aes-128-cbc",vN="sha256",tp="base64",bN=Lt.constants.RSA_PKCS1_OAEP_PADDING;function wN(t,e,r){let[n,i]=e.split(":"),o=(0,Lt.privateDecrypt)({key:r,padding:bN,oaepHash:vN},Hc.Buffer.from(i,tp)),s=Hc.Buffer.from(n,tp),a=(0,Lt.createDecipheriv)(DN,o,s);return a.setAutoPadding(!0),Hc.Buffer.concat([a.update(t),a.final()])}function rp(t,e){let r=(0,Lt.randomBytes)(16),n=(0,Lt.randomBytes)(16),i=(0,Lt.createCipheriv)(DN,n,r);i.setAutoPadding(!0);let o=r.toString(tp),s=(0,Lt.publicEncrypt)({key:e,padding:bN,oaepHash:vN},n).toString(tp),a=`${o}:${s}`;return{encryptedData:Hc.Buffer.concat([i.update(t),i.final()]),ivSessionKey:a}}function np(t="pem",e=2048){let{publicKey:r,privateKey:n}=(0,Lt.generateKeyPairSync)("rsa",{modulusLength:e});return t==="pem"?{publicKey:r.export({type:"pkcs1",format:"pem"}),privateKey:n.export({type:"pkcs1",format:"pem"})}:{publicKey:r.export({type:"spki",format:"der"}).toString("base64"),privateKey:n.export({type:"pkcs1",format:"pem"}).toString("base64")}}async function EN(t,e,r){X("Decrypt zip file"),await De(),(0,sn.existsSync)(t)||(m.error(`Zip not found at the path ${t}`),A.error(""));let n=await Q();!r.key&&!(0,sn.existsSync)(er)&&!n.config.plugins?.CapacitorUpdater?.privateKey&&(m.error(`Private Key not found at the path ${er} or in ${n.path}`),A.error(""));let i=r.key||er,o=n.config.plugins?.CapacitorUpdater?.privateKey;!(0,sn.existsSync)(i)&&!o?(m.error(`Cannot find public key ${i} or as keyData option or in ${n.path}`),A.error("")):(0,sn.existsSync)(i)&&(o=(0,sn.readFileSync)(i).toString());let s=(0,sn.readFileSync)(t),a=wN(s,e,r.keyData??o??"");(0,sn.writeFileSync)(`${t}_decrypted.zip`,a),J(`Decrypted zip file at ${t}_decrypted.zip`),(0,_N.exit)()}var an=require("node:fs"),FN=require("node:process");var ON=ce(vu());var To=require("node:buffer"),At=require("node:crypto"),CN="aes-128-cbc",wi="base64",ip=At.constants.RSA_PKCS1_PADDING;function SN(t,e,r){let[n,i]=e.split(":"),o=(0,At.publicDecrypt)({key:r,padding:ip},To.Buffer.from(i,wi)),s=To.Buffer.from(n,wi),a=(0,At.createDecipheriv)(CN,o,s);return a.setAutoPadding(!0),To.Buffer.concat([a.update(t),a.final()])}function op(t,e){return(0,At.privateEncrypt)({key:e,padding:ip},To.Buffer.from(t,wi)).toString(wi)}function xN(t,e){return(0,At.publicDecrypt)({key:e,padding:ip},To.Buffer.from(t,wi)).toString(wi)}function sp(t,e){let r=(0,At.randomBytes)(16),n=(0,At.randomBytes)(16),i=(0,At.createCipheriv)(CN,n,r);i.setAutoPadding(!0);let o=r.toString(wi),s=(0,At.privateEncrypt)({key:e,padding:ip},n).toString(wi),a=`${o}:${s}`;return{encryptedData:To.Buffer.concat([i.update(t),i.final()]),ivSessionKey:a}}async function AN(t,e,r){X("Decrypt zip file"),await De(),(0,an.existsSync)(t)||(m.error(`Zip not found at the path ${t}`),A.error(""));let n=await Q();!r.key&&!(0,an.existsSync)(jn)&&!n.config.plugins?.CapacitorUpdater?.privateKey&&(m.error(`Private Key not found at the path ${jn} or in ${n.path}`),A.error(""));let i=r.key||jn,o=n.config.plugins?.CapacitorUpdater?.publicKey;!(0,an.existsSync)(i)&&!o?(m.error(`Cannot find public key ${i} or as keyData option or in ${n.path}`),A.error("")):(0,an.existsSync)(i)&&(o=(0,an.readFileSync)(i).toString());let s=(0,an.readFileSync)(t),a=SN(s,e,r.keyData??o??"");if((0,an.writeFileSync)(`${t}_decrypted.zip`,a),m.info(`Decrypted zip file at ${t}_decrypted.zip`),r.checksum){let u=await(0,ON.checksum)(a,"sha256"),c=xN(r.checksum,r.keyData??o??"");u!==c?(m.error(`Checksum does not match ${u} !== ${c}`),A.error("")):m.info("Checksum matches")}J("\u2705 done"),(0,FN.exit)()}var kN=require("node:process");async function TN(t,e,r){X("Delete bundle"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey);await me(i,r.apikey,["write","all"]),await Le(i,r.apikey,e,3),r.apikey||(m.error("Missing API key, you need to provide an API key to delete your app"),A.error("")),t||(m.error("Missing argument, you need to provide a bundleId, or be in a capacitor project"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error("")),m.info(`Deleting bundle ${e}@${t} from Capgo`),m.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever"),await Zh(i,e,t),m.success(`Bundle ${e}@${t} deleted in Capgo`),J("Done"),(0,kN.exit)()}var _i=require("node:fs"),PN=require("node:process");async function RN(t,e){X("Encryption"),await De(),(0,_i.existsSync)(t)||(m.error(`Error: Zip not found at the path ${t}`),A.error(""));let r=e.key||lr,n=e.keyData||"";(0,_i.existsSync)(r)&&(n=(0,_i.readFileSync)(r).toString());let i=(0,_i.readFileSync)(t),o=rp(i,n);m.success(`ivSessionKey: ${o.ivSessionKey}`),(0,_i.writeFileSync)(`${t}_encrypted.zip`,o.encryptedData),m.success(`Encrypted zip saved at ${t}_encrypted.zip`),J("Done \u2705"),(0,PN.exit)()}var qn=require("node:fs"),$N=require("node:process");async function IN(t,e,r){let{json:n}=r;n||(X("Encryption"),await De());let i=await Q(),o=!!i.config.plugins?.CapacitorUpdater?.privateKey,s=!!i.config.plugins?.CapacitorUpdater?.publicKey;o&&!n&&m.warning("There is still a privateKey in the config"),(0,qn.existsSync)(t)||(n?console.error(ee({error:"zip_not_found"})):m.error(`Error: Zip not found at the path ${t}`),A.error("")),s||(n?console.error(ee({error:"missing_public_key"})):m.warning("Warning: Missing Public Key in config"),A.error(""));let a=r.key||cr,u=r.keyData||"";!(0,qn.existsSync)(a)&&!u?(n?console.error(ee({error:"missing_key"})):(m.warning(`Cannot find a private key at ${a} or as a keyData option`),m.error("Error: Missing key")),A.error("")):(0,qn.existsSync)(a)&&(u=(0,qn.readFileSync)(a).toString()),u&&!u.startsWith("-----BEGIN RSA PRIVATE KEY-----")&&(n?console.error(ee({error:"invalid_private_key"})):m.error("the private key provided is not a valid RSA Private key"),A.error(""));let c=(0,qn.readFileSync)(t),l=sp(c,u),f=op(e,u),h=`${t}_encrypted.zip`;n?console.log(JSON.stringify({checksum:f,filename:h,ivSessionKey:l.ivSessionKey},null,2)):(m.success(`Encoded Checksum: ${f}`),m.success(`ivSessionKey: ${l.ivSessionKey}`)),(0,qn.writeFileSync)(h,l.encryptedData),n||(m.success(`Encrypted zip saved at ${h}`),J("Done \u2705")),(0,$N.exit)()}var jN=require("node:process");async function NN(t,e){X("List bundles"),await De(),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),t||(m.error("Missing argument, you need to provide a appid, or be in a capacitor project"),A.error(""));let n=await de(e.apikey);await me(n,e.apikey,["write","all","read","upload"]),m.info(`Querying available versions of: ${t} in Capgo`),await Le(n,e.apikey,t,1);let i=await ep(n,t);m.info(`Active versions in Capgo: ${i?.length}`),Qh(i),J("Done \u2705"),(0,jN.exit)()}var tL=require("node:crypto"),cn=require("node:fs"),rL=require("node:process");function Vc(t,e,r=0){r=Math.max(0,Math.min(r,e.byteLength));let n=e.byteLength-r;return t.byteLength>n&&(t=t.subarray(0,n)),e.set(t,r),t.byteLength}var ap=32*1024,Hb=2**32-2,up=class{#e;#t=0;constructor(e){this.#e=e===void 0?new Uint8Array(0):new Uint8Array(e)}bytes(e={copy:!0}){return e.copy===!1?this.#e.subarray(this.#t):this.#e.slice(this.#t)}empty(){return this.#e.byteLength<=this.#t}get length(){return this.#e.byteLength-this.#t}get capacity(){return this.#e.buffer.byteLength}truncate(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this.#r(this.#t+e)}reset(){this.#r(0),this.#t=0}#i(e){let r=this.#e.byteLength;return e<=this.capacity-r?(this.#r(r+e),r):-1}#r(e){if(e>this.#e.buffer.byteLength)throw new RangeError("Length is greater than buffer capacity");this.#e=new Uint8Array(this.#e.buffer,0,e)}readSync(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;let r=Vc(this.#e.subarray(this.#t),e);return this.#t+=r,r}read(e){let r=this.readSync(e);return Promise.resolve(r)}writeSync(e){let r=this.#n(e.byteLength);return Vc(e,this.#e,r)}write(e){let r=this.writeSync(e);return Promise.resolve(r)}#n(e){let r=this.length;r===0&&this.#t!==0&&this.reset();let n=this.#i(e);if(n>=0)return n;let i=this.capacity;if(e<=Math.floor(i/2)-r)Vc(this.#e.subarray(this.#t),this.#e);else{if(i+e>Hb)throw new Error("The buffer cannot be grown beyond the maximum size.");{let o=new Uint8Array(Math.min(2*i+e,Hb));Vc(this.#e.subarray(this.#t),o),this.#e=o}}return this.#t=0,this.#r(Math.min(r+e,Hb)),r}grow(e){if(e<0)throw Error("Buffer.grow: negative count");let r=this.#n(e);this.#r(r)}async readFrom(e){let r=0,n=new Uint8Array(ap);for(;;){let i=this.capacity-this.length<ap,o=i?n:new Uint8Array(this.#e.buffer,this.length),s=await e.read(o);if(s===null)return r;i?this.writeSync(o.subarray(0,s)):this.#r(this.length+s),r+=s}}readFromSync(e){let r=0,n=new Uint8Array(ap);for(;;){let i=this.capacity-this.length<ap,o=i?n:new Uint8Array(this.#e.buffer,this.length),s=e.readSync(o);if(s===null)return r;i?this.writeSync(o.subarray(0,s)):this.#r(this.length+s),r+=s}}};var cp=class extends TransformStream{constructor(e){let r=new up;r.grow(e),super({start(){},async transform(n,i){for(r.write(n);r.length>=e;){let o=new Uint8Array(e),s=await r.read(o);if(s!==e)throw new Error(`Unexpectedly read ${s} bytes from transform buffer when trying to read ${e} bytes.`);i.enqueue(o)}},flush(n){r.length&&n.enqueue(r.bytes())}})}};function Ei(t){return t=t.trim(),t=t.replace(/<!--[\s\S]*?-->/g,""),e();function e(){return{declaration:r(),root:n()}}function r(){if(!u(/^<\?xml\s*/))return;let h={attributes:{}};for(;!(c()||l("?>"));){let d=o();if(!d)return h;h.attributes[d.name]=d.value}return u(/\?>\s*/),h}function n(){let f=u(/^<([\w-:.]+)\s*/);if(!f)return;let h={name:f[1],attributes:{},children:[]};for(;!(c()||l(">")||l("?>")||l("/>"));){let p=o();if(!p)return h;h.attributes[p.name]=p.value}if(u(/^\s*\/>\s*/))return h;u(/\??>\s*/),h.content=i();let d;for(;d=n();)h.children.push(d);return u(/^<\/[\w-:.]+>\s*/),h}function i(){let f=u(/^([^<]*)/);return f?a(f[1]):""}function o(){let f=u(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(f)return{name:f[1],value:a(s(f[2]))}}function s(f){return f.replace(/^['"]|['"]$/g,"")}function a(f){return f.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}function u(f){let h=t.match(f);if(h)return t=t.slice(h[0].length),h}function c(){return t.length==0}function l(f){return t.indexOf(f)==0}}var un=class extends Error{constructor(e){super(e)}};var Or=class extends un{},lp=class extends un{},fp=class extends un{},Mn=class extends un{},Po=class extends un{},zc=class extends un{},Gc=class extends un{},Un=class extends un{statusCode;code;key;bucketName;resource;region;constructor(e,r,n,i={}){super(n),this.statusCode=e,this.code=r,this.key=i.key,this.bucketName=i.bucketName,this.resource=i.resource,this.region=i.region}};async function LN(t){try{let r=Ei(await t.text()).root;if(r?.name!=="Error")throw new Error("Invalid root, expected <Error>");let n=r.children.find(c=>c.name==="Code")?.content??"UnknownErrorCode",i=r.children.find(c=>c.name==="Message")?.content??"The error message could not be determined.",o=r.children.find(c=>c.name==="Key")?.content,s=r.children.find(c=>c.name==="BucketName")?.content,a=r.children.find(c=>c.name==="Resource")?.content,u=r.children.find(c=>c.name==="Region")?.content;return new Un(t.status,n,i,{key:o,bucketName:s,resource:a,region:u})}catch{return new Un(t.status,"UnrecognizedError",`Error: Unexpected response code ${t.status} ${t.statusText}. Unable to parse response as XML.`)}}function BN(t){return typeof t!="number"||isNaN(t)||t<=0?!1:t>=1&&t<=65535}function qN(t){return typeof t!="string"||t.length<3||t.length>63||t.indexOf("..")>-1||t.match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)?!1:!!t.match(/^[a-z0-9][a-z0-9.-]+[a-z0-9]$/)}function Ro(t){return!(!Zae(t)||t.length===0)}function Zae(t){return!(typeof t!="string"||t.length>1024)}function dp(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function $o(t=""){let e={'"':"","&quot;":"","&#34;":"","&QUOT;":"","&#x00022":""};return t.replace(/^("|&quot;|&#34;)|("|&quot;|&#34;)$/g,r=>e[r])}function zb(t){return t.get("x-amz-version-id")??null}function Wc(t){t=t||new Date;let e=t.toISOString();return e.substr(0,4)+e.substr(5,2)+e.substr(8,5)+e.substr(14,2)+e.substr(17,2)+"Z"}function Gb(t){t=t||new Date;let e=t.toISOString();return e.substr(0,4)+e.substr(5,2)+e.substr(8,2)}function Wb(t,e){return`${Gb(e)}/${t}/s3/aws4_request`}async function hp(t){return t instanceof Uint8Array||(t=new TextEncoder().encode(t)),dp(new Uint8Array(await crypto.subtle.digest("SHA-256",t)))}var Qae=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"],pp=class extends WritableStream{getResult;constructor({client:e,bucketName:r,objectName:n,partSize:i,metadata:o}){let s,a=1,u,c=[],l=[];super({start(){},async write(f,h){let d="PUT",p=a++;try{if(p==1&&f.length<i){let w=await e.makeRequest({method:d,headers:new Headers({...o,"Content-Length":String(f.length)}),bucketName:r,objectName:n,payload:f});s={etag:$o(w.headers.get("etag")??void 0),versionId:zb(w.headers)};return}p===1&&(u=(await eue({client:e,bucketName:r,objectName:n,metadata:o})).uploadId);let b={"Content-Length":String(f.length)};for(let w of Qae){let S=o[w];S&&(b[w]=S)}let g=e.makeRequest({method:d,query:{partNumber:p.toString(),uploadId:u},headers:new Headers(b),bucketName:r,objectName:n,payload:f});g.then(w=>{let S=w.headers.get("etag")??"";S&&(S=S.replace(/^"/,"").replace(/"$/,"")),c.push({part:p,etag:S})}),l.push(g)}catch(b){throw b}},async close(){if(!s)if(u)await Promise.all(l),c.sort((f,h)=>f.part>h.part?1:-1),s=await tue({client:e,bucketName:r,objectName:n,uploadId:u,etags:c});else throw new Error("Stream was closed without uploading any data.")}}),this.getResult=()=>{if(s===void 0)throw new Error("Result is not ready. await the stream first.");return s}}};async function eue(t){let e="POST",r=new Headers(t.metadata),o=await(await t.client.makeRequest({method:e,bucketName:t.bucketName,objectName:t.objectName,query:"uploads",headers:r,returnBody:!0})).text(),s=Ei(o).root;if(!s||s.name!=="InitiateMultipartUploadResult")throw new Error(`Unexpected response: ${o}`);let a=s.children.find(u=>u.name==="UploadId")?.content;if(!a)throw new Error(`Unable to get UploadId from response: ${o}`);return{uploadId:a}}async function tue({client:t,bucketName:e,objectName:r,uploadId:n,etags:i}){let o=`
274
274
  <CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
275
275
  ${i.map(f=>` <Part><PartNumber>${f.part}</PartNumber><ETag>${f.etag}</ETag></Part>`).join(`
276
276
  `)}
@@ -280,7 +280,7 @@ ${te(n)}`),A.error("")),r))}function fN(t,e){return t.from("channels").insert(e)
280
280
  `),u.push(n.join(";").toLowerCase()),u.push(i),u.join(`
281
281
  `)}async function zN(t,e,r){let n=await hp(t),i=Wb(r,e),o=[];return o.push(Kb),o.push(Wc(e)),o.push(i),o.push(n),o.join(`
282
282
  `)}async function GN(t,e,r){let n=Gb(t),i=await Ta("AWS4"+r,n),o=await Ta(i,e),s=await Ta(o,"s3");return await Ta(s,"aws4_request")}function WN(t,e,r){return`${t}/${Wb(e,r)}`}async function Ta(t,e){let r=new TextEncoder,n=await crypto.subtle.importKey("raw",t instanceof Uint8Array?t:r.encode(t),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"]),i=await crypto.subtle.sign("HMAC",n,e instanceof Uint8Array?e:r.encode(e));return new Uint8Array(i)}var iue=["Content-Type","Cache-Control","Content-Disposition","Content-Encoding","Content-Language","Expires","x-amz-grant-full-control","x-amz-grant-read","x-amz-grant-read-acp","x-amz-grant-write-acp","x-amz-server-side-encryption","x-amz-storage-class","x-amz-website-redirect-location","x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5","x-amz-server-side-encryption-aws-kms-key-id","x-amz-server-side-encryption-context","x-amz-server-side-encryption-bucket-key-enabled","x-amz-request-payer","x-amz-tagging","x-amz-object-lock-mode","x-amz-object-lock-retain-until-date","x-amz-object-lock-legal-hold","x-amz-expected-bucket-owner"],oue=5*1024*1024,sue=5*1024*1024*1024,Yb=5*1024*1024*1024*1024,Kc=class{host;port;protocol;accessKey;#e;sessionToken;defaultBucket;region;userAgent="s3-lite-client";pathStyle;constructor(e){if(e.useSSL===void 0&&(e.useSSL=!0),typeof e.endPoint!="string"||e.endPoint.length===0||e.endPoint.indexOf("/")!==-1)throw new lp(`Invalid endPoint : ${e.endPoint}`);if(e.port!==void 0&&!BN(e.port))throw new Or(`Invalid port : ${e.port}`);if(e.accessKey&&!e.secretKey)throw new Or("If specifying access key, secret key must also be provided.");if(e.accessKey&&e.accessKey.startsWith("ASIA")&&!e.sessionToken)throw new Or("If specifying temporary access key, session token must also be provided.");let r=e.useSSL?443:80;this.port=e.port??r,this.host=e.endPoint.toLowerCase()+(this.port!==r?`:${e.port}`:""),this.protocol=e.useSSL?"https:":"http:",this.accessKey=e.accessKey,this.#e=e.secretKey??"",this.sessionToken=e.sessionToken,this.pathStyle=e.pathStyle??!0,this.defaultBucket=e.bucket,this.region=e.region}getBucketName(e){let r=e?.bucketName??this.defaultBucket;if(r===void 0||!qN(r))throw new fp(`Invalid bucket name: ${r}`);return r}buildRequestOptions(e){let r=this.getBucketName(e),n=this.pathStyle?this.host:`${r}.${this.host}`,i=e.headers??new Headers;i.set("host",n);let o=typeof e.query=="object"?new URLSearchParams(e.query).toString().replace("+","%20"):e.query,s=(this.pathStyle?`/${r}/${e.objectName}`:`/${e.objectName}`)+(o?`?${o}`:"");return{headers:i,host:n,path:s}}async makeRequest({method:e,payload:r,...n}){let i=new Date,{headers:o,host:s,path:a}=this.buildRequestOptions(n),u=n.statusCode??200;if(e==="POST"||e==="PUT"||e==="DELETE")r===void 0?r=new Uint8Array:typeof r=="string"&&(r=new TextEncoder().encode(r)),o.set("Content-Length",String(r.length));else if(r)throw new Error(`Unexpected payload on ${e} request.`);let c=await hp(r??new Uint8Array);o.set("x-amz-date",Wc(i)),o.set("x-amz-content-sha256",c),this.accessKey&&(this.sessionToken&&o.set("x-amz-security-token",this.sessionToken),o.set("authorization",await MN({headers:o,method:e,path:a,accessKey:this.accessKey,secretKey:this.#e,region:this.region,date:i})));let l=`${this.protocol}//${s}${a}`,f=await fetch(l,{method:e,headers:o,body:r});if(f.status!==u)throw f.status>=400?await LN(f):f.status===301?new Un(f.status,"UnexpectedRedirect",'The server unexpectedly returned a redirect response. With AWS S3, this usually means you need to use a region-specific endpoint like "s3.us-west-2.amazonaws.com" instead of "s3.amazonaws.com"'):new Un(f.status,"UnexpectedStatusCode",`Unexpected response code from the server (expected ${u}, got ${f.status} ${f.statusText}).`);return n.returnBody||await f.body?.getReader().read(),f}async deleteObject(e,r={}){let n=this.getBucketName(r);if(!Ro(e))throw new Mn(`Invalid object name: ${e}`);let i=r.versionId?{versionId:r.versionId}:{},o=new Headers;r.governanceBypass&&o.set("X-Amz-Bypass-Governance-Retention","true"),await this.makeRequest({method:"DELETE",bucketName:n,objectName:e,headers:o,query:i,statusCode:204})}async exists(e,r){try{return await this.statObject(e,r),!0}catch(n){if(n instanceof Un&&n.statusCode===404)return!1;throw n}}getObject(e,r){return this.getPartialObject(e,{...r,offset:0,length:0})}async getPartialObject(e,{offset:r,length:n,...i}){let o=this.getBucketName(i);if(!Ro(e))throw new Mn(`Invalid object name: ${e}`);let s=new Headers(Object.entries(i.metadata??{})),a=200;if(r||n){let c="";r?c=`bytes=${+r}-`:(c="bytes=0-",r=0),n&&(c+=`${+n+r-1}`),s.set("Range",c),a=206}let u={...i.responseParams,...i.versionId?{versionId:i.versionId}:{}};return await this.makeRequest({method:"GET",bucketName:o,objectName:e,headers:s,query:u,statusCode:a,returnBody:!0})}getPresignedUrl(e,r,n={}){if(!this.accessKey)throw new Po(`Presigned ${e} URLs cannot be generated for anonymous requests. Specify an accessKey and secretKey.`);if(!Ro(r))throw new Mn(`Invalid object name: ${r}`);let{headers:i,path:o}=this.buildRequestOptions({objectName:r,bucketName:n.bucketName,query:n.parameters}),s=n.requestDate??new Date,a=n.expirySeconds??24*60*60*7;return UN({protocol:this.protocol,headers:i,method:e,path:o,accessKey:this.accessKey,secretKey:this.#e,region:this.region,date:s,expirySeconds:a})}presignedGetObject(e,r={}){let{versionId:n,responseParams:i,...o}=r,s={...i,...n?{versionId:n}:{}};return this.getPresignedUrl("GET",e,{parameters:s,...o})}async*listObjects(e={}){for await(let r of this.listObjectsGrouped({...e,delimiter:""}))if(r.type==="Object")yield r;else throw new Error(`Unexpected result from listObjectsGrouped(): ${r}`)}async*listObjectsGrouped(e){let r=this.getBucketName(e),n="",i=e.pageSize??1e3;if(i<1||i>1e3)throw new Or("pageSize must be between 1 and 1,000.");let o=0;for(;;){let s=e.maxResults?Math.min(i,e.maxResults-o):i;if(s===0)return;let u=await(await this.makeRequest({method:"GET",bucketName:r,objectName:"",query:{"list-type":"2",prefix:e.prefix??"",delimiter:e.delimiter,"max-keys":String(s),...n?{"continuation-token":n}:{}},returnBody:!0})).text(),c=Ei(u).root;if(!c||c.name!=="ListBucketResult")throw new Error(`Unexpected response: ${u}`);let l=c.children.filter(d=>d.name==="CommonPrefixes").flatMap(d=>d.children),f=[];for(let d of l)f.push({type:"CommonPrefix",prefix:d.content??""}),o++;for(let d of c.children.filter(p=>p.name==="Contents"))f.push({type:"Object",key:d.children.find(p=>p.name==="Key")?.content??"",etag:$o(d.children.find(p=>p.name==="ETag")?.content??""),size:parseInt(d.children.find(p=>p.name==="Size")?.content??"",10),lastModified:new Date(d.children.find(p=>p.name==="LastModified")?.content??"invalid")}),o++;f.sort((d,p)=>{let b=d.type==="Object"?d.key:d.prefix,g=p.type==="Object"?p.key:p.prefix;return b>g?1:b<g?-1:0});for(let d of f)yield d;if(c.children.find(d=>d.name==="IsTruncated")?.content==="true"){let d=c.children.find(p=>p.name==="NextContinuationToken")?.content;if(!d)throw new Error("Unexpectedly missing continuation token, but server said there are more results.");n=d}else return}}async putObject(e,r,n){let i=this.getBucketName(n);if(!Ro(e))throw new Mn(`Invalid object name: ${e}`);let o,s;if(typeof r=="string"){let l=new TextEncoder().encode(r);typeof ReadableStream.from<"u"?s=ReadableStream.from([l]):s=new ReadableStream({start(f){f.enqueue(l),f.close()}}),o=l.length}else if(r instanceof Uint8Array)typeof ReadableStream.from<"u"?s=ReadableStream.from([r]):s=new ReadableStream({start(l){l.enqueue(r),l.close()}}),o=r.byteLength;else if(r instanceof ReadableStream)s=r;else throw new Or("Invalid stream/data type provided.");if(n?.size!==void 0){if(o!==void 0&&n?.size!==o)throw new Or(`size was specified (${n.size}) but doesn't match auto-detected size (${o}).`);if(typeof n.size!="number"||n.size<0||isNaN(n.size))throw new Or(`invalid size specified: ${n.size}`);o=n.size}let a=n?.partSize??this.calculatePartSize(o);if(a<oue)throw new Or("Part size should be greater than 5MB");if(a>sue)throw new Or("Part size should be less than 6MB");let u=new cp(a),c=new pp({client:this,bucketName:i,objectName:e,partSize:a,metadata:n?.metadata??{}});return await s.pipeThrough(u).pipeTo(c),c.getResult()}calculatePartSize(e){if(e===void 0&&(e=Yb),e>Yb)throw new TypeError(`size should not be more than ${Yb}`);let r=64*1024*1024;for(;;){if(r*1e4>e)return r;r+=16*1024*1024}}async statObject(e,r){let n=this.getBucketName(r);if(!Ro(e))throw new Mn(`Invalid object name: ${e}`);let i={};r?.versionId&&(i.versionId=r.versionId);let o=await this.makeRequest({method:"HEAD",bucketName:n,objectName:e,query:i}),s={};for(let a of iue)o.headers.has(a)&&(s[a]=o.headers.get(a));return o.headers.forEach((a,u)=>{u.startsWith("x-amz-meta-")&&(s[u]=o.headers.get(u))}),{type:"Object",key:e,size:parseInt(o.headers.get("content-length")??"",10),metadata:s,lastModified:new Date(o.headers.get("Last-Modified")??"error: missing last modified"),versionId:o.headers.get("x-amz-version-id")||null,etag:$o(o.headers.get("ETag")??"")}}async copyObject(e,r,n){let i=this.getBucketName(n),o=e.sourceBucketName??i;if(!Ro(r))throw new Mn(`Invalid object name: ${r}`);let s=`${o}/${e.sourceKey}`;e.sourceVersionId&&(s+=`?versionId=${e.sourceVersionId}`);let a=new Headers(n?.metadata);n?.metadata!==void 0&&a.set("x-amz-metadata-directive","REPLACE"),a.set("x-amz-copy-source",s);let u=await this.makeRequest({method:"PUT",bucketName:i,objectName:r,headers:a,returnBody:!0}),c=await u.text(),l=Ei(c).root;if(!l||l.name!=="CopyObjectResult")throw new Error(`Unexpected response: ${c}`);let f=l.children.find(d=>d.name==="ETag")?.content??"",h=l.children.find(d=>d.name==="LastModified")?.content;if(h===void 0)throw new Error("Unable to find <LastModified>...</LastModified> from the server.");return{copySourceVersionId:u.headers.get("x-amz-copy-source-version-id")||null,etag:$o(f),lastModified:new Date(h),versionId:u.headers.get("x-amz-version-id")||null}}async bucketExists(e){try{return await this.listObjects({bucketName:e}).next(),!0}catch(r){if(r instanceof Un&&r.statusCode===404)return!1;throw r}}async makeBucket(e){await this.makeRequest({method:"PUT",bucketName:this.getBucketName({bucketName:e}),objectName:"",statusCode:200})}async removeBucket(e){await this.makeRequest({method:"DELETE",bucketName:this.getBucketName({bucketName:e}),objectName:"",statusCode:204})}};var Jb=ce(vu());var jo=require("node:fs"),mp=require("node:path");function aue(t,e){return(0,jo.readFileSync)(t,"utf8").includes(e)}function Yc(t,e){let r=(0,jo.readdirSync)(t);for(let n of r){let i=(0,mp.join)(t,n),o=(0,jo.statSync)(i);if(o.isDirectory()){if(Yc(i,e))return!0}else if(o.isFile()&&(0,mp.extname)(i)===".js"&&aue(i,e))return!0}return!1}function gp(t){return(0,jo.readdirSync)(t).indexOf("index.html")>-1}var KN=require("node:fs"),YN=require("node:os"),No=require("node:path"),JN=require("node:stream/consumers"),XN=require("node:zlib");var ZN=ce(aD());async function QN(t,e,r,n){let i=Ee();i.start("Generating the update manifest");let o=await uj(t);return i.stop("Manifest generated successfully"),await Fe(e,{channel:"partial-update",event:"Generate manifest",icon:"\u{1F4C2}",user_id:r,tags:{"app-id":n},notify:!1}),o}function uue(t){return(0,YN.platform)()!=="win32"?t:No.win32.normalize(t).split(No.win32.sep).join(No.posix.sep)}async function eL(t,e,r,n,i,o){let s=Ee();s.start("Preparing partial update with TUS protocol");let a=performance.now(),u=await Cr(),c=0,l=e.length,f=e.map(async h=>{let d=(0,No.join)(r,h.file),p=uue(h.file),b=(0,KN.createReadStream)(d).pipe((0,XN.createBrotliCompress)()),g=await(0,JN.buffer)(b);return new Promise((w,S)=>{new ZN.Upload(g,{endpoint:`${u.hostFilesApi}/files/upload/attachments/`,metadata:{filename:`orgs/${o}/apps/${n}/${i}/${p}`},headers:{Authorization:t},onError(C){m.info(`Failed to upload ${p}: ${C}`),S(C)},onProgress(){let C=(c/l*100).toFixed(2);s.message(`Uploading partial update: ${C}%`)},onSuccess(){c++,w({file_name:p,s3_path:`orgs/${o}/apps/${n}/${i}/${p}`,file_hash:h.hash})}}).start()})});try{let h=await Promise.all(f),p=((performance.now()-a)/1e3).toFixed(2);return s.stop(`Partial update uploaded successfully \u{1F4AA} in (${p} seconds)`),await Fe(t,{channel:"app",event:"App Partial TUS done",icon:"\u23EB",user_id:o,tags:{"app-id":n},notify:!1}),await Fe(t,{channel:"performance",event:"Partial upload performance",icon:"\u{1F684}",user_id:o,tags:{"app-id":n,time:p},notify:!1}),h}catch(h){let p=((performance.now()-a)/1e3).toFixed(2);return s.stop(`Failed to upload Partial bundle ( after ${p} seconds)`),m.info(`Error uploading partial update: ${h}, This is not a critical error, the bundle has been uploaded without the partial files`),null}}async function cue(t,e){let r=await jt("",e.packageJson),n=e.bundle||t?.plugins?.CapacitorUpdater?.version||r?.version||`0.0.1-beta.${(0,tL.randomUUID)().split("-")[0]}`;return da.test(n)||(m.error(`Your bundle name ${n}, is not valid it should follow semver convention : https://semver.org/`),A.error("")),n}function lue(t){let e=t.apikey||pe();return e||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e}function fue(t,e,r){let n=ge(t,r),i=e.path||r?.webDir;return n||(m.error("Missing argument, you need to provide a appid or be in a capacitor project"),A.error("")),i||(m.error("Missing argument, you need to provide a path (--path), or be in a capacitor project"),A.error("")),(0,cn.existsSync)(i)||(m.error(`Path ${i} does not exist, build your app first, or provide a valid path`),A.error("")),{appid:n,path:i}}function due(t,e){let r=t.codeCheck;(typeof r>"u"||r)&&(Yc(e,"notifyAppReady")||(m.error("notifyAppReady() is missing in the source code. see: https://capgo.app/docs/plugin/api/#notifyappready"),A.error("")),gp(e)||(m.error(`index.html is missing in the root folder of ${e}`),A.error("")))}async function hue(t,e,r,n,i,o){let s=r.ignoreMetadataCheck,a=r.autoMinUpdateVersion,u=r.minUpdateVersion,{data:c,error:l}=await t.from("channels").select("disable_auto_update, version ( min_update_version, native_packages )").eq("name",n).eq("app_id",i).single(),f=!!c&&c.disable_auto_update==="version_number",h,d;if(!l&&c&&c.version&&c.version.native_packages&&!s){let g=Ee();g.start(`Checking bundle compatibility with channel ${n}`);let{finalCompatibility:w,localDependencies:S}=await Ih(t,i,n,r.packageJson,r.nodeModules);if(d=w,h=S,d.find(y=>y.localVersion!==y.remoteVersion))g.stop(`Bundle NOT compatible with ${n} channel`),m.warn(`You can check compatibility with "${e.runner} @capgo/cli bundle compatibility"`),a&&(u=o,m.info(`Auto set min-update-version to ${u}`));else if(a)try{let{min_update_version:y}=c.version;(!y||!da.test(y))&&(m.error("Invalid remote min update version, skipping auto setting compatibility"),A.error("")),u=y,g.stop(`Auto set min-update-version to ${u}`)}catch{m.error(`Cannot auto set compatibility, invalid data ${c}`),A.error("")}else g.stop(`Bundle compatible with ${n} channel`)}else s||(m.warn(`Channel ${n} is new or it's your first upload with compatibility check, it will be ignored this time`),h=await fb(r.packageJson,r.nodeModules),a&&(u=o,m.info(`Auto set min-update-version to ${u}`)));f&&!u&&!s&&(m.error("You need to provide a min-update-version to upload a bundle to this channel"),A.error("")),u&&(da.test(u)||(m.error(`Your minimal version update ${u}, is not valid it should follow semver convention : https://semver.org/`),A.error("")));let p=h?new Map(h.filter(g=>!!g.native&&g.native!==void 0).map(g=>[g.name,g])):new Map;return{nativePackages:p.size>0||!r.ignoreMetadataCheck?Array.from(p,([g,w])=>({name:g,version:w.version})):void 0,minUpdateVersion:u}}async function pue(t,e,r){let{data:n,error:i}=await t.rpc("is_trial_org",{orgid:e}).single();(n&&n>0||i)&&(m.warn(`WARNING !!
283
- Trial expires in ${n} days`),m.warn(`Upgrade here: ${r.hostWeb}/dashboard/settings/plans?oid=${e}`))}async function mue(t,e,r){let{data:n,error:i}=await t.rpc("exist_app_versions",{appid:e,apikey:"",name_version:r}).single();(n||i)&&(m.error(`Version already exists ${te(i)}`),A.error(""))}async function gue(t,e,r,n,i,o){let s,a="",u=null,c=e.key,l=e.keyV2;u=await Rh(t);let f=Ee();if(f.start("Calculating checksum"),(l||e.keyDataV2||(0,cn.existsSync)(cr))&&c!==!1?a=await(0,Jb.checksum)(u,"sha256"):a=await(0,Jb.checksum)(u,"crc32"),f.stop(`Checksum: ${a}`),c===!1)m.info("Encryption ignored");else if((l||(0,cn.existsSync)(cr)||e.keyDataV2)&&!e.oldEncryption){let d=typeof l=="string"?l:cr,p=e.keyDataV2||"";!p&&!(0,cn.existsSync)(d)&&(m.error(`Cannot find private key ${d}`),A.error("")),await Fe(n,{channel:"app",event:"App encryption v2",icon:"\u{1F511}",user_id:i,tags:{"app-id":o},notify:!1}),p||(p=(0,cn.readFileSync)(d).toString()),m.info("Encrypting your bundle with V2");let b=sp(u,p);a=op(a,p),s=b.ivSessionKey,e.displayIvSession&&m.info(`Your Iv Session key is ${s},
283
+ Trial expires in ${n} days`),m.warn(`Upgrade here: ${r.hostWeb}/dashboard/settings/plans?oid=${e}`))}async function mue(t,e,r){let{data:n,error:i}=await t.rpc("exist_app_versions",{appid:e,apikey:"",name_version:r}).single();(n||i)&&(m.error(`Version already exists ${ee(i)}`),A.error(""))}async function gue(t,e,r,n,i,o){let s,a="",u=null,c=e.key,l=e.keyV2;u=await Rh(t);let f=Ee();if(f.start("Calculating checksum"),(l||e.keyDataV2||(0,cn.existsSync)(cr))&&c!==!1?a=await(0,Jb.checksum)(u,"sha256"):a=await(0,Jb.checksum)(u,"crc32"),f.stop(`Checksum: ${a}`),c===!1)m.info("Encryption ignored");else if((l||(0,cn.existsSync)(cr)||e.keyDataV2)&&!e.oldEncryption){let d=typeof l=="string"?l:cr,p=e.keyDataV2||"";!p&&!(0,cn.existsSync)(d)&&(m.error(`Cannot find private key ${d}`),A.error("")),await Fe(n,{channel:"app",event:"App encryption v2",icon:"\u{1F511}",user_id:i,tags:{"app-id":o},notify:!1}),p||(p=(0,cn.readFileSync)(d).toString()),m.info("Encrypting your bundle with V2");let b=sp(u,p);a=op(a,p),s=b.ivSessionKey,e.displayIvSession&&m.info(`Your Iv Session key is ${s},
284
284
  keep it safe, you will need it to decrypt your bundle.
285
285
  It will be also visible in your dashboard
286
286
  `),u=b.encryptedData}else if(c||e.keyData||(0,cn.existsSync)(lr)){m.warn(`WARNING !!
@@ -291,11 +291,11 @@ It will be also visible in your dashboard
291
291
  The app size is ${h} Mb, this may take a while to download for users
292
292
  `),m.info(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
293
293
  `),await Fe(n,{channel:"app-error",event:"App Too Large",icon:"\u{1F69B}",user_id:i,tags:{"app-id":o},notify:!1})),{zipped:u,sessionKey:s,checksum:a}}async function yue(t,e,r,n,i,o,s){let a=Ee();a.start("Uploading Bundle");let u=performance.now(),c=!1;if(s.dryUpload){a.stop(`Dry run, bundle not uploaded
294
- Bundle uploaded \u{1F4AA} in 0 seconds`);return}try{let h=await Cr();if(s.multipart!==void 0&&s.multipart||s.tus!==void 0&&s.tus){s.multipart?m.info("Uploading bundle with multipart protocol, multipart is deprecated"):m.info("Uploading bundle with TUS protocol"),await cj(t,o,i,r,n,a,h),c=!0;let d=`orgs/${i}/apps/${r}/${n}.zip`,{error:p}=await e.from("app_versions").update({r2_path:d}).eq("name",n).eq("app_id",r);p&&(m.error(`Cannot finish TUS upload ${te(p)}`),Promise.reject(new Error("Cannot finish TUS upload")))}else{let d=await sj(e,r,n);d||(m.error("Cannot get upload url"),Promise.reject(new Error("Cannot get upload url"))),await Vr.put(d,{timeout:s.timeout||Q6,retry:5,body:o})}}catch(h){let p=((performance.now()-u)/1e3).toFixed(2);if(a.stop(`Failed to upload bundle ( after ${p} seconds)`),h instanceof ti){let b=await h.response.json();m.error(`Response Error: ${b.error||b.status||b.message}`)}else m.error(`Cannot upload bundle ( try again with --tus option) ${te(h)}`);await lj(e,r,n),A.error("")}let f=((performance.now()-u)/1e3).toFixed(2);a.stop(`Bundle uploaded \u{1F4AA} in (${f} seconds)`),await Fe(t,{channel:"performance",event:c?"TUS upload zip performance":"Upload zip performance",icon:"\u{1F684}",user_id:i,tags:{"app-id":r,time:f},notify:!1})}async function Due(t,e,r,n,i,o,s,a,u){let{data:c}=await t.rpc("get_app_versions",{apikey:e,name_version:n,appid:a}).single();c||(m.warn("Cannot get version id, cannot set channel"),A.error(""));let{error:l,data:f}=await $h(t,{name:i,app_id:a,created_by:o,version:c,owner_org:s});l&&(m.error(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this. ${te(l)}`),A.error(""));let h=wo(a),d=`${u.hostWeb}/app/p/${h}/channel/${f.id}`;f?.public?m.info("Your update is now available in your public channel \u{1F389}"):f?.id&&m.info(`Link device to this bundle to try it: ${d}`),r?m.info(`Bundle url: ${d}`):c||(m.warn("Cannot set bundle with upload key, use key with more rights for that"),A.error(""))}async function vue(t,e,r){let{error:n,data:i}=await e.from("apps").select("default_upload_channel").single();if(n){m.warn("Cannot find default upload channel");let o=wo(t);return m.info(`You can set it here: ${r}/app/p/${o}/settings`),null}return i.default_upload_channel}async function yp(t,e,r=!0){X(`Uploading with CLI version ${Ir.version}`);let n=Nt();await De();let{s3Region:i,s3Apikey:o,s3Apisecret:s,s3BucketName:a,s3Endpoint:u,s3Port:c,s3SSL:l}=e,f=lue(e),h=await Q(),d=await ej(),{appid:p,path:b}=fue(t,e,h.config),g=await cue(h.config,e);e.autoSetBundle&&await bo({version:g}),due(e,b),m.info(`Upload ${p}@${g} started from path "${b}" to Capgo cloud`);let w=await Cr(),S=await de(f),y=await me(S,f,["write","all","upload"]),C=e.channel||await vue(p,S,w.hostWeb)||"dev",k=await Sr(S,p);await ha(S,k,f,p,!0),await pue(S,k,w);let{nativePackages:$,minUpdateVersion:F}=await hue(S,n,e,C,p,g);await mue(S,p,g),e.external&&!e.external.startsWith("https://")&&(m.error(`External link should should start with "https://" current is "${e.external}"`),A.error(""));let L={name:g,app_id:p,session_key:void 0,external_url:e.external,storage_provider:e.external?"external":"r2-direct",min_update_version:F,native_packages:$,owner_org:k,user_id:y,checksum:void 0},x=null;if(e.external)await Fe(f,{channel:"app",event:"App external",icon:"\u{1F4E4}",user_id:k,tags:{"app-id":p},notify:!1}),L.session_key=e.ivSessionKey,L.checksum=e.encryptedChecksum;else{let{zipped:q,sessionKey:K,checksum:M}=await gue(b,e,w,f,k,p);L.session_key=K,L.checksum=M,x=q,e.ignoreChecksumCheck||await dj(S,p,C,M)}!d.TUSUpload||e.external?e.tus=!1:e.tus=e.tus||d.TUSUploadForced,!d.partialUpload||e.external?e.partial=!1:e.partial=e.partial||d.partialUploadForced;let I=e.partial?await QN(b,f,k,p):[],{error:R}=await lb(S,L);if(R&&(m.error(`Cannot add bundle ${te(R)}`),A.error("")),x&&(a||u||i||o||s||c||l)){(!a||!u||!i||!o||!s||!c)&&(m.error("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret"),A.error("")),m.info("Uploading to S3");let q=new Kc({endPoint:u,region:i,port:c,useSSL:l,bucket:a,accessKey:o,secretKey:s}),K=`${p}-${g}`,M=encodeURIComponent(K);await q.putObject(K,Uint8Array.from(x)),L.external_url=`https://${u}/${M}`,L.storage_provider="external"}else if(x){await yue(f,S,p,g,k,x,e);let q=null;try{e.dryUpload&&(e.partial=!1),q=e.partial?await eL(f,I,b,p,g,k):null}catch(M){m.info(`Failed to upload partial files to capgo cloud. Error: ${te(M)}. This is not a critical error, the bundle has been uploaded without the partial files`)}L.storage_provider="r2",L.manifest=q;let{error:K}=await lb(S,L);K&&(m.error(`Cannot update bundle ${te(K)}`),A.error(""))}let B=await Le(S,f,p,2);return tj(B,3)?await Due(S,f,!!e.bundleUrl,g,C,y,k,p,w):m.warn("Cannot set channel as a upload organization member"),await Fe(f,{channel:"app",event:"App Uploaded",icon:"\u23EB",user_id:k,tags:{"app-id":p},notify:!1}),r&&(J("Time to share your update to the world \u{1F30D}"),(0,rL.exit)()),!0}function nL(t){t.ivSessionKey&&!t.external&&(m.error("You need to provide an external url if you want to use the --iv-session-key option"),A.error("")),t.encryptedChecksum&&!t.external&&(m.error("You need to provide an external url if you want to use the --encrypted-checksum option"),A.error("")),t.partial&&t.external&&(m.error("You cannot use the --partial option with an external url"),A.error("")),t.tus&&t.external&&(m.error("You cannot use the --tus option with an external url"),A.error("")),t.dryUpload&&t.external&&(m.error("You cannot use the --dry-upload option with an external url"),A.error("")),t.multipart&&t.external&&(m.error("You cannot use the --multipart option with an external url"),A.error("")),t.external&&(t.key||t.keyData||t.keyV2||t.keyDataV2)&&(m.error("You cannot set a key if you are uploading to an external url"),A.error("")),(t.key||t.keyData)&&(t.keyV2||t.keyDataV2)&&(m.error("You cannot set both key and key-v2"),A.error("")),t.key&&t.keyData&&(m.error("You cannot set both key and key-data"),A.error("")),t.keyV2&&t.keyDataV2&&(m.error("You cannot set both key-v2 and key-data-v2"),A.error("")),t.external&&(t.s3Region||t.s3Apikey||t.s3Apisecret||t.s3Endpoint||t.s3BucketName||t.s3Port||t.s3SSL)&&(m.error("You cannot set S3 options if you are uploading to an external url, it's automatically handled"),A.error("")),t.encryptedChecksum&&!t.external&&(m.error("You cannot set the --encrypted-checksum option if you are not uploading to an external url"),A.error("")),t.minUpdateVersion&&t.autoMinUpdateVersion&&(m.error("You cannot set both min-update-version and auto-min-update-version, use only one of them"),A.error(""))}async function iL(t,e){try{nL(e),await yp(t,e,!0)}catch(r){m.error(te(r)),A.error("")}}async function oL(t,e){let r=Nt();m.warn(`\u26A0\uFE0F This command is deprecated, use "${r.runner} @capgo/cli bundle upload" instead \u26A0\uFE0F`);try{nL(e),await yp(t,e,!0)}catch(n){m.error(te(n)),A.error("")}}var sL=require("node:crypto"),Dp=require("node:fs"),aL=require("node:process");var Xb=ce(vu());var bue=20;async function uL(t,e){try{let{bundle:r,path:n}=e,{json:i}=e;i||await De();let o=await Q();t=ge(t,o?.config);let s=(0,sL.randomUUID)().split("-")[0],a=await jt("",e.packageJson);r=r||a?.version||`0.0.1-beta.${s}`,i||X(`Zipping ${t}@${r}`),r&&!da.test(r)&&(i?console.error(te({error:"invalid_semver"})):m.error(`Your bundle name ${r}, is not valid it should follow semver convention : https://semver.org/`),A.error("")),n=n||o?.config?.webDir,(!t||!r||!n)&&(i?console.error(te({error:"missing_argument"})):m.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project"),A.error("")),i||m.info(`Started from path "${n}"`);let u=e.codeCheck;(typeof u>"u"||u)&&(Yc(n,"notifyAppReady")||(i?console.error(te({error:"notifyAppReady_not_in_source_code"})):m.error("notifyAppReady() is missing in the source code. see: https://capgo.app/docs/plugin/api/#notifyappready"),A.error("")),gp(n)||(i?console.error(te({error:"index_html_not_found"})):m.error(`index.html is missing in the root folder of ${n}`),A.error("")));let c=await Rh(n);i||m.info(`Zipped ${c.byteLength} bytes`);let l=Ee();i||l.start("Calculating checksum");let f="";e.keyV2||(0,Dp.existsSync)(cr)?f=await(0,Xb.checksum)(c,"sha256"):f=await(0,Xb.checksum)(c,"crc32"),i||l.stop(`Checksum: ${f}`);let h=Math.floor(c.byteLength/1024/1024);h>bue&&!i&&(m.warn(`WARNING !!
294
+ Bundle uploaded \u{1F4AA} in 0 seconds`);return}try{let h=await Cr();if(s.multipart!==void 0&&s.multipart||s.tus!==void 0&&s.tus){s.multipart?m.info("Uploading bundle with multipart protocol, multipart is deprecated"):m.info("Uploading bundle with TUS protocol"),await cj(t,o,i,r,n,a,h),c=!0;let d=`orgs/${i}/apps/${r}/${n}.zip`,{error:p}=await e.from("app_versions").update({r2_path:d}).eq("name",n).eq("app_id",r);p&&(m.error(`Cannot finish TUS upload ${ee(p)}`),Promise.reject(new Error("Cannot finish TUS upload")))}else{let d=await sj(e,r,n);d||(m.error("Cannot get upload url"),Promise.reject(new Error("Cannot get upload url"))),await Vr.put(d,{timeout:s.timeout||Q6,retry:5,body:o})}}catch(h){let p=((performance.now()-u)/1e3).toFixed(2);if(a.stop(`Failed to upload bundle ( after ${p} seconds)`),h instanceof ti){let b=await h.response.json();m.error(`Response Error: ${b.error||b.status||b.message}`)}else s.tus?m.error(`Cannot upload bundle please contact support if the issue persists ${ee(h)}`):m.error(`Cannot upload bundle ( try again with --tus option) ${ee(h)}`);await lj(e,r,n),A.error("")}let f=((performance.now()-u)/1e3).toFixed(2);a.stop(`Bundle uploaded \u{1F4AA} in (${f} seconds)`),await Fe(t,{channel:"performance",event:c?"TUS upload zip performance":"Upload zip performance",icon:"\u{1F684}",user_id:i,tags:{"app-id":r,time:f},notify:!1})}async function Due(t,e,r,n,i,o,s,a,u){let{data:c}=await t.rpc("get_app_versions",{apikey:e,name_version:n,appid:a}).single();c||(m.warn("Cannot get version id, cannot set channel"),A.error(""));let{error:l,data:f}=await $h(t,{name:i,app_id:a,created_by:o,version:c,owner_org:s});l&&(m.error(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this. ${ee(l)}`),A.error(""));let h=wo(a),d=`${u.hostWeb}/app/p/${h}/channel/${f.id}`;f?.public?m.info("Your update is now available in your public channel \u{1F389}"):f?.id&&m.info(`Link device to this bundle to try it: ${d}`),r?m.info(`Bundle url: ${d}`):c||(m.warn("Cannot set bundle with upload key, use key with more rights for that"),A.error(""))}async function vue(t,e,r){let{error:n,data:i}=await e.from("apps").select("default_upload_channel").single();if(n){m.warn("Cannot find default upload channel");let o=wo(t);return m.info(`You can set it here: ${r}/app/p/${o}/settings`),null}return i.default_upload_channel}async function yp(t,e,r=!0){X(`Uploading with CLI version ${Ir.version}`);let n=Nt();await De();let{s3Region:i,s3Apikey:o,s3Apisecret:s,s3BucketName:a,s3Endpoint:u,s3Port:c,s3SSL:l}=e,f=lue(e),h=await Q(),d=await ej(),{appid:p,path:b}=fue(t,e,h.config),g=await cue(h.config,e);e.autoSetBundle&&await bo({version:g}),due(e,b),m.info(`Upload ${p}@${g} started from path "${b}" to Capgo cloud`);let w=await Cr(),S=await de(f),y=await me(S,f,["write","all","upload"]),C=e.channel||await vue(p,S,w.hostWeb)||"dev",k=await Sr(S,p);await ha(S,k,f,p,!0),await pue(S,k,w);let{nativePackages:$,minUpdateVersion:F}=await hue(S,n,e,C,p,g);await mue(S,p,g),e.external&&!e.external.startsWith("https://")&&(m.error(`External link should should start with "https://" current is "${e.external}"`),A.error(""));let L={name:g,app_id:p,session_key:void 0,external_url:e.external,storage_provider:e.external?"external":"r2-direct",min_update_version:F,native_packages:$,owner_org:k,user_id:y,checksum:void 0},x=null;if(e.external)await Fe(f,{channel:"app",event:"App external",icon:"\u{1F4E4}",user_id:k,tags:{"app-id":p},notify:!1}),L.session_key=e.ivSessionKey,L.checksum=e.encryptedChecksum;else{let{zipped:q,sessionKey:K,checksum:M}=await gue(b,e,w,f,k,p);L.session_key=K,L.checksum=M,x=q,e.ignoreChecksumCheck||await dj(S,p,C,M)}!d.TUSUpload||e.external?e.tus=!1:e.tus=e.tus||d.TUSUploadForced,!d.partialUpload||e.external?e.partial=!1:e.partial=e.partial||d.partialUploadForced;let I=e.partial?await QN(b,f,k,p):[],{error:R}=await lb(S,L);if(R&&(m.error(`Cannot add bundle ${ee(R)}`),A.error("")),x&&(a||u||i||o||s||c||l)){(!a||!u||!i||!o||!s||!c)&&(m.error("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret"),A.error("")),m.info("Uploading to S3");let q=new Kc({endPoint:u,region:i,port:c,useSSL:l,bucket:a,accessKey:o,secretKey:s}),K=`${p}-${g}`,M=encodeURIComponent(K);await q.putObject(K,Uint8Array.from(x)),L.external_url=`https://${u}/${M}`,L.storage_provider="external"}else if(x){await yue(f,S,p,g,k,x,e);let q=null;try{e.dryUpload&&(e.partial=!1),q=e.partial?await eL(f,I,b,p,g,k):null}catch(M){m.info(`Failed to upload partial files to capgo cloud. Error: ${ee(M)}. This is not a critical error, the bundle has been uploaded without the partial files`)}L.storage_provider="r2",L.manifest=q;let{error:K}=await lb(S,L);K&&(m.error(`Cannot update bundle ${ee(K)}`),A.error(""))}let B=await Le(S,f,p,2);return tj(B,3)?await Due(S,f,!!e.bundleUrl,g,C,y,k,p,w):m.warn("Cannot set channel as a upload organization member"),await Fe(f,{channel:"app",event:"App Uploaded",icon:"\u23EB",user_id:k,tags:{"app-id":p},notify:!1}),r&&(J("Time to share your update to the world \u{1F30D}"),(0,rL.exit)()),!0}function nL(t){t.ivSessionKey&&!t.external&&(m.error("You need to provide an external url if you want to use the --iv-session-key option"),A.error("")),t.encryptedChecksum&&!t.external&&(m.error("You need to provide an external url if you want to use the --encrypted-checksum option"),A.error("")),t.partial&&t.external&&(m.error("You cannot use the --partial option with an external url"),A.error("")),t.tus&&t.external&&(m.error("You cannot use the --tus option with an external url"),A.error("")),t.dryUpload&&t.external&&(m.error("You cannot use the --dry-upload option with an external url"),A.error("")),t.multipart&&t.external&&(m.error("You cannot use the --multipart option with an external url"),A.error("")),t.external&&(t.key||t.keyData||t.keyV2||t.keyDataV2)&&(m.error("You cannot set a key if you are uploading to an external url"),A.error("")),(t.key||t.keyData)&&(t.keyV2||t.keyDataV2)&&(m.error("You cannot set both key and key-v2"),A.error("")),t.key&&t.keyData&&(m.error("You cannot set both key and key-data"),A.error("")),t.keyV2&&t.keyDataV2&&(m.error("You cannot set both key-v2 and key-data-v2"),A.error("")),t.external&&(t.s3Region||t.s3Apikey||t.s3Apisecret||t.s3Endpoint||t.s3BucketName||t.s3Port||t.s3SSL)&&(m.error("You cannot set S3 options if you are uploading to an external url, it's automatically handled"),A.error("")),t.encryptedChecksum&&!t.external&&(m.error("You cannot set the --encrypted-checksum option if you are not uploading to an external url"),A.error("")),t.minUpdateVersion&&t.autoMinUpdateVersion&&(m.error("You cannot set both min-update-version and auto-min-update-version, use only one of them"),A.error(""))}async function iL(t,e){try{nL(e),await yp(t,e,!0)}catch(r){m.error(ee(r)),A.error("")}}async function oL(t,e){let r=Nt();m.warn(`\u26A0\uFE0F This command is deprecated, use "${r.runner} @capgo/cli bundle upload" instead \u26A0\uFE0F`);try{nL(e),await yp(t,e,!0)}catch(n){m.error(ee(n)),A.error("")}}var sL=require("node:crypto"),Dp=require("node:fs"),aL=require("node:process");var Xb=ce(vu());var bue=20;async function uL(t,e){try{let{bundle:r,path:n}=e,{json:i}=e;i||await De();let o=await Q();t=ge(t,o?.config);let s=(0,sL.randomUUID)().split("-")[0],a=await jt("",e.packageJson);r=r||a?.version||`0.0.1-beta.${s}`,i||X(`Zipping ${t}@${r}`),r&&!da.test(r)&&(i?console.error(ee({error:"invalid_semver"})):m.error(`Your bundle name ${r}, is not valid it should follow semver convention : https://semver.org/`),A.error("")),n=n||o?.config?.webDir,(!t||!r||!n)&&(i?console.error(ee({error:"missing_argument"})):m.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project"),A.error("")),i||m.info(`Started from path "${n}"`);let u=e.codeCheck;(typeof u>"u"||u)&&(Yc(n,"notifyAppReady")||(i?console.error(ee({error:"notifyAppReady_not_in_source_code"})):m.error("notifyAppReady() is missing in the source code. see: https://capgo.app/docs/plugin/api/#notifyappready"),A.error("")),gp(n)||(i?console.error(ee({error:"index_html_not_found"})):m.error(`index.html is missing in the root folder of ${n}`),A.error("")));let c=await Rh(n);i||m.info(`Zipped ${c.byteLength} bytes`);let l=Ee();i||l.start("Calculating checksum");let f="";e.keyV2||(0,Dp.existsSync)(cr)?f=await(0,Xb.checksum)(c,"sha256"):f=await(0,Xb.checksum)(c,"crc32"),i||l.stop(`Checksum: ${f}`);let h=Math.floor(c.byteLength/1024/1024);h>bue&&!i&&(m.warn(`WARNING !!
295
295
  The app size is ${h} Mb, this may take a while to download for users
296
296
  `),m.warn(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
297
- `));let d=Ee(),p=e.name||`${t}_${r}.zip`;i||d.start(`Saving to ${p}`),(0,Dp.writeFileSync)(p,c),i||d.stop(`Saved to ${p}`),i||J("Done \u2705"),i&&console.log(JSON.stringify({bundle:r,filename:p,checksum:f},null,2)),(0,aL.exit)()}catch(r){m.error(te(r)),A.error("")}}var cL=require("node:process");async function Zb(t,e,r,n=!0){X("Create channel"),r.apikey=r.apikey||pe();let i=await Q();e=ge(e,i?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let o=await de(r.apikey);await me(o,r.apikey,["write","all"]),await Le(o,r.apikey,e,4),m.info(`Creating channel ${e}#${t} to Capgo`);try{let s=await Mb(o,e),a=await Sr(o,e);s||(m.error("Cannot find default version for channel creation, please contact Capgo support \u{1F928}"),A.error(""));let u=await fN(o,{name:t,app_id:e,version:s.id,owner_org:a});u.error&&(m.error(`Cannot create Channel \u{1F640}
298
- ${te(u.error)}`),A.error("")),m.success("Channel created \u2705"),await Fe(r.apikey,{channel:"channel",event:"Create channel",icon:"\u2705",user_id:a,tags:{"app-id":e,channel:t},notify:!1}).catch()}catch{return m.error("Cannot create Channel \u{1F640}"),!1}return n&&(J("Done \u2705"),(0,cL.exit)()),!0}async function lL(t,e,r){Zb(t,e,r,!0)}var fL=require("node:process");async function dL(t,e,r){let{quiet:n}=r;n||X("List current bundle"),r.apikey=r.apikey||pe(n);let i=await Q();e=ge(e,i?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let o=await de(r.apikey),s=await me(o,r.apikey,["write","all","read"]);await Le(o,r.apikey,e,1),t||(m.error("Please provide a channel to get the bundle from."),A.error(""));let{data:a,error:u}=await o.from("channels").select("version ( name )").eq("name",t).eq("app_id",e).limit(1);(u||a.length===0)&&(m.error(`Error retrieving channel ${t} for app ${e}. Perhaps the channel does not exists?`),A.error(""));let{version:c}=a[0];c||(m.error(`Error retrieving channel ${t} for app ${e}. Perhaps the channel does not exists?`),A.error("")),n?m.info(c.name):m.info(`Current bundle for channel ${t} is ${c.name}`),(0,fL.exit)()}var hL=require("node:process");async function pL(t,e,r){X("Delete channel"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey),o=await me(i,r.apikey,["write","all"]);await Le(i,r.apikey,e,4),m.info(`Deleting channel ${e}#${t} from Capgo`);try{let s=await dN(i,t,e,o);s.error&&(m.error(`Cannot delete Channel \u{1F640} ${te(s.error)}`),A.error(""));let a=await Sr(i,e);m.success("Channel deleted"),await Fe(r.apikey,{channel:"channel",event:"Delete channel",icon:"\u2705",user_id:a,tags:{"user-id":o,"app-id":e,channel:t},notify:!1}).catch()}catch{m.error("Cannot delete Channel \u{1F640}")}J("Done \u2705"),(0,hL.exit)()}var mL=require("node:process");async function gL(t,e){X("List channels"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||m.error("Missing API key, you need to provide a API key to upload your bundle"),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),i=await me(n,e.apikey,["write","all","read","upload"]);await Le(n,e.apikey,t,1),m.info("Querying available channels in Capgo");let o=await pN(n,t);m.info(`Active channels in Capgo: ${o?.length}`),hN(o),await Fe(e.apikey,{channel:"channel",event:"List channel",icon:"\u2705",user_id:i,tags:{"app-id":t},notify:!1}).catch(),J("Done \u2705"),(0,mL.exit)()}var DL=require("node:process");var yL=["major","minor","metadata","patch","none"];async function vL(t,e,r){X("Set channel"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey),o=await me(i,r.apikey,["write","all"]);await Le(i,r.apikey,e,4);let s=await Sr(i,e),{bundle:a,state:u,downgrade:c,latest:l,upgrade:f,ios:h,android:d,selfAssign:p,disableAutoUpdate:b,dev:g,emulator:w}=r;t||(m.error("Missing argument, you need to provide a channel"),A.error("")),l&&a&&(m.error("Cannot set latest and bundle at the same time"),A.error("")),a==null&&u==null&&l==null&&c==null&&f==null&&h==null&&d==null&&p==null&&g==null&&w==null&&b==null&&(m.error("Missing argument, you need to provide a option to set"),A.error(""));try{await ha(i,s,r.apikey,e);let S={created_by:o,app_id:e,name:t,owner_org:s,version:void 0},y=await jt("",r.packageJson),C=l?n?.config?.plugins?.CapacitorUpdater?.version||y?.version:a;if(C!=null){let{data:k,error:$}=await i.from("app_versions").select().eq("app_id",e).eq("name",C).eq("user_id",o).eq("deleted",!1).single();($||!k)&&(m.error(`Cannot find version ${C}`),A.error("")),m.info(`Set ${e} channel: ${t} to @${C}`),S.version=k.id}if(u!=null&&((u==="public"||u==="private")&&m.info(`Set ${e} channel: ${t} to public or private is deprecated, use default or normal instead`),m.info(`Set ${e} channel: ${t} to ${u==="public"||u==="default"?"default":"normal"}`),S.public=u==="public"||u==="default"),c!=null&&(m.info(`Set ${e} channel: ${t} to ${c?"allow":"disallow"} downgrade`),S.disable_auto_update_under_native=!c),h!=null&&(m.info(`Set ${e} channel: ${t} to ${h?"allow":"disallow"} ios update`),S.ios=!!h),d!=null&&(m.info(`Set ${e} channel: ${t} to ${d?"allow":"disallow"} android update`),S.android=!!d),p!=null&&(m.info(`Set ${e} channel: ${t} to ${p?"allow":"disallow"} self assign to this channel`),S.allow_device_self_set=!!p),b!=null){let k=b.toLocaleLowerCase();yL.includes(k)||(m.error(`Channel strategy ${k} is not known. The possible values are: ${yL.join(", ")}.`),A.error("")),k==="metadata"&&(k="version_number"),S.disable_auto_update=k,m.info(`Set ${e} channel: ${t} to ${k} disable update strategy to this channel`)}try{let{error:k}=await $h(i,S);k&&(m.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.'),A.error(""))}catch{m.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.'),A.error("")}await Fe(r.apikey,{channel:"channel",event:"Set channel",icon:"\u2705",user_id:s,tags:{"app-id":e},notify:!1}).catch()}catch(S){m.error(`Unknow error ${te(S)}`),A.error("")}J("Done \u2705"),(0,DL.exit)()}var Xc=require("node:child_process"),st=require("node:fs"),wp=require("node:path"),rr=require("node:process");var _p=ce(IL());var sw=require("node:process");function Nue(t){return new Promise(e=>{setTimeout(e,t)})}async function Vn(t,e,r,n,i="\u2705"){await Fe(r,{channel:t,event:n,icon:i,user_id:e,notify:!1})}async function Lue(t,e,r,n){kt(e)&&(await Vn(t,r,n,"canceled","\u{1F937}"),(0,sw.exit)())}async function Bue(t,e,r){try{let n=await Cr(),i=await Vr.post(`${n.hostApi}/private/stats`,{headers:{"Content-Type":"application/json",capgkey:t},body:JSON.stringify(e)}).then(o=>o.json()).catch(o=>(console.error("Cannot get devices",o),[]));if(i?.length>0&&(r===null||r!==i[0].created_at))return i}catch(n){m.error(`Cannot get stats ${te(n)}`)}return[]}async function que(t,e,r,n,i,o){if(m.info(`Log from Device: ${t.device_id}`),t.action==="get")m.info("Update Sent your your device, wait until event download complete"),await Vn(e,r,n,"done");else if(t.action.startsWith("download_")){let s=t.action.split("_")[1];s==="complete"?(m.info("Your bundle has been downloaded on your device, background the app now and open it again to see the update"),await Vn(e,r,n,"downloaded")):s==="fail"?(m.error("Your bundle has failed to download on your device."),m.error("Please check if you have network connection and try again")):m.info(`Your bundle is downloading ${s}% ...`)}else{if(t.action==="set")return m.info("Your bundle has been set on your device \u2764\uFE0F"),await Vn(e,r,n,"set"),!1;t.action==="NoChannelOrOverride"?m.error(`No default channel or override (channel/device) found, please create it here ${i}`):t.action==="needPlanUpgrade"?m.error(`Your are out of quota, please upgrade your plan here ${o}/dashboard/settings/plans`):t.action==="missingBundle"?m.error("Your bundle is missing, please check how you build your app"):t.action==="noNew"?(m.error(`The version number you uploaded to your default channel in Capgo, is the same as the present in the device ${t.device_id}.`),m.error(`To fix it, ensure the variable:
297
+ `));let d=Ee(),p=e.name||`${t}_${r}.zip`;i||d.start(`Saving to ${p}`),(0,Dp.writeFileSync)(p,c),i||d.stop(`Saved to ${p}`),i||J("Done \u2705"),i&&console.log(JSON.stringify({bundle:r,filename:p,checksum:f},null,2)),(0,aL.exit)()}catch(r){m.error(ee(r)),A.error("")}}var cL=require("node:process");async function Zb(t,e,r,n=!0){X("Create channel"),r.apikey=r.apikey||pe();let i=await Q();e=ge(e,i?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let o=await de(r.apikey);await me(o,r.apikey,["write","all"]),await Le(o,r.apikey,e,4),m.info(`Creating channel ${e}#${t} to Capgo`);try{let s=await Mb(o,e),a=await Sr(o,e);s||(m.error("Cannot find default version for channel creation, please contact Capgo support \u{1F928}"),A.error(""));let u=await fN(o,{name:t,app_id:e,version:s.id,owner_org:a});u.error&&(m.error(`Cannot create Channel \u{1F640}
298
+ ${ee(u.error)}`),A.error("")),m.success("Channel created \u2705"),await Fe(r.apikey,{channel:"channel",event:"Create channel",icon:"\u2705",user_id:a,tags:{"app-id":e,channel:t},notify:!1}).catch()}catch{return m.error("Cannot create Channel \u{1F640}"),!1}return n&&(J("Done \u2705"),(0,cL.exit)()),!0}async function lL(t,e,r){Zb(t,e,r,!0)}var fL=require("node:process");async function dL(t,e,r){let{quiet:n}=r;n||X("List current bundle"),r.apikey=r.apikey||pe(n);let i=await Q();e=ge(e,i?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let o=await de(r.apikey),s=await me(o,r.apikey,["write","all","read"]);await Le(o,r.apikey,e,1),t||(m.error("Please provide a channel to get the bundle from."),A.error(""));let{data:a,error:u}=await o.from("channels").select("version ( name )").eq("name",t).eq("app_id",e).limit(1);(u||a.length===0)&&(m.error(`Error retrieving channel ${t} for app ${e}. Perhaps the channel does not exists?`),A.error(""));let{version:c}=a[0];c||(m.error(`Error retrieving channel ${t} for app ${e}. Perhaps the channel does not exists?`),A.error("")),n?m.info(c.name):m.info(`Current bundle for channel ${t} is ${c.name}`),(0,fL.exit)()}var hL=require("node:process");async function pL(t,e,r){X("Delete channel"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey),o=await me(i,r.apikey,["write","all"]);await Le(i,r.apikey,e,4),m.info(`Deleting channel ${e}#${t} from Capgo`);try{let s=await dN(i,t,e,o);s.error&&(m.error(`Cannot delete Channel \u{1F640} ${ee(s.error)}`),A.error(""));let a=await Sr(i,e);m.success("Channel deleted"),await Fe(r.apikey,{channel:"channel",event:"Delete channel",icon:"\u2705",user_id:a,tags:{"user-id":o,"app-id":e,channel:t},notify:!1}).catch()}catch{m.error("Cannot delete Channel \u{1F640}")}J("Done \u2705"),(0,hL.exit)()}var mL=require("node:process");async function gL(t,e){X("List channels"),e.apikey=e.apikey||pe();let r=await Q();t=ge(t,r?.config),e.apikey||m.error("Missing API key, you need to provide a API key to upload your bundle"),t||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let n=await de(e.apikey),i=await me(n,e.apikey,["write","all","read","upload"]);await Le(n,e.apikey,t,1),m.info("Querying available channels in Capgo");let o=await pN(n,t);m.info(`Active channels in Capgo: ${o?.length}`),hN(o),await Fe(e.apikey,{channel:"channel",event:"List channel",icon:"\u2705",user_id:i,tags:{"app-id":t},notify:!1}).catch(),J("Done \u2705"),(0,mL.exit)()}var DL=require("node:process");var yL=["major","minor","metadata","patch","none"];async function vL(t,e,r){X("Set channel"),r.apikey=r.apikey||pe();let n=await Q();e=ge(e,n?.config),r.apikey||(m.error("Missing API key, you need to provide a API key to upload your bundle"),A.error("")),e||(m.error("Missing argument, you need to provide a appId, or be in a capacitor project"),A.error(""));let i=await de(r.apikey),o=await me(i,r.apikey,["write","all"]);await Le(i,r.apikey,e,4);let s=await Sr(i,e),{bundle:a,state:u,downgrade:c,latest:l,upgrade:f,ios:h,android:d,selfAssign:p,disableAutoUpdate:b,dev:g,emulator:w}=r;t||(m.error("Missing argument, you need to provide a channel"),A.error("")),l&&a&&(m.error("Cannot set latest and bundle at the same time"),A.error("")),a==null&&u==null&&l==null&&c==null&&f==null&&h==null&&d==null&&p==null&&g==null&&w==null&&b==null&&(m.error("Missing argument, you need to provide a option to set"),A.error(""));try{await ha(i,s,r.apikey,e);let S={created_by:o,app_id:e,name:t,owner_org:s,version:void 0},y=await jt("",r.packageJson),C=l?n?.config?.plugins?.CapacitorUpdater?.version||y?.version:a;if(C!=null){let{data:k,error:$}=await i.from("app_versions").select().eq("app_id",e).eq("name",C).eq("user_id",o).eq("deleted",!1).single();($||!k)&&(m.error(`Cannot find version ${C}`),A.error("")),m.info(`Set ${e} channel: ${t} to @${C}`),S.version=k.id}if(u!=null&&((u==="public"||u==="private")&&m.info(`Set ${e} channel: ${t} to public or private is deprecated, use default or normal instead`),m.info(`Set ${e} channel: ${t} to ${u==="public"||u==="default"?"default":"normal"}`),S.public=u==="public"||u==="default"),c!=null&&(m.info(`Set ${e} channel: ${t} to ${c?"allow":"disallow"} downgrade`),S.disable_auto_update_under_native=!c),h!=null&&(m.info(`Set ${e} channel: ${t} to ${h?"allow":"disallow"} ios update`),S.ios=!!h),d!=null&&(m.info(`Set ${e} channel: ${t} to ${d?"allow":"disallow"} android update`),S.android=!!d),p!=null&&(m.info(`Set ${e} channel: ${t} to ${p?"allow":"disallow"} self assign to this channel`),S.allow_device_self_set=!!p),b!=null){let k=b.toLocaleLowerCase();yL.includes(k)||(m.error(`Channel strategy ${k} is not known. The possible values are: ${yL.join(", ")}.`),A.error("")),k==="metadata"&&(k="version_number"),S.disable_auto_update=k,m.info(`Set ${e} channel: ${t} to ${k} disable update strategy to this channel`)}try{let{error:k}=await $h(i,S);k&&(m.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.'),A.error(""))}catch{m.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.'),A.error("")}await Fe(r.apikey,{channel:"channel",event:"Set channel",icon:"\u2705",user_id:s,tags:{"app-id":e},notify:!1}).catch()}catch(S){m.error(`Unknow error ${ee(S)}`),A.error("")}J("Done \u2705"),(0,DL.exit)()}var Xc=require("node:child_process"),st=require("node:fs"),wp=require("node:path"),rr=require("node:process");var _p=ce(IL());var sw=require("node:process");function Nue(t){return new Promise(e=>{setTimeout(e,t)})}async function Vn(t,e,r,n,i="\u2705"){await Fe(r,{channel:t,event:n,icon:i,user_id:e,notify:!1})}async function Lue(t,e,r,n){kt(e)&&(await Vn(t,r,n,"canceled","\u{1F937}"),(0,sw.exit)())}async function Bue(t,e,r){try{let n=await Cr(),i=await Vr.post(`${n.hostApi}/private/stats`,{headers:{"Content-Type":"application/json",capgkey:t},body:JSON.stringify(e)}).then(o=>o.json()).catch(o=>(console.error("Cannot get devices",o),[]));if(i?.length>0&&(r===null||r!==i[0].created_at))return i}catch(n){m.error(`Cannot get stats ${ee(n)}`)}return[]}async function que(t,e,r,n,i,o){if(m.info(`Log from Device: ${t.device_id}`),t.action==="get")m.info("Update Sent your your device, wait until event download complete"),await Vn(e,r,n,"done");else if(t.action.startsWith("download_")){let s=t.action.split("_")[1];s==="complete"?(m.info("Your bundle has been downloaded on your device, background the app now and open it again to see the update"),await Vn(e,r,n,"downloaded")):s==="fail"?(m.error("Your bundle has failed to download on your device."),m.error("Please check if you have network connection and try again")):m.info(`Your bundle is downloading ${s}% ...`)}else{if(t.action==="set")return m.info("Your bundle has been set on your device \u2764\uFE0F"),await Vn(e,r,n,"set"),!1;t.action==="NoChannelOrOverride"?m.error(`No default channel or override (channel/device) found, please create it here ${i}`):t.action==="needPlanUpgrade"?m.error(`Your are out of quota, please upgrade your plan here ${o}/dashboard/settings/plans`):t.action==="missingBundle"?m.error("Your bundle is missing, please check how you build your app"):t.action==="noNew"?(m.error(`The version number you uploaded to your default channel in Capgo, is the same as the present in the device ${t.device_id}.`),m.error(`To fix it, ensure the variable:
299
299
  - iOS: keyCFBundleShortVersionString or MARKETING_VERSION
300
300
  - Android: versionName
301
301
  Are lower than the version number you uploaded to Capgo.`),m.error("More info here: https://capgo.app/blog/how-version-work-in-capgo/#versioning-system")):t.action==="disablePlatformIos"?m.error(`iOS is disabled in the default channel and your device ${t.device_id} is an iOS device ${i}`):t.action==="disablePlatformAndroid"?m.error(`Android is disabled in the default channel and your device ${t.device_id} is an Android device ${i}`):t.action==="disableAutoUpdateToMajor"?(m.error(`The version number you uploaded to your default channel in Capgo, is a major version higher (ex: 1.0.0 in device to 2.0.0 in Capgo) than the present in the device ${t.device_id}.`),m.error("Capgo is set by default to protect you from this, and avoid sending breaking changes incompatible with the native code present in the device."),m.error(`To fix it, ensure the variable: