@capgo/cli 8.25.1 → 8.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -10
- package/dist/package.json +1 -1
- package/dist/src/sdk.js +2 -2
- package/dist/src/support/support-upload.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ Expecting one of '${B.join("', '")}'`);if(this._lifeCycleHooks[A])this._lifeCycl
|
|
|
91
91
|
`),this.outputHelp({error:!0});let B=Q||{},$=B.exitCode||1,J=B.code||"commander.error";this._exit($,J,A)}_parseOptionsEnv(){this.options.forEach((A)=>{if(A.envVar&&A.envVar in V$.env){let Q=A.attributeName();if(this.getOptionValue(Q)===void 0||["default","config","env"].includes(this.getOptionValueSource(Q)))if(A.required||A.optional)this.emit(`optionEnv:${A.name()}`,V$.env[A.envVar]);else this.emit(`optionEnv:${A.name()}`)}})}_parseOptionsImplied(){let A=new s3Q(this.options),Q=(B)=>{return this.getOptionValue(B)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(B))};this.options.filter((B)=>B.implied!==void 0&&Q(B.attributeName())&&A.valueFromOption(this.getOptionValue(B.attributeName()),B)).forEach((B)=>{Object.keys(B.implied).filter(($)=>!Q($)).forEach(($)=>{this.setOptionValueWithSource($,B.implied[$],"implied")})})}missingArgument(A){let Q=`error: missing required argument '${A}'`;this.error(Q,{code:"commander.missingArgument"})}optionMissingArgument(A){let Q=`error: option '${A.flags}' argument missing`;this.error(Q,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(A){let Q=`error: required option '${A.flags}' not specified`;this.error(Q,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(A,Q){let B=(Y)=>{let X=Y.attributeName(),G=this.getOptionValue(X),K=this.options.find((H)=>H.negate&&X===H.attributeName()),W=this.options.find((H)=>!H.negate&&X===H.attributeName());if(K&&(K.presetArg===void 0&&G===!1||K.presetArg!==void 0&&G===K.presetArg))return K;return W||Y},$=(Y)=>{let X=B(Y),G=X.attributeName();if(this.getOptionValueSource(G)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},J=`error: ${$(A)} cannot be used with ${$(Q)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption(A){if(this._allowUnknownOption)return;let Q="";if(A.startsWith("--")&&this._showSuggestionAfterError){let $=[],J=this;do{let Y=J.createHelp().visibleOptions(J).filter((X)=>X.long).map((X)=>X.long);$=$.concat(Y),J=J.parent}while(J&&!J._enablePositionalOptions);Q=UMA(A,$)}let B=`error: unknown option '${A}'${Q}`;this.error(B,{code:"commander.unknownOption"})}_excessArguments(A){if(this._allowExcessArguments)return;let Q=this.registeredArguments.length,B=Q===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${Q} argument${B} but got ${A.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let A=this.args[0],Q="";if(this._showSuggestionAfterError){let $=[];this.createHelp().visibleCommands(this).forEach((J)=>{if($.push(J.name()),J.alias())$.push(J.alias())}),Q=UMA(A,$)}let B=`error: unknown command '${A}'${Q}`;this.error(B,{code:"commander.unknownCommand"})}version(A,Q,B){if(A===void 0)return this._version;this._version=A,Q=Q||"-V, --version",B=B||"output the version number";let $=this.createOption(Q,B);return this._versionOptionName=$.attributeName(),this._registerOption($),this.on("option:"+$.name(),()=>{this._outputConfiguration.writeOut(`${A}
|
|
92
92
|
`),this._exit(0,"commander.version",A)}),this}description(A,Q){if(A===void 0&&Q===void 0)return this._description;if(this._description=A,Q)this._argsDescription=Q;return this}summary(A){if(A===void 0)return this._summary;return this._summary=A,this}alias(A){if(A===void 0)return this._aliases[0];let Q=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)Q=this.commands[this.commands.length-1];if(A===Q._name)throw Error("Command alias can't be the same as its name");let B=this.parent?._findCommand(A);if(B){let $=[B.name()].concat(B.aliases()).join("|");throw Error(`cannot add alias '${A}' to command '${this.name()}' as already have command '${$}'`)}return Q._aliases.push(A),this}aliases(A){if(A===void 0)return this._aliases;return A.forEach((Q)=>this.alias(Q)),this}usage(A){if(A===void 0){if(this._usage)return this._usage;let Q=this.registeredArguments.map((B)=>{return a3Q(B)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?Q:[]).join(" ")}return this._usage=A,this}name(A){if(A===void 0)return this._name;return this._name=A,this}helpGroup(A){if(A===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=A,this}commandsGroup(A){if(A===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=A,this}optionsGroup(A){if(A===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=A,this}_initOptionGroup(A){if(this._defaultOptionGroup&&!A.helpGroupHeading)A.helpGroup(this._defaultOptionGroup)}_initCommandGroup(A){if(this._defaultCommandGroup&&!A.helpGroup())A.helpGroup(this._defaultCommandGroup)}nameFromFilename(A){return this._name=Tq.basename(A,Tq.extname(A)),this}executableDir(A){if(A===void 0)return this._executableDir;return this._executableDir=A,this}helpInformation(A){let Q=this.createHelp(),B=this._getOutputContext(A);Q.prepareContext({error:B.error,helpWidth:B.helpWidth,outputHasColors:B.hasColors});let $=Q.formatHelp(this,Q);if(B.hasColors)return $;return this._outputConfiguration.stripColor($)}_getOutputContext(A){A=A||{};let Q=!!A.error,B,$,J;if(Q)B=(X)=>this._outputConfiguration.writeErr(X),$=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else B=(X)=>this._outputConfiguration.writeOut(X),$=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:Q,write:(X)=>{if(!$)X=this._outputConfiguration.stripColor(X);return B(X)},hasColors:$,helpWidth:J}}outputHelp(A){let Q;if(typeof A==="function")Q=A,A=void 0;let B=this._getOutputContext(A),$={error:B.error,write:B.write,command:this};this._getCommandAndAncestors().reverse().forEach((Y)=>Y.emit("beforeAllHelp",$)),this.emit("beforeHelp",$);let J=this.helpInformation({error:B.error});if(Q){if(J=Q(J),typeof J!=="string"&&!Buffer.isBuffer(J))throw Error("outputHelp callback must return a string or a Buffer")}if(B.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",$),this._getCommandAndAncestors().forEach((Y)=>Y.emit("afterAllHelp",$))}helpOption(A,Q){if(typeof A==="boolean"){if(A){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(A??"-h, --help",Q??"display help for command"),A||Q)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(A){return this._helpOption=A,this._initOptionGroup(A),this}help(A){this.outputHelp(A);let Q=Number(V$.exitCode??0);if(Q===0&&A&&typeof A!=="function"&&A.error)Q=1;this._exit(Q,"commander.help","(outputHelp)")}addHelpText(A,Q){let B=["beforeAll","before","after","afterAll"];if(!B.includes(A))throw Error(`Unexpected value for position to addHelpText.
|
|
93
93
|
Expecting one of '${B.join("', '")}'`);let $=`${A}Help`;return this.on($,(J)=>{let Y;if(typeof Q==="function")Y=Q({error:J.error,command:J.command});else Y=Q;if(Y)J.write(`${Y}
|
|
94
|
-
`)}),this}_outputHelpIfRequested(A){let Q=this._getHelpOption();if(Q&&A.find(($)=>Q.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function zMA(A){return A.map((Q)=>{if(!Q.startsWith("--inspect"))return Q;let B,$="127.0.0.1",J="9229",Y;if((Y=Q.match(/^(--inspect(-brk)?)$/))!==null)B=Y[1];else if((Y=Q.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Y[1],/^\d+$/.test(Y[3]))J=Y[3];else $=Y[3];else if((Y=Q.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Y[1],$=Y[3],J=Y[4];if(B&&J!=="0")return`${B}=${$}:${parseInt(J)+1}`;return Q})}function i1A(){if(V$.env.NO_COLOR||V$.env.FORCE_COLOR==="0"||V$.env.FORCE_COLOR==="false")return!1;if(V$.env.FORCE_COLOR||V$.env.CLICOLOR_FORCE!==void 0)return!0;return}t3Q.Command=n1A;t3Q.useColor=i1A});var NMA=t(($qQ)=>{var{Argument:CMA}=Em(),{Command:a1A}=IMA(),{CommanderError:QqQ,InvalidArgumentError:OMA}=WP(),{Help:BqQ}=c1A(),{Option:MMA}=d1A();$qQ.program=new a1A;$qQ.createCommand=(A)=>new a1A(A);$qQ.createOption=(A,Q)=>new MMA(A,Q);$qQ.createArgument=(A,Q)=>new CMA(A,Q);$qQ.Command=a1A;$qQ.Option=MMA;$qQ.Argument=CMA;$qQ.Help=BqQ;$qQ.CommanderError=QqQ;$qQ.InvalidArgumentError=OMA;$qQ.InvalidOptionArgumentError=OMA});var z4;var JK=vA(()=>{z4={name:"@capgo/cli",type:"module",version:"8.25.1",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/capgo.git",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs","test:credentials":"bun test/test-credentials.mjs","test:asc-key-protocol":"bun test/test-asc-key-protocol.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:android-service-account-validation":"bun test/test-android-service-account-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:build-needed":"bun test/test-build-needed.mjs","test:ci-prompts":"bun test/test-ci-prompts.mjs","test:ci-secrets":"bun test/test-ci-secrets.mjs","test:android-onboarding-progress":"bun test/test-android-onboarding-progress.mjs","test:onboarding-telemetry":"bun test/test-onboarding-telemetry.mjs","test:v2-event-migration":"bun test/test-v2-event-migration.mjs","test:analytics":"bun test/test-analytics.mjs","test:analytics-error-category":"bun test/test-analytics-error-category.mjs","test:analytics-org-resolver":"bun test/test-analytics-org-resolver.mjs","test:supabase-perf":"bun test/test-supabase-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:mcp-analytics":"bun test/test-mcp-analytics.mjs","test:mcp-instructions":"bun test/test-mcp-instructions.mjs","test:mcp-stdout-guard":"bun test/test-mcp-stdout-guard.mjs","test:mcp-platform-select":"bun test/test-mcp-platform-select.mjs","test:mcp-explain-scopes":"bun test/test-mcp-explain-scopes.mjs","test:mcp-oauth-reopen":"bun test/test-mcp-oauth-reopen.mjs","test:mcp-broker-oauth":"bun test/test-mcp-broker-oauth.mjs","test:mcp-broker-session":"bun test/test-mcp-broker-session.mjs","test:mcp-credentials-manage":"bun test/test-mcp-credentials-manage.mjs","test:mcp-resume-prompt":"bun test/test-mcp-resume-prompt.mjs","test:mcp-build-job":"bun test/test-mcp-build-job.mjs","test:mcp-build-tools":"bun test/test-mcp-build-tools.mjs","test:app-created-source":"bun test/test-app-created-source.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:onboarding-recovery":"bun test/test-onboarding-recovery.mjs","test:onboarding-progress":"bun test/test-onboarding-progress.mjs","test:onboarding-run-targets":"bun test/test-onboarding-run-targets.mjs","test:run-device-command":"bun test/test-run-device-command.mjs","test:init-app-conflict":"bun test/test-init-app-conflict.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:manifest-path-encoding":"bun test/test-manifest-path-encoding.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-flow-contract":"bun test/test-ios-flow-contract.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:platform-flow-contract":"bun test/test-platform-flow-contract.mjs","test:tail-engine-shared":"bun test/test-tail-engine-shared.mjs",test:"bun run build && bun run test:helper-dce && bun run test:version-detection:setup && bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:credentials && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:build-needed && bun run test:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-app-conflict && bun run test:init-guardrails && bun run test:init-replay && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:frame-fit-ios-shared && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-e2e && bun run test:ios-flow-contract && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run test:p8-error && bun run test:ios-tui-routing && bun run test:ios-updater-sync-validation && bun run test:ios-verify-app && bun run test:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && bun run test:android-app-verification && bun run test:android-rename && bun run test:appflow-auth && bun run test:appflow-api-map && bun run test:appflow-validate && bun run test:appflow-flow && bun run test:appflow-gapfill && bun run test:appflow-engine && bun run test:appflow-tail && bun run test:appflow-fetch && bun run test:appflow-sa-decode","test:build-platform-selection":"bun test/test-build-platform-selection.mjs","test:ai-log-capture":"bun test/test-ai-log-capture.mjs","test:ai-analyze-flow":"bun test/test-ai-analyze-flow.mjs","test:cicd-failure-help":"bun test/test-cicd-failure-help.mjs","test:ai-analyze-stream":"bun test/test-ai-analyze-stream.mjs","test:ai-sse-parser":"bun test/test-ai-sse-parser.mjs","test:ai-render-markdown":"bun test/test-ai-render-markdown.mjs","test:ai-onboarding-mode":"bun test/test-ai-onboarding-mode.mjs","test:ai-fit":"bun test/test-ai-fit.mjs","test:platform-layout":"bun test/test-platform-layout.mjs","test:frame-fit":"bun test/run-frame-fit.mjs","test:onboarding-min-size":"bun test/test-onboarding-min-size.mjs","test:min-size-gate":"bun test/test-min-size-gate.mjs","test:shell-size-gate":"bun test/test-shell-size-gate.mjs","test:build-log-sanitize":"bun test/test-build-log-sanitize.mjs","test:build-output-viewport":"bun test/test-build-output-viewport.mjs","test:diff-viewer-viewport":"bun test/test-diff-viewer-viewport.mjs","test:build-complete-exit":"bun test/test-build-complete-exit.mjs","test:ai-stream-markdown":"bun test/test-ai-stream-markdown.mjs","test:support-mailto":"bun test/test-support-mailto.mjs","test:support-redact":"bun test/test-support-redact.mjs","test:support-internal-log":"bun test/test-support-internal-log.mjs","test:support-help-menu":"bun test/test-support-help-menu.mjs","test:support-contact":"bun test/test-support-contact.mjs","test:support-upload-prompt":"bun test/test-support-upload-prompt.mjs","test:support-bundle-files":"bun test/test-support-bundle-files.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.mjs","test:app-set-options":"bun test/test-app-set-options.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-app-verification":"bun test/test-android-app-verification.mjs","test:android-rename":"bun test/test-android-rename.mjs","test:appflow-auth":"bun test/test-appflow-auth.mjs","test:appflow-api-map":"bun test/test-appflow-api-map.mjs","test:appflow-validate":"bun test/test-appflow-validate.mjs","test:appflow-flow":"bun test/test-appflow-flow.mjs","test:appflow-gapfill":"bun test/test-appflow-gapfill.mjs","test:appflow-engine":"bun test/test-appflow-engine.mjs","test:appflow-tail":"bun test/test-appflow-tail.mjs","test:appflow-fetch":"bun test/test-appflow-fetch.mjs","test:appflow-sa-decode":"bun test/test-appflow-sa-decode.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@rrweb/types":"^2.0.1","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","happy-dom":"^20.10.4",ink:"^7.0.4","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.6","rrweb-snapshot":"^2.0.1","string-width":"^8.2.1"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1","node-pty":"^1.1.0"},devDependencies:{"@antfu/eslint-config":"^9.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.3.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.4.0","@modelcontextprotocol/sdk":"^1.29.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.106.2","@tanstack/intent":"^0.0.41","@types/adm-zip":"^0.5.8","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.9.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.15","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native-preview":"7.0.0-dev.20260526.1","@vercel/ncc":"^0.38.4","@xterm/headless":"^6.0.0","adm-zip":"^0.5.17","ci-info":"^4.4.0",commander:"^14.0.3",eslint:"^10.4.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.1",micromatch:"^4.0.8",open:"^11.0.0",oxlint:"^1.67.0",partysocket:"^1.1.19",prettyjson:"^1.2.5",tmp:"^0.2.6","tus-js-client":"^4.3.1",typescript:"^6.0.3",ws:"^8.21.0",zod:"^4.4.3"}}});function zqQ(A){if(A&&typeof A==="object"&&"status"in A){let Q=A.status;if(typeof Q==="number")return Q}return}function IqQ(A){if(A instanceof Error)return A.message;if(typeof A==="string")return A;return""}function ZP(A){if(A&&typeof A==="object"&&"code"in A){let $=A.code;if(typeof $==="string"&&$.startsWith("commander."))return"commander"}let Q=zqQ(A);if(Q!==void 0){if(Q===401)return"unauthorized";if(Q===403)return"forbidden";if(Q===404)return"not_found";if(Q===413)return"payload_too_large";if(Q>=500)return"server_error"}let B=IqQ(A).toLowerCase();if(/econnrefused|enotfound|fetch failed|network|socket|dns/.test(B))return"network_error";if(/timed out|timeout|etimedout|aborted/.test(B))return"timeout";if(/invalid|must be|required|not allowed|malformed|validation/.test(B))return"validation_error";return"unknown"}function VMA(A){if(A===401)return"unauthorized";if(A===403)return"forbidden";if(A===404)return"not_found";if(A===408||A===504)return"timeout";if(A===413)return"payload_too_large";if(A===429)return"rate_limited";if(A===400||A===422)return"validation_error";if(A>=500)return"server_error";return"unknown"}import{AsyncLocalStorage as OqQ}from"node:async_hooks";function HP(A,Q){return jMA.run(A,()=>Promise.resolve(Q()))}function MqQ(){return jMA.getStore()}function qP(){wMA=!0}function _MA(){return wMA}function TMA(A){PMA=A}function RMA(A){try{PMA?.(A)}catch{}}function SMA(A,Q){let B;try{B=new URL(A).pathname}catch{B=A.split("?")[0]}let $="/functions/v1/",J=B.indexOf($);if(J>=0){let W=B.slice(J+$.length).replace(/^\/+|\/+$/g,"");return W?`${Q} functions:${W}`:`${Q} functions`}let Y="/rest/v1/",X=B.indexOf(Y),G=X>=0?B.slice(X+Y.length):B.replace(/^\//,"");if(G.startsWith("rpc/"))return`rpc:${G.slice(4).split("/")[0]}`;let K=G.split("/")[0]||B;return`${Q} ${K}`}function NqQ(A){let Q=A?.headers;if(!Q)return;let B=Q.get;if(typeof B==="function")return B.call(Q,"capgkey")??void 0;if(Array.isArray(Q))return Q.find(([$])=>$.toLowerCase()==="capgkey")?.[1];return Q.capgkey}function xMA(){return async(Q,B)=>{let $=(B?.method??"GET").toUpperCase(),J=typeof Q==="string"?Q:Q instanceof URL?Q.href:Q.url,Y=MqQ(),X=NqQ(B),G=Date.now();try{let K=await globalThis.fetch(Q,B);return RMA({url:J,method:$,status:K.status,ok:K.ok,durationMs:Date.now()-G,source:Y,apikey:X}),K}catch(K){throw RMA({url:J,method:$,status:0,ok:!1,durationMs:Date.now()-G,source:Y,apikey:X,error:K}),K}}}var jMA,wMA=!1,PMA,kMA=5000;var DP=vA(()=>{jMA=new OqQ});import{homedir as bMA,platform as LqQ,release as VqQ}from"node:os";import{arch as EqQ,cwd as fMA,env as sI,version as RqQ}from"node:process";function kW(A){return A==="1"||A?.toLowerCase()==="true"||A?.toLowerCase()==="yes"}function PqQ(){if(kW(sI.CAPGO_DISABLE_TELEMETRY)||kW(sI.CAPGO_DISABLE_POSTHOG))return;return sI.CAPGO_CLI_POSTHOG_API_KEY?.trim()||sI.POSTHOG_API_KEY?.trim()||wqQ}function TqQ(A){let Q=A.replace(/\/+$/,"");if(Q.endsWith("/i/v0/e"))return`${Q}/`;let B=Q.replace(/\/capture$/,"/");return new URL("i/v0/e/",B.endsWith("/")?B:`${B}/`).toString()}function kqQ(A){if(A instanceof Error)return{cause:A.cause,message:A.message,name:A.name||"Error",stack:A.stack};if(typeof A==="string")return{message:A,name:"Error",stack:void 0};try{return{message:JSON.stringify(A)??String(A),name:"Error",stack:void 0}}catch{return{message:String(A),name:"Error",stack:void 0}}}function SqQ(A){let Q=A,B=fMA(),$=bMA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q}function xqQ(A){let Q=A,B=fMA(),$=bMA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q.replace(/<cwd>\/[^\s"',)]+/g,"<cwd>/<path>").replace(/~\/[^\s"',)]+/g,"~/<path>").replace(/[\w.%+-]+@[\w.-]+\.[A-Z]{2,}/gi,"<email>").replace(/(https?:\/\/)([^/\s:@]+):([^/\s@]+)@/gi,"$1<redacted>@").replace(/\b[a-z][\w-]*(?:\.[\w-]+){2,}\b/gi,"<app_id>").replace(/\b[a-z]:\\[^\s"',)]+/gi,"<path>").replace(/(^|[\s"'(])\/[^\s"',)]+/g,"$1<path>").replace(/(--(?:token|api[-_]?key|key|password|secret|private[-_]?key|jwt|session|auth)(?:=|\s+))("[^"]+"|'[^']+'|\S+)/gi,"$1<redacted>").replace(/\b((?:token|api[-_]?key|password|secret|authorization)\s*[:=]\s*)[^\s,;]+/gi,"$1<redacted>")}function bqQ(A,Q){let B=A?.split(`
|
|
94
|
+
`)}),this}_outputHelpIfRequested(A){let Q=this._getHelpOption();if(Q&&A.find(($)=>Q.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function zMA(A){return A.map((Q)=>{if(!Q.startsWith("--inspect"))return Q;let B,$="127.0.0.1",J="9229",Y;if((Y=Q.match(/^(--inspect(-brk)?)$/))!==null)B=Y[1];else if((Y=Q.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Y[1],/^\d+$/.test(Y[3]))J=Y[3];else $=Y[3];else if((Y=Q.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Y[1],$=Y[3],J=Y[4];if(B&&J!=="0")return`${B}=${$}:${parseInt(J)+1}`;return Q})}function i1A(){if(V$.env.NO_COLOR||V$.env.FORCE_COLOR==="0"||V$.env.FORCE_COLOR==="false")return!1;if(V$.env.FORCE_COLOR||V$.env.CLICOLOR_FORCE!==void 0)return!0;return}t3Q.Command=n1A;t3Q.useColor=i1A});var NMA=t(($qQ)=>{var{Argument:CMA}=Em(),{Command:a1A}=IMA(),{CommanderError:QqQ,InvalidArgumentError:OMA}=WP(),{Help:BqQ}=c1A(),{Option:MMA}=d1A();$qQ.program=new a1A;$qQ.createCommand=(A)=>new a1A(A);$qQ.createOption=(A,Q)=>new MMA(A,Q);$qQ.createArgument=(A,Q)=>new CMA(A,Q);$qQ.Command=a1A;$qQ.Option=MMA;$qQ.Argument=CMA;$qQ.Help=BqQ;$qQ.CommanderError=QqQ;$qQ.InvalidArgumentError=OMA;$qQ.InvalidOptionArgumentError=OMA});var z4;var JK=vA(()=>{z4={name:"@capgo/cli",type:"module",version:"8.25.2",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/capgo.git",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs","test:credentials":"bun test/test-credentials.mjs","test:asc-key-protocol":"bun test/test-asc-key-protocol.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:android-service-account-validation":"bun test/test-android-service-account-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:build-needed":"bun test/test-build-needed.mjs","test:ci-prompts":"bun test/test-ci-prompts.mjs","test:ci-secrets":"bun test/test-ci-secrets.mjs","test:android-onboarding-progress":"bun test/test-android-onboarding-progress.mjs","test:onboarding-telemetry":"bun test/test-onboarding-telemetry.mjs","test:v2-event-migration":"bun test/test-v2-event-migration.mjs","test:analytics":"bun test/test-analytics.mjs","test:analytics-error-category":"bun test/test-analytics-error-category.mjs","test:analytics-org-resolver":"bun test/test-analytics-org-resolver.mjs","test:supabase-perf":"bun test/test-supabase-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:mcp-analytics":"bun test/test-mcp-analytics.mjs","test:mcp-instructions":"bun test/test-mcp-instructions.mjs","test:mcp-stdout-guard":"bun test/test-mcp-stdout-guard.mjs","test:mcp-platform-select":"bun test/test-mcp-platform-select.mjs","test:mcp-explain-scopes":"bun test/test-mcp-explain-scopes.mjs","test:mcp-oauth-reopen":"bun test/test-mcp-oauth-reopen.mjs","test:mcp-broker-oauth":"bun test/test-mcp-broker-oauth.mjs","test:mcp-broker-session":"bun test/test-mcp-broker-session.mjs","test:mcp-credentials-manage":"bun test/test-mcp-credentials-manage.mjs","test:mcp-resume-prompt":"bun test/test-mcp-resume-prompt.mjs","test:mcp-build-job":"bun test/test-mcp-build-job.mjs","test:mcp-build-tools":"bun test/test-mcp-build-tools.mjs","test:app-created-source":"bun test/test-app-created-source.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:onboarding-recovery":"bun test/test-onboarding-recovery.mjs","test:onboarding-progress":"bun test/test-onboarding-progress.mjs","test:onboarding-run-targets":"bun test/test-onboarding-run-targets.mjs","test:run-device-command":"bun test/test-run-device-command.mjs","test:init-app-conflict":"bun test/test-init-app-conflict.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:manifest-path-encoding":"bun test/test-manifest-path-encoding.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-flow-contract":"bun test/test-ios-flow-contract.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:platform-flow-contract":"bun test/test-platform-flow-contract.mjs","test:tail-engine-shared":"bun test/test-tail-engine-shared.mjs",test:"bun run build && bun run test:helper-dce && bun run test:version-detection:setup && bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:credentials && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:build-needed && bun run test:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-app-conflict && bun run test:init-guardrails && bun run test:init-replay && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:frame-fit-ios-shared && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-e2e && bun run test:ios-flow-contract && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run test:p8-error && bun run test:ios-tui-routing && bun run test:ios-updater-sync-validation && bun run test:ios-verify-app && bun run test:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && bun run test:android-app-verification && bun run test:android-rename && bun run test:appflow-auth && bun run test:appflow-api-map && bun run test:appflow-validate && bun run test:appflow-flow && bun run test:appflow-gapfill && bun run test:appflow-engine && bun run test:appflow-tail && bun run test:appflow-fetch && bun run test:appflow-sa-decode","test:build-platform-selection":"bun test/test-build-platform-selection.mjs","test:ai-log-capture":"bun test/test-ai-log-capture.mjs","test:ai-analyze-flow":"bun test/test-ai-analyze-flow.mjs","test:cicd-failure-help":"bun test/test-cicd-failure-help.mjs","test:ai-analyze-stream":"bun test/test-ai-analyze-stream.mjs","test:ai-sse-parser":"bun test/test-ai-sse-parser.mjs","test:ai-render-markdown":"bun test/test-ai-render-markdown.mjs","test:ai-onboarding-mode":"bun test/test-ai-onboarding-mode.mjs","test:ai-fit":"bun test/test-ai-fit.mjs","test:platform-layout":"bun test/test-platform-layout.mjs","test:frame-fit":"bun test/run-frame-fit.mjs","test:onboarding-min-size":"bun test/test-onboarding-min-size.mjs","test:min-size-gate":"bun test/test-min-size-gate.mjs","test:shell-size-gate":"bun test/test-shell-size-gate.mjs","test:build-log-sanitize":"bun test/test-build-log-sanitize.mjs","test:build-output-viewport":"bun test/test-build-output-viewport.mjs","test:diff-viewer-viewport":"bun test/test-diff-viewer-viewport.mjs","test:build-complete-exit":"bun test/test-build-complete-exit.mjs","test:ai-stream-markdown":"bun test/test-ai-stream-markdown.mjs","test:support-mailto":"bun test/test-support-mailto.mjs","test:support-redact":"bun test/test-support-redact.mjs","test:support-internal-log":"bun test/test-support-internal-log.mjs","test:support-help-menu":"bun test/test-support-help-menu.mjs","test:support-contact":"bun test/test-support-contact.mjs","test:support-upload-prompt":"bun test/test-support-upload-prompt.mjs","test:support-bundle-files":"bun test/test-support-bundle-files.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.mjs","test:app-set-options":"bun test/test-app-set-options.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-app-verification":"bun test/test-android-app-verification.mjs","test:android-rename":"bun test/test-android-rename.mjs","test:appflow-auth":"bun test/test-appflow-auth.mjs","test:appflow-api-map":"bun test/test-appflow-api-map.mjs","test:appflow-validate":"bun test/test-appflow-validate.mjs","test:appflow-flow":"bun test/test-appflow-flow.mjs","test:appflow-gapfill":"bun test/test-appflow-gapfill.mjs","test:appflow-engine":"bun test/test-appflow-engine.mjs","test:appflow-tail":"bun test/test-appflow-tail.mjs","test:appflow-fetch":"bun test/test-appflow-fetch.mjs","test:appflow-sa-decode":"bun test/test-appflow-sa-decode.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@rrweb/types":"^2.0.1","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","happy-dom":"^20.10.4",ink:"^7.0.4","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.6","rrweb-snapshot":"^2.0.1","string-width":"^8.2.1"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1","node-pty":"^1.1.0"},devDependencies:{"@antfu/eslint-config":"^9.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.3.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.4.0","@modelcontextprotocol/sdk":"^1.29.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.106.2","@tanstack/intent":"^0.0.41","@types/adm-zip":"^0.5.8","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.9.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.15","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native-preview":"7.0.0-dev.20260526.1","@vercel/ncc":"^0.38.4","@xterm/headless":"^6.0.0","adm-zip":"^0.5.17","ci-info":"^4.4.0",commander:"^14.0.3",eslint:"^10.4.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.1",micromatch:"^4.0.8",open:"^11.0.0",oxlint:"^1.67.0",partysocket:"^1.1.19",prettyjson:"^1.2.5",tmp:"^0.2.6","tus-js-client":"^4.3.1",typescript:"^6.0.3",ws:"^8.21.0",zod:"^4.4.3"}}});function zqQ(A){if(A&&typeof A==="object"&&"status"in A){let Q=A.status;if(typeof Q==="number")return Q}return}function IqQ(A){if(A instanceof Error)return A.message;if(typeof A==="string")return A;return""}function ZP(A){if(A&&typeof A==="object"&&"code"in A){let $=A.code;if(typeof $==="string"&&$.startsWith("commander."))return"commander"}let Q=zqQ(A);if(Q!==void 0){if(Q===401)return"unauthorized";if(Q===403)return"forbidden";if(Q===404)return"not_found";if(Q===413)return"payload_too_large";if(Q>=500)return"server_error"}let B=IqQ(A).toLowerCase();if(/econnrefused|enotfound|fetch failed|network|socket|dns/.test(B))return"network_error";if(/timed out|timeout|etimedout|aborted/.test(B))return"timeout";if(/invalid|must be|required|not allowed|malformed|validation/.test(B))return"validation_error";return"unknown"}function VMA(A){if(A===401)return"unauthorized";if(A===403)return"forbidden";if(A===404)return"not_found";if(A===408||A===504)return"timeout";if(A===413)return"payload_too_large";if(A===429)return"rate_limited";if(A===400||A===422)return"validation_error";if(A>=500)return"server_error";return"unknown"}import{AsyncLocalStorage as OqQ}from"node:async_hooks";function HP(A,Q){return jMA.run(A,()=>Promise.resolve(Q()))}function MqQ(){return jMA.getStore()}function qP(){wMA=!0}function _MA(){return wMA}function TMA(A){PMA=A}function RMA(A){try{PMA?.(A)}catch{}}function SMA(A,Q){let B;try{B=new URL(A).pathname}catch{B=A.split("?")[0]}let $="/functions/v1/",J=B.indexOf($);if(J>=0){let W=B.slice(J+$.length).replace(/^\/+|\/+$/g,"");return W?`${Q} functions:${W}`:`${Q} functions`}let Y="/rest/v1/",X=B.indexOf(Y),G=X>=0?B.slice(X+Y.length):B.replace(/^\//,"");if(G.startsWith("rpc/"))return`rpc:${G.slice(4).split("/")[0]}`;let K=G.split("/")[0]||B;return`${Q} ${K}`}function NqQ(A){let Q=A?.headers;if(!Q)return;let B=Q.get;if(typeof B==="function")return B.call(Q,"capgkey")??void 0;if(Array.isArray(Q))return Q.find(([$])=>$.toLowerCase()==="capgkey")?.[1];return Q.capgkey}function xMA(){return async(Q,B)=>{let $=(B?.method??"GET").toUpperCase(),J=typeof Q==="string"?Q:Q instanceof URL?Q.href:Q.url,Y=MqQ(),X=NqQ(B),G=Date.now();try{let K=await globalThis.fetch(Q,B);return RMA({url:J,method:$,status:K.status,ok:K.ok,durationMs:Date.now()-G,source:Y,apikey:X}),K}catch(K){throw RMA({url:J,method:$,status:0,ok:!1,durationMs:Date.now()-G,source:Y,apikey:X,error:K}),K}}}var jMA,wMA=!1,PMA,kMA=5000;var DP=vA(()=>{jMA=new OqQ});import{homedir as bMA,platform as LqQ,release as VqQ}from"node:os";import{arch as EqQ,cwd as fMA,env as sI,version as RqQ}from"node:process";function kW(A){return A==="1"||A?.toLowerCase()==="true"||A?.toLowerCase()==="yes"}function PqQ(){if(kW(sI.CAPGO_DISABLE_TELEMETRY)||kW(sI.CAPGO_DISABLE_POSTHOG))return;return sI.CAPGO_CLI_POSTHOG_API_KEY?.trim()||sI.POSTHOG_API_KEY?.trim()||wqQ}function TqQ(A){let Q=A.replace(/\/+$/,"");if(Q.endsWith("/i/v0/e"))return`${Q}/`;let B=Q.replace(/\/capture$/,"/");return new URL("i/v0/e/",B.endsWith("/")?B:`${B}/`).toString()}function kqQ(A){if(A instanceof Error)return{cause:A.cause,message:A.message,name:A.name||"Error",stack:A.stack};if(typeof A==="string")return{message:A,name:"Error",stack:void 0};try{return{message:JSON.stringify(A)??String(A),name:"Error",stack:void 0}}catch{return{message:String(A),name:"Error",stack:void 0}}}function SqQ(A){let Q=A,B=fMA(),$=bMA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q}function xqQ(A){let Q=A,B=fMA(),$=bMA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q.replace(/<cwd>\/[^\s"',)]+/g,"<cwd>/<path>").replace(/~\/[^\s"',)]+/g,"~/<path>").replace(/[\w.%+-]+@[\w.-]+\.[A-Z]{2,}/gi,"<email>").replace(/(https?:\/\/)([^/\s:@]+):([^/\s@]+)@/gi,"$1<redacted>@").replace(/\b[a-z][\w-]*(?:\.[\w-]+){2,}\b/gi,"<app_id>").replace(/\b[a-z]:\\[^\s"',)]+/gi,"<path>").replace(/(^|[\s"'(])\/[^\s"',)]+/g,"$1<path>").replace(/(--(?:token|api[-_]?key|key|password|secret|private[-_]?key|jwt|session|auth)(?:=|\s+))("[^"]+"|'[^']+'|\S+)/gi,"$1<redacted>").replace(/\b((?:token|api[-_]?key|password|secret|authorization)\s*[:=]\s*)[^\s,;]+/gi,"$1<redacted>")}function bqQ(A,Q){let B=A?.split(`
|
|
95
95
|
`).slice(1).map(($)=>{let J=$.trim(),Y=J.startsWith("at ")?J.slice(3):J,X=Q,G=Y,K=Y.lastIndexOf(" (");if(K!==-1&&Y.endsWith(")"))X=Y.slice(0,K).trim()||Q,G=Y.slice(K+2,-1);else{let D=Y.lastIndexOf(" "),F=D===-1?"":Y.slice(D+1);if(/:\d+:\d+$/.test(F))X=Y.slice(0,D).trim()||Q,G=F}let W=G.lastIndexOf(":"),H=W===-1?-1:G.lastIndexOf(":",W-1);if(W===-1||H===-1)return{function:Q,platform:"custom",lang:"javascript"};return{function:X,filename:SqQ(G.slice(0,H)),lineno:Number.parseInt(G.slice(H+1,W),10),colno:Number.parseInt(G.slice(W+1),10),platform:"custom",lang:"javascript"}}).filter(Boolean);return B&&B.length>0?B:[{function:Q,platform:"custom",lang:"javascript"}]}function fqQ(A){if(!A||typeof A!=="object"||!("code"in A))return;let{code:Q}=A;return typeof Q==="string"?Q:void 0}function vMA(A){return!fqQ(A)?.startsWith("commander.")}function o1A(A){let Q=[],B=A;while(B?.parent){let $=B.name();if($)Q.push($);B=B.parent}return Q.reverse().join(" ")||"unknown"}async function r1A(A){let Q=PqQ();if(!Q)return!1;let B=sI.CAPGO_CLI_POSTHOG_API_HOST?.trim()||sI.POSTHOG_API_HOST?.trim()||jqQ,$;try{$=TqQ(B)}catch{return!1}let J=kqQ(A.error),Y=xqQ(J.message),X=`cli:${z4.version}:${A.functionName}`,G=bqQ(J.stack,A.functionName),K=G[0],W=[X,A.kind,J.name||"Error",K?.function||A.functionName,K&&"filename"in K?K.filename:"unknown",String(A.status??1)].join(":"),H={token:Q,event:"$exception",properties:{distinct_id:X,$exception_list:[{type:J.name||"Error",value:Y,mechanism:{handled:!0,synthetic:!1},stacktrace:{type:"raw",frames:G}}],$exception_fingerprint:W,architecture:EqQ,cli_version:z4.version,error_kind:A.kind,function_name:A.functionName,is_ci:Boolean(sI.CI),node_version:RqQ,os_platform:LqQ(),os_release:VqQ(),runtime:"cli",status:A.status},timestamp:new Date().toISOString()};try{let D=new AbortController,F=setTimeout(()=>D.abort(),_qQ);try{return(await fetch($,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H),signal:D.signal})).ok}finally{clearTimeout(F)}}catch{return!1}}var jqQ="https://eu.i.posthog.com/i/v0/e/",wqQ="phc_NXDyDajQaTQVwb25DEhIVZfxVUn4R0Y348Z7vWYHZUi",_qQ=1500;var FP=vA(()=>{JK()});import{existsSync as $X}from"fs";var C2=(A=".",Q="unknown")=>{let B=`${A}/bun.lockb`,$=`${A}/bun.lock`,J=`${A}/pnpm-lock.yaml`,Y=`${A}/shrinkwrap.yaml`,X=`${A}/yarn.lock`,G=`${A}/package-lock.json`,K=`${A}/npm-shrinkwrap.json`;if($X(B)||$X($))return"bun";if($X(J)||$X(Y))return"pnpm";if($X(X))return"yarn";if($X(G)||$X(K))return"npm";return Q},wm=(A=C2(),Q=!1)=>{switch(A){case"bun":return Q?"bun install":"install";case"pnpm":return Q?"pnpm install":"install";case"yarn":return Q?"yarn install":"install";case"npm":return Q?"npm install":"install";case"unknown":return Q?"unknown unknown":"unknown";default:return Q?"npm install":"install"}},gMA=(A=".",Q="npx")=>{let B=`${A}/bun.lockb`,$=`${A}/bun.lock`,J=`${A}/pnpm-lock.yaml`,Y=`${A}/shrinkwrap.yaml`,X=`${A}/yarn.lock`,G=`${A}/package-lock.json`,K=`${A}/npm-shrinkwrap.json`;if($X(B)||$X($))return"bunx";if($X(J)||$X(Y))return"pnpm exec";if($X(X))return"yarn dlx";if($X(G)||$X(K))return"npx";return Q};var s1A=()=>{};function _m(A,Q){if(isNaN(A)||isNaN(Q))throw Error("Cannot compare against non-numbers");return A===Q?0:A<Q?-1:1}function uMA(A=[],Q=[]){if(A.length&&!Q.length)return-1;if(!A.length&&Q.length)return 1;return 0}function Pm(A=[],Q=[]){let B=Math.max(A.length,Q.length);for(let $=0;$<B;$++){let J=A[$],Y=Q[$];if(J===void 0&&Y===void 0)return 0;if(Y===void 0)return 1;if(J===void 0)return-1;if(typeof J==="string"&&typeof Y==="number")return 1;if(typeof J==="number"&&typeof Y==="string")return-1;if(J<Y)return-1;if(J>Y)return 1}return 0}function e1A(A){return typeof A==="number"&&!Number.isNaN(A)&&(!Number.isFinite(A)||0<=A&&A<=Number.MAX_SAFE_INTEGER)}function JX(A){return A.split(".").filter(Boolean).map((Q)=>{if(hqQ.test(Q)){let B=Number(Q);if(e1A(B))return B}return Q})}function KH(A){return A.split(".").filter(Boolean)}function km(A,Q){let B=Number(A);if(!e1A(B))throw TypeError(Q);return B}function kq(A){return Number.isNaN(A.major)&&Number.isNaN(A.minor)&&Number.isNaN(A.patch)&&(A.prerelease===void 0||A.prerelease.length===0)&&(A.build===void 0||A.build.length===0)}var DL="0|[1-9]\\d*",vqQ="\\d*[a-zA-Z-][a-zA-Z0-9-]*",gqQ,yMA,mMA,hMA="[0-9A-Za-z-]+",cMA,dMA,lMA,pMA="(?:<|>)?=?",yqQ="x|X|\\*",t1A,Tm,iMA,nMA,A8A=256,hqQ;var KG=vA(()=>{gqQ=`(?<major>${DL})\\.(?<minor>${DL})\\.(?<patch>${DL})`,yMA=`(?:${DL}|${vqQ})`,mMA=`(?:-(?<prerelease>${yMA}(?:\\.${yMA})*))`,cMA=`(?:\\+(?<buildmetadata>${hMA}(?:\\.${hMA})*))`,dMA=`v?${gqQ}${mMA}?${cMA}?`,lMA=new RegExp(`^${dMA}$`),t1A=`${DL}|${yqQ}`,Tm=`[v=\\s]*(?<major>${t1A})(?:\\.(?<minor>${t1A})(?:\\.(?<patch>${t1A})${mMA}?${cMA}?)?)?`,iMA=new RegExp(`^(?<operator>~>?|\\^|${pMA})\\s*${Tm}$`),nMA=new RegExp(`^(?<operator>${pMA})\\s*(${dMA})$|^$`);hqQ=new RegExp(`^${DL}$`)});function aY(A,Q){if(A===Q)return 0;return _m(A.major,Q.major)||_m(A.minor,Q.minor)||_m(A.patch,Q.patch)||uMA(A.prerelease,Q.prerelease)||Pm(A.prerelease,Q.prerelease)}var YK=vA(()=>{KG()});function aMA(A,Q){let B=A.prerelease?.length||Q.prerelease?.length;if(A.major!==Q.major)return B?"premajor":"major";if(A.minor!==Q.minor)return B?"preminor":"minor";if(A.patch!==Q.patch)return B?"prepatch":"patch";if(Pm(A.prerelease,Q.prerelease)!==0)return"prerelease"}var oMA=vA(()=>{KG()});function Q8A(A){return A.toFixed(0)}function F5(A){let Q=Q8A(A.major),B=Q8A(A.minor),$=Q8A(A.patch),J=A.prerelease?.join(".")??"",Y=A.build?.join(".")??"";return[[`${Q}.${B}.${$}`,J].filter((K)=>K).join("-"),Y].filter((K)=>K).join("+")}function uqQ(A,Q){if(kq(Q))return!0;let B=aY(A,Q);switch(Q.operator){case"=":case void 0:return B===0;case"!=":return B!==0;case">":return B>0;case"<":return B<0;case">=":return B>=0;case"<=":return B<=0}}function Sm(A,Q){for(let B of Q)if(!uqQ(A,B))return!1;if(!A.prerelease?.length)return!0;for(let B of Q){if(kq(B))continue;if(!B.prerelease?.length)continue;let{major:$,minor:J,patch:Y}=B;if(A.major===$&&A.minor===J&&A.patch===Y)return!0}return!1}var xm=vA(()=>{KG();YK()});function UP(A,Q){return Q.some((B)=>Sm(A,B))}var zP=vA(()=>{xm()});function mqQ(A=[]){let Q=[...A],B=Q.length;while(B>=0){let $=Q[B];if(typeof $==="number"){Q[B]=$+1;break}B-=1}if(B===-1)Q.push(0);return Q}function IP(A=[],Q){let B=mqQ(A);if(!Q)return B;let $=JX(Q);if($.every((J)=>typeof J==="string")){if($.every((J,Y)=>J===B[Y])&&typeof B[$.length]==="number")return B;$=[...$,0]}return $}function O2(A,Q,B={}){let $=B.build!==void 0?KH(B.build):A.build??[];switch(Q){case"premajor":return{major:A.major+1,minor:0,patch:0,prerelease:IP(A.prerelease,B.prerelease),build:$};case"preminor":return{major:A.major,minor:A.minor+1,patch:0,prerelease:IP(A.prerelease,B.prerelease),build:$};case"prepatch":return{major:A.major,minor:A.minor,patch:A.patch+1,prerelease:IP(A.prerelease,B.prerelease),build:$};case"prerelease":{let Y=(A.prerelease??[]).length===0?A.patch+1:A.patch;return{major:A.major,minor:A.minor,patch:Y,prerelease:IP(A.prerelease,B.prerelease),build:$}}case"major":return{major:(A.prerelease??[]).length===0||A.minor!==0||A.patch!==0?A.major+1:A.major,minor:0,patch:0,prerelease:[],build:$};case"minor":{let Y=(A.prerelease??[]).length===0||A.patch!==0?A.minor+1:A.minor;return{major:A.major,minor:Y,patch:0,prerelease:[],build:$}}case"patch":{let Y=(A.prerelease??[]).length===0?A.patch+1:A.patch;return{major:A.major,minor:A.minor,patch:Y,prerelease:[],build:$}}case"pre":return{major:A.major,minor:A.minor,patch:A.patch,prerelease:IP(A.prerelease,B.prerelease),build:$};default:throw TypeError(`Cannot increment version: invalid argument ${Q}`)}}var rMA=vA(()=>{KG()});var bm,FL;var CP=vA(()=>{bm={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},FL={operator:void 0,...bm}});var B8A=vA(()=>{CP();KG()});function $8A(A,Q){return aY(A,Q)>0}var J8A=vA(()=>{YK()});var sMA=vA(()=>{zP();J8A()});function WG(A,Q){return aY(A,Q)<0}var Y8A=vA(()=>{YK()});var tMA=vA(()=>{zP();Y8A()});function cqQ(A){let B=A.match(nMA)?.groups;if(!B)return null;let{operator:$}=B;return{operator:$||void 0,...bm}}function P4(A){return!A||A.toLowerCase()==="x"||A==="*"}function dqQ(A){if(P4(A.major))return;if(P4(A.minor))return{operator:">=",major:+A.major,minor:0,patch:0,prerelease:[],build:[]};if(P4(A.patch))return{operator:">=",major:+A.major,minor:+A.minor,patch:0,prerelease:[],build:[]};return{operator:">=",major:+A.major,minor:+A.minor,patch:+A.patch,prerelease:A.prerelease?JX(A.prerelease):[],build:[]}}function lqQ(A){if(P4(A.major))return;if(P4(A.minor))return{operator:"<",major:+A.major+1,minor:0,patch:0,prerelease:[],build:[]};if(P4(A.patch))return{operator:"<",major:+A.major,minor:+A.minor+1,patch:0,prerelease:[],build:[]};if(A.prerelease)return{operator:"<=",major:+A.major,minor:+A.minor,patch:+A.patch,prerelease:JX(A.prerelease),build:[]};return{operator:"<=",major:+A.major,minor:+A.minor,patch:+A.patch,prerelease:[],build:[]}}function pqQ(A){let Q=A.match(new RegExp(`^${Tm}`)),B=Q?.groups;if(!B)return null;let $=Q[0].length,J=A.slice($).match(/^\s+-\s+/);if(!J)return null;let Y=J[0].length,G=A.slice($+Y).match(new RegExp(`^${Tm}\\s*$`))?.groups,K=dqQ(B),W=lqQ(G);return[K,W].filter(Boolean)}function iqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[FL];if(B)return[{operator:">=",major:J,minor:0,patch:0},{operator:"<",major:J+1,minor:0,patch:0}];if($){if(J===0)return[{operator:">=",major:J,minor:Y,patch:0},{operator:"<",major:J,minor:Y+1,patch:0}];return[{operator:">=",major:J,minor:Y,patch:0},{operator:"<",major:J+1,minor:0,patch:0}]}let G=JX(A.prerelease??"");if(J===0){if(Y===0)return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G},{operator:"<",major:J,minor:Y,patch:X+1}];return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G},{operator:"<",major:J,minor:Y+1,patch:0}]}return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G},{operator:"<",major:J+1,minor:0,patch:0}]}function nqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[FL];if(B)return[{operator:">=",major:J,minor:0,patch:0},{operator:"<",major:J+1,minor:0,patch:0}];if($)return[{operator:">=",major:J,minor:Y,patch:0},{operator:"<",major:J,minor:Y+1,patch:0}];let G=JX(A.prerelease??"");return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G},{operator:"<",major:J,minor:Y+1,patch:0}]}function aqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[{operator:"<",major:0,minor:0,patch:0}];if(B){if($)return[{operator:"<",major:J,minor:0,patch:0}];return[{operator:"<",major:J,minor:0,patch:0}]}if($)return[{operator:"<",major:J,minor:Y,patch:0}];let G=JX(A.prerelease??""),K=KH(A.build??"");return[{operator:"<",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function oqQ(A){let Q=P4(A.minor),B=P4(A.patch),$=+A.major,J=+A.minor,Y=+A.patch;if(Q)return[{operator:"<",major:$+1,minor:0,patch:0}];if(B)return[{operator:"<",major:$,minor:J+1,patch:0}];let X=JX(A.prerelease??""),G=KH(A.build??"");return[{operator:"<=",major:$,minor:J,patch:Y,prerelease:X,build:G}]}function rqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[{operator:"<",major:0,minor:0,patch:0}];if(B)return[{operator:">=",major:J+1,minor:0,patch:0}];if($)return[{operator:">=",major:J,minor:Y+1,patch:0}];let G=JX(A.prerelease??""),K=KH(A.build??"");return[{operator:">",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function sqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[FL];if(B)return[{operator:">=",major:J,minor:0,patch:0}];if($)return[{operator:">=",major:J,minor:Y,patch:0}];let G=JX(A.prerelease??""),K=KH(A.build??"");return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function tqQ(A){let Q=P4(A.major),B=P4(A.minor),$=P4(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[FL];if(B)return[{operator:">=",major:J,minor:0,patch:0},{operator:"<",major:J+1,minor:0,patch:0}];if($)return[{operator:">=",major:J,minor:Y,patch:0},{operator:"<",major:J,minor:Y+1,patch:0}];let G=JX(A.prerelease??""),K=KH(A.build??"");return[{operator:A.operator==="="?"=":void 0,major:J,minor:Y,patch:X,prerelease:G,build:K}]}function eqQ(A){let Q=A.match(iMA)?.groups;if(!Q)return cqQ(A);switch(Q.operator){case"^":return iqQ(Q);case"~":case"~>":return nqQ(Q);case"<":return aqQ(Q);case"<=":return oqQ(Q);case">":return rqQ(Q);case">=":return sqQ(Q);default:return tqQ(Q)}}function ADQ(A){return A.split(/\s+/).flatMap(eqQ)}function fm(A){let Q=A.replaceAll(/(?<=[<>=~^])(\s+)/g,"").split(/\s*\|\|\s*/).map((B)=>pqQ(B)||ADQ(B));if(Q.some((B)=>B.includes(null)))throw TypeError(`Cannot parse version range: range "${A}" is invalid`);return Q}var X8A=vA(()=>{KG();CP()});function X1(A){if(typeof A!=="string")throw TypeError(`Cannot parse version as version must be a string: received ${typeof A}`);if(A.length>A8A)throw TypeError(`Cannot parse version as version length is too long: length is ${A.length}, max length is ${A8A}`);A=A.trim();let Q=A.match(lMA)?.groups;if(!Q)throw TypeError(`Cannot parse version: ${A}`);let B=km(Q.major,`Cannot parse version ${A}: invalid major version`),$=km(Q.minor,`Cannot parse version ${A}: invalid minor version`),J=km(Q.patch,`Cannot parse version ${A}: invalid patch version`),Y=Q.prerelease?JX(Q.prerelease):[],X=Q.buildmetadata?KH(Q.buildmetadata):[];return{major:B,minor:$,patch:J,prerelease:Y,build:X}}var vm=vA(()=>{KG();KG()});function eMA(A,Q){let B=A.operator,$=Q.operator;if(B===void 0){if(kq(A))return!0;return UP(A,[[Q]])}if($===void 0){if(kq(Q))return!0;return UP(Q,[[A]])}let J=aY(A,Q);return(B===">="||B===">")&&($===">="||$===">")||(B==="<="||B==="<")&&($==="<="||$==="<")||J===0&&((B===">="||B==="<=")&&($===">="||$==="<="))||J===-1&&(B===">="||B===">")&&($==="<="||$==="<")||J===1&&(B==="<="||B==="<")&&($===">="||$===">")}function QDQ(A){return A.every((Q)=>{return Q.some((B)=>BDQ(B))})}function BDQ(A){for(let Q=0;Q<A.length-1;Q++){let B=A[Q];for(let $ of A.slice(Q+1))if(!eMA(B,$))return!1}return!0}function ANA(A,Q){return QDQ([A,Q])&&A.some((B)=>{return Q.some(($)=>{return B.every((J)=>{return $.every((Y)=>eMA(J,Y))})})})}var QNA=vA(()=>{KG();YK();zP()});var BNA=vA(()=>{X8A()});var $NA=vA(()=>{CP();CP();B8A()});function OP(A){try{return X1(A),!0}catch{return!1}}var JNA=vA(()=>{vm()});var YNA=vA(()=>{vm()});var XNA=vA(()=>{KG()});var GNA=vA(()=>{YK()});var KNA=vA(()=>{YK()});var WNA=vA(()=>{xm();KG();YK()});function G8A(A,Q){return aY(A,Q)>=0}var ZNA=vA(()=>{YK()});var HNA=vA(()=>{xm();KG();YK()});var qNA=vA(()=>{YK()});var SW=vA(()=>{YK();oMA();zP();rMA();B8A();sMA();tMA();X8A();vm();QNA();BNA();$NA();JNA();YNA();XNA();GNA();KNA();J8A();WNA();ZNA();Y8A();HNA();qNA()});var YX=t((Ew0,hm)=>{var DNA,FNA,UNA,zNA,INA,CNA,ONA,MNA,NNA,LNA,VNA,ENA,RNA,gm,K8A,jNA,wNA,_NA,UL,PNA,TNA,kNA,SNA,xNA,bNA,fNA,vNA,gNA,ym,yNA,hNA,uNA;(function(A){var Q=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd)define("tslib",["exports"],function($){A(B(Q,B($)))});else if(typeof hm==="object"&&typeof Ew0==="object")A(B(Q,B(Ew0)));else A(B(Q));function B($,J){if($!==Q)if(typeof Object.create==="function")Object.defineProperty($,"__esModule",{value:!0});else $.__esModule=!0;return function(Y,X){return $[Y]=J?J(Y,X):X}}})(function(A){var Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Y,X){Y.__proto__=X}||function(Y,X){for(var G in X)if(Object.prototype.hasOwnProperty.call(X,G))Y[G]=X[G]};DNA=function(Y,X){if(typeof X!=="function"&&X!==null)throw TypeError("Class extends value "+String(X)+" is not a constructor or null");Q(Y,X);function G(){this.constructor=Y}Y.prototype=X===null?Object.create(X):(G.prototype=X.prototype,new G)},FNA=Object.assign||function(Y){for(var X,G=1,K=arguments.length;G<K;G++){X=arguments[G];for(var W in X)if(Object.prototype.hasOwnProperty.call(X,W))Y[W]=X[W]}return Y},UNA=function(Y,X){var G={};for(var K in Y)if(Object.prototype.hasOwnProperty.call(Y,K)&&X.indexOf(K)<0)G[K]=Y[K];if(Y!=null&&typeof Object.getOwnPropertySymbols==="function"){for(var W=0,K=Object.getOwnPropertySymbols(Y);W<K.length;W++)if(X.indexOf(K[W])<0&&Object.prototype.propertyIsEnumerable.call(Y,K[W]))G[K[W]]=Y[K[W]]}return G},zNA=function(Y,X,G,K){var W=arguments.length,H=W<3?X:K===null?K=Object.getOwnPropertyDescriptor(X,G):K,D;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")H=Reflect.decorate(Y,X,G,K);else for(var F=Y.length-1;F>=0;F--)if(D=Y[F])H=(W<3?D(H):W>3?D(X,G,H):D(X,G))||H;return W>3&&H&&Object.defineProperty(X,G,H),H},INA=function(Y,X){return function(G,K){X(G,K,Y)}},CNA=function(Y,X,G,K,W,H){function D(T){if(T!==void 0&&typeof T!=="function")throw TypeError("Function expected");return T}var F=K.kind,U=F==="getter"?"get":F==="setter"?"set":"value",z=!X&&Y?K.static?Y:Y.prototype:null,I=X||(z?Object.getOwnPropertyDescriptor(z,K.name):{}),O,V=!1;for(var E=G.length-1;E>=0;E--){var M={};for(var N in K)M[N]=N==="access"?{}:K[N];for(var N in K.access)M.access[N]=K.access[N];M.addInitializer=function(T){if(V)throw TypeError("Cannot add initializers after decoration has completed");H.push(D(T||null))};var R=(0,G[E])(F==="accessor"?{get:I.get,set:I.set}:I[U],M);if(F==="accessor"){if(R===void 0)continue;if(R===null||typeof R!=="object")throw TypeError("Object expected");if(O=D(R.get))I.get=O;if(O=D(R.set))I.set=O;if(O=D(R.init))W.unshift(O)}else if(O=D(R))if(F==="field")W.unshift(O);else I[U]=O}if(z)Object.defineProperty(z,K.name,I);V=!0},ONA=function(Y,X,G){var K=arguments.length>2;for(var W=0;W<X.length;W++)G=K?X[W].call(Y,G):X[W].call(Y);return K?G:void 0},MNA=function(Y){return typeof Y==="symbol"?Y:"".concat(Y)},NNA=function(Y,X,G){if(typeof X==="symbol")X=X.description?"[".concat(X.description,"]"):"";return Object.defineProperty(Y,"name",{configurable:!0,value:G?"".concat(G," ",X):X})},LNA=function(Y,X){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,X)},VNA=function(Y,X,G,K){function W(H){return H instanceof G?H:new G(function(D){D(H)})}return new(G||(G=Promise))(function(H,D){function F(I){try{z(K.next(I))}catch(O){D(O)}}function U(I){try{z(K.throw(I))}catch(O){D(O)}}function z(I){I.done?H(I.value):W(I.value).then(F,U)}z((K=K.apply(Y,X||[])).next())})},ENA=function(Y,X){var G={label:0,sent:function(){if(H[0]&1)throw H[1];return H[1]},trys:[],ops:[]},K,W,H,D=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return D.next=F(0),D.throw=F(1),D.return=F(2),typeof Symbol==="function"&&(D[Symbol.iterator]=function(){return this}),D;function F(z){return function(I){return U([z,I])}}function U(z){if(K)throw TypeError("Generator is already executing.");while(D&&(D=0,z[0]&&(G=0)),G)try{if(K=1,W&&(H=z[0]&2?W.return:z[0]?W.throw||((H=W.return)&&H.call(W),0):W.next)&&!(H=H.call(W,z[1])).done)return H;if(W=0,H)z=[z[0]&2,H.value];switch(z[0]){case 0:case 1:H=z;break;case 4:return G.label++,{value:z[1],done:!1};case 5:G.label++,W=z[1],z=[0];continue;case 7:z=G.ops.pop(),G.trys.pop();continue;default:if((H=G.trys,!(H=H.length>0&&H[H.length-1]))&&(z[0]===6||z[0]===2)){G=0;continue}if(z[0]===3&&(!H||z[1]>H[0]&&z[1]<H[3])){G.label=z[1];break}if(z[0]===6&&G.label<H[1]){G.label=H[1],H=z;break}if(H&&G.label<H[2]){G.label=H[2],G.ops.push(z);break}if(H[2])G.ops.pop();G.trys.pop();continue}z=X.call(Y,G)}catch(I){z=[6,I],W=0}finally{K=H=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}},RNA=function(Y,X){for(var G in Y)if(G!=="default"&&!Object.prototype.hasOwnProperty.call(X,G))ym(X,Y,G)},ym=Object.create?function(Y,X,G,K){if(K===void 0)K=G;var W=Object.getOwnPropertyDescriptor(X,G);if(!W||("get"in W?!X.__esModule:W.writable||W.configurable))W={enumerable:!0,get:function(){return X[G]}};Object.defineProperty(Y,K,W)}:function(Y,X,G,K){if(K===void 0)K=G;Y[K]=X[G]},gm=function(Y){var X=typeof Symbol==="function"&&Symbol.iterator,G=X&&Y[X],K=0;if(G)return G.call(Y);if(Y&&typeof Y.length==="number")return{next:function(){if(Y&&K>=Y.length)Y=void 0;return{value:Y&&Y[K++],done:!Y}}};throw TypeError(X?"Object is not iterable.":"Symbol.iterator is not defined.")},K8A=function(Y,X){var G=typeof Symbol==="function"&&Y[Symbol.iterator];if(!G)return Y;var K=G.call(Y),W,H=[],D;try{while((X===void 0||X-- >0)&&!(W=K.next()).done)H.push(W.value)}catch(F){D={error:F}}finally{try{if(W&&!W.done&&(G=K.return))G.call(K)}finally{if(D)throw D.error}}return H},jNA=function(){for(var Y=[],X=0;X<arguments.length;X++)Y=Y.concat(K8A(arguments[X]));return Y},wNA=function(){for(var Y=0,X=0,G=arguments.length;X<G;X++)Y+=arguments[X].length;for(var K=Array(Y),W=0,X=0;X<G;X++)for(var H=arguments[X],D=0,F=H.length;D<F;D++,W++)K[W]=H[D];return K},_NA=function(Y,X,G){if(G||arguments.length===2){for(var K=0,W=X.length,H;K<W;K++)if(H||!(K in X)){if(!H)H=Array.prototype.slice.call(X,0,K);H[K]=X[K]}}return Y.concat(H||Array.prototype.slice.call(X))},UL=function(Y){return this instanceof UL?(this.v=Y,this):new UL(Y)},PNA=function(Y,X,G){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var K=G.apply(Y,X||[]),W,H=[];return W=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),F("next"),F("throw"),F("return",D),W[Symbol.asyncIterator]=function(){return this},W;function D(E){return function(M){return Promise.resolve(M).then(E,O)}}function F(E,M){if(K[E]){if(W[E]=function(N){return new Promise(function(R,T){H.push([E,N,R,T])>1||U(E,N)})},M)W[E]=M(W[E])}}function U(E,M){try{z(K[E](M))}catch(N){V(H[0][3],N)}}function z(E){E.value instanceof UL?Promise.resolve(E.value.v).then(I,O):V(H[0][2],E)}function I(E){U("next",E)}function O(E){U("throw",E)}function V(E,M){if(E(M),H.shift(),H.length)U(H[0][0],H[0][1])}},TNA=function(Y){var X,G;return X={},K("next"),K("throw",function(W){throw W}),K("return"),X[Symbol.iterator]=function(){return this},X;function K(W,H){X[W]=Y[W]?function(D){return(G=!G)?{value:UL(Y[W](D)),done:!1}:H?H(D):D}:H}},kNA=function(Y){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var X=Y[Symbol.asyncIterator],G;return X?X.call(Y):(Y=typeof gm==="function"?gm(Y):Y[Symbol.iterator](),G={},K("next"),K("throw"),K("return"),G[Symbol.asyncIterator]=function(){return this},G);function K(H){G[H]=Y[H]&&function(D){return new Promise(function(F,U){D=Y[H](D),W(F,U,D.done,D.value)})}}function W(H,D,F,U){Promise.resolve(U).then(function(z){H({value:z,done:F})},D)}},SNA=function(Y,X){if(Object.defineProperty)Object.defineProperty(Y,"raw",{value:X});else Y.raw=X;return Y};var B=Object.create?function(Y,X){Object.defineProperty(Y,"default",{enumerable:!0,value:X})}:function(Y,X){Y.default=X},$=function(Y){return $=Object.getOwnPropertyNames||function(X){var G=[];for(var K in X)if(Object.prototype.hasOwnProperty.call(X,K))G[G.length]=K;return G},$(Y)};xNA=function(Y){if(Y&&Y.__esModule)return Y;var X={};if(Y!=null){for(var G=$(Y),K=0;K<G.length;K++)if(G[K]!=="default")ym(X,Y,G[K])}return B(X,Y),X},bNA=function(Y){return Y&&Y.__esModule?Y:{default:Y}},fNA=function(Y,X,G,K){if(G==="a"&&!K)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?Y!==X||!K:!X.has(Y))throw TypeError("Cannot read private member from an object whose class did not declare it");return G==="m"?K:G==="a"?K.call(Y):K?K.value:X.get(Y)},vNA=function(Y,X,G,K,W){if(K==="m")throw TypeError("Private method is not writable");if(K==="a"&&!W)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?Y!==X||!W:!X.has(Y))throw TypeError("Cannot write private member to an object whose class did not declare it");return K==="a"?W.call(Y,G):W?W.value=G:X.set(Y,G),G},gNA=function(Y,X){if(X===null||typeof X!=="object"&&typeof X!=="function")throw TypeError("Cannot use 'in' operator on non-object");return typeof Y==="function"?X===Y:Y.has(X)},yNA=function(Y,X,G){if(X!==null&&X!==void 0){if(typeof X!=="object"&&typeof X!=="function")throw TypeError("Object expected.");var K,W;if(G){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");K=X[Symbol.asyncDispose]}if(K===void 0){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");if(K=X[Symbol.dispose],G)W=K}if(typeof K!=="function")throw TypeError("Object not disposable.");if(W)K=function(){try{W.call(this)}catch(H){return Promise.reject(H)}};Y.stack.push({value:X,dispose:K,async:G})}else if(G)Y.stack.push({async:!0});return X};var J=typeof SuppressedError==="function"?SuppressedError:function(Y,X,G){var K=Error(G);return K.name="SuppressedError",K.error=Y,K.suppressed=X,K};hNA=function(Y){function X(H){Y.error=Y.hasError?new J(H,Y.error,"An error was suppressed during disposal."):H,Y.hasError=!0}var G,K=0;function W(){while(G=Y.stack.pop())try{if(!G.async&&K===1)return K=0,Y.stack.push(G),Promise.resolve().then(W);if(G.dispose){var H=G.dispose.call(G.value);if(G.async)return K|=2,Promise.resolve(H).then(W,function(D){return X(D),W()})}else K|=1}catch(D){X(D)}if(K===1)return Y.hasError?Promise.reject(Y.error):Promise.resolve();if(Y.hasError)throw Y.error}return W()},uNA=function(Y,X){if(typeof Y==="string"&&/^\.\.?\//.test(Y))return Y.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(G,K,W,H,D){return K?X?".jsx":".js":W&&(!H||!D)?G:W+H+"."+D.toLowerCase()+"js"});return Y},A("__extends",DNA),A("__assign",FNA),A("__rest",UNA),A("__decorate",zNA),A("__param",INA),A("__esDecorate",CNA),A("__runInitializers",ONA),A("__propKey",MNA),A("__setFunctionName",NNA),A("__metadata",LNA),A("__awaiter",VNA),A("__generator",ENA),A("__exportStar",RNA),A("__createBinding",ym),A("__values",gm),A("__read",K8A),A("__spread",jNA),A("__spreadArrays",wNA),A("__spreadArray",_NA),A("__await",UL),A("__asyncGenerator",PNA),A("__asyncDelegator",TNA),A("__asyncValues",kNA),A("__makeTemplateObject",SNA),A("__importStar",xNA),A("__importDefault",bNA),A("__classPrivateFieldGet",fNA),A("__classPrivateFieldSet",vNA),A("__classPrivateFieldIn",gNA),A("__addDisposableResource",yNA),A("__disposeResources",hNA),A("__rewriteRelativeImportExtension",uNA)})});var dNA=t((mNA)=>{Object.defineProperty(mNA,"__esModule",{value:!0});mNA.resolveFetch=void 0;var $DQ=(A)=>{if(A)return(...Q)=>A(...Q);return(...Q)=>fetch(...Q)};mNA.resolveFetch=$DQ});var W8A=t((aNA)=>{Object.defineProperty(aNA,"__esModule",{value:!0});aNA.FunctionRegion=aNA.FunctionsHttpError=aNA.FunctionsRelayError=aNA.FunctionsFetchError=aNA.FunctionsError=void 0;class MP extends Error{constructor(A,Q="FunctionsError",B){super(A);this.name=Q,this.context=B}toJSON(){return{name:this.name,message:this.message,context:this.context}}}aNA.FunctionsError=MP;class pNA extends MP{constructor(A){super("Failed to send a request to the Edge Function","FunctionsFetchError",A)}}aNA.FunctionsFetchError=pNA;class iNA extends MP{constructor(A){super("Relay Error invoking the Edge Function","FunctionsRelayError",A)}}aNA.FunctionsRelayError=iNA;class nNA extends MP{constructor(A){super("Edge Function returned a non-2xx status code","FunctionsHttpError",A)}}aNA.FunctionsHttpError=nNA;var lNA;(function(A){A.Any="any",A.ApNortheast1="ap-northeast-1",A.ApNortheast2="ap-northeast-2",A.ApSouth1="ap-south-1",A.ApSoutheast1="ap-southeast-1",A.ApSoutheast2="ap-southeast-2",A.CaCentral1="ca-central-1",A.EuCentral1="eu-central-1",A.EuWest1="eu-west-1",A.EuWest2="eu-west-2",A.EuWest3="eu-west-3",A.SaEast1="sa-east-1",A.UsEast1="us-east-1",A.UsWest1="us-west-1",A.UsWest2="us-west-2"})(lNA||(aNA.FunctionRegion=lNA={}))});var eNA=t((sNA)=>{Object.defineProperty(sNA,"__esModule",{value:!0});sNA.FunctionsClient=void 0;var KDQ=YX(),WDQ=dNA(),zL=W8A();class rNA{constructor(A,{headers:Q={},customFetch:B,region:$=zL.FunctionRegion.Any}={}){this.url=A,this.headers=Q,this.region=$,this.fetch=(0,WDQ.resolveFetch)(B)}setAuth(A){this.headers.Authorization=`Bearer ${A}`}invoke(A){return KDQ.__awaiter(this,arguments,void 0,function*(Q,B={}){var $;let J,Y;try{let{headers:X,method:G,body:K,signal:W,timeout:H}=B,D={},{region:F}=B;if(!F)F=this.region;let U=new URL(`${this.url}/${Q}`);if(F&&F!=="any")D["x-region"]=F,U.searchParams.set("forceFunctionRegion",F);let z;if(K&&(X&&!Object.prototype.hasOwnProperty.call(X,"Content-Type")||!X))if(typeof Blob<"u"&&K instanceof Blob||K instanceof ArrayBuffer)D["Content-Type"]="application/octet-stream",z=K;else if(typeof K==="string")D["Content-Type"]="text/plain",z=K;else if(typeof FormData<"u"&&K instanceof FormData)z=K;else D["Content-Type"]="application/json",z=JSON.stringify(K);else if(K&&typeof K!=="string"&&!(typeof Blob<"u"&&K instanceof Blob)&&!(K instanceof ArrayBuffer)&&!(typeof FormData<"u"&&K instanceof FormData))z=JSON.stringify(K);else z=K;let I=W;if(H)if(Y=new AbortController,J=setTimeout(()=>Y.abort(),H),W)I=Y.signal,W.addEventListener("abort",()=>Y.abort());else I=Y.signal;let O=yield this.fetch(U.toString(),{method:G||"POST",headers:Object.assign(Object.assign(Object.assign({},D),this.headers),X),body:z,signal:I}).catch((N)=>{throw new zL.FunctionsFetchError(N)}),V=O.headers.get("x-relay-error");if(V&&V==="true")throw new zL.FunctionsRelayError(O);if(!O.ok)throw new zL.FunctionsHttpError(O);let E=(($=O.headers.get("Content-Type"))!==null&&$!==void 0?$:"text/plain").split(";")[0].trim(),M;if(E==="application/json")M=yield O.json();else if(E==="application/octet-stream"||E==="application/pdf")M=yield O.blob();else if(E==="text/event-stream")M=O;else if(E==="multipart/form-data")M=yield O.formData();else M=yield O.text();return{data:M,error:null,response:O}}catch(X){return{data:null,error:X,response:X instanceof zL.FunctionsHttpError||X instanceof zL.FunctionsRelayError?X.context:void 0}}finally{if(J)clearTimeout(J)}})}}sNA.FunctionsClient=rNA});var ALA=t((M2)=>{Object.defineProperty(M2,"__esModule",{value:!0});M2.FunctionRegion=M2.FunctionsRelayError=M2.FunctionsHttpError=M2.FunctionsFetchError=M2.FunctionsError=M2.FunctionsClient=void 0;var ZDQ=eNA();Object.defineProperty(M2,"FunctionsClient",{enumerable:!0,get:function(){return ZDQ.FunctionsClient}});var NP=W8A();Object.defineProperty(M2,"FunctionsError",{enumerable:!0,get:function(){return NP.FunctionsError}});Object.defineProperty(M2,"FunctionsFetchError",{enumerable:!0,get:function(){return NP.FunctionsFetchError}});Object.defineProperty(M2,"FunctionsHttpError",{enumerable:!0,get:function(){return NP.FunctionsHttpError}});Object.defineProperty(M2,"FunctionsRelayError",{enumerable:!0,get:function(){return NP.FunctionsRelayError}});Object.defineProperty(M2,"FunctionRegion",{enumerable:!0,get:function(){return NP.FunctionRegion}})});function BLA(A,Q){return new Promise((B)=>{if(Q===null||Q===void 0?void 0:Q.aborted){B();return}let $=setTimeout(()=>{Q===null||Q===void 0||Q.removeEventListener("abort",J),B()},A);function J(){clearTimeout($),B()}Q===null||Q===void 0||Q.addEventListener("abort",J)})}function DDQ(A,Q,B,$){if(!$||B>=3)return!1;if(!YLA.includes(A))return!1;if(!qDQ.includes(Q))return!1;return!0}function LP(A){return LP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Q){return typeof Q}:function(Q){return Q&&typeof Symbol=="function"&&Q.constructor===Symbol&&Q!==Symbol.prototype?"symbol":typeof Q},LP(A)}function IDQ(A,Q){if(LP(A)!="object"||!A)return A;var B=A[Symbol.toPrimitive];if(B!==void 0){var $=B.call(A,Q||"default");if(LP($)!="object")return $;throw TypeError("@@toPrimitive must return a primitive value.")}return(Q==="string"?String:Number)(A)}function CDQ(A){var Q=IDQ(A,"string");return LP(Q)=="symbol"?Q:Q+""}function ODQ(A,Q,B){return(Q=CDQ(Q))in A?Object.defineProperty(A,Q,{value:B,enumerable:!0,configurable:!0,writable:!0}):A[Q]=B,A}function JLA(A,Q){var B=Object.keys(A);if(Object.getOwnPropertySymbols){var $=Object.getOwnPropertySymbols(A);Q&&($=$.filter(function(J){return Object.getOwnPropertyDescriptor(A,J).enumerable})),B.push.apply(B,$)}return B}function um(A){for(var Q=1;Q<arguments.length;Q++){var B=arguments[Q]!=null?arguments[Q]:{};Q%2?JLA(Object(B),!0).forEach(function($){ODQ(A,$,B[$])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(B)):JLA(Object(B)).forEach(function($){Object.defineProperty(A,$,Object.getOwnPropertyDescriptor(B,$))})}return A}var QLA=(A)=>Math.min(1000*2**A,30000),qDQ,YLA,Z8A,FDQ=class{constructor(A){var Q,B,$,J,Y;if(this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=A.method,this.url=A.url,this.headers=new Headers(A.headers),this.schema=A.schema,this.body=A.body,this.shouldThrowOnError=(Q=A.shouldThrowOnError)!==null&&Q!==void 0?Q:!1,this.signal=A.signal,this.isMaybeSingle=(B=A.isMaybeSingle)!==null&&B!==void 0?B:!1,this.shouldStripNulls=($=A.shouldStripNulls)!==null&&$!==void 0?$:!1,this.urlLengthLimit=(J=A.urlLengthLimit)!==null&&J!==void 0?J:8000,this.retryEnabled=(Y=A.retry)!==null&&Y!==void 0?Y:!0,A.fetch)this.fetch=A.fetch;else this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(A,Q){return this.headers=new Headers(this.headers),this.headers.set(A,Q),this}retry(A){return this.retryEnabled=A,this}then(A,Q){var B=this;if(this.schema===void 0);else if(["GET","HEAD"].includes(this.method))this.headers.set("Accept-Profile",this.schema);else this.headers.set("Content-Profile",this.schema);if(this.method!=="GET"&&this.method!=="HEAD")this.headers.set("Content-Type","application/json");if(this.shouldStripNulls){let X=this.headers.get("Accept");if(X==="application/vnd.pgrst.object+json")this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped");else if(!X||X==="application/json")this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}let $=this.fetch,Y=(async()=>{let X=0;while(!0){let W={};if(B.headers.forEach((D,F)=>{W[F]=D}),X>0)W["X-Retry-Count"]=String(X);let H;try{H=await $(B.url.toString(),{method:B.method,headers:W,body:JSON.stringify(B.body,(D,F)=>typeof F==="bigint"?F.toString():F),signal:B.signal})}catch(D){if((D===null||D===void 0?void 0:D.name)==="AbortError"||(D===null||D===void 0?void 0:D.code)==="ABORT_ERR")throw D;if(!YLA.includes(B.method))throw D;if(B.retryEnabled&&X<3){let F=QLA(X);X++,await BLA(F,B.signal);continue}throw D}if(DDQ(B.method,H.status,X,B.retryEnabled)){var G,K;let D=(G=(K=H.headers)===null||K===void 0?void 0:K.get("Retry-After"))!==null&&G!==void 0?G:null,F=D!==null?Math.max(0,parseInt(D,10)||0)*1000:QLA(X);await H.text(),X++,await BLA(F,B.signal);continue}return await B.processResponse(H)}})();if(!this.shouldThrowOnError)Y=Y.catch((X)=>{var G;let K="",W="",H="",D=X===null||X===void 0?void 0:X.cause;if(D){var F,U,z,I;let E=(F=D===null||D===void 0?void 0:D.message)!==null&&F!==void 0?F:"",M=(U=D===null||D===void 0?void 0:D.code)!==null&&U!==void 0?U:"";if(K=`${(z=X===null||X===void 0?void 0:X.name)!==null&&z!==void 0?z:"FetchError"}: ${X===null||X===void 0?void 0:X.message}`,K+=`
|
|
96
96
|
|
|
97
97
|
Caused by: ${(I=D===null||D===void 0?void 0:D.name)!==null&&I!==void 0?I:"Error"}: ${E}`,M)K+=` (${M})`;if(D===null||D===void 0?void 0:D.stack)K+=`
|
|
@@ -1043,7 +1043,7 @@ ${$.url}`);return"opened"}let Y=A.copyPath(Q.gzPath),X=A.reveal?.(Q.gzPath)===!0
|
|
|
1043
1043
|
(The path is already on your clipboard.)`:"",K=`
|
|
1044
1044
|
|
|
1045
1045
|
Please attach the logs file saved at:
|
|
1046
|
-
${Q.gzPath}${G}`,W=`${vtA(A.body,K)}${K}`,H=Z3A({to:c5,subject:A.subject,body:W}),D=!0;try{await A.openUrl(H)}catch{D=!1}let F=Y?" (copied to your clipboard)":"",U=X?" A Finder window showing the file is open behind your mail app.":"";if(D)A.print(`Opened an email to ${c5}. Your logs are saved at ${Q.gzPath}${F} — attach that file and send.${U} (A readable copy is also at ${Q.logPath}.)`);else A.print(`Couldn't open your mail app automatically. Please email ${c5} and attach your logs saved at ${Q.gzPath}${F}.${U} (A readable copy is also at ${Q.logPath}.)`);return"opened"}R5();import{readFileSync as H$0}from"node:fs";async function sK(A){let Q;try{Q=H$0(A.gzPath).toString("base64")}catch{return null}let B=A.apiHost.replace(/\/+$/,"");try{let $=await fetch(`${B}/build/support_logs`,{method:"POST",headers:{capgkey:A.apikey,"content-type":"application/json"},body:JSON.stringify({appId:A.appId,jobId:A.jobId,gzB64:Q}),signal:AbortSignal.timeout(15000)});if($.status!==200)return null;let J=await $.json();if(typeof J.id!=="string"||typeof J.url!=="string")return null;return{id:J.id,url:J.url}}catch{return null}}function q$0(A){return A?`${"Logs uploaded — Capgo support will be in touch by email."}
|
|
1046
|
+
${Q.gzPath}${G}`,W=`${vtA(A.body,K)}${K}`,H=Z3A({to:c5,subject:A.subject,body:W}),D=!0;try{await A.openUrl(H)}catch{D=!1}let F=Y?" (copied to your clipboard)":"",U=X?" A Finder window showing the file is open behind your mail app.":"";if(D)A.print(`Opened an email to ${c5}. Your logs are saved at ${Q.gzPath}${F} — attach that file and send.${U} (A readable copy is also at ${Q.logPath}.)`);else A.print(`Couldn't open your mail app automatically. Please email ${c5} and attach your logs saved at ${Q.gzPath}${F}.${U} (A readable copy is also at ${Q.logPath}.)`);return"opened"}R5();import{readFileSync as H$0}from"node:fs";async function sK(A){let Q;try{Q=H$0(A.gzPath).toString("base64")}catch{return null}let B=A.apiHost.replace(/\/+$/,"");try{let $=await fetch(`${B}/build/support_logs`,{method:"POST",headers:{capgkey:A.apikey,"content-type":"application/json"},body:JSON.stringify({appId:A.appId,jobId:A.jobId,platform:A.platform,gzB64:Q}),signal:AbortSignal.timeout(15000)});if($.status!==200)return null;let J=await $.json();if(typeof J.id!=="string"||typeof J.url!=="string")return null;return{id:J.id,url:J.url}}catch{return null}}function q$0(A){return A?`${"Logs uploaded — Capgo support will be in touch by email."}
|
|
1047
1047
|
Reference: ${A}`:"Logs uploaded — Capgo support will be in touch by email."}async function cj(A){let Q=(Y)=>{try{A.print(Y)}catch{}},B=!1;try{B=await A.confirm("Also upload these logs to Capgo support so our team can help? They'll follow up by email.")}catch{return"declined"}if(!B)return"declined";let $;try{$=await A.buildFiles()}catch{$=null}if(!$)return Q("Couldn't prepare your logs to send to Capgo support. You can email support@capgo.app and we'll help."),"failed";let J=null;try{J=await A.upload($.gzPath)}catch{J=null}if(!J)return Q("Logs upload to Capgo support is unavailable right now — continuing with AI analysis. You can email support@capgo.app if you need a hand."),"unavailable";return Q(q$0(J.url)),"uploaded"}c0();FG();q3A();var D3A=pA(jt(),1);import{chmod as F$0,lstat as utA,mkdir as U$0,readFile as z$0,rm as ft,writeFile as I$0}from"node:fs/promises";import{tmpdir as mtA}from"node:os";import{dirname as C$0,join as O$0,resolve as M$0}from"node:path";import vt,{cwd as N$0}from"node:process";async function ctA(A,Q,B){let $=M$0(N$0(),A),J=`${$}.qr.png`,Y=C$0($);if(await U$0(Y,{recursive:!0,mode:448}),$.startsWith(mtA())){let W=await utA(Y);if(W.isSymbolicLink())throw Error(`Refusing to write the build record: ${Y} is a symbolic link.`);if(typeof vt.getuid==="function"&&W.uid!==vt.getuid())throw Error(`Refusing to write the build record: ${Y} is owned by another user.`)}await ft($,{force:!0}),await ft(J,{force:!0});let X=null,G=null;if(Q.outputUrl){try{X=await D3A.default.toString(Q.outputUrl,{type:"utf8",errorCorrectionLevel:"L"})}catch(W){B?.(`Failed to render ASCII QR code: ${hg(W)}`)}try{await D3A.default.toFile(J,Q.outputUrl,{errorCorrectionLevel:"L",width:512}),await F$0(J,384),G=J}catch(W){B?.(`Failed to render PNG QR code at ${J}: ${hg(W)}`)}}let K={schemaVersion:1,jobId:Q.jobId,appId:Q.appId,platform:Q.platform,buildMode:Q.buildMode,status:Q.status,outputUrl:Q.outputUrl??null,qrCodeAscii:X,qrCodePngPath:G,finishedAt:new Date().toISOString()};return await I$0($,`${JSON.stringify(K,null,2)}
|
|
1048
1048
|
`,{encoding:"utf-8",mode:384}),K}function gt(A,Q){let B=A.replace(/[/\\]/g,"_").replace(/\.\./g,"_"),$=typeof vt.getuid==="function"?String(vt.getuid()):"default";return O$0(mtA(),`capgo-build-records-${$}`,`capgo-build-record-${B}-${Q}.json`)}async function yt(A){await ft(A,{force:!0}),await ft(`${A}.qr.png`,{force:!0})}class AF extends Error{recordPath;constructor(A,Q){super(A);this.name="BuildRecordReadError",this.recordPath=Q}}async function ht(A){try{if((await utA(A)).isSymbolicLink())throw new AF(`Build record at ${A} is a symbolic link — refusing to follow it.`,A)}catch(Y){if(Y instanceof AF)throw Y;if(Y?.code==="ENOENT")return null;throw new AF(`Build record at ${A} could not be read: ${hg(Y)}`,A)}let Q;try{Q=await z$0(A,"utf-8")}catch(Y){if(Y?.code==="ENOENT")return null;throw new AF(`Build record at ${A} could not be read: ${hg(Y)}`,A)}let B;try{B=JSON.parse(Q)}catch(Y){throw new AF(`Build record at ${A} is not valid JSON (possibly a truncated write): ${hg(Y)}`,A)}if(typeof B!=="object"||B===null)throw new AF(`Build record at ${A} has an unexpected shape (not a JSON object).`,A);let $=B;if(!(typeof $.jobId==="string"&&typeof $.status==="string"&&($.outputUrl===null||typeof $.outputUrl==="string")))throw new AF(`Build record at ${A} has an unexpected shape (jobId/status must be strings; outputUrl must be a string or null).`,A);if($.schemaVersion===1){if(!(typeof $.appId==="string"&&($.platform==="ios"||$.platform==="android")&&($.buildMode==="debug"||$.buildMode==="release")&&typeof $.finishedAt==="string"&&($.qrCodeAscii===null||typeof $.qrCodeAscii==="string")&&($.qrCodePngPath===null||typeof $.qrCodePngPath==="string")))throw new AF(`Build record at ${A} declares schemaVersion 1 but is missing or mistyping required v1 fields (appId/platform/buildMode/finishedAt/qrCodeAscii/qrCodePngPath).`,A)}return B}function hg(A){if(A instanceof Error)return A.message;return String(A)}c0();function L$0(A){if(!A||typeof A!=="object")return;let Q=A.originalResponse?.getStatus?.();return typeof Q==="number"?Q:void 0}function V$0(A){let Q=L$0(A);if(Q===401||Q===403)return"unauthorized";if(Q===413)return"payload_too_large";if(Q!==void 0&&Q>=500&&Q<600)return"storage_failure";if(Q===void 0||Q===0)return"network_error";return"unknown"}var E$0={started:"Builder Upload Started",succeeded:"Builder Upload Succeeded",failed:"Builder Upload Failed"},R$0={started:"⬆️",succeeded:"\uD83D\uDCE6",failed:"\uD83D\uDEAB"};async function ut(A){let Q={app_id:A.appId,platform:A.platform,build_mode:A.buildMode,job_id:A.jobId,upload_size_bytes:String(A.sizeBytes)};if(typeof A.durationSeconds==="number"&&Number.isFinite(A.durationSeconds))Q.upload_duration_seconds=String(Math.round(A.durationSeconds));if(A.phase==="failed"&&A.error!==void 0)Q.failure_category=V$0(A.error);try{await HB(A.apikey,{event:E$0[A.phase],channel:"build-lifecycle",icon:R$0[A.phase],notify:!1,org_id:A.orgId,tracking_version:2,tags:Q})}catch{}}async function Z60(){return c9({message:"No platform selected. Which platform do you want to build?",options:[{value:"ios",label:"iOS"},{value:"android",label:"Android"}]})}async function H60(A,{silent:Q=!1,interactive:B=BU({silent:Q}),promptPlatform:$=Z60}={}){if(A==="ios"||A==="android")return A;if(A)throw Error(`Invalid platform "${A}". Must be "ios" or "android"`);if(!B)throw Error("Missing required argument: --platform <ios|android>. In an interactive terminal, you can omit --platform and choose one when prompted.");let J=await $();if(U1(J))throw Error("Build request canceled.");if(J!=="ios"&&J!=="android")throw Error("Build request canceled.");return J}function q60(A){return{info:(Q)=>{if(!A)_.info(Q)},error:(Q)=>{if(!A)_.error(Q)},warn:(Q)=>{if(!A)_.warn(Q)},success:(Q)=>{if(!A)_.success(Q)},buildLog:(Q)=>{if(!A)console.log(Q)},uploadProgress:(()=>{let Q=A?null:z$(),B=!1;return($)=>{if(A||!Q)return;if(!B)Q.start("Uploading bundle"),B=!0;if($>=100)Q.stop("Upload complete!");else Q.message(`Uploading ${$.toFixed(0)}%`)}})(),customMsg:async(Q,B)=>{if(!A)await yM(Q,B,($)=>console.log($),($)=>_.warn($))}}}async function D60(A,Q,B=3,$){let J=[1000,3000,5000];for(let Y=1;Y<=B;Y++)try{let X=await fetch(A,Q);if(X.ok||X.status>=400&&X.status<500)return X;let G=await X.text().catch(()=>"unknown error");if($?.warn(`Build request attempt ${Y}/${B} failed: ${X.status} - ${G}`),Y<B){let K=J[Y-1]||5000;$?.info(`Retrying in ${K/1000}s...`),await new Promise((W)=>setTimeout(W,K))}else throw Error(`Failed to request build after ${B} attempts: ${X.status} - ${G}`)}catch(X){let G=X instanceof Error?X.message:String(X);if(G.startsWith("Failed to request build after"))throw X;if($?.warn(`Build request attempt ${Y}/${B} failed: ${G}`),Y<B){let K=J[Y-1]||5000;$?.info(`Retrying in ${K/1000}s...`),await new Promise((W)=>setTimeout(W,K))}else throw Error(`Failed to request build after ${B} attempts: ${G}`)}throw Error("Unexpected error in fetchWithRetry")}var F60=["succeeded","failed","expired","released","cancelled"],rt=new Set(F60);function U60(A){if(typeof A.data==="string")return A.data;if(A.data instanceof ArrayBuffer)return new TextDecoder().decode(A.data);if(ArrayBuffer.isView(A.data)){let Q=A.data;return new TextDecoder().decode(new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength))}if(A.data&&typeof A.data.toString==="function")return A.data.toString();return""}function hAQ(A,Q,B){if(Q)Q.warn(A);else if(!B)_.warn(A)}async function z60(A,Q,B,$){try{if(B)await B.customMsg(A,Q);else if(!$)await yM(A,Q,(J)=>console.log(J),(J)=>_.warn(J))}catch(J){hAQ(`Custom message handler encountered an error, continuing... ${String(J)}`,B,$)}}async function I60(A,Q=!1,B,$,J,Y,X,G){if(A&&!G)return null;let K=null,W=!1,H=(F)=>{if(!F.trim())return;if(K)return;if(!W)if(W=!0,G)G.buildLog("");else console.log("");if(G)G.buildLog(F);else console.log(F)},D=async()=>{if(!B||!$)return null;let F=B.replace(/\/+$/,""),U=`${F}/start`,I=`${F}/stream?token=${encodeURIComponent($)}`.replace(/^https:/,"wss:").replace(/^http:/,"ws:");if(G)G.info("Connecting to log streaming...");else if(!A)console.log("Connecting to log streaming...");let O=await fetch(U,{method:"POST",headers:{"x-capgo-log-token":$}});if(!O.ok){let V=await O.text().catch(()=>"unknown error");if(G)G.warn(`Could not start log session (${O.status}): ${V}`);else if(!A)console.warn(`Could not start log session (${O.status}): ${V}`);return null}return await new Promise((V)=>{let E=!1,M=10,N=0,R=!1,T=new gg(I,void 0,{maxRetries:M,WebSocket:HU}),x=null,m=0,i=Date.now(),b=!1,u=2000,p=4,r=rt,DA=null,o=null,g=(y)=>{if(E)return;if(E=!0,o)clearTimeout(o),o=null;if(x)clearInterval(x),x=null;if(Y&&DA)Y.removeEventListener("abort",DA),DA=null;try{T.close()}catch(d){DB(`ws.close failed during cleanup (ignored): ${d instanceof Error?d.message:String(d)}`)}V(y)};o=setTimeout(()=>{if(!E){if(G)G.warn("Log streaming timed out after 3 hours");else if(!A)console.warn("Log streaming timed out after 3 hours");g(null)}},10800000);let f=()=>{if(x)return;x=setInterval(async()=>{try{if(T.readyState===gg.OPEN)T.send(JSON.stringify({type:"heartbeat",lastId:m}));let y=Date.now();if(J&&!b&&y-i>=u*p){b=!0;try{let d=await J();if(d&&r.has(d))K=d,g(K)}finally{b=!1}}}catch(y){if(G)G.warn(`Heartbeat encountered an error, continuing... ${String(y)}`);else if(!A)_.warn(`Heartbeat encountered an error, continuing... ${String(y)}`)}},u)},S=async(y)=>{if(y.type==="custom_msg"&&typeof y.kind==="string"&&y.data){i=Date.now(),await z60(y.kind,y.data,G,A);return}if(y.type==="status"&&typeof y.status==="string"){let d=y.status.toLowerCase();if(i=Date.now(),r.has(d))K=d;return}if(y.type==="log"&&typeof y.message==="string"){i=Date.now(),H(y.message);return}if(typeof y.message==="string")i=Date.now(),H(y.message)},h=(y)=>{if(T.readyState!==gg.OPEN)return;try{T.send(JSON.stringify({type:"confirmed_received",lastId:y}))}catch(d){hAQ(`Failed to send log confirmation, continuing... ${String(d)}`,G,A)}};if(f(),Y){if(DA=()=>{if(!E)g("cancelled")},Y.aborted){g("cancelled");return}Y.addEventListener("abort",DA)}T.addEventListener("message",async(y)=>{let d=U60(y),KA=null;try{KA=JSON.parse(d)}catch{KA=null}if(KA?.type==="heartbeat_response")return;if(KA?.type==="batch_messages"&&Array.isArray(KA.messages)){let s=m;for(let GA of KA.messages)if(await S(GA),typeof GA.id==="number")s=Math.max(s,GA.id);if(s>m)m=s,h(s)}else{if(KA)await S(KA);else if(d)i=Date.now(),H(d);if(KA&&typeof KA.id==="number"&&KA.id>m)m=KA.id,h(KA.id)}if(K)g(K)}),T.addEventListener("error",()=>{if(N+=1,G)G.warn(`Log stream encountered an error, retrying (${N}/${M})...`);else if(!A)console.warn(`Log stream encountered an error, retrying (${N}/${M})...`);if(!R&&N>=M){if(R=!0,G)G.warn("Log stream retry limit reached. Falling back to status checks.");else if(!A)_.warn("Log stream retry limit reached. Falling back to status checks.");if(X)X();g(null)}}),T.addEventListener("close",()=>{if(E)return;if(K){g(K);return}if(G)G.warn("Log stream closed, waiting for reconnect...");else if(!A)_.warn("Log stream closed, waiting for reconnect...")})})};try{let F=await D();if(F||K)return F||K}catch(F){if(G)G.warn(`Direct log streaming failed${F instanceof Error?`: ${F.message}`:""}`);else if(!A)_.warn(`Direct log streaming failed${F instanceof Error?`: ${F.message}`:""}`)}return K}async function C60(A,Q,B,$,J,Y,X=!1,G,K){let H=0;while(H<120){if(G?.aborted)return"cancelled";try{let D=await fetch(`${A}/build/status?job_id=${encodeURIComponent(Q)}&app_id=${encodeURIComponent(B)}&platform=${$}`,{headers:{authorization:J},signal:G});if(!D.ok){K?.warn(`Status check failed: ${D.status}`),await new Promise((z)=>setTimeout(z,5000)),H++;continue}let F=await D.json(),U=F.status?.toLowerCase?.()??"";if(X)K?.info(`Build status: ${U||F.status}`);if(rt.has(U))return U;await new Promise((z)=>setTimeout(z,5000)),H++}catch(D){if(G?.aborted)return"cancelled";K?.warn(`Status check error: ${D}`),await new Promise((F)=>setTimeout(F,5000)),H++}}return K?.warn("Build status polling timed out"),"timeout"}async function O60(A,Q,B){let $=new Set,J=new Set,Y=!1,X=!1;if(Q==="ios"){let G=gX(A,B,"App","CapApp-SPM","Package.swift");if(u3(G)){Y=!0;let H=(await ot(G,"utf-8")).matchAll(/\.package\s*\([^)]*path:\s*["'](?:\.\.[\\/])*node_modules[\\/]([^"']+)["']\s*\)/g);for(let D of H){let F=D[1].replace(/\\/g,"/"),U=F.lastIndexOf("node_modules/");if(U!==-1)F=F.substring(U+13);$.add(F)}}let K=gX(A,B);if(u3(K)){let W=[gX(K,"App","Podfile"),gX(K,"Podfile")];for(let D of R3A(K,{withFileTypes:!0}))if(D.isDirectory())W.push(gX(K,D.name,"Podfile"));let H=[...new Set(W)].filter((D)=>u3(D));if(H.length>0)X=!0;for(let D of H){let U=(await ot(D,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"](?:\.\.[\\/])+node_modules[\\/]([^'"]+)['"]/g);for(let z of U){let I=z[1],O=I.lastIndexOf("node_modules/");if(O!==-1)I=I.substring(O+13);$.add(I)}}}}else if(Q==="android"){let G=gX(A,B,"capacitor.settings.gradle");if(u3(G)){let H=(await ot(G,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.[\\/]node_modules[\\/]([^'"]+)['"]\s*\)/g);for(let D of H){let F=D[1].replace(/\\/g,"/"),U=F.lastIndexOf("node_modules/");if(U!==-1)F=F.substring(U+13);let z=F.replace(/\/(android|capacitor)$/,"");$.add(z)}}let K=gX(A,B,"capacitor-cordova-android-plugins","build.gradle");if(u3(K)){let H=(await ot(K,"utf-8")).matchAll(/apply\s+from\s*:\s*["'](?:\.\.\/)+node_modules\/([^"']+)["']/g);for(let D of H){let F=D[1],U=F.lastIndexOf("node_modules/");if(U!==-1)F=F.substring(U+13);let z=F.split("/"),I=z[0].startsWith("@")&&z.length>=2?`${z[0]}/${z[1]}`:z[0];J.add(I)}}}return{packages:$,cordovaPackages:J,usesSPM:Y,usesCocoaPods:X}}function gAQ(A,Q,B,$){let J=A.replace(/\\/g,"/");if(J.startsWith(`${$}/`))return!0;if(J==="package.json"||J==="package-lock.json"||J.startsWith("capacitor.config."))return!0;if(J.startsWith("resources/"))return!0;if(Q==="ios"&&J.startsWith("node_modules/@capacitor/ios/"))return!0;if(Q==="android"&&J.startsWith("node_modules/@capacitor/android/"))return!0;if(Q==="android")for(let Y of B.cordovaPackages){let X=`node_modules/${Y}/`;if(J===`node_modules/${Y}/package.json`)return!0;if(J.startsWith(X)){let G=J.slice(X.length);if(G==="node_modules"||G.startsWith("node_modules/"))continue;return!0}}for(let Y of B.packages){let X=`node_modules/${Y}/`;if(J===`${X}package.json`)return!0;if(Q==="android"){if(J.startsWith(`${X}android/`))return!0}else if(Q==="ios"){if(J.startsWith(`${X}ios/`))return!0;if(B.usesSPM){if(J===`${X}Package.swift`)return!0}if(B.usesCocoaPods||!B.usesSPM){if(J.startsWith(X)&&J.endsWith(".podspec"))return!0}}}return!1}function tg(A,Q,B,$,J,Y){let X=R3A(Q);for(let G of X){let K=gX(Q,G),W=B?`${B}/${G}`:G,H=$60(K);if(H.isDirectory()){if(G===".git"||G==="dist"||G==="build"||G===".angular"||G===".vite"||G===".gradle"||G===".idea"||G===".swiftpm")continue;if(G==="node_modules"){tg(A,K,W,$,J,Y);continue}if(G==="resources"){tg(A,K,W,$,J,Y);continue}let D=W.replace(/\\/g,"/"),F=[...J.packages,...J.cordovaPackages];if(gAQ(W,$,J,Y)||Y===D||Y.startsWith(`${D}/`)||F.some((z)=>{return`node_modules/${z}/`.startsWith(`${D}/`)||D.startsWith(`node_modules/${z}`)}))tg(A,K,W,$,J,Y)}else if(H.isFile()){if(G===".DS_Store"||G.endsWith(".log"))continue;if(gAQ(W,$,J,Y))M60(A,K,W)}}}function M60(A,Q,B){let $=B.replace(/\\/g,"/");if(A.getEntry($))return;let J=$.lastIndexOf("/"),Y=J===-1?void 0:$.slice(0,J);A.addLocalFile(Q,Y)}function N60(A){if(!A)return[];let Q=A.split(",").map((B)=>B.trim()).filter(Boolean).map((B)=>E3A(B));return[...new Set(Q)]}function L60(A,Q){let B=new Set([...Q.packages,...Q.cordovaPackages]);return B.add(A==="ios"?"@capacitor/ios":"@capacitor/android"),B}function V60(A,Q){let B=gX(A,...Q.split("/"));if(u3(B))return B;let $=gX(A,".pnpm");if(!u3($))return;let J=Q.replace("/","+"),Y=R3A($,{withFileTypes:!0}).filter((X)=>X.isDirectory()).map((X)=>X.name).filter((X)=>X.startsWith(`${J}@`)).sort();if(Y.length>1)throw Error(`Multiple pnpm store entries found for ${Q} in ${$}; provide the app-specific node_modules path so the native build archive can use the exact resolved package.`);for(let X of Y){let G=gX($,X,"node_modules",...Q.split("/"));if(u3(G))return G}return}function E60(A,Q,B,$,J){if(Q.length===0)return;let Y=Q.filter((X)=>!u3(X));if(Y.length>0)throw Error(`Missing node_modules folder at ${Y.join(", ")}`);for(let X of Q)for(let G of L60(B,$)){let K=V60(X,G);if(!K)continue;tg(A,K,`node_modules/${G}`,B,$,J)}}async function R60(A,Q,B,$,J={}){let Y=$9($,B),X=await O60(A,B,Y),G=new yAQ.default;tg(G,A,"",B,X,Y),E60(G,N60(J.nodeModules),B,X,Y);let K=/node_modules\/\.pnpm\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,W=/node_modules\/\.bun\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,H=new Set(["",".gradle",".swift",".json",".lock",".xml",".properties",".pbxproj",".xcconfig",".plist",".podspec",".rb",".yaml",".yml"]);for(let F of G.getEntries()){if(F.isDirectory)continue;let U=F.entryName.includes(".")?`.${F.entryName.split(".").pop()}`:"",z=F.entryName.split("/").pop()||"";if(!H.has(U)&&z!=="Podfile")continue;let I=F.getData().toString("utf-8"),O=ArA(I);if(O=O.replace(K,"node_modules/").replace(W,"node_modules/"),B==="ios"){let V="../".repeat(F.entryName.split("/").length-1);O=O.replace(/(?:\.\.\/){4,}(ios\/|node_modules\/)/g,(E,M)=>`${V}${M}`)}if(O!==I)G.updateFile(F.entryName,bAQ.from(O,"utf-8"))}let D=gX(A,"capacitor.config.json");if($&&!u3(D)){let F=`${JSON.stringify($,null,2)}
|
|
1049
1049
|
`;G.addFile("capacitor.config.json",bAQ.from(F,"utf-8"))}await G60(Q,G.toBuffer())}var j60=new Set(["CAPGO_IOS_SCHEME","CAPGO_IOS_TARGET","CAPGO_IOS_DISTRIBUTION","BUILD_OUTPUT_UPLOAD_ENABLED","BUILD_OUTPUT_RETENTION_SECONDS","SKIP_BUILD_NUMBER_BUMP","CAPGO_STORE_SUBMIT_REVIEW","CAPGO_STORE_RELEASE_NAME","CAPGO_STORE_RELEASE_NOTES","CAPGO_STORE_RELEASE_NOTES_LOCALIZED","CAPGO_IOS_AUTOMATIC_RELEASE","CAPGO_IOS_TESTFLIGHT_GROUPS","CAPGO_IOS_SOURCE_DIR","CAPGO_IOS_APP_DIR","CAPGO_IOS_PROJECT_DIR","IOS_PROJECT_DIR","CAPGO_ANDROID_SOURCE_DIR","CAPGO_ANDROID_APP_DIR","CAPGO_ANDROID_PROJECT_DIR","ANDROID_PROJECT_DIR","CAPGO_ANDROID_FLAVOR"]);function w60(A){if(!A||A.length===0)return;let Q={};for(let B of A){let $=B.indexOf("=");if($<=0)throw Error('--store-release-notes-locale must use locale=notes format, for example: --store-release-notes-locale en-US="Bug fixes"');let J=B.slice(0,$).trim(),Y=B.slice($+1).trim();if(!J||!Y)throw Error("--store-release-notes-locale requires both a locale and non-empty release notes");Q[J]=Y}return Object.keys(Q).length>0?Q:void 0}function tt(A){let Q=A?.trim();if(!Q)return;let B;try{B=JSON.parse(Q)}catch(J){throw Error(`CAPGO_STORE_RELEASE_NOTES_LOCALIZED must be valid JSON: ${J instanceof Error?J.message:String(J)}`)}if(!B||typeof B!=="object"||Array.isArray(B))throw Error('CAPGO_STORE_RELEASE_NOTES_LOCALIZED must be a JSON object like {"en-US":"Bug fixes"}');let $={};for(let[J,Y]of Object.entries(B)){let X=J.trim();if(typeof Y!=="string"||!Y.trim())throw Error(`CAPGO_STORE_RELEASE_NOTES_LOCALIZED.${X||J} must be a non-empty string`);if(!X)throw Error("CAPGO_STORE_RELEASE_NOTES_LOCALIZED cannot contain an empty locale key");$[X]=Y.trim()}return Object.keys($).length>0?$:void 0}function _60(A,Q,B,$){let J=tt(A.CAPGO_STORE_RELEASE_NOTES_LOCALIZED),Y=A.CAPGO_IOS_AUTOMATIC_RELEASE===void 0?void 0:A.CAPGO_IOS_AUTOMATIC_RELEASE==="true",X={platform:Q,buildMode:B,cliVersion:$,iosScheme:A.CAPGO_IOS_SCHEME,iosTarget:A.CAPGO_IOS_TARGET,iosDistribution:A.CAPGO_IOS_DISTRIBUTION,iosSourceDir:A.CAPGO_IOS_SOURCE_DIR,iosAppDir:A.CAPGO_IOS_APP_DIR,iosProjectDir:A.CAPGO_IOS_PROJECT_DIR,androidSourceDir:A.CAPGO_ANDROID_SOURCE_DIR,androidAppDir:A.CAPGO_ANDROID_APP_DIR,androidProjectDir:A.CAPGO_ANDROID_PROJECT_DIR,androidFlavor:A.CAPGO_ANDROID_FLAVOR,outputUploadEnabled:A.BUILD_OUTPUT_UPLOAD_ENABLED==="true",outputRetentionSeconds:A.BUILD_OUTPUT_RETENTION_SECONDS?Number.parseInt(A.BUILD_OUTPUT_RETENTION_SECONDS,10)||dq:dq,skipBuildNumberBump:A.SKIP_BUILD_NUMBER_BUMP==="true",submitToStoreReview:A.CAPGO_STORE_SUBMIT_REVIEW==="true",storeReleaseName:A.CAPGO_STORE_RELEASE_NAME,storeReleaseNotes:A.CAPGO_STORE_RELEASE_NOTES,storeReleaseNotesLocalized:J,iosTestflightGroups:A.CAPGO_IOS_TESTFLIGHT_GROUPS,iosAutomaticRelease:Y},G={};for(let[K,W]of Object.entries(A))if(!j60.has(K)&&W!==void 0)G[K]=W;return{buildOptions:X,buildCredentials:G}}async function QF(A,Q,B=!1,$){if(!UK())OU(A);DB(`build request: started for ${A} (platform ${Q.platform??"auto"})`);let J=Date.now(),Y=Q.verbose??!1,X=$||q60(B),G=null,K=Q.outputRecord?{...X,customMsg:async(W,H)=>{if(W==="qr_download_link"&&typeof H.url==="string")G=H.url;await X.customMsg(W,H)}}:X;try{if(Q.prescan===!0){let{validateFlags:s}=await Promise.resolve().then(() => (at(),V3A));s({ignoreFatal:Q.prescanIgnoreFatal,failOnWarnings:Q.failOnWarnings})}Q.apikey=Q.apikey||k0(B);let W=E3A(Q.path||vAQ()),H=await bt(W,()=>N0());if(A=A||H?.config?.appId,!A)throw Error("Missing argument, you need to provide a appId, or be in a capacitor project");let D=await H60(Q.platform,{silent:B}),F=Q.supaHost||"https://api.capgo.app",U=await YB(Q.apikey,Q.supaHost,Q.supaAnon),z="";try{z=await T4(U,A)}catch{}if(K.info(`Requesting native build for ${A}`),K.info(`Platform: ${D}`),K.info(`Project: ${W}`),K.info(`
|
|
@@ -1293,12 +1293,12 @@ ${E6Q}`)};return}if(A.endsWith(".css")){if(!Q.includes("capgo-test-background"))
|
|
|
1293
1293
|
${V6Q}`,"<body>");return B!==Q?B:void 0}if(A==="vue-banner"){let B=Q.replace(`<template>
|
|
1294
1294
|
${E6Q}`,"<template>");return B!==Q?B:void 0}if(A==="css-background"){let B=Q.replace(R6Q,"");return B!==Q?B:void 0}return}function RH0(A){return A===" "||A===`
|
|
1295
1295
|
`||A==="\r"||A==="\t"||A==="\f"}function X6Q(A,Q){let B=Q;while(B<A.length&&RH0(A[B]))B+=1;return B}function G6Q(A,Q,B){let $=X6Q(A,Q);if(A.slice($,$+B.length).toLowerCase()!==B)return Q;let J=A.indexOf(";",$+B.length);if(J===-1)return Q;return X6Q(A,J+1)}function jH0(A){let Q=A.startsWith("\uFEFF")?1:0;Q=G6Q(A,Q,"@charset");while(!0){let B=G6Q(A,Q,"@import");if(B===Q)return Q;Q=B}}function wH0(A){let Q=A.slice(3).trim(),B=" -> ";if(!Q.includes(" -> "))return Q;return Q.slice(Q.lastIndexOf(" -> ")+4)}function _H0(A,Q){if(!Q||!A.inRepo||!A.repoRoot||A.error||A.clean||A.entries.length===0)return!1;try{let B=fDA.native(A.repoRoot),$=fDA.native(L6.resolve(Q.filePath)),J=A.entries.map(wH0).filter(Boolean).map((W)=>fDA.native(L6.resolve(B,W)));if(J.length===0||!J.every((W)=>W===$))return!1;let Y=MF($,"utf8"),X=_6Q(Q.kind,Y);if(!X)return!1;let G=L6.relative(B,$).split(L6.sep).join("/"),K=TZ("git",["show",`:${G}`],{cwd:B,stdio:"pipe",encoding:"utf8"});if(K.error||K.status!==0)return!1;return K.stdout.toString()===X}catch{return!1}}function PH0(){return[{value:"check-again",label:"Check again",hint:"recommended after committing or stashing changes"},{value:"continue-dirty",label:"Continue anyway",hint:"not recommended; onboarding may edit files"}]}async function TH0(){let A=await E5({message:'Type "ready" once the repository is clean and you want me to check again.',placeholder:"ready",validate:(Q)=>{if(!Q?.trim())return'Type "ready" when the repository is clean.';if(Q.trim().toLowerCase()!=="ready")return'Type "ready" when the repository is clean.'}});await ez(A)}async function kH0(A){let Q=!1;while(!0){let B=nDA();if(B.error&&!B.inRepo){XA.warn(`Could not verify git status, skipping clean-repo check: ${B.error}`);return}if(!B.inRepo)return;if(B.error){Q=!0,XA.error(`Could not verify git status for ${B.repoRoot}: ${B.error}`),XA.info("Fix the git error first, then retry onboarding."),await TH0();continue}if(B.clean){if(Q)XA.success("Git repository is clean ✅");return}if(_H0(B,A))return;Q=!0,XA.warn(`Git repository is not clean: ${B.repoRoot}`);for(let J of B.entries.slice(0,10))XA.warn(` ${J}`);if(B.entries.length>10)XA.warn(` ...and ${B.entries.length-10} more`);XA.info("Clean, commit, or stash those changes before init continues, or continue anyway if you accept the risk.");let $=await I1({message:"How do you want to handle the dirty git status?",options:PH0()});if(await ez($),$==="continue-dirty"){XA.warn("Continuing with dirty git status. This is not recommended.");return}}}function sDA(A,Q=[]){let B=zAA>0?`Step ${zAA}/${fG.length} · ${fG[zAA-1]?.title??"Unknown step"}`:void 0,{pm:$,doctor:J,capAddIos:Y,capAddAndroid:X}=ly();return xt({kind:"init",appId:$W,currentStep:B,packageManager:$.pm,cwd:u1(),error:A,commands:[J,Y,X],docs:["https://capgo.app/docs/getting-started/onboarding/","https://capgo.app/docs/getting-started/add-an-app/"],sections:[{title:"Onboarding state",lines:[`Channel: ${dX}`,`Platform: ${Tw}`,`Current version: ${IF??"unknown"}`]},...Q]})}function SH0(){let A=UK();if(!A)return[];try{return MF(A,"utf8").split(`
|
|
1296
|
-
`)}catch{return[]}}async function xH0(A){await uz({subject:`Capgo Builder onboarding support — ${$W??"unknown"}`,body:`Hi Capgo team,
|
|
1296
|
+
`)}catch{return[]}}async function xH0(A,Q){await uz({subject:`Capgo Builder onboarding support — ${$W??"unknown"}`,body:`Hi Capgo team,
|
|
1297
1297
|
|
|
1298
1298
|
I hit an error during Capgo Builder onboarding.
|
|
1299
1299
|
|
|
1300
1300
|
App: ${$W??"unknown"}
|
|
1301
|
-
Error: ${A}`,confirm:async(
|
|
1301
|
+
Error: ${A}`,confirm:async(B,$)=>{for(;;){let J=await I1({message:B,options:[{value:"yes",label:"\uD83D\uDCE8 Yes, send to support"},{value:"view",label:"\uD83D\uDC40 View logs first (opens the file)"},{value:"no",label:"✖ Cancel"}]});if(vB(J)||J==="no")return!1;if(J==="view"){XA.info(`Logs to be sent: ${$}`);try{await n6($)}catch{}continue}return!0}},buildFiles:()=>NZ({kind:"init",appId:$W,error:A,sections:[{title:"Internal log",lines:SH0()}]}),copyPath:(B)=>f3(B).ok,reveal:(B)=>hz(B),openUrl:(B)=>n6(B),print:(B)=>XA.info(B),upload:async(B)=>{let $=S$();if(!$)return null;let J=W4();J.start("Uploading your logs to Capgo support…");let Y=await sK({apiHost:j6Q??QU,apikey:$,appId:$W,platform:Q,gzPath:B});return J.stop(Y?"Logs uploaded.":"Logs upload unavailable — falling back to attaching the file."),Y}})}async function P6Q(){try{await aC({packageJson:E4},!1)}catch(A){XA.warn(`Doctor found an issue: ${hA(A)}`)}}async function RAA(A,Q,B="You can resume the onboarding anytime by running the same command again"){return await OF(A,Q,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1302
1302
|
\uD83D\uDCA1 ${B}`),await X6(1)}function IAA(A){try{let Q=L6.isAbsolute(A)?A:L6.resolve(u1(),A),B=u1(),$=L6.dirname(B);if($===B)return A;let J=L6.relative($,Q);return J.length>0?J:A}catch{return A}}function yDA(A,Q,B){let $=A.length===0?[]:A.split(`
|
|
1303
1303
|
`),J=Q.split(`
|
|
1304
1304
|
`),Y=0;while(Y<$.length&&Y<J.length&&$[Y]===J[Y])Y++;let X=$.length-1,G=J.length-1;while(X>=Y&&G>=Y&&$[X]===J[G])X--,G--;if(G<Y)return[];let K=Math.max(0,Y-B),W=Math.min(J.length-1,G+B),H=[];for(let D=K;D<=W;D++)H.push({lineNumber:D+1,text:J[D]??"",kind:D>=Y&&D<=G?"add":"context"});return H}function bH0(){dy??=O6Q(UAA.default.tmpdir).map((A)=>{return{name:A,full:`${UAA.default.tmpdir}/${A}`}}).find((A)=>A.name.startsWith("capgocli"))?.full??UAA.default.fileSync({prefix:"capgocli"}).name}function T6Q(){if(bH0(),!dy)throw Error("Unable to allocate onboarding state file");return dy}function CAA(A,Q){let B=A,$=L6.parse(B).root;while(!0){for(let Y of Q){let X=d4(B,Y);if(RJ(X))return X}if(B===$)break;let J=h7(B);if(J===B)break;B=J}return}function k6Q(A){return CAA(A,[W$])}function gy(A){if(!A||!RJ(A))return;return MF(A,"utf8")}function jAA(A){if(A.startsWith("nextjs-"))return"nextjs";if(A.startsWith("nuxtjs-"))return"nuxtjs";if(A.startsWith("sveltekit-"))return"sveltekit";return}function K6Q(A){let Q=jAA(A);if(Q==="nextjs")return"Next.js";if(Q==="nuxtjs")return"Nuxt";if(Q==="sveltekit")return"SvelteKit";return"web"}function fH0(A){let Q=jAA(A);if(Q==="nextjs")return"out";if(Q==="nuxtjs")return".output/public";if(Q==="sveltekit")return"build";return"dist"}function vH0(A){if(!A||!RJ(A))return;try{return JSON.parse(MF(A,"utf8"))}catch{return}}function gH0(A){return(vH0(k6Q(A))?.name?.split("/").pop()||L6.basename(A)).replaceAll(/[-_]+/g," ").replaceAll(/\b\w/g,($)=>$.toUpperCase())}function W6Q(A,Q,B){let $=jAA(A);if(!$)return[];let J=[];if($==="nextjs"){let Y=gy(CAA(Q,["next.config.ts","next.config.js","next.config.mjs"]));if(!Y?.includes("output")||!Y.includes("export"))J.push("Next.js must use static export (`output: 'export'`).");let X=gy(B);if(X&&!VH0.test(X))J.push("Capacitor `webDir` should point to `out` for Next.js.")}if($==="nuxtjs"){let Y=gy(CAA(Q,["nuxt.config.ts","nuxt.config.js"]));if(!Y?.includes("preset")||!Y.includes("static"))J.push('Nuxt must use static Nitro output (`nitro.preset = "static"`).');let X=gy(B);if(X&&!EH0.test(X))J.push("Capacitor `webDir` should point to `.output/public` for Nuxt.")}if($==="sveltekit"){if(!gy(CAA(Q,["svelte.config.js","svelte.config.ts"]))?.includes("adapter-static"))J.push("SvelteKit must use `@sveltejs/adapter-static` before Capacitor sync works reliably.")}return J}async function OAA(){return O4(`Bye \uD83D\uDC4B
|
|
@@ -1308,8 +1308,8 @@ Error: ${A}`,confirm:async(Q,B)=>{for(;;){let $=await I1({message:Q,options:[{va
|
|
|
1308
1308
|
${$}`),XA.warn("Onboarding will continue but please report it to the capgo team!")}}async function cH0(A){try{let Q=MF(T6Q(),"utf-8");if(!Q||Q.length===0)return;let{step_done:B,orgId:$,orgName:J,appId:Y,pathToPackageJson:X,nodeModulesPath:G,channelName:K,platform:W,delta:H,currentVersion:D,codeDiff:F,encryptionSummary:U,autoTestChange:z}=JSON.parse(Q);if(!$||!B){XA.warn("⚠️ Found previous onboarding progress, but it was saved in an older format."),XA.info(" Starting fresh. Your previous progress cannot be resumed.");return}if(XA.info($6Q(B,fG.length)),J)XA.info(` Organization: ${J}`);let I=await I1({message:"Would you like to continue from where you left off?",options:[{value:"yes",label:"✅ Yes, continue"},{value:"no",label:"❌ No, start over"}]});if(await g8(I,$,A),I==="yes"){if(X)E4=X;if(typeof G==="string"&&G.length>0)CF=G;if(K)dX=K;if(W==="ios"||W==="android")Tw=W;if(typeof H==="boolean")cy=H;if(typeof D==="string"&&D.length>0)IF=D;if(Y)$W=Y;if(z&&typeof z==="object"&&typeof z.filePath==="string"&&typeof z.displayPath==="string"&&["html-banner","vue-banner","css-background"].includes(z.kind))YW={filePath:z.filePath,displayPath:z.displayPath,kind:z.kind};if(B===4&&F&&typeof F==="object"&&typeof F.filePath==="string"&&Array.isArray(F.lines)){let O=[];for(let V of F.lines)if(typeof V==="object"&&V!==null&&typeof V.lineNumber==="number"&&typeof V.text==="string"&&(V.kind==="context"||V.kind==="add")){let E=V;O.push({lineNumber:E.lineNumber,text:E.text,kind:E.kind})}EJ={filePath:F.filePath,created:Boolean(F.created),lines:O,note:typeof F.note==="string"?F.note:void 0}}if(B>=5&&B<7&&U&&typeof U==="object"&&typeof U.title==="string"&&typeof U.phase==="string"&&Array.isArray(U.lines)){let O=U.lines.filter((M)=>typeof M==="string");JW={phase:["enabled","pending-sync","skipped","failed"].includes(U.phase)?U.phase:"skipped",title:U.title,lines:O},CU(JW)}return{stepDone:B,orgId:$,orgName:J,appId:Y}}cDA(),EJ=void 0,RH(void 0),JW=void 0,CU(void 0),YW=void 0,CF=void 0;return}catch(Q){XA.error(`Cannot read which steps have been completed, error:
|
|
1309
1309
|
${Q}`),XA.warn("Onboarding will continue but please report it to the capgo team!"),EJ=void 0,RH(void 0),JW=void 0,CU(void 0),YW=void 0,CF=void 0;return}}function cDA(){if(YW=void 0,CF=void 0,!dy)return;try{M6Q(dy)}catch(A){XA.error(`Cannot delete the tmp steps file.
|
|
1310
1310
|
Error: ${A}`)}}async function g8(A,Q,B){if(vB(A))return await OF(Q,B,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1311
|
-
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6()}async function kw(A,Q,B,$,J=B){while(!0){let
|
|
1312
|
-
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6(1);if(
|
|
1311
|
+
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6()}async function kw(A,Q,B,$,J=B,Y){while(!0){let X=await I1({message:B,options:[...$,{value:"__email_support__",label:"\uD83D\uDCE8 Email Capgo support"},{value:"__doctor__",label:"Run doctor diagnostics now"},{value:"__support__",label:"Save a support bundle"},{value:"__cancel__",label:"Exit onboarding"}]});if(vB(X)||X==="__cancel__")return await OF(A,Q,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1312
|
+
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6(1);if(X==="__doctor__"){try{await aC({packageJson:E4},!1)}catch(G){XA.warn(`Doctor found an issue: ${hA(G)}`)}continue}if(X==="__email_support__"){await xH0(J,Y);continue}if(X==="__support__"){let G=sDA(J);if(G)XA.info(`Saved support bundle to ${G}`);else XA.warn("Could not save a support bundle automatically.");continue}return X}}async function dH0(A,Q,B,$){let J=await E5({message:B,placeholder:$,validate:(Y)=>{let X=Y?.trim();if(!X)return"Path is required.";if(!RJ(X))return`Path ${X} does not exist`;if(!N6Q(X).isDirectory())return"Selected path is not a directory"}});if(vB(J))await g8(J,A,Q);return J.trim()}function wAA(A){let Q=A,B=L6.parse(Q).root;while(!0){for(let J of iDA){let Y=d4(Q,J);if(RJ(Y))return{dir:Q,file:Y}}if(Q===B)break;let $=h7(Q);if($===Q)break;Q=$}return}async function H6Q(){let A=u1();if(iDA.some((Y)=>RJ(d4(A,Y))))return;let B=wAA(A);if(XA.warn("Capacitor config not found in the current folder."),B)XA.info(`Found a capacitor config at: ${B.file}`),XA.info(`You are currently in: ${A}`);else XA.info("No capacitor config was found in this folder or any parent directories.");let $=L6.basename(A);if($==="ios"||$==="android")XA.info("It looks like you are inside a platform folder (ios/android)."),XA.info("Try running the onboarding from the project root (the folder with capacitor.config.*).");if(B){let Y=await I1({message:"How do you want to continue?",options:[{value:"switch",label:`Switch to ${B.dir} and continue there`},{value:"continue",label:"Stay here and continue anyway"},{value:"exit",label:"Exit onboarding"}]});if(vB(Y)||Y==="exit")return X7("Operation cancelled."),await X6(1);if(Y==="switch"){JN(B.dir),XA.info(`Switched to ${B.dir}`);return}return}let J=await n1({message:"Are you sure you want to continue? If you do, the auto-configuration will probably not work from here.",initialValue:!1});if(vB(J)||!J)return X7("Operation cancelled."),await X6(1)}async function OF(A,Q,B,$,J="✅"){let Y=er();return MC("onboarding-v2",A,Q,B,$,J,Y?{$session_id:Y}:void 0)}async function jJ(A,Q,B,$){return OF(A,Q,`onboarding-step-${B}`,$)}async function tDA(A){try{await $U({appId:A}),XA.info(`\uD83D\uDCBE Saved new app ID "${A}" to CapacitorUpdater config`)}catch(Q){XA.warn(`⚠️ Could not save app ID to capacitor config: ${Q}`),XA.info(` You may need to manually update your capacitor.config file with the new app ID: ${A}`)}}async function lH0(A){try{let Q=await N0();Q.config.appId=A,Q.config.plugins||={},Q.config.plugins.CapacitorUpdater={...Q.config.plugins.CapacitorUpdater,appId:A},await y2(Q,!0),XA.info(`\uD83D\uDCBE Synced pending onboarding app ID "${A}" to capacitor config`)}catch(Q){XA.warn(`⚠️ Could not save app ID to capacitor config: ${Q}`),XA.info(` You may need to manually update your capacitor.config file with the new app ID: ${A}`)}}function pH0(A,Q,B,$){XA.error("Capgo iOS dependency sync verification failed.");for(let J of A)XA.error(J);XA.error("The native iOS project is still broken, so this build step cannot continue yet."),XA.warn(Q),XA.info(B),XA.info(`Diagnostics: ${$}`)}function iH0(A,Q,B,$){if(A<2)return;let J=sDA("iOS dependency sync verification failed",[{title:"Failure details",lines:Q},{title:"Recommended commands",lines:[B,$]}]);if(J)XA.info(`Support bundle: ${J}`);else XA.warn("Could not save a support bundle automatically.")}async function nH0(A,Q,B){if(A%3!==0)return;let $=await n1({message:`iOS sync has failed ${A} times. Do you want to cancel init?`,initialValue:!1});if(await g8($,Q,B),$)await RAA(Q,B)}async function aH0(A,Q,B,$){let J=Ni(A,Q),Y=W4();Y.start(`Running: ${J.command}`);try{let X=jZ(A);M6Q(Q,{recursive:!0,force:!0});let G=await Sw(X.command,[...X.args,"cap","add",Q]);if(G.error||G.status!==0)throw G.error??Error(`cap add ${Q} failed with ${LAA(G)}`);let K=await Sw(X.command,[...X.args,"cap","sync",Q]);if(K.error||K.status!==0)throw K.error??Error(`cap sync ${Q} failed with ${LAA(K)}`);Y.stop(B)}catch(X){Y.stop($),XA.error(hA(X))}}async function eDA(A,Q,B,$='Type "ready" when the manual fix is done.',J="ready"){XA.info(A);while(!0){let Y=await E5({message:$,placeholder:J,validate:(X)=>{if(!X?.trim())return'Type "ready" to retry.';if(X.trim().toLowerCase()!=="ready")return'Type "ready" to retry.'}});if(vB(Y)){await g8(Y,Q,B);continue}if(typeof Y==="string"&&Y.trim().toLowerCase()==="ready")return}}async function oH0(A,Q,B,$="ready"){await eDA(A,Q,B,'Type "ready" when the iOS folder is fixed.',$)}async function rH0(A,Q,B,$,J){let Y=Ni(A,"ios"),{doctor:X}=ly();pH0(Q,Y.summary,Y.command,X),iH0(J,Q,Y.command,X),await nH0(J,B,$);let G=await n1({message:"Would you like me to run this reset command for you now?",initialValue:!0});if(await g8(G,B,$),G){await aH0(A,"ios","iOS folder recreated and synced ✅","iOS folder reset failed ❌");return}await oH0(`We will wait while you fix the iOS folder yourself.
|
|
1313
1313
|
When you are ready, type "ready" and I will retry this step.`,B,$)}function sH0(A){if(!A)return"App ID is required";if(A.includes("--"))return'App ID cannot contain "--"';if(!MH0.test(A))return"Invalid format. Use reverse domain notation (e.g., com.example.app)"}function tH0(A){let Q=A?.trim();if(!Q)return"Channel name is required";if(!OH0.test(Q))return"Use only letters, numbers, dot, dash, or underscore"}function _AA(A){if(!A)return;let Q=A.trim();if(!Q||Q==="latest")return;if(OP(Q))return F5(X1(Q));let B=/\d+\.\d+\.\d+(?:-[0-9A-Z.-]+)?/i.exec(Q);if(!B?.[0])return;if(!OP(B[0]))return;return F5(X1(B[0]))}async function py(A="Enter your appId:"){let Q=await E5({message:A,validate:sH0});if(vB(Q))return X7("Operation cancelled."),O4(`Bye \uD83D\uDC4B
|
|
1314
1314
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();return Q}async function eH0(A,Q,B,$){let J=wAA(u1());if(J?.dir===u1())return;if(J){await H6Q();return}if($?.existing_app===!1){let Y=Z8(),X=$.name?.trim()||B;XA.info(`No Capacitor config was found for ${B}.`),XA.info("This app was created from the web onboarding as a new app.");let G=`${Y.runner} cap init "${X}" "${B}"`,K=await n1({message:`Do you want me to run "${G}" now?`,initialValue:!0});if(await g8(K,A,Q),K){let W=W4();W.start(`Running: ${Y.runner} cap init "${X}" "${B}"`);try{let H=TZ(Y.runner,["cap","init",X,B],{stdio:"pipe"});if(H.error)throw H.error;if(H.status!==0){let D=H.stderr?.toString().trim(),F=H.stdout?.toString().trim();throw Error(D||F||`cap init exited with code ${H.status}`)}W.stop("Capacitor init done ✅"),await tDA(B);return}catch(H){throw W.stop("Capacitor init failed ❌"),H}}}await H6Q()}async function A30(A,Q,B,$){let J=B?$.find((X)=>X.app_id===B):void 0;if(J){let X=await n1({message:`Use the pending onboarding app "${J.name||J.app_id}" (${J.app_id}) from the web console?`,initialValue:!0});return await g8(X,A,Q),X?J:void 0}if($.length===0)return;let Y=await I1({message:"A pending onboarding app already exists in Capgo. What do you want to do?",options:[...$.map((X)=>({value:X.app_id,label:`${X.name||X.app_id} (${X.app_id})`,hint:X.existing_app?"Existing app":"New app created from web onboarding"})),{value:"__create_new__",label:"Create a new app from the CLI"}]});if(await g8(Y,A,Q),Y==="__create_new__")return;return $.find((X)=>X.app_id===Y)}async function Q30(A,Q,B,$){let J=await zvA($,A.gid),Y=await A30(A.gid,Q,B,J);if(!Y)return{appId:B,pendingApp:void 0,reusedPendingApp:!1};let X=Y.app_id;if(XA.info(`Using pending onboarding app ${X}`),wAA(u1()))await lH0(X);let G=W4();G.start(`Preparing ${X} for real onboarding`);try{await iYA($,A.gid,X),G.stop("Pending onboarding app prepared ✅")}catch(K){throw G.stop("Could not prepare pending onboarding app ❌"),K}return await jJ(A.gid,Q,"add-app",X),{appId:X,pendingApp:Y,reusedPendingApp:!0}}async function yy(A,Q){let{allOrganizations:B,allowedOrganizations:$}=await mYA(A,Q,"org.create_app"),J=$.length>1?await I1({message:"Pick the organization that should own this app",options:$.map((G)=>{let K=G.enforcing_2fa&&!G["2fa_has_access"]?"2FA required":void 0;return{value:G.gid,label:G.name,hint:K}})}):$[0].gid;if(vB(J))return O4(`Bye \uD83D\uDC4B
|
|
1315
1315
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();let Y=J,X=B.find((G)=>G.gid===Y);if(!X)throw Error("Selected organization not found");if(X.enforcing_2fa&&!X["2fa_has_access"])throw XA.error(`The organization "${X.name}" requires all members to have 2FA enabled.`),XA.error(`Enable 2FA at ${FX("/settings/account")} and try again.`),Error("2FA required for selected organization");return XA.info(`Using organization "${X.name}" as the app owner`),X}async function B30(A,Q){XA.info("\uD83D\uDCCB Checking development environment prerequisites"),XA.info(" For mobile development, you need at least one platform setup");let B=uy==="darwin"&&RJ("/Applications/Xcode.app"),$=tz.HOME||tz.USERPROFILE||"~",Y=[tz.ANDROID_HOME,tz.ANDROID_SDK_ROOT,d4($,"Library","Android","sdk"),d4($,"Android","Sdk"),d4($,"AppData","Local","Android","Sdk")].filter(Boolean).some((X)=>X&&RJ(X));if(B)XA.success("✅ Xcode detected - iOS development ready");else if(uy==="darwin")XA.warn("⚠️ Xcode not found");if(Y)XA.success("✅ Android SDK detected - Android development ready");else XA.warn("⚠️ Android SDK not found");if(!B&&!Y){XA.error("❌ No development environment detected"),XA.info(""),XA.info("\uD83D\uDCF1 To develop mobile apps with Capacitor, you need:"),XA.info(" • For iOS: Xcode (macOS only) - https://developer.apple.com/xcode/"),XA.info(" • For Android: Android Studio - https://developer.android.com/studio"),XA.info("");let X=await n1({message:"Continue onboarding without a development environment? (You won't be able to build or test)",initialValue:!1});if(await g8(X,A,Q),!X)return XA.info("\uD83D\uDCDD Please install a development environment and run the onboarding again"),O4(`Bye \uD83D\uDC4B
|
|
@@ -1317,7 +1317,7 @@ When you are ready, type "ready" and I will retry this step.`,B,$)}function sH0(
|
|
|
1317
1317
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();if(G==="custom")return py("Enter your custom app ID (e.g., com.example.myapp):");let K=Number.parseInt(G.replace("suggest-",""),10);return X[K]}async function X30(A,Q,B,$){let J=Z8(),Y=B,X;while(!0){if(X!==Y){let G=await I1({message:`Add ${Y} to Capgo?`,options:[{value:"yes",label:"✅ Yes, add it"},{value:"change",label:"❌ No, use a different app ID"}]});if(await g8(G,A.gid,Q),G==="change"){Y=await py("Enter the correct app ID (e.g., com.example.app):"),X=void 0;continue}X=Y}try{let G=W4();G.start(`Running: ${J.runner} @capgo/cli@latest app add ${Y}`);try{await ck(Y,$,A,!0,"onboarding"),await tDA(Y)}catch(K){throw G.stop("App add failed ❌"),K}return await jJ(A.gid,Q,"add-app",Y),Y}catch(G){if(_w(G)){let K=await YB($.apikey??Q,$.supaHost,$.supaAnon),W=await J30(K,A,Q,Y,$);if(W==="use-existing")return await jJ(A.gid,Q,"add-app",Y),Y;if(W==="recreate"){X=Y;continue}if(W==="not-owned")XA.error(`❌ App ID "${Y}" is already taken`);Y=await Y30(K,A,Q,Y),X=void 0,XA.info(`\uD83D\uDD04 Trying with new app ID: ${Y}`);continue}throw G}}}async function G30(A,Q,B){let $=Z8();XA.success(`✅ App ${B} added — accessible to all members of your organization`),XA.info("\uD83D\uDCA1 A channel is a release track — it controls which users get which updates."),XA.info(" Nothing goes live until you release a native build with Capacitor Updater to the stores."),XA.info(' Most apps just need one: "production". You can add more later.'),XA.info(" Learn more: https://capgo.app/docs/live-updates/channels/");let J=dX,Y=await I1({message:"Which channel name do you want to use?",options:[{value:"default",label:`✅ Use "${pDA}"`},{value:"custom",label:"✏️ Choose a custom name"}]});if(await g8(Y,A,Q),Y==="custom"){let G=await E5({message:"Enter the channel name to use for onboarding:",placeholder:"e.g. staging, beta, dev",validate:tH0});await g8(G,A,Q),J=G.trim()}dX=J;let X=W4();X.start(`Running: ${$.runner} @capgo/cli@latest channel add ${J} ${B} --default`);try{if(!await BN(J,B,{default:!0,apikey:Q},!0))X.stop("Channel already added ✅");else X.stop("Channel add done ✅")}catch(G){throw X.stop("Channel creation failed ❌"),G}return await jJ(A,Q,"add-channel",B),J}function K30(A){E4=A}async function NAA(A){if(vB(A))return X7("Operation cancelled."),await X6(1)}function x6Q(A){let Q=A?.trim();if(!Q)return"Path is required.";if(!RJ(Q))return`Path ${Q} does not exist`;if(L6.basename(Q)!==W$)return"Selected a file that is not a package.json file"}async function W30(){let A=u1(),Q=W$;while(!0){let B=O6Q(A).map(($)=>({value:$,label:$}));if(B.push({value:"..",label:".."}),Q=await I1({message:"Select package.json file:",options:B}),await NAA(Q),typeof Q!=="string")continue;if(!N6Q(d4(A,Q)).isDirectory()&&Q!==W$){XA.error("Selected a file that is not a package.json file");continue}if(A=d4(A,Q),Q===W$)return A}}async function Z30(){let A=await E5({message:"Enter path to package.json file:",validate:x6Q});return await NAA(A),A.trim()}async function H30(){let A=await n1({message:"Would you like to select the package.json file manually?"});if(await NAA(A),!A)return null;let Q=eK();if(Q){let B=await aAQ();if(B){let $=x6Q(B);if(!$)return B;XA.error($)}XA.info("Falling back to manual path entry.")}if(!Q){let B=await n1({message:"Would you like to use a tree selector to choose the package.json file?"});if(await NAA(B),B)return W30()}return Z30()}async function q30(){let A=d4(W8(u1()),W$),Q=E4??A,B=await mW(void 0,Q);if(B.size===0||!B.has("@capacitor/core")){XA.warn("No adequate dependencies found");let $=await H30();if($)Q=$,B=await mW(void 0,Q)}return K30(Q),{dependencies:B,path:Q}}var D30="https://capacitorjs.com/docs/updating/5-0",F30="https://capacitorjs.com/docs/updating/6-0",U30="https://capacitorjs.com/docs/updating/7-0",z30="https://capacitorjs.com/docs/updating/8-0";function b6Q(A,Q){if(!A.has("@capacitor/core"))return"Cannot find @capacitor/core in package.json.";let B=A.get("@capacitor/core");if(!B)return"Cannot determine the installed @capacitor/core version.";let $=_AA(B);if(!$)return`Cannot parse @capacitor/core version "${B}". Pin a concrete semver version before continuing.`;if(WG(X1($),X1("5.0.0")))return`@capacitor/core version is ${$}. Capgo requires Capacitor v5 or newer. Migration guide: ${D30}`;if(Q.pm==="unknown")return"Cannot recognize the package manager for this project. Use bun, pnpm, yarn, or npm in a Capacitor project root.";return}function f6Q(A,Q=!0){if(WG(X1(A),X1("6.0.0"))){if(Q)XA.info(`@capacitor/core version is ${A}, installing compatible capacitor-updater v5`),XA.warn(`Consider upgrading to Capacitor v6 or higher to support the latest mobile OS features: ${F30}`);return{versionToInstall:"^5.0.0",shouldOfferDirectInstall:!1}}if(WG(X1(A),X1("7.0.0"))){if(Q)XA.info(`@capacitor/core version is ${A}, installing compatible capacitor-updater v6`),XA.warn(`Consider upgrading to Capacitor v7 or higher to support the latest mobile OS features: ${U30}`);return{versionToInstall:"^6.0.0",shouldOfferDirectInstall:!1}}if(WG(X1(A),X1("8.0.0"))){if(Q)XA.info(`@capacitor/core version is ${A}, installing compatible capacitor-updater v7`),XA.warn(`Consider upgrading to Capacitor v8 to support the latest mobile OS features: ${z30}`);return{versionToInstall:"^7.0.0",shouldOfferDirectInstall:!1}}if(Q)XA.info(`@capacitor/core version is ${A}, installing latest capacitor-updater`);return{versionToInstall:"latest",shouldOfferDirectInstall:!0}}function dDA(A,Q,B=!1){let $=B?" --force":"";return`${A.installCommand}${$} ${mX}@${Q}`}function q6Q(A){if(!A)return"";return typeof A==="string"?A:A.toString("utf8")}function v6Q(A,Q,B){let[$,...J]=A.installCommand.split(NH0).filter(Boolean);if(!$)throw Error("Cannot determine package manager install command");let Y=TZ($,[...J,"--force",`${mX}@${B}`],{stdio:"pipe",cwd:h7(Q)});if(Y.error||Y.status!==0){let X=[q6Q(Y.stdout),q6Q(Y.stderr)].map((W)=>W.trim()).filter(Boolean).join(`
|
|
1318
1318
|
`),G=X?`
|
|
1319
1319
|
${X}`:"",K=`Updater install failed with code ${Y.status??"unknown"}${G}`;throw Y.error??Error(K)}}function I30(A,Q,B){XA.warn(`${mX} is not ready yet.`);for(let $ of Q)XA.warn($);XA.info(`Run this in ${h7(A)}: ${B}`)}async function AFA(A,Q,B,$,J,Y={}){let X=dDA($,J);while(!0){let G=$N(B);if(G.ready)return XA.info(`${mX} found in package.json and node_modules ✅`),G;if(I30(B,G.details,X),Y.allowAutoRetry){if(await kw(A,Q,"Updater install is not complete yet. What do you want to do?",[{value:"retry-auto",label:"Retry automatic updater install"},{value:"manual",label:"Install it manually, then continue"}],Y.failureText??G.details.join(`
|
|
1320
|
-
`))==="retry-auto"){let W=W4();try{W.start(`Running: ${dDA($,J,!0)}`),v6Q($,B,J),W.stop("Updater install command finished ✅")}catch(H){W.stop("Updater install failed ❌"),XA.error(hA(H))}continue}}await eDA(`Install ${mX} manually, then come back here.`,A,Q,`Type "ready" when ${mX} is installed.`)}}async function C30(A,Q,B){let $=Z8(),J="1.0.0",Y=!1,X=await I1({message:"Install @capgo/capacitor-updater in your project?",options:[{value:"yes",label:"✅ Yes, install it"},{value:"no",label:"❌ No, I'll do it manually"}]});await g8(X,A,Q);while(!0){let{dependencies:G,path:K}=await q30(),W=b6Q(G,$);if(W){XA.warn(W),await kw(A,Q,"Fix the project, then choose what to do next.",[{value:"retry",label:"Retry updater checks"}],W);continue}let H=_AA(G.get("@capacitor/core")),{versionToInstall:D,shouldOfferDirectInstall:F}=f6Q(H);if(J=UX(void 0,K)||J,X==="yes"){let O=W4();if(O.start(`Checking if ${mX} is installed`),$N(K).ready)O.stop("Capgo already installed ✅");else try{v6Q($,K,D),O.stop("Install Done ✅")}catch(E){O.stop("Updater install failed ❌"),XA.error(hA(E))}}else XA.info(`Install it manually with: "${dDA($,D)}"`);await AFA(A,Q,K,$,D,{allowAutoRetry:X==="yes"});let U=!1;if(F)U=await n1({message:`Do you want to set instant updates in ${B}? Read more about it here: https://capgo.app/docs/live-updates/update-behavior/#applying-updates-immediately`}),await g8(U,A,Q);let z=W4();z.start("Updating config file"),Y=!!U;let I=h7(K);await hy(I,async()=>{if(U)await vk("SplashScreen",{launchAutoHide:!1});await $U(aDA(B,Y))}),z.stop("Config file updated ✅");break}return await jJ(A,Q,"add-updater",B),{pkgVersion:J,delta:Y}}async function O30(A,Q,B){let $=await I1({message:"Add the Capacitor Updater import to your main file?",options:[{value:"yes",label:"✅ Yes, add it"},{value:"no",label:"❌ No, I'll do it manually"}]});if(await g8($,A,Q),$==="yes"){let J=W4();J.start("Adding @capacitor-updater to your main file");let Y=L6.resolve(E4??d4(W8(u1()),W$)),X=h7(Y),G=(W)=>L6.isAbsolute(W)?W:d4(X,W),K=await $7({quiet:!0,packageJsonPath:Y});if(K==="nuxtjs-js"||K==="nuxtjs-ts"){let W=d4(X,"plugins");if(!RJ(W))UH0(W,{recursive:!0});let H;if(K==="nuxtjs-ts")H=d4(W,"capacitorUpdater.client.ts");else H=d4(W,"capacitorUpdater.client.js");let F=["import { CapacitorUpdater } from '@capgo/capacitor-updater'","","export default defineNuxtPlugin(() => {"," CapacitorUpdater.notifyAppReady()","})",""].join(`
|
|
1320
|
+
`),Y.supportPlatform)==="retry-auto"){let W=W4();try{W.start(`Running: ${dDA($,J,!0)}`),v6Q($,B,J),W.stop("Updater install command finished ✅")}catch(H){W.stop("Updater install failed ❌"),XA.error(hA(H))}continue}}await eDA(`Install ${mX} manually, then come back here.`,A,Q,`Type "ready" when ${mX} is installed.`)}}async function C30(A,Q,B){let $=Z8(),J="1.0.0",Y=!1,X=await I1({message:"Install @capgo/capacitor-updater in your project?",options:[{value:"yes",label:"✅ Yes, install it"},{value:"no",label:"❌ No, I'll do it manually"}]});await g8(X,A,Q);while(!0){let{dependencies:G,path:K}=await q30(),W=b6Q(G,$);if(W){XA.warn(W),await kw(A,Q,"Fix the project, then choose what to do next.",[{value:"retry",label:"Retry updater checks"}],W);continue}let H=_AA(G.get("@capacitor/core")),{versionToInstall:D,shouldOfferDirectInstall:F}=f6Q(H);if(J=UX(void 0,K)||J,X==="yes"){let O=W4();if(O.start(`Checking if ${mX} is installed`),$N(K).ready)O.stop("Capgo already installed ✅");else try{v6Q($,K,D),O.stop("Install Done ✅")}catch(E){O.stop("Updater install failed ❌"),XA.error(hA(E))}}else XA.info(`Install it manually with: "${dDA($,D)}"`);await AFA(A,Q,K,$,D,{allowAutoRetry:X==="yes"});let U=!1;if(F)U=await n1({message:`Do you want to set instant updates in ${B}? Read more about it here: https://capgo.app/docs/live-updates/update-behavior/#applying-updates-immediately`}),await g8(U,A,Q);let z=W4();z.start("Updating config file"),Y=!!U;let I=h7(K);await hy(I,async()=>{if(U)await vk("SplashScreen",{launchAutoHide:!1});await $U(aDA(B,Y))}),z.stop("Config file updated ✅");break}return await jJ(A,Q,"add-updater",B),{pkgVersion:J,delta:Y}}async function O30(A,Q,B){let $=await I1({message:"Add the Capacitor Updater import to your main file?",options:[{value:"yes",label:"✅ Yes, add it"},{value:"no",label:"❌ No, I'll do it manually"}]});if(await g8($,A,Q),$==="yes"){let J=W4();J.start("Adding @capacitor-updater to your main file");let Y=L6.resolve(E4??d4(W8(u1()),W$)),X=h7(Y),G=(W)=>L6.isAbsolute(W)?W:d4(X,W),K=await $7({quiet:!0,packageJsonPath:Y});if(K==="nuxtjs-js"||K==="nuxtjs-ts"){let W=d4(X,"plugins");if(!RJ(W))UH0(W,{recursive:!0});let H;if(K==="nuxtjs-ts")H=d4(W,"capacitorUpdater.client.ts");else H=d4(W,"capacitorUpdater.client.js");let F=["import { CapacitorUpdater } from '@capgo/capacitor-updater'","","export default defineNuxtPlugin(() => {"," CapacitorUpdater.notifyAppReady()","})",""].join(`
|
|
1321
1321
|
`),U=IAA(H);if(RJ(H)){let z=MF(H,"utf8");if(z.includes("CapacitorUpdater.notifyAppReady()"))J.stop(),EJ={filePath:U,created:!1,lines:[],note:"Already contains CapacitorUpdater.notifyAppReady() — no change needed"};else Pw(H,F,"utf8"),J.stop(),EJ={filePath:U,created:!1,lines:yDA(z,F,gDA)}}else Pw(H,F,"utf8"),J.stop(),EJ={filePath:U,created:!0,lines:yDA("",F,gDA)};RH(EJ)}else{let W=null;if(K==="unknown")W=await gk(!0,X);else{let z=K.endsWith("-ts"),I=lfA(K,z,X);W=I?G(I):I}if(!W||!RJ(W)){J.stop("Cannot find main file to install Updater plugin","neutral");let z=await E5({message:"Provide the correct relative path to your main file (JS or TS):",validate:(I)=>{if(!I||!RJ(G(I)))return"File does not exist. Please provide a valid path."}});if(vB(z))return X7("Operation cancelled."),await X6(1);W=G(z)}let D=MF(W,"utf8").toString(),U=D.match(CH0)?.pop();if(!U){J.stop("Cannot auto-inject code","neutral"),XA.warn(`❌ Cannot find import statements in ${W}`),XA.info("\uD83D\uDCA1 You'll need to add the code manually"),XA.info("\uD83D\uDCDD Add this to your main file:"),XA.info(` ${vDA}`),XA.info(` ${FAA}`),XA.info("\uD83D\uDCDA Or follow: https://capgo.app/docs/getting-started/add-an-app/");let z=await n1({message:"Continue without auto-injecting the code? (You'll add it manually)"});if(await g8(z,A,Q),!z)return O4(`Bye \uD83D\uDC4B
|
|
1322
1322
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();XA.info("⏭️ Skipping auto-injection - remember to add the code manually!"),await jJ(A,Q,"add-code-manual",B)}else if(D.includes(FAA))J.stop(),EJ={filePath:IAA(W),created:!1,lines:[],note:"Already contains CapacitorUpdater.notifyAppReady() — no change needed"},RH(EJ);else{let z=D.replace(U,`${U}
|
|
1323
1323
|
${vDA};
|
|
@@ -1330,14 +1330,14 @@ ${FAA};
|
|
|
1330
1330
|
`)}async function g6Q(A,Q,B){if(EJ)RH(EJ);let $=L6.resolve(E4??d4(W8(u1()),W$)),J=h7($),X=(await mW(void 0,$)).get("@capacitor/core"),G=_AA(X);if(!X)XA.warn("Cannot find @capacitor/core in package.json. It is likely that you are using a monorepo. Please NOTE that encryption is not supported in Capacitor V5.");let K=Z8(),W="https://capgo.app/docs/live-updates/encryption/",H=!1,D=!1;while(!0){let I=[{value:"not_needed",label:"❌ No, my app doesn't need this"},{value:"critical",label:"\uD83D\uDD10 Yes — set up end-to-end encryption"}];if(!D)I.push({value:"learn",label:"❓ What is encryption? (learn more)"});let O=await I1({message:`Is ${B} a security-critical app, like banking, regulated, or sensitive-data handling?`,options:I});if(await g8(O,A,Q),EJ)EJ=void 0,RH(void 0);if(O==="learn"){D=!0,XA.info("\uD83D\uDD10 End-to-end encryption in Capgo (fast overview):"),XA.info(" • Capgo bundles are plain web assets (JS / HTML / CSS) served over HTTPS."),XA.info(" • Without encryption, anyone who obtains a bundle URL can download and read them."),XA.info(" • Capgo's encryption uses a hybrid RSA + AES scheme:"),XA.info(" – A random AES session key encrypts the bundle contents."),XA.info(" – Your RSA private key encrypts that AES key and signs a checksum."),XA.info(" – The public RSA key shipped in your app decrypts + verifies it."),XA.info(" • True end-to-end: the private key lives only on your machine, so not even"),XA.info(" Capgo can read the bundle contents."),XA.info(" • Requires Capacitor v6+. Debugging update failures is slightly harder once enabled."),XA.info(" • Recommended for banking, healthcare, regulated, or sensitive-data apps."),XA.info(" Most other apps do not need it."),XA.info(`
|
|
1331
1331
|
\uD83D\uDCD6 Full docs: ${W}`);let V=await n1({message:"Open the full encryption docs in your browser now?",initialValue:!1});if(await g8(V,A,Q),V)try{await n6(W),XA.info(` \uD83C\uDF10 Opened ${W}`)}catch{XA.warn(`Could not open your browser automatically. Visit: ${W}`)}continue}H=O==="critical";break}let F={phase:"pending-sync",title:"\uD83D\uDD10 Encryption keys generated — awaiting cap sync",lines:[" • Private RSA key saved locally (.capgo_key_v2) — do not commit it."," • Public RSA key written to capacitor.config — not bundled in the native app yet."," • Encrypted updates will FAIL until the native project is synced.",` • Step 7 runs "${K.runner} cap sync" automatically, which bundles the key.`]},z={phase:"skipped",title:"⏭️ Encryption SKIPPED",lines:[" • Bundles are plain JS / HTML / CSS, fetchable by anyone who finds the URL."," • Never put private API keys or backend secrets in a mobile app.",` • You can enable encryption later with: ${K.runner} @capgo/cli@latest key create`]};if(H){if(X&&!G){XA.error(`Cannot parse @capacitor/core version "${X}". Pin a concrete semver version before enabling encryption.`);return}if(G&&WG(X1(G),X1("6.0.0"))){XA.warn("Encryption is not supported in Capacitor V5.");return}let I=W4();I.start("Creating RSA encryption keys");try{let O=u1();try{JN(J),await fy({force:!0,setupChannel:!1},!0)}finally{JN(O)}I.stop(),await OF(A,Q,"Use encryption v2",B),await u6Q(K,A,Q,$);let V=await M30({title:"\uD83D\uDD10 Syncing native project so the public key is bundled",runner:K.runner,args:["cap","sync"],cwd:J});if(await N30(3500),lcA(),V.success)z={phase:"enabled",title:"\uD83D\uDD10 Encryption ENABLED",lines:[" • Private RSA key stays on your machine — do not commit it."," • Public RSA key is bundled in the app (extractable by reverse engineering)."," • Bundles encrypted with a random AES key, key wrapped with your RSA key."," • Bundle checksum is signed with your RSA key so the app can verify integrity."]};else XA.warn(`cap sync failed: ${V.error?.message??"unknown error"}`),XA.warn("Encryption keys were generated but the native project has not been synced yet."),XA.info("Step 7 will run the build and cap sync again — if that succeeds, encryption becomes fully active."),z=F}catch(O){I.stop("Error","error");let V=O instanceof Error?O.message:String(O);if(XA.warn(`Cannot create key ❌ ${V}`),await kw(A,Q,"Encryption key creation failed. What do you want to do?",[{value:"retry",label:"Retry key creation"},{value:"skip",label:"Continue without encryption"}],V)==="retry")return g6Q(A,Q,B);z={phase:"failed",title:"⚠️ Encryption NOT ENABLED (key creation failed)",lines:[" • Key creation failed and you chose to continue without encryption.",` • You can retry later with: ${K.runner} @capgo/cli@latest key create`," • Meanwhile, never put API keys or backend secrets in the bundle."]}}}JW=z,CU(z),await jJ(A,Q,"add-encryption",B)}async function M30(A){let Q;try{Q=jZ(A.runner)}catch(G){return{success:!1,error:G instanceof Error?G:Error(String(G))}}let{command:B,args:$}=Q,J=[...$,...A.args],Y=`${A.runner} ${A.args.join(" ")}`;ccA({title:A.title,command:Y});let X=(G)=>{let K=typeof G==="string"?G:G.toString("utf8");for(let W of K.split(/\r?\n/)){let H=W.replace(/\r/g,"");if(H.length>0)dcA(H)}};return new Promise((G)=>{let K;try{K=VAA(B,J,{cwd:A.cwd,stdio:["ignore","pipe","pipe"]})}catch(W){pS("error",W instanceof Error?W.message:String(W)),G({success:!1,error:W instanceof Error?W:Error(String(W))});return}K.stdout?.on("data",X),K.stderr?.on("data",X),K.once("error",(W)=>{pS("error",W.message),G({success:!1,error:W})}),K.once("close",(W)=>{if(W===0){pS("success","Done"),G({success:!0});return}let H=Error(`Command exited with code ${W??"unknown"}`);pS("error",H.message),G({success:!1,error:H})})})}function N30(A){return new Promise((Q)=>setTimeout(Q,A))}function L30(){if(!JW||JW.phase!=="pending-sync")return;let A={phase:"enabled",title:"\uD83D\uDD10 Encryption ENABLED",lines:[" • Private RSA key stays on your machine — do not commit it."," • Public RSA key is bundled in the app (extractable by reverse engineering)."," • Bundles encrypted with a random AES key, key wrapped with your RSA key."," • Bundle checksum is signed with your RSA key so the app can verify integrity."]};JW=A,CU(A)}var J8={refresh:"__refresh__",simulator:"__simulator__",skip:"__skip__"},y6Q=/\(simulator\)$/i,V30=new Set(["?"]),D6Q=30000;async function E30(A,Q,B,$=u1()){let J=n8(B,["cap","add",A]);while(!0){let Y=EAA(Q,$);if(A==="ios"?Y.ios:Y.android)return;let G=A==="ios"?Y.iosDir:Y.androidDir;XA.warn(`⚠️ ${G}/ is missing, so Capgo cannot build the ${A.toUpperCase()} project yet.`);let K=await I1({message:`How do you want to continue with ${A.toUpperCase()}?`,options:[{value:"add",label:`\uD83D\uDEE0 Run ${J} now`},{value:"doctor",label:"Run doctor diagnostics now"},{value:"exit",label:"Exit onboarding"}]});if(vB(K)||K==="exit")return O4(`Bye \uD83D\uDC4B
|
|
1332
1332
|
\uD83D\uDCA1 Run "${J}", then try again.`),await X6();if(K==="doctor"){await P6Q();continue}if(!await MAA(A,B,$))XA.warn(`Still could not add ${A}.`)}}async function R30(A,Q,B,$,J,Y){let X=W4();X.start("Checking project type"),X.stop("Missing build script","neutral"),XA.warn(`❌ Cannot find "${A}" script in package.json`),XA.info(`\uD83D\uDCA1 Your package.json needs a "${A}" script to build the app`);let G=await n1({message:"Would you like to skip the build for now and continue? You can build manually later."});if(await g8(G,$,J),G)return XA.info(`⏭️ Skipping build step - you can build manually with: ${Y.pm} run ${A}`),XA.info(`\uD83D\uDCDD After building, run: ${Y.runner} cap sync ${B}`),await jJ($,J,"build-project-skipped",Q),"skipped";return O4(`Bye \uD83D\uDC4B
|
|
1333
|
-
\uD83D\uDCA1 Add a "${A}" script to package.json and run the command again`),await X6()}async function h6Q(A,Q){try{let B=await mW(void 0,A);if(b6Q(B,Q))return"latest";let J=_AA(B.get("@capacitor/core"));return f6Q(J,!1).versionToInstall}catch{return"latest"}}async function j30(A,Q,B,$,J,Y,X){let G=hA(X),K=$N(B);if(XA.error(`Build or sync failed: ${G}`),!K.ready){XA.warn(`Capacitor sync cannot wire ${mX} until it is declared and installed.`);let H=await h6Q(B,$);return await AFA(J,Y,B,$,H,{failureText:G}),"retry"}if(await kw(J,Y,"Build or sync failed. What do you want to do?",[{value:"retry",label:"Retry build and sync"},{value:"manual",label:"Fix it manually, then continue"}],G)==="retry")return"retry";return await eDA(`Run or fix this command manually, then come back here:
|
|
1333
|
+
\uD83D\uDCA1 Add a "${A}" script to package.json and run the command again`),await X6()}async function h6Q(A,Q){try{let B=await mW(void 0,A);if(b6Q(B,Q))return"latest";let J=_AA(B.get("@capacitor/core"));return f6Q(J,!1).versionToInstall}catch{return"latest"}}async function j30(A,Q,B,$,J,Y,X){let G=hA(X),K=$N(B);if(XA.error(`Build or sync failed: ${G}`),!K.ready){XA.warn(`Capacitor sync cannot wire ${mX} until it is declared and installed.`);let H=await h6Q(B,$);return await AFA(J,Y,B,$,H,{failureText:G,supportPlatform:A}),"retry"}if(await kw(J,Y,"Build or sync failed. What do you want to do?",[{value:"retry",label:"Retry build and sync"},{value:"manual",label:"Fix it manually, then continue"}],G,A)==="retry")return"retry";return await eDA(`Run or fix this command manually, then come back here:
|
|
1334
1334
|
${Q}`,J,Y,'Type "ready" when build and sync are done.'),"retry"}async function u6Q(A,Q,B,$){let J=$N($);if(J.ready)return;XA.warn(`Capacitor sync needs ${mX} declared in package.json and installed first.`);let Y=await h6Q($,A);await AFA(Q,B,$,A,Y,{failureText:J.details.join(`
|
|
1335
1335
|
`)})}async function w30(A,Q,B,$,J,Y,X){let G=0;while(!0){await u6Q(J,Y,X,$);let K=W4();K.start("Preparing build and sync");let W=B===u1()?`Running: ${Q}`:`Running in ${B}: ${Q}`;K.stop(W,"neutral");try{let H=await S30(Q,{cwd:B});if(H.error||H.status!==0)throw H.error??Error(`Build or sync command failed with ${LAA(H)}`)}catch(H){if(XA.error("Build or sync failed ❌"),await j30(A,Q,$,J,Y,X,H)==="completed")return;continue}if(A==="ios"){let H=dYA(B,$);if(H.shouldCheck&&!H.valid){G+=1,K.stop("iOS sync check failed ❌"),await rH0(J.runner,H.details,Y,X,G),XA.info(`Retrying build and sync for iOS (attempt ${G+1})`);continue}}K.stop("Build & Sync Done ✅"),L30();return}}async function _30(A,Q,B,$,J){let Y=L6.resolve(E4??d4(W8(u1()),W$)),X=h7(Y),G=await $7({packageJsonPath:Y}),K=await DG(G);if(!WK(void 0,Y)[K])return R30(K,A,Q,B,$,J);let H=`${J.pm} run ${K} && ${J.runner} cap sync ${Q}`;return await w30(Q,H,X,Y,J,B,$),"completed"}async function P30(A,Q,B,$,J){let Y=Z8(),X=L6.resolve(E4??d4(W8(u1()),W$)),G=h7(X);await E30($,J,Y.runner,G);let K=await n1({message:`Automatic build ${B} with "${Y.pm} run build" ?`});if(await g8(K,A,Q),!K){XA.info(`Build yourself in ${G} with command: ${Y.pm} run build && ${Y.runner} cap sync ${$}`),await jJ(A,Q,"build-project",B);return}if(await _30(B,$,A,Q,Y)==="skipped")return;await jJ(A,Q,"build-project",B)}function QFA(A,Q,B){let $=jZ(A);return TZ($.command,[...$.args,...Q],B)}async function F6Q(A,Q,B={}){let $=jZ(A);return Sw($.command,[...$.args,...Q],B)}async function Sw(A,Q,B={}){if(B.forcePty||BW.isTTY&&cX.isTTY)return k30(A,Q,B);return T30(A,Q,B)}function T30(A,Q,B={}){return new Promise(($)=>{let J=!1,Y=(G)=>{if(J)return;J=!0,$(G)},X;try{X=VAA(A,Q,{cwd:B.cwd,stdio:["inherit","pipe","pipe"]})}catch(G){Y({status:null,signal:null,error:G instanceof Error?G:Error(String(G))});return}X.stdout?.on("data",(G)=>cX.write(G)),X.stderr?.on("data",(G)=>IH0.write(G)),X.once("error",(G)=>Y({status:null,signal:null,error:G})),X.once("close",(G,K)=>Y({status:G,signal:K}))})}function U6Q(A,Q,B={}){return new Promise(($)=>{let J;try{J=VAA(A,Q,{cwd:B.cwd,stdio:"inherit"})}catch(Y){$({status:null,signal:null,error:Y instanceof Error?Y:Error(String(Y))});return}J.once("error",(Y)=>$({status:null,signal:null,error:Y})),J.once("close",(Y,X)=>$({status:Y,signal:X}))})}async function k30(A,Q,B={}){let $;try{({spawn:$}=await import("node-pty"))}catch{return U6Q(A,Q,B)}return new Promise((J)=>{let Y=!1,X,G,K=(F)=>G?.write(F),W=()=>{try{G?.resize(cX.columns||100,cX.rows||30)}catch{}},H=()=>{if(cX.off("resize",W),BW.off("data",K),BW.isTTY&&typeof X==="boolean")BW.setRawMode?.(X)},D=(F)=>{if(Y)return;Y=!0,H(),J(F)};try{G=$(A,Q,{cols:cX.columns||100,cwd:B.cwd||u1(),env:tz,name:tz.TERM||"xterm-256color",rows:cX.rows||30})}catch{H(),U6Q(A,Q,B).then(J);return}if(G.onData((F)=>cX.write(F)),G.onExit(({exitCode:F,signal:U})=>D({status:F,signal:U??null})),cX.on("resize",W),BW.on("data",K),BW.isTTY)X=BW.isRaw,BW.setRawMode?.(!0),BW.resume()})}function S30(A,Q={}){let B=uy==="win32"?tz.ComSpec||"cmd.exe":"/bin/sh";return Sw(B,uy==="win32"?["/d","/s","/c",A]:["-c",A],Q)}function LAA(A){if(A.error)return hA(A.error);if(A.signal)return`signal ${A.signal}`;return`exit code ${A.status??"unknown"}`}function lDA(A){if(!A)return"";return typeof A==="string"?A.trim():A.toString("utf8").trim()}function x30(A){let Q=A.trim();if(!Q||Q.startsWith("["))return Q;let B=Q.indexOf("["),$=Q.lastIndexOf("]");return B>=0&&$>B?Q.slice(B,$+1):Q}function b30(A){let Q=x30(A);if(!Q)return{targets:[],error:Error("Capacitor returned no target list output.")};let B;try{B=JSON.parse(Q)}catch{return{targets:[],error:Error("Capacitor returned an invalid target list.")}}if(!Array.isArray(B))return{targets:[],error:Error("Capacitor returned target list data in an unexpected format.")};return{targets:B.filter((J)=>typeof J==="object"&&J!==null).map((J)=>{let Y=typeof J.id==="string"?J.id.trim():"",X=typeof J.name==="string"?J.name.trim():"",G=typeof J.api==="string"?J.api.trim():void 0;return{id:Y,name:X||Y,api:G}}).filter((J)=>J.id.length>0&&!V30.has(J.id)&&J.name.length>0)}}function f30(A){return A.filter((Q)=>!y6Q.test(Q.name))}function v30(A){return A.filter((Q)=>y6Q.test(Q.name))}function m6Q(){let A=tz.CAPGO_RUN_DEVICE_LIST_TIMEOUT_MS;if(!A)return D6Q;let Q=Number.parseInt(A,10);return Number.isFinite(Q)&&Q>0?Q:D6Q}function g30(A,Q,B,$=u1()){let J;try{J=jZ(A)}catch(Y){return Promise.resolve({stdout:"",stderr:"",status:null,signal:null,error:Y instanceof Error?Y:Error(String(Y))})}return new Promise((Y)=>{let X="",G="",K=!1,W,H=(F)=>{if(K)return;if(K=!0,W)clearTimeout(W);Y({stdout:X,stderr:G,...F})},D=VAA(J.command,[...J.args,...Q],{stdio:["ignore","pipe","pipe"],cwd:$});W=setTimeout(()=>{D.kill("SIGTERM"),H({status:null,signal:"SIGTERM",timedOut:!0})},B),D.stdout?.on("data",(F)=>X+=F.toString()),D.stderr?.on("data",(F)=>G+=F.toString()),D.on("error",(F)=>H({status:null,signal:null,error:F})),D.on("close",(F,U)=>H({status:F,signal:U}))})}function z6Q(A,Q,B){let J=n8(A,["cap","run",Q,"--list","--json"]),Y=lDA(B.stderr)||lDA(B.stdout);if(B.timedOut){let X=Math.max(1,Math.ceil(m6Q()/1000));return Error(`Timed out after ${X}s while checking ${Q} targets. Run manually to see the native error: ${J}`)}if(B.error)return Error(`${hA(B.error)}. Run manually to see the native error: ${J}`);return Error(Y||`cap run ${Q} --list exited with code ${B.status??"unknown"}. Run manually to see the native error: ${J}`)}async function y30(A,Q,B=u1()){try{let $=["cap","run",Q,"--list","--json"],J=await g30(A,$,m6Q(),B);if(J.timedOut||J.error)return{targets:[],error:z6Q(A,Q,J)};if(J.status!==0)return{targets:[],error:z6Q(A,Q,J)};let Y=b30(lDA(J.stdout));if(Y.error)return{targets:[],error:Error(`${hA(Y.error)} Run manually to see the native output: ${n8(A,$)}`)};return Y}catch($){return{targets:[],error:$ instanceof Error?$:Error(String($))}}}async function BFA(A,Q,B,$=u1()){let J=W4();J.start(B),await new Promise((Y)=>setTimeout(Y,0));try{let Y=await y30(A.runner,Q,$);if(Y.error)J.stop("Device check failed ❌","error");else J.stop();return Y}catch(Y){return J.stop("Device check failed ❌","error"),{targets:[],error:Y instanceof Error?Y:Error(String(Y))}}}function $FA(A,Q,B){let $=["cap","run",Q];if(B)$.push("--target",B.id);return{args:$,command:n8(A.runner,$)}}function xw(A,Q){let B=["cap","run",Q];return{args:void 0,command:n8(A.runner,B)}}async function h30(A,Q,B){let $=await I1({message:"Which physical iOS device do you want to run on?",options:[...B.map((Y)=>({value:Y.id,label:Y.name,hint:Y.id})),{value:J8.refresh,label:"Reload list"},{value:J8.simulator,label:"Use iOS Simulator instead"},{value:J8.skip,label:"Skip running now"}]});if(vB($))await A();if($===J8.refresh)return J8.refresh;if($===J8.simulator)return J8.simulator;if($===J8.skip)return xw(Q,"ios");let J=B.find(({id:Y})=>Y===$);if(J)return $FA(Q,"ios",J);return XA.warn("That iOS device is no longer available. Checking again."),J8.refresh}async function u30(A,Q,B){XA.warn(B?"The iOS device list is unavailable right now.":"No physical iOS device detected yet.");let $=await I1({message:B?"Fix the error above, then reload the list.":"Connect and unlock your iPhone, then check again.",options:[{value:J8.refresh,label:"Reload list"},{value:J8.simulator,label:"Use iOS Simulator instead"},{value:J8.skip,label:"Skip running now"}]});if(vB($))await A();if($===J8.refresh)return J8.refresh;if($===J8.simulator)return J8.simulator;return xw(Q,"ios")}async function m30(A,Q,B){let $=await I1({message:"Which iOS Simulator do you want to run on?",options:[...B.map((Y)=>({value:Y.id,label:Y.name,hint:Y.id})),{value:J8.refresh,label:"Reload list"},{value:J8.skip,label:"Skip running now"}]});if(vB($))await A();if($===J8.refresh)return J8.refresh;if($===J8.skip)return xw(Q,"ios");let J=B.find(({id:Y})=>Y===$);if(J)return $FA(Q,"ios",J);return XA.warn("That iOS Simulator is no longer available. Checking again."),J8.refresh}async function c30(A,Q,B){XA.warn(B?"The iOS Simulator list is unavailable right now.":"No iOS Simulator detected yet.");let $=await I1({message:B?"Fix the error above, then reload the list.":"Open Xcode or install a simulator, then check again.",options:[{value:J8.refresh,label:"Reload list"},{value:J8.skip,label:"Skip running now"}]});if(vB($))await A();if($===J8.refresh)return J8.refresh;return xw(Q,"ios")}async function c6Q(A,Q,B,$=u1()){let J=B;while(!0){let Y=J?{targets:J}:await BFA(Q,"ios","Checking iOS Simulators...",$);if(J=void 0,"error"in Y&&Y.error)XA.warn(`Could not check iOS Simulators: ${hA(Y.error)}`);let X=v30(Y.targets),G=X.length>0?await m30(A,Q,X):await c30(A,Q,Y.error);if(G===J8.refresh)continue;return G}}async function d30(A,Q,B=u1()){XA.info("Connect your iPhone or iPad, unlock it, and tap Trust if prompted.");while(!0){let $=await BFA(Q,"ios","Checking connected iOS devices...",B);if($.error)XA.warn(`Could not check connected iOS devices: ${hA($.error)}`);let J=f30($.targets),Y=J.length>0?await h30(A,Q,J):await u30(A,Q,$.error);if(Y===J8.refresh)continue;if(Y===J8.simulator)return c6Q(A,Q,$.targets,B);return Y}}function d6Q(A){return A==="ios"?"iOS device or simulator":"Android device or emulator"}async function l30(A,Q,B,$){let J=d6Q(B),Y=await I1({message:`Which ${J} do you want to run on?`,options:[...$.map((G)=>({value:G.id,label:G.name,hint:G.id})),{value:J8.refresh,label:"Reload list"},{value:J8.skip,label:"Skip running now"}]});if(vB(Y))await A();if(Y===J8.refresh)return J8.refresh;if(Y===J8.skip)return xw(Q,B);let X=$.find(({id:G})=>G===Y);if(X)return $FA(Q,B,X);return XA.warn(`That ${J} is no longer available. Checking again.`),J8.refresh}async function p30(A,Q,B,$){let J=d6Q(B);XA.warn($?`The ${J} list is unavailable right now.`:`No ${J} detected yet.`);let Y=await I1({message:$?"Fix the error above, then reload the list.":"Connect or start one, then reload the list.",options:[{value:J8.refresh,label:"Reload list"},{value:J8.skip,label:"Skip running now"}]});if(vB(Y))await A();if(Y===J8.refresh)return J8.refresh;return xw(Q,B)}async function i30(A,Q,B,$=u1()){while(!0){let J=await BFA(Q,B,"Checking available Android devices and emulators...",$);if(J.error)XA.warn(`Could not check available devices: ${hA(J.error)}`);let Y=J.targets.length>0?await l30(A,Q,B,J.targets):await p30(A,Q,B,J.error);if(Y===J8.refresh)continue;return Y}}async function JFA(A,Q,B,$=u1()){if(B!=="ios")return i30(A,Q,B,$);let J=await I1({message:"Where do you want to run the iOS app?",options:[{value:"physical",label:"Physical iPhone or iPad"},{value:"simulator",label:"iOS Simulator"}]});if(vB(J))await A();if(J==="simulator")return c6Q(A,Q,void 0,$);return d30(A,Q,$)}function n30(A,Q=u1()){let B=EAA(A,Q),$=[];if(B.ios)$.push({value:"ios",label:"IOS"});if(B.android)$.push({value:"android",label:"Android"});return $}async function a30(A,Q,B){let $=await I1({message:"Which platform do you want to test with during this onboarding?",options:B});if(vB($))await RAA(A,Q);let J=$;return XA.info(`\uD83C\uDFAF Testing with: ${J.toUpperCase()}`),XA.info(`\uD83D\uDCA1 Note: Onboarding builds will use ${J} only`),await jJ(A,Q,"select-platform",J),J}async function o30(A,Q,B,$=u1()){let{pm:J,capAddAndroid:Y,capAddIos:X}=ly();XA.warn(`⚠️ No native platform directories found (${B.iosDir}/ or ${B.androidDir}/).`);let G=await I1({message:"Add a native platform before choosing a test platform.",options:[{value:"add-ios",label:`\uD83D\uDEE0 Run ${X} now`},{value:"add-android",label:`\uD83D\uDEE0 Run ${Y} now`},{value:"doctor",label:"Run doctor diagnostics now"},{value:"exit",label:"Exit onboarding"}]});if(vB(G)||G==="exit")await RAA(A,Q,`Run "${X}" or "${Y}", then try again.`);if(G==="doctor"){await P6Q();return}let K=G==="add-ios"?"ios":"android";if(!await MAA(K,J.runner,$))XA.warn(`Still could not add ${K}.`)}function l6Q(A){let Q=A.toLowerCase();if(Q==="ios"||Q==="android")return Q;throw Error('Platform must be "ios" or "android".')}async function r30(A,Q,B,$=u1()){XA.info("\uD83D\uDCF1 Platform selection for onboarding"),XA.info(" This is just for testing during onboarding - your app will work on all platforms");while(!0){let J=n30(B,$);if(J.length>0)return a30(A,Q,J);await o30(A,Q,EAA(B,$),$)}}async function s30(A,Q,B,$,J=u1()){let Y=Z8(),X=await n1({message:`Run ${B} on ${$.toUpperCase()} device now to test the initial version?`});if(await g8(X,A,Q),X){let G=await JFA(()=>RAA(A,Q),Y,$,J);if(!G.args){XA.info(`Skipped device launch. You can run it manually in ${J} with: ${G.command}`),await jJ(A,Q,"run-device",B);return}let K=W4(),W=J===u1()?`Running: ${G.command}`:`Running in ${J}: ${G.command}`;K.start(W);let H,D;try{H=await F6Q(Y.runner,G.args,{cwd:J})}catch(U){D=U instanceof Error?U:Error(String(U))}if(D||H?.error||H?.status!==0){let U=$==="ios"?"iOS":"Android";if(K.stop("App failed to start ❌"),DB(`app run failed (${U}): ${D||H?.error?hA(D??H?.error):`exit status ${H?.status??"unknown"}`}`),D||H?.error)XA.error(hA(D??H?.error));XA.error(`The app failed to start on your ${U} device.`);let z=await n1({message:`Would you like to open ${$==="ios"?"Xcode":"Android Studio"} to run the app manually?`});if(!vB(z)&&z){let I=W4();I.start(`Opening ${$==="ios"?"Xcode":"Android Studio"}...`);try{let O=await F6Q(Y.runner,["cap","open",$],{cwd:J});if(O.error||O.status!==0){if(I.stop(`Could not open ${$==="ios"?"Xcode":"Android Studio"} ❌`),O.error)XA.error(hA(O.error));XA.info(`You can run the app manually in ${J} with: ${G.command}`)}else I.stop("IDE opened ✅"),XA.info(`Please run the app manually from ${$==="ios"?"Xcode":"Android Studio"}`)}catch(O){I.stop(`Could not open ${$==="ios"?"Xcode":"Android Studio"} ❌`),XA.error(hA(O)),XA.info(`You can run the app manually in ${J} with: ${G.command}`)}}else XA.info(`You can run the app manually in ${J} with: ${G.command}`)}else K.stop("App started ✅"),XA.info(`\uD83D\uDCF1 Your app should now be running on your ${$} device with Capgo integrated`),XA.info("\uD83D\uDD04 This is your baseline version - we'll create an update next")}else XA.info(`If you change your mind, run it for yourself in ${J} with: ${Y.runner} cap run ${$}`);await jJ(A,Q,"run-device",B)}async function t30(A,Q,B,$,J){XA.info("\uD83C\uDFAF Now let's test Capgo by making a visible change and deploying an update!");let Y=L6.resolve(E4??d4(W8(u1()),W$)),X=h7(Y),G=await I1({message:"How would you like to test the update?",options:[{value:"auto",label:"Auto: Let Capgo CLI make a visible change for you"},{value:"manual",label:"Manual: I'll make changes myself"}]});if(vB(G))return await OF(A,Q,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1336
1336
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();if(G==="auto"){let V=W4();V.start("Making automatic changes to test Capgo updates");let E=!1,M=["src/index.html","public/index.html","index.html","src/App.vue","src/app/app.component.html","src/app/home/home.page.html","src/main.css","src/style.css","public/style.css"];for(let N of M){let R=d4(X,N);if(RJ(R)&&!E)try{let T=MF(R,"utf8"),x=rDA(N,T);if(x){Pw(R,x.content,"utf8");let m=IAA(R);V.stop(`✅ Made test changes to ${m}`),XA.info("\uD83D\uDCDD Added visible test modification to verify the update works"),YW={filePath:R,displayPath:m,kind:x.kind},vG(8),E=!0;break}}catch{}}if(!E){V.stop("⚠️ Could not automatically modify files","neutral"),XA.warn("Please make a visible change manually (like editing a text or color)");let N=await n1({message:"Continue after making your changes?"});await g8(N,A,Q)}}else{XA.info("✋ Please make a visible change to your app now (example: change a text, color, or add an element)"),XA.info("\uD83D\uDCA1 This change will help you see that Capgo updates work correctly");let V=await n1({message:"Have you made your changes and ready to continue?"});await g8(V,A,Q)}let K=w6Q($),W=oDA($);if(XA.info("\uD83D\uDD22 OTA update versioning:"),K===my&&$!==my)XA.info(` Init pinned CapacitorUpdater.version to ${my} for this guided test.`),XA.info(` Keep the first OTA upload on major 0 (for example ${K} → ${W}) to avoid channel major-gate blocks.`);else XA.info(` Each upload must use a new version (for example ${K} → ${W})`);let H=await I1({message:"How do you want to handle the version for this update?",options:[{value:"auto",label:`Auto: Bump patch version (${K} → ${W})`},{value:"manual",label:"Manual: I'll provide the version number"}]});if(vB(H))return await OF(A,Q,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1337
1337
|
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();let D;if(H==="auto")D=W,XA.info(`\uD83D\uDD22 Auto-bumped version from ${K} to ${D}`);else{let V=await E5({message:K===$?`Current version is ${K}. Enter new version:`:`Guided OTA baseline is ${K}. Enter a new 0.x.x version:`,validate:(E)=>{if(!E?.match(/^\d+\.\d+\.\d+/))return"Please enter a valid version (x.y.z)"}});if(vB(V))return await OF(A,Q,"canceled",void 0,"\uD83E\uDD37"),O4(`Bye \uD83D\uDC4B
|
|
1338
|
-
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();D=V}XA.info(`\uD83E\uDDED This OTA upload will use version ${D}. For the next test, increment it again.`);let F=Z8(),U=await $7({packageJsonPath:Y}),z=await DG(U),I=()=>{XA.info(`Build web assets manually in ${X} with: ${F.pm} run ${z}`),XA.warn(`Do NOT run "${F.runner} cap sync ${J}" for this OTA test.`),XA.warn(`Why: "${F.runner} cap sync ${J}" copies the current web build into the native project and regenerates native plugin files.`),XA.warn("If you sync now, the native app already contains your new change before Capgo download, so you cannot verify OTA behavior."),XA.info("Sync is safe again only after you confirmed the OTA update on device, or when preparing a new native/App Store build.")},O=await n1({message:`Build ${B} web assets before uploading with "${F.pm} run ${z}"? (no cap sync)`});if(await g8(O,A,Q),O){let V=W4();if(V.start(`Running in ${X}: ${F.pm} run ${z}`),!WK(void 0,Y)[z]){V.stop("Missing build script","neutral"),XA.warn(`❌ Cannot find "${z}" script in package.json`),XA.info("\uD83D\uDCA1 Build manually in another terminal, then come back and continue"),I();let M=await n1({message:"Have you built the app manually? (If not, we'll skip the build)"});if(await g8(M,A,Q),!M)XA.warn("⚠️ Continuing without build - upload may fail if app isn't built"),I();else XA.info("✅ Great! Continuing with your manual build")}else try{let M=TZ(F.pm,["run",z],{stdio:"pipe",cwd:X});if(M.error)throw M.error;if(M.status!==0)throw Error(`Build command "${F.pm} run ${z}" failed with exit code ${M.status??"unknown"}`);V.stop("✅ Build with changes completed"),XA.info("\uD83D\uDCE6 Your modifications are built and ready for OTA upload")}catch{V.stop("Build failed ❌"),XA.warn("Automatic build failed."),I();let M=await n1({message:"Have you built the app manually now? (If not, we will continue without build)"});if(await g8(M,A,Q),!M)XA.warn("⚠️ Continuing without build - upload may fail if app isn't built")}}else I();return await jJ(A,Q,"add-code-change",B),D}function e30(A){try{return F5(O2(X1(A),"patch"))}catch{return"1.0.2"}}async function Aq0(A,Q,B,$,J,Y){let X=YW;if(!X)return;XA.info(`Capgo CLI added a temporary onboarding test change in ${X.displayPath}.`);let G=await n1({message:"Do you want me to revert that temporary test change now?",initialValue:!0});await g8(G,A,Q);let K=!1;if(G)if(!RJ(X.filePath))XA.warn(`${X.displayPath} no longer exists, so there is nothing left to revert automatically.`),K=!0,YW=void 0;else try{let U=MF(X.filePath,"utf8"),z=_6Q(X.kind,U);if(!z)XA.warn(`Could not automatically revert ${X.displayPath}. Please revert it manually.`);else Pw(X.filePath,z,"utf8"),XA.success(`Reverted ${X.displayPath} ✅`),K=!0,YW=void 0}catch(U){if(U.code==="ENOENT")XA.warn(`${X.displayPath} was removed before cleanup, so there is nothing left to revert automatically.`),K=!0,YW=void 0;else XA.warn(`Could not automatically revert ${X.displayPath}: ${hA(U)}`)}let W="build";try{let U=await $7({packageJsonPath:E4});W=await DG(U)}catch(U){DB(`project-type detection failed, defaulting buildCommand to 'build': ${U instanceof Error?U.message:String(U)}`)}let H=Z8(),D=e30($),F=[`${H.runner} @capgo/cli@latest bundle upload ${B}`,`--bundle ${D}`,`--channel ${dX}`,Y?"--delta-only":"",E4?`--package-json ${E4}`:"",CF?`--node-modules ${CF}`:""].filter(Boolean).join(" ");XA.info(K?"Build and upload one more cleanup bundle so the onboarding test change disappears from the installed app.":"After you revert that onboarding test change, build and upload one more cleanup bundle so it disappears from the installed app."),XA.info(`Suggested cleanup build: ${H.pm} run ${W}`),XA.info(`Suggested cleanup upload: ${F}`),XA.warn(`Do not run "${H.runner} cap sync ${J}" before this cleanup upload.`)}async function Qq0(A,Q,B,$,J){let Y=Z8(),X=E4?L6.resolve(E4):void 0,G=X?h7(X):u1(),K=await n1({message:`Upload the updated ${B} bundle (v${$}) to Capgo?`});if(await g8(K,A,Q),K){let W,H=xfA(u1());while(!0){let D=W4();if(D.start(`Running: ${Y.runner} @capgo/cli@latest bundle upload ${J?"--delta-only":""}`),E4&&H){if(XA.warn("You are most likely using a monorepo, please provide the path to your package.json file AND node_modules path folder when uploading your bundle"),XA.warn(`Example: ${Y.runner} @capgo/cli@latest bundle upload --package-json ./packages/my-app/package.json --node-modules ./packages/my-app/node_modules ${J?"--delta-only":""}`),W||=d4(W8(u1()),"node_modules"),XA.warn(`Using node modules path: ${W}`),!RJ(W)){D.stop("Upload blocked ❌"),XA.error("Node modules path does not exist"),W=await dH0(A,Q,"Enter the path to the correct node_modules directory:",W);continue}}CF=H?W:void 0;let F;try{let U=u1();try{JN(G),F=await sz(B,{channel:dX,apikey:Q,packageJson:H?X:void 0,nodeModules:H?W:void 0,deltaOnly:J,bundle:$,ignoreChecksumCheck:!0,showReplicationProgress:!1},!1)}finally{JN(U)}}catch(U){D.stop("Upload failed ❌"),XA.error(hA(U)),await kw(A,Q,"Bundle upload failed. What do you want to do?",[{value:"retry",label:"Retry bundle upload"}],hA(U));continue}if(!F?.success){D.stop("Upload failed ❌"),await kw(A,Q,"Bundle upload failed. What do you want to do?",[{value:"retry",label:"Retry bundle upload"}],"Bundle upload did not complete successfully.");continue}D.stop(`✅ Update v${$} uploaded successfully!`),await AAA({title:"Replicating your updated bundle in onboarding regions.",completeMessage:"Update replication is now fully propagated.",interactive:!!BW.isTTY&&!!cX.isTTY}),XA.info("\uD83C\uDF89 Your updated bundle is now available on Capgo");break}}else{let H=[`${Y.runner} @capgo/cli@latest bundle upload ${B}`,`--bundle ${$}`,`--channel ${dX}`,J?"--delta-only":"",E4?`--package-json ${E4}`:""].filter(Boolean).join(" ");XA.info(`Upload yourself from ${G} with command: ${H}`)}await jJ(A,Q,"upload",B)}async function Bq0(A,Q,B,$,J){if(XA.info("\uD83E\uDDEA Time to test the Capgo update system!"),XA.info("\uD83D\uDCF1 Go to your device where the app is running"),J)XA.info("\uD83D\uDD04 IMPORTANT: Background your app (swipe up/press home button) and then reopen it"),XA.info("⏱️ The update should be downloaded and applied automatically");else XA.info("\uD83D\uDCF1 With standard updates, you will need to:"),XA.info(" 1. Background the app (swipe up/press home button) to start download"),XA.info(" 2. Wait a few seconds for download to complete"),XA.info(" 3. Background and foreground again to see the update");XA.info("\uD83D\uDC40 You should see your changes appear in the app!");let Y=await n1({message:"Monitor Capgo logs to verify the update worked?"});if(await g8(Y,A,Q),Y)XA.info(`\uD83D\uDCCA Watching logs from ${B}...`),XA.info("\uD83D\uDD04 Please background and reopen your app now to trigger the update"),await h$A("onboarding-v2",Q,B,Q,A);else XA.info(`\uD83D\uDCCA Check logs manually at ${$}/app/${B}/logs to verify the update`);await jJ(A,Q,"test-update",B)}var I6Q="https://github.com/Cap-go/capgo-skills",C6Q="Cap-go/capgo-skills";function $q0(A){if(A.length===0)return"";if(A.length===1)return A[0];if(A.length===2)return`${A[0]} and ${A[1]}`;return`${A.slice(0,-1).join(", ")}, and ${A.at(-1)}`}async function Jq0(){if(!BW.isTTY||!cX.isTTY)return!1;let A=Z8(),Q=`${A.runner} skills add ${I6Q} -g -y`,B=await n1({message:"Install Capgo capacitor skills (capgo-skills) for your coding agent?",initialValue:!0});if(vB(B)||!B)return!1;XA.info(`Running command: ${Q}`);let $=W4();$.start(`Running: ${Q}`);try{let J=TZ(A.runner,["skills","add",I6Q,"-g","-y"],{stdio:"pipe",encoding:"utf8"});if(J.status===0)return $.stop("Capgo skills install Done ✅"),!0;$.stop("Capgo skills install failed ❌");let Y=[J.stderr,J.stdout].find((X)=>typeof X==="string"&&X.trim().length>0)?.trim();return XA.warn(`Could not install Capgo skills automatically: ${Y||"Unknown error"}`),XA.info(`Run it yourself with: "${Q}"`),!0}catch(J){return $.stop("Capgo skills install failed ❌"),XA.warn(`Could not install Capgo skills automatically: ${hA(J)}`),XA.info(`Run it yourself with: "${Q}"`),!0}}async function Yq0(A=!1,Q){if(!BW.isTTY||!cX.isTTY)return;let B=Ow(Q);if(!B.ghInstalled||!B.ghLoggedIn)return;let $=[B.repository];if(A)$.push(C6Q);let J=$.filter((K)=>{let W=Ow(K);return W.repositoryExists&&!W.starred&&!Cw(W.repository)});if(J.length===0&&(!B.repositoryExists||B.starred||Cw(B.repository)))return;let Y=J.length>0?`Star ${$q0(J)}`:`Star ${B.repository}`,G=await I1({message:"How would you like to support Capgo on GitHub?",options:[{value:"star-update",label:Y},{value:"star-all",label:A?"Star all Capgo repos and Cap-go/capgo-skills":"Star all Capgo repos (repositories starting with capacitor- in Cap-go org)"},{value:"skip",label:"No, thanks"}]});if(vB(G)||G==="skip")return;try{if(G==="star-update")for(let K of J){let W=UF(K);if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`)}else if(G==="star-all"){let K=await Mw();for(let W of K)if(W.error)XA.error(`⚠️ Could not star ${W.repository}: ${W.error}`);else if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`);if(A){let W=UF(C6Q);if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`)}}}catch(K){XA.warn(`Cannot star ${B.repository} right now: ${hA(K)}`)}}async function YFA(A,Q,B){j6Q=B.supaHost;let $=Z8();B.apikey=A;let J=B.analytics!==!1&&!zWA();if(As({analyticsEnabled:J,apikey:B.apikey?.trim()||S$(),supaAnon:B.supaAnon,supaHost:B.supaHost}),OU(Q||$W),DB(`init: onboarding started for app ${Q||$W||"unknown"}`),Za("Capgo onboarding"),A6Q(fG.length,J),!B.apikey)try{B.apikey??=k0(!0)}catch{}let Y=await cH0(B.apikey),X=Y?.stepDone??0;await kH0(X>0?YW:void 0),Q=await mH0(Q)??Q;let G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G),W=await XT();if(W.isOutdated)pcA(W.currentVersion,W.latestVersion,W.majorVersion);let H;if(!B.supaAnon||!B.supaHost)try{H=await hy(K,()=>N0())}catch{H=void 0}else H=await hy(K,()=>$U({statsUrl:`${B.supaHost}/functions/v1/stats`,channelUrl:`${B.supaHost}/functions/v1/channel_self`,updateUrl:`${B.supaHost}/functions/v1/updates`,localApiFiles:`${B.supaHost}/functions/v1`,localS3:!0,localSupa:B.supaHost,localSupaAnon:B.supaAnon}));if(!iDA.some((p)=>RJ(d4(K,p)))){XA.warn("⚠️ No capacitor.config.* found in the selected project directory."),XA.info(` Capgo requires a Capacitor project. Selected project: ${K}`),XA.info(" Learn more: https://capacitorjs.com/docs/getting-started");let p=await I1({message:"Continue anyway?",options:[{value:"yes",label:"✅ Yes, continue"},{value:"no",label:"❌ No, exit"}]});if(vB(p)||p==="no")return O4("Bye \uD83D\uDC4B"),await X6()}else{let p=EAA(H?.config,K);if(!p.ios&&!p.android){let{pm:r,capAddAndroid:DA,capAddIos:o}=ly();XA.warn(`⚠️ No native platform directories found (${p.iosDir}/ or ${p.androidDir}/).`),XA.info(` Suggested commands: ${o} or ${DA}`);let g=await I1({message:"How do you want to continue?",options:[{value:"add-ios",label:`\uD83D\uDEE0 Run ${o} now`},{value:"add-android",label:`\uD83D\uDEE0 Run ${DA} now`},{value:"yes",label:"✅ Continue without native platforms"},{value:"no",label:"❌ Exit onboarding"}]});if(vB(g)||g==="no")return O4(`Bye \uD83D\uDC4B
|
|
1338
|
+
\uD83D\uDCA1 You can resume the onboarding anytime by running the same command again`),await X6();D=V}XA.info(`\uD83E\uDDED This OTA upload will use version ${D}. For the next test, increment it again.`);let F=Z8(),U=await $7({packageJsonPath:Y}),z=await DG(U),I=()=>{XA.info(`Build web assets manually in ${X} with: ${F.pm} run ${z}`),XA.warn(`Do NOT run "${F.runner} cap sync ${J}" for this OTA test.`),XA.warn(`Why: "${F.runner} cap sync ${J}" copies the current web build into the native project and regenerates native plugin files.`),XA.warn("If you sync now, the native app already contains your new change before Capgo download, so you cannot verify OTA behavior."),XA.info("Sync is safe again only after you confirmed the OTA update on device, or when preparing a new native/App Store build.")},O=await n1({message:`Build ${B} web assets before uploading with "${F.pm} run ${z}"? (no cap sync)`});if(await g8(O,A,Q),O){let V=W4();if(V.start(`Running in ${X}: ${F.pm} run ${z}`),!WK(void 0,Y)[z]){V.stop("Missing build script","neutral"),XA.warn(`❌ Cannot find "${z}" script in package.json`),XA.info("\uD83D\uDCA1 Build manually in another terminal, then come back and continue"),I();let M=await n1({message:"Have you built the app manually? (If not, we'll skip the build)"});if(await g8(M,A,Q),!M)XA.warn("⚠️ Continuing without build - upload may fail if app isn't built"),I();else XA.info("✅ Great! Continuing with your manual build")}else try{let M=TZ(F.pm,["run",z],{stdio:"pipe",cwd:X});if(M.error)throw M.error;if(M.status!==0)throw Error(`Build command "${F.pm} run ${z}" failed with exit code ${M.status??"unknown"}`);V.stop("✅ Build with changes completed"),XA.info("\uD83D\uDCE6 Your modifications are built and ready for OTA upload")}catch{V.stop("Build failed ❌"),XA.warn("Automatic build failed."),I();let M=await n1({message:"Have you built the app manually now? (If not, we will continue without build)"});if(await g8(M,A,Q),!M)XA.warn("⚠️ Continuing without build - upload may fail if app isn't built")}}else I();return await jJ(A,Q,"add-code-change",B),D}function e30(A){try{return F5(O2(X1(A),"patch"))}catch{return"1.0.2"}}async function Aq0(A,Q,B,$,J,Y){let X=YW;if(!X)return;XA.info(`Capgo CLI added a temporary onboarding test change in ${X.displayPath}.`);let G=await n1({message:"Do you want me to revert that temporary test change now?",initialValue:!0});await g8(G,A,Q);let K=!1;if(G)if(!RJ(X.filePath))XA.warn(`${X.displayPath} no longer exists, so there is nothing left to revert automatically.`),K=!0,YW=void 0;else try{let U=MF(X.filePath,"utf8"),z=_6Q(X.kind,U);if(!z)XA.warn(`Could not automatically revert ${X.displayPath}. Please revert it manually.`);else Pw(X.filePath,z,"utf8"),XA.success(`Reverted ${X.displayPath} ✅`),K=!0,YW=void 0}catch(U){if(U.code==="ENOENT")XA.warn(`${X.displayPath} was removed before cleanup, so there is nothing left to revert automatically.`),K=!0,YW=void 0;else XA.warn(`Could not automatically revert ${X.displayPath}: ${hA(U)}`)}let W="build";try{let U=await $7({packageJsonPath:E4});W=await DG(U)}catch(U){DB(`project-type detection failed, defaulting buildCommand to 'build': ${U instanceof Error?U.message:String(U)}`)}let H=Z8(),D=e30($),F=[`${H.runner} @capgo/cli@latest bundle upload ${B}`,`--bundle ${D}`,`--channel ${dX}`,Y?"--delta-only":"",E4?`--package-json ${E4}`:"",CF?`--node-modules ${CF}`:""].filter(Boolean).join(" ");XA.info(K?"Build and upload one more cleanup bundle so the onboarding test change disappears from the installed app.":"After you revert that onboarding test change, build and upload one more cleanup bundle so it disappears from the installed app."),XA.info(`Suggested cleanup build: ${H.pm} run ${W}`),XA.info(`Suggested cleanup upload: ${F}`),XA.warn(`Do not run "${H.runner} cap sync ${J}" before this cleanup upload.`)}async function Qq0(A,Q,B,$,J,Y){let X=Z8(),G=E4?L6.resolve(E4):void 0,K=G?h7(G):u1(),W=await n1({message:`Upload the updated ${B} bundle (v${$}) to Capgo?`});if(await g8(W,A,Q),W){let H,D=xfA(u1());while(!0){let F=W4();if(F.start(`Running: ${X.runner} @capgo/cli@latest bundle upload ${J?"--delta-only":""}`),E4&&D){if(XA.warn("You are most likely using a monorepo, please provide the path to your package.json file AND node_modules path folder when uploading your bundle"),XA.warn(`Example: ${X.runner} @capgo/cli@latest bundle upload --package-json ./packages/my-app/package.json --node-modules ./packages/my-app/node_modules ${J?"--delta-only":""}`),H||=d4(W8(u1()),"node_modules"),XA.warn(`Using node modules path: ${H}`),!RJ(H)){F.stop("Upload blocked ❌"),XA.error("Node modules path does not exist"),H=await dH0(A,Q,"Enter the path to the correct node_modules directory:",H);continue}}CF=D?H:void 0;let U;try{let z=u1();try{JN(K),U=await sz(B,{channel:dX,apikey:Q,packageJson:D?G:void 0,nodeModules:D?H:void 0,deltaOnly:J,bundle:$,ignoreChecksumCheck:!0,showReplicationProgress:!1},!1)}finally{JN(z)}}catch(z){F.stop("Upload failed ❌"),XA.error(hA(z)),await kw(A,Q,"Bundle upload failed. What do you want to do?",[{value:"retry",label:"Retry bundle upload"}],hA(z),Y);continue}if(!U?.success){F.stop("Upload failed ❌"),await kw(A,Q,"Bundle upload failed. What do you want to do?",[{value:"retry",label:"Retry bundle upload"}],"Bundle upload did not complete successfully.",Y);continue}F.stop(`✅ Update v${$} uploaded successfully!`),await AAA({title:"Replicating your updated bundle in onboarding regions.",completeMessage:"Update replication is now fully propagated.",interactive:!!BW.isTTY&&!!cX.isTTY}),XA.info("\uD83C\uDF89 Your updated bundle is now available on Capgo");break}}else{let D=[`${X.runner} @capgo/cli@latest bundle upload ${B}`,`--bundle ${$}`,`--channel ${dX}`,J?"--delta-only":"",E4?`--package-json ${E4}`:""].filter(Boolean).join(" ");XA.info(`Upload yourself from ${K} with command: ${D}`)}await jJ(A,Q,"upload",B)}async function Bq0(A,Q,B,$,J){if(XA.info("\uD83E\uDDEA Time to test the Capgo update system!"),XA.info("\uD83D\uDCF1 Go to your device where the app is running"),J)XA.info("\uD83D\uDD04 IMPORTANT: Background your app (swipe up/press home button) and then reopen it"),XA.info("⏱️ The update should be downloaded and applied automatically");else XA.info("\uD83D\uDCF1 With standard updates, you will need to:"),XA.info(" 1. Background the app (swipe up/press home button) to start download"),XA.info(" 2. Wait a few seconds for download to complete"),XA.info(" 3. Background and foreground again to see the update");XA.info("\uD83D\uDC40 You should see your changes appear in the app!");let Y=await n1({message:"Monitor Capgo logs to verify the update worked?"});if(await g8(Y,A,Q),Y)XA.info(`\uD83D\uDCCA Watching logs from ${B}...`),XA.info("\uD83D\uDD04 Please background and reopen your app now to trigger the update"),await h$A("onboarding-v2",Q,B,Q,A);else XA.info(`\uD83D\uDCCA Check logs manually at ${$}/app/${B}/logs to verify the update`);await jJ(A,Q,"test-update",B)}var I6Q="https://github.com/Cap-go/capgo-skills",C6Q="Cap-go/capgo-skills";function $q0(A){if(A.length===0)return"";if(A.length===1)return A[0];if(A.length===2)return`${A[0]} and ${A[1]}`;return`${A.slice(0,-1).join(", ")}, and ${A.at(-1)}`}async function Jq0(){if(!BW.isTTY||!cX.isTTY)return!1;let A=Z8(),Q=`${A.runner} skills add ${I6Q} -g -y`,B=await n1({message:"Install Capgo capacitor skills (capgo-skills) for your coding agent?",initialValue:!0});if(vB(B)||!B)return!1;XA.info(`Running command: ${Q}`);let $=W4();$.start(`Running: ${Q}`);try{let J=TZ(A.runner,["skills","add",I6Q,"-g","-y"],{stdio:"pipe",encoding:"utf8"});if(J.status===0)return $.stop("Capgo skills install Done ✅"),!0;$.stop("Capgo skills install failed ❌");let Y=[J.stderr,J.stdout].find((X)=>typeof X==="string"&&X.trim().length>0)?.trim();return XA.warn(`Could not install Capgo skills automatically: ${Y||"Unknown error"}`),XA.info(`Run it yourself with: "${Q}"`),!0}catch(J){return $.stop("Capgo skills install failed ❌"),XA.warn(`Could not install Capgo skills automatically: ${hA(J)}`),XA.info(`Run it yourself with: "${Q}"`),!0}}async function Yq0(A=!1,Q){if(!BW.isTTY||!cX.isTTY)return;let B=Ow(Q);if(!B.ghInstalled||!B.ghLoggedIn)return;let $=[B.repository];if(A)$.push(C6Q);let J=$.filter((K)=>{let W=Ow(K);return W.repositoryExists&&!W.starred&&!Cw(W.repository)});if(J.length===0&&(!B.repositoryExists||B.starred||Cw(B.repository)))return;let Y=J.length>0?`Star ${$q0(J)}`:`Star ${B.repository}`,G=await I1({message:"How would you like to support Capgo on GitHub?",options:[{value:"star-update",label:Y},{value:"star-all",label:A?"Star all Capgo repos and Cap-go/capgo-skills":"Star all Capgo repos (repositories starting with capacitor- in Cap-go org)"},{value:"skip",label:"No, thanks"}]});if(vB(G)||G==="skip")return;try{if(G==="star-update")for(let K of J){let W=UF(K);if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`)}else if(G==="star-all"){let K=await Mw();for(let W of K)if(W.error)XA.error(`⚠️ Could not star ${W.repository}: ${W.error}`);else if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`);if(A){let W=UF(C6Q);if(W.alreadyStarred)XA.info(`\uD83E\uDEF6 ${W.repository} is already starred`);else XA.success(`\uD83D\uDE4F Thanks for starring ${W.repository} \uD83C\uDF89`)}}}catch(K){XA.warn(`Cannot star ${B.repository} right now: ${hA(K)}`)}}async function YFA(A,Q,B){j6Q=B.supaHost;let $=Z8();B.apikey=A;let J=B.analytics!==!1&&!zWA();if(As({analyticsEnabled:J,apikey:B.apikey?.trim()||S$(),supaAnon:B.supaAnon,supaHost:B.supaHost}),OU(Q||$W),DB(`init: onboarding started for app ${Q||$W||"unknown"}`),Za("Capgo onboarding"),A6Q(fG.length,J),!B.apikey)try{B.apikey??=k0(!0)}catch{}let Y=await cH0(B.apikey),X=Y?.stepDone??0;await kH0(X>0?YW:void 0),Q=await mH0(Q)??Q;let G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G),W=await XT();if(W.isOutdated)pcA(W.currentVersion,W.latestVersion,W.majorVersion);let H;if(!B.supaAnon||!B.supaHost)try{H=await hy(K,()=>N0())}catch{H=void 0}else H=await hy(K,()=>$U({statsUrl:`${B.supaHost}/functions/v1/stats`,channelUrl:`${B.supaHost}/functions/v1/channel_self`,updateUrl:`${B.supaHost}/functions/v1/updates`,localApiFiles:`${B.supaHost}/functions/v1`,localS3:!0,localSupa:B.supaHost,localSupaAnon:B.supaAnon}));if(!iDA.some((p)=>RJ(d4(K,p)))){XA.warn("⚠️ No capacitor.config.* found in the selected project directory."),XA.info(` Capgo requires a Capacitor project. Selected project: ${K}`),XA.info(" Learn more: https://capacitorjs.com/docs/getting-started");let p=await I1({message:"Continue anyway?",options:[{value:"yes",label:"✅ Yes, continue"},{value:"no",label:"❌ No, exit"}]});if(vB(p)||p==="no")return O4("Bye \uD83D\uDC4B"),await X6()}else{let p=EAA(H?.config,K);if(!p.ios&&!p.android){let{pm:r,capAddAndroid:DA,capAddIos:o}=ly();XA.warn(`⚠️ No native platform directories found (${p.iosDir}/ or ${p.androidDir}/).`),XA.info(` Suggested commands: ${o} or ${DA}`);let g=await I1({message:"How do you want to continue?",options:[{value:"add-ios",label:`\uD83D\uDEE0 Run ${o} now`},{value:"add-android",label:`\uD83D\uDEE0 Run ${DA} now`},{value:"yes",label:"✅ Continue without native platforms"},{value:"no",label:"❌ Exit onboarding"}]});if(vB(g)||g==="no")return O4(`Bye \uD83D\uDC4B
|
|
1339
1339
|
\uD83D\uDCA1 Run "${o}" or "${DA}", then try again.`),await X6();if(g==="add-ios"||g==="add-android"){let f=g==="add-ios"?"ios":"android";if(!await MAA(f,r.runner,K)){let h=await I1({message:`Could not add ${f}. What do you want to do next?`,options:[{value:"retry",label:`Retry ${f} setup`},{value:"doctor",label:"Run doctor diagnostics now"},{value:"continue",label:"Continue without native platforms"},{value:"exit",label:"Exit onboarding"}]});if(vB(h)||h==="exit")return O4(`Bye \uD83D\uDC4B
|
|
1340
|
-
\uD83D\uDCA1 Run "${f==="ios"?o:DA}", then try again.`),await X6();if(h==="doctor")try{await aC({packageJson:E4},!1)}catch(y){XA.warn(`Doctor found an issue: ${hA(y)}`)}if(h==="retry"){if(!await MAA(f,r.runner,K))XA.warn(`Still could not add ${f}. Continuing without native platforms for now.`)}}}}}let F=await hy(K,()=>XX());Q=hB(Q,H?.config),Q??=await py("Enter your appId:");let U=W4();if(!t4Q()||A){U.start(`Running: ${$.runner} @capgo/cli@latest login ***`);try{await vy(B.apikey,B,!0),U.stop("Login Done ✅")}catch(p){throw U.stop("Login failed ❌"),p}}let z=await YB(B.apikey,B.supaHost,B.supaAnon);await u8(z,B.apikey);let I=()=>{X=0,Y=void 0,E4=void 0,CF=void 0,dX=pDA,Tw="ios",cy=!1,IF=void 0,$W=void 0,uDA=void 0,mDA=void 0,EJ=void 0,RH(void 0),JW=void 0,CU(void 0),YW=void 0,cDA()},O;if(Y){let p=Y,{error:r,data:DA}=await z.rpc("get_orgs_v7");if(r||!DA)XA.error(`Cannot verify organization access: ${r?JSON.stringify(r):"no data returned"}`),XA.warn("Falling back to organization selection."),O=await yy(z,B.apikey),I();else{let o=DA.find((S)=>S.gid===p.orgId),g=o?.enforcing_2fa&&!o["2fa_has_access"],f=o?await nC(z,B.apikey,"org.create_app",{orgId:o.gid}):!1;if(!o)XA.warn(`Previously used organization "${p.orgName}" is no longer available. Please select a new one.`),O=await yy(z,B.apikey),I();else if(!f)XA.warn(`You no longer have permission to create an app in "${o.name}". Please select a different organization.`),O=await yy(z,B.apikey),I();else if(g)XA.warn(`Organization "${o.name}" now requires 2FA. Enable it at ${FX("/settings/account")}`),XA.warn("Please select a different organization or enable 2FA and try again."),O=await yy(z,B.apikey),I();else O=o,XA.info(`Using organization "${o.name}"`)}}else O=await yy(z,B.apikey);let V=O.gid;if(uDA=V,mDA=O.name,Y?.appId)Q=Y.appId,$W=Q;let E=await Q30(O,B.apikey,Q,z);if(Q=E.appId??Q,await eH0(V,B.apikey,Q,E.pendingApp),G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G),E.reusedPendingApp)X=Math.max(X,1);let M=UX(void 0,E4)||"1.0.0",N=cy,R=IF||M,T=dX,x=Tw;if(IF&&X>=3)M=IF;let m=fG.length,i=X>0,b=(p)=>{zAA=p,Q6Q(p,m,{resumed:i}),i=!1};try{if(X<1)b(1),await B30(V,B.apikey),Q=await X30(O,B.apikey,Q,B),$W=Q,vG(1);if(X<2)b(2),T=await G30(V,B.apikey,Q),dX=T,vG(2,void 0,T);if(X<3){b(3);let p=await C30(V,B.apikey,Q);M=p.pkgVersion,R=M,N=p.delta,IF=R,cy=N,G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G);try{H=await hy(K,()=>N0())}catch{H=void 0}vG(3)}if(X<4)b(4),await O30(V,B.apikey,Q),vG(4);if(X<5)b(5),await g6Q(V,B.apikey,Q),vG(5);if(EJ)EJ=void 0,RH(void 0);if(X<6)b(6),x=await r30(V,B.apikey,H?.config,K),Tw=x,vG(6);if(X<7)b(7),await P30(V,B.apikey,Q,x,H?.config),vG(7);if(JW)JW=void 0,CU(void 0);if(X<8)b(8),await s30(V,B.apikey,Q,x,K),vG(8);if(X<9)b(9),R=await t30(V,B.apikey,Q,M,x),IF=R,vG(9);if(X<10)b(10),await Qq0(V,B.apikey,Q,R,N),vG(10);if(X<11)b(11),await Bq0(V,B.apikey,Q,F.hostWeb,N),vG(11);if(X<12)b(12),await Aq0(V,B.apikey,Q,R,x,N),vG(12);await jJ(V,B.apikey,"done",Q),cDA()}catch(p){let r=hA(p),DA=sDA(r),{doctor:o}=ly();if(XA.error(`Error during onboarding: ${r}`),DA)XA.error(`Support bundle saved to ${DA}`);else XA.error("Could not save a support bundle automatically.");return XA.error(`Run ${o} for extra diagnostics before contacting support@capgo.app`),XA.error("Manual installation guide: https://capgo.app/docs/getting-started/add-an-app/"),await X6(1)}B6Q(Q,`${$.runner} @capgo/cli@latest bundle upload --bundle <new-version> --channel ${dX}`,`${$.runner} @capgo/cli@latest app debug`),XA.info("If you want to run another full OTA self-test after onboarding:"),XA.info("1. Make a visible change"),XA.info(`2. Build web assets only: ${$.pm} run build`),XA.info(`3. Upload with a new version: ${$.runner} @capgo/cli@latest bundle upload --bundle <new-version> --channel ${dX}`),XA.warn(`Do not run "${$.runner} cap sync" before validating the OTA update.`),XA.warn("Reason: cap sync puts your local build directly in the native app, which bypasses the Capgo OTA path."),XA.info(`If you have any issue try to use the debug command \`${$.runner} @capgo/cli@latest app debug\``);let u=await Jq0();return await Yq0(u),O4("Bye \uD83D\uDC4B"),await X6()}import oV0 from"node:process";var y8;(function(A){A.assertEqual=(J)=>{};function Q(J){}A.assertIs=Q;function B(J){throw Error()}A.assertNever=B,A.arrayToEnum=(J)=>{let Y={};for(let X of J)Y[X]=X;return Y},A.getValidEnumValues=(J)=>{let Y=A.objectKeys(J).filter((G)=>typeof J[J[G]]!=="number"),X={};for(let G of Y)X[G]=J[G];return A.objectValues(X)},A.objectValues=(J)=>{return A.objectKeys(J).map(function(Y){return J[Y]})},A.objectKeys=typeof Object.keys==="function"?(J)=>Object.keys(J):(J)=>{let Y=[];for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X))Y.push(X);return Y},A.find=(J,Y)=>{for(let X of J)if(Y(X))return X;return},A.isInteger=typeof Number.isInteger==="function"?(J)=>Number.isInteger(J):(J)=>typeof J==="number"&&Number.isFinite(J)&&Math.floor(J)===J;function $(J,Y=" | "){return J.map((X)=>typeof X==="string"?`'${X}'`:X).join(Y)}A.joinValues=$,A.jsonStringifyReplacer=(J,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(y8||(y8={}));var p6Q;(function(A){A.mergeShapes=(Q,B)=>{return{...Q,...B}}})(p6Q||(p6Q={}));var M0=y8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),NF=(A)=>{switch(typeof A){case"undefined":return M0.undefined;case"string":return M0.string;case"number":return Number.isNaN(A)?M0.nan:M0.number;case"boolean":return M0.boolean;case"function":return M0.function;case"bigint":return M0.bigint;case"symbol":return M0.symbol;case"object":if(Array.isArray(A))return M0.array;if(A===null)return M0.null;if(A.then&&typeof A.then==="function"&&A.catch&&typeof A.catch==="function")return M0.promise;if(typeof Map<"u"&&A instanceof Map)return M0.map;if(typeof Set<"u"&&A instanceof Set)return M0.set;if(typeof Date<"u"&&A instanceof Date)return M0.date;return M0.object;default:return M0.unknown}};var X0=y8.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class gG extends Error{get errors(){return this.issues}constructor(A){super();this.issues=[],this.addIssue=(B)=>{this.issues=[...this.issues,B]},this.addIssues=(B=[])=>{this.issues=[...this.issues,...B]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=A}format(A){let Q=A||function(J){return J.message},B={_errors:[]},$=(J)=>{for(let Y of J.issues)if(Y.code==="invalid_union")Y.unionErrors.map($);else if(Y.code==="invalid_return_type")$(Y.returnTypeError);else if(Y.code==="invalid_arguments")$(Y.argumentsError);else if(Y.path.length===0)B._errors.push(Q(Y));else{let X=B,G=0;while(G<Y.path.length){let K=Y.path[G];if(G!==Y.path.length-1)X[K]=X[K]||{_errors:[]};else X[K]=X[K]||{_errors:[]},X[K]._errors.push(Q(Y));X=X[K],G++}}};return $(this),B}static assert(A){if(!(A instanceof gG))throw Error(`Not a ZodError: ${A}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,y8.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(A=(Q)=>Q.message){let Q=Object.create(null),B=[];for(let $ of this.issues)if($.path.length>0){let J=$.path[0];Q[J]=Q[J]||[],Q[J].push(A($))}else B.push(A($));return{formErrors:B,fieldErrors:Q}}get formErrors(){return this.flatten()}}gG.create=(A)=>{return new gG(A)};var Xq0=(A,Q)=>{let B;switch(A.code){case X0.invalid_type:if(A.received===M0.undefined)B="Required";else B=`Expected ${A.expected}, received ${A.received}`;break;case X0.invalid_literal:B=`Invalid literal value, expected ${JSON.stringify(A.expected,y8.jsonStringifyReplacer)}`;break;case X0.unrecognized_keys:B=`Unrecognized key(s) in object: ${y8.joinValues(A.keys,", ")}`;break;case X0.invalid_union:B="Invalid input";break;case X0.invalid_union_discriminator:B=`Invalid discriminator value. Expected ${y8.joinValues(A.options)}`;break;case X0.invalid_enum_value:B=`Invalid enum value. Expected ${y8.joinValues(A.options)}, received '${A.received}'`;break;case X0.invalid_arguments:B="Invalid function arguments";break;case X0.invalid_return_type:B="Invalid function return type";break;case X0.invalid_date:B="Invalid date";break;case X0.invalid_string:if(typeof A.validation==="object")if("includes"in A.validation){if(B=`Invalid input: must include "${A.validation.includes}"`,typeof A.validation.position==="number")B=`${B} at one or more positions greater than or equal to ${A.validation.position}`}else if("startsWith"in A.validation)B=`Invalid input: must start with "${A.validation.startsWith}"`;else if("endsWith"in A.validation)B=`Invalid input: must end with "${A.validation.endsWith}"`;else y8.assertNever(A.validation);else if(A.validation!=="regex")B=`Invalid ${A.validation}`;else B="Invalid";break;case X0.too_small:if(A.type==="array")B=`Array must contain ${A.exact?"exactly":A.inclusive?"at least":"more than"} ${A.minimum} element(s)`;else if(A.type==="string")B=`String must contain ${A.exact?"exactly":A.inclusive?"at least":"over"} ${A.minimum} character(s)`;else if(A.type==="number")B=`Number must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${A.minimum}`;else if(A.type==="bigint")B=`Number must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${A.minimum}`;else if(A.type==="date")B=`Date must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(A.minimum))}`;else B="Invalid input";break;case X0.too_big:if(A.type==="array")B=`Array must contain ${A.exact?"exactly":A.inclusive?"at most":"less than"} ${A.maximum} element(s)`;else if(A.type==="string")B=`String must contain ${A.exact?"exactly":A.inclusive?"at most":"under"} ${A.maximum} character(s)`;else if(A.type==="number")B=`Number must be ${A.exact?"exactly":A.inclusive?"less than or equal to":"less than"} ${A.maximum}`;else if(A.type==="bigint")B=`BigInt must be ${A.exact?"exactly":A.inclusive?"less than or equal to":"less than"} ${A.maximum}`;else if(A.type==="date")B=`Date must be ${A.exact?"exactly":A.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(A.maximum))}`;else B="Invalid input";break;case X0.custom:B="Invalid input";break;case X0.invalid_intersection_types:B="Intersection results could not be merged";break;case X0.not_multiple_of:B=`Number must be a multiple of ${A.multipleOf}`;break;case X0.not_finite:B="Number must be finite";break;default:B=Q.defaultError,y8.assertNever(A)}return{message:B}},AI=Xq0;var Gq0=AI;function iy(){return Gq0}var PAA=(A)=>{let{data:Q,path:B,errorMaps:$,issueData:J}=A,Y=[...B,...J.path||[]],X={...J,path:Y};if(J.message!==void 0)return{...J,path:Y,message:J.message};let G="",K=$.filter((W)=>!!W).slice().reverse();for(let W of K)G=W(X,{data:Q,defaultError:G}).message;return{...J,path:Y,message:G}};function h0(A,Q){let B=iy(),$=PAA({issueData:Q,data:A.data,path:A.path,errorMaps:[A.common.contextualErrorMap,A.schemaErrorMap,B,B===AI?void 0:AI].filter((J)=>!!J)});A.common.issues.push($)}class xY{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(A,Q){let B=[];for(let $ of Q){if($.status==="aborted")return B1;if($.status==="dirty")A.dirty();B.push($.value)}return{status:A.value,value:B}}static async mergeObjectAsync(A,Q){let B=[];for(let $ of Q){let J=await $.key,Y=await $.value;B.push({key:J,value:Y})}return xY.mergeObjectSync(A,B)}static mergeObjectSync(A,Q){let B={};for(let $ of Q){let{key:J,value:Y}=$;if(J.status==="aborted")return B1;if(Y.status==="aborted")return B1;if(J.status==="dirty")A.dirty();if(Y.status==="dirty")A.dirty();if(J.value!=="__proto__"&&(typeof Y.value<"u"||$.alwaysSet))B[J.value]=Y.value}return{status:A.value,value:B}}}var B1=Object.freeze({status:"aborted"}),bw=(A)=>({status:"dirty",value:A}),u7=(A)=>({status:"valid",value:A}),XFA=(A)=>A.status==="aborted",GFA=(A)=>A.status==="dirty",YN=(A)=>A.status==="valid",ny=(A)=>typeof Promise<"u"&&A instanceof Promise;var OB;(function(A){A.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},A.toString=(Q)=>typeof Q==="string"?Q:Q?.message})(OB||(OB={}));class kZ{constructor(A,Q,B,$){this._cachedPath=[],this.parent=A,this.data=Q,this._path=B,this._key=$}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var i6Q=(A,Q)=>{if(YN(Q))return{success:!0,data:Q.value};else{if(!A.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let B=new gG(A.common.issues);return this._error=B,this._error}}}};function l1(A){if(!A)return{};let{errorMap:Q,invalid_type_error:B,required_error:$,description:J}=A;if(Q&&(B||$))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:J};return{errorMap:(X,G)=>{let{message:K}=A;if(X.code==="invalid_enum_value")return{message:K??G.defaultError};if(typeof G.data>"u")return{message:K??$??G.defaultError};if(X.code!=="invalid_type")return{message:G.defaultError};return{message:K??B??G.defaultError}},description:J}}class V8{get description(){return this._def.description}_getType(A){return NF(A.data)}_getOrReturnCtx(A,Q){return Q||{common:A.parent.common,data:A.data,parsedType:NF(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}_processInputParams(A){return{status:new xY,ctx:{common:A.parent.common,data:A.data,parsedType:NF(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}}_parseSync(A){let Q=this._parse(A);if(ny(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync(A){let Q=this._parse(A);return Promise.resolve(Q)}parse(A,Q){let B=this.safeParse(A,Q);if(B.success)return B.data;throw B.error}safeParse(A,Q){let B={common:{issues:[],async:Q?.async??!1,contextualErrorMap:Q?.errorMap},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)},$=this._parseSync({data:A,path:B.path,parent:B});return i6Q(B,$)}"~validate"(A){let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)};if(!this["~standard"].async)try{let B=this._parseSync({data:A,path:[],parent:Q});return YN(B)?{value:B.value}:{issues:Q.common.issues}}catch(B){if(B?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:A,path:[],parent:Q}).then((B)=>YN(B)?{value:B.value}:{issues:Q.common.issues})}async parseAsync(A,Q){let B=await this.safeParseAsync(A,Q);if(B.success)return B.data;throw B.error}async safeParseAsync(A,Q){let B={common:{issues:[],contextualErrorMap:Q?.errorMap,async:!0},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)},$=this._parse({data:A,path:B.path,parent:B}),J=await(ny($)?$:Promise.resolve($));return i6Q(B,J)}refine(A,Q){let B=($)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q($);else return Q};return this._refinement(($,J)=>{let Y=A($),X=()=>J.addIssue({code:X0.custom,...B($)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((G)=>{if(!G)return X(),!1;else return!0});if(!Y)return X(),!1;else return!0})}refinement(A,Q){return this._refinement((B,$)=>{if(!A(B))return $.addIssue(typeof Q==="function"?Q(B,$):Q),!1;else return!0})}_refinement(A){return new i3({schema:this,typeName:Z0.ZodEffects,effect:{type:"refinement",refinement:A}})}superRefine(A){return this._refinement(A)}constructor(A){this.spa=this.safeParseAsync,this._def=A,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(Q)=>this["~validate"](Q)}}optional(){return p3.create(this,this._def)}nullable(){return QI.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return l3.create(this)}promise(){return hw.create(this,this._def)}or(A){return ty.create([this,A],this._def)}and(A){return ey.create(this,A,this._def)}transform(A){return new i3({...l1(this._def),schema:this,typeName:Z0.ZodEffects,effect:{type:"transform",transform:A}})}default(A){let Q=typeof A==="function"?A:()=>A;return new $h({...l1(this._def),innerType:this,defaultValue:Q,typeName:Z0.ZodDefault})}brand(){return new HFA({typeName:Z0.ZodBranded,type:this,...l1(this._def)})}catch(A){let Q=typeof A==="function"?A:()=>A;return new Jh({...l1(this._def),innerType:this,catchValue:Q,typeName:Z0.ZodCatch})}describe(A){return new this.constructor({...this._def,description:A})}pipe(A){return gAA.create(this,A)}readonly(){return Yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Kq0=/^c[^\s-]{8,}$/i,Wq0=/^[0-9a-z]+$/,Zq0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Hq0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qq0=/^[a-z0-9_-]{21}$/i,Dq0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fq0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Uq0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zq0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",KFA,Iq0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cq0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Oq0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Mq0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nq0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lq0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,n6Q="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vq0=new RegExp(`^${n6Q}$`);function a6Q(A){let Q="[0-5]\\d";if(A.precision)Q=`${Q}\\.\\d{${A.precision}}`;else if(A.precision==null)Q=`${Q}(\\.\\d+)?`;let B=A.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${Q})${B}`}function Eq0(A){return new RegExp(`^${a6Q(A)}$`)}function Rq0(A){let Q=`${n6Q}T${a6Q(A)}`,B=[];if(B.push(A.local?"Z?":"Z"),A.offset)B.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${B.join("|")})`,new RegExp(`^${Q}$`)}function jq0(A,Q){if((Q==="v4"||!Q)&&Iq0.test(A))return!0;if((Q==="v6"||!Q)&&Oq0.test(A))return!0;return!1}function wq0(A,Q){if(!Dq0.test(A))return!1;try{let[B]=A.split(".");if(!B)return!1;let $=B.replace(/-/g,"+").replace(/_/g,"/").padEnd(B.length+(4-B.length%4)%4,"="),J=JSON.parse(atob($));if(typeof J!=="object"||J===null)return!1;if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if(Q&&J.alg!==Q)return!1;return!0}catch{return!1}}function _q0(A,Q){if((Q==="v4"||!Q)&&Cq0.test(A))return!0;if((Q==="v6"||!Q)&&Mq0.test(A))return!0;return!1}class VF extends V8{_parse(A){if(this._def.coerce)A.data=String(A.data);if(this._getType(A)!==M0.string){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.string,received:J.parsedType}),B1}let B=new xY,$=void 0;for(let J of this._def.checks)if(J.kind==="min"){if(A.data.length<J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),B.dirty()}else if(J.kind==="max"){if(A.data.length>J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),B.dirty()}else if(J.kind==="length"){let Y=A.data.length>J.value,X=A.data.length<J.value;if(Y||X){if($=this._getOrReturnCtx(A,$),Y)h0($,{code:X0.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});else if(X)h0($,{code:X0.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});B.dirty()}}else if(J.kind==="email"){if(!Uq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"email",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="emoji"){if(!KFA)KFA=new RegExp(zq0,"u");if(!KFA.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"emoji",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="uuid"){if(!Hq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"uuid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="nanoid"){if(!qq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"nanoid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cuid"){if(!Kq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"cuid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cuid2"){if(!Wq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"cuid2",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="ulid"){if(!Zq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"ulid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="url")try{new URL(A.data)}catch{$=this._getOrReturnCtx(A,$),h0($,{validation:"url",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="regex"){if(J.regex.lastIndex=0,!J.regex.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"regex",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="trim")A.data=A.data.trim();else if(J.kind==="includes"){if(!A.data.includes(J.value,J.position))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{includes:J.value,position:J.position},message:J.message}),B.dirty()}else if(J.kind==="toLowerCase")A.data=A.data.toLowerCase();else if(J.kind==="toUpperCase")A.data=A.data.toUpperCase();else if(J.kind==="startsWith"){if(!A.data.startsWith(J.value))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{startsWith:J.value},message:J.message}),B.dirty()}else if(J.kind==="endsWith"){if(!A.data.endsWith(J.value))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{endsWith:J.value},message:J.message}),B.dirty()}else if(J.kind==="datetime"){if(!Rq0(J).test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"datetime",message:J.message}),B.dirty()}else if(J.kind==="date"){if(!Vq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"date",message:J.message}),B.dirty()}else if(J.kind==="time"){if(!Eq0(J).test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"time",message:J.message}),B.dirty()}else if(J.kind==="duration"){if(!Fq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"duration",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="ip"){if(!jq0(A.data,J.version))$=this._getOrReturnCtx(A,$),h0($,{validation:"ip",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="jwt"){if(!wq0(A.data,J.alg))$=this._getOrReturnCtx(A,$),h0($,{validation:"jwt",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cidr"){if(!_q0(A.data,J.version))$=this._getOrReturnCtx(A,$),h0($,{validation:"cidr",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="base64"){if(!Nq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"base64",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="base64url"){if(!Lq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"base64url",code:X0.invalid_string,message:J.message}),B.dirty()}else y8.assertNever(J);return{status:B.value,value:A.data}}_regex(A,Q,B){return this.refinement(($)=>A.test($),{validation:Q,code:X0.invalid_string,...OB.errToObj(B)})}_addCheck(A){return new VF({...this._def,checks:[...this._def.checks,A]})}email(A){return this._addCheck({kind:"email",...OB.errToObj(A)})}url(A){return this._addCheck({kind:"url",...OB.errToObj(A)})}emoji(A){return this._addCheck({kind:"emoji",...OB.errToObj(A)})}uuid(A){return this._addCheck({kind:"uuid",...OB.errToObj(A)})}nanoid(A){return this._addCheck({kind:"nanoid",...OB.errToObj(A)})}cuid(A){return this._addCheck({kind:"cuid",...OB.errToObj(A)})}cuid2(A){return this._addCheck({kind:"cuid2",...OB.errToObj(A)})}ulid(A){return this._addCheck({kind:"ulid",...OB.errToObj(A)})}base64(A){return this._addCheck({kind:"base64",...OB.errToObj(A)})}base64url(A){return this._addCheck({kind:"base64url",...OB.errToObj(A)})}jwt(A){return this._addCheck({kind:"jwt",...OB.errToObj(A)})}ip(A){return this._addCheck({kind:"ip",...OB.errToObj(A)})}cidr(A){return this._addCheck({kind:"cidr",...OB.errToObj(A)})}datetime(A){if(typeof A==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:A});return this._addCheck({kind:"datetime",precision:typeof A?.precision>"u"?null:A?.precision,offset:A?.offset??!1,local:A?.local??!1,...OB.errToObj(A?.message)})}date(A){return this._addCheck({kind:"date",message:A})}time(A){if(typeof A==="string")return this._addCheck({kind:"time",precision:null,message:A});return this._addCheck({kind:"time",precision:typeof A?.precision>"u"?null:A?.precision,...OB.errToObj(A?.message)})}duration(A){return this._addCheck({kind:"duration",...OB.errToObj(A)})}regex(A,Q){return this._addCheck({kind:"regex",regex:A,...OB.errToObj(Q)})}includes(A,Q){return this._addCheck({kind:"includes",value:A,position:Q?.position,...OB.errToObj(Q?.message)})}startsWith(A,Q){return this._addCheck({kind:"startsWith",value:A,...OB.errToObj(Q)})}endsWith(A,Q){return this._addCheck({kind:"endsWith",value:A,...OB.errToObj(Q)})}min(A,Q){return this._addCheck({kind:"min",value:A,...OB.errToObj(Q)})}max(A,Q){return this._addCheck({kind:"max",value:A,...OB.errToObj(Q)})}length(A,Q){return this._addCheck({kind:"length",value:A,...OB.errToObj(Q)})}nonempty(A){return this.min(1,OB.errToObj(A))}trim(){return new VF({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new VF({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new VF({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((A)=>A.kind==="datetime")}get isDate(){return!!this._def.checks.find((A)=>A.kind==="date")}get isTime(){return!!this._def.checks.find((A)=>A.kind==="time")}get isDuration(){return!!this._def.checks.find((A)=>A.kind==="duration")}get isEmail(){return!!this._def.checks.find((A)=>A.kind==="email")}get isURL(){return!!this._def.checks.find((A)=>A.kind==="url")}get isEmoji(){return!!this._def.checks.find((A)=>A.kind==="emoji")}get isUUID(){return!!this._def.checks.find((A)=>A.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((A)=>A.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((A)=>A.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((A)=>A.kind==="cuid2")}get isULID(){return!!this._def.checks.find((A)=>A.kind==="ulid")}get isIP(){return!!this._def.checks.find((A)=>A.kind==="ip")}get isCIDR(){return!!this._def.checks.find((A)=>A.kind==="cidr")}get isBase64(){return!!this._def.checks.find((A)=>A.kind==="base64")}get isBase64url(){return!!this._def.checks.find((A)=>A.kind==="base64url")}get minLength(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxLength(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}}VF.create=(A)=>{return new VF({checks:[],typeName:Z0.ZodString,coerce:A?.coerce??!1,...l1(A)})};function Pq0(A,Q){let B=(A.toString().split(".")[1]||"").length,$=(Q.toString().split(".")[1]||"").length,J=B>$?B:$,Y=Number.parseInt(A.toFixed(J).replace(".","")),X=Number.parseInt(Q.toFixed(J).replace(".",""));return Y%X/10**J}class vw extends V8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(A){if(this._def.coerce)A.data=Number(A.data);if(this._getType(A)!==M0.number){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.number,received:J.parsedType}),B1}let B=void 0,$=new xY;for(let J of this._def.checks)if(J.kind==="int"){if(!y8.isInteger(A.data))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.invalid_type,expected:"integer",received:"float",message:J.message}),$.dirty()}else if(J.kind==="min"){if(J.inclusive?A.data<J.value:A.data<=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_small,minimum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),$.dirty()}else if(J.kind==="max"){if(J.inclusive?A.data>J.value:A.data>=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_big,maximum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),$.dirty()}else if(J.kind==="multipleOf"){if(Pq0(A.data,J.value)!==0)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_multiple_of,multipleOf:J.value,message:J.message}),$.dirty()}else if(J.kind==="finite"){if(!Number.isFinite(A.data))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_finite,message:J.message}),$.dirty()}else y8.assertNever(J);return{status:$.value,value:A.data}}gte(A,Q){return this.setLimit("min",A,!0,OB.toString(Q))}gt(A,Q){return this.setLimit("min",A,!1,OB.toString(Q))}lte(A,Q){return this.setLimit("max",A,!0,OB.toString(Q))}lt(A,Q){return this.setLimit("max",A,!1,OB.toString(Q))}setLimit(A,Q,B,$){return new vw({...this._def,checks:[...this._def.checks,{kind:A,value:Q,inclusive:B,message:OB.toString($)}]})}_addCheck(A){return new vw({...this._def,checks:[...this._def.checks,A]})}int(A){return this._addCheck({kind:"int",message:OB.toString(A)})}positive(A){return this._addCheck({kind:"min",value:0,inclusive:!1,message:OB.toString(A)})}negative(A){return this._addCheck({kind:"max",value:0,inclusive:!1,message:OB.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:0,inclusive:!0,message:OB.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:0,inclusive:!0,message:OB.toString(A)})}multipleOf(A,Q){return this._addCheck({kind:"multipleOf",value:A,message:OB.toString(Q)})}finite(A){return this._addCheck({kind:"finite",message:OB.toString(A)})}safe(A){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:OB.toString(A)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:OB.toString(A)})}get minValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}get isInt(){return!!this._def.checks.find((A)=>A.kind==="int"||A.kind==="multipleOf"&&y8.isInteger(A.value))}get isFinite(){let A=null,Q=null;for(let B of this._def.checks)if(B.kind==="finite"||B.kind==="int"||B.kind==="multipleOf")return!0;else if(B.kind==="min"){if(Q===null||B.value>Q)Q=B.value}else if(B.kind==="max"){if(A===null||B.value<A)A=B.value}return Number.isFinite(Q)&&Number.isFinite(A)}}vw.create=(A)=>{return new vw({checks:[],typeName:Z0.ZodNumber,coerce:A?.coerce||!1,...l1(A)})};class gw extends V8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(A){if(this._def.coerce)try{A.data=BigInt(A.data)}catch{return this._getInvalidInput(A)}if(this._getType(A)!==M0.bigint)return this._getInvalidInput(A);let B=void 0,$=new xY;for(let J of this._def.checks)if(J.kind==="min"){if(J.inclusive?A.data<J.value:A.data<=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_small,type:"bigint",minimum:J.value,inclusive:J.inclusive,message:J.message}),$.dirty()}else if(J.kind==="max"){if(J.inclusive?A.data>J.value:A.data>=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_big,type:"bigint",maximum:J.value,inclusive:J.inclusive,message:J.message}),$.dirty()}else if(J.kind==="multipleOf"){if(A.data%J.value!==BigInt(0))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_multiple_of,multipleOf:J.value,message:J.message}),$.dirty()}else y8.assertNever(J);return{status:$.value,value:A.data}}_getInvalidInput(A){let Q=this._getOrReturnCtx(A);return h0(Q,{code:X0.invalid_type,expected:M0.bigint,received:Q.parsedType}),B1}gte(A,Q){return this.setLimit("min",A,!0,OB.toString(Q))}gt(A,Q){return this.setLimit("min",A,!1,OB.toString(Q))}lte(A,Q){return this.setLimit("max",A,!0,OB.toString(Q))}lt(A,Q){return this.setLimit("max",A,!1,OB.toString(Q))}setLimit(A,Q,B,$){return new gw({...this._def,checks:[...this._def.checks,{kind:A,value:Q,inclusive:B,message:OB.toString($)}]})}_addCheck(A){return new gw({...this._def,checks:[...this._def.checks,A]})}positive(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:OB.toString(A)})}negative(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:OB.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:OB.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:OB.toString(A)})}multipleOf(A,Q){return this._addCheck({kind:"multipleOf",value:A,message:OB.toString(Q)})}get minValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}}gw.create=(A)=>{return new gw({checks:[],typeName:Z0.ZodBigInt,coerce:A?.coerce??!1,...l1(A)})};class TAA extends V8{_parse(A){if(this._def.coerce)A.data=Boolean(A.data);if(this._getType(A)!==M0.boolean){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.boolean,received:B.parsedType}),B1}return u7(A.data)}}TAA.create=(A)=>{return new TAA({typeName:Z0.ZodBoolean,coerce:A?.coerce||!1,...l1(A)})};class oy extends V8{_parse(A){if(this._def.coerce)A.data=new Date(A.data);if(this._getType(A)!==M0.date){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.date,received:J.parsedType}),B1}if(Number.isNaN(A.data.getTime())){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_date}),B1}let B=new xY,$=void 0;for(let J of this._def.checks)if(J.kind==="min"){if(A.data.getTime()<J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_small,message:J.message,inclusive:!0,exact:!1,minimum:J.value,type:"date"}),B.dirty()}else if(J.kind==="max"){if(A.data.getTime()>J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_big,message:J.message,inclusive:!0,exact:!1,maximum:J.value,type:"date"}),B.dirty()}else y8.assertNever(J);return{status:B.value,value:new Date(A.data.getTime())}}_addCheck(A){return new oy({...this._def,checks:[...this._def.checks,A]})}min(A,Q){return this._addCheck({kind:"min",value:A.getTime(),message:OB.toString(Q)})}max(A,Q){return this._addCheck({kind:"max",value:A.getTime(),message:OB.toString(Q)})}get minDate(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A!=null?new Date(A):null}get maxDate(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A!=null?new Date(A):null}}oy.create=(A)=>{return new oy({checks:[],coerce:A?.coerce||!1,typeName:Z0.ZodDate,...l1(A)})};class kAA extends V8{_parse(A){if(this._getType(A)!==M0.symbol){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.symbol,received:B.parsedType}),B1}return u7(A.data)}}kAA.create=(A)=>{return new kAA({typeName:Z0.ZodSymbol,...l1(A)})};class ry extends V8{_parse(A){if(this._getType(A)!==M0.undefined){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.undefined,received:B.parsedType}),B1}return u7(A.data)}}ry.create=(A)=>{return new ry({typeName:Z0.ZodUndefined,...l1(A)})};class sy extends V8{_parse(A){if(this._getType(A)!==M0.null){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.null,received:B.parsedType}),B1}return u7(A.data)}}sy.create=(A)=>{return new sy({typeName:Z0.ZodNull,...l1(A)})};class SAA extends V8{constructor(){super(...arguments);this._any=!0}_parse(A){return u7(A.data)}}SAA.create=(A)=>{return new SAA({typeName:Z0.ZodAny,...l1(A)})};class XN extends V8{constructor(){super(...arguments);this._unknown=!0}_parse(A){return u7(A.data)}}XN.create=(A)=>{return new XN({typeName:Z0.ZodUnknown,...l1(A)})};class EF extends V8{_parse(A){let Q=this._getOrReturnCtx(A);return h0(Q,{code:X0.invalid_type,expected:M0.never,received:Q.parsedType}),B1}}EF.create=(A)=>{return new EF({typeName:Z0.ZodNever,...l1(A)})};class xAA extends V8{_parse(A){if(this._getType(A)!==M0.undefined){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.void,received:B.parsedType}),B1}return u7(A.data)}}xAA.create=(A)=>{return new xAA({typeName:Z0.ZodVoid,...l1(A)})};class l3 extends V8{_parse(A){let{ctx:Q,status:B}=this._processInputParams(A),$=this._def;if(Q.parsedType!==M0.array)return h0(Q,{code:X0.invalid_type,expected:M0.array,received:Q.parsedType}),B1;if($.exactLength!==null){let Y=Q.data.length>$.exactLength.value,X=Q.data.length<$.exactLength.value;if(Y||X)h0(Q,{code:Y?X0.too_big:X0.too_small,minimum:X?$.exactLength.value:void 0,maximum:Y?$.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:$.exactLength.message}),B.dirty()}if($.minLength!==null){if(Q.data.length<$.minLength.value)h0(Q,{code:X0.too_small,minimum:$.minLength.value,type:"array",inclusive:!0,exact:!1,message:$.minLength.message}),B.dirty()}if($.maxLength!==null){if(Q.data.length>$.maxLength.value)h0(Q,{code:X0.too_big,maximum:$.maxLength.value,type:"array",inclusive:!0,exact:!1,message:$.maxLength.message}),B.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((Y,X)=>{return $.type._parseAsync(new kZ(Q,Y,Q.path,X))})).then((Y)=>{return xY.mergeArray(B,Y)});let J=[...Q.data].map((Y,X)=>{return $.type._parseSync(new kZ(Q,Y,Q.path,X))});return xY.mergeArray(B,J)}get element(){return this._def.type}min(A,Q){return new l3({...this._def,minLength:{value:A,message:OB.toString(Q)}})}max(A,Q){return new l3({...this._def,maxLength:{value:A,message:OB.toString(Q)}})}length(A,Q){return new l3({...this._def,exactLength:{value:A,message:OB.toString(Q)}})}nonempty(A){return this.min(1,A)}}l3.create=(A,Q)=>{return new l3({type:A,minLength:null,maxLength:null,exactLength:null,typeName:Z0.ZodArray,...l1(Q)})};function fw(A){if(A instanceof J9){let Q={};for(let B in A.shape){let $=A.shape[B];Q[B]=p3.create(fw($))}return new J9({...A._def,shape:()=>Q})}else if(A instanceof l3)return new l3({...A._def,type:fw(A.element)});else if(A instanceof p3)return p3.create(fw(A.unwrap()));else if(A instanceof QI)return QI.create(fw(A.unwrap()));else if(A instanceof RF)return RF.create(A.items.map((Q)=>fw(Q)));else return A}class J9 extends V8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let A=this._def.shape(),Q=y8.objectKeys(A);return this._cached={shape:A,keys:Q},this._cached}_parse(A){if(this._getType(A)!==M0.object){let K=this._getOrReturnCtx(A);return h0(K,{code:X0.invalid_type,expected:M0.object,received:K.parsedType}),B1}let{status:B,ctx:$}=this._processInputParams(A),{shape:J,keys:Y}=this._getCached(),X=[];if(!(this._def.catchall instanceof EF&&this._def.unknownKeys==="strip")){for(let K in $.data)if(!Y.includes(K))X.push(K)}let G=[];for(let K of Y){let W=J[K],H=$.data[K];G.push({key:{status:"valid",value:K},value:W._parse(new kZ($,H,$.path,K)),alwaysSet:K in $.data})}if(this._def.catchall instanceof EF){let K=this._def.unknownKeys;if(K==="passthrough")for(let W of X)G.push({key:{status:"valid",value:W},value:{status:"valid",value:$.data[W]}});else if(K==="strict"){if(X.length>0)h0($,{code:X0.unrecognized_keys,keys:X}),B.dirty()}else if(K==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let K=this._def.catchall;for(let W of X){let H=$.data[W];G.push({key:{status:"valid",value:W},value:K._parse(new kZ($,H,$.path,W)),alwaysSet:W in $.data})}}if($.common.async)return Promise.resolve().then(async()=>{let K=[];for(let W of G){let H=await W.key,D=await W.value;K.push({key:H,value:D,alwaysSet:W.alwaysSet})}return K}).then((K)=>{return xY.mergeObjectSync(B,K)});else return xY.mergeObjectSync(B,G)}get shape(){return this._def.shape()}strict(A){return OB.errToObj,new J9({...this._def,unknownKeys:"strict",...A!==void 0?{errorMap:(Q,B)=>{let $=this._def.errorMap?.(Q,B).message??B.defaultError;if(Q.code==="unrecognized_keys")return{message:OB.errToObj(A).message??$};return{message:$}}}:{}})}strip(){return new J9({...this._def,unknownKeys:"strip"})}passthrough(){return new J9({...this._def,unknownKeys:"passthrough"})}extend(A){return new J9({...this._def,shape:()=>({...this._def.shape(),...A})})}merge(A){return new J9({unknownKeys:A._def.unknownKeys,catchall:A._def.catchall,shape:()=>({...this._def.shape(),...A._def.shape()}),typeName:Z0.ZodObject})}setKey(A,Q){return this.augment({[A]:Q})}catchall(A){return new J9({...this._def,catchall:A})}pick(A){let Q={};for(let B of y8.objectKeys(A))if(A[B]&&this.shape[B])Q[B]=this.shape[B];return new J9({...this._def,shape:()=>Q})}omit(A){let Q={};for(let B of y8.objectKeys(this.shape))if(!A[B])Q[B]=this.shape[B];return new J9({...this._def,shape:()=>Q})}deepPartial(){return fw(this)}partial(A){let Q={};for(let B of y8.objectKeys(this.shape)){let $=this.shape[B];if(A&&!A[B])Q[B]=$;else Q[B]=$.optional()}return new J9({...this._def,shape:()=>Q})}required(A){let Q={};for(let B of y8.objectKeys(this.shape))if(A&&!A[B])Q[B]=this.shape[B];else{let J=this.shape[B];while(J instanceof p3)J=J._def.innerType;Q[B]=J}return new J9({...this._def,shape:()=>Q})}keyof(){return o6Q(y8.objectKeys(this.shape))}}J9.create=(A,Q)=>{return new J9({shape:()=>A,unknownKeys:"strip",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};J9.strictCreate=(A,Q)=>{return new J9({shape:()=>A,unknownKeys:"strict",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};J9.lazycreate=(A,Q)=>{return new J9({shape:A,unknownKeys:"strip",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};class ty extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=this._def.options;function $(J){for(let X of J)if(X.result.status==="valid")return X.result;for(let X of J)if(X.result.status==="dirty")return Q.common.issues.push(...X.ctx.common.issues),X.result;let Y=J.map((X)=>new gG(X.ctx.common.issues));return h0(Q,{code:X0.invalid_union,unionErrors:Y}),B1}if(Q.common.async)return Promise.all(B.map(async(J)=>{let Y={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await J._parseAsync({data:Q.data,path:Q.path,parent:Y}),ctx:Y}})).then($);else{let J=void 0,Y=[];for(let G of B){let K={...Q,common:{...Q.common,issues:[]},parent:null},W=G._parseSync({data:Q.data,path:Q.path,parent:K});if(W.status==="valid")return W;else if(W.status==="dirty"&&!J)J={result:W,ctx:K};if(K.common.issues.length)Y.push(K.common.issues)}if(J)return Q.common.issues.push(...J.ctx.common.issues),J.result;let X=Y.map((G)=>new gG(G));return h0(Q,{code:X0.invalid_union,unionErrors:X}),B1}}get options(){return this._def.options}}ty.create=(A,Q)=>{return new ty({options:A,typeName:Z0.ZodUnion,...l1(Q)})};var LF=(A)=>{if(A instanceof Ah)return LF(A.schema);else if(A instanceof i3)return LF(A.innerType());else if(A instanceof Qh)return[A.value];else if(A instanceof GN)return A.options;else if(A instanceof Bh)return y8.objectValues(A.enum);else if(A instanceof $h)return LF(A._def.innerType);else if(A instanceof ry)return[void 0];else if(A instanceof sy)return[null];else if(A instanceof p3)return[void 0,...LF(A.unwrap())];else if(A instanceof QI)return[null,...LF(A.unwrap())];else if(A instanceof HFA)return LF(A.unwrap());else if(A instanceof Yh)return LF(A.unwrap());else if(A instanceof Jh)return LF(A._def.innerType);else return[]};class ZFA extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.object)return h0(Q,{code:X0.invalid_type,expected:M0.object,received:Q.parsedType}),B1;let B=this.discriminator,$=Q.data[B],J=this.optionsMap.get($);if(!J)return h0(Q,{code:X0.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[B]}),B1;if(Q.common.async)return J._parseAsync({data:Q.data,path:Q.path,parent:Q});else return J._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(A,Q,B){let $=new Map;for(let J of Q){let Y=LF(J.shape[A]);if(!Y.length)throw Error(`A discriminator value for key \`${A}\` could not be extracted from all schema options`);for(let X of Y){if($.has(X))throw Error(`Discriminator property ${String(A)} has duplicate value ${String(X)}`);$.set(X,J)}}return new ZFA({typeName:Z0.ZodDiscriminatedUnion,discriminator:A,options:Q,optionsMap:$,...l1(B)})}}function WFA(A,Q){let B=NF(A),$=NF(Q);if(A===Q)return{valid:!0,data:A};else if(B===M0.object&&$===M0.object){let J=y8.objectKeys(Q),Y=y8.objectKeys(A).filter((G)=>J.indexOf(G)!==-1),X={...A,...Q};for(let G of Y){let K=WFA(A[G],Q[G]);if(!K.valid)return{valid:!1};X[G]=K.data}return{valid:!0,data:X}}else if(B===M0.array&&$===M0.array){if(A.length!==Q.length)return{valid:!1};let J=[];for(let Y=0;Y<A.length;Y++){let X=A[Y],G=Q[Y],K=WFA(X,G);if(!K.valid)return{valid:!1};J.push(K.data)}return{valid:!0,data:J}}else if(B===M0.date&&$===M0.date&&+A===+Q)return{valid:!0,data:A};else return{valid:!1}}class ey extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A),$=(J,Y)=>{if(XFA(J)||XFA(Y))return B1;let X=WFA(J.value,Y.value);if(!X.valid)return h0(B,{code:X0.invalid_intersection_types}),B1;if(GFA(J)||GFA(Y))Q.dirty();return{status:Q.value,value:X.data}};if(B.common.async)return Promise.all([this._def.left._parseAsync({data:B.data,path:B.path,parent:B}),this._def.right._parseAsync({data:B.data,path:B.path,parent:B})]).then(([J,Y])=>$(J,Y));else return $(this._def.left._parseSync({data:B.data,path:B.path,parent:B}),this._def.right._parseSync({data:B.data,path:B.path,parent:B}))}}ey.create=(A,Q,B)=>{return new ey({left:A,right:Q,typeName:Z0.ZodIntersection,...l1(B)})};class RF extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.array)return h0(B,{code:X0.invalid_type,expected:M0.array,received:B.parsedType}),B1;if(B.data.length<this._def.items.length)return h0(B,{code:X0.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B1;if(!this._def.rest&&B.data.length>this._def.items.length)h0(B,{code:X0.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let J=[...B.data].map((Y,X)=>{let G=this._def.items[X]||this._def.rest;if(!G)return null;return G._parse(new kZ(B,Y,B.path,X))}).filter((Y)=>!!Y);if(B.common.async)return Promise.all(J).then((Y)=>{return xY.mergeArray(Q,Y)});else return xY.mergeArray(Q,J)}get items(){return this._def.items}rest(A){return new RF({...this._def,rest:A})}}RF.create=(A,Q)=>{if(!Array.isArray(A))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new RF({items:A,typeName:Z0.ZodTuple,rest:null,...l1(Q)})};class bAA extends V8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.object)return h0(B,{code:X0.invalid_type,expected:M0.object,received:B.parsedType}),B1;let $=[],J=this._def.keyType,Y=this._def.valueType;for(let X in B.data)$.push({key:J._parse(new kZ(B,X,B.path,X)),value:Y._parse(new kZ(B,B.data[X],B.path,X)),alwaysSet:X in B.data});if(B.common.async)return xY.mergeObjectAsync(Q,$);else return xY.mergeObjectSync(Q,$)}get element(){return this._def.valueType}static create(A,Q,B){if(Q instanceof V8)return new bAA({keyType:A,valueType:Q,typeName:Z0.ZodRecord,...l1(B)});return new bAA({keyType:VF.create(),valueType:A,typeName:Z0.ZodRecord,...l1(Q)})}}class fAA extends V8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.map)return h0(B,{code:X0.invalid_type,expected:M0.map,received:B.parsedType}),B1;let $=this._def.keyType,J=this._def.valueType,Y=[...B.data.entries()].map(([X,G],K)=>{return{key:$._parse(new kZ(B,X,B.path,[K,"key"])),value:J._parse(new kZ(B,G,B.path,[K,"value"]))}});if(B.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let G of Y){let K=await G.key,W=await G.value;if(K.status==="aborted"||W.status==="aborted")return B1;if(K.status==="dirty"||W.status==="dirty")Q.dirty();X.set(K.value,W.value)}return{status:Q.value,value:X}})}else{let X=new Map;for(let G of Y){let{key:K,value:W}=G;if(K.status==="aborted"||W.status==="aborted")return B1;if(K.status==="dirty"||W.status==="dirty")Q.dirty();X.set(K.value,W.value)}return{status:Q.value,value:X}}}}fAA.create=(A,Q,B)=>{return new fAA({valueType:Q,keyType:A,typeName:Z0.ZodMap,...l1(B)})};class yw extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.set)return h0(B,{code:X0.invalid_type,expected:M0.set,received:B.parsedType}),B1;let $=this._def;if($.minSize!==null){if(B.data.size<$.minSize.value)h0(B,{code:X0.too_small,minimum:$.minSize.value,type:"set",inclusive:!0,exact:!1,message:$.minSize.message}),Q.dirty()}if($.maxSize!==null){if(B.data.size>$.maxSize.value)h0(B,{code:X0.too_big,maximum:$.maxSize.value,type:"set",inclusive:!0,exact:!1,message:$.maxSize.message}),Q.dirty()}let J=this._def.valueType;function Y(G){let K=new Set;for(let W of G){if(W.status==="aborted")return B1;if(W.status==="dirty")Q.dirty();K.add(W.value)}return{status:Q.value,value:K}}let X=[...B.data.values()].map((G,K)=>J._parse(new kZ(B,G,B.path,K)));if(B.common.async)return Promise.all(X).then((G)=>Y(G));else return Y(X)}min(A,Q){return new yw({...this._def,minSize:{value:A,message:OB.toString(Q)}})}max(A,Q){return new yw({...this._def,maxSize:{value:A,message:OB.toString(Q)}})}size(A,Q){return this.min(A,Q).max(A,Q)}nonempty(A){return this.min(1,A)}}yw.create=(A,Q)=>{return new yw({valueType:A,minSize:null,maxSize:null,typeName:Z0.ZodSet,...l1(Q)})};class ay extends V8{constructor(){super(...arguments);this.validate=this.implement}_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.function)return h0(Q,{code:X0.invalid_type,expected:M0.function,received:Q.parsedType}),B1;function B(X,G){return PAA({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,iy(),AI].filter((K)=>!!K),issueData:{code:X0.invalid_arguments,argumentsError:G}})}function $(X,G){return PAA({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,iy(),AI].filter((K)=>!!K),issueData:{code:X0.invalid_return_type,returnTypeError:G}})}let J={errorMap:Q.common.contextualErrorMap},Y=Q.data;if(this._def.returns instanceof hw){let X=this;return u7(async function(...G){let K=new gG([]),W=await X._def.args.parseAsync(G,J).catch((F)=>{throw K.addIssue(B(G,F)),K}),H=await Reflect.apply(Y,this,W);return await X._def.returns._def.type.parseAsync(H,J).catch((F)=>{throw K.addIssue($(H,F)),K})})}else{let X=this;return u7(function(...G){let K=X._def.args.safeParse(G,J);if(!K.success)throw new gG([B(G,K.error)]);let W=Reflect.apply(Y,this,K.data),H=X._def.returns.safeParse(W,J);if(!H.success)throw new gG([$(W,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...A){return new ay({...this._def,args:RF.create(A).rest(XN.create())})}returns(A){return new ay({...this._def,returns:A})}implement(A){return this.parse(A)}strictImplement(A){return this.parse(A)}static create(A,Q,B){return new ay({args:A?A:RF.create([]).rest(XN.create()),returns:Q||XN.create(),typeName:Z0.ZodFunction,...l1(B)})}}class Ah extends V8{get schema(){return this._def.getter()}_parse(A){let{ctx:Q}=this._processInputParams(A);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}}Ah.create=(A,Q)=>{return new Ah({getter:A,typeName:Z0.ZodLazy,...l1(Q)})};class Qh extends V8{_parse(A){if(A.data!==this._def.value){let Q=this._getOrReturnCtx(A);return h0(Q,{received:Q.data,code:X0.invalid_literal,expected:this._def.value}),B1}return{status:"valid",value:A.data}}get value(){return this._def.value}}Qh.create=(A,Q)=>{return new Qh({value:A,typeName:Z0.ZodLiteral,...l1(Q)})};function o6Q(A,Q){return new GN({values:A,typeName:Z0.ZodEnum,...l1(Q)})}class GN extends V8{_parse(A){if(typeof A.data!=="string"){let Q=this._getOrReturnCtx(A),B=this._def.values;return h0(Q,{expected:y8.joinValues(B),received:Q.parsedType,code:X0.invalid_type}),B1}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(A.data)){let Q=this._getOrReturnCtx(A),B=this._def.values;return h0(Q,{received:Q.data,code:X0.invalid_enum_value,options:B}),B1}return u7(A.data)}get options(){return this._def.values}get enum(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}get Values(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}get Enum(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}extract(A,Q=this._def){return GN.create(A,{...this._def,...Q})}exclude(A,Q=this._def){return GN.create(this.options.filter((B)=>!A.includes(B)),{...this._def,...Q})}}GN.create=o6Q;class Bh extends V8{_parse(A){let Q=y8.getValidEnumValues(this._def.values),B=this._getOrReturnCtx(A);if(B.parsedType!==M0.string&&B.parsedType!==M0.number){let $=y8.objectValues(Q);return h0(B,{expected:y8.joinValues($),received:B.parsedType,code:X0.invalid_type}),B1}if(!this._cache)this._cache=new Set(y8.getValidEnumValues(this._def.values));if(!this._cache.has(A.data)){let $=y8.objectValues(Q);return h0(B,{received:B.data,code:X0.invalid_enum_value,options:$}),B1}return u7(A.data)}get enum(){return this._def.values}}Bh.create=(A,Q)=>{return new Bh({values:A,typeName:Z0.ZodNativeEnum,...l1(Q)})};class hw extends V8{unwrap(){return this._def.type}_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.promise&&Q.common.async===!1)return h0(Q,{code:X0.invalid_type,expected:M0.promise,received:Q.parsedType}),B1;let B=Q.parsedType===M0.promise?Q.data:Promise.resolve(Q.data);return u7(B.then(($)=>{return this._def.type.parseAsync($,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}hw.create=(A,Q)=>{return new hw({type:A,typeName:Z0.ZodPromise,...l1(Q)})};class i3 extends V8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z0.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A),$=this._def.effect||null,J={addIssue:(Y)=>{if(h0(B,Y),Y.fatal)Q.abort();else Q.dirty()},get path(){return B.path}};if(J.addIssue=J.addIssue.bind(J),$.type==="preprocess"){let Y=$.transform(B.data,J);if(B.common.async)return Promise.resolve(Y).then(async(X)=>{if(Q.value==="aborted")return B1;let G=await this._def.schema._parseAsync({data:X,path:B.path,parent:B});if(G.status==="aborted")return B1;if(G.status==="dirty")return bw(G.value);if(Q.value==="dirty")return bw(G.value);return G});else{if(Q.value==="aborted")return B1;let X=this._def.schema._parseSync({data:Y,path:B.path,parent:B});if(X.status==="aborted")return B1;if(X.status==="dirty")return bw(X.value);if(Q.value==="dirty")return bw(X.value);return X}}if($.type==="refinement"){let Y=(X)=>{let G=$.refinement(X,J);if(B.common.async)return Promise.resolve(G);if(G instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(B.common.async===!1){let X=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(X.status==="aborted")return B1;if(X.status==="dirty")Q.dirty();return Y(X.value),{status:Q.value,value:X.value}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((X)=>{if(X.status==="aborted")return B1;if(X.status==="dirty")Q.dirty();return Y(X.value).then(()=>{return{status:Q.value,value:X.value}})})}if($.type==="transform")if(B.common.async===!1){let Y=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(!YN(Y))return B1;let X=$.transform(Y.value,J);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:X}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Y)=>{if(!YN(Y))return B1;return Promise.resolve($.transform(Y.value,J)).then((X)=>({status:Q.value,value:X}))});y8.assertNever($)}}i3.create=(A,Q,B)=>{return new i3({schema:A,typeName:Z0.ZodEffects,effect:Q,...l1(B)})};i3.createWithPreprocess=(A,Q,B)=>{return new i3({schema:Q,effect:{type:"preprocess",transform:A},typeName:Z0.ZodEffects,...l1(B)})};class p3 extends V8{_parse(A){if(this._getType(A)===M0.undefined)return u7(void 0);return this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}p3.create=(A,Q)=>{return new p3({innerType:A,typeName:Z0.ZodOptional,...l1(Q)})};class QI extends V8{_parse(A){if(this._getType(A)===M0.null)return u7(null);return this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}QI.create=(A,Q)=>{return new QI({innerType:A,typeName:Z0.ZodNullable,...l1(Q)})};class $h extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=Q.data;if(Q.parsedType===M0.undefined)B=this._def.defaultValue();return this._def.innerType._parse({data:B,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}$h.create=(A,Q)=>{return new $h({innerType:A,typeName:Z0.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...l1(Q)})};class Jh extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B={...Q,common:{...Q.common,issues:[]}},$=this._def.innerType._parse({data:B.data,path:B.path,parent:{...B}});if(ny($))return $.then((J)=>{return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new gG(B.common.issues)},input:B.data})}});else return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new gG(B.common.issues)},input:B.data})}}removeCatch(){return this._def.innerType}}Jh.create=(A,Q)=>{return new Jh({innerType:A,typeName:Z0.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...l1(Q)})};class vAA extends V8{_parse(A){if(this._getType(A)!==M0.nan){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.nan,received:B.parsedType}),B1}return{status:"valid",value:A.data}}}vAA.create=(A)=>{return new vAA({typeName:Z0.ZodNaN,...l1(A)})};var CQ1=Symbol("zod_brand");class HFA extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=Q.data;return this._def.type._parse({data:B,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class gAA extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.common.async)return(async()=>{let J=await this._def.in._parseAsync({data:B.data,path:B.path,parent:B});if(J.status==="aborted")return B1;if(J.status==="dirty")return Q.dirty(),bw(J.value);else return this._def.out._parseAsync({data:J.value,path:B.path,parent:B})})();else{let $=this._def.in._parseSync({data:B.data,path:B.path,parent:B});if($.status==="aborted")return B1;if($.status==="dirty")return Q.dirty(),{status:"dirty",value:$.value};else return this._def.out._parseSync({data:$.value,path:B.path,parent:B})}}static create(A,Q){return new gAA({in:A,out:Q,typeName:Z0.ZodPipeline})}}class Yh extends V8{_parse(A){let Q=this._def.innerType._parse(A),B=($)=>{if(YN($))$.value=Object.freeze($.value);return $};return ny(Q)?Q.then(($)=>B($)):B(Q)}unwrap(){return this._def.innerType}}Yh.create=(A,Q)=>{return new Yh({innerType:A,typeName:Z0.ZodReadonly,...l1(Q)})};var OQ1={object:J9.lazycreate},Z0;(function(A){A.ZodString="ZodString",A.ZodNumber="ZodNumber",A.ZodNaN="ZodNaN",A.ZodBigInt="ZodBigInt",A.ZodBoolean="ZodBoolean",A.ZodDate="ZodDate",A.ZodSymbol="ZodSymbol",A.ZodUndefined="ZodUndefined",A.ZodNull="ZodNull",A.ZodAny="ZodAny",A.ZodUnknown="ZodUnknown",A.ZodNever="ZodNever",A.ZodVoid="ZodVoid",A.ZodArray="ZodArray",A.ZodObject="ZodObject",A.ZodUnion="ZodUnion",A.ZodDiscriminatedUnion="ZodDiscriminatedUnion",A.ZodIntersection="ZodIntersection",A.ZodTuple="ZodTuple",A.ZodRecord="ZodRecord",A.ZodMap="ZodMap",A.ZodSet="ZodSet",A.ZodFunction="ZodFunction",A.ZodLazy="ZodLazy",A.ZodLiteral="ZodLiteral",A.ZodEnum="ZodEnum",A.ZodEffects="ZodEffects",A.ZodNativeEnum="ZodNativeEnum",A.ZodOptional="ZodOptional",A.ZodNullable="ZodNullable",A.ZodDefault="ZodDefault",A.ZodCatch="ZodCatch",A.ZodPromise="ZodPromise",A.ZodBranded="ZodBranded",A.ZodPipeline="ZodPipeline",A.ZodReadonly="ZodReadonly"})(Z0||(Z0={}));var MQ1=VF.create,NQ1=vw.create,LQ1=vAA.create,VQ1=gw.create,EQ1=TAA.create,RQ1=oy.create,jQ1=kAA.create,wQ1=ry.create,_Q1=sy.create,PQ1=SAA.create,TQ1=XN.create,kQ1=EF.create,SQ1=xAA.create,xQ1=l3.create,r6Q=J9.create,bQ1=J9.strictCreate,fQ1=ty.create,vQ1=ZFA.create,gQ1=ey.create,yQ1=RF.create,hQ1=bAA.create,uQ1=fAA.create,mQ1=yw.create,cQ1=ay.create,dQ1=Ah.create,lQ1=Qh.create,pQ1=GN.create,iQ1=Bh.create,nQ1=hw.create,aQ1=i3.create,oQ1=p3.create,rQ1=QI.create,sQ1=i3.createWithPreprocess,tQ1=gAA.create;DY();DY();DY();FB();var kq0=fA("ZodMiniType",(A,Q)=>{if(!A._zod)throw Error("Uninitialized schema in ZodMiniType.");G1.init(A,Q),A.def=Q,A.type=Q.type,A.parse=(B,$)=>bC(A,B,$,{callee:A.parse}),A.safeParse=(B,$)=>d2(A,B,$),A.parseAsync=async(B,$)=>fC(A,B,$,{callee:A.parseAsync}),A.safeParseAsync=async(B,$)=>l2(A,B,$),A.check=(...B)=>{return A.clone({...Q,checks:[...Q.checks??[],...B.map(($)=>typeof $==="function"?{_zod:{check:$,def:{check:"custom"},onattach:[]}}:$)]},{parent:!0})},A.with=A.check,A.clone=(B,$)=>M5(A,B,$),A.brand=()=>A,A.register=(B,$)=>{return B.add(A,$),A},A.apply=(B)=>B(A)});var Sq0=fA("ZodMiniObject",(A,Q)=>{Nl.init(A,Q),kq0.init(A,Q),i1(A,"shape",()=>Q.shape)});function qFA(A,Q){let B={type:"object",shape:A??{},...K0(Q)};return new Sq0(B)}yV();il();function XW(A){return!!A._zod}function KN(A){let Q=Object.values(A);if(Q.length===0)return qFA({});let B=Q.every(XW),$=Q.every((J)=>!XW(J));if(B)return qFA(A);if($)return r6Q(A);throw Error("Mixed Zod versions detected in object shape.")}function BI(A,Q){if(XW(A))return d2(A,Q);return A.safeParse(Q)}async function yAA(A,Q){if(XW(A))return await l2(A,Q);return await A.safeParseAsync(Q)}function $I(A){if(!A)return;let Q;if(XW(A))Q=A._zod?.def?.shape;else Q=A.shape;if(!Q)return;if(typeof Q==="function")try{return Q()}catch{return}return Q}function uw(A){if(!A)return;if(typeof A==="object"){let Q=A,B=A;if(!Q._def&&!B._zod){let $=Object.values(A);if($.length>0&&$.every((J)=>typeof J==="object"&&J!==null&&(J._def!==void 0||J._zod!==void 0||typeof J.parse==="function")))return KN(A)}}if(XW(A)){let B=A._zod?.def;if(B&&(B.type==="object"||B.shape!==void 0))return A}else if(A.shape!==void 0)return A;return}function hAA(A){if(A&&typeof A==="object"){if("message"in A&&typeof A.message==="string")return A.message;if("issues"in A&&Array.isArray(A.issues)&&A.issues.length>0){let Q=A.issues[0];if(Q&&typeof Q==="object"&&"message"in Q)return String(Q.message)}try{return JSON.stringify(A)}catch{return String(A)}}return String(A)}function s6Q(A){return A.description}function t6Q(A){if(XW(A))return A._zod?.def?.type==="optional";let Q=A;if(typeof A.isOptional==="function")return A.isOptional();return Q._def?.typeName==="ZodOptional"}function uAA(A){if(XW(A)){let Y=A._zod?.def;if(Y){if(Y.value!==void 0)return Y.value;if(Array.isArray(Y.values)&&Y.values.length>0)return Y.values[0]}}let B=A._def;if(B){if(B.value!==void 0)return B.value;if(Array.isArray(B.values)&&B.values.length>0)return B.values[0]}let $=A.value;if($!==void 0)return $;return}var DFA="2025-11-25";var e6Q=[DFA,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],JI="io.modelcontextprotocol/related-task",cAA="2.0",wJ=Yi((A)=>A!==null&&(typeof A==="object"||typeof A==="function")),A9Q=K4([DQ(),K$().int()]),Q9Q=DQ(),q01=L5({ttl:K$().optional(),pollInterval:K$().optional()}),bq0=s0({ttl:K$().optional()}),fq0=s0({taskId:DQ()}),FFA=L5({progressToken:A9Q.optional(),[JI]:fq0.optional()}),yG=s0({_meta:FFA.optional()}),Xh=yG.extend({task:bq0.optional()}),B9Q=(A)=>Xh.safeParse(A).success,i5=s0({method:DQ(),params:yG.loose().optional()}),GW=s0({_meta:FFA.optional()}),KW=s0({method:DQ(),params:GW.loose().optional()}),n5=L5({_meta:FFA.optional()}),dAA=K4([DQ(),K$().int()]),$9Q=s0({jsonrpc:VB(cAA),id:dAA,...i5.shape}).strict(),UFA=(A)=>$9Q.safeParse(A).success,J9Q=s0({jsonrpc:VB(cAA),...KW.shape}).strict(),Y9Q=(A)=>J9Q.safeParse(A).success,zFA=s0({jsonrpc:VB(cAA),id:dAA,result:n5}).strict(),Gh=(A)=>zFA.safeParse(A).success;var uB;(function(A){A[A.ConnectionClosed=-32000]="ConnectionClosed",A[A.RequestTimeout=-32001]="RequestTimeout",A[A.ParseError=-32700]="ParseError",A[A.InvalidRequest=-32600]="InvalidRequest",A[A.MethodNotFound=-32601]="MethodNotFound",A[A.InvalidParams=-32602]="InvalidParams",A[A.InternalError=-32603]="InternalError",A[A.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(uB||(uB={}));var IFA=s0({jsonrpc:VB(cAA),id:dAA.optional(),error:s0({code:K$().int(),message:DQ(),data:G4().optional()})}).strict();var X9Q=(A)=>IFA.safeParse(A).success;var G9Q=K4([$9Q,J9Q,zFA,IFA]),D01=K4([zFA,IFA]),lAA=n5.strict(),vq0=GW.extend({requestId:dAA.optional(),reason:DQ().optional()}),pAA=KW.extend({method:VB("notifications/cancelled"),params:vq0}),gq0=s0({src:DQ(),mimeType:DQ().optional(),sizes:K8(DQ()).optional(),theme:V5(["light","dark"]).optional()}),Kh=s0({icons:K8(gq0).optional()}),mw=s0({name:DQ(),title:DQ().optional()}),K9Q=mw.extend({...mw.shape,...Kh.shape,version:DQ(),websiteUrl:DQ().optional(),description:DQ().optional()}),yq0=iV(s0({applyDefaults:F9().optional()}),n$(DQ(),G4())),hq0=Pk((A)=>{if(A&&typeof A==="object"&&!Array.isArray(A)){if(Object.keys(A).length===0)return{form:{}}}return A},iV(s0({form:yq0.optional(),url:wJ.optional()}),n$(DQ(),G4()).optional())),uq0=L5({list:wJ.optional(),cancel:wJ.optional(),requests:L5({sampling:L5({createMessage:wJ.optional()}).optional(),elicitation:L5({create:wJ.optional()}).optional()}).optional()}),mq0=L5({list:wJ.optional(),cancel:wJ.optional(),requests:L5({tools:L5({call:wJ.optional()}).optional()}).optional()}),cq0=s0({experimental:n$(DQ(),wJ).optional(),sampling:s0({context:wJ.optional(),tools:wJ.optional()}).optional(),elicitation:hq0.optional(),roots:s0({listChanged:F9().optional()}).optional(),tasks:uq0.optional(),extensions:n$(DQ(),wJ).optional()}),dq0=yG.extend({protocolVersion:DQ(),capabilities:cq0,clientInfo:K9Q}),CFA=i5.extend({method:VB("initialize"),params:dq0});var lq0=s0({experimental:n$(DQ(),wJ).optional(),logging:wJ.optional(),completions:wJ.optional(),prompts:s0({listChanged:F9().optional()}).optional(),resources:s0({subscribe:F9().optional(),listChanged:F9().optional()}).optional(),tools:s0({listChanged:F9().optional()}).optional(),tasks:mq0.optional(),extensions:n$(DQ(),wJ).optional()}),pq0=n5.extend({protocolVersion:DQ(),capabilities:lq0,serverInfo:K9Q,instructions:DQ().optional()}),OFA=KW.extend({method:VB("notifications/initialized"),params:GW.optional()});var iAA=i5.extend({method:VB("ping"),params:yG.optional()}),iq0=s0({progress:K$(),total:C4(K$()),message:C4(DQ())}),nq0=s0({...GW.shape,...iq0.shape,progressToken:A9Q}),nAA=KW.extend({method:VB("notifications/progress"),params:nq0}),aq0=yG.extend({cursor:Q9Q.optional()}),Wh=i5.extend({params:aq0.optional()}),Zh=n5.extend({nextCursor:Q9Q.optional()}),oq0=V5(["working","input_required","completed","failed","cancelled"]),Hh=s0({taskId:DQ(),status:oq0,ttl:K4([K$(),Nk()]),createdAt:DQ(),lastUpdatedAt:DQ(),pollInterval:C4(K$()),statusMessage:C4(DQ())}),cw=n5.extend({task:Hh}),rq0=GW.merge(Hh),qh=KW.extend({method:VB("notifications/tasks/status"),params:rq0}),aAA=i5.extend({method:VB("tasks/get"),params:yG.extend({taskId:DQ()})}),oAA=n5.merge(Hh),rAA=i5.extend({method:VB("tasks/result"),params:yG.extend({taskId:DQ()})}),F01=n5.loose(),sAA=Wh.extend({method:VB("tasks/list")}),tAA=Zh.extend({tasks:K8(Hh)}),eAA=i5.extend({method:VB("tasks/cancel"),params:yG.extend({taskId:DQ()})}),W9Q=n5.merge(Hh),Z9Q=s0({uri:DQ(),mimeType:C4(DQ()),_meta:n$(DQ(),G4()).optional()}),H9Q=Z9Q.extend({text:DQ()}),MFA=DQ().refine((A)=>{try{return atob(A),!0}catch{return!1}},{message:"Invalid Base64 string"}),q9Q=Z9Q.extend({blob:MFA}),Dh=V5(["user","assistant"]),dw=s0({audience:K8(Dh).optional(),priority:K$().min(0).max(1).optional(),lastModified:s2.datetime({offset:!0}).optional()}),D9Q=s0({...mw.shape,...Kh.shape,uri:DQ(),description:C4(DQ()),mimeType:C4(DQ()),size:C4(K$()),annotations:dw.optional(),_meta:C4(L5({}))}),sq0=s0({...mw.shape,...Kh.shape,uriTemplate:DQ(),description:C4(DQ()),mimeType:C4(DQ()),annotations:dw.optional(),_meta:C4(L5({}))}),AQA=Wh.extend({method:VB("resources/list")}),tq0=Zh.extend({resources:K8(D9Q)}),QQA=Wh.extend({method:VB("resources/templates/list")}),eq0=Zh.extend({resourceTemplates:K8(sq0)}),NFA=yG.extend({uri:DQ()}),AD0=NFA,BQA=i5.extend({method:VB("resources/read"),params:AD0}),QD0=n5.extend({contents:K8(K4([H9Q,q9Q]))}),BD0=KW.extend({method:VB("notifications/resources/list_changed"),params:GW.optional()}),$D0=NFA,JD0=i5.extend({method:VB("resources/subscribe"),params:$D0}),YD0=NFA,XD0=i5.extend({method:VB("resources/unsubscribe"),params:YD0}),GD0=GW.extend({uri:DQ()}),KD0=KW.extend({method:VB("notifications/resources/updated"),params:GD0}),WD0=s0({name:DQ(),description:C4(DQ()),required:C4(F9())}),ZD0=s0({...mw.shape,...Kh.shape,description:C4(DQ()),arguments:C4(K8(WD0)),_meta:C4(L5({}))}),$QA=Wh.extend({method:VB("prompts/list")}),HD0=Zh.extend({prompts:K8(ZD0)}),qD0=yG.extend({name:DQ(),arguments:n$(DQ(),DQ()).optional()}),JQA=i5.extend({method:VB("prompts/get"),params:qD0}),LFA=s0({type:VB("text"),text:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),VFA=s0({type:VB("image"),data:MFA,mimeType:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),EFA=s0({type:VB("audio"),data:MFA,mimeType:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),DD0=s0({type:VB("tool_use"),name:DQ(),id:DQ(),input:n$(DQ(),G4()),_meta:n$(DQ(),G4()).optional()}),FD0=s0({type:VB("resource"),resource:K4([H9Q,q9Q]),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),UD0=D9Q.extend({type:VB("resource_link")}),RFA=K4([LFA,VFA,EFA,UD0,FD0]),zD0=s0({role:Dh,content:RFA}),ID0=n5.extend({description:DQ().optional(),messages:K8(zD0)}),CD0=KW.extend({method:VB("notifications/prompts/list_changed"),params:GW.optional()}),OD0=s0({title:DQ().optional(),readOnlyHint:F9().optional(),destructiveHint:F9().optional(),idempotentHint:F9().optional(),openWorldHint:F9().optional()}),MD0=s0({taskSupport:V5(["required","optional","forbidden"]).optional()}),F9Q=s0({...mw.shape,...Kh.shape,description:DQ().optional(),inputSchema:s0({type:VB("object"),properties:n$(DQ(),wJ).optional(),required:K8(DQ()).optional()}).catchall(G4()),outputSchema:s0({type:VB("object"),properties:n$(DQ(),wJ).optional(),required:K8(DQ()).optional()}).catchall(G4()).optional(),annotations:OD0.optional(),execution:MD0.optional(),_meta:n$(DQ(),G4()).optional()}),YQA=Wh.extend({method:VB("tools/list")}),ND0=Zh.extend({tools:K8(F9Q)}),XQA=n5.extend({content:K8(RFA).default([]),structuredContent:n$(DQ(),G4()).optional(),isError:F9().optional()}),U01=XQA.or(n5.extend({toolResult:G4()})),LD0=Xh.extend({name:DQ(),arguments:n$(DQ(),G4()).optional()}),lw=i5.extend({method:VB("tools/call"),params:LD0}),VD0=KW.extend({method:VB("notifications/tools/list_changed"),params:GW.optional()}),z01=s0({autoRefresh:F9().default(!0),debounceMs:K$().int().nonnegative().default(300)}),Fh=V5(["debug","info","notice","warning","error","critical","alert","emergency"]),ED0=yG.extend({level:Fh}),jFA=i5.extend({method:VB("logging/setLevel"),params:ED0}),RD0=GW.extend({level:Fh,logger:DQ().optional(),data:G4()}),jD0=KW.extend({method:VB("notifications/message"),params:RD0}),wD0=s0({name:DQ().optional()}),_D0=s0({hints:K8(wD0).optional(),costPriority:K$().min(0).max(1).optional(),speedPriority:K$().min(0).max(1).optional(),intelligencePriority:K$().min(0).max(1).optional()}),PD0=s0({mode:V5(["auto","required","none"]).optional()}),TD0=s0({type:VB("tool_result"),toolUseId:DQ().describe("The unique identifier for the corresponding tool call."),content:K8(RFA).default([]),structuredContent:s0({}).loose().optional(),isError:F9().optional(),_meta:n$(DQ(),G4()).optional()}),kD0=Rk("type",[LFA,VFA,EFA]),mAA=Rk("type",[LFA,VFA,EFA,DD0,TD0]),SD0=s0({role:Dh,content:K4([mAA,K8(mAA)]),_meta:n$(DQ(),G4()).optional()}),xD0=Xh.extend({messages:K8(SD0),modelPreferences:_D0.optional(),systemPrompt:DQ().optional(),includeContext:V5(["none","thisServer","allServers"]).optional(),temperature:K$().optional(),maxTokens:K$().int(),stopSequences:K8(DQ()).optional(),metadata:wJ.optional(),tools:K8(F9Q).optional(),toolChoice:PD0.optional()}),bD0=i5.extend({method:VB("sampling/createMessage"),params:xD0}),Uh=n5.extend({model:DQ(),stopReason:C4(V5(["endTurn","stopSequence","maxTokens"]).or(DQ())),role:Dh,content:kD0}),wFA=n5.extend({model:DQ(),stopReason:C4(V5(["endTurn","stopSequence","maxTokens","toolUse"]).or(DQ())),role:Dh,content:K4([mAA,K8(mAA)])}),fD0=s0({type:VB("boolean"),title:DQ().optional(),description:DQ().optional(),default:F9().optional()}),vD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),minLength:K$().optional(),maxLength:K$().optional(),format:V5(["email","uri","date","date-time"]).optional(),default:DQ().optional()}),gD0=s0({type:V5(["number","integer"]),title:DQ().optional(),description:DQ().optional(),minimum:K$().optional(),maximum:K$().optional(),default:K$().optional()}),yD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),enum:K8(DQ()),default:DQ().optional()}),hD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),oneOf:K8(s0({const:DQ(),title:DQ()})),default:DQ().optional()}),uD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),enum:K8(DQ()),enumNames:K8(DQ()).optional(),default:DQ().optional()}),mD0=K4([yD0,hD0]),cD0=s0({type:VB("array"),title:DQ().optional(),description:DQ().optional(),minItems:K$().optional(),maxItems:K$().optional(),items:s0({type:VB("string"),enum:K8(DQ())}),default:K8(DQ()).optional()}),dD0=s0({type:VB("array"),title:DQ().optional(),description:DQ().optional(),minItems:K$().optional(),maxItems:K$().optional(),items:s0({anyOf:K8(s0({const:DQ(),title:DQ()}))}),default:K8(DQ()).optional()}),lD0=K4([cD0,dD0]),pD0=K4([uD0,mD0,lD0]),iD0=K4([pD0,fD0,vD0,gD0]),nD0=Xh.extend({mode:VB("form").optional(),message:DQ(),requestedSchema:s0({type:VB("object"),properties:n$(DQ(),iD0),required:K8(DQ()).optional()})}),aD0=Xh.extend({mode:VB("url"),message:DQ(),elicitationId:DQ(),url:DQ().url()}),oD0=K4([nD0,aD0]),rD0=i5.extend({method:VB("elicitation/create"),params:oD0}),sD0=GW.extend({elicitationId:DQ()}),tD0=KW.extend({method:VB("notifications/elicitation/complete"),params:sD0}),pw=n5.extend({action:V5(["accept","decline","cancel"]),content:Pk((A)=>A===null?void 0:A,n$(DQ(),K4([DQ(),K$(),F9(),K8(DQ())])).optional())}),eD0=s0({type:VB("ref/resource"),uri:DQ()});var AF0=s0({type:VB("ref/prompt"),name:DQ()}),QF0=yG.extend({ref:K4([AF0,eD0]),argument:s0({name:DQ(),value:DQ()}),context:s0({arguments:n$(DQ(),DQ()).optional()}).optional()}),GQA=i5.extend({method:VB("completion/complete"),params:QF0});function U9Q(A){if(A.params.ref.type!=="ref/prompt")throw TypeError(`Expected CompleteRequestPrompt, but got ${A.params.ref.type}`)}function z9Q(A){if(A.params.ref.type!=="ref/resource")throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${A.params.ref.type}`)}var BF0=n5.extend({completion:L5({values:K8(DQ()).max(100),total:C4(K$().int()),hasMore:C4(F9())})}),$F0=s0({uri:DQ().startsWith("file://"),name:DQ().optional(),_meta:n$(DQ(),G4()).optional()}),JF0=i5.extend({method:VB("roots/list"),params:yG.optional()}),_FA=n5.extend({roots:K8($F0)}),YF0=KW.extend({method:VB("notifications/roots/list_changed"),params:GW.optional()}),I01=K4([iAA,CFA,GQA,jFA,JQA,$QA,AQA,QQA,BQA,JD0,XD0,lw,YQA,aAA,rAA,sAA,eAA]),C01=K4([pAA,nAA,OFA,YF0,qh]),O01=K4([lAA,Uh,wFA,pw,_FA,oAA,tAA,cw]),M01=K4([iAA,bD0,rD0,JF0,aAA,rAA,sAA,eAA]),N01=K4([pAA,nAA,jD0,KD0,BD0,VD0,CD0,qh,tD0]),L01=K4([lAA,pq0,BF0,ID0,HD0,tq0,eq0,QD0,XQA,ND0,oAA,tAA,cw]);class RB extends Error{constructor(A,Q,B){super(`MCP error ${A}: ${Q}`);this.code=A,this.data=B,this.name="McpError"}static fromError(A,Q,B){if(A===uB.UrlElicitationRequired&&B){let $=B;if($.elicitations)return new I9Q($.elicitations,Q)}return new RB(A,Q,B)}}class I9Q extends RB{constructor(A,Q=`URL elicitation${A.length>1?"s":""} required`){super(uB.UrlElicitationRequired,Q,{elicitations:A})}get elicitations(){return this.data?.elicitations??[]}}function YI(A){return A==="completed"||A==="failed"||A==="cancelled"}var O9Q=Symbol("Let zodToJsonSchema decide on which parser to use");var C9Q={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},M9Q=(A)=>typeof A==="string"?{...C9Q,name:A}:{...C9Q,...A};var N9Q=(A)=>{let Q=M9Q(A),B=Q.name!==void 0?[...Q.basePath,Q.definitionPath,Q.name]:Q.basePath;return{...Q,flags:{hasReferencedOpenAiAnyType:!1},currentPath:B,propertyPath:void 0,seen:new Map(Object.entries(Q.definitions).map(([$,J])=>[J._def,{def:J._def,path:[...Q.basePath,Q.definitionPath,$],jsonSchema:void 0}]))}};function PFA(A,Q,B,$){if(!$?.errorMessages)return;if(B)A.errorMessage={...A.errorMessage,[Q]:B}}function a8(A,Q,B,$,J){A[Q]=B,PFA(A,Q,$,J)}var KQA=(A,Q)=>{let B=0;for(;B<A.length&&B<Q.length;B++)if(A[B]!==Q[B])break;return[(A.length-B).toString(),...Q.slice(B)].join("/")};function V6(A){if(A.target!=="openAi")return{};let Q=[...A.basePath,A.definitionPath,A.openAiAnyTypeName];return A.flags.hasReferencedOpenAiAnyType=!0,{$ref:A.$refStrategy==="relative"?KQA(Q,A.currentPath):Q.join("/")}}function L9Q(A,Q){let B={type:"array"};if(A.type?._def&&A.type?._def?.typeName!==Z0.ZodAny)B.items=$1(A.type._def,{...Q,currentPath:[...Q.currentPath,"items"]});if(A.minLength)a8(B,"minItems",A.minLength.value,A.minLength.message,Q);if(A.maxLength)a8(B,"maxItems",A.maxLength.value,A.maxLength.message,Q);if(A.exactLength)a8(B,"minItems",A.exactLength.value,A.exactLength.message,Q),a8(B,"maxItems",A.exactLength.value,A.exactLength.message,Q);return B}function V9Q(A,Q){let B={type:"integer",format:"int64"};if(!A.checks)return B;for(let $ of A.checks)switch($.kind){case"min":if(Q.target==="jsonSchema7")if($.inclusive)a8(B,"minimum",$.value,$.message,Q);else a8(B,"exclusiveMinimum",$.value,$.message,Q);else{if(!$.inclusive)B.exclusiveMinimum=!0;a8(B,"minimum",$.value,$.message,Q)}break;case"max":if(Q.target==="jsonSchema7")if($.inclusive)a8(B,"maximum",$.value,$.message,Q);else a8(B,"exclusiveMaximum",$.value,$.message,Q);else{if(!$.inclusive)B.exclusiveMaximum=!0;a8(B,"maximum",$.value,$.message,Q)}break;case"multipleOf":a8(B,"multipleOf",$.value,$.message,Q);break}return B}function E9Q(){return{type:"boolean"}}function WQA(A,Q){return $1(A.type._def,Q)}var R9Q=(A,Q)=>{return $1(A.innerType._def,Q)};function TFA(A,Q,B){let $=B??Q.dateStrategy;if(Array.isArray($))return{anyOf:$.map((J,Y)=>TFA(A,Q,J))};switch($){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return XF0(A,Q)}}var XF0=(A,Q)=>{let B={type:"integer",format:"unix-time"};if(Q.target==="openApi3")return B;for(let $ of A.checks)switch($.kind){case"min":a8(B,"minimum",$.value,$.message,Q);break;case"max":a8(B,"maximum",$.value,$.message,Q);break}return B};function j9Q(A,Q){return{...$1(A.innerType._def,Q),default:A.defaultValue()}}function w9Q(A,Q){return Q.effectStrategy==="input"?$1(A.schema._def,Q):V6(Q)}function _9Q(A){return{type:"string",enum:Array.from(A.values)}}var GF0=(A)=>{if("type"in A&&A.type==="string")return!1;return"allOf"in A};function P9Q(A,Q){let B=[$1(A.left._def,{...Q,currentPath:[...Q.currentPath,"allOf","0"]}),$1(A.right._def,{...Q,currentPath:[...Q.currentPath,"allOf","1"]})].filter((Y)=>!!Y),$=Q.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,J=[];return B.forEach((Y)=>{if(GF0(Y)){if(J.push(...Y.allOf),Y.unevaluatedProperties===void 0)$=void 0}else{let X=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:G,...K}=Y;X=K}else $=void 0;J.push(X)}}),J.length?{allOf:J,...$}:void 0}function T9Q(A,Q){let B=typeof A.value;if(B!=="bigint"&&B!=="number"&&B!=="boolean"&&B!=="string")return{type:Array.isArray(A.value)?"array":"object"};if(Q.target==="openApi3")return{type:B==="bigint"?"integer":B,enum:[A.value]};return{type:B==="bigint"?"integer":B,const:A.value}}var kFA=void 0,SZ={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(kFA===void 0)kFA=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return kFA},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ZQA(A,Q){let B={type:"string"};if(A.checks)for(let $ of A.checks)switch($.kind){case"min":a8(B,"minLength",typeof B.minLength==="number"?Math.max(B.minLength,$.value):$.value,$.message,Q);break;case"max":a8(B,"maxLength",typeof B.maxLength==="number"?Math.min(B.maxLength,$.value):$.value,$.message,Q);break;case"email":switch(Q.emailStrategy){case"format:email":xZ(B,"email",$.message,Q);break;case"format:idn-email":xZ(B,"idn-email",$.message,Q);break;case"pattern:zod":m7(B,SZ.email,$.message,Q);break}break;case"url":xZ(B,"uri",$.message,Q);break;case"uuid":xZ(B,"uuid",$.message,Q);break;case"regex":m7(B,$.regex,$.message,Q);break;case"cuid":m7(B,SZ.cuid,$.message,Q);break;case"cuid2":m7(B,SZ.cuid2,$.message,Q);break;case"startsWith":m7(B,RegExp(`^${SFA($.value,Q)}`),$.message,Q);break;case"endsWith":m7(B,RegExp(`${SFA($.value,Q)}$`),$.message,Q);break;case"datetime":xZ(B,"date-time",$.message,Q);break;case"date":xZ(B,"date",$.message,Q);break;case"time":xZ(B,"time",$.message,Q);break;case"duration":xZ(B,"duration",$.message,Q);break;case"length":a8(B,"minLength",typeof B.minLength==="number"?Math.max(B.minLength,$.value):$.value,$.message,Q),a8(B,"maxLength",typeof B.maxLength==="number"?Math.min(B.maxLength,$.value):$.value,$.message,Q);break;case"includes":{m7(B,RegExp(SFA($.value,Q)),$.message,Q);break}case"ip":{if($.version!=="v6")xZ(B,"ipv4",$.message,Q);if($.version!=="v4")xZ(B,"ipv6",$.message,Q);break}case"base64url":m7(B,SZ.base64url,$.message,Q);break;case"jwt":m7(B,SZ.jwt,$.message,Q);break;case"cidr":{if($.version!=="v6")m7(B,SZ.ipv4Cidr,$.message,Q);if($.version!=="v4")m7(B,SZ.ipv6Cidr,$.message,Q);break}case"emoji":m7(B,SZ.emoji(),$.message,Q);break;case"ulid":{m7(B,SZ.ulid,$.message,Q);break}case"base64":{switch(Q.base64Strategy){case"format:binary":{xZ(B,"binary",$.message,Q);break}case"contentEncoding:base64":{a8(B,"contentEncoding","base64",$.message,Q);break}case"pattern:zod":{m7(B,SZ.base64,$.message,Q);break}}break}case"nanoid":m7(B,SZ.nanoid,$.message,Q);case"toLowerCase":case"toUpperCase":case"trim":break;default:((J)=>{})($)}return B}function SFA(A,Q){return Q.patternStrategy==="escape"?WF0(A):A}var KF0=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function WF0(A){let Q="";for(let B=0;B<A.length;B++){if(!KF0.has(A[B]))Q+="\\";Q+=A[B]}return Q}function xZ(A,Q,B,$){if(A.format||A.anyOf?.some((J)=>J.format)){if(!A.anyOf)A.anyOf=[];if(A.format){if(A.anyOf.push({format:A.format,...A.errorMessage&&$.errorMessages&&{errorMessage:{format:A.errorMessage.format}}}),delete A.format,A.errorMessage){if(delete A.errorMessage.format,Object.keys(A.errorMessage).length===0)delete A.errorMessage}}A.anyOf.push({format:Q,...B&&$.errorMessages&&{errorMessage:{format:B}}})}else a8(A,"format",Q,B,$)}function m7(A,Q,B,$){if(A.pattern||A.allOf?.some((J)=>J.pattern)){if(!A.allOf)A.allOf=[];if(A.pattern){if(A.allOf.push({pattern:A.pattern,...A.errorMessage&&$.errorMessages&&{errorMessage:{pattern:A.errorMessage.pattern}}}),delete A.pattern,A.errorMessage){if(delete A.errorMessage.pattern,Object.keys(A.errorMessage).length===0)delete A.errorMessage}}A.allOf.push({pattern:k9Q(Q,$),...B&&$.errorMessages&&{errorMessage:{pattern:B}}})}else a8(A,"pattern",k9Q(Q,$),B,$)}function k9Q(A,Q){if(!Q.applyRegexFlags||!A.flags)return A.source;let B={i:A.flags.includes("i"),m:A.flags.includes("m"),s:A.flags.includes("s")},$=B.i?A.source.toLowerCase():A.source,J="",Y=!1,X=!1,G=!1;for(let K=0;K<$.length;K++){if(Y){J+=$[K],Y=!1;continue}if(B.i){if(X){if($[K].match(/[a-z]/)){if(G)J+=$[K],J+=`${$[K-2]}-${$[K]}`.toUpperCase(),G=!1;else if($[K+1]==="-"&&$[K+2]?.match(/[a-z]/))J+=$[K],G=!0;else J+=`${$[K]}${$[K].toUpperCase()}`;continue}}else if($[K].match(/[a-z]/)){J+=`[${$[K]}${$[K].toUpperCase()}]`;continue}}if(B.m){if($[K]==="^"){J+=`(^|(?<=[\r
|
|
1340
|
+
\uD83D\uDCA1 Run "${f==="ios"?o:DA}", then try again.`),await X6();if(h==="doctor")try{await aC({packageJson:E4},!1)}catch(y){XA.warn(`Doctor found an issue: ${hA(y)}`)}if(h==="retry"){if(!await MAA(f,r.runner,K))XA.warn(`Still could not add ${f}. Continuing without native platforms for now.`)}}}}}let F=await hy(K,()=>XX());Q=hB(Q,H?.config),Q??=await py("Enter your appId:");let U=W4();if(!t4Q()||A){U.start(`Running: ${$.runner} @capgo/cli@latest login ***`);try{await vy(B.apikey,B,!0),U.stop("Login Done ✅")}catch(p){throw U.stop("Login failed ❌"),p}}let z=await YB(B.apikey,B.supaHost,B.supaAnon);await u8(z,B.apikey);let I=()=>{X=0,Y=void 0,E4=void 0,CF=void 0,dX=pDA,Tw="ios",cy=!1,IF=void 0,$W=void 0,uDA=void 0,mDA=void 0,EJ=void 0,RH(void 0),JW=void 0,CU(void 0),YW=void 0,cDA()},O;if(Y){let p=Y,{error:r,data:DA}=await z.rpc("get_orgs_v7");if(r||!DA)XA.error(`Cannot verify organization access: ${r?JSON.stringify(r):"no data returned"}`),XA.warn("Falling back to organization selection."),O=await yy(z,B.apikey),I();else{let o=DA.find((S)=>S.gid===p.orgId),g=o?.enforcing_2fa&&!o["2fa_has_access"],f=o?await nC(z,B.apikey,"org.create_app",{orgId:o.gid}):!1;if(!o)XA.warn(`Previously used organization "${p.orgName}" is no longer available. Please select a new one.`),O=await yy(z,B.apikey),I();else if(!f)XA.warn(`You no longer have permission to create an app in "${o.name}". Please select a different organization.`),O=await yy(z,B.apikey),I();else if(g)XA.warn(`Organization "${o.name}" now requires 2FA. Enable it at ${FX("/settings/account")}`),XA.warn("Please select a different organization or enable 2FA and try again."),O=await yy(z,B.apikey),I();else O=o,XA.info(`Using organization "${o.name}"`)}}else O=await yy(z,B.apikey);let V=O.gid;if(uDA=V,mDA=O.name,Y?.appId)Q=Y.appId,$W=Q;let E=await Q30(O,B.apikey,Q,z);if(Q=E.appId??Q,await eH0(V,B.apikey,Q,E.pendingApp),G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G),E.reusedPendingApp)X=Math.max(X,1);let M=UX(void 0,E4)||"1.0.0",N=cy,R=IF||M,T=dX,x=Tw;if(IF&&X>=3)M=IF;let m=fG.length,i=X>0,b=(p)=>{zAA=p,Q6Q(p,m,{resumed:i}),i=!1};try{if(X<1)b(1),await B30(V,B.apikey),Q=await X30(O,B.apikey,Q,B),$W=Q,vG(1);if(X<2)b(2),T=await G30(V,B.apikey,Q),dX=T,vG(2,void 0,T);if(X<3){b(3);let p=await C30(V,B.apikey,Q);M=p.pkgVersion,R=M,N=p.delta,IF=R,cy=N,G=L6.resolve(E4??d4(W8(u1()),W$)),K=h7(G);try{H=await hy(K,()=>N0())}catch{H=void 0}vG(3)}if(X<4)b(4),await O30(V,B.apikey,Q),vG(4);if(X<5)b(5),await g6Q(V,B.apikey,Q),vG(5);if(EJ)EJ=void 0,RH(void 0);if(X<6)b(6),x=await r30(V,B.apikey,H?.config,K),Tw=x,vG(6);if(X<7)b(7),await P30(V,B.apikey,Q,x,H?.config),vG(7);if(JW)JW=void 0,CU(void 0);if(X<8)b(8),await s30(V,B.apikey,Q,x,K),vG(8);if(X<9)b(9),R=await t30(V,B.apikey,Q,M,x),IF=R,vG(9);if(X<10)b(10),await Qq0(V,B.apikey,Q,R,N,x),vG(10);if(X<11)b(11),await Bq0(V,B.apikey,Q,F.hostWeb,N),vG(11);if(X<12)b(12),await Aq0(V,B.apikey,Q,R,x,N),vG(12);await jJ(V,B.apikey,"done",Q),cDA()}catch(p){let r=hA(p),DA=sDA(r),{doctor:o}=ly();if(XA.error(`Error during onboarding: ${r}`),DA)XA.error(`Support bundle saved to ${DA}`);else XA.error("Could not save a support bundle automatically.");return XA.error(`Run ${o} for extra diagnostics before contacting support@capgo.app`),XA.error("Manual installation guide: https://capgo.app/docs/getting-started/add-an-app/"),await X6(1)}B6Q(Q,`${$.runner} @capgo/cli@latest bundle upload --bundle <new-version> --channel ${dX}`,`${$.runner} @capgo/cli@latest app debug`),XA.info("If you want to run another full OTA self-test after onboarding:"),XA.info("1. Make a visible change"),XA.info(`2. Build web assets only: ${$.pm} run build`),XA.info(`3. Upload with a new version: ${$.runner} @capgo/cli@latest bundle upload --bundle <new-version> --channel ${dX}`),XA.warn(`Do not run "${$.runner} cap sync" before validating the OTA update.`),XA.warn("Reason: cap sync puts your local build directly in the native app, which bypasses the Capgo OTA path."),XA.info(`If you have any issue try to use the debug command \`${$.runner} @capgo/cli@latest app debug\``);let u=await Jq0();return await Yq0(u),O4("Bye \uD83D\uDC4B"),await X6()}import oV0 from"node:process";var y8;(function(A){A.assertEqual=(J)=>{};function Q(J){}A.assertIs=Q;function B(J){throw Error()}A.assertNever=B,A.arrayToEnum=(J)=>{let Y={};for(let X of J)Y[X]=X;return Y},A.getValidEnumValues=(J)=>{let Y=A.objectKeys(J).filter((G)=>typeof J[J[G]]!=="number"),X={};for(let G of Y)X[G]=J[G];return A.objectValues(X)},A.objectValues=(J)=>{return A.objectKeys(J).map(function(Y){return J[Y]})},A.objectKeys=typeof Object.keys==="function"?(J)=>Object.keys(J):(J)=>{let Y=[];for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X))Y.push(X);return Y},A.find=(J,Y)=>{for(let X of J)if(Y(X))return X;return},A.isInteger=typeof Number.isInteger==="function"?(J)=>Number.isInteger(J):(J)=>typeof J==="number"&&Number.isFinite(J)&&Math.floor(J)===J;function $(J,Y=" | "){return J.map((X)=>typeof X==="string"?`'${X}'`:X).join(Y)}A.joinValues=$,A.jsonStringifyReplacer=(J,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(y8||(y8={}));var p6Q;(function(A){A.mergeShapes=(Q,B)=>{return{...Q,...B}}})(p6Q||(p6Q={}));var M0=y8.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),NF=(A)=>{switch(typeof A){case"undefined":return M0.undefined;case"string":return M0.string;case"number":return Number.isNaN(A)?M0.nan:M0.number;case"boolean":return M0.boolean;case"function":return M0.function;case"bigint":return M0.bigint;case"symbol":return M0.symbol;case"object":if(Array.isArray(A))return M0.array;if(A===null)return M0.null;if(A.then&&typeof A.then==="function"&&A.catch&&typeof A.catch==="function")return M0.promise;if(typeof Map<"u"&&A instanceof Map)return M0.map;if(typeof Set<"u"&&A instanceof Set)return M0.set;if(typeof Date<"u"&&A instanceof Date)return M0.date;return M0.object;default:return M0.unknown}};var X0=y8.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class gG extends Error{get errors(){return this.issues}constructor(A){super();this.issues=[],this.addIssue=(B)=>{this.issues=[...this.issues,B]},this.addIssues=(B=[])=>{this.issues=[...this.issues,...B]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=A}format(A){let Q=A||function(J){return J.message},B={_errors:[]},$=(J)=>{for(let Y of J.issues)if(Y.code==="invalid_union")Y.unionErrors.map($);else if(Y.code==="invalid_return_type")$(Y.returnTypeError);else if(Y.code==="invalid_arguments")$(Y.argumentsError);else if(Y.path.length===0)B._errors.push(Q(Y));else{let X=B,G=0;while(G<Y.path.length){let K=Y.path[G];if(G!==Y.path.length-1)X[K]=X[K]||{_errors:[]};else X[K]=X[K]||{_errors:[]},X[K]._errors.push(Q(Y));X=X[K],G++}}};return $(this),B}static assert(A){if(!(A instanceof gG))throw Error(`Not a ZodError: ${A}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,y8.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(A=(Q)=>Q.message){let Q=Object.create(null),B=[];for(let $ of this.issues)if($.path.length>0){let J=$.path[0];Q[J]=Q[J]||[],Q[J].push(A($))}else B.push(A($));return{formErrors:B,fieldErrors:Q}}get formErrors(){return this.flatten()}}gG.create=(A)=>{return new gG(A)};var Xq0=(A,Q)=>{let B;switch(A.code){case X0.invalid_type:if(A.received===M0.undefined)B="Required";else B=`Expected ${A.expected}, received ${A.received}`;break;case X0.invalid_literal:B=`Invalid literal value, expected ${JSON.stringify(A.expected,y8.jsonStringifyReplacer)}`;break;case X0.unrecognized_keys:B=`Unrecognized key(s) in object: ${y8.joinValues(A.keys,", ")}`;break;case X0.invalid_union:B="Invalid input";break;case X0.invalid_union_discriminator:B=`Invalid discriminator value. Expected ${y8.joinValues(A.options)}`;break;case X0.invalid_enum_value:B=`Invalid enum value. Expected ${y8.joinValues(A.options)}, received '${A.received}'`;break;case X0.invalid_arguments:B="Invalid function arguments";break;case X0.invalid_return_type:B="Invalid function return type";break;case X0.invalid_date:B="Invalid date";break;case X0.invalid_string:if(typeof A.validation==="object")if("includes"in A.validation){if(B=`Invalid input: must include "${A.validation.includes}"`,typeof A.validation.position==="number")B=`${B} at one or more positions greater than or equal to ${A.validation.position}`}else if("startsWith"in A.validation)B=`Invalid input: must start with "${A.validation.startsWith}"`;else if("endsWith"in A.validation)B=`Invalid input: must end with "${A.validation.endsWith}"`;else y8.assertNever(A.validation);else if(A.validation!=="regex")B=`Invalid ${A.validation}`;else B="Invalid";break;case X0.too_small:if(A.type==="array")B=`Array must contain ${A.exact?"exactly":A.inclusive?"at least":"more than"} ${A.minimum} element(s)`;else if(A.type==="string")B=`String must contain ${A.exact?"exactly":A.inclusive?"at least":"over"} ${A.minimum} character(s)`;else if(A.type==="number")B=`Number must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${A.minimum}`;else if(A.type==="bigint")B=`Number must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${A.minimum}`;else if(A.type==="date")B=`Date must be ${A.exact?"exactly equal to ":A.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(A.minimum))}`;else B="Invalid input";break;case X0.too_big:if(A.type==="array")B=`Array must contain ${A.exact?"exactly":A.inclusive?"at most":"less than"} ${A.maximum} element(s)`;else if(A.type==="string")B=`String must contain ${A.exact?"exactly":A.inclusive?"at most":"under"} ${A.maximum} character(s)`;else if(A.type==="number")B=`Number must be ${A.exact?"exactly":A.inclusive?"less than or equal to":"less than"} ${A.maximum}`;else if(A.type==="bigint")B=`BigInt must be ${A.exact?"exactly":A.inclusive?"less than or equal to":"less than"} ${A.maximum}`;else if(A.type==="date")B=`Date must be ${A.exact?"exactly":A.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(A.maximum))}`;else B="Invalid input";break;case X0.custom:B="Invalid input";break;case X0.invalid_intersection_types:B="Intersection results could not be merged";break;case X0.not_multiple_of:B=`Number must be a multiple of ${A.multipleOf}`;break;case X0.not_finite:B="Number must be finite";break;default:B=Q.defaultError,y8.assertNever(A)}return{message:B}},AI=Xq0;var Gq0=AI;function iy(){return Gq0}var PAA=(A)=>{let{data:Q,path:B,errorMaps:$,issueData:J}=A,Y=[...B,...J.path||[]],X={...J,path:Y};if(J.message!==void 0)return{...J,path:Y,message:J.message};let G="",K=$.filter((W)=>!!W).slice().reverse();for(let W of K)G=W(X,{data:Q,defaultError:G}).message;return{...J,path:Y,message:G}};function h0(A,Q){let B=iy(),$=PAA({issueData:Q,data:A.data,path:A.path,errorMaps:[A.common.contextualErrorMap,A.schemaErrorMap,B,B===AI?void 0:AI].filter((J)=>!!J)});A.common.issues.push($)}class xY{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(A,Q){let B=[];for(let $ of Q){if($.status==="aborted")return B1;if($.status==="dirty")A.dirty();B.push($.value)}return{status:A.value,value:B}}static async mergeObjectAsync(A,Q){let B=[];for(let $ of Q){let J=await $.key,Y=await $.value;B.push({key:J,value:Y})}return xY.mergeObjectSync(A,B)}static mergeObjectSync(A,Q){let B={};for(let $ of Q){let{key:J,value:Y}=$;if(J.status==="aborted")return B1;if(Y.status==="aborted")return B1;if(J.status==="dirty")A.dirty();if(Y.status==="dirty")A.dirty();if(J.value!=="__proto__"&&(typeof Y.value<"u"||$.alwaysSet))B[J.value]=Y.value}return{status:A.value,value:B}}}var B1=Object.freeze({status:"aborted"}),bw=(A)=>({status:"dirty",value:A}),u7=(A)=>({status:"valid",value:A}),XFA=(A)=>A.status==="aborted",GFA=(A)=>A.status==="dirty",YN=(A)=>A.status==="valid",ny=(A)=>typeof Promise<"u"&&A instanceof Promise;var OB;(function(A){A.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},A.toString=(Q)=>typeof Q==="string"?Q:Q?.message})(OB||(OB={}));class kZ{constructor(A,Q,B,$){this._cachedPath=[],this.parent=A,this.data=Q,this._path=B,this._key=$}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var i6Q=(A,Q)=>{if(YN(Q))return{success:!0,data:Q.value};else{if(!A.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let B=new gG(A.common.issues);return this._error=B,this._error}}}};function l1(A){if(!A)return{};let{errorMap:Q,invalid_type_error:B,required_error:$,description:J}=A;if(Q&&(B||$))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:J};return{errorMap:(X,G)=>{let{message:K}=A;if(X.code==="invalid_enum_value")return{message:K??G.defaultError};if(typeof G.data>"u")return{message:K??$??G.defaultError};if(X.code!=="invalid_type")return{message:G.defaultError};return{message:K??B??G.defaultError}},description:J}}class V8{get description(){return this._def.description}_getType(A){return NF(A.data)}_getOrReturnCtx(A,Q){return Q||{common:A.parent.common,data:A.data,parsedType:NF(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}_processInputParams(A){return{status:new xY,ctx:{common:A.parent.common,data:A.data,parsedType:NF(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}}_parseSync(A){let Q=this._parse(A);if(ny(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync(A){let Q=this._parse(A);return Promise.resolve(Q)}parse(A,Q){let B=this.safeParse(A,Q);if(B.success)return B.data;throw B.error}safeParse(A,Q){let B={common:{issues:[],async:Q?.async??!1,contextualErrorMap:Q?.errorMap},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)},$=this._parseSync({data:A,path:B.path,parent:B});return i6Q(B,$)}"~validate"(A){let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)};if(!this["~standard"].async)try{let B=this._parseSync({data:A,path:[],parent:Q});return YN(B)?{value:B.value}:{issues:Q.common.issues}}catch(B){if(B?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:A,path:[],parent:Q}).then((B)=>YN(B)?{value:B.value}:{issues:Q.common.issues})}async parseAsync(A,Q){let B=await this.safeParseAsync(A,Q);if(B.success)return B.data;throw B.error}async safeParseAsync(A,Q){let B={common:{issues:[],contextualErrorMap:Q?.errorMap,async:!0},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:NF(A)},$=this._parse({data:A,path:B.path,parent:B}),J=await(ny($)?$:Promise.resolve($));return i6Q(B,J)}refine(A,Q){let B=($)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q($);else return Q};return this._refinement(($,J)=>{let Y=A($),X=()=>J.addIssue({code:X0.custom,...B($)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((G)=>{if(!G)return X(),!1;else return!0});if(!Y)return X(),!1;else return!0})}refinement(A,Q){return this._refinement((B,$)=>{if(!A(B))return $.addIssue(typeof Q==="function"?Q(B,$):Q),!1;else return!0})}_refinement(A){return new i3({schema:this,typeName:Z0.ZodEffects,effect:{type:"refinement",refinement:A}})}superRefine(A){return this._refinement(A)}constructor(A){this.spa=this.safeParseAsync,this._def=A,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(Q)=>this["~validate"](Q)}}optional(){return p3.create(this,this._def)}nullable(){return QI.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return l3.create(this)}promise(){return hw.create(this,this._def)}or(A){return ty.create([this,A],this._def)}and(A){return ey.create(this,A,this._def)}transform(A){return new i3({...l1(this._def),schema:this,typeName:Z0.ZodEffects,effect:{type:"transform",transform:A}})}default(A){let Q=typeof A==="function"?A:()=>A;return new $h({...l1(this._def),innerType:this,defaultValue:Q,typeName:Z0.ZodDefault})}brand(){return new HFA({typeName:Z0.ZodBranded,type:this,...l1(this._def)})}catch(A){let Q=typeof A==="function"?A:()=>A;return new Jh({...l1(this._def),innerType:this,catchValue:Q,typeName:Z0.ZodCatch})}describe(A){return new this.constructor({...this._def,description:A})}pipe(A){return gAA.create(this,A)}readonly(){return Yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Kq0=/^c[^\s-]{8,}$/i,Wq0=/^[0-9a-z]+$/,Zq0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Hq0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qq0=/^[a-z0-9_-]{21}$/i,Dq0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fq0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Uq0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zq0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",KFA,Iq0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cq0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Oq0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Mq0=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nq0=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lq0=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,n6Q="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vq0=new RegExp(`^${n6Q}$`);function a6Q(A){let Q="[0-5]\\d";if(A.precision)Q=`${Q}\\.\\d{${A.precision}}`;else if(A.precision==null)Q=`${Q}(\\.\\d+)?`;let B=A.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${Q})${B}`}function Eq0(A){return new RegExp(`^${a6Q(A)}$`)}function Rq0(A){let Q=`${n6Q}T${a6Q(A)}`,B=[];if(B.push(A.local?"Z?":"Z"),A.offset)B.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${B.join("|")})`,new RegExp(`^${Q}$`)}function jq0(A,Q){if((Q==="v4"||!Q)&&Iq0.test(A))return!0;if((Q==="v6"||!Q)&&Oq0.test(A))return!0;return!1}function wq0(A,Q){if(!Dq0.test(A))return!1;try{let[B]=A.split(".");if(!B)return!1;let $=B.replace(/-/g,"+").replace(/_/g,"/").padEnd(B.length+(4-B.length%4)%4,"="),J=JSON.parse(atob($));if(typeof J!=="object"||J===null)return!1;if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if(Q&&J.alg!==Q)return!1;return!0}catch{return!1}}function _q0(A,Q){if((Q==="v4"||!Q)&&Cq0.test(A))return!0;if((Q==="v6"||!Q)&&Mq0.test(A))return!0;return!1}class VF extends V8{_parse(A){if(this._def.coerce)A.data=String(A.data);if(this._getType(A)!==M0.string){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.string,received:J.parsedType}),B1}let B=new xY,$=void 0;for(let J of this._def.checks)if(J.kind==="min"){if(A.data.length<J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),B.dirty()}else if(J.kind==="max"){if(A.data.length>J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),B.dirty()}else if(J.kind==="length"){let Y=A.data.length>J.value,X=A.data.length<J.value;if(Y||X){if($=this._getOrReturnCtx(A,$),Y)h0($,{code:X0.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});else if(X)h0($,{code:X0.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});B.dirty()}}else if(J.kind==="email"){if(!Uq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"email",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="emoji"){if(!KFA)KFA=new RegExp(zq0,"u");if(!KFA.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"emoji",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="uuid"){if(!Hq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"uuid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="nanoid"){if(!qq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"nanoid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cuid"){if(!Kq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"cuid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cuid2"){if(!Wq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"cuid2",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="ulid"){if(!Zq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"ulid",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="url")try{new URL(A.data)}catch{$=this._getOrReturnCtx(A,$),h0($,{validation:"url",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="regex"){if(J.regex.lastIndex=0,!J.regex.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"regex",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="trim")A.data=A.data.trim();else if(J.kind==="includes"){if(!A.data.includes(J.value,J.position))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{includes:J.value,position:J.position},message:J.message}),B.dirty()}else if(J.kind==="toLowerCase")A.data=A.data.toLowerCase();else if(J.kind==="toUpperCase")A.data=A.data.toUpperCase();else if(J.kind==="startsWith"){if(!A.data.startsWith(J.value))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{startsWith:J.value},message:J.message}),B.dirty()}else if(J.kind==="endsWith"){if(!A.data.endsWith(J.value))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:{endsWith:J.value},message:J.message}),B.dirty()}else if(J.kind==="datetime"){if(!Rq0(J).test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"datetime",message:J.message}),B.dirty()}else if(J.kind==="date"){if(!Vq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"date",message:J.message}),B.dirty()}else if(J.kind==="time"){if(!Eq0(J).test(A.data))$=this._getOrReturnCtx(A,$),h0($,{code:X0.invalid_string,validation:"time",message:J.message}),B.dirty()}else if(J.kind==="duration"){if(!Fq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"duration",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="ip"){if(!jq0(A.data,J.version))$=this._getOrReturnCtx(A,$),h0($,{validation:"ip",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="jwt"){if(!wq0(A.data,J.alg))$=this._getOrReturnCtx(A,$),h0($,{validation:"jwt",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="cidr"){if(!_q0(A.data,J.version))$=this._getOrReturnCtx(A,$),h0($,{validation:"cidr",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="base64"){if(!Nq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"base64",code:X0.invalid_string,message:J.message}),B.dirty()}else if(J.kind==="base64url"){if(!Lq0.test(A.data))$=this._getOrReturnCtx(A,$),h0($,{validation:"base64url",code:X0.invalid_string,message:J.message}),B.dirty()}else y8.assertNever(J);return{status:B.value,value:A.data}}_regex(A,Q,B){return this.refinement(($)=>A.test($),{validation:Q,code:X0.invalid_string,...OB.errToObj(B)})}_addCheck(A){return new VF({...this._def,checks:[...this._def.checks,A]})}email(A){return this._addCheck({kind:"email",...OB.errToObj(A)})}url(A){return this._addCheck({kind:"url",...OB.errToObj(A)})}emoji(A){return this._addCheck({kind:"emoji",...OB.errToObj(A)})}uuid(A){return this._addCheck({kind:"uuid",...OB.errToObj(A)})}nanoid(A){return this._addCheck({kind:"nanoid",...OB.errToObj(A)})}cuid(A){return this._addCheck({kind:"cuid",...OB.errToObj(A)})}cuid2(A){return this._addCheck({kind:"cuid2",...OB.errToObj(A)})}ulid(A){return this._addCheck({kind:"ulid",...OB.errToObj(A)})}base64(A){return this._addCheck({kind:"base64",...OB.errToObj(A)})}base64url(A){return this._addCheck({kind:"base64url",...OB.errToObj(A)})}jwt(A){return this._addCheck({kind:"jwt",...OB.errToObj(A)})}ip(A){return this._addCheck({kind:"ip",...OB.errToObj(A)})}cidr(A){return this._addCheck({kind:"cidr",...OB.errToObj(A)})}datetime(A){if(typeof A==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:A});return this._addCheck({kind:"datetime",precision:typeof A?.precision>"u"?null:A?.precision,offset:A?.offset??!1,local:A?.local??!1,...OB.errToObj(A?.message)})}date(A){return this._addCheck({kind:"date",message:A})}time(A){if(typeof A==="string")return this._addCheck({kind:"time",precision:null,message:A});return this._addCheck({kind:"time",precision:typeof A?.precision>"u"?null:A?.precision,...OB.errToObj(A?.message)})}duration(A){return this._addCheck({kind:"duration",...OB.errToObj(A)})}regex(A,Q){return this._addCheck({kind:"regex",regex:A,...OB.errToObj(Q)})}includes(A,Q){return this._addCheck({kind:"includes",value:A,position:Q?.position,...OB.errToObj(Q?.message)})}startsWith(A,Q){return this._addCheck({kind:"startsWith",value:A,...OB.errToObj(Q)})}endsWith(A,Q){return this._addCheck({kind:"endsWith",value:A,...OB.errToObj(Q)})}min(A,Q){return this._addCheck({kind:"min",value:A,...OB.errToObj(Q)})}max(A,Q){return this._addCheck({kind:"max",value:A,...OB.errToObj(Q)})}length(A,Q){return this._addCheck({kind:"length",value:A,...OB.errToObj(Q)})}nonempty(A){return this.min(1,OB.errToObj(A))}trim(){return new VF({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new VF({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new VF({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((A)=>A.kind==="datetime")}get isDate(){return!!this._def.checks.find((A)=>A.kind==="date")}get isTime(){return!!this._def.checks.find((A)=>A.kind==="time")}get isDuration(){return!!this._def.checks.find((A)=>A.kind==="duration")}get isEmail(){return!!this._def.checks.find((A)=>A.kind==="email")}get isURL(){return!!this._def.checks.find((A)=>A.kind==="url")}get isEmoji(){return!!this._def.checks.find((A)=>A.kind==="emoji")}get isUUID(){return!!this._def.checks.find((A)=>A.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((A)=>A.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((A)=>A.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((A)=>A.kind==="cuid2")}get isULID(){return!!this._def.checks.find((A)=>A.kind==="ulid")}get isIP(){return!!this._def.checks.find((A)=>A.kind==="ip")}get isCIDR(){return!!this._def.checks.find((A)=>A.kind==="cidr")}get isBase64(){return!!this._def.checks.find((A)=>A.kind==="base64")}get isBase64url(){return!!this._def.checks.find((A)=>A.kind==="base64url")}get minLength(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxLength(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}}VF.create=(A)=>{return new VF({checks:[],typeName:Z0.ZodString,coerce:A?.coerce??!1,...l1(A)})};function Pq0(A,Q){let B=(A.toString().split(".")[1]||"").length,$=(Q.toString().split(".")[1]||"").length,J=B>$?B:$,Y=Number.parseInt(A.toFixed(J).replace(".","")),X=Number.parseInt(Q.toFixed(J).replace(".",""));return Y%X/10**J}class vw extends V8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(A){if(this._def.coerce)A.data=Number(A.data);if(this._getType(A)!==M0.number){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.number,received:J.parsedType}),B1}let B=void 0,$=new xY;for(let J of this._def.checks)if(J.kind==="int"){if(!y8.isInteger(A.data))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.invalid_type,expected:"integer",received:"float",message:J.message}),$.dirty()}else if(J.kind==="min"){if(J.inclusive?A.data<J.value:A.data<=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_small,minimum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),$.dirty()}else if(J.kind==="max"){if(J.inclusive?A.data>J.value:A.data>=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_big,maximum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),$.dirty()}else if(J.kind==="multipleOf"){if(Pq0(A.data,J.value)!==0)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_multiple_of,multipleOf:J.value,message:J.message}),$.dirty()}else if(J.kind==="finite"){if(!Number.isFinite(A.data))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_finite,message:J.message}),$.dirty()}else y8.assertNever(J);return{status:$.value,value:A.data}}gte(A,Q){return this.setLimit("min",A,!0,OB.toString(Q))}gt(A,Q){return this.setLimit("min",A,!1,OB.toString(Q))}lte(A,Q){return this.setLimit("max",A,!0,OB.toString(Q))}lt(A,Q){return this.setLimit("max",A,!1,OB.toString(Q))}setLimit(A,Q,B,$){return new vw({...this._def,checks:[...this._def.checks,{kind:A,value:Q,inclusive:B,message:OB.toString($)}]})}_addCheck(A){return new vw({...this._def,checks:[...this._def.checks,A]})}int(A){return this._addCheck({kind:"int",message:OB.toString(A)})}positive(A){return this._addCheck({kind:"min",value:0,inclusive:!1,message:OB.toString(A)})}negative(A){return this._addCheck({kind:"max",value:0,inclusive:!1,message:OB.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:0,inclusive:!0,message:OB.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:0,inclusive:!0,message:OB.toString(A)})}multipleOf(A,Q){return this._addCheck({kind:"multipleOf",value:A,message:OB.toString(Q)})}finite(A){return this._addCheck({kind:"finite",message:OB.toString(A)})}safe(A){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:OB.toString(A)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:OB.toString(A)})}get minValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}get isInt(){return!!this._def.checks.find((A)=>A.kind==="int"||A.kind==="multipleOf"&&y8.isInteger(A.value))}get isFinite(){let A=null,Q=null;for(let B of this._def.checks)if(B.kind==="finite"||B.kind==="int"||B.kind==="multipleOf")return!0;else if(B.kind==="min"){if(Q===null||B.value>Q)Q=B.value}else if(B.kind==="max"){if(A===null||B.value<A)A=B.value}return Number.isFinite(Q)&&Number.isFinite(A)}}vw.create=(A)=>{return new vw({checks:[],typeName:Z0.ZodNumber,coerce:A?.coerce||!1,...l1(A)})};class gw extends V8{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(A){if(this._def.coerce)try{A.data=BigInt(A.data)}catch{return this._getInvalidInput(A)}if(this._getType(A)!==M0.bigint)return this._getInvalidInput(A);let B=void 0,$=new xY;for(let J of this._def.checks)if(J.kind==="min"){if(J.inclusive?A.data<J.value:A.data<=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_small,type:"bigint",minimum:J.value,inclusive:J.inclusive,message:J.message}),$.dirty()}else if(J.kind==="max"){if(J.inclusive?A.data>J.value:A.data>=J.value)B=this._getOrReturnCtx(A,B),h0(B,{code:X0.too_big,type:"bigint",maximum:J.value,inclusive:J.inclusive,message:J.message}),$.dirty()}else if(J.kind==="multipleOf"){if(A.data%J.value!==BigInt(0))B=this._getOrReturnCtx(A,B),h0(B,{code:X0.not_multiple_of,multipleOf:J.value,message:J.message}),$.dirty()}else y8.assertNever(J);return{status:$.value,value:A.data}}_getInvalidInput(A){let Q=this._getOrReturnCtx(A);return h0(Q,{code:X0.invalid_type,expected:M0.bigint,received:Q.parsedType}),B1}gte(A,Q){return this.setLimit("min",A,!0,OB.toString(Q))}gt(A,Q){return this.setLimit("min",A,!1,OB.toString(Q))}lte(A,Q){return this.setLimit("max",A,!0,OB.toString(Q))}lt(A,Q){return this.setLimit("max",A,!1,OB.toString(Q))}setLimit(A,Q,B,$){return new gw({...this._def,checks:[...this._def.checks,{kind:A,value:Q,inclusive:B,message:OB.toString($)}]})}_addCheck(A){return new gw({...this._def,checks:[...this._def.checks,A]})}positive(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:OB.toString(A)})}negative(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:OB.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:OB.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:OB.toString(A)})}multipleOf(A,Q){return this._addCheck({kind:"multipleOf",value:A,message:OB.toString(Q)})}get minValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A}get maxValue(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A}}gw.create=(A)=>{return new gw({checks:[],typeName:Z0.ZodBigInt,coerce:A?.coerce??!1,...l1(A)})};class TAA extends V8{_parse(A){if(this._def.coerce)A.data=Boolean(A.data);if(this._getType(A)!==M0.boolean){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.boolean,received:B.parsedType}),B1}return u7(A.data)}}TAA.create=(A)=>{return new TAA({typeName:Z0.ZodBoolean,coerce:A?.coerce||!1,...l1(A)})};class oy extends V8{_parse(A){if(this._def.coerce)A.data=new Date(A.data);if(this._getType(A)!==M0.date){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_type,expected:M0.date,received:J.parsedType}),B1}if(Number.isNaN(A.data.getTime())){let J=this._getOrReturnCtx(A);return h0(J,{code:X0.invalid_date}),B1}let B=new xY,$=void 0;for(let J of this._def.checks)if(J.kind==="min"){if(A.data.getTime()<J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_small,message:J.message,inclusive:!0,exact:!1,minimum:J.value,type:"date"}),B.dirty()}else if(J.kind==="max"){if(A.data.getTime()>J.value)$=this._getOrReturnCtx(A,$),h0($,{code:X0.too_big,message:J.message,inclusive:!0,exact:!1,maximum:J.value,type:"date"}),B.dirty()}else y8.assertNever(J);return{status:B.value,value:new Date(A.data.getTime())}}_addCheck(A){return new oy({...this._def,checks:[...this._def.checks,A]})}min(A,Q){return this._addCheck({kind:"min",value:A.getTime(),message:OB.toString(Q)})}max(A,Q){return this._addCheck({kind:"max",value:A.getTime(),message:OB.toString(Q)})}get minDate(){let A=null;for(let Q of this._def.checks)if(Q.kind==="min"){if(A===null||Q.value>A)A=Q.value}return A!=null?new Date(A):null}get maxDate(){let A=null;for(let Q of this._def.checks)if(Q.kind==="max"){if(A===null||Q.value<A)A=Q.value}return A!=null?new Date(A):null}}oy.create=(A)=>{return new oy({checks:[],coerce:A?.coerce||!1,typeName:Z0.ZodDate,...l1(A)})};class kAA extends V8{_parse(A){if(this._getType(A)!==M0.symbol){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.symbol,received:B.parsedType}),B1}return u7(A.data)}}kAA.create=(A)=>{return new kAA({typeName:Z0.ZodSymbol,...l1(A)})};class ry extends V8{_parse(A){if(this._getType(A)!==M0.undefined){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.undefined,received:B.parsedType}),B1}return u7(A.data)}}ry.create=(A)=>{return new ry({typeName:Z0.ZodUndefined,...l1(A)})};class sy extends V8{_parse(A){if(this._getType(A)!==M0.null){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.null,received:B.parsedType}),B1}return u7(A.data)}}sy.create=(A)=>{return new sy({typeName:Z0.ZodNull,...l1(A)})};class SAA extends V8{constructor(){super(...arguments);this._any=!0}_parse(A){return u7(A.data)}}SAA.create=(A)=>{return new SAA({typeName:Z0.ZodAny,...l1(A)})};class XN extends V8{constructor(){super(...arguments);this._unknown=!0}_parse(A){return u7(A.data)}}XN.create=(A)=>{return new XN({typeName:Z0.ZodUnknown,...l1(A)})};class EF extends V8{_parse(A){let Q=this._getOrReturnCtx(A);return h0(Q,{code:X0.invalid_type,expected:M0.never,received:Q.parsedType}),B1}}EF.create=(A)=>{return new EF({typeName:Z0.ZodNever,...l1(A)})};class xAA extends V8{_parse(A){if(this._getType(A)!==M0.undefined){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.void,received:B.parsedType}),B1}return u7(A.data)}}xAA.create=(A)=>{return new xAA({typeName:Z0.ZodVoid,...l1(A)})};class l3 extends V8{_parse(A){let{ctx:Q,status:B}=this._processInputParams(A),$=this._def;if(Q.parsedType!==M0.array)return h0(Q,{code:X0.invalid_type,expected:M0.array,received:Q.parsedType}),B1;if($.exactLength!==null){let Y=Q.data.length>$.exactLength.value,X=Q.data.length<$.exactLength.value;if(Y||X)h0(Q,{code:Y?X0.too_big:X0.too_small,minimum:X?$.exactLength.value:void 0,maximum:Y?$.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:$.exactLength.message}),B.dirty()}if($.minLength!==null){if(Q.data.length<$.minLength.value)h0(Q,{code:X0.too_small,minimum:$.minLength.value,type:"array",inclusive:!0,exact:!1,message:$.minLength.message}),B.dirty()}if($.maxLength!==null){if(Q.data.length>$.maxLength.value)h0(Q,{code:X0.too_big,maximum:$.maxLength.value,type:"array",inclusive:!0,exact:!1,message:$.maxLength.message}),B.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((Y,X)=>{return $.type._parseAsync(new kZ(Q,Y,Q.path,X))})).then((Y)=>{return xY.mergeArray(B,Y)});let J=[...Q.data].map((Y,X)=>{return $.type._parseSync(new kZ(Q,Y,Q.path,X))});return xY.mergeArray(B,J)}get element(){return this._def.type}min(A,Q){return new l3({...this._def,minLength:{value:A,message:OB.toString(Q)}})}max(A,Q){return new l3({...this._def,maxLength:{value:A,message:OB.toString(Q)}})}length(A,Q){return new l3({...this._def,exactLength:{value:A,message:OB.toString(Q)}})}nonempty(A){return this.min(1,A)}}l3.create=(A,Q)=>{return new l3({type:A,minLength:null,maxLength:null,exactLength:null,typeName:Z0.ZodArray,...l1(Q)})};function fw(A){if(A instanceof J9){let Q={};for(let B in A.shape){let $=A.shape[B];Q[B]=p3.create(fw($))}return new J9({...A._def,shape:()=>Q})}else if(A instanceof l3)return new l3({...A._def,type:fw(A.element)});else if(A instanceof p3)return p3.create(fw(A.unwrap()));else if(A instanceof QI)return QI.create(fw(A.unwrap()));else if(A instanceof RF)return RF.create(A.items.map((Q)=>fw(Q)));else return A}class J9 extends V8{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let A=this._def.shape(),Q=y8.objectKeys(A);return this._cached={shape:A,keys:Q},this._cached}_parse(A){if(this._getType(A)!==M0.object){let K=this._getOrReturnCtx(A);return h0(K,{code:X0.invalid_type,expected:M0.object,received:K.parsedType}),B1}let{status:B,ctx:$}=this._processInputParams(A),{shape:J,keys:Y}=this._getCached(),X=[];if(!(this._def.catchall instanceof EF&&this._def.unknownKeys==="strip")){for(let K in $.data)if(!Y.includes(K))X.push(K)}let G=[];for(let K of Y){let W=J[K],H=$.data[K];G.push({key:{status:"valid",value:K},value:W._parse(new kZ($,H,$.path,K)),alwaysSet:K in $.data})}if(this._def.catchall instanceof EF){let K=this._def.unknownKeys;if(K==="passthrough")for(let W of X)G.push({key:{status:"valid",value:W},value:{status:"valid",value:$.data[W]}});else if(K==="strict"){if(X.length>0)h0($,{code:X0.unrecognized_keys,keys:X}),B.dirty()}else if(K==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let K=this._def.catchall;for(let W of X){let H=$.data[W];G.push({key:{status:"valid",value:W},value:K._parse(new kZ($,H,$.path,W)),alwaysSet:W in $.data})}}if($.common.async)return Promise.resolve().then(async()=>{let K=[];for(let W of G){let H=await W.key,D=await W.value;K.push({key:H,value:D,alwaysSet:W.alwaysSet})}return K}).then((K)=>{return xY.mergeObjectSync(B,K)});else return xY.mergeObjectSync(B,G)}get shape(){return this._def.shape()}strict(A){return OB.errToObj,new J9({...this._def,unknownKeys:"strict",...A!==void 0?{errorMap:(Q,B)=>{let $=this._def.errorMap?.(Q,B).message??B.defaultError;if(Q.code==="unrecognized_keys")return{message:OB.errToObj(A).message??$};return{message:$}}}:{}})}strip(){return new J9({...this._def,unknownKeys:"strip"})}passthrough(){return new J9({...this._def,unknownKeys:"passthrough"})}extend(A){return new J9({...this._def,shape:()=>({...this._def.shape(),...A})})}merge(A){return new J9({unknownKeys:A._def.unknownKeys,catchall:A._def.catchall,shape:()=>({...this._def.shape(),...A._def.shape()}),typeName:Z0.ZodObject})}setKey(A,Q){return this.augment({[A]:Q})}catchall(A){return new J9({...this._def,catchall:A})}pick(A){let Q={};for(let B of y8.objectKeys(A))if(A[B]&&this.shape[B])Q[B]=this.shape[B];return new J9({...this._def,shape:()=>Q})}omit(A){let Q={};for(let B of y8.objectKeys(this.shape))if(!A[B])Q[B]=this.shape[B];return new J9({...this._def,shape:()=>Q})}deepPartial(){return fw(this)}partial(A){let Q={};for(let B of y8.objectKeys(this.shape)){let $=this.shape[B];if(A&&!A[B])Q[B]=$;else Q[B]=$.optional()}return new J9({...this._def,shape:()=>Q})}required(A){let Q={};for(let B of y8.objectKeys(this.shape))if(A&&!A[B])Q[B]=this.shape[B];else{let J=this.shape[B];while(J instanceof p3)J=J._def.innerType;Q[B]=J}return new J9({...this._def,shape:()=>Q})}keyof(){return o6Q(y8.objectKeys(this.shape))}}J9.create=(A,Q)=>{return new J9({shape:()=>A,unknownKeys:"strip",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};J9.strictCreate=(A,Q)=>{return new J9({shape:()=>A,unknownKeys:"strict",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};J9.lazycreate=(A,Q)=>{return new J9({shape:A,unknownKeys:"strip",catchall:EF.create(),typeName:Z0.ZodObject,...l1(Q)})};class ty extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=this._def.options;function $(J){for(let X of J)if(X.result.status==="valid")return X.result;for(let X of J)if(X.result.status==="dirty")return Q.common.issues.push(...X.ctx.common.issues),X.result;let Y=J.map((X)=>new gG(X.ctx.common.issues));return h0(Q,{code:X0.invalid_union,unionErrors:Y}),B1}if(Q.common.async)return Promise.all(B.map(async(J)=>{let Y={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await J._parseAsync({data:Q.data,path:Q.path,parent:Y}),ctx:Y}})).then($);else{let J=void 0,Y=[];for(let G of B){let K={...Q,common:{...Q.common,issues:[]},parent:null},W=G._parseSync({data:Q.data,path:Q.path,parent:K});if(W.status==="valid")return W;else if(W.status==="dirty"&&!J)J={result:W,ctx:K};if(K.common.issues.length)Y.push(K.common.issues)}if(J)return Q.common.issues.push(...J.ctx.common.issues),J.result;let X=Y.map((G)=>new gG(G));return h0(Q,{code:X0.invalid_union,unionErrors:X}),B1}}get options(){return this._def.options}}ty.create=(A,Q)=>{return new ty({options:A,typeName:Z0.ZodUnion,...l1(Q)})};var LF=(A)=>{if(A instanceof Ah)return LF(A.schema);else if(A instanceof i3)return LF(A.innerType());else if(A instanceof Qh)return[A.value];else if(A instanceof GN)return A.options;else if(A instanceof Bh)return y8.objectValues(A.enum);else if(A instanceof $h)return LF(A._def.innerType);else if(A instanceof ry)return[void 0];else if(A instanceof sy)return[null];else if(A instanceof p3)return[void 0,...LF(A.unwrap())];else if(A instanceof QI)return[null,...LF(A.unwrap())];else if(A instanceof HFA)return LF(A.unwrap());else if(A instanceof Yh)return LF(A.unwrap());else if(A instanceof Jh)return LF(A._def.innerType);else return[]};class ZFA extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.object)return h0(Q,{code:X0.invalid_type,expected:M0.object,received:Q.parsedType}),B1;let B=this.discriminator,$=Q.data[B],J=this.optionsMap.get($);if(!J)return h0(Q,{code:X0.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[B]}),B1;if(Q.common.async)return J._parseAsync({data:Q.data,path:Q.path,parent:Q});else return J._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(A,Q,B){let $=new Map;for(let J of Q){let Y=LF(J.shape[A]);if(!Y.length)throw Error(`A discriminator value for key \`${A}\` could not be extracted from all schema options`);for(let X of Y){if($.has(X))throw Error(`Discriminator property ${String(A)} has duplicate value ${String(X)}`);$.set(X,J)}}return new ZFA({typeName:Z0.ZodDiscriminatedUnion,discriminator:A,options:Q,optionsMap:$,...l1(B)})}}function WFA(A,Q){let B=NF(A),$=NF(Q);if(A===Q)return{valid:!0,data:A};else if(B===M0.object&&$===M0.object){let J=y8.objectKeys(Q),Y=y8.objectKeys(A).filter((G)=>J.indexOf(G)!==-1),X={...A,...Q};for(let G of Y){let K=WFA(A[G],Q[G]);if(!K.valid)return{valid:!1};X[G]=K.data}return{valid:!0,data:X}}else if(B===M0.array&&$===M0.array){if(A.length!==Q.length)return{valid:!1};let J=[];for(let Y=0;Y<A.length;Y++){let X=A[Y],G=Q[Y],K=WFA(X,G);if(!K.valid)return{valid:!1};J.push(K.data)}return{valid:!0,data:J}}else if(B===M0.date&&$===M0.date&&+A===+Q)return{valid:!0,data:A};else return{valid:!1}}class ey extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A),$=(J,Y)=>{if(XFA(J)||XFA(Y))return B1;let X=WFA(J.value,Y.value);if(!X.valid)return h0(B,{code:X0.invalid_intersection_types}),B1;if(GFA(J)||GFA(Y))Q.dirty();return{status:Q.value,value:X.data}};if(B.common.async)return Promise.all([this._def.left._parseAsync({data:B.data,path:B.path,parent:B}),this._def.right._parseAsync({data:B.data,path:B.path,parent:B})]).then(([J,Y])=>$(J,Y));else return $(this._def.left._parseSync({data:B.data,path:B.path,parent:B}),this._def.right._parseSync({data:B.data,path:B.path,parent:B}))}}ey.create=(A,Q,B)=>{return new ey({left:A,right:Q,typeName:Z0.ZodIntersection,...l1(B)})};class RF extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.array)return h0(B,{code:X0.invalid_type,expected:M0.array,received:B.parsedType}),B1;if(B.data.length<this._def.items.length)return h0(B,{code:X0.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B1;if(!this._def.rest&&B.data.length>this._def.items.length)h0(B,{code:X0.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let J=[...B.data].map((Y,X)=>{let G=this._def.items[X]||this._def.rest;if(!G)return null;return G._parse(new kZ(B,Y,B.path,X))}).filter((Y)=>!!Y);if(B.common.async)return Promise.all(J).then((Y)=>{return xY.mergeArray(Q,Y)});else return xY.mergeArray(Q,J)}get items(){return this._def.items}rest(A){return new RF({...this._def,rest:A})}}RF.create=(A,Q)=>{if(!Array.isArray(A))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new RF({items:A,typeName:Z0.ZodTuple,rest:null,...l1(Q)})};class bAA extends V8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.object)return h0(B,{code:X0.invalid_type,expected:M0.object,received:B.parsedType}),B1;let $=[],J=this._def.keyType,Y=this._def.valueType;for(let X in B.data)$.push({key:J._parse(new kZ(B,X,B.path,X)),value:Y._parse(new kZ(B,B.data[X],B.path,X)),alwaysSet:X in B.data});if(B.common.async)return xY.mergeObjectAsync(Q,$);else return xY.mergeObjectSync(Q,$)}get element(){return this._def.valueType}static create(A,Q,B){if(Q instanceof V8)return new bAA({keyType:A,valueType:Q,typeName:Z0.ZodRecord,...l1(B)});return new bAA({keyType:VF.create(),valueType:A,typeName:Z0.ZodRecord,...l1(Q)})}}class fAA extends V8{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.map)return h0(B,{code:X0.invalid_type,expected:M0.map,received:B.parsedType}),B1;let $=this._def.keyType,J=this._def.valueType,Y=[...B.data.entries()].map(([X,G],K)=>{return{key:$._parse(new kZ(B,X,B.path,[K,"key"])),value:J._parse(new kZ(B,G,B.path,[K,"value"]))}});if(B.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let G of Y){let K=await G.key,W=await G.value;if(K.status==="aborted"||W.status==="aborted")return B1;if(K.status==="dirty"||W.status==="dirty")Q.dirty();X.set(K.value,W.value)}return{status:Q.value,value:X}})}else{let X=new Map;for(let G of Y){let{key:K,value:W}=G;if(K.status==="aborted"||W.status==="aborted")return B1;if(K.status==="dirty"||W.status==="dirty")Q.dirty();X.set(K.value,W.value)}return{status:Q.value,value:X}}}}fAA.create=(A,Q,B)=>{return new fAA({valueType:Q,keyType:A,typeName:Z0.ZodMap,...l1(B)})};class yw extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.parsedType!==M0.set)return h0(B,{code:X0.invalid_type,expected:M0.set,received:B.parsedType}),B1;let $=this._def;if($.minSize!==null){if(B.data.size<$.minSize.value)h0(B,{code:X0.too_small,minimum:$.minSize.value,type:"set",inclusive:!0,exact:!1,message:$.minSize.message}),Q.dirty()}if($.maxSize!==null){if(B.data.size>$.maxSize.value)h0(B,{code:X0.too_big,maximum:$.maxSize.value,type:"set",inclusive:!0,exact:!1,message:$.maxSize.message}),Q.dirty()}let J=this._def.valueType;function Y(G){let K=new Set;for(let W of G){if(W.status==="aborted")return B1;if(W.status==="dirty")Q.dirty();K.add(W.value)}return{status:Q.value,value:K}}let X=[...B.data.values()].map((G,K)=>J._parse(new kZ(B,G,B.path,K)));if(B.common.async)return Promise.all(X).then((G)=>Y(G));else return Y(X)}min(A,Q){return new yw({...this._def,minSize:{value:A,message:OB.toString(Q)}})}max(A,Q){return new yw({...this._def,maxSize:{value:A,message:OB.toString(Q)}})}size(A,Q){return this.min(A,Q).max(A,Q)}nonempty(A){return this.min(1,A)}}yw.create=(A,Q)=>{return new yw({valueType:A,minSize:null,maxSize:null,typeName:Z0.ZodSet,...l1(Q)})};class ay extends V8{constructor(){super(...arguments);this.validate=this.implement}_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.function)return h0(Q,{code:X0.invalid_type,expected:M0.function,received:Q.parsedType}),B1;function B(X,G){return PAA({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,iy(),AI].filter((K)=>!!K),issueData:{code:X0.invalid_arguments,argumentsError:G}})}function $(X,G){return PAA({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,iy(),AI].filter((K)=>!!K),issueData:{code:X0.invalid_return_type,returnTypeError:G}})}let J={errorMap:Q.common.contextualErrorMap},Y=Q.data;if(this._def.returns instanceof hw){let X=this;return u7(async function(...G){let K=new gG([]),W=await X._def.args.parseAsync(G,J).catch((F)=>{throw K.addIssue(B(G,F)),K}),H=await Reflect.apply(Y,this,W);return await X._def.returns._def.type.parseAsync(H,J).catch((F)=>{throw K.addIssue($(H,F)),K})})}else{let X=this;return u7(function(...G){let K=X._def.args.safeParse(G,J);if(!K.success)throw new gG([B(G,K.error)]);let W=Reflect.apply(Y,this,K.data),H=X._def.returns.safeParse(W,J);if(!H.success)throw new gG([$(W,H.error)]);return H.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...A){return new ay({...this._def,args:RF.create(A).rest(XN.create())})}returns(A){return new ay({...this._def,returns:A})}implement(A){return this.parse(A)}strictImplement(A){return this.parse(A)}static create(A,Q,B){return new ay({args:A?A:RF.create([]).rest(XN.create()),returns:Q||XN.create(),typeName:Z0.ZodFunction,...l1(B)})}}class Ah extends V8{get schema(){return this._def.getter()}_parse(A){let{ctx:Q}=this._processInputParams(A);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}}Ah.create=(A,Q)=>{return new Ah({getter:A,typeName:Z0.ZodLazy,...l1(Q)})};class Qh extends V8{_parse(A){if(A.data!==this._def.value){let Q=this._getOrReturnCtx(A);return h0(Q,{received:Q.data,code:X0.invalid_literal,expected:this._def.value}),B1}return{status:"valid",value:A.data}}get value(){return this._def.value}}Qh.create=(A,Q)=>{return new Qh({value:A,typeName:Z0.ZodLiteral,...l1(Q)})};function o6Q(A,Q){return new GN({values:A,typeName:Z0.ZodEnum,...l1(Q)})}class GN extends V8{_parse(A){if(typeof A.data!=="string"){let Q=this._getOrReturnCtx(A),B=this._def.values;return h0(Q,{expected:y8.joinValues(B),received:Q.parsedType,code:X0.invalid_type}),B1}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(A.data)){let Q=this._getOrReturnCtx(A),B=this._def.values;return h0(Q,{received:Q.data,code:X0.invalid_enum_value,options:B}),B1}return u7(A.data)}get options(){return this._def.values}get enum(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}get Values(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}get Enum(){let A={};for(let Q of this._def.values)A[Q]=Q;return A}extract(A,Q=this._def){return GN.create(A,{...this._def,...Q})}exclude(A,Q=this._def){return GN.create(this.options.filter((B)=>!A.includes(B)),{...this._def,...Q})}}GN.create=o6Q;class Bh extends V8{_parse(A){let Q=y8.getValidEnumValues(this._def.values),B=this._getOrReturnCtx(A);if(B.parsedType!==M0.string&&B.parsedType!==M0.number){let $=y8.objectValues(Q);return h0(B,{expected:y8.joinValues($),received:B.parsedType,code:X0.invalid_type}),B1}if(!this._cache)this._cache=new Set(y8.getValidEnumValues(this._def.values));if(!this._cache.has(A.data)){let $=y8.objectValues(Q);return h0(B,{received:B.data,code:X0.invalid_enum_value,options:$}),B1}return u7(A.data)}get enum(){return this._def.values}}Bh.create=(A,Q)=>{return new Bh({values:A,typeName:Z0.ZodNativeEnum,...l1(Q)})};class hw extends V8{unwrap(){return this._def.type}_parse(A){let{ctx:Q}=this._processInputParams(A);if(Q.parsedType!==M0.promise&&Q.common.async===!1)return h0(Q,{code:X0.invalid_type,expected:M0.promise,received:Q.parsedType}),B1;let B=Q.parsedType===M0.promise?Q.data:Promise.resolve(Q.data);return u7(B.then(($)=>{return this._def.type.parseAsync($,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}hw.create=(A,Q)=>{return new hw({type:A,typeName:Z0.ZodPromise,...l1(Q)})};class i3 extends V8{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z0.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(A){let{status:Q,ctx:B}=this._processInputParams(A),$=this._def.effect||null,J={addIssue:(Y)=>{if(h0(B,Y),Y.fatal)Q.abort();else Q.dirty()},get path(){return B.path}};if(J.addIssue=J.addIssue.bind(J),$.type==="preprocess"){let Y=$.transform(B.data,J);if(B.common.async)return Promise.resolve(Y).then(async(X)=>{if(Q.value==="aborted")return B1;let G=await this._def.schema._parseAsync({data:X,path:B.path,parent:B});if(G.status==="aborted")return B1;if(G.status==="dirty")return bw(G.value);if(Q.value==="dirty")return bw(G.value);return G});else{if(Q.value==="aborted")return B1;let X=this._def.schema._parseSync({data:Y,path:B.path,parent:B});if(X.status==="aborted")return B1;if(X.status==="dirty")return bw(X.value);if(Q.value==="dirty")return bw(X.value);return X}}if($.type==="refinement"){let Y=(X)=>{let G=$.refinement(X,J);if(B.common.async)return Promise.resolve(G);if(G instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(B.common.async===!1){let X=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(X.status==="aborted")return B1;if(X.status==="dirty")Q.dirty();return Y(X.value),{status:Q.value,value:X.value}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((X)=>{if(X.status==="aborted")return B1;if(X.status==="dirty")Q.dirty();return Y(X.value).then(()=>{return{status:Q.value,value:X.value}})})}if($.type==="transform")if(B.common.async===!1){let Y=this._def.schema._parseSync({data:B.data,path:B.path,parent:B});if(!YN(Y))return B1;let X=$.transform(Y.value,J);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:X}}else return this._def.schema._parseAsync({data:B.data,path:B.path,parent:B}).then((Y)=>{if(!YN(Y))return B1;return Promise.resolve($.transform(Y.value,J)).then((X)=>({status:Q.value,value:X}))});y8.assertNever($)}}i3.create=(A,Q,B)=>{return new i3({schema:A,typeName:Z0.ZodEffects,effect:Q,...l1(B)})};i3.createWithPreprocess=(A,Q,B)=>{return new i3({schema:Q,effect:{type:"preprocess",transform:A},typeName:Z0.ZodEffects,...l1(B)})};class p3 extends V8{_parse(A){if(this._getType(A)===M0.undefined)return u7(void 0);return this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}p3.create=(A,Q)=>{return new p3({innerType:A,typeName:Z0.ZodOptional,...l1(Q)})};class QI extends V8{_parse(A){if(this._getType(A)===M0.null)return u7(null);return this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}QI.create=(A,Q)=>{return new QI({innerType:A,typeName:Z0.ZodNullable,...l1(Q)})};class $h extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=Q.data;if(Q.parsedType===M0.undefined)B=this._def.defaultValue();return this._def.innerType._parse({data:B,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}$h.create=(A,Q)=>{return new $h({innerType:A,typeName:Z0.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...l1(Q)})};class Jh extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B={...Q,common:{...Q.common,issues:[]}},$=this._def.innerType._parse({data:B.data,path:B.path,parent:{...B}});if(ny($))return $.then((J)=>{return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new gG(B.common.issues)},input:B.data})}});else return{status:"valid",value:$.status==="valid"?$.value:this._def.catchValue({get error(){return new gG(B.common.issues)},input:B.data})}}removeCatch(){return this._def.innerType}}Jh.create=(A,Q)=>{return new Jh({innerType:A,typeName:Z0.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...l1(Q)})};class vAA extends V8{_parse(A){if(this._getType(A)!==M0.nan){let B=this._getOrReturnCtx(A);return h0(B,{code:X0.invalid_type,expected:M0.nan,received:B.parsedType}),B1}return{status:"valid",value:A.data}}}vAA.create=(A)=>{return new vAA({typeName:Z0.ZodNaN,...l1(A)})};var CQ1=Symbol("zod_brand");class HFA extends V8{_parse(A){let{ctx:Q}=this._processInputParams(A),B=Q.data;return this._def.type._parse({data:B,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class gAA extends V8{_parse(A){let{status:Q,ctx:B}=this._processInputParams(A);if(B.common.async)return(async()=>{let J=await this._def.in._parseAsync({data:B.data,path:B.path,parent:B});if(J.status==="aborted")return B1;if(J.status==="dirty")return Q.dirty(),bw(J.value);else return this._def.out._parseAsync({data:J.value,path:B.path,parent:B})})();else{let $=this._def.in._parseSync({data:B.data,path:B.path,parent:B});if($.status==="aborted")return B1;if($.status==="dirty")return Q.dirty(),{status:"dirty",value:$.value};else return this._def.out._parseSync({data:$.value,path:B.path,parent:B})}}static create(A,Q){return new gAA({in:A,out:Q,typeName:Z0.ZodPipeline})}}class Yh extends V8{_parse(A){let Q=this._def.innerType._parse(A),B=($)=>{if(YN($))$.value=Object.freeze($.value);return $};return ny(Q)?Q.then(($)=>B($)):B(Q)}unwrap(){return this._def.innerType}}Yh.create=(A,Q)=>{return new Yh({innerType:A,typeName:Z0.ZodReadonly,...l1(Q)})};var OQ1={object:J9.lazycreate},Z0;(function(A){A.ZodString="ZodString",A.ZodNumber="ZodNumber",A.ZodNaN="ZodNaN",A.ZodBigInt="ZodBigInt",A.ZodBoolean="ZodBoolean",A.ZodDate="ZodDate",A.ZodSymbol="ZodSymbol",A.ZodUndefined="ZodUndefined",A.ZodNull="ZodNull",A.ZodAny="ZodAny",A.ZodUnknown="ZodUnknown",A.ZodNever="ZodNever",A.ZodVoid="ZodVoid",A.ZodArray="ZodArray",A.ZodObject="ZodObject",A.ZodUnion="ZodUnion",A.ZodDiscriminatedUnion="ZodDiscriminatedUnion",A.ZodIntersection="ZodIntersection",A.ZodTuple="ZodTuple",A.ZodRecord="ZodRecord",A.ZodMap="ZodMap",A.ZodSet="ZodSet",A.ZodFunction="ZodFunction",A.ZodLazy="ZodLazy",A.ZodLiteral="ZodLiteral",A.ZodEnum="ZodEnum",A.ZodEffects="ZodEffects",A.ZodNativeEnum="ZodNativeEnum",A.ZodOptional="ZodOptional",A.ZodNullable="ZodNullable",A.ZodDefault="ZodDefault",A.ZodCatch="ZodCatch",A.ZodPromise="ZodPromise",A.ZodBranded="ZodBranded",A.ZodPipeline="ZodPipeline",A.ZodReadonly="ZodReadonly"})(Z0||(Z0={}));var MQ1=VF.create,NQ1=vw.create,LQ1=vAA.create,VQ1=gw.create,EQ1=TAA.create,RQ1=oy.create,jQ1=kAA.create,wQ1=ry.create,_Q1=sy.create,PQ1=SAA.create,TQ1=XN.create,kQ1=EF.create,SQ1=xAA.create,xQ1=l3.create,r6Q=J9.create,bQ1=J9.strictCreate,fQ1=ty.create,vQ1=ZFA.create,gQ1=ey.create,yQ1=RF.create,hQ1=bAA.create,uQ1=fAA.create,mQ1=yw.create,cQ1=ay.create,dQ1=Ah.create,lQ1=Qh.create,pQ1=GN.create,iQ1=Bh.create,nQ1=hw.create,aQ1=i3.create,oQ1=p3.create,rQ1=QI.create,sQ1=i3.createWithPreprocess,tQ1=gAA.create;DY();DY();DY();FB();var kq0=fA("ZodMiniType",(A,Q)=>{if(!A._zod)throw Error("Uninitialized schema in ZodMiniType.");G1.init(A,Q),A.def=Q,A.type=Q.type,A.parse=(B,$)=>bC(A,B,$,{callee:A.parse}),A.safeParse=(B,$)=>d2(A,B,$),A.parseAsync=async(B,$)=>fC(A,B,$,{callee:A.parseAsync}),A.safeParseAsync=async(B,$)=>l2(A,B,$),A.check=(...B)=>{return A.clone({...Q,checks:[...Q.checks??[],...B.map(($)=>typeof $==="function"?{_zod:{check:$,def:{check:"custom"},onattach:[]}}:$)]},{parent:!0})},A.with=A.check,A.clone=(B,$)=>M5(A,B,$),A.brand=()=>A,A.register=(B,$)=>{return B.add(A,$),A},A.apply=(B)=>B(A)});var Sq0=fA("ZodMiniObject",(A,Q)=>{Nl.init(A,Q),kq0.init(A,Q),i1(A,"shape",()=>Q.shape)});function qFA(A,Q){let B={type:"object",shape:A??{},...K0(Q)};return new Sq0(B)}yV();il();function XW(A){return!!A._zod}function KN(A){let Q=Object.values(A);if(Q.length===0)return qFA({});let B=Q.every(XW),$=Q.every((J)=>!XW(J));if(B)return qFA(A);if($)return r6Q(A);throw Error("Mixed Zod versions detected in object shape.")}function BI(A,Q){if(XW(A))return d2(A,Q);return A.safeParse(Q)}async function yAA(A,Q){if(XW(A))return await l2(A,Q);return await A.safeParseAsync(Q)}function $I(A){if(!A)return;let Q;if(XW(A))Q=A._zod?.def?.shape;else Q=A.shape;if(!Q)return;if(typeof Q==="function")try{return Q()}catch{return}return Q}function uw(A){if(!A)return;if(typeof A==="object"){let Q=A,B=A;if(!Q._def&&!B._zod){let $=Object.values(A);if($.length>0&&$.every((J)=>typeof J==="object"&&J!==null&&(J._def!==void 0||J._zod!==void 0||typeof J.parse==="function")))return KN(A)}}if(XW(A)){let B=A._zod?.def;if(B&&(B.type==="object"||B.shape!==void 0))return A}else if(A.shape!==void 0)return A;return}function hAA(A){if(A&&typeof A==="object"){if("message"in A&&typeof A.message==="string")return A.message;if("issues"in A&&Array.isArray(A.issues)&&A.issues.length>0){let Q=A.issues[0];if(Q&&typeof Q==="object"&&"message"in Q)return String(Q.message)}try{return JSON.stringify(A)}catch{return String(A)}}return String(A)}function s6Q(A){return A.description}function t6Q(A){if(XW(A))return A._zod?.def?.type==="optional";let Q=A;if(typeof A.isOptional==="function")return A.isOptional();return Q._def?.typeName==="ZodOptional"}function uAA(A){if(XW(A)){let Y=A._zod?.def;if(Y){if(Y.value!==void 0)return Y.value;if(Array.isArray(Y.values)&&Y.values.length>0)return Y.values[0]}}let B=A._def;if(B){if(B.value!==void 0)return B.value;if(Array.isArray(B.values)&&B.values.length>0)return B.values[0]}let $=A.value;if($!==void 0)return $;return}var DFA="2025-11-25";var e6Q=[DFA,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],JI="io.modelcontextprotocol/related-task",cAA="2.0",wJ=Yi((A)=>A!==null&&(typeof A==="object"||typeof A==="function")),A9Q=K4([DQ(),K$().int()]),Q9Q=DQ(),q01=L5({ttl:K$().optional(),pollInterval:K$().optional()}),bq0=s0({ttl:K$().optional()}),fq0=s0({taskId:DQ()}),FFA=L5({progressToken:A9Q.optional(),[JI]:fq0.optional()}),yG=s0({_meta:FFA.optional()}),Xh=yG.extend({task:bq0.optional()}),B9Q=(A)=>Xh.safeParse(A).success,i5=s0({method:DQ(),params:yG.loose().optional()}),GW=s0({_meta:FFA.optional()}),KW=s0({method:DQ(),params:GW.loose().optional()}),n5=L5({_meta:FFA.optional()}),dAA=K4([DQ(),K$().int()]),$9Q=s0({jsonrpc:VB(cAA),id:dAA,...i5.shape}).strict(),UFA=(A)=>$9Q.safeParse(A).success,J9Q=s0({jsonrpc:VB(cAA),...KW.shape}).strict(),Y9Q=(A)=>J9Q.safeParse(A).success,zFA=s0({jsonrpc:VB(cAA),id:dAA,result:n5}).strict(),Gh=(A)=>zFA.safeParse(A).success;var uB;(function(A){A[A.ConnectionClosed=-32000]="ConnectionClosed",A[A.RequestTimeout=-32001]="RequestTimeout",A[A.ParseError=-32700]="ParseError",A[A.InvalidRequest=-32600]="InvalidRequest",A[A.MethodNotFound=-32601]="MethodNotFound",A[A.InvalidParams=-32602]="InvalidParams",A[A.InternalError=-32603]="InternalError",A[A.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(uB||(uB={}));var IFA=s0({jsonrpc:VB(cAA),id:dAA.optional(),error:s0({code:K$().int(),message:DQ(),data:G4().optional()})}).strict();var X9Q=(A)=>IFA.safeParse(A).success;var G9Q=K4([$9Q,J9Q,zFA,IFA]),D01=K4([zFA,IFA]),lAA=n5.strict(),vq0=GW.extend({requestId:dAA.optional(),reason:DQ().optional()}),pAA=KW.extend({method:VB("notifications/cancelled"),params:vq0}),gq0=s0({src:DQ(),mimeType:DQ().optional(),sizes:K8(DQ()).optional(),theme:V5(["light","dark"]).optional()}),Kh=s0({icons:K8(gq0).optional()}),mw=s0({name:DQ(),title:DQ().optional()}),K9Q=mw.extend({...mw.shape,...Kh.shape,version:DQ(),websiteUrl:DQ().optional(),description:DQ().optional()}),yq0=iV(s0({applyDefaults:F9().optional()}),n$(DQ(),G4())),hq0=Pk((A)=>{if(A&&typeof A==="object"&&!Array.isArray(A)){if(Object.keys(A).length===0)return{form:{}}}return A},iV(s0({form:yq0.optional(),url:wJ.optional()}),n$(DQ(),G4()).optional())),uq0=L5({list:wJ.optional(),cancel:wJ.optional(),requests:L5({sampling:L5({createMessage:wJ.optional()}).optional(),elicitation:L5({create:wJ.optional()}).optional()}).optional()}),mq0=L5({list:wJ.optional(),cancel:wJ.optional(),requests:L5({tools:L5({call:wJ.optional()}).optional()}).optional()}),cq0=s0({experimental:n$(DQ(),wJ).optional(),sampling:s0({context:wJ.optional(),tools:wJ.optional()}).optional(),elicitation:hq0.optional(),roots:s0({listChanged:F9().optional()}).optional(),tasks:uq0.optional(),extensions:n$(DQ(),wJ).optional()}),dq0=yG.extend({protocolVersion:DQ(),capabilities:cq0,clientInfo:K9Q}),CFA=i5.extend({method:VB("initialize"),params:dq0});var lq0=s0({experimental:n$(DQ(),wJ).optional(),logging:wJ.optional(),completions:wJ.optional(),prompts:s0({listChanged:F9().optional()}).optional(),resources:s0({subscribe:F9().optional(),listChanged:F9().optional()}).optional(),tools:s0({listChanged:F9().optional()}).optional(),tasks:mq0.optional(),extensions:n$(DQ(),wJ).optional()}),pq0=n5.extend({protocolVersion:DQ(),capabilities:lq0,serverInfo:K9Q,instructions:DQ().optional()}),OFA=KW.extend({method:VB("notifications/initialized"),params:GW.optional()});var iAA=i5.extend({method:VB("ping"),params:yG.optional()}),iq0=s0({progress:K$(),total:C4(K$()),message:C4(DQ())}),nq0=s0({...GW.shape,...iq0.shape,progressToken:A9Q}),nAA=KW.extend({method:VB("notifications/progress"),params:nq0}),aq0=yG.extend({cursor:Q9Q.optional()}),Wh=i5.extend({params:aq0.optional()}),Zh=n5.extend({nextCursor:Q9Q.optional()}),oq0=V5(["working","input_required","completed","failed","cancelled"]),Hh=s0({taskId:DQ(),status:oq0,ttl:K4([K$(),Nk()]),createdAt:DQ(),lastUpdatedAt:DQ(),pollInterval:C4(K$()),statusMessage:C4(DQ())}),cw=n5.extend({task:Hh}),rq0=GW.merge(Hh),qh=KW.extend({method:VB("notifications/tasks/status"),params:rq0}),aAA=i5.extend({method:VB("tasks/get"),params:yG.extend({taskId:DQ()})}),oAA=n5.merge(Hh),rAA=i5.extend({method:VB("tasks/result"),params:yG.extend({taskId:DQ()})}),F01=n5.loose(),sAA=Wh.extend({method:VB("tasks/list")}),tAA=Zh.extend({tasks:K8(Hh)}),eAA=i5.extend({method:VB("tasks/cancel"),params:yG.extend({taskId:DQ()})}),W9Q=n5.merge(Hh),Z9Q=s0({uri:DQ(),mimeType:C4(DQ()),_meta:n$(DQ(),G4()).optional()}),H9Q=Z9Q.extend({text:DQ()}),MFA=DQ().refine((A)=>{try{return atob(A),!0}catch{return!1}},{message:"Invalid Base64 string"}),q9Q=Z9Q.extend({blob:MFA}),Dh=V5(["user","assistant"]),dw=s0({audience:K8(Dh).optional(),priority:K$().min(0).max(1).optional(),lastModified:s2.datetime({offset:!0}).optional()}),D9Q=s0({...mw.shape,...Kh.shape,uri:DQ(),description:C4(DQ()),mimeType:C4(DQ()),size:C4(K$()),annotations:dw.optional(),_meta:C4(L5({}))}),sq0=s0({...mw.shape,...Kh.shape,uriTemplate:DQ(),description:C4(DQ()),mimeType:C4(DQ()),annotations:dw.optional(),_meta:C4(L5({}))}),AQA=Wh.extend({method:VB("resources/list")}),tq0=Zh.extend({resources:K8(D9Q)}),QQA=Wh.extend({method:VB("resources/templates/list")}),eq0=Zh.extend({resourceTemplates:K8(sq0)}),NFA=yG.extend({uri:DQ()}),AD0=NFA,BQA=i5.extend({method:VB("resources/read"),params:AD0}),QD0=n5.extend({contents:K8(K4([H9Q,q9Q]))}),BD0=KW.extend({method:VB("notifications/resources/list_changed"),params:GW.optional()}),$D0=NFA,JD0=i5.extend({method:VB("resources/subscribe"),params:$D0}),YD0=NFA,XD0=i5.extend({method:VB("resources/unsubscribe"),params:YD0}),GD0=GW.extend({uri:DQ()}),KD0=KW.extend({method:VB("notifications/resources/updated"),params:GD0}),WD0=s0({name:DQ(),description:C4(DQ()),required:C4(F9())}),ZD0=s0({...mw.shape,...Kh.shape,description:C4(DQ()),arguments:C4(K8(WD0)),_meta:C4(L5({}))}),$QA=Wh.extend({method:VB("prompts/list")}),HD0=Zh.extend({prompts:K8(ZD0)}),qD0=yG.extend({name:DQ(),arguments:n$(DQ(),DQ()).optional()}),JQA=i5.extend({method:VB("prompts/get"),params:qD0}),LFA=s0({type:VB("text"),text:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),VFA=s0({type:VB("image"),data:MFA,mimeType:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),EFA=s0({type:VB("audio"),data:MFA,mimeType:DQ(),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),DD0=s0({type:VB("tool_use"),name:DQ(),id:DQ(),input:n$(DQ(),G4()),_meta:n$(DQ(),G4()).optional()}),FD0=s0({type:VB("resource"),resource:K4([H9Q,q9Q]),annotations:dw.optional(),_meta:n$(DQ(),G4()).optional()}),UD0=D9Q.extend({type:VB("resource_link")}),RFA=K4([LFA,VFA,EFA,UD0,FD0]),zD0=s0({role:Dh,content:RFA}),ID0=n5.extend({description:DQ().optional(),messages:K8(zD0)}),CD0=KW.extend({method:VB("notifications/prompts/list_changed"),params:GW.optional()}),OD0=s0({title:DQ().optional(),readOnlyHint:F9().optional(),destructiveHint:F9().optional(),idempotentHint:F9().optional(),openWorldHint:F9().optional()}),MD0=s0({taskSupport:V5(["required","optional","forbidden"]).optional()}),F9Q=s0({...mw.shape,...Kh.shape,description:DQ().optional(),inputSchema:s0({type:VB("object"),properties:n$(DQ(),wJ).optional(),required:K8(DQ()).optional()}).catchall(G4()),outputSchema:s0({type:VB("object"),properties:n$(DQ(),wJ).optional(),required:K8(DQ()).optional()}).catchall(G4()).optional(),annotations:OD0.optional(),execution:MD0.optional(),_meta:n$(DQ(),G4()).optional()}),YQA=Wh.extend({method:VB("tools/list")}),ND0=Zh.extend({tools:K8(F9Q)}),XQA=n5.extend({content:K8(RFA).default([]),structuredContent:n$(DQ(),G4()).optional(),isError:F9().optional()}),U01=XQA.or(n5.extend({toolResult:G4()})),LD0=Xh.extend({name:DQ(),arguments:n$(DQ(),G4()).optional()}),lw=i5.extend({method:VB("tools/call"),params:LD0}),VD0=KW.extend({method:VB("notifications/tools/list_changed"),params:GW.optional()}),z01=s0({autoRefresh:F9().default(!0),debounceMs:K$().int().nonnegative().default(300)}),Fh=V5(["debug","info","notice","warning","error","critical","alert","emergency"]),ED0=yG.extend({level:Fh}),jFA=i5.extend({method:VB("logging/setLevel"),params:ED0}),RD0=GW.extend({level:Fh,logger:DQ().optional(),data:G4()}),jD0=KW.extend({method:VB("notifications/message"),params:RD0}),wD0=s0({name:DQ().optional()}),_D0=s0({hints:K8(wD0).optional(),costPriority:K$().min(0).max(1).optional(),speedPriority:K$().min(0).max(1).optional(),intelligencePriority:K$().min(0).max(1).optional()}),PD0=s0({mode:V5(["auto","required","none"]).optional()}),TD0=s0({type:VB("tool_result"),toolUseId:DQ().describe("The unique identifier for the corresponding tool call."),content:K8(RFA).default([]),structuredContent:s0({}).loose().optional(),isError:F9().optional(),_meta:n$(DQ(),G4()).optional()}),kD0=Rk("type",[LFA,VFA,EFA]),mAA=Rk("type",[LFA,VFA,EFA,DD0,TD0]),SD0=s0({role:Dh,content:K4([mAA,K8(mAA)]),_meta:n$(DQ(),G4()).optional()}),xD0=Xh.extend({messages:K8(SD0),modelPreferences:_D0.optional(),systemPrompt:DQ().optional(),includeContext:V5(["none","thisServer","allServers"]).optional(),temperature:K$().optional(),maxTokens:K$().int(),stopSequences:K8(DQ()).optional(),metadata:wJ.optional(),tools:K8(F9Q).optional(),toolChoice:PD0.optional()}),bD0=i5.extend({method:VB("sampling/createMessage"),params:xD0}),Uh=n5.extend({model:DQ(),stopReason:C4(V5(["endTurn","stopSequence","maxTokens"]).or(DQ())),role:Dh,content:kD0}),wFA=n5.extend({model:DQ(),stopReason:C4(V5(["endTurn","stopSequence","maxTokens","toolUse"]).or(DQ())),role:Dh,content:K4([mAA,K8(mAA)])}),fD0=s0({type:VB("boolean"),title:DQ().optional(),description:DQ().optional(),default:F9().optional()}),vD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),minLength:K$().optional(),maxLength:K$().optional(),format:V5(["email","uri","date","date-time"]).optional(),default:DQ().optional()}),gD0=s0({type:V5(["number","integer"]),title:DQ().optional(),description:DQ().optional(),minimum:K$().optional(),maximum:K$().optional(),default:K$().optional()}),yD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),enum:K8(DQ()),default:DQ().optional()}),hD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),oneOf:K8(s0({const:DQ(),title:DQ()})),default:DQ().optional()}),uD0=s0({type:VB("string"),title:DQ().optional(),description:DQ().optional(),enum:K8(DQ()),enumNames:K8(DQ()).optional(),default:DQ().optional()}),mD0=K4([yD0,hD0]),cD0=s0({type:VB("array"),title:DQ().optional(),description:DQ().optional(),minItems:K$().optional(),maxItems:K$().optional(),items:s0({type:VB("string"),enum:K8(DQ())}),default:K8(DQ()).optional()}),dD0=s0({type:VB("array"),title:DQ().optional(),description:DQ().optional(),minItems:K$().optional(),maxItems:K$().optional(),items:s0({anyOf:K8(s0({const:DQ(),title:DQ()}))}),default:K8(DQ()).optional()}),lD0=K4([cD0,dD0]),pD0=K4([uD0,mD0,lD0]),iD0=K4([pD0,fD0,vD0,gD0]),nD0=Xh.extend({mode:VB("form").optional(),message:DQ(),requestedSchema:s0({type:VB("object"),properties:n$(DQ(),iD0),required:K8(DQ()).optional()})}),aD0=Xh.extend({mode:VB("url"),message:DQ(),elicitationId:DQ(),url:DQ().url()}),oD0=K4([nD0,aD0]),rD0=i5.extend({method:VB("elicitation/create"),params:oD0}),sD0=GW.extend({elicitationId:DQ()}),tD0=KW.extend({method:VB("notifications/elicitation/complete"),params:sD0}),pw=n5.extend({action:V5(["accept","decline","cancel"]),content:Pk((A)=>A===null?void 0:A,n$(DQ(),K4([DQ(),K$(),F9(),K8(DQ())])).optional())}),eD0=s0({type:VB("ref/resource"),uri:DQ()});var AF0=s0({type:VB("ref/prompt"),name:DQ()}),QF0=yG.extend({ref:K4([AF0,eD0]),argument:s0({name:DQ(),value:DQ()}),context:s0({arguments:n$(DQ(),DQ()).optional()}).optional()}),GQA=i5.extend({method:VB("completion/complete"),params:QF0});function U9Q(A){if(A.params.ref.type!=="ref/prompt")throw TypeError(`Expected CompleteRequestPrompt, but got ${A.params.ref.type}`)}function z9Q(A){if(A.params.ref.type!=="ref/resource")throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${A.params.ref.type}`)}var BF0=n5.extend({completion:L5({values:K8(DQ()).max(100),total:C4(K$().int()),hasMore:C4(F9())})}),$F0=s0({uri:DQ().startsWith("file://"),name:DQ().optional(),_meta:n$(DQ(),G4()).optional()}),JF0=i5.extend({method:VB("roots/list"),params:yG.optional()}),_FA=n5.extend({roots:K8($F0)}),YF0=KW.extend({method:VB("notifications/roots/list_changed"),params:GW.optional()}),I01=K4([iAA,CFA,GQA,jFA,JQA,$QA,AQA,QQA,BQA,JD0,XD0,lw,YQA,aAA,rAA,sAA,eAA]),C01=K4([pAA,nAA,OFA,YF0,qh]),O01=K4([lAA,Uh,wFA,pw,_FA,oAA,tAA,cw]),M01=K4([iAA,bD0,rD0,JF0,aAA,rAA,sAA,eAA]),N01=K4([pAA,nAA,jD0,KD0,BD0,VD0,CD0,qh,tD0]),L01=K4([lAA,pq0,BF0,ID0,HD0,tq0,eq0,QD0,XQA,ND0,oAA,tAA,cw]);class RB extends Error{constructor(A,Q,B){super(`MCP error ${A}: ${Q}`);this.code=A,this.data=B,this.name="McpError"}static fromError(A,Q,B){if(A===uB.UrlElicitationRequired&&B){let $=B;if($.elicitations)return new I9Q($.elicitations,Q)}return new RB(A,Q,B)}}class I9Q extends RB{constructor(A,Q=`URL elicitation${A.length>1?"s":""} required`){super(uB.UrlElicitationRequired,Q,{elicitations:A})}get elicitations(){return this.data?.elicitations??[]}}function YI(A){return A==="completed"||A==="failed"||A==="cancelled"}var O9Q=Symbol("Let zodToJsonSchema decide on which parser to use");var C9Q={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},M9Q=(A)=>typeof A==="string"?{...C9Q,name:A}:{...C9Q,...A};var N9Q=(A)=>{let Q=M9Q(A),B=Q.name!==void 0?[...Q.basePath,Q.definitionPath,Q.name]:Q.basePath;return{...Q,flags:{hasReferencedOpenAiAnyType:!1},currentPath:B,propertyPath:void 0,seen:new Map(Object.entries(Q.definitions).map(([$,J])=>[J._def,{def:J._def,path:[...Q.basePath,Q.definitionPath,$],jsonSchema:void 0}]))}};function PFA(A,Q,B,$){if(!$?.errorMessages)return;if(B)A.errorMessage={...A.errorMessage,[Q]:B}}function a8(A,Q,B,$,J){A[Q]=B,PFA(A,Q,$,J)}var KQA=(A,Q)=>{let B=0;for(;B<A.length&&B<Q.length;B++)if(A[B]!==Q[B])break;return[(A.length-B).toString(),...Q.slice(B)].join("/")};function V6(A){if(A.target!=="openAi")return{};let Q=[...A.basePath,A.definitionPath,A.openAiAnyTypeName];return A.flags.hasReferencedOpenAiAnyType=!0,{$ref:A.$refStrategy==="relative"?KQA(Q,A.currentPath):Q.join("/")}}function L9Q(A,Q){let B={type:"array"};if(A.type?._def&&A.type?._def?.typeName!==Z0.ZodAny)B.items=$1(A.type._def,{...Q,currentPath:[...Q.currentPath,"items"]});if(A.minLength)a8(B,"minItems",A.minLength.value,A.minLength.message,Q);if(A.maxLength)a8(B,"maxItems",A.maxLength.value,A.maxLength.message,Q);if(A.exactLength)a8(B,"minItems",A.exactLength.value,A.exactLength.message,Q),a8(B,"maxItems",A.exactLength.value,A.exactLength.message,Q);return B}function V9Q(A,Q){let B={type:"integer",format:"int64"};if(!A.checks)return B;for(let $ of A.checks)switch($.kind){case"min":if(Q.target==="jsonSchema7")if($.inclusive)a8(B,"minimum",$.value,$.message,Q);else a8(B,"exclusiveMinimum",$.value,$.message,Q);else{if(!$.inclusive)B.exclusiveMinimum=!0;a8(B,"minimum",$.value,$.message,Q)}break;case"max":if(Q.target==="jsonSchema7")if($.inclusive)a8(B,"maximum",$.value,$.message,Q);else a8(B,"exclusiveMaximum",$.value,$.message,Q);else{if(!$.inclusive)B.exclusiveMaximum=!0;a8(B,"maximum",$.value,$.message,Q)}break;case"multipleOf":a8(B,"multipleOf",$.value,$.message,Q);break}return B}function E9Q(){return{type:"boolean"}}function WQA(A,Q){return $1(A.type._def,Q)}var R9Q=(A,Q)=>{return $1(A.innerType._def,Q)};function TFA(A,Q,B){let $=B??Q.dateStrategy;if(Array.isArray($))return{anyOf:$.map((J,Y)=>TFA(A,Q,J))};switch($){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return XF0(A,Q)}}var XF0=(A,Q)=>{let B={type:"integer",format:"unix-time"};if(Q.target==="openApi3")return B;for(let $ of A.checks)switch($.kind){case"min":a8(B,"minimum",$.value,$.message,Q);break;case"max":a8(B,"maximum",$.value,$.message,Q);break}return B};function j9Q(A,Q){return{...$1(A.innerType._def,Q),default:A.defaultValue()}}function w9Q(A,Q){return Q.effectStrategy==="input"?$1(A.schema._def,Q):V6(Q)}function _9Q(A){return{type:"string",enum:Array.from(A.values)}}var GF0=(A)=>{if("type"in A&&A.type==="string")return!1;return"allOf"in A};function P9Q(A,Q){let B=[$1(A.left._def,{...Q,currentPath:[...Q.currentPath,"allOf","0"]}),$1(A.right._def,{...Q,currentPath:[...Q.currentPath,"allOf","1"]})].filter((Y)=>!!Y),$=Q.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,J=[];return B.forEach((Y)=>{if(GF0(Y)){if(J.push(...Y.allOf),Y.unevaluatedProperties===void 0)$=void 0}else{let X=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:G,...K}=Y;X=K}else $=void 0;J.push(X)}}),J.length?{allOf:J,...$}:void 0}function T9Q(A,Q){let B=typeof A.value;if(B!=="bigint"&&B!=="number"&&B!=="boolean"&&B!=="string")return{type:Array.isArray(A.value)?"array":"object"};if(Q.target==="openApi3")return{type:B==="bigint"?"integer":B,enum:[A.value]};return{type:B==="bigint"?"integer":B,const:A.value}}var kFA=void 0,SZ={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(kFA===void 0)kFA=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return kFA},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ZQA(A,Q){let B={type:"string"};if(A.checks)for(let $ of A.checks)switch($.kind){case"min":a8(B,"minLength",typeof B.minLength==="number"?Math.max(B.minLength,$.value):$.value,$.message,Q);break;case"max":a8(B,"maxLength",typeof B.maxLength==="number"?Math.min(B.maxLength,$.value):$.value,$.message,Q);break;case"email":switch(Q.emailStrategy){case"format:email":xZ(B,"email",$.message,Q);break;case"format:idn-email":xZ(B,"idn-email",$.message,Q);break;case"pattern:zod":m7(B,SZ.email,$.message,Q);break}break;case"url":xZ(B,"uri",$.message,Q);break;case"uuid":xZ(B,"uuid",$.message,Q);break;case"regex":m7(B,$.regex,$.message,Q);break;case"cuid":m7(B,SZ.cuid,$.message,Q);break;case"cuid2":m7(B,SZ.cuid2,$.message,Q);break;case"startsWith":m7(B,RegExp(`^${SFA($.value,Q)}`),$.message,Q);break;case"endsWith":m7(B,RegExp(`${SFA($.value,Q)}$`),$.message,Q);break;case"datetime":xZ(B,"date-time",$.message,Q);break;case"date":xZ(B,"date",$.message,Q);break;case"time":xZ(B,"time",$.message,Q);break;case"duration":xZ(B,"duration",$.message,Q);break;case"length":a8(B,"minLength",typeof B.minLength==="number"?Math.max(B.minLength,$.value):$.value,$.message,Q),a8(B,"maxLength",typeof B.maxLength==="number"?Math.min(B.maxLength,$.value):$.value,$.message,Q);break;case"includes":{m7(B,RegExp(SFA($.value,Q)),$.message,Q);break}case"ip":{if($.version!=="v6")xZ(B,"ipv4",$.message,Q);if($.version!=="v4")xZ(B,"ipv6",$.message,Q);break}case"base64url":m7(B,SZ.base64url,$.message,Q);break;case"jwt":m7(B,SZ.jwt,$.message,Q);break;case"cidr":{if($.version!=="v6")m7(B,SZ.ipv4Cidr,$.message,Q);if($.version!=="v4")m7(B,SZ.ipv6Cidr,$.message,Q);break}case"emoji":m7(B,SZ.emoji(),$.message,Q);break;case"ulid":{m7(B,SZ.ulid,$.message,Q);break}case"base64":{switch(Q.base64Strategy){case"format:binary":{xZ(B,"binary",$.message,Q);break}case"contentEncoding:base64":{a8(B,"contentEncoding","base64",$.message,Q);break}case"pattern:zod":{m7(B,SZ.base64,$.message,Q);break}}break}case"nanoid":m7(B,SZ.nanoid,$.message,Q);case"toLowerCase":case"toUpperCase":case"trim":break;default:((J)=>{})($)}return B}function SFA(A,Q){return Q.patternStrategy==="escape"?WF0(A):A}var KF0=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function WF0(A){let Q="";for(let B=0;B<A.length;B++){if(!KF0.has(A[B]))Q+="\\";Q+=A[B]}return Q}function xZ(A,Q,B,$){if(A.format||A.anyOf?.some((J)=>J.format)){if(!A.anyOf)A.anyOf=[];if(A.format){if(A.anyOf.push({format:A.format,...A.errorMessage&&$.errorMessages&&{errorMessage:{format:A.errorMessage.format}}}),delete A.format,A.errorMessage){if(delete A.errorMessage.format,Object.keys(A.errorMessage).length===0)delete A.errorMessage}}A.anyOf.push({format:Q,...B&&$.errorMessages&&{errorMessage:{format:B}}})}else a8(A,"format",Q,B,$)}function m7(A,Q,B,$){if(A.pattern||A.allOf?.some((J)=>J.pattern)){if(!A.allOf)A.allOf=[];if(A.pattern){if(A.allOf.push({pattern:A.pattern,...A.errorMessage&&$.errorMessages&&{errorMessage:{pattern:A.errorMessage.pattern}}}),delete A.pattern,A.errorMessage){if(delete A.errorMessage.pattern,Object.keys(A.errorMessage).length===0)delete A.errorMessage}}A.allOf.push({pattern:k9Q(Q,$),...B&&$.errorMessages&&{errorMessage:{pattern:B}}})}else a8(A,"pattern",k9Q(Q,$),B,$)}function k9Q(A,Q){if(!Q.applyRegexFlags||!A.flags)return A.source;let B={i:A.flags.includes("i"),m:A.flags.includes("m"),s:A.flags.includes("s")},$=B.i?A.source.toLowerCase():A.source,J="",Y=!1,X=!1,G=!1;for(let K=0;K<$.length;K++){if(Y){J+=$[K],Y=!1;continue}if(B.i){if(X){if($[K].match(/[a-z]/)){if(G)J+=$[K],J+=`${$[K-2]}-${$[K]}`.toUpperCase(),G=!1;else if($[K+1]==="-"&&$[K+2]?.match(/[a-z]/))J+=$[K],G=!0;else J+=`${$[K]}${$[K].toUpperCase()}`;continue}}else if($[K].match(/[a-z]/)){J+=`[${$[K]}${$[K].toUpperCase()}]`;continue}}if(B.m){if($[K]==="^"){J+=`(^|(?<=[\r
|
|
1341
1341
|
]))`;continue}else if($[K]==="$"){J+=`($|(?=[\r
|
|
1342
1342
|
]))`;continue}}if(B.s&&$[K]==="."){J+=X?`${$[K]}\r
|
|
1343
1343
|
`:`[${$[K]}\r
|