@capgo/cli 8.12.5 → 8.12.6
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 +4 -4
- package/dist/package.json +3 -2
- package/dist/src/sdk.js +1 -1
- package/package.json +3 -2
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 C4.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()}`,C4.env[A.envVar]);else this.emit(`optionEnv:${A.name()}`)}})}_parseOptionsImplied(){let A=new qKQ(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=XCA(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=XCA(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 HKQ(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=$3.basename(A,$3.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(C4.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 GCA(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 KBA(){if(C4.env.NO_COLOR||C4.env.FORCE_COLOR==="0"||C4.env.FORCE_COLOR==="false")return!1;if(C4.env.FORCE_COLOR||C4.env.CLICOLOR_FORCE!==void 0)return!0;return}UKQ.Command=WBA;UKQ.useColor=KBA});var DCA=r((MKQ)=>{var{Argument:WCA}=Hu(),{Command:ZBA}=KCA(),{CommanderError:CKQ,InvalidArgumentError:ZCA}=K_(),{Help:OKQ}=JBA(),{Option:HCA}=YBA();MKQ.program=new ZBA;MKQ.createCommand=(A)=>new ZBA(A);MKQ.createOption=(A,Q)=>new HCA(A,Q);MKQ.createArgument=(A,Q)=>new WCA(A,Q);MKQ.Command=ZBA;MKQ.Option=HCA;MKQ.Argument=WCA;MKQ.Help=OKQ;MKQ.CommanderError=CKQ;MKQ.InvalidArgumentError=ZCA;MKQ.InvalidOptionArgumentError=ZCA});var Z$;var fG=eA(()=>{Z$={name:"@capgo/cli",type:"module",version:"8.12.5",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: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: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: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: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: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: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: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: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: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-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","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: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-bundle-files":"bun test/test-support-bundle-files.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.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 xKQ(A){if(A&&typeof A==="object"&&"status"in A){let Q=A.status;if(typeof Q==="number")return Q}return}function bKQ(A){if(A instanceof Error)return A.message;if(typeof A==="string")return A;return""}function Z_(A){if(A&&typeof A==="object"&&"code"in A){let $=A.code;if(typeof $==="string"&&$.startsWith("commander."))return"commander"}let Q=xKQ(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=bKQ(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 qCA(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 vKQ}from"node:async_hooks";function H_(A,Q){return zCA.run(A,()=>Promise.resolve(Q()))}function gKQ(){return zCA.getStore()}function D_(){CCA=!0}function OCA(){return CCA}function NCA(A){MCA=A}function ICA(A){try{MCA?.(A)}catch{}}function VCA(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 yKQ(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 ECA(){return async(Q,B)=>{let $=(B?.method??"GET").toUpperCase(),J=typeof Q==="string"?Q:Q instanceof URL?Q.href:Q.url,Y=gKQ(),X=yKQ(B),G=Date.now();try{let K=await globalThis.fetch(Q,B);return ICA({url:J,method:$,status:K.status,ok:K.ok,durationMs:Date.now()-G,source:Y,apikey:X}),K}catch(K){throw ICA({url:J,method:$,status:0,ok:!1,durationMs:Date.now()-G,source:Y,apikey:X,error:K}),K}}}var zCA,CCA=!1,MCA,LCA=5000;var F_=eA(()=>{zCA=new vKQ});import{homedir as RCA,platform as hKQ,release as uKQ}from"node:os";import{arch as mKQ,cwd as jCA,env as Gz,version as cKQ}from"node:process";function JW(A){return A==="1"||A?.toLowerCase()==="true"||A?.toLowerCase()==="yes"}function iKQ(){if(JW(Gz.CAPGO_DISABLE_TELEMETRY)||JW(Gz.CAPGO_DISABLE_POSTHOG))return;return Gz.CAPGO_CLI_POSTHOG_API_KEY?.trim()||Gz.POSTHOG_API_KEY?.trim()||lKQ}function nKQ(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 oKQ(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 aKQ(A){let Q=A,B=jCA(),$=RCA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q}function rKQ(A){let Q=A,B=jCA(),$=RCA();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 sKQ(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 GCA(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 KBA(){if(C4.env.NO_COLOR||C4.env.FORCE_COLOR==="0"||C4.env.FORCE_COLOR==="false")return!1;if(C4.env.FORCE_COLOR||C4.env.CLICOLOR_FORCE!==void 0)return!0;return}UKQ.Command=WBA;UKQ.useColor=KBA});var DCA=r((MKQ)=>{var{Argument:WCA}=Hu(),{Command:ZBA}=KCA(),{CommanderError:CKQ,InvalidArgumentError:ZCA}=K_(),{Help:OKQ}=JBA(),{Option:HCA}=YBA();MKQ.program=new ZBA;MKQ.createCommand=(A)=>new ZBA(A);MKQ.createOption=(A,Q)=>new HCA(A,Q);MKQ.createArgument=(A,Q)=>new WCA(A,Q);MKQ.Command=ZBA;MKQ.Option=HCA;MKQ.Argument=WCA;MKQ.Help=OKQ;MKQ.CommanderError=CKQ;MKQ.InvalidArgumentError=ZCA;MKQ.InvalidOptionArgumentError=ZCA});var Z$;var fG=eA(()=>{Z$={name:"@capgo/cli",type:"module",version:"8.12.6",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: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: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: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: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: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: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: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-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","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: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-bundle-files":"bun test/test-support-bundle-files.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.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 xKQ(A){if(A&&typeof A==="object"&&"status"in A){let Q=A.status;if(typeof Q==="number")return Q}return}function bKQ(A){if(A instanceof Error)return A.message;if(typeof A==="string")return A;return""}function Z_(A){if(A&&typeof A==="object"&&"code"in A){let $=A.code;if(typeof $==="string"&&$.startsWith("commander."))return"commander"}let Q=xKQ(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=bKQ(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 qCA(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 vKQ}from"node:async_hooks";function H_(A,Q){return zCA.run(A,()=>Promise.resolve(Q()))}function gKQ(){return zCA.getStore()}function D_(){CCA=!0}function OCA(){return CCA}function NCA(A){MCA=A}function ICA(A){try{MCA?.(A)}catch{}}function VCA(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 yKQ(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 ECA(){return async(Q,B)=>{let $=(B?.method??"GET").toUpperCase(),J=typeof Q==="string"?Q:Q instanceof URL?Q.href:Q.url,Y=gKQ(),X=yKQ(B),G=Date.now();try{let K=await globalThis.fetch(Q,B);return ICA({url:J,method:$,status:K.status,ok:K.ok,durationMs:Date.now()-G,source:Y,apikey:X}),K}catch(K){throw ICA({url:J,method:$,status:0,ok:!1,durationMs:Date.now()-G,source:Y,apikey:X,error:K}),K}}}var zCA,CCA=!1,MCA,LCA=5000;var F_=eA(()=>{zCA=new vKQ});import{homedir as RCA,platform as hKQ,release as uKQ}from"node:os";import{arch as mKQ,cwd as jCA,env as Gz,version as cKQ}from"node:process";function JW(A){return A==="1"||A?.toLowerCase()==="true"||A?.toLowerCase()==="yes"}function iKQ(){if(JW(Gz.CAPGO_DISABLE_TELEMETRY)||JW(Gz.CAPGO_DISABLE_POSTHOG))return;return Gz.CAPGO_CLI_POSTHOG_API_KEY?.trim()||Gz.POSTHOG_API_KEY?.trim()||lKQ}function nKQ(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 oKQ(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 aKQ(A){let Q=A,B=jCA(),$=RCA();if(B)Q=Q.replaceAll(B,"<cwd>");if($)Q=Q.replaceAll($,"~");return Q}function rKQ(A){let Q=A,B=jCA(),$=RCA();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 sKQ(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 F=Y.lastIndexOf(" "),q=F===-1?"":Y.slice(F+1);if(/:\d+:\d+$/.test(q))X=Y.slice(0,F).trim()||Q,G=q}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:aKQ(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 tKQ(A){if(!A||typeof A!=="object"||!("code"in A))return;let{code:Q}=A;return typeof Q==="string"?Q:void 0}function wCA(A){return!tKQ(A)?.startsWith("commander.")}function HBA(A){let Q=[],B=A;while(B?.parent){let $=B.name();if($)Q.push($);B=B.parent}return Q.reverse().join(" ")||"unknown"}async function DBA(A){let Q=iKQ();if(!Q)return!1;let B=Gz.CAPGO_CLI_POSTHOG_API_HOST?.trim()||Gz.POSTHOG_API_HOST?.trim()||dKQ,$;try{$=nKQ(B)}catch{return!1}let J=oKQ(A.error),Y=rKQ(J.message),X=`cli:${Z$.version}:${A.functionName}`,G=sKQ(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:mKQ,cli_version:Z$.version,error_kind:A.kind,function_name:A.functionName,is_ci:Boolean(Gz.CI),node_version:cKQ,os_platform:hKQ(),os_release:uKQ(),runtime:"cli",status:A.status},timestamp:new Date().toISOString()};try{let F=new AbortController,q=setTimeout(()=>F.abort(),pKQ);try{return(await fetch($,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H),signal:F.signal})).ok}finally{clearTimeout(q)}}catch{return!1}}var dKQ="https://eu.i.posthog.com/i/v0/e/",lKQ="phc_NXDyDajQaTQVwb25DEhIVZfxVUn4R0Y348Z7vWYHZUi",pKQ=1500;var q_=eA(()=>{fG()});import{existsSync as g7}from"fs";var kq=(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(g7(B)||g7($))return"bun";if(g7(J)||g7(Y))return"pnpm";if(g7(X))return"yarn";if(g7(G)||g7(K))return"npm";return Q},qu=(A=kq(),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"}},_CA=(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(g7(B)||g7($))return"bunx";if(g7(J)||g7(Y))return"pnpm exec";if(g7(X))return"yarn dlx";if(g7(G)||g7(K))return"npx";return Q};var FBA=()=>{};function Uu(A,Q){if(isNaN(A)||isNaN(Q))throw Error("Cannot compare against non-numbers");return A===Q?0:A<Q?-1:1}function kCA(A=[],Q=[]){if(A.length&&!Q.length)return-1;if(!A.length&&Q.length)return 1;return 0}function Iu(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 UBA(A){return typeof A==="number"&&!Number.isNaN(A)&&(!Number.isFinite(A)||0<=A&&A<=Number.MAX_SAFE_INTEGER)}function y7(A){return A.split(".").filter(Boolean).map((Q)=>{if(BWQ.test(Q)){let B=Number(Q);if(UBA(B))return B}return Q})}function yZ(A){return A.split(".").filter(Boolean)}function Cu(A,Q){let B=Number(A);if(!UBA(B))throw TypeError(Q);return B}function J3(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 PN="0|[1-9]\\d*",eKQ="\\d*[a-zA-Z-][a-zA-Z0-9-]*",AWQ,PCA,SCA,TCA="[0-9A-Za-z-]+",xCA,bCA,fCA,vCA="(?:<|>)?=?",QWQ="x|X|\\*",qBA,zu,gCA,yCA,IBA=256,BWQ;var mX=eA(()=>{AWQ=`(?<major>${PN})\\.(?<minor>${PN})\\.(?<patch>${PN})`,PCA=`(?:${PN}|${eKQ})`,SCA=`(?:-(?<prerelease>${PCA}(?:\\.${PCA})*))`,xCA=`(?:\\+(?<buildmetadata>${TCA}(?:\\.${TCA})*))`,bCA=`v?${AWQ}${SCA}?${xCA}?`,fCA=new RegExp(`^${bCA}$`),qBA=`${PN}|${QWQ}`,zu=`[v=\\s]*(?<major>${qBA})(?:\\.(?<minor>${qBA})(?:\\.(?<patch>${qBA})${SCA}?${xCA}?)?)?`,gCA=new RegExp(`^(?<operator>~>?|\\^|${vCA})\\s*${zu}$`),yCA=new RegExp(`^(?<operator>${vCA})\\s*(${bCA})$|^$`);BWQ=new RegExp(`^${PN}$`)});function PY(A,Q){if(A===Q)return 0;return Uu(A.major,Q.major)||Uu(A.minor,Q.minor)||Uu(A.patch,Q.patch)||kCA(A.prerelease,Q.prerelease)||Iu(A.prerelease,Q.prerelease)}var vG=eA(()=>{mX()});function hCA(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(Iu(A.prerelease,Q.prerelease)!==0)return"prerelease"}var uCA=eA(()=>{mX()});function zBA(A){return A.toFixed(0)}function Q5(A){let Q=zBA(A.major),B=zBA(A.minor),$=zBA(A.patch),J=A.prerelease?.join(".")??"",Y=A.build?.join(".")??"";return[[`${Q}.${B}.${$}`,J].filter((K)=>K).join("-"),Y].filter((K)=>K).join("+")}function $WQ(A,Q){if(J3(Q))return!0;let B=PY(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 Ou(A,Q){for(let B of Q)if(!$WQ(A,B))return!1;if(!A.prerelease?.length)return!0;for(let B of Q){if(J3(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 Mu=eA(()=>{mX();vG()});function U_(A,Q){return Q.some((B)=>Ou(A,B))}var I_=eA(()=>{Mu()});function JWQ(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 z_(A=[],Q){let B=JWQ(A);if(!Q)return B;let $=y7(Q);if($.every((J)=>typeof J==="string")){if($.every((J,Y)=>J===B[Y])&&typeof B[$.length]==="number")return B;$=[...$,0]}return $}function Sq(A,Q,B={}){let $=B.build!==void 0?yZ(B.build):A.build??[];switch(Q){case"premajor":return{major:A.major+1,minor:0,patch:0,prerelease:z_(A.prerelease,B.prerelease),build:$};case"preminor":return{major:A.major,minor:A.minor+1,patch:0,prerelease:z_(A.prerelease,B.prerelease),build:$};case"prepatch":return{major:A.major,minor:A.minor,patch:A.patch+1,prerelease:z_(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:z_(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:z_(A.prerelease,B.prerelease),build:$};default:throw TypeError(`Cannot increment version: invalid argument ${Q}`)}}var mCA=eA(()=>{mX()});var Nu,TN;var C_=eA(()=>{Nu={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},TN={operator:void 0,...Nu}});var CBA=eA(()=>{C_();mX()});function OBA(A,Q){return PY(A,Q)>0}var MBA=eA(()=>{vG()});var cCA=eA(()=>{I_();MBA()});function cX(A,Q){return PY(A,Q)<0}var NBA=eA(()=>{vG()});var dCA=eA(()=>{I_();NBA()});function YWQ(A){let B=A.match(yCA)?.groups;if(!B)return null;let{operator:$}=B;return{operator:$||void 0,...Nu}}function R$(A){return!A||A.toLowerCase()==="x"||A==="*"}function XWQ(A){if(R$(A.major))return;if(R$(A.minor))return{operator:">=",major:+A.major,minor:0,patch:0,prerelease:[],build:[]};if(R$(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?y7(A.prerelease):[],build:[]}}function GWQ(A){if(R$(A.major))return;if(R$(A.minor))return{operator:"<",major:+A.major+1,minor:0,patch:0,prerelease:[],build:[]};if(R$(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:y7(A.prerelease),build:[]};return{operator:"<=",major:+A.major,minor:+A.minor,patch:+A.patch,prerelease:[],build:[]}}function KWQ(A){let Q=A.match(new RegExp(`^${zu}`)),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(`^${zu}\\s*$`))?.groups,K=XWQ(B),W=GWQ(G);return[K,W].filter(Boolean)}function WWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[TN];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=y7(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 ZWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[TN];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=y7(A.prerelease??"");return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G},{operator:"<",major:J,minor:Y+1,patch:0}]}function HWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(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=y7(A.prerelease??""),K=yZ(A.build??"");return[{operator:"<",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function DWQ(A){let Q=R$(A.minor),B=R$(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=y7(A.prerelease??""),G=yZ(A.build??"");return[{operator:"<=",major:$,minor:J,patch:Y,prerelease:X,build:G}]}function FWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(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=y7(A.prerelease??""),K=yZ(A.build??"");return[{operator:">",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function qWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[TN];if(B)return[{operator:">=",major:J,minor:0,patch:0}];if($)return[{operator:">=",major:J,minor:Y,patch:0}];let G=y7(A.prerelease??""),K=yZ(A.build??"");return[{operator:">=",major:J,minor:Y,patch:X,prerelease:G,build:K}]}function UWQ(A){let Q=R$(A.major),B=R$(A.minor),$=R$(A.patch),J=+A.major,Y=+A.minor,X=+A.patch;if(Q)return[TN];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=y7(A.prerelease??""),K=yZ(A.build??"");return[{operator:A.operator==="="?"=":void 0,major:J,minor:Y,patch:X,prerelease:G,build:K}]}function IWQ(A){let Q=A.match(gCA)?.groups;if(!Q)return YWQ(A);switch(Q.operator){case"^":return WWQ(Q);case"~":case"~>":return ZWQ(Q);case"<":return HWQ(Q);case"<=":return DWQ(Q);case">":return FWQ(Q);case">=":return qWQ(Q);default:return UWQ(Q)}}function zWQ(A){return A.split(/\s+/).flatMap(IWQ)}function Lu(A){let Q=A.replaceAll(/(?<=[<>=~^])(\s+)/g,"").split(/\s*\|\|\s*/).map((B)=>KWQ(B)||zWQ(B));if(Q.some((B)=>B.includes(null)))throw TypeError(`Cannot parse version range: range "${A}" is invalid`);return Q}var LBA=eA(()=>{mX();C_()});function tB(A){if(typeof A!=="string")throw TypeError(`Cannot parse version as version must be a string: received ${typeof A}`);if(A.length>IBA)throw TypeError(`Cannot parse version as version length is too long: length is ${A.length}, max length is ${IBA}`);A=A.trim();let Q=A.match(fCA)?.groups;if(!Q)throw TypeError(`Cannot parse version: ${A}`);let B=Cu(Q.major,`Cannot parse version ${A}: invalid major version`),$=Cu(Q.minor,`Cannot parse version ${A}: invalid minor version`),J=Cu(Q.patch,`Cannot parse version ${A}: invalid patch version`),Y=Q.prerelease?y7(Q.prerelease):[],X=Q.buildmetadata?yZ(Q.buildmetadata):[];return{major:B,minor:$,patch:J,prerelease:Y,build:X}}var Vu=eA(()=>{mX();mX()});function lCA(A,Q){let B=A.operator,$=Q.operator;if(B===void 0){if(J3(A))return!0;return U_(A,[[Q]])}if($===void 0){if(J3(Q))return!0;return U_(Q,[[A]])}let J=PY(A,Q);return(B===">="||B===">")&&($===">="||$===">")||(B==="<="||B==="<")&&($==="<="||$==="<")||J===0&&((B===">="||B==="<=")&&($===">="||$==="<="))||J===-1&&(B===">="||B===">")&&($==="<="||$==="<")||J===1&&(B==="<="||B==="<")&&($===">="||$===">")}function CWQ(A){return A.every((Q)=>{return Q.some((B)=>OWQ(B))})}function OWQ(A){for(let Q=0;Q<A.length-1;Q++){let B=A[Q];for(let $ of A.slice(Q+1))if(!lCA(B,$))return!1}return!0}function pCA(A,Q){return CWQ([A,Q])&&A.some((B)=>{return Q.some(($)=>{return B.every((J)=>{return $.every((Y)=>lCA(J,Y))})})})}var iCA=eA(()=>{mX();vG();I_()});var nCA=eA(()=>{LBA()});var oCA=eA(()=>{C_();C_();CBA()});function O_(A){try{return tB(A),!0}catch{return!1}}var aCA=eA(()=>{Vu()});var rCA=eA(()=>{Vu()});var sCA=eA(()=>{mX()});var tCA=eA(()=>{vG()});var eCA=eA(()=>{vG()});var AOA=eA(()=>{Mu();mX();vG()});function VBA(A,Q){return PY(A,Q)>=0}var QOA=eA(()=>{vG()});var BOA=eA(()=>{Mu();mX();vG()});var $OA=eA(()=>{vG()});var YW=eA(()=>{vG();uCA();I_();mCA();CBA();cCA();dCA();LBA();Vu();iCA();nCA();oCA();aCA();rCA();sCA();tCA();eCA();MBA();AOA();QOA();NBA();BOA();$OA()});var h7=r((LO0,ju)=>{var JOA,YOA,XOA,GOA,KOA,WOA,ZOA,HOA,DOA,FOA,qOA,UOA,IOA,Eu,EBA,zOA,COA,OOA,kN,MOA,NOA,LOA,VOA,EOA,ROA,jOA,wOA,_OA,Ru,POA,TOA,kOA;(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 ju==="object"&&typeof LO0==="object")A(B(Q,B(LO0)));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]};JOA=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)},YOA=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},XOA=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},GOA=function(Y,X,G,K){var W=arguments.length,H=W<3?X:K===null?K=Object.getOwnPropertyDescriptor(X,G):K,F;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")H=Reflect.decorate(Y,X,G,K);else for(var q=Y.length-1;q>=0;q--)if(F=Y[q])H=(W<3?F(H):W>3?F(X,G,H):F(X,G))||H;return W>3&&H&&Object.defineProperty(X,G,H),H},KOA=function(Y,X){return function(G,K){X(G,K,Y)}},WOA=function(Y,X,G,K,W,H){function F(T){if(T!==void 0&&typeof T!=="function")throw TypeError("Function expected");return T}var q=K.kind,U=q==="getter"?"get":q==="setter"?"set":"value",I=!X&&Y?K.static?Y:Y.prototype:null,z=X||(I?Object.getOwnPropertyDescriptor(I,K.name):{}),O,V=!1;for(var E=G.length-1;E>=0;E--){var M={};for(var L in K)M[L]=L==="access"?{}:K[L];for(var L in K.access)M.access[L]=K.access[L];M.addInitializer=function(T){if(V)throw TypeError("Cannot add initializers after decoration has completed");H.push(F(T||null))};var R=(0,G[E])(q==="accessor"?{get:z.get,set:z.set}:z[U],M);if(q==="accessor"){if(R===void 0)continue;if(R===null||typeof R!=="object")throw TypeError("Object expected");if(O=F(R.get))z.get=O;if(O=F(R.set))z.set=O;if(O=F(R.init))W.unshift(O)}else if(O=F(R))if(q==="field")W.unshift(O);else z[U]=O}if(I)Object.defineProperty(I,K.name,z);V=!0},ZOA=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},HOA=function(Y){return typeof Y==="symbol"?Y:"".concat(Y)},DOA=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})},FOA=function(Y,X){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,X)},qOA=function(Y,X,G,K){function W(H){return H instanceof G?H:new G(function(F){F(H)})}return new(G||(G=Promise))(function(H,F){function q(z){try{I(K.next(z))}catch(O){F(O)}}function U(z){try{I(K.throw(z))}catch(O){F(O)}}function I(z){z.done?H(z.value):W(z.value).then(q,U)}I((K=K.apply(Y,X||[])).next())})},UOA=function(Y,X){var G={label:0,sent:function(){if(H[0]&1)throw H[1];return H[1]},trys:[],ops:[]},K,W,H,F=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return F.next=q(0),F.throw=q(1),F.return=q(2),typeof Symbol==="function"&&(F[Symbol.iterator]=function(){return this}),F;function q(I){return function(z){return U([I,z])}}function U(I){if(K)throw TypeError("Generator is already executing.");while(F&&(F=0,I[0]&&(G=0)),G)try{if(K=1,W&&(H=I[0]&2?W.return:I[0]?W.throw||((H=W.return)&&H.call(W),0):W.next)&&!(H=H.call(W,I[1])).done)return H;if(W=0,H)I=[I[0]&2,H.value];switch(I[0]){case 0:case 1:H=I;break;case 4:return G.label++,{value:I[1],done:!1};case 5:G.label++,W=I[1],I=[0];continue;case 7:I=G.ops.pop(),G.trys.pop();continue;default:if((H=G.trys,!(H=H.length>0&&H[H.length-1]))&&(I[0]===6||I[0]===2)){G=0;continue}if(I[0]===3&&(!H||I[1]>H[0]&&I[1]<H[3])){G.label=I[1];break}if(I[0]===6&&G.label<H[1]){G.label=H[1],H=I;break}if(H&&G.label<H[2]){G.label=H[2],G.ops.push(I);break}if(H[2])G.ops.pop();G.trys.pop();continue}I=X.call(Y,G)}catch(z){I=[6,z],W=0}finally{K=H=0}if(I[0]&5)throw I[1];return{value:I[0]?I[1]:void 0,done:!0}}},IOA=function(Y,X){for(var G in Y)if(G!=="default"&&!Object.prototype.hasOwnProperty.call(X,G))Ru(X,Y,G)},Ru=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]},Eu=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.")},EBA=function(Y,X){var G=typeof Symbol==="function"&&Y[Symbol.iterator];if(!G)return Y;var K=G.call(Y),W,H=[],F;try{while((X===void 0||X-- >0)&&!(W=K.next()).done)H.push(W.value)}catch(q){F={error:q}}finally{try{if(W&&!W.done&&(G=K.return))G.call(K)}finally{if(F)throw F.error}}return H},zOA=function(){for(var Y=[],X=0;X<arguments.length;X++)Y=Y.concat(EBA(arguments[X]));return Y},COA=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],F=0,q=H.length;F<q;F++,W++)K[W]=H[F];return K},OOA=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))},kN=function(Y){return this instanceof kN?(this.v=Y,this):new kN(Y)},MOA=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),q("next"),q("throw"),q("return",F),W[Symbol.asyncIterator]=function(){return this},W;function F(E){return function(M){return Promise.resolve(M).then(E,O)}}function q(E,M){if(K[E]){if(W[E]=function(L){return new Promise(function(R,T){H.push([E,L,R,T])>1||U(E,L)})},M)W[E]=M(W[E])}}function U(E,M){try{I(K[E](M))}catch(L){V(H[0][3],L)}}function I(E){E.value instanceof kN?Promise.resolve(E.value.v).then(z,O):V(H[0][2],E)}function z(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])}},NOA=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(F){return(G=!G)?{value:kN(Y[W](F)),done:!1}:H?H(F):F}:H}},LOA=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 Eu==="function"?Eu(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(F){return new Promise(function(q,U){F=Y[H](F),W(q,U,F.done,F.value)})}}function W(H,F,q,U){Promise.resolve(U).then(function(I){H({value:I,done:q})},F)}},VOA=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)};EOA=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")Ru(X,Y,G[K])}return B(X,Y),X},ROA=function(Y){return Y&&Y.__esModule?Y:{default:Y}},jOA=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)},wOA=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},_OA=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)},POA=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};TOA=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(F){return X(F),W()})}else K|=1}catch(F){X(F)}if(K===1)return Y.hasError?Promise.reject(Y.error):Promise.resolve();if(Y.hasError)throw Y.error}return W()},kOA=function(Y,X){if(typeof Y==="string"&&/^\.\.?\//.test(Y))return Y.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(G,K,W,H,F){return K?X?".jsx":".js":W&&(!H||!F)?G:W+H+"."+F.toLowerCase()+"js"});return Y},A("__extends",JOA),A("__assign",YOA),A("__rest",XOA),A("__decorate",GOA),A("__param",KOA),A("__esDecorate",WOA),A("__runInitializers",ZOA),A("__propKey",HOA),A("__setFunctionName",DOA),A("__metadata",FOA),A("__awaiter",qOA),A("__generator",UOA),A("__exportStar",IOA),A("__createBinding",Ru),A("__values",Eu),A("__read",EBA),A("__spread",zOA),A("__spreadArrays",COA),A("__spreadArray",OOA),A("__await",kN),A("__asyncGenerator",MOA),A("__asyncDelegator",NOA),A("__asyncValues",LOA),A("__makeTemplateObject",VOA),A("__importStar",EOA),A("__importDefault",ROA),A("__classPrivateFieldGet",jOA),A("__classPrivateFieldSet",wOA),A("__classPrivateFieldIn",_OA),A("__addDisposableResource",POA),A("__disposeResources",TOA),A("__rewriteRelativeImportExtension",kOA)})});var bOA=r((SOA)=>{Object.defineProperty(SOA,"__esModule",{value:!0});SOA.resolveFetch=void 0;var MWQ=(A)=>{if(A)return(...Q)=>A(...Q);return(...Q)=>fetch(...Q)};SOA.resolveFetch=MWQ});var RBA=r((hOA)=>{Object.defineProperty(hOA,"__esModule",{value:!0});hOA.FunctionRegion=hOA.FunctionsHttpError=hOA.FunctionsRelayError=hOA.FunctionsFetchError=hOA.FunctionsError=void 0;class M_ 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}}}hOA.FunctionsError=M_;class vOA extends M_{constructor(A){super("Failed to send a request to the Edge Function","FunctionsFetchError",A)}}hOA.FunctionsFetchError=vOA;class gOA extends M_{constructor(A){super("Relay Error invoking the Edge Function","FunctionsRelayError",A)}}hOA.FunctionsRelayError=gOA;class yOA extends M_{constructor(A){super("Edge Function returned a non-2xx status code","FunctionsHttpError",A)}}hOA.FunctionsHttpError=yOA;var fOA;(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"})(fOA||(hOA.FunctionRegion=fOA={}))});var lOA=r((cOA)=>{Object.defineProperty(cOA,"__esModule",{value:!0});cOA.FunctionsClient=void 0;var RWQ=h7(),jWQ=bOA(),SN=RBA();class mOA{constructor(A,{headers:Q={},customFetch:B,region:$=SN.FunctionRegion.Any}={}){this.url=A,this.headers=Q,this.region=$,this.fetch=(0,jWQ.resolveFetch)(B)}setAuth(A){this.headers.Authorization=`Bearer ${A}`}invoke(A){return RWQ.__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,F={},{region:q}=B;if(!q)q=this.region;let U=new URL(`${this.url}/${Q}`);if(q&&q!=="any")F["x-region"]=q,U.searchParams.set("forceFunctionRegion",q);let I;if(K&&(X&&!Object.prototype.hasOwnProperty.call(X,"Content-Type")||!X))if(typeof Blob<"u"&&K instanceof Blob||K instanceof ArrayBuffer)F["Content-Type"]="application/octet-stream",I=K;else if(typeof K==="string")F["Content-Type"]="text/plain",I=K;else if(typeof FormData<"u"&&K instanceof FormData)I=K;else F["Content-Type"]="application/json",I=JSON.stringify(K);else if(K&&typeof K!=="string"&&!(typeof Blob<"u"&&K instanceof Blob)&&!(K instanceof ArrayBuffer)&&!(typeof FormData<"u"&&K instanceof FormData))I=JSON.stringify(K);else I=K;let z=W;if(H)if(Y=new AbortController,J=setTimeout(()=>Y.abort(),H),W)z=Y.signal,W.addEventListener("abort",()=>Y.abort());else z=Y.signal;let O=yield this.fetch(U.toString(),{method:G||"POST",headers:Object.assign(Object.assign(Object.assign({},F),this.headers),X),body:I,signal:z}).catch((L)=>{throw new SN.FunctionsFetchError(L)}),V=O.headers.get("x-relay-error");if(V&&V==="true")throw new SN.FunctionsRelayError(O);if(!O.ok)throw new SN.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 SN.FunctionsHttpError||X instanceof SN.FunctionsRelayError?X.context:void 0}}finally{if(J)clearTimeout(J)}})}}cOA.FunctionsClient=mOA});var pOA=r((xq)=>{Object.defineProperty(xq,"__esModule",{value:!0});xq.FunctionRegion=xq.FunctionsRelayError=xq.FunctionsHttpError=xq.FunctionsFetchError=xq.FunctionsError=xq.FunctionsClient=void 0;var wWQ=lOA();Object.defineProperty(xq,"FunctionsClient",{enumerable:!0,get:function(){return wWQ.FunctionsClient}});var N_=RBA();Object.defineProperty(xq,"FunctionsError",{enumerable:!0,get:function(){return N_.FunctionsError}});Object.defineProperty(xq,"FunctionsFetchError",{enumerable:!0,get:function(){return N_.FunctionsFetchError}});Object.defineProperty(xq,"FunctionsHttpError",{enumerable:!0,get:function(){return N_.FunctionsHttpError}});Object.defineProperty(xq,"FunctionsRelayError",{enumerable:!0,get:function(){return N_.FunctionsRelayError}});Object.defineProperty(xq,"FunctionRegion",{enumerable:!0,get:function(){return N_.FunctionRegion}})});function nOA(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 TWQ(A,Q,B,$){if(!$||B>=3)return!1;if(!rOA.includes(A))return!1;if(!PWQ.includes(Q))return!1;return!0}function L_(A){return L_=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},L_(A)}function bWQ(A,Q){if(L_(A)!="object"||!A)return A;var B=A[Symbol.toPrimitive];if(B!==void 0){var $=B.call(A,Q||"default");if(L_($)!="object")return $;throw TypeError("@@toPrimitive must return a primitive value.")}return(Q==="string"?String:Number)(A)}function fWQ(A){var Q=bWQ(A,"string");return L_(Q)=="symbol"?Q:Q+""}function vWQ(A,Q,B){return(Q=fWQ(Q))in A?Object.defineProperty(A,Q,{value:B,enumerable:!0,configurable:!0,writable:!0}):A[Q]=B,A}function aOA(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 wu(A){for(var Q=1;Q<arguments.length;Q++){var B=arguments[Q]!=null?arguments[Q]:{};Q%2?aOA(Object(B),!0).forEach(function($){vWQ(A,$,B[$])}):Object.getOwnPropertyDescriptors?Object.defineProperties(A,Object.getOwnPropertyDescriptors(B)):aOA(Object(B)).forEach(function($){Object.defineProperty(A,$,Object.getOwnPropertyDescriptor(B,$))})}return A}var iOA=(A)=>Math.min(1000*2**A,30000),PWQ,rOA,jBA,kWQ=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((F,q)=>{W[q]=F}),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,(F,q)=>typeof q==="bigint"?q.toString():q),signal:B.signal})}catch(F){if((F===null||F===void 0?void 0:F.name)==="AbortError"||(F===null||F===void 0?void 0:F.code)==="ABORT_ERR")throw F;if(!rOA.includes(B.method))throw F;if(B.retryEnabled&&X<3){let q=iOA(X);X++,await nOA(q,B.signal);continue}throw F}if(TWQ(B.method,H.status,X,B.retryEnabled)){var G,K;let F=(G=(K=H.headers)===null||K===void 0?void 0:K.get("Retry-After"))!==null&&G!==void 0?G:null,q=F!==null?Math.max(0,parseInt(F,10)||0)*1000:iOA(X);await H.text(),X++,await nOA(q,B.signal);continue}return await B.processResponse(H)}})();if(!this.shouldThrowOnError)Y=Y.catch((X)=>{var G;let K="",W="",H="",F=X===null||X===void 0?void 0:X.cause;if(F){var q,U,I,z;let E=(q=F===null||F===void 0?void 0:F.message)!==null&&q!==void 0?q:"",M=(U=F===null||F===void 0?void 0:F.code)!==null&&U!==void 0?U:"";if(K=`${(I=X===null||X===void 0?void 0:X.name)!==null&&I!==void 0?I:"FetchError"}: ${X===null||X===void 0?void 0:X.message}`,K+=`
|
|
96
96
|
|
|
97
97
|
Caused by: ${(z=F===null||F===void 0?void 0:F.name)!==null&&z!==void 0?z:"Error"}: ${E}`,M)K+=` (${M})`;if(F===null||F===void 0?void 0:F.stack)K+=`
|
|
@@ -937,14 +937,14 @@ https://www.w3ctech.com/topic/2226`)}let b=R(...p);return b.postcssPlugin=L,b.po
|
|
|
937
937
|
<p>Capgo needs every permission it asks for in order to set up Play Store publishing. The following requested permissions were not approved on the consent screen:</p>
|
|
938
938
|
<ul>${A.map((B)=>`<li><code>${EdA(B)}</code></li>`).join("")}</ul>
|
|
939
939
|
<p>Head back to your terminal — the CLI will offer to retry sign-in. When the consent screen appears again, please make sure every requested permission is checked before approving.</p>
|
|
940
|
-
</body></html>`}class IR extends Error{missing;granted;constructor(A,Q){super(`User did not grant all required OAuth scopes. Missing: ${A.join(", ")}`);this.name="MissingScopesError",this.missing=A,this.granted=Q}}function hcQ(A,Q){let B=new Set(A.split(/\s+/).filter(($)=>$.length>0));return Q.filter(($)=>!B.has($))}function ucQ(A){return new Promise((Q,B)=>{let $,J,Y=new Promise((H,F)=>{$=H,J=F}),X=jcQ((H,F)=>{try{if(!H.url||!H.url.startsWith(NdA)){F.statusCode=404,F.end("not found");return}let q=new URL(H.url,`http://${vGA}`),U=q.searchParams.get("error"),I=q.searchParams.get("code"),z=q.searchParams.get("state");if(U){let E=q.searchParams.get("error_description")||U;F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma(E)),J(Error(`Google returned an auth error: ${E}`));return}if(!I||!z){F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma("Missing code or state in redirect")),J(Error("Google redirect was missing the authorization code or state parameter"));return}if(z!==A.expectedState){F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma("State mismatch — possible CSRF attempt")),J(Error("OAuth state parameter did not match — aborting"));return}let O=!1;$({code:I,finishResponse:(E,M=200)=>{if(O)return;O=!0;try{F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=M,F.end(E)}catch{}}})}catch(q){F.statusCode=500,F.end("internal error"),J(q instanceof Error?q:Error(String(q)))}}),G=setTimeout(()=>{J(Error(`Timed out after ${Math.round(A.timeoutMs/1000)}s waiting for browser sign-in`))},A.timeoutMs);function K(){let H=Error("OAuth flow aborted");J(H),B(H)}if(A.signal){if(A.signal.aborted){K();return}A.signal.addEventListener("abort",K,{once:!0})}function W(){if(clearTimeout(G),A.signal)A.signal.removeEventListener("abort",K);X.close()}Y.then(W,W),X.on("error",(H)=>{W(),B(H),J(H)}),X.listen(0,vGA,()=>{let H=X.address();if(!H){W(),B(Error("Failed to read loopback server port after bind"));return}let F=`http://${vGA}:${H.port}${NdA}`;Q({port:H.port,redirectUri:F,code:Y,close:W})})})}async function hGA(A,Q={}){if(!A.clientId)throw Error("Google OAuth clientId is required");if(!A.scopes.length)throw Error("At least one OAuth scope is required");let B=ScQ(),$=xcQ(),J=Q.timeoutMs??kcQ,Y=await ucQ({expectedState:$,timeoutMs:J,signal:Q.signal}),X=bcQ({clientId:A.clientId,redirectUri:Y.redirectUri,scopes:A.scopes,state:$,codeChallenge:B.challenge,extra:A.extraAuthParams});Q.onAuthUrl?.(X),Q.onStatus?.("Opening browser for Google sign-in...");try{await q9(X)}catch(K){gB(`google sign-in: could not auto-open browser: ${K instanceof Error?K.message:String(K)}`),Q.onStatus?.("Could not open browser automatically — open the URL above manually.")}let G=(async()=>{try{let{code:K,finishResponse:W}=await Y.code;Q.onStatus?.("Exchanging code for tokens...");let H;try{H=await vcQ({config:A,code:K,codeVerifier:B.verifier,redirectUri:Y.redirectUri})}catch(q){throw W(ma(q instanceof Error?q.message:String(q)),500),q}let F=hcQ(H.scope,A.scopes);if(F.length>0)throw W(ycQ(F),400),new IR(F,H.scope);return W(gcQ()),H}finally{Y.close()}})();return{authUrl:X,redirectUri:Y.redirectUri,result:G,close:Y.close}}async function da(A,Q={}){let B=await hGA(A,Q);return Q.onStatus?.("Waiting for browser redirect..."),await B.result}var NnA=iA(WKA(),1);var UY=iA(FWA(),1);function hr(){let A=UY.default.pki.rsa.generateKeyPair(2048),Q=UY.default.pki.createCertificationRequest();return Q.publicKey=A.publicKey,Q.setSubject([{name:"commonName",value:"Capgo Build"},{name:"organizationName",value:"Capgo"}]),Q.sign(A.privateKey),{csrPem:UY.default.pki.certificationRequestToPem(Q),privateKeyPem:UY.default.pki.privateKeyToPem(A.privateKey)}}function qWA(A){try{let Q=UY.default.util.decode64(A),B=UY.default.asn1.fromDer(Q);return UY.default.pki.certificateFromAsn1(B).subject.getField("OU")?.value||""}catch{return""}}var Fv="capgo";function ur(A,Q,B=Fv){let $=UY.default.util.decode64(A),J=UY.default.asn1.fromDer($),Y=UY.default.pki.certificateFromAsn1(J),X=UY.default.pki.privateKeyFromPem(Q),G=UY.default.pkcs12.toPkcs12Asn1(X,[Y],B,{algorithm:"3des"}),K=UY.default.asn1.toDer(G).getBytes();return{p12Base64:UY.default.util.encode64(K)}}var qv="https://api.appstoreconnect.apple.com/v1";function mr(A,Q,B){let $=Math.floor(Date.now()/1000);return NnA.default.sign({iss:Q,exp:$+1199,aud:"appstoreconnect-v1"},B,{algorithm:"ES256",header:{alg:"ES256",kid:A,typ:"JWT"}})}class Uv extends Error{status;code;constructor(A,Q,B){super(Q);this.name="AppleApiHttpError",this.status=A,this.code=B}}async function VK(A,Q,B={}){let $=`${qv}${A}`,J=await fetch($,{...B,headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/json",...B.headers}}),Y=await J.json().catch(()=>null);if(!J.ok){let G=(Y?.errors||[])[0];if(gB(`apple-api ${B.method??"GET"} ${A}: HTTP ${J.status} ${J.statusText} ${JSON.stringify(Y?.errors??Y??null)} | ${V3(J.headers)}`),G)throw new Uv(J.status,`Apple API error (${J.status}): ${G.title} — ${G.detail} (${G.code})`,G.code);throw new Uv(J.status,`Apple API error: HTTP ${J.status} ${J.statusText}`)}return gB(`apple-api ${B.method??"GET"} ${A}: HTTP ${J.status} | ${V3(J.headers)}`),Y}async function cr(A){try{let Q=await VK("/certificates?limit=1",A),B="";if(Q.data?.length>0&&Q.data[0].attributes?.certificateContent)B=qWA(Q.data[0].attributes.certificateContent);return{valid:!0,teamId:B}}catch(Q){let B=typeof Q?.status==="number"?Q.status:void 0,$=typeof Q?.code==="string"?Q.code:void 0,J=B===401||Q.message?.includes("401"),Y=B===403||Q.message?.includes("403");if(Y&&($==="FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"
|
|
940
|
+
</body></html>`}class IR extends Error{missing;granted;constructor(A,Q){super(`User did not grant all required OAuth scopes. Missing: ${A.join(", ")}`);this.name="MissingScopesError",this.missing=A,this.granted=Q}}function hcQ(A,Q){let B=new Set(A.split(/\s+/).filter(($)=>$.length>0));return Q.filter(($)=>!B.has($))}function ucQ(A){return new Promise((Q,B)=>{let $,J,Y=new Promise((H,F)=>{$=H,J=F}),X=jcQ((H,F)=>{try{if(!H.url||!H.url.startsWith(NdA)){F.statusCode=404,F.end("not found");return}let q=new URL(H.url,`http://${vGA}`),U=q.searchParams.get("error"),I=q.searchParams.get("code"),z=q.searchParams.get("state");if(U){let E=q.searchParams.get("error_description")||U;F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma(E)),J(Error(`Google returned an auth error: ${E}`));return}if(!I||!z){F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma("Missing code or state in redirect")),J(Error("Google redirect was missing the authorization code or state parameter"));return}if(z!==A.expectedState){F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=400,F.end(ma("State mismatch — possible CSRF attempt")),J(Error("OAuth state parameter did not match — aborting"));return}let O=!1;$({code:I,finishResponse:(E,M=200)=>{if(O)return;O=!0;try{F.setHeader("Content-Type","text/html; charset=utf-8"),F.statusCode=M,F.end(E)}catch{}}})}catch(q){F.statusCode=500,F.end("internal error"),J(q instanceof Error?q:Error(String(q)))}}),G=setTimeout(()=>{J(Error(`Timed out after ${Math.round(A.timeoutMs/1000)}s waiting for browser sign-in`))},A.timeoutMs);function K(){let H=Error("OAuth flow aborted");J(H),B(H)}if(A.signal){if(A.signal.aborted){K();return}A.signal.addEventListener("abort",K,{once:!0})}function W(){if(clearTimeout(G),A.signal)A.signal.removeEventListener("abort",K);X.close()}Y.then(W,W),X.on("error",(H)=>{W(),B(H),J(H)}),X.listen(0,vGA,()=>{let H=X.address();if(!H){W(),B(Error("Failed to read loopback server port after bind"));return}let F=`http://${vGA}:${H.port}${NdA}`;Q({port:H.port,redirectUri:F,code:Y,close:W})})})}async function hGA(A,Q={}){if(!A.clientId)throw Error("Google OAuth clientId is required");if(!A.scopes.length)throw Error("At least one OAuth scope is required");let B=ScQ(),$=xcQ(),J=Q.timeoutMs??kcQ,Y=await ucQ({expectedState:$,timeoutMs:J,signal:Q.signal}),X=bcQ({clientId:A.clientId,redirectUri:Y.redirectUri,scopes:A.scopes,state:$,codeChallenge:B.challenge,extra:A.extraAuthParams});Q.onAuthUrl?.(X),Q.onStatus?.("Opening browser for Google sign-in...");try{await q9(X)}catch(K){gB(`google sign-in: could not auto-open browser: ${K instanceof Error?K.message:String(K)}`),Q.onStatus?.("Could not open browser automatically — open the URL above manually.")}let G=(async()=>{try{let{code:K,finishResponse:W}=await Y.code;Q.onStatus?.("Exchanging code for tokens...");let H;try{H=await vcQ({config:A,code:K,codeVerifier:B.verifier,redirectUri:Y.redirectUri})}catch(q){throw W(ma(q instanceof Error?q.message:String(q)),500),q}let F=hcQ(H.scope,A.scopes);if(F.length>0)throw W(ycQ(F),400),new IR(F,H.scope);return W(gcQ()),H}finally{Y.close()}})();return{authUrl:X,redirectUri:Y.redirectUri,result:G,close:Y.close}}async function da(A,Q={}){let B=await hGA(A,Q);return Q.onStatus?.("Waiting for browser redirect..."),await B.result}var NnA=iA(WKA(),1);var UY=iA(FWA(),1);function hr(){let A=UY.default.pki.rsa.generateKeyPair(2048),Q=UY.default.pki.createCertificationRequest();return Q.publicKey=A.publicKey,Q.setSubject([{name:"commonName",value:"Capgo Build"},{name:"organizationName",value:"Capgo"}]),Q.sign(A.privateKey),{csrPem:UY.default.pki.certificationRequestToPem(Q),privateKeyPem:UY.default.pki.privateKeyToPem(A.privateKey)}}function qWA(A){try{let Q=UY.default.util.decode64(A),B=UY.default.asn1.fromDer(Q);return UY.default.pki.certificateFromAsn1(B).subject.getField("OU")?.value||""}catch{return""}}var Fv="capgo";function ur(A,Q,B=Fv){let $=UY.default.util.decode64(A),J=UY.default.asn1.fromDer($),Y=UY.default.pki.certificateFromAsn1(J),X=UY.default.pki.privateKeyFromPem(Q),G=UY.default.pkcs12.toPkcs12Asn1(X,[Y],B,{algorithm:"3des"}),K=UY.default.asn1.toDer(G).getBytes();return{p12Base64:UY.default.util.encode64(K)}}var qv="https://api.appstoreconnect.apple.com/v1";function mr(A,Q,B){let $=Math.floor(Date.now()/1000);return NnA.default.sign({iss:Q,exp:$+1199,aud:"appstoreconnect-v1"},B,{algorithm:"ES256",header:{alg:"ES256",kid:A,typ:"JWT"}})}class Uv extends Error{status;code;constructor(A,Q,B){super(Q);this.name="AppleApiHttpError",this.status=A,this.code=B}}async function VK(A,Q,B={}){let $=`${qv}${A}`,J=await fetch($,{...B,headers:{Authorization:`Bearer ${Q}`,"Content-Type":"application/json",...B.headers}}),Y=await J.json().catch(()=>null);if(!J.ok){let G=(Y?.errors||[])[0];if(gB(`apple-api ${B.method??"GET"} ${A}: HTTP ${J.status} ${J.statusText} ${JSON.stringify(Y?.errors??Y??null)} | ${V3(J.headers)}`),G)throw new Uv(J.status,`Apple API error (${J.status}): ${G.title} — ${G.detail} (${G.code})`,G.code);throw new Uv(J.status,`Apple API error: HTTP ${J.status} ${J.statusText}`)}return gB(`apple-api ${B.method??"GET"} ${A}: HTTP ${J.status} | ${V3(J.headers)}`),Y}async function cr(A){try{let Q=await VK("/certificates?limit=1",A),B="";if(Q.data?.length>0&&Q.data[0].attributes?.certificateContent)B=qWA(Q.data[0].attributes.certificateContent);return{valid:!0,teamId:B}}catch(Q){let B=typeof Q?.status==="number"?Q.status:void 0,$=typeof Q?.code==="string"?Q.code:void 0,J=B===401||Q.message?.includes("401"),Y=B===403||Q.message?.includes("403");if(Y&&($==="FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"||$==="FORBIDDEN_ERROR.PLA_NOT_ACCEPTED"||/\bPLA_NOT_ACCEPTED\b|required agreement|program license agreement/i.test(Q.message??"")))throw new Uv(403,`Apple is blocking App Store Connect API access because your developer account has a required agreement that is unsigned or has expired.
|
|
941
941
|
- Sign in as the Account Holder at https://appstoreconnect.apple.com
|
|
942
942
|
- Open "Business" (Agreements, Tax, and Banking) and accept the pending or updated agreement
|
|
943
943
|
`+" - Then run this step again — your API key is valid, so no key changes are needed",$);if(J||Y)throw new Uv(B??(Y?403:401),`API key verification failed. Please check:
|
|
944
944
|
- The .p8 file is correct and hasn't been modified
|
|
945
945
|
- The Key ID matches the key shown in App Store Connect
|
|
946
946
|
- The Issuer ID is correct (shown at the top of the API keys page)
|
|
947
|
-
- The key has "Admin" or "Developer" access`,$);throw Q}}function dr(A){if(A.localExpirationDate){let Q=Date.parse(A.localExpirationDate);if(!Number.isNaN(Q)&&Q<Date.now())return{available:!1,reason:"expired",reasonText:`Expired (${A.localExpirationDate.split("T")[0]})`}}if(A.isManaged)return{available:!1,reason:"managed",reasonText:"Apple-managed — can't sign locally"};if(A.lookupError)return{available:!1,reason:"check-failed",reasonText:`Lookup failed: ${A.lookupError instanceof Error?A.lookupError.message:String(A.lookupError)}`};if(A.appleCertId)return{available:!0,appleCertId:A.appleCertId};return{available:!1,reason:"not-visible",reasonText:"Not visible to current API key (revoked, different team, or lookup limitation)"}}async function uU(A,Q={}){let B=(Q.types??["DISTRIBUTION","IOS_DISTRIBUTION"]).join(",");return((await VK(`/certificates?filter[certificateType]=${B}&limit=200`,A)).data||[]).map((J)=>({id:J.id,name:J.attributes.name||J.attributes.displayName||"iOS Distribution",serialNumber:J.attributes.serialNumber||"",expirationDate:J.attributes.expirationDate,...Q.includeContent&&J.attributes.certificateContent?{certificateContent:J.attributes.certificateContent}:{}}))}function Iv(A){let{Buffer:Q}=XQ("node:buffer"),{createHash:B}=XQ("node:crypto"),$=Q.from(A,"base64");return B("sha1").update($).digest("hex").toLowerCase()}async function lr(A,Q){let B=await uaQ(A,Q);return B?B.id:null}async function uaQ(A,Q){let B=Q.toLowerCase(),$=await uU(A,{includeContent:!0});for(let J of $){if(!J.certificateContent)continue;if(Iv(J.certificateContent)===B)return J}return null}async function pr(A,Q){let B=[],$=[],J="/profiles?include=certificates,bundleId&limit=200";while(J){let G=await VK(J,A);if(Array.isArray(G.data))B.push(...G.data);if(Array.isArray(G.included))$.push(...G.included);let K=G.links?.next;J=K?K.startsWith(qv)?K.slice(qv.length):K:""}let Y=new Map;for(let G of $)if(G.type==="bundleIds"&&G.attributes?.identifier)Y.set(G.id,G.attributes.identifier);return B.filter((G)=>{return(G.relationships?.certificates?.data??[]).some((W)=>W.id===Q)}).map((G)=>{let K=G.relationships?.bundleId?.data?.id;return{id:G.id,name:G.attributes.name||"",profileType:G.attributes.profileType||"",profileContent:G.attributes.profileContent||"",expirationDate:G.attributes.expirationDate||"",bundleIdentifier:K?Y.get(K)||"":""}})}async function ir(A,Q){await VK(`/certificates/${Q}`,A,{method:"DELETE"})}class gR extends Error{certificates;constructor(A){super(`Certificate limit reached. Found ${A.length} existing Apple Distribution certificate(s).`);this.certificates=A;this.name="CertificateLimitError"}}async function nr(A,Q){try{let $=(await VK("/certificates",A,{method:"POST",body:JSON.stringify({data:{type:"certificates",attributes:{certificateType:"DISTRIBUTION",csrContent:Q}}})})).data,J=qWA($.attributes.certificateContent);return{certificateId:$.id,certificateContent:$.attributes.certificateContent,expirationDate:$.attributes.expirationDate,teamId:J}}catch(B){if(B.message?.includes("ENTITY_ERROR.ATTRIBUTE.INVALID")||B.message?.includes("There is a problem with the request entity")||B.message?.includes("maximum number of certificates")){let $;try{$=await uU(A,{types:["DISTRIBUTION"]})}catch{throw B}if($.length>0)throw new gR($)}throw B}}async function LF(A,Q){let B=await VK(`/bundleIds?filter[identifier]=${encodeURIComponent(Q)}&limit=1`,A);if(B.data?.length>0)return{bundleIdResourceId:B.data[0].id};let $=Q.replace(/[^a-zA-Z0-9]+/g," ").trim();return{bundleIdResourceId:(await VK("/bundleIds",A,{method:"POST",body:JSON.stringify({data:{type:"bundleIds",attributes:{identifier:Q,name:`Capgo ${$}`,platform:"IOS"}}})})).data.id}}function maQ(A){return(A?.data||[]).map((Q)=>({id:Q?.id||"",bundleId:Q?.attributes?.bundleId||"",name:Q?.attributes?.name||""}))}function caQ(A){return(A?.data||[]).map((Q)=>Q?.attributes?.identifier||"").filter((Q)=>Boolean(Q))}var LnA=10;function VnA(A){if(!A)return null;return A.startsWith(qv)?A.slice(qv.length):A}async function zv(A){let Q=[],B="/apps?limit=200";for(let $=0;$<LnA&&B;$++){let J=await VK(B,A);Q.push(...maQ(J)),B=VnA(J?.links?.next)}return Q}async function Cv(A){let Q=[],B="/bundleIds?limit=200";for(let $=0;$<LnA&&B;$++){let J=await VK(B,A);Q.push(...caQ(J)),B=VnA(J?.links?.next)}return Q}function EnA(A){return`Capgo ${A} AppStore`}async function daQ(A,Q){let B=EnA(Q);return((await VK(`/profiles?filter[name]=${encodeURIComponent(B)}&limit=10`,A)).data||[]).map((J)=>({id:J.id,name:J.attributes.name,profileType:J.attributes.profileType}))}async function or(A,Q){await VK(`/profiles/${Q}`,A,{method:"DELETE"})}class Ov extends Error{profiles;constructor(A){super(`Duplicate profiles found: ${A.map((Q)=>Q.name).join(", ")}`);this.profiles=A;this.name="DuplicateProfileError"}}async function Mv(A,Q,B,$){let J=EnA($);try{let Y=await VK("/profiles",A,{method:"POST",body:JSON.stringify({data:{type:"profiles",attributes:{name:J,profileType:"IOS_APP_STORE"},relationships:{bundleId:{data:{type:"bundleIds",id:Q}},certificates:{data:[{type:"certificates",id:B}]}}}})});return{profileId:Y.data.id,profileName:Y.data.attributes.name,profileContent:Y.data.attributes.profileContent,expirationDate:Y.data.attributes.expirationDate}}catch(Y){if(Y.message?.includes("Multiple profiles found")||Y.message?.includes("duplicate")){let X;try{X=await daQ(A,$)}catch{throw Y}if(X.length>0)throw new Ov(X)}throw Y}}function laQ(A){if(!A||typeof A!=="object")return;let Q=A.status;return typeof Q==="number"?Q:void 0}function paQ(A){if(!A||typeof A!=="object")return;let Q=A.code;return typeof Q==="string"?Q:void 0}function RnA(A){if(!A||typeof A!=="object")return;let Q=A.phase;return typeof Q==="string"?Q:void 0}function ar(A,Q){if(A instanceof gR)return"cert_limit_reached";let B=laQ(A),$=paQ(A),J=A instanceof Error?A.message:"";if($==="FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"||/required agreement[^.]{0,60}\b(unsigned|expired|missing|not been signed)\b/i.test(J))return"apple_agreements_missing";if(B===401)return"apple_api_unauthorized";if(B===403)return"apple_api_forbidden";if(B===429)return"apple_api_rate_limited";let X=RnA(A);if(X==="profile")return"profile_creation_failed";if(X==="p8")return"p8_invalid";if(Q==="import-scanning")return"keychain_no_identities";if(Q==="import-exporting")return"keychain_export_failed";if(Q==="import-provide-profile-path")return"profile_read_failed";if(Q==="import-pick-profile"||Q==="import-no-match-recovery")return"profile_no_match";return"unknown"}function rr(A){if(A instanceof IR)return"google_oauth_failed";let Q=RnA(A);if(Q==="keystore")return"keystore_invalid";if(Q==="oauth")return"google_oauth_failed";if(Q==="play_account_id")return"play_account_id_invalid";return"unknown"}function jnA(A){switch(A){case"shape-error":return"sa_json_shape_invalid";case"token-error":return"sa_json_token_rejected";case"no-app-access":return"sa_json_no_app_access";case"network-error":return"sa_json_network_error"}}function UWA(A,Q){let B=Q||ha();if(B)A.$session_id=B}async function yR(A){let Q={journey_id:A.journeyId,step:A.step,platform:A.platform,app_id:A.appId};if(typeof A.durationMs==="number"&&Number.isFinite(A.durationMs)){if(Q.duration_ms=String(Math.round(A.durationMs)),A.durationStep)Q.duration_step=A.durationStep}if(A.errorCategory!==void 0)Q.error_category=A.errorCategory;else if(A.error!==void 0)Q.error_category=A.platform==="ios"?ar(A.error):rr(A.error);UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Step",channel:"builder-onboarding",icon:"\uD83E\uDDED",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q})}catch{}}async function hR(A){let Q={};for(let[B,$]of Object.entries(A.tags??{}))Q[B]=String($);Q.journey_id=A.journeyId,Q.step=A.step,Q.platform=A.platform,Q.app_id=A.appId,Q.action=A.action,UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Action",channel:"builder-onboarding",icon:"\uD83E\uDDED",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q})}catch{}}async function wnA(A){let Q={journey_id:A.journeyId,app_id:A.appId};if(A.platform)Q.platform=A.platform;if(A.lastStep)Q.last_step=A.lastStep;if(typeof A.durationMs==="number"&&Number.isFinite(A.durationMs))Q.duration_ms=String(Math.round(A.durationMs));UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Quit",channel:"builder-onboarding",icon:"\uD83D\uDEAA",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q},void 0,A.signal)}catch{}}O4();import{spawn as CrQ}from"node:child_process";import{existsSync as CWA}from"node:fs";import{createRequire as OrQ}from"node:module";import{homedir as MrQ,release as NrQ}from"node:os";import{dirname as ynA,join as VF}from"node:path";import Rv,{platform as LrQ}from"node:process";import{fileURLToPath as VrQ}from"node:url";import{spawn as PnA}from"node:child_process";import{randomBytes as iaQ}from"node:crypto";import{accessSync as naQ,constants as oaQ}from"node:fs";import{mkdtemp as aaQ,readdir as raQ,readFile as saQ,rm as taQ}from"node:fs/promises";import{createRequire as _nA}from"node:module";import{tmpdir as eaQ}from"node:os";import{dirname as ArQ,join as mO}from"node:path";import Nv from"node:process";var QrQ="/usr/bin/security",BrQ=["Library/Developer/Xcode/UserData/Provisioning Profiles","Library/MobileDevice/Provisioning Profiles"];class FX extends Error{cause;constructor(A,Q){super(A);this.cause=Q;this.name="MacOSSigningError"}}class sr extends FX{constructor(){super("Importing existing iOS credentials is only supported on macOS.");this.name="NotMacOSError"}}function mU(){return Nv.platform==="darwin"}var $rQ=(A)=>{return new Promise((Q)=>{let B=PnA(QrQ,[...A],{stdio:["ignore","pipe","pipe"]}),$="",J="";B.stdout.on("data",(Y)=>{$+=Y.toString("utf-8")}),B.stderr.on("data",(Y)=>{J+=Y.toString("utf-8")}),B.once("error",(Y)=>{Q({stdout:$,stderr:J+(Y instanceof Error?Y.message:String(Y)),code:null})}),B.once("close",(Y)=>{Q({stdout:$,stderr:J,code:Y})})})},JrQ=/^\s*\d+\)\s+([A-F0-9]{40})\s+"([^"]+)"\s*$/,YrQ=/\(([A-Z0-9]{10})\)\s*$/;function XrQ(A){let Q=[];for(let B of A.split(`
|
|
947
|
+
- The key has "Admin" or "Developer" access`,$);throw Q}}function dr(A){if(A.localExpirationDate){let Q=Date.parse(A.localExpirationDate);if(!Number.isNaN(Q)&&Q<Date.now())return{available:!1,reason:"expired",reasonText:`Expired (${A.localExpirationDate.split("T")[0]})`}}if(A.isManaged)return{available:!1,reason:"managed",reasonText:"Apple-managed — can't sign locally"};if(A.lookupError)return{available:!1,reason:"check-failed",reasonText:`Lookup failed: ${A.lookupError instanceof Error?A.lookupError.message:String(A.lookupError)}`};if(A.appleCertId)return{available:!0,appleCertId:A.appleCertId};return{available:!1,reason:"not-visible",reasonText:"Not visible to current API key (revoked, different team, or lookup limitation)"}}async function uU(A,Q={}){let B=(Q.types??["DISTRIBUTION","IOS_DISTRIBUTION"]).join(",");return((await VK(`/certificates?filter[certificateType]=${B}&limit=200`,A)).data||[]).map((J)=>({id:J.id,name:J.attributes.name||J.attributes.displayName||"iOS Distribution",serialNumber:J.attributes.serialNumber||"",expirationDate:J.attributes.expirationDate,...Q.includeContent&&J.attributes.certificateContent?{certificateContent:J.attributes.certificateContent}:{}}))}function Iv(A){let{Buffer:Q}=XQ("node:buffer"),{createHash:B}=XQ("node:crypto"),$=Q.from(A,"base64");return B("sha1").update($).digest("hex").toLowerCase()}async function lr(A,Q){let B=await uaQ(A,Q);return B?B.id:null}async function uaQ(A,Q){let B=Q.toLowerCase(),$=await uU(A,{includeContent:!0});for(let J of $){if(!J.certificateContent)continue;if(Iv(J.certificateContent)===B)return J}return null}async function pr(A,Q){let B=[],$=[],J="/profiles?include=certificates,bundleId&limit=200";while(J){let G=await VK(J,A);if(Array.isArray(G.data))B.push(...G.data);if(Array.isArray(G.included))$.push(...G.included);let K=G.links?.next;J=K?K.startsWith(qv)?K.slice(qv.length):K:""}let Y=new Map;for(let G of $)if(G.type==="bundleIds"&&G.attributes?.identifier)Y.set(G.id,G.attributes.identifier);return B.filter((G)=>{return(G.relationships?.certificates?.data??[]).some((W)=>W.id===Q)}).map((G)=>{let K=G.relationships?.bundleId?.data?.id;return{id:G.id,name:G.attributes.name||"",profileType:G.attributes.profileType||"",profileContent:G.attributes.profileContent||"",expirationDate:G.attributes.expirationDate||"",bundleIdentifier:K?Y.get(K)||"":""}})}async function ir(A,Q){await VK(`/certificates/${Q}`,A,{method:"DELETE"})}class gR extends Error{certificates;constructor(A){super(`Certificate limit reached. Found ${A.length} existing Apple Distribution certificate(s).`);this.certificates=A;this.name="CertificateLimitError"}}async function nr(A,Q){try{let $=(await VK("/certificates",A,{method:"POST",body:JSON.stringify({data:{type:"certificates",attributes:{certificateType:"DISTRIBUTION",csrContent:Q}}})})).data,J=qWA($.attributes.certificateContent);return{certificateId:$.id,certificateContent:$.attributes.certificateContent,expirationDate:$.attributes.expirationDate,teamId:J}}catch(B){if(B.message?.includes("ENTITY_ERROR.ATTRIBUTE.INVALID")||B.message?.includes("There is a problem with the request entity")||B.message?.includes("maximum number of certificates")){let $;try{$=await uU(A,{types:["DISTRIBUTION"]})}catch{throw B}if($.length>0)throw new gR($)}throw B}}async function LF(A,Q){let B=await VK(`/bundleIds?filter[identifier]=${encodeURIComponent(Q)}&limit=1`,A);if(B.data?.length>0)return{bundleIdResourceId:B.data[0].id};let $=Q.replace(/[^a-zA-Z0-9]+/g," ").trim();return{bundleIdResourceId:(await VK("/bundleIds",A,{method:"POST",body:JSON.stringify({data:{type:"bundleIds",attributes:{identifier:Q,name:`Capgo ${$}`,platform:"IOS"}}})})).data.id}}function maQ(A){return(A?.data||[]).map((Q)=>({id:Q?.id||"",bundleId:Q?.attributes?.bundleId||"",name:Q?.attributes?.name||""}))}function caQ(A){return(A?.data||[]).map((Q)=>Q?.attributes?.identifier||"").filter((Q)=>Boolean(Q))}var LnA=10;function VnA(A){if(!A)return null;return A.startsWith(qv)?A.slice(qv.length):A}async function zv(A){let Q=[],B="/apps?limit=200";for(let $=0;$<LnA&&B;$++){let J=await VK(B,A);Q.push(...maQ(J)),B=VnA(J?.links?.next)}return Q}async function Cv(A){let Q=[],B="/bundleIds?limit=200";for(let $=0;$<LnA&&B;$++){let J=await VK(B,A);Q.push(...caQ(J)),B=VnA(J?.links?.next)}return Q}function EnA(A){return`Capgo ${A} AppStore`}async function daQ(A,Q){let B=EnA(Q);return((await VK(`/profiles?filter[name]=${encodeURIComponent(B)}&limit=10`,A)).data||[]).map((J)=>({id:J.id,name:J.attributes.name,profileType:J.attributes.profileType}))}async function or(A,Q){await VK(`/profiles/${Q}`,A,{method:"DELETE"})}class Ov extends Error{profiles;constructor(A){super(`Duplicate profiles found: ${A.map((Q)=>Q.name).join(", ")}`);this.profiles=A;this.name="DuplicateProfileError"}}async function Mv(A,Q,B,$){let J=EnA($);try{let Y=await VK("/profiles",A,{method:"POST",body:JSON.stringify({data:{type:"profiles",attributes:{name:J,profileType:"IOS_APP_STORE"},relationships:{bundleId:{data:{type:"bundleIds",id:Q}},certificates:{data:[{type:"certificates",id:B}]}}}})});return{profileId:Y.data.id,profileName:Y.data.attributes.name,profileContent:Y.data.attributes.profileContent,expirationDate:Y.data.attributes.expirationDate}}catch(Y){if(Y.message?.includes("Multiple profiles found")||Y.message?.includes("duplicate")){let X;try{X=await daQ(A,$)}catch{throw Y}if(X.length>0)throw new Ov(X)}throw Y}}function laQ(A){if(!A||typeof A!=="object")return;let Q=A.status;return typeof Q==="number"?Q:void 0}function paQ(A){if(!A||typeof A!=="object")return;let Q=A.code;return typeof Q==="string"?Q:void 0}function RnA(A){if(!A||typeof A!=="object")return;let Q=A.phase;return typeof Q==="string"?Q:void 0}function ar(A,Q){if(A instanceof gR)return"cert_limit_reached";let B=laQ(A),$=paQ(A),J=A instanceof Error?A.message:"";if($==="FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"||$==="FORBIDDEN_ERROR.PLA_NOT_ACCEPTED"||/required agreement[^.]{0,60}\b(unsigned|expired|missing|not been signed)\b/i.test(J)||/\b(unsigned|expired)\b[^.]{0,40}\bagreement\b/i.test(J)||/program license agreement/i.test(J))return"apple_agreements_missing";if(B===401)return"apple_api_unauthorized";if(B===403)return"apple_api_forbidden";if(B===429)return"apple_api_rate_limited";let X=RnA(A);if(X==="profile")return"profile_creation_failed";if(X==="p8")return"p8_invalid";if(Q==="import-scanning")return"keychain_no_identities";if(Q==="import-exporting")return"keychain_export_failed";if(Q==="import-provide-profile-path")return"profile_read_failed";if(Q==="import-pick-profile"||Q==="import-no-match-recovery")return"profile_no_match";return"unknown"}function rr(A){if(A instanceof IR)return"google_oauth_failed";let Q=RnA(A);if(Q==="keystore")return"keystore_invalid";if(Q==="oauth")return"google_oauth_failed";if(Q==="play_account_id")return"play_account_id_invalid";return"unknown"}function jnA(A){switch(A){case"shape-error":return"sa_json_shape_invalid";case"token-error":return"sa_json_token_rejected";case"no-app-access":return"sa_json_no_app_access";case"network-error":return"sa_json_network_error"}}function UWA(A,Q){let B=Q||ha();if(B)A.$session_id=B}async function yR(A){let Q={journey_id:A.journeyId,step:A.step,platform:A.platform,app_id:A.appId};if(typeof A.durationMs==="number"&&Number.isFinite(A.durationMs)){if(Q.duration_ms=String(Math.round(A.durationMs)),A.durationStep)Q.duration_step=A.durationStep}if(A.errorCategory!==void 0)Q.error_category=A.errorCategory;else if(A.error!==void 0)Q.error_category=A.platform==="ios"?ar(A.error):rr(A.error);UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Step",channel:"builder-onboarding",icon:"\uD83E\uDDED",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q})}catch{}}async function hR(A){let Q={};for(let[B,$]of Object.entries(A.tags??{}))Q[B]=String($);Q.journey_id=A.journeyId,Q.step=A.step,Q.platform=A.platform,Q.app_id=A.appId,Q.action=A.action,UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Action",channel:"builder-onboarding",icon:"\uD83E\uDDED",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q})}catch{}}async function wnA(A){let Q={journey_id:A.journeyId,app_id:A.appId};if(A.platform)Q.platform=A.platform;if(A.lastStep)Q.last_step=A.lastStep;if(typeof A.durationMs==="number"&&Number.isFinite(A.durationMs))Q.duration_ms=String(Math.round(A.durationMs));UWA(Q,A.replaySessionId);try{await qB(A.apikey,{event:"Builder Onboarding Quit",channel:"builder-onboarding",icon:"\uD83D\uDEAA",notify:!1,org_id:A.orgId,tracking_version:2,tags:Q},void 0,A.signal)}catch{}}O4();import{spawn as CrQ}from"node:child_process";import{existsSync as CWA}from"node:fs";import{createRequire as OrQ}from"node:module";import{homedir as MrQ,release as NrQ}from"node:os";import{dirname as ynA,join as VF}from"node:path";import Rv,{platform as LrQ}from"node:process";import{fileURLToPath as VrQ}from"node:url";import{spawn as PnA}from"node:child_process";import{randomBytes as iaQ}from"node:crypto";import{accessSync as naQ,constants as oaQ}from"node:fs";import{mkdtemp as aaQ,readdir as raQ,readFile as saQ,rm as taQ}from"node:fs/promises";import{createRequire as _nA}from"node:module";import{tmpdir as eaQ}from"node:os";import{dirname as ArQ,join as mO}from"node:path";import Nv from"node:process";var QrQ="/usr/bin/security",BrQ=["Library/Developer/Xcode/UserData/Provisioning Profiles","Library/MobileDevice/Provisioning Profiles"];class FX extends Error{cause;constructor(A,Q){super(A);this.cause=Q;this.name="MacOSSigningError"}}class sr extends FX{constructor(){super("Importing existing iOS credentials is only supported on macOS.");this.name="NotMacOSError"}}function mU(){return Nv.platform==="darwin"}var $rQ=(A)=>{return new Promise((Q)=>{let B=PnA(QrQ,[...A],{stdio:["ignore","pipe","pipe"]}),$="",J="";B.stdout.on("data",(Y)=>{$+=Y.toString("utf-8")}),B.stderr.on("data",(Y)=>{J+=Y.toString("utf-8")}),B.once("error",(Y)=>{Q({stdout:$,stderr:J+(Y instanceof Error?Y.message:String(Y)),code:null})}),B.once("close",(Y)=>{Q({stdout:$,stderr:J,code:Y})})})},JrQ=/^\s*\d+\)\s+([A-F0-9]{40})\s+"([^"]+)"\s*$/,YrQ=/\(([A-Z0-9]{10})\)\s*$/;function XrQ(A){let Q=[];for(let B of A.split(`
|
|
948
948
|
`)){let $=B.match(JrQ);if(!$)continue;let J=$[1].toLowerCase(),Y=$[2],X=Y.match(YrQ),G=X?X[1]:"",K=X?Y.slice(0,Y.length-X[0].length).trimEnd():Y,W=K.indexOf(":"),H=GrQ(K),F=W!==-1?K.slice(W+1).trim():"";Q.push({sha1:J,name:Y,type:H,teamName:F,teamId:G})}return Q}function GrQ(A){let Q=A.toLowerCase();if(Q.startsWith("apple distribution")||Q.startsWith("iphone distribution"))return"distribution";if(Q.startsWith("apple development")||Q.startsWith("iphone developer")||Q.startsWith("mac developer"))return"development";return"unknown"}async function tr(A=$rQ){if(!mU())throw new sr;let Q=await A(["find-identity","-v","-p","codesigning"]);if(Q.code!==0)throw new FX(`security find-identity failed (exit ${Q.code}): ${Q.stderr.trim()||Q.stdout.trim()}`);return XrQ(Q.stdout)}async function er(A){if(!mU()&&!A)throw new sr;let Q=A??Nv.env.HOME??"";if(!Q)return[];let B=new Set,$=[];for(let J of BrQ){let Y=mO(Q,J),X;try{X=await raQ(Y)}catch{continue}for(let G of X){if(!G.endsWith(".mobileprovision"))continue;let K=mO(Y,G);if(B.has(K))continue;B.add(K);try{let W=bbA(K);$.push({...W,path:K})}catch{}}}return $}function TnA(A,Q){return A.map((B)=>({identity:B,profiles:Q.filter(($)=>$.certificateSha1s.includes(B.sha1))}))}function As(A,Q){if(A===Q)return!0;if(A==="*")return!0;if(A.endsWith(".*")){let B=A.slice(0,A.length-1);return Q.startsWith(B)}return!1}function GD(A,Q,B){return A.filter(($)=>As($.bundleId,Q)&&(!B||$.profileType===B))}function KrQ(){return iaQ(32).toString("hex")}var knA="UVTJ336J2D",SnA="app.capgo.cli.helper",IWA="app.capgo.asc-key-helper",WrQ="@capgo/cli-helper-darwin-";function Lv(A){if(A==="arm64"||A==="x64")return`${WrQ}${A}`;return null}function ZrQ(A=knA,Q=SnA){return`=identifier "${Q}" and anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.13] and certificate leaf[subject.OU] = "${A}"`}var xnA=(A)=>bnA("/usr/bin/codesign",A);async function HrQ(A={}){let Q=A.arch??Nv.arch,B=Lv(Q);if(!B)throw new FX(`No precompiled Capgo keychain helper exists for ${Nv.platform}/${Q}. Supported macOS architectures: arm64, x64.`);let $=A.resolve?Array.isArray(A.resolve)?A.resolve:[A.resolve]:[_nA(import.meta.url).resolve,_nA(mO(A.cwd??Nv.cwd(),"package.json")).resolve],J;for(let G of $)try{J=G(`${B}/package.json`);break}catch{}if(!J)throw new FX(`The Capgo keychain helper package (${B}) is not installed. `+"It ships as an optional dependency of @capgo/cli — reinstall without "+`--no-optional / --omit=optional, or install it in this project: npm i ${B}`);let Y=mO(ArQ(J),"CapgoKeychainHelper.app"),X=mO(Y,"Contents","MacOS","capgo");try{naQ(X,oaQ.X_OK)}catch{throw new FX(`The keychain helper package (${B}) is installed but its CapgoKeychainHelper.app bundle is missing or not executable at ${X}. Reinstall ${B}.`)}return await DrQ(Y,B,A.codesignRunner??xnA),X}async function DrQ(A,Q,B){await Qs(A,{bundleIdentifier:SnA,label:"keychain helper",reinstallHint:`Reinstall ${Q} and try again.`,codesignRunner:B})}async function Qs(A,Q){let B=Q.codesignRunner??xnA,$=ZrQ(knA,Q.bundleIdentifier),J=await B(["--verify","--strict","-R",$,A]);if(J.code!==0){let Y=J.stderr.trim()||J.stdout.trim(),X=Q.label??"helper",G=Q.reinstallHint?` ${Q.reinstallHint}`:"";throw new FX(`Refusing to run the ${X} at ${A}: its code signature did not verify as Capgo's (codesign exit ${J.code}${Y?`: ${Y}`:""}).${G}`)}}function bnA(A,Q,B){return new Promise(($)=>{let J=B!==void 0?"pipe":"ignore",Y=PnA(A,[...Q],{stdio:[J,"pipe","pipe"]}),X="",G="";if(Y.stdout?.on("data",(K)=>{X+=K.toString("utf-8")}),Y.stderr?.on("data",(K)=>{G+=K.toString("utf-8")}),Y.once("error",(K)=>{$({stdout:X,stderr:G+(K instanceof Error?K.message:String(K)),code:null})}),Y.once("close",(K)=>{$({stdout:X,stderr:G,code:K})}),B!==void 0&&Y.stdin)Y.stdin.on("error",()=>{}),Y.stdin.end(B)})}async function Bs(A,Q={}){if(!mU())throw new sr;let B=A.toLowerCase();if(!/^[a-f0-9]{40}$/.test(B))throw new FX(`Invalid SHA1 for identity export: "${A}"`);let $=Q.helperPathOverride??await HrQ(Q.resolveOptions),J=KrQ(),Y=await aaQ(mO(eaQ(),"capgo-p12-")),X=mO(Y,"identity.p12");try{let G=await bnA($,["keychain-export","--sha1",B,"--output",X,"--invoked-by","capgo-cli"],`${J}
|
|
949
949
|
`),K=FrQ(G.stdout,G.stderr,G.code);if(K.ok!==!0){let H=K.errorCode??"INTERNAL",F=K.message??"Unknown error from keychain-export helper",q=K.osStatus!==void 0?` [OSStatus ${K.osStatus}]`:"";throw new FX(`keychain-export ${H}: ${F}${q}`)}let W=await saQ(X);if(W.length===0)throw new FX("keychain-export reported success but the exported .p12 is empty.");if(typeof K.p12SizeBytes==="number"&&K.p12SizeBytes!==W.length)throw new FX(`keychain-export size mismatch: helper reported ${K.p12SizeBytes} bytes, read ${W.length}.`);return{base64:W.toString("base64"),passphrase:J}}finally{await taQ(Y,{recursive:!0,force:!0}).catch(()=>{})}}function FrQ(A,Q,B){let $=A.trim().replace(/^\uFEFF/,"");if(!$)throw new FX(`keychain-export helper produced no JSON output (exit ${B}). Stderr: ${Q.trim()||"(empty)"}`);let J=$.split(`
|
|
950
950
|
`).filter(Boolean).pop()??"",Y;try{Y=JSON.parse(J)}catch(X){throw new FX(`keychain-export helper emitted unparsable JSON (exit ${B}): "${J}". Parse error: ${X instanceof Error?X.message:String(X)}`)}if(!Y||typeof Y!=="object")throw new FX(`keychain-export helper JSON was not an object (exit ${B}): "${J}"`);return Y}var Vv="app-store-connect-key",qrQ=["debug","info","warn","error"];function UrQ(A){return typeof A==="string"&&qrQ.includes(A)?A:"info"}function fnA(A){let Q=A.trim().replace(/^\uFEFF/,"");if(!Q||Q[0]!=="{")return null;let B;try{B=JSON.parse(Q)}catch{return null}if(!B||typeof B!=="object")return null;let $=B;if($.capgoAscKey!==1)return null;if($.kind==="event"){if(typeof $.name!=="string")return null;return{capgoAscKey:1,kind:"event",ts:typeof $.ts==="number"?$.ts:0,runId:typeof $.runId==="string"?$.runId:"",name:$.name,props:$.props&&typeof $.props==="object"&&!Array.isArray($.props)?$.props:{}}}if($.kind==="log"){if(typeof $.message!=="string")return null;return{capgoAscKey:1,kind:"log",ts:typeof $.ts==="number"?$.ts:0,runId:typeof $.runId==="string"?$.runId:"",level:UrQ($.level),message:$.message,props:$.props&&typeof $.props==="object"&&!Array.isArray($.props)?$.props:{}}}if($.kind==="result")return{capgoAscKey:1,kind:"result",ts:typeof $.ts==="number"?$.ts:0,runId:typeof $.runId==="string"?$.runId:"",ok:$.ok===!0,keyId:typeof $.keyId==="string"?$.keyId:void 0,issuerId:typeof $.issuerId==="string"?$.issuerId:void 0,privateKey:typeof $.privateKey==="string"?$.privateKey:void 0,errorCode:typeof $.errorCode==="string"?$.errorCode:void 0,message:typeof $.message==="string"?$.message:void 0};return null}class zWA{buffer="";push(A){this.buffer+=A;let Q=[],B=this.buffer.indexOf(`
|
|
@@ -1100,7 +1100,7 @@ Error: ${jA}`,confirm:async(YQ,U0)=>Yq(YQ,U0),buildFiles:async()=>{return NY("Pr
|
|
|
1100
1100
|
`)}]:[]]})},copyPath:(YQ)=>DD(YQ).ok,reveal:(YQ)=>aU(YQ),openUrl:(YQ)=>q9(YQ),print:(YQ)=>ZB(YQ,"cyan"),upload:(YQ)=>{return NY("Uploading your logs to Capgo support…"),U("support-uploading"),sU({apiHost:J??"https://api.capgo.app",apikey:L.current??$??"",appId:A,jobId:Y$??void 0,gzPath:YQ})}}),U(IA)},[A,$,Y$,p,x,f5,m$,Yq,NG,ZB]);EQ.useEffect(()=>{c$.current=I4},[I4]);let Xq=EQ.useRef(null),d5=EQ.useCallback(async()=>{if(Xq.current)return Xq.current;let IA=await cs();if(!IA)throw Error("Capgo Android onboarding is not configured server-side. Use the manual setup at https://capgo.app/docs/cli/cloud-build/android.");return Xq.current=IA,IA},[]),MJ=EQ.useCallback(async()=>{if(b8)return b8;if(!K8)throw Error("Not signed in — re-run onboarding to re-authenticate.");let IA=await d5(),jA=await VdA({clientId:IA.clientId,clientSecret:IA.clientSecret,scopes:FtA},K8);if(u6(jA.accessToken),!J$)u$(IA.clientId);return jA.accessToken},[b8,K8,J$,d5]);EQ.useEffect(()=>{let IA=!1;if(q==="welcome")setTimeout(()=>{if(IA)return;if(!ns(B10(os.cwd(),B))){U("no-platform");return}(async()=>{let jA=await h4(A);if(IA)return;if(jA?.android)U("credentials-exist");else U("keystore-method-select")})()},800);if(q==="no-platform")setTimeout(()=>{if(!IA)H()},2000);if(q!=="keystore-existing-picker")v.current=!1;if(q!=="google-sign-in-running")S.current=!1;if(q!=="gcp-setup-running")y.current=!1;if(q!=="sa-json-existing-picker")g.current=!1;if(q!=="sa-json-validating")d.current=!1;if(t.current=!1,q==="keystore-existing-picker"&&!v.current)v.current=!0,(async()=>{try{let jA=await drA();if(IA)return;if(!jA){U("keystore-existing-path");return}tA(jA),await S7((YQ)=>({...YQ,keystoreExistingPath:jA})),ZB(`✔ Keystore selected · ${jA}`),U("keystore-existing-store-password")}catch(jA){if(!IA)I4(jA,"keystore-existing-path")}})();if(q==="sa-json-existing-picker"&&!g.current)g.current=!0,(async()=>{try{let jA=await prA();if(IA)return;if(!jA){WA("manual"),U("sa-json-existing-path");return}X0(jA),await S7((YQ)=>({...YQ,serviceAccountJsonPath:jA})),ZB(`✔ Service account JSON · ${jA}`),U("sa-json-validating")}catch(jA){if(!IA)I4(jA,"sa-json-existing-path")}})();if(q==="sa-json-validating"&&!d.current){d.current=!0;let jA=new AbortController;XA.current=()=>jA.abort(),(async()=>{try{if(!j8)throw Error("No service account JSON path on record — pick the file again.");if(!S5)throw Error("No Android package on record — pick the package again.");let YQ=await BM(j8);if(IA)return;let U0=await Bj({jsonBytes:YQ,packageName:S5.packageName,signal:jA.signal});if(IA)return;if(U0.ok){let cB=YQ.toString("base64");BB({ok:!0}),u("android_sa_validation_result",{result:"success"},"sa-json-validating"),await S7((LB)=>({...LB,_serviceAccountKeyBase64:cB,serviceAccountValidationSkipped:!1})),ZB(`✔ Service account verified — ${U0.serviceAccountEmail}`),U("saving-credentials");return}if(BB(U0),gB(`service-account validation failed (${U0.kind}): ${U0.message}`),u("android_sa_validation_result",{result:"failure",validation_kind:U0.kind},"sa-json-validating"),T.current=jnA(U0.kind),U0.kind==="shape-error")ZB(`✖ ${U0.message}`,"red");U("sa-json-validation-failed")}catch(YQ){if(!IA)I4(YQ,"sa-json-existing-path")}})()}if(q!=="keystore-existing-key-password"){if(h$.current=!1,d1!==null)p8(null)}if(q==="keystore-existing-key-password"&&!h$.current)h$.current=!0,(async()=>{let jA=null,YQ=null;if(xQ)jA=xQ,YQ="progress";else if(nQ&&CA)try{let cB=await BM(CA);if(Xj(cB,nQ).ok)jA=nQ,YQ="probed-same"}catch(cB){gB(`package resolution readFile failed: ${cB instanceof Error?cB.message:String(cB)}`)}if(IA)return;if(!jA){p8("prompt");return}if(p8("auto"),YQ==="probed-same")ZB("ℹ Key password matches store password — using the same value");let U0=jA;WB(U0),ZB("✔ Key password set");try{let cB=await BM(CA);if(IA)return;let LB=cB.toString("base64"),hQ={keystorePath:CA,alias:rA||as,isGenerated:!1};await S7((ZQ)=>({...ZQ,keystoreKeyPassword:U0,_keystoreBase64:LB,serviceAccountForkSeen:!0,completedSteps:{...ZQ.completedSteps,keystoreReady:hQ}})),ZB(`✔ Keystore loaded — ${CA}`);let bQ=await iJ(A);if(IA)return;if((bQ?cO(bQ):!1)||bQ?.serviceAccountMethod!==void 0)U(bQ?E9(bQ):"service-account-method-select");else U("service-account-method-select")}catch(cB){if(!IA)I4(cB,"keystore-existing-path")}})();if(q!=="play-developer-id-input"&&bB==="input")s0("actions");if(q==="gcp-projects-loading")(async()=>{try{let jA=await MJ(),YQ=await Jj(jA);if(IA)return;A1(YQ),U("gcp-projects-select")}catch(jA){if(!IA)I4(jA,"gcp-projects-loading")}})();if(q==="preview-workflow-file")(()=>{try{if(!CZ)throw Error("Internal error: no build script choice recorded.");let jA=tW({appId:A,defaultPlatform:"android",packageManager:e1??eW(m5.pm),buildScript:CZ,secretKeys:X9.map((bQ)=>bQ.key)}),YQ=pZA(os.cwd(),J6),U0="",cB=!0;if(ns(YQ))try{U0=lZA(YQ,"utf8"),cB=!1}catch(bQ){gB(`workflow file not readable, treating as new: ${bQ instanceof Error?bQ.message:String(bQ)}`)}if(IA)return;let LB=gs(U0,jA.content),hQ=tU(LB,cB);G9(YQ),w7(cB),_7(hQ),P9(LB),MG("workflow-preview-prepared",{diff:LB,isNew:cB})}catch(jA){if(!IA)ZB(`⚠ Failed to build workflow preview: ${jA instanceof Error?jA.message:String(jA)}`,"yellow"),U("build-complete")}})();if(q==="ai-analysis-running"&&Y$)(async()=>{await RK({apikey:L.current??$??"",orgId:E??"",appId:A,platform:"android",jobId:Y$,choice:"capgo_ai",triggeredBy:"onboarding"}).catch(()=>{}),R7("");let jA="",YQ=null,U0=sR((hQ)=>{jA+=hQ,YQ??=setTimeout(()=>{if(YQ=null,!IA)R7(jA)},250)},!0),cB=await Is({apiHost:J??"https://api.capgo.app",apikey:L.current??$??"",jobId:Y$,appId:A,onChunk:(hQ)=>U0.feed(hQ)});if(U0.flush(),YQ)clearTimeout(YQ),YQ=null;if(!IA)R7(jA);if(IA)return;let LB=tR(cB);if(await eR({apikey:L.current??$??"",orgId:E??"",appId:A,platform:"android",jobId:Y$,result:LB,errorStatus:cB.kind==="error"?cB.status:void 0}).catch(()=>{}),cB.kind==="ok")Z4(nO(cB.analysis,!0)),PX(null);else if(cB.kind==="already_analyzed")Z4(null),PX({kind:"already_analyzed",message:"AI analysis was already requested for this build (only one per job)."});else if(cB.kind==="too_big")Z4(null),PX({kind:"too_big",message:"Build log is too large for Capgo AI (>10 MB). Try a local AI tool with the captured log."});else if(cB.kind==="upgrade_required")Z4(null),PX({kind:"error",message:cB.message??"AI build analysis requires a newer CLI. Please upgrade: npx @capgo/cli@latest"});else{Z4(null);let hQ=[cB.status?`(status ${cB.status})`:null,cB.message].filter(Boolean).join(" ");PX({kind:"error",message:cB.partial?`AI analysis was interrupted${hQ?`: ${hQ}`:""}. The captured log is saved for local AI.`:`AI analysis failed${hQ?`: ${hQ}`:""}.`})}U("ai-analysis-result")})();if(q==="build-complete"){if(M$([]),G?.({outcome:"completed",summary:{buildUrl:MY||void 0,ciSecretUploadSummary:jI,workflowFilePath:TI,envExportPath:jD}}),Y$)rR(Y$).catch(()=>{});return()=>{IA=!0,XA.current?.(),XA.current=null}}return()=>{IA=!0,XA.current?.(),XA.current=null}},[q]),EQ.useEffect(()=>{let IA=DtA[q];if(!(q in DtA))return;if(q==="google-sign-in-running"){if(S.current)return;S.current=!0}if(q==="gcp-setup-running"){if(y.current)return;y.current=!0}if(q==="android-package-select"){if(x5.current)return;x5.current=!0}let jA=!1,YQ=new AbortController;return(async()=>{let U0=null;if(q==="google-sign-in-running"){try{U0=await d5()}catch(LB){if(!jA)I4(LB,"google-sign-in");return}if(jA)return;u$(U0.clientId),xA([])}if(q==="gcp-setup-running")hK([]);let cB={onInternalLog:(LB)=>gB(LB),generateKeystore:ov,listKeystoreAliases:av,tryUnlockPrivateKey:Xj,validateServiceAccountJson:Bj,updateSavedCredentials:XJ,loadSavedCredentials:h4,saveAndroidProgress:EF,loadAndroidProgress:iJ,deleteAndroidProgress:mR,readFile:BM,copyFile:HtA,runOAuthFlow:(LB)=>da({clientId:U0.clientId,clientSecret:U0.clientSecret,scopes:FtA},LB),fetchUserInfo:pf,getAccessToken:MJ,revokeToken:nf,listProjects:Jj,createProject:lv,enableService:pv,ensureServiceAccount:iv,createServiceAccountKey:nv,inviteServiceAccount:async(LB)=>{await rv(LB)},findAndroidApplicationIds:()=>cv(B),onLog:(LB,hQ)=>{if(!jA)ZB(LB,hQ)},onStatus:(LB)=>{if(jA)return;if(q==="gcp-setup-running")c5(LB);else xA((hQ)=>[...hQ,LB])},onAuthUrl:(LB)=>{if(!jA)xA((hQ)=>[...hQ,`\uD83C\uDF10 If the browser didn't open: ${LB}`])},signal:YQ.signal};try{let LB=await iJ(A)??iZA(A);if(jA)return;let hQ=await sv(q,LB,cB);if(jA)return;let{transient:bQ,progress:VQ}=hQ;if(bQ?.detectedPackageIds!==void 0)E7(bQ.detectedPackageIds);if(bQ?.detectedAliases!==void 0)xB(bQ.detectedAliases);if(bQ?.accessToken!==void 0)u6(bQ.accessToken);if(q==="keystore-existing-detecting-alias"){if(VQ.keystoreAlias)Q0(VQ.keystoreAlias)}else if(q==="keystore-generating"){if(VQ.keystoreAlias)Q0(VQ.keystoreAlias);a(0)}else if(q==="google-sign-in-running"){if(VQ._oauthRefreshToken)R4(VQ._oauthRefreshToken);if(VQ.completedSteps.googleSignInComplete)J1(VQ.completedSteps.googleSignInComplete);a(0)}else if(q==="gcp-setup-running"){if(VQ.completedSteps.gcpProjectChosen)v1(VQ.completedSteps.gcpProjectChosen);if(VQ.completedSteps.serviceAccountProvisioned)O$(VQ.completedSteps.serviceAccountProvisioned);if(VQ.completedSteps.playInviteProvisioned)aJ(VQ.completedSteps.playInviteProvisioned);a(0)}if(bQ?.wrongPassword){b("Store password was rejected by the keystore. Try again."),s("keystore-existing-store-password"),U("error");return}let ZQ=hQ.next??E9(VQ);if(ZQ&&ZQ!==q)U(ZQ)}catch(LB){if(jA)return;if(IA)I4(LB,IA)}})(),()=>{jA=!0,YQ.abort()}},[q]),EQ.useEffect(()=>{if(!J10.has(q))return;let IA=!1,jA=new AbortController;return(async()=>{let YQ=()=>$??q6(),U0=await iJ(A);if(IA)return;let LB={...U0??iZA(A),setupMode:zZ,ciSecretTarget:RA,selectedPackageManager:e1??eW(m5.pm),buildScriptChoice:CZ,envExportTargetPath:K6,keystorePasswordGenerated:rQ},hQ={onInternalLog:(bQ)=>gB(bQ),generateKeystore:ov,listKeystoreAliases:av,tryUnlockPrivateKey:Xj,validateServiceAccountJson:Bj,updateSavedCredentials:XJ,loadSavedCredentials:h4,saveAndroidProgress:EF,loadAndroidProgress:iJ,deleteAndroidProgress:mR,readFile:BM,copyFile:HtA,runOAuthFlow:async()=>{throw Error("not used in tail")},fetchUserInfo:pf,getAccessToken:MJ,revokeToken:nf,listProjects:Jj,createProject:lv,enableService:pv,ensureServiceAccount:iv,createServiceAccountKey:nv,inviteServiceAccount:async(bQ)=>{await rv(bQ)},findAndroidApplicationIds:()=>cv(B),createCiSecretEntries:(bQ)=>rO(bQ,YQ()),detectCiSecretTargets:sO,getCiSecretRepoLabelAsync:tO,listExistingCiSecretKeysAsync:eO,uploadCiSecretsAsync:AM,exportCredentialsToEnv:_F,defaultExportPath:UX,generateWorkflow:tW,writeWorkflowFile:QM,requestBuildInternal:(bQ,VQ,ZQ,i8)=>aO(bQ,{...VQ,supaHost:J,builderJourneyId:Y},ZQ,i8),logger:{info:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,bQ])},error:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,`✖ ${bQ}`])},warn:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,`⚠ ${bQ}`])},success:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,`✔ ${bQ}`])},buildLog:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,...fs(bQ)])},uploadProgress:(bQ)=>{if(IA)return;M$((VQ)=>{let ZQ=VQ.findIndex((l4)=>l4.startsWith("Uploading:")),i8=`Uploading: ${bQ.toFixed(0)}%`;if(ZQ>=0){let l4=[...VQ];return l4[ZQ]=i8,l4}return[...VQ,i8]})},customMsg:async(bQ,VQ)=>{await pO(bQ,VQ,(ZQ)=>{if(!IA)M$((i8)=>[...i8,ZQ])},(ZQ)=>{if(!IA)M$((i8)=>[...i8,ZQ])})}},onBuildOutput:(bQ)=>{if(!IA)M$((VQ)=>[...VQ,bQ])},resolveApikey:YQ,onCiSecretUploadProgress:(bQ,VQ,ZQ)=>{if(!IA)z8({current:bQ,total:VQ,key:ZQ})},onCiSecretCheckPhase:(bQ)=>{if(!IA)L1(bQ)},onCiSecretError:(bQ)=>{if(!IA)eF(bQ)},getPackageScripts:aZ,findProjectType:iX,findBuildCommandForProjectType:UW,trackWorkflowEvent:(bQ,VQ)=>{MG(bQ,VQ)},carried:{savedCredentials:wD??void 0,ciSecretEntries:X9,ciSecretExistingKeys:jQ,workflowIsNew:K9},onLog:(bQ,VQ)=>{if(!IA)ZB(bQ,VQ)},signal:jA.signal};if(q==="requesting-build")M$([]);try{let bQ=await sv(q,LB,hQ);if(IA)return;let{transient:VQ,progress:ZQ}=bQ;if(VQ?.savedCredentials!==void 0)MZ(VQ.savedCredentials);if(VQ?.ciSecretEntries!==void 0)BA(VQ.ciSecretEntries);if(VQ?.ciSecretTargets!==void 0)OA(VQ.ciSecretTargets);if(VQ?.ciSecretSetupAdvice!==void 0)yQ(VQ.ciSecretSetupAdvice);if(VQ?.ciSecretRepoLabel!==void 0)x0(VQ.ciSecretRepoLabel);if(VQ?.ciSecretExistingKeys!==void 0)K0(VQ.ciSecretExistingKeys);if(VQ?.ciSecretUploadSummary!==void 0)P7(VQ.ciSecretUploadSummary);if(VQ?.availableScripts!==void 0)Dw(VQ.availableScripts);if(VQ?.recommendedScript!==void 0)Qq(VQ.recommendedScript);if(VQ?.envExportPath!==void 0)TX(VQ.envExportPath);if(VQ?.envExportError!==void 0)Bq(VQ.envExportError);if(VQ?.workflowFilePath!==void 0)RD(VQ.workflowFilePath);if(VQ?.buildUrl!==void 0)_X(VQ.buildUrl);if(VQ?.aiJobId!==void 0)VD(VQ.aiJobId);if(ZQ.ciSecretTarget!==void 0&&ZQ.ciSecretTarget!==null)yA(ZQ.ciSecretTarget);if(ZQ.envExportTargetPath!==void 0&&ZQ.envExportTargetPath!==K6)$q(ZQ.envExportTargetPath);if(q==="uploading-ci-secrets")z8(null);if(bQ.next&&bQ.next!==q)if(q==="writing-workflow-file"){let i8=bQ.next;setTimeout(()=>{if(!IA)U(i8)},150)}else U(bQ.next)}catch(bQ){if(IA)return;let VQ=bQ instanceof Error?bQ.message:String(bQ);if(q==="saving-credentials")I4(bQ,"saving-credentials");else if(q==="requesting-build")M$((ZQ)=>[...ZQ,`⚠ ${VQ}`]),M$((ZQ)=>[...ZQ,"Your credentials are saved. Run `capgo build request --platform android` to try again."]),U("build-complete");else if(q==="exporting-env"||q==="overwrite-and-export-env")Bq(VQ),U("build-complete");else if(q==="writing-workflow-file")ZB(`⚠ Failed to write workflow file: ${VQ}`,"yellow"),setTimeout(()=>{if(!IA)U("build-complete")},150);else eF(VQ),U("ci-secrets-failed")}})(),()=>{IA=!0,jA.abort()}},[q]),EQ.useEffect(()=>{if(q!=="ai-analysis-result"&&q!=="ai-analysis-result-scroll")return;let IA=gi({current:q,text:m$,viewedFull:Y9,terminalRows:t9,terminalCols:N$});if(IA)U(IA)},[q,m$,Y9,t9,N$]);let LG=PF[q]??0,dK=dZA(q),x7=q==="ai-analysis-result-scroll",NZ=q==="ai-analysis-prompt"||q==="ai-analysis-running"||q==="ai-analysis-result"||x7,PD=q==="detecting-ci-secrets"||q==="checking-ci-secrets"||q==="ask-github-actions-setup"||q==="confirm-secrets-push"||q==="uploading-ci-secrets"||q==="ci-secrets-target-select"||q==="ci-secrets-setup"||q==="ask-ci-secrets"||q==="pick-package-manager"||q==="pick-build-script"||q==="pick-build-script-custom"||q==="preview-workflow-file"||q==="view-workflow-diff"||q==="writing-workflow-file"||q==="ask-export-env"||q==="exporting-env"||q==="confirm-env-export-overwrite"||q==="overwrite-and-export-env"||q==="ci-secrets-failed"||q==="confirm-ci-secret-overwrite",gM=q!=="requesting-build"&&q!=="view-workflow-diff"&&!x7,yM=q!=="welcome"&&q!=="error"&&q!=="build-complete"&&q!=="requesting-build"&&q!=="ai-analysis-result"&&q!=="support-confirm"&&q!=="support-log-view"&&q!=="support-uploading"&&!x7&&!PD,hM=q!=="requesting-build"&&q!=="build-complete"&&!NZ&&!PD;if(q==="requesting-build")return BQ.jsxDEV(mi,{title:"Building...",lines:f5,terminalRows:t9},void 0,!1,void 0,this);if(x7&&m$)return BQ.jsxDEV(RC,{title:"AI analysis",subtitle:`${m$.split(`
|
|
1101
1101
|
`).length} lines — scrollable because the analysis is taller than your terminal`,lines:m$.split(`
|
|
1102
1102
|
`),terminalRows:t9,onExit:()=>{j7(!0),U("ai-analysis-result")}},void 0,!1,void 0,this);if(q==="support-log-view")return BQ.jsxDEV(RC,{title:"Logs that will be sent to Capgo support",subtitle:`${zG.length} lines — secrets are already removed.`,lines:zG,terminalRows:t9,exitHint:"Press Esc or Enter to go back to the send / cancel prompt.",onExit:()=>U("support-confirm")},void 0,!1,void 0,this);if(q==="view-workflow-diff"&&m6.length>0)return BQ.jsxDEV(di,{title:K9?`\uD83C\uDD95 Proposed new file — ${X$??J6}`:`✏️ Proposed changes — ${X$??J6}`,subtitle:K9?"Nothing exists on disk yet. Every line below is what would be written.":"Proposed diff vs the file on disk. Lines marked - would be removed, lines marked + would be added.",lines:m6,terminalRows:t9,onExit:()=>{MG("workflow-diff-closed",{decision:"close"}),U("preview-workflow-file")}},void 0,!1,void 0,this);if(!mv(N$,t9,"android"))return BQ.jsxDEV(Qj,{cols:N$,rows:t9,minRows:arA},void 0,!1,void 0,this);return BQ.jsxDEV(GA,{flexDirection:"column",minHeight:t9,padding:1,children:[gM&&BQ.jsxDEV(_2,{},void 0,!1,void 0,this),BQ.jsxDEV(GA,{flexGrow:1},void 0,!1,void 0,this),hM&&BQ.jsxDEV(bs,{entries:x,maxRows:xM},void 0,!1,void 0,this),BQ.jsxDEV(GA,{flexDirection:"column",ref:T7,children:[yM&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,color:"cyan",children:dK},void 0,!1,void 0,this),BQ.jsxDEV(GA,{marginTop:1,children:[BQ.jsxDEV(JE,{value:LG},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:[" ",LG,"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),BQ.jsxDEV(w2,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="resume-prompt"&&Q&&(()=>{let{startedAt:IA,keystoreMethod:jA,serviceAccountMethod:YQ,completedSteps:U0}=Q,cB;try{let SX=new Date(IA);if(Number.isNaN(SX.getTime()))throw Error("NaN");cB=SX.toLocaleString()}catch{cB=`${IA} (could not parse)`}let LB=jA==="existing"?"Import existing keystore":jA==="generate"?"Generate new keystore":"Not chosen yet",hQ=YQ==="existing"?"Import existing JSON":YQ==="generate"?"Create via Google":null,bQ=Boolean(U0.keystoreReady),VQ=U0.androidPackageChosen,ZQ=YQ==="existing",i8=YQ==="generate"||cO(Q),l4=U0.googleSignInComplete,z4=U0.playAccountChosen,Gq=U0.gcpProjectChosen,lK=U0.serviceAccountProvisioned,pK=dZA(F)||F;return BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:1,children:[BQ.jsxDEV(l,{bold:!0,color:"cyan",children:`↩️ Found in-progress onboarding for ${A}`},void 0,!1,void 0,this),BQ.jsxDEV(l,{children:"Pick up where you left off, or start over from the welcome step."},void 0,!1,void 0,this),BQ.jsxDEV(GA,{flexDirection:"column",children:[BQ.jsxDEV(l,{children:`• Started: ${cB}`},void 0,!1,void 0,this),BQ.jsxDEV(l,{children:`• Keystore method: ${LB}`},void 0,!1,void 0,this),hQ&&BQ.jsxDEV(l,{children:`• Service account method: ${hQ}`},void 0,!1,void 0,this),BQ.jsxDEV(l,{children:`• Keystore ready: ${bQ?`Yes (${U0.keystoreReady.keystorePath})`:"No"}`},void 0,!1,void 0,this),ZQ&&BQ.jsxDEV(l,{children:`• Service account JSON: ${Q.serviceAccountJsonPath?`selected (${Q.serviceAccountJsonPath})`:"not selected yet"}`},void 0,!1,void 0,this),i8&&BQ.jsxDEV(l,{children:`• Signed in with Google: ${l4?`Yes (${l4.email})`:"No"}`},void 0,!1,void 0,this),i8&&BQ.jsxDEV(l,{children:`• Play Developer account: ${z4?`Yes (${z4.displayName||z4.developerId})`:"No"}`},void 0,!1,void 0,this),i8&&BQ.jsxDEV(l,{children:`• GCP project: ${Gq?`Yes (${Gq.displayName})`:"No"}`},void 0,!1,void 0,this),(ZQ||i8)&&BQ.jsxDEV(l,{children:`• Android package: ${VQ?`Yes (${VQ.packageName})`:"No"}`},void 0,!1,void 0,this),i8&&BQ.jsxDEV(l,{children:`• Service account provisioned: ${lK?`Yes (${lK.email})`:"No"}`},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:`• Resume target: ${pK}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BQ.jsxDEV(F0,{options:[{label:"▶️ Continue from where I left off",value:"continue"},{label:"\uD83D\uDD04 Restart onboarding (wipe saved progress)",value:"restart"}],onChange:async(SX)=>{if(t.current)return;if(t.current=!0,u("resume_prompt_decision",{choice:SX}),SX==="continue"){cK(),U(F);return}await Jq(),ZB("↩️ Restarted — fresh start","yellow"),U("welcome")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})(),q==="welcome"&&BQ.jsxDEV(hsA,{},void 0,!1,void 0,this),q==="no-platform"&&BQ.jsxDEV(usA,{androidDir:B,dense:!1},void 0,!1,void 0,this),q==="credentials-exist"&&BQ.jsxDEV(msA,{appId:A,dense:!1,onChoose:(IA)=>{if(IA==="backup")U("backing-up");else k7("Exiting onboarding.")}},void 0,!1,void 0,this),q==="backing-up"&&BQ.jsxDEV(csA,{},void 0,!1,void 0,this),q==="keystore-method-select"&&BQ.jsxDEV(AsA,{dense:!1,onChoose:(IA)=>{if(IA==="learn")U("keystore-explainer");else if(IA==="existing")IQ("existing"),G$((jA)=>({...jA,keystoreMethod:"existing"}));else IQ("generate"),G$((jA)=>({...jA,keystoreMethod:"generate"}))}},void 0,!1,void 0,this),q==="keystore-explainer"&&BQ.jsxDEV(QsA,{dense:!1,onBack:()=>U("keystore-method-select")},void 0,!1,void 0,this),q==="keystore-existing-path"&&BQ.jsxDEV(BsA,{dense:!1,showChooser:jK()&&ZA==="choose",onChoosePicker:()=>U("keystore-existing-picker"),onChooseManual:()=>PA("manual"),onSubmitPath:(IA)=>{let jA=qtA(IA);if(!jA)return;let YQ=pZA(jA);if(!ns(YQ)){b(`File not found: ${YQ}`),s("keystore-existing-path"),U("error");return}tA(YQ),ZB(`✔ Keystore selected · ${YQ}`),G$((U0)=>({...U0,keystoreExistingPath:YQ}))}},void 0,!1,void 0,this),q==="keystore-existing-picker"&&BQ.jsxDEV($sA,{},void 0,!1,void 0,this),q==="keystore-existing-store-password"&&BQ.jsxDEV(JsA,{dense:!1,onSubmit:(IA)=>{if(!IA){b("Store password cannot be empty"),s("keystore-existing-store-password"),U("error");return}B0(IA),ZB("✔ Store password set"),G$((jA)=>({...jA,keystoreStorePassword:IA}))}},void 0,!1,void 0,this),q==="keystore-existing-detecting-alias"&&BQ.jsxDEV(YsA,{},void 0,!1,void 0,this),q==="keystore-existing-alias-select"&&BQ.jsxDEV(XsA,{dense:!1,aliases:XB,onSelect:(IA)=>{Q0(IA),ZB(`✔ Alias selected · ${IA}`),G$((jA)=>({...jA,keystoreAlias:IA}))}},void 0,!1,void 0,this),q==="keystore-existing-alias"&&BQ.jsxDEV(GsA,{dense:!1,onSubmit:(IA)=>{let jA=IA.trim()||as;Q0(jA),ZB(`✔ Key alias · ${jA}`),G$((YQ)=>({...YQ,keystoreAlias:jA}))}},void 0,!1,void 0,this),q==="keystore-existing-key-password"&&BQ.jsxDEV(KsA,{dense:!1,mode:d1==="prompt"?"prompt":"probing",onSubmit:(IA)=>{let jA=IA||nQ;WB(jA),ZB("✔ Key password set"),(async()=>{try{let U0=(await BM(CA)).toString("base64"),cB={keystorePath:CA,alias:rA||as,isGenerated:!1};await S7((bQ)=>({...bQ,keystoreKeyPassword:jA,_keystoreBase64:U0,serviceAccountForkSeen:!0,completedSteps:{...bQ.completedSteps,keystoreReady:cB}})),ZB(`✔ Keystore loaded — ${CA}`);let LB=await iJ(A);if((LB?cO(LB):!1)||LB?.serviceAccountMethod!==void 0)U(LB?E9(LB):"service-account-method-select");else U("service-account-method-select")}catch(YQ){I4(YQ,"keystore-existing-path")}})()}},void 0,!1,void 0,this),q==="keystore-new-alias"&&BQ.jsxDEV(WsA,{dense:!1,onSubmit:(IA)=>{let jA=IA.trim()||as;Q0(jA),ZB(`✔ Key alias · ${jA}`),G$((YQ)=>({...YQ,keystoreAlias:jA}))}},void 0,!1,void 0,this),q==="keystore-new-password-method"&&BQ.jsxDEV(ZsA,{dense:!1,onChoose:(IA)=>{if(IA==="random"){let jA=ms();B0(jA),WB(jA),oQ(!0),ZB("✔ Store + key passwords generated"),G$((YQ)=>({...YQ,keystoreStorePassword:jA,keystoreKeyPassword:jA}))}else U("keystore-new-store-password")}},void 0,!1,void 0,this),q==="keystore-new-store-password"&&BQ.jsxDEV(HsA,{dense:!1,onSubmit:(IA)=>{if(IA.length<6){b("Password must be at least 6 characters"),s("keystore-new-store-password"),U("error");return}B0(IA),ZB("✔ Store password set"),G$((jA)=>({...jA,keystoreStorePassword:IA}),"keystore-new-key-password")}},void 0,!1,void 0,this),q==="keystore-new-key-password"&&BQ.jsxDEV(DsA,{dense:!1,onSubmit:(IA)=>{let jA=IA||nQ;WB(jA),ZB("✔ Key password set"),G$((YQ)=>({...YQ,keystoreKeyPassword:jA}))}},void 0,!1,void 0,this),q==="keystore-new-cn"&&BQ.jsxDEV(FsA,{dense:!1,appId:A,onSubmit:(IA)=>{let jA=IA.trim()||A;TB(jA),ZB(`✔ Common name · ${jA}`),G$((YQ)=>({...YQ,keystoreCommonName:jA}),"keystore-generating")}},void 0,!1,void 0,this),q==="keystore-generating"&&BQ.jsxDEV(qsA,{},void 0,!1,void 0,this),q==="service-account-method-select"&&BQ.jsxDEV(IsA,{dense:!1,onChoose:(IA)=>{if(t.current)return;if(t.current=!0,u("android_sa_method_selected",{method:IA}),IA==="existing")G$((jA)=>({...jA,serviceAccountMethod:"existing"}));else G$((jA)=>({...jA,serviceAccountMethod:"generate"}))}},void 0,!1,void 0,this),q==="sa-json-existing-path"&&BQ.jsxDEV(zsA,{dense:!1,showChooser:jK()&&TA==="choose",onChoosePicker:()=>{if(t.current)return;t.current=!0,U("sa-json-existing-picker")},onChooseManual:()=>{WA("manual")},onSubmitPath:(IA)=>{let jA=qtA(IA);if(!jA)return;let YQ=pZA(jA);if(!ns(YQ)){b(`File not found: ${YQ}`),s("sa-json-existing-path"),U("error");return}X0(YQ),ZB(`✔ Service account JSON · ${YQ}`),G$((U0)=>({...U0,serviceAccountJsonPath:YQ}))}},void 0,!1,void 0,this),q==="sa-json-existing-picker"&&BQ.jsxDEV(CsA,{},void 0,!1,void 0,this),q==="sa-json-validating"&&BQ.jsxDEV(OsA,{},void 0,!1,void 0,this),q==="sa-json-validation-failed"&&r0&&!r0.ok&&BQ.jsxDEV(MsA,{dense:!1,message:r0.message,onChoose:(IA)=>{if(t.current)return;if(t.current=!0,T.current=void 0,IA==="retry"){u("android_sa_validation_recovery_selected",{recovery_action:"retry"}),X0(""),BB(null),WA("choose"),G$((jA)=>({...jA,serviceAccountJsonPath:void 0}));return}if(IA==="save-anyway"){u("android_sa_validation_recovery_selected",{recovery_action:"save_anyway"}),(async()=>{try{if(!j8)throw Error("No service account JSON path on record.");let YQ=(await BM(j8)).toString("base64");await S7((U0)=>({...U0,_serviceAccountKeyBase64:YQ,serviceAccountValidationSkipped:!0})),ZB("⚠ Saved service account without validation — builds may fail if the SA isn't invited to your Play Console app.","yellow"),U("saving-credentials")}catch(jA){I4(jA,"sa-json-existing-path")}})();return}u("android_sa_validation_recovery_selected",{recovery_action:"fallback_oauth"}),BB(null),G$((jA)=>({...jA,serviceAccountMethod:"generate"}))}},void 0,!1,void 0,this),q==="google-sign-in"&&!PQ&&BQ.jsxDEV(NsA,{dense:!1,onChoose:(IA)=>{if(IA==="go")U("google-sign-in-running");else if(IA==="learn")sQ(!0);else k7("Run `capgo build init --platform android` again when ready.")}},void 0,!1,void 0,this),q==="google-sign-in"&&PQ&&BQ.jsxDEV(LsA,{dense:!1,onBack:()=>sQ(!1)},void 0,!1,void 0,this),q==="google-sign-in-running"&&BQ.jsxDEV(VsA,{dense:!1,statusMessages:e},void 0,!1,void 0,this),q==="play-developer-id-input"&&bB==="actions"&&BQ.jsxDEV(EsA,{dense:!1,playDeveloperUrl:ds,onChoose:async(IA)=>{if(IA==="open"){try{await q9(ds),ZB("\uD83C\uDF10 Opened Play Console in your browser","cyan")}catch(jA){gB(`could not auto-open Play Console in browser (headless?): ${jA instanceof Error?jA.message:String(jA)}`),ZB(`⚠ Couldn't auto-open the browser. Visit ${ds} manually.`,"yellow")}s0("input")}else if(IA==="tutorial")try{await q9(mZA),ZB("\uD83C\uDFAC Opened video tutorial in your browser","cyan")}catch{ZB(`⚠ Couldn't auto-open the browser. Visit ${mZA} manually.`,"yellow")}else s0("input")}},void 0,!1,void 0,this),q==="play-developer-id-input"&&bB==="input"&&BQ.jsxDEV(RsA,{dense:!1,onSubmit:(IA)=>{let jA=Gj(IA);if(!jA){b("Could not extract a developer ID. Paste the full Play Console URL or just the numeric ID."),s("play-developer-id-input"),U("error");return}let YQ={developerId:jA};S0(YQ),ZB(`✔ Play Developer account — ${jA}`),G$((U0)=>({...U0,completedSteps:{...U0.completedSteps,playAccountChosen:YQ}}))}},void 0,!1,void 0,this),q==="gcp-projects-loading"&&BQ.jsxDEV(jsA,{},void 0,!1,void 0,this),q==="gcp-projects-select"&&BQ.jsxDEV(wsA,{dense:!1,options:[{label:"\uD83C\uDD95 Create a new project",value:"__new__"},...l1.map((IA)=>({label:`${IA.name} (${IA.projectId})`,value:IA.projectId}))],onChange:(IA)=>{if(IA==="__new__"){let U0=Yj(`Capgo Native Build ${A}`);k5(U0),U("gcp-project-create-name");return}let jA=l1.find((U0)=>U0.projectId===IA);if(!jA)return;let YQ={projectId:jA.projectId,projectNumber:jA.projectNumber,displayName:jA.name,createdByOnboarding:!1};v1(YQ),ZB(`✔ GCP project — ${jA.name}`),G$((U0)=>({...U0,completedSteps:{...U0.completedSteps,gcpProjectChosen:YQ}}))}},void 0,!1,void 0,this),q==="gcp-project-create-name"&&BQ.jsxDEV(_sA,{dense:!1,defaultDisplayName:U4||Yj(`Capgo ${A}`),onSubmit:(IA)=>{let jA=Yj(IA.trim()||U4||`Capgo ${A}`),YQ=us(A),U0={projectId:YQ,displayName:jA,createdByOnboarding:!0};v1(U0),k5(jA),ZB(`✔ GCP project (new) — ${jA} / ${YQ}`),G$((cB)=>({...cB,pendingNewProjectId:YQ,pendingNewProjectDisplayName:jA,completedSteps:{...cB.completedSteps,gcpProjectChosen:U0}}))}},void 0,!1,void 0,this),q==="android-package-select"&&BQ.jsxDEV(PsA,{dense:!1,androidDir:B,showChooser:w6.length>0&&w8==="choose",detectedCount:w6.length,detectedOptions:[...w6.map((IA)=>({label:`\uD83D\uDCE6 ${IA}`,value:IA})),{label:"✍️ Type a different package name",value:"__manual__"}],onChooseDetected:(IA)=>{if(IA==="__manual__"){W4("manual");return}if(t.current)return;t.current=!0;let jA={packageName:IA,source:"gradle"};OJ(jA),ZB(`✔ Android package — ${IA}`),G$((YQ)=>({...YQ,completedSteps:{...YQ.completedSteps,androidPackageChosen:jA}}))},onSubmitManual:(IA)=>{let jA=IA.trim();if(!/^[a-z][\w]*(?:\.[a-z][\w]*)+$/i.test(jA)){b(`"${jA}" doesn't look like a valid Android package name (e.g. com.example.app).`),s("android-package-select"),U("error");return}let YQ={packageName:jA,source:w6.includes(jA)?"gradle":"user-input"};OJ(YQ),ZB(`✔ Android package — ${jA}`),G$((U0)=>({...U0,completedSteps:{...U0.completedSteps,androidPackageChosen:YQ}}))}},void 0,!1,void 0,this),q==="gcp-setup-running"&&BQ.jsxDEV(TsA,{dense:!1,statusMessages:b5},void 0,!1,void 0,this),q==="saving-credentials"&&BQ.jsxDEV(ksA,{},void 0,!1,void 0,this),q==="detecting-ci-secrets"&&BQ.jsxDEV(SsA,{},void 0,!1,void 0,this),q==="ci-secrets-setup"&&BQ.jsxDEV(xsA,{dense:!1,advice:LQ,onChoose:(IA)=>{U(IA==="retry"?"detecting-ci-secrets":"build-complete")}},void 0,!1,void 0,this),q==="ci-secrets-target-select"&&BQ.jsxDEV(bsA,{dense:!1,options:[...AA.map((IA)=>({label:IA.provider==="github"?"GitHub Actions repository secrets":"GitLab CI/CD variables",value:IA.provider})),{label:"Skip",value:"skip"}],onChange:(IA)=>{if(IA==="skip"){U("build-complete");return}let jA=AA.find((YQ)=>YQ.provider===IA)||null;if(yA(jA),!jA){U("build-complete");return}U(jA.provider==="github"?"ask-github-actions-setup":"ask-ci-secrets")}},void 0,!1,void 0,this),q==="ask-ci-secrets"&&BQ.jsxDEV(fsA,{dense:!1,entryCount:X9.length,targetLabel:wF(RA),cli:RA?.cli||"CLI",onChoose:(IA)=>{U(IA==="yes"?"checking-ci-secrets":"build-complete")}},void 0,!1,void 0,this),q==="ask-github-actions-setup"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(BY,{text:"Android credentials saved · GitHub detected"},void 0,!1,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(l,{bold:!0,children:"Set up GitHub Actions for you?"},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:["Capgo can push your"," ",X9.length," ","build env var",X9.length===1?"":"s"," ","as repository secrets and drop a"," ",".github/workflows/capgo-build.yml file you can dispatch manually."]},void 0,!0,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:[{label:"\uD83D\uDE80 Yes — set the secrets AND create a workflow file",value:"with-workflow"},{label:"\uD83D\uDD12 Yes — set ONLY the secrets",value:"secrets-only"},{label:"❌ No",value:"no"}],onChange:(IA)=>{let jA=IA==="no"?"declined":IA;bM(jA),U(_D("ask-github-actions-setup",{step:"ask-github-actions-setup",value:jA},{buildRequested:!0}))}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="ask-export-env"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,children:"Export the credentials as a .env file instead?"},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:["Writes"," ",UX(A,"android").split("/").slice(-1)[0]," ","so you can wire up CI later via"," ",BQ.jsxDEV(l,{children:"gh secret set -f"},void 0,!1,void 0,this)," ","or paste the values manually."]},void 0,!0,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:[{label:`\uD83D\uDCDD Yes — write .env.capgo.${A}.android`,value:"yes"},{label:"❌ No, exit without exporting",value:"no"}],onChange:(IA)=>{if(IA==="yes"){let jA=UX(A,"android");$q(jA),U(_D("ask-export-env",{step:"ask-export-env",value:"yes",envExportTargetPath:jA},{buildRequested:!0}));return}U("build-complete")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="exporting-env"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:BQ.jsxDEV(VB,{text:`Writing ${UX(A,"android").split("/").slice(-1)[0]}…`},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="confirm-env-export-overwrite"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,color:"yellow",children:[K6," ","already exists."]},void 0,!0,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:"Replace it with a fresh export, or skip?"},void 0,!1,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:[{label:"✏️ Replace it",value:"replace"},{label:"\uD83D\uDED1 Skip — keep the existing file",value:"skip"}],onChange:(IA)=>{U(IA==="replace"?"overwrite-and-export-env":"build-complete")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="pick-package-manager"&&(()=>{let IA=eW(m5.pm),jA=m5.pm==="unknown"?"(no recognizable lockfile in this project — pick whichever you actually use)":`(detected from your lockfile — ${m5.pm})`;return BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,children:"Which package manager does this project use?"},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:["Drives the install + build steps in the generated workflow. We"," ",jA]},void 0,!0,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:[{label:`\uD83D\uDCE6 bun${IA==="bun"?" (recommended — matches your lockfile)":""}`,value:"bun"},{label:`\uD83D\uDCE6 npm${IA==="npm"?" (recommended — matches your lockfile)":""}`,value:"npm"},{label:`\uD83D\uDCE6 pnpm${IA==="pnpm"?" (recommended — matches your lockfile)":""}`,value:"pnpm"},{label:`\uD83D\uDCE6 yarn${IA==="yarn"?" (recommended — matches your lockfile)":""}`,value:"yarn"}],onChange:(YQ)=>{let U0=YQ;_9(U0),U(_D("pick-package-manager",{step:"pick-package-manager",selectedPackageManager:U0},{buildRequested:!0,ciSecretsUploaded:!0}))}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})(),q==="pick-build-script"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,children:"Which script builds your web assets?"},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:["Capgo will run this before invoking"," ",BQ.jsxDEV(l,{children:"capgo build request"},void 0,!1,void 0,this)," ","in the workflow. Pick the script you use locally to produce the web build (typically into capacitor.config webDir, e.g. dist/)."]},void 0,!0,void 0,this),BQ.jsxDEV(lA,{},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:$j(fM,Aq),onChange:(IA)=>{if(IA==="__skip__"){OZ({type:"skip"}),U("preview-workflow-file");return}if(IA==="__custom__"){U("pick-build-script-custom");return}OZ({type:"npm-script",name:IA}),U("preview-workflow-file")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="pick-build-script-custom"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,children:"Custom build command"},void 0,!1,void 0,this),BQ.jsxDEV(l,{dimColor:!0,children:["Type the exact command you want the workflow to run before"," ",BQ.jsxDEV(l,{children:"capgo build request"},void 0,!1,void 0,this)," ","(e.g."," ",BQ.jsxDEV(l,{children:"make web"},void 0,!1,void 0,this),","," ",BQ.jsxDEV(l,{children:"bash scripts/build.sh"},void 0,!1,void 0,this),")."]},void 0,!0,void 0,this),BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(O6,{placeholder:"make web",onSubmit:(IA)=>{let jA=IA.trim();if(!jA)return;OZ({type:"custom",command:jA}),U("preview-workflow-file")}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="preview-workflow-file"&&m6.length>0&&(()=>{let jA=m6.every((LB)=>LB.kind==="eq")?"✏️ Write file anyway (re-writes identical content)":K9?"✏️ Write file":"✏️ Replace existing file",YQ="❌ Do not write file",U0=K9?`\uD83C\uDD95 Proposed new file — ${X$??J6}`:`✏️ Proposed changes — ${X$??J6}`;return BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(ci,{title:U0,subtitle:K9?"Nothing exists on disk yet. Every line below is what would be written.":"Proposed diff vs the file on disk. Lines marked - would be removed, lines marked + would be added.",lines:m6},void 0,!1,void 0,this),BQ.jsxDEV(GA,{marginTop:1,flexDirection:"column",children:[BQ.jsxDEV(l,{bold:!0,children:["What should we do with ",J6,"?"]},void 0,!0,void 0,this),BQ.jsxDEV(F0,{options:[{label:jA,value:"write"},{label:"\uD83D\uDC40 Show proposed file diff",value:"view"},{label:"❌ Do not write file",value:"cancel"}],onChange:(LB)=>{if(LB==="view"){MG("workflow-preview-action",{decision:"view"}),MG("workflow-diff-opened",{decision:"view"}),U("view-workflow-diff");return}MG("workflow-preview-action",{decision:LB==="write"?"write":"cancel"}),P9([]),U(LB==="write"?"writing-workflow-file":"build-complete")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)})(),q==="preview-workflow-file"&&m6.length===0&&BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(VB,{text:`Preparing diff for ${J6}…`},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="writing-workflow-file"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:BQ.jsxDEV(VB,{text:`Writing ${J6}…`},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="checking-ci-secrets"&&BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(VB,{text:$B},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="confirm-secrets-push"&&(()=>{let IA=new Set(jQ),jA=X9.filter((U0)=>!IA.has(U0.key)).length,YQ=X9.length-jA;return BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[BQ.jsxDEV(l,{bold:!0,color:"yellow",children:"⚠ Confirm before pushing secrets"},void 0,!1,void 0,this),BQ.jsxDEV(l,{children:["Repository:"," ",BQ.jsxDEV(l,{bold:!0,color:"cyan",children:$0},void 0,!1,void 0,this)," ",BQ.jsxDEV(l,{dimColor:!0,children:"(resolved via `gh repo view`)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BQ.jsxDEV(l,{bold:!0,children:[`Will push ${X9.length} env var${X9.length===1?"":"s"}`,YQ>0?` — ${jA} new, ${YQ} REPLACING existing:`:" — all new:"]},void 0,!0,void 0,this),BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(li,{rows:X9.map((U0)=>({name:U0.key,status:IA.has(U0.key)?"REPLACE":"NEW"}))},void 0,!1,void 0,this)},void 0,!1,void 0,this),YQ>0&&BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(l,{dimColor:!0,color:"yellow",children:"⚠ `gh secret set` overwrites silently — replaced values cannot be recovered."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})(),q==="confirm-secrets-push"&&BQ.jsxDEV(BQ.Fragment,{children:BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(F0,{options:[{label:`✅ Yes, push to ${$0}`,value:"confirm"},{label:"❌ Cancel — don't push anything",value:"cancel"}],onChange:(IA)=>{U(IA==="confirm"?"uploading-ci-secrets":"build-complete")}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="confirm-ci-secret-overwrite"&&BQ.jsxDEV(vsA,{dense:!1,existingKeys:jQ,onChoose:(IA)=>{U(IA==="replace"?"uploading-ci-secrets":"build-complete")}},void 0,!1,void 0,this),q==="uploading-ci-secrets"&&BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(VB,{text:t1?`Pushing ${t1.current} of ${t1.total}: ${t1.key}…`:`Uploading env vars to ${$0??wF(RA)}…`},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="ci-secrets-failed"&&BQ.jsxDEV(gsA,{dense:!1,error:ED,onChoose:(IA)=>{U(IA==="retry"?RA?"checking-ci-secrets":"detecting-ci-secrets":"build-complete")}},void 0,!1,void 0,this),q==="ask-build"&&BQ.jsxDEV(ysA,{dense:!1,onChoose:(IA)=>{if(IA==="yes")U("requesting-build");else U("build-complete")}},void 0,!1,void 0,this),q==="build-complete"&&BQ.jsxDEV(dsA,{uploadSummary:jI,buildUrl:MY,workflowWrittenPath:TI,envExportPath:jD,envExportError:vM,dense:!1},void 0,!1,void 0,this),q==="ai-analysis-prompt"&&BQ.jsxDEV(psA,{dense:!1,onChoose:async(IA)=>{if(IA==="support"){await kX("ai-analysis-prompt").catch((jA)=>{console.error("[support-flow]",jA)});return}if(IA==="debug")U("ai-analysis-running");else{if(Y$)await RK({apikey:L.current??$??"",orgId:E??"",appId:A,platform:"android",jobId:Y$,choice:"skip",triggeredBy:"onboarding"}).catch(()=>{});U("build-complete")}}},void 0,!1,void 0,this),q==="ai-analysis-running"&&BQ.jsxDEV(isA,{streamText:uK,terminalRows:t9,terminalCols:N$},void 0,!1,void 0,this),q==="support-uploading"&&BQ.jsxDEV(GA,{marginTop:1,children:BQ.jsxDEV(VB,{text:l0},void 0,!1,void 0,this)},void 0,!1,void 0,this),q==="ai-analysis-result"&&BQ.jsxDEV(nsA,{analysisText:m$,collapsed:Y9&&!!m$&&ck(m$,t9,N$),result:CG,retryCount:v5,maxRetries:$10,dense:!1,onReread:()=>U("ai-analysis-result-scroll"),onSupport:()=>{kX("ai-analysis-result").catch((IA)=>{console.error("[support-flow]",IA)})},onRetry:async()=>{if(Y$)await RK({apikey:L.current??$??"",orgId:E??"",appId:A,platform:"android",jobId:Y$,choice:"retry",triggeredBy:"onboarding"}).catch(()=>{}),rR(Y$).catch(()=>{});VD(null),Z4(null),PX(null),j7(!1),OG((IA)=>IA+1),U("requesting-build")},onSkipOrContinue:()=>U("build-complete")},void 0,!1,void 0,this),q==="support-confirm"&&BQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:1,children:[BQ.jsxDEV(l,{bold:!0,children:"Email Capgo support"},void 0,!1,void 0,this),BQ.jsxDEV(l,{children:IG},void 0,!1,void 0,this),BQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCE8 Yes, send to support",value:"yes"},{label:"\uD83D\uDC40 View logs first",value:"view"},{label:"✖ Cancel",value:"no"}],onChange:(IA)=>{if(IA==="view"){let YQ=[];try{YQ=lZA(UZ.current,"utf8").split(`
|
|
1103
|
-
`)}catch{YQ=["(could not read the logs file)"]}LD(YQ),U("support-log-view");return}let jA=qZ.current;qZ.current=null,jA?.(IA==="yes")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="error"&&p&&qA&&BQ.jsxDEV(lsA,{message:p,dense:!1,hasBuildLog:!!Y$,onChoose:(IA)=>{if(IA==="support")kX().catch((jA)=>{console.error("[support-flow]",jA)});else if(IA==="ai")U("ai-analysis-prompt");else if(IA==="retry"){b(null),T.current=void 0;let jA=qA;s(null),U(jA)}else k7("Run `capgo build init --platform android` to resume.")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},UtA=Y10;import{readFile as X10,unlink as G10}from"node:fs/promises";import{homedir as K10}from"node:os";import{join as nZA}from"node:path";var W10=".capgo-credentials",Z10="onboarding";function ItA(A){let Q=A||nZA(K10(),W10);return nZA(Q,Z10)}function H10(A){let Q=A.replace(/[/\\]/g,"_").replace(/\.\./g,"_");if(!Q||Q==="."||Q==="..")throw Error(`Invalid appId for progress file: "${A}"`);return Q}function oZA(A,Q){return nZA(ItA(Q),`${H10(A)}.json`)}async function x4(A,Q){let B=oZA(A,Q);try{let $=await X10(B,"utf-8");return JSON.parse($)}catch($){if($ instanceof Error&&"code"in $&&$.code==="ENOENT")return null;throw $}}async function GG(A,Q,B){let $=ItA(B);await _V($,448);let J=oZA(A,B);await zW(J,JSON.stringify(Q,null,2),{mode:384})}async function tv(A,Q){let B=oZA(A,Q);try{await G10(B)}catch{}}function ztA(A,Q=!0){if(!A)return"welcome";let{completedSteps:B,setupMethod:$}=A;if($==="import-existing"){if(!B.apiKeyVerified){if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";if(A.importDistribution==="ad_hoc")return"import-scanning";if(A.importDistribution==="app_store")return"api-key-instructions";return"import-distribution-mode"}return"import-scanning"}if(!B.apiKeyVerified){if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";if(A.p8CreateMethod==="automated"&&Q)return"asc-key-generating";return"api-key-instructions"}if(!B.certificateCreated)return"verify-app";if(!B.profileCreated)return"creating-profile";return"saving-credentials"}function rs(A){if(!A?.importDistribution)return"import-distribution-mode";if(A.importDistribution==="ad_hoc")return"import-pick-identity";if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";return"api-key-instructions"}function $M(A){return A.match(/(?:Auth|Api)Key_([A-Z0-9]+)\.p8$/i)?.[1]?.toUpperCase()??""}import{Buffer as AI}from"node:buffer";import{spawn as B80}from"node:child_process";import{existsSync as Hj,readFileSync as sZA}from"node:fs";import{copyFile as $80,mkdir as J80,readFile as Dj,writeFile as Y80}from"node:fs/promises";import{homedir as X80}from"node:os";import{dirname as G80,join as Bg,resolve as K80}from"node:path";import U7 from"node:process";FW();var $Q=iA(_0(),1);O4();var D10=/\s+/g,F10=new Set(["bunx","npx","pnpm exec","yarn dlx"]);function G4(A,Q){return`${A} ${Q.join(" ")}`}function TF(A){let Q=A.trim().replaceAll(D10," ");if(!F10.has(Q))throw Error(`Unsupported package manager runner: "${A}"`);let B=Q.split(" ").map((Y)=>Y.trim()).filter(Boolean),[$=A,...J]=B;return{command:$,args:J}}JB();function CtA(A){let Q=A.apps.find((B)=>B.bundleId===A.releaseBundleId)??null;if(Q)return{result:"exact-match",matchedApp:Q};if(A.apps.length>0)return{result:"wrong-build-id",matchedApp:null};if(A.registeredBundleIds.includes(A.releaseBundleId))return{result:"no-app-identifier-exists",matchedApp:null};return{result:"no-app-unregistered",matchedApp:null}}var q10=3;function ev(A){if(A.satisfied)return{proceed:!0,escalationLevel:0};return{proceed:!1,escalationLevel:Math.min(A.attempt,q10)}}import{readFileSync as OtA}from"node:fs";function NtA(A){if(!A)return[];let Q=/\w+\s*\/\*[^*]*\*\/\s*=\s*\{[^{}]*(?:\{[^}]*\}[^{}]*)*\}/g,B=[];for(let $ of A.matchAll(Q)){let J=$[0];if(!J.includes("XCBuildConfiguration"))continue;let Y=J.match(/name\s*=\s*("[^"]*"|[^;\s]+)\s*;/),X=J.match(/PRODUCT_BUNDLE_IDENTIFIER\s*=\s*"?([^";\s]+)"?\s*;/);if(!Y||!X)continue;let G=Y[1].replace(/^"|"$/g,""),K=X[1];if(K.includes("$("))continue;B.push({value:K,configName:G})}return B}function MtA(A,Q){return A.filter((B)=>B.configName===Q).sort((B,$)=>B.value.length-$.value.length)[0]}function LtA(A){let Q=NtA(A),B=MtA(Q,"Release"),$=MtA(Q,"Debug"),J=B?{value:B.value,source:"pbxproj-release",label:"project.pbxproj (Release config)"}:null,Y=$?{value:$.value,source:"pbxproj-debug",label:"project.pbxproj (Debug config)"}:null;return{release:J,debug:Y,releaseResolved:J!==null}}function U10(A){let{release:Q}=LtA(A);if(Q)return Q;let B=NtA(A);if(B.length===0)return null;let $=B.slice().sort((J,Y)=>J.value.length-Y.value.length)[0];return{value:$.value,source:"pbxproj-fallback",label:`project.pbxproj (${$.configName} config)`}}function I10(A){if(!A)return null;let Q=A.match(/<key>CFBundleIdentifier<\/key>\s*<string>([^<]+)<\/string>/);if(!Q)return null;let B=Q[1].trim();if(!B||B.includes("$("))return null;return{value:B,source:"plist",label:"Info.plist (CFBundleIdentifier)"}}function Zj(A){let{cwd:Q,iosDir:B,capacitorAppId:$}=A,J={value:$,source:"capacitor-config",label:"capacitor.config.ts (appId)"},Y=null,X=null,G=!1,K=null,W=xV(`${Q}/${B}`)??xV(Q);if(W)try{let O=OtA(W,"utf-8"),V=LtA(O);X=V.debug,G=V.releaseResolved,Y=V.release??U10(O)}catch{}let H=[`${Q}/${B}/App/App/Info.plist`,`${Q}/${B}/App/Info.plist`];for(let O of H)try{let V=OtA(O,"utf-8");if(K=I10(V),K)break}catch{}let F=new Set,q=[];for(let O of[Y,K,J]){if(!O||F.has(O.value))continue;F.add(O.value),q.push(O)}let U=q[0],I=U.value!==J.value,z=G&&X!==null&&Y!==null&&X.value!==Y.value;return{pbxproj:Y,debug:X,plist:K,capacitor:J,recommended:U,mismatch:I,debugReleaseDiffer:z,releaseResolved:G,candidates:q}}function VtA(A,Q,B,$){let J=A.toLowerCase(),Y=[],X=new Set,G=new Set,K=G4(B,["cap","add","ios"]),W=G4(B,["cap","sync","ios"]),H=G4(B,["@capgo/cli@latest","doctor"]),F=G4(B,["@capgo/cli@latest","build","init"]),q=G4(B,["@capgo/cli@latest","build","request",$,"--platform","ios"]),U=G4(B,["@capgo/cli@latest","login"]);if(Q==="no-platform"||Q==="adding-platform"||J.includes("no ios/ directory"))Y.push("This project does not have a generated native iOS folder yet.","Create the iOS platform, then sync native sources before resuming onboarding."),X.add(K),X.add(W);if(J.includes("required agreement")||J.includes("agreements, tax, and banking"))Y.push("Apple is blocking App Store Connect API access because a required agreement is unsigned or has expired.","Your API key is fine — the Account Holder must accept the agreement in App Store Connect, then retry the saved step."),G.add("https://appstoreconnect.apple.com/agreements");else if(J.includes("api key verification failed")||J.includes("401")||J.includes("403"))Y.push("Apple rejected the App Store Connect credentials.","Double-check the .p8 file, Key ID, Issuer ID, and that the key still has Admin or Developer access."),G.add("https://capgo.app/docs/cli/cloud-build/ios/"),G.add("https://appstoreconnect.apple.com/access/integrations/api");if(J.includes("fetch failed")||J.includes("network")||J.includes("etimedout")||J.includes("enotfound")||J.includes("econnreset"))Y.push("The CLI could not reach Apple or Capgo over the network.","Check VPN, proxy, firewall, and DNS settings, then retry from the saved step."),X.add(H);if(J.includes("429")||J.includes("rate limit"))Y.push("Apple is rate-limiting the request right now.","Wait a minute, then retry from the saved step instead of restarting the whole flow.");if(J.includes("certificate limit"))Y.push("Apple has reached the maximum number of active distribution certificates for this team.");if(J.includes("duplicate profile"))Y.push("Apple still has conflicting provisioning profiles for this bundle identifier.","You can let onboarding delete the duplicates automatically, or clean them up in App Store Connect and resume."),G.add("https://appstoreconnect.apple.com/access/users");if(J.includes("bundle")&&J.includes("identifier"))Y.push("Apple reported a bundle identifier conflict or bundle registration issue.",`Verify that ${$} is the bundle ID you intend to build for in both Capgo and your Capacitor config.`),X.add(H);if(J.includes("file not found")||J.includes("could not read file")||J.includes("need .p8 file"))Y.push("The onboarding flow could not read the API key file from disk.","Re-select the .p8 file or move it somewhere stable before retrying.");if(J.includes("no capgo api key found"))Y.push("Capgo login is missing, so the first cloud build cannot be requested automatically."),X.add(U),X.add(q);if(J.includes("credentials are saved"))Y.push("Your signing material is already saved locally, so you only need to re-run the build request."),X.add(q);if(Y.length===0)Y.push("The onboarding flow hit an unexpected error.","Retry the saved step first. If it still fails, capture diagnostics and keep the support bundle when you contact support."),X.add(H),X.add(F),G.add("https://capgo.app/docs/cli/cloud-build/ios/");else X.add(F);return{summary:Y,commands:Array.from(X),docs:Array.from(G)}}var QZ={welcome:0,"resume-prompt":2,"platform-select":0,"adding-platform":0,"credentials-exist":0,"backing-up":0,"setup-method-select":5,"import-scanning":10,"import-distribution-mode":15,"import-pick-identity":40,"import-pick-profile":55,"import-validating-all-certs":38,"import-checking-apple-cert":50,"import-no-match-recovery":55,"import-portal-explanation":56,"import-provide-profile-path":58,"import-create-profile-only":60,"import-export-warning":70,"import-exporting":75,"p8-source-select":6,"asc-key-generating":22,"asc-key-created":24,"api-key-instructions":5,"p8-method-select":8,"input-p8-path":10,"input-key-id":12,"input-issuer-id":18,"verifying-key":25,"verify-app":30,"creating-certificate":45,"cert-limit-prompt":45,"revoking-certificate":48,"creating-profile":65,"duplicate-profile-prompt":65,"deleting-duplicate-profiles":68,"saving-credentials":80,"detecting-ci-secrets":82,"ci-secrets-setup":82,"ci-secrets-target-select":82,"ask-ci-secrets":82,"checking-ci-secrets":83,"confirm-ci-secret-overwrite":83,"uploading-ci-secrets":84,"ci-secrets-failed":84,"ask-github-actions-setup":82,"confirm-secrets-push":83,"ask-export-env":95,"exporting-env":96,"confirm-env-export-overwrite":96,"overwrite-and-export-env":96,"pick-package-manager":95,"pick-build-script":96,"pick-build-script-custom":96,"preview-workflow-file":97,"view-workflow-diff":97,"writing-workflow-file":98,"ask-build":85,"requesting-build":90,"ai-analysis-prompt":92,"ai-analysis-running":95,"ai-analysis-result-scroll":97,"ai-analysis-result":98,"build-complete":100,"no-platform":0,error:0,"support-confirm":0,"support-log-view":0,"support-uploading":0};function aZA(A){switch(A){case"welcome":case"platform-select":case"adding-platform":case"credentials-exist":case"backing-up":return"";case"resume-prompt":return"Resume or restart?";case"setup-method-select":return"Setup method";case"verify-app":return"Verify App Store app";case"import-scanning":return"Step 1 of 4 · Scanning your Mac";case"import-distribution-mode":return"Step 1 of 4 · Distribution mode";case"import-pick-identity":return"Step 2 of 4 · Choose certificate";case"import-validating-all-certs":return"Step 2 of 4 · Validating certificates with Apple";case"import-pick-profile":return"Step 3 of 4 · Choose provisioning profile";case"import-checking-apple-cert":return"Step 3 of 4 · Checking certificate on Apple";case"import-no-match-recovery":return"Step 3 of 4 · No matching profile — recover";case"import-portal-explanation":return"Step 3 of 4 · Manual portal walkthrough";case"import-provide-profile-path":return"Step 3 of 4 · Provide .mobileprovision file";case"import-create-profile-only":return"Step 3 of 4 · Creating profile via Apple";case"import-export-warning":case"import-exporting":return"Step 4 of 4 · Export from Keychain";case"p8-source-select":case"asc-key-generating":case"asc-key-created":case"api-key-instructions":case"p8-method-select":case"input-p8-path":case"input-key-id":case"input-issuer-id":case"verifying-key":return"Step 1 of 4 · App Store Connect API Key";case"creating-certificate":case"cert-limit-prompt":case"revoking-certificate":return"Step 2 of 4 · Distribution Certificate";case"creating-profile":case"duplicate-profile-prompt":case"deleting-duplicate-profiles":return"Step 3 of 4 · Provisioning Profile";case"saving-credentials":case"detecting-ci-secrets":case"ci-secrets-setup":case"ci-secrets-target-select":case"ask-ci-secrets":case"ask-github-actions-setup":case"confirm-secrets-push":case"checking-ci-secrets":case"confirm-ci-secret-overwrite":case"uploading-ci-secrets":case"ci-secrets-failed":case"ask-export-env":case"exporting-env":case"confirm-env-export-overwrite":case"overwrite-and-export-env":case"pick-package-manager":case"pick-build-script":case"pick-build-script-custom":case"preview-workflow-file":case"view-workflow-diff":case"writing-workflow-file":case"ask-build":case"requesting-build":return"Step 4 of 4 · Save & Build";case"ai-analysis-prompt":case"ai-analysis-running":case"ai-analysis-result":case"ai-analysis-result-scroll":return"AI debug";case"build-complete":return"Complete";case"no-platform":case"error":case"support-confirm":case"support-log-view":case"support-uploading":return""}}var T1=iA(M8(),1),z10=3,EtA=()=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:T1.jsxDEV(VB,{text:"Checking git hosting..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),RtA=({advice:A,onChange:Q})=>{let B=T1.jsxDEV(F0,{options:[{label:"I installed and logged in, check again",value:"retry"},{label:"Skip upload",value:"skip"}],onChange:Q},void 0,!1,void 0,this);return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,children:"Set up your git hosting CLI to upload env vars"},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),A.map(($)=>T1.jsxDEV(GA,{flexDirection:"column",marginBottom:1,children:[T1.jsxDEV(l,{children:$.target.label},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:$.message},void 0,!1,void 0,this),$.commands.map((J)=>T1.jsxDEV(l,{color:"cyan",children:J},`${$.target.provider}-${J}`,!1,void 0,this))]},$.target.provider,!0,void 0,this)),T1.jsxDEV(l,{dimColor:!0,children:"Run this in another terminal, then come back here."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),B]},void 0,!0,void 0,this)},jtA=({options:A,dense:Q=!1,onChange:B})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,children:"Where should Capgo upload the build env vars?"},void 0,!1,void 0,this),!Q&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),Q?T1.jsxDEV(F0,{visibleOptionCount:z10,options:A,onChange:B},void 0,!1,void 0,this):T1.jsxDEV(F0,{options:A,onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),wtA=({entryCount:A,target:Q,targetLabel:B,dense:$=!1,onChange:J})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(BY,{text:"Credentials saved"},void 0,!1,void 0,this),!$&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{bold:!0,children:`Upload ${A} build env var${A===1?"":"s"} to ${B}?`},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:$?"Capgo checks for existing names first and asks before replacing anything.":"Capgo will check for existing names first and ask before replacing anything."},void 0,!1,void 0,this),!$&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:[{label:`Upload with ${Q?.cli||"CLI"}`,value:"yes"},{label:"Skip",value:"no"}],onChange:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C10=[{label:"Replace existing env vars",value:"replace"},{label:"Skip upload",value:"skip"}],_tA=({existingKeys:A,onChange:Q})=>{return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,color:"yellow",children:"These env vars already exist and will be replaced:"},void 0,!1,void 0,this),T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,marginLeft:2,children:A.map((B)=>T1.jsxDEV(l,{children:`• ${B}`},B,!1,void 0,this))},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:C10,onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},O10=[{label:"Try upload again",value:"retry"},{label:"Continue without upload",value:"continue"}],PtA=({error:A,onChange:Q})=>{return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV($Y,{text:A||"Could not upload env vars."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:"You can continue; credentials are already saved locally."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:O10,onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},TtA=({dense:A=!1,onChange:Q})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(BY,{text:"Credentials saved"},void 0,!1,void 0,this),!A&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{bold:!0,children:"Start your first cloud build now?"},void 0,!1,void 0,this),!A&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:[{label:"\uD83D\uDE80 Yes, build now",value:"yes"},{label:"⏭️ No, I'll build later",value:"no"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var RQ=iA(M8(),1),ktA=({appId:A,dense:Q=!1,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,color:"yellow",children:["⚠ iOS credentials already exist for"," ",A]},void 0,!0,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{children:Q?"New certs and profiles will replace your existing credentials.":"Onboarding will create new certificates and profiles, replacing your existing credentials."},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCE6 Start fresh (backup existing credentials first)",value:"backup"},{label:"✖ Exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),StA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Backing up existing credentials..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),xtA=({dense:A=!1,onChange:Q})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"How do you want to set up iOS credentials?"},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83C\uDD95 Create new via App Store Connect API",value:"create"},{label:"\uD83D\uDCE5 Import existing from this Mac (Keychain + Xcode profiles)",value:"import"}],onChange:Q},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:A?"Tip: Import reuses Xcode's cert, so it skips Apple's 3-cert limit.":"Tip: Importing reuses the certificate Xcode already installed, so it doesn't count against Apple's 3-cert limit."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),btA=({dense:A=!1,canAutomate:Q,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"Do you already have an App Store Connect API key (.p8 file)?"},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:Q?"✨ No — create one for me (guided, opens a window)":"\uD83C\uDD95 No — I will create one at App Store Connect",value:"create"},{label:"✓ Yes — I have a .p8 file",value:"have"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ftA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Guiding you through App Store Connect — finish in the window that opened…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),vtA=({keyId:A,onContinue:Q})=>{return u4((B,$)=>{if($.return)Q()}),RQ.jsxDEV(GA,{flexGrow:1,alignItems:"center",justifyContent:"center",children:RQ.jsxDEV(GA,{flexDirection:"column",alignItems:"center",borderStyle:"round",borderColor:"green",paddingX:6,paddingY:1,children:[RQ.jsxDEV(l,{children:"\uD83C\uDF89"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(l,{bold:!0,color:"green",children:"App Store Connect API key created"},void 0,!1,void 0,this)},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,flexDirection:"column",alignItems:"center",children:[RQ.jsxDEV(l,{children:"Your key was created and validated with Apple."},void 0,!1,void 0,this),A?RQ.jsxDEV(l,{dimColor:!0,children:`Key ID: ${A}`},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(l,{bold:!0,color:"cyan",children:"Press Enter to continue →"},void 0,!1,void 0,this)},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:"This closes the helper window and finishes your setup here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},gtA=({canUseFilePicker:A,canCreateGuided:Q=!1,dense:B=!1,onMethodChange:$,onPathSubmit:J})=>{let Y=A?RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:"How do you want to provide the .p8 file?"},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCC2 Open file picker",value:"picker"},{label:"\uD83D\uDCDD Type the path",value:"manual"},...Q?[{label:"✨ Create one for me instead (guided)",value:"guided"}]:[]],onChange:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this):RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:"Path to your .p8 file:"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"~/Downloads/AuthKey_XXXXXXXXXX.p8",onSubmit:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"We need an App Store Connect API key to manage certificates and profiles for you."},void 0,!1,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{flexDirection:"column",marginLeft:2,children:[RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"1."},void 0,!1,void 0,this)," ","Go to"," ",RQ.jsxDEV(l,{color:"cyan",underline:!0,children:"appstoreconnect.apple.com/access/integrations/api"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"2."},void 0,!1,void 0,this)," ","Click"," ",RQ.jsxDEV(l,{bold:!0,children:'"Generate API Key"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"3."},void 0,!1,void 0,this)," ","Name it"," ",RQ.jsxDEV(l,{color:"yellow",children:'"Capgo Builder"'},void 0,!1,void 0,this)," ","· Access:"," ",RQ.jsxDEV(l,{bold:!0,color:"green",children:'"Admin"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"4."},void 0,!1,void 0,this)," ","Download the"," ",RQ.jsxDEV(l,{bold:!0,children:".p8"},void 0,!1,void 0,this)," ","file"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{children:[RQ.jsxDEV(l,{dimColor:!0,children:"Press "},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,color:"white",children:"Ctrl+O"},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:" to open App Store Connect in your browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(w2,{},void 0,!1,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this)},ytA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Opening file picker..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),htA=({onSubmit:A})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,children:"Path to your .p8 file:"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"~/Downloads/AuthKey_XXXXXXXXXX.p8",onSubmit:A},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),utA=({keyId:A,dense:Q=!1,onSubmit:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:A?RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:["Key ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:"(detected from filename)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:[RQ.jsxDEV(l,{color:"green",children:"✔ "},void 0,!1,void 0,this),RQ.jsxDEV(l,{children:A},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:Q?" — Enter to confirm, or type another":" — press Enter to confirm, or type a different one"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:A,onSubmit:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:["Key ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:"(shown next to the key name in App Store Connect)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"ABC123DEF",onSubmit:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),mtA=({dense:A=!1,onSubmit:Q})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,children:["Issuer ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:A?"(UUID at the top of the API keys page)":"(UUID at the very top of the API keys page, above the key list)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{children:[RQ.jsxDEV(l,{dimColor:!0,children:"Press "},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,color:"white",children:"Ctrl+O"},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:" to open App Store Connect in your browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",onSubmit:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ctA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Verifying API key with Apple..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),dtA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(VB,{text:"Generating signing key and CSR..."},void 0,!1,void 0,this),RQ.jsxDEV(VB,{text:"Creating Apple Distribution certificate..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ltA=({existingCount:A,options:Q,dense:B=!1,onChange:$})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV($Y,{text:`Apple Distribution certificate limit reached (${A} existing).`},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,children:"Select a certificate to revoke:"},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:Q,onChange:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ptA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Revoking old certificate..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),itA=({appId:A,dense:Q=!1})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(BY,{text:"Bundle ID",detail:A},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(VB,{text:"Creating App Store provisioning profile..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ntA=({duplicateCount:A,dense:Q=!1,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV($Y,{text:`Found ${A} existing Capgo profile(s) for this app.`},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,children:"Delete old profiles and create a new one?"},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"✔ Yes, delete old profiles and recreate",value:"delete"},{label:"✖ No, exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),otA=({duplicateCount:A})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:`Deleting ${A} old profile(s)...`},void 0,!1,void 0,this)},void 0,!1,void 0,this),atA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Saving credentials..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);var EB=iA(M8(),1),ss=3,rtA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Scanning Keychain and provisioning profiles..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"This is read-only — no Keychain password prompt yet."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),stA=({dense:A=!1,onChange:Q})=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:"How will Capgo distribute your build?"},void 0,!1,void 0,this),!A&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:A?"• App Store: auto-uploads to TestFlight (needs an ASC API key).":"• App Store: builds upload to TestFlight automatically (requires an App Store Connect API key)"},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:A?"• Ad-hoc: signed build, downloaded from Capgo or via QR. No ASC key.":"• Ad-hoc: builds are signed and either downloaded from Capgo or installed via QR. No ASC key needed."},void 0,!1,void 0,this),!A&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(F0,{options:[{label:"\uD83D\uDEEB App Store / TestFlight",value:"app_store"},{label:"\uD83D\uDCE6 Ad-hoc (no TestFlight upload)",value:"ad_hoc"},{label:"↩️ Cancel and use Create new instead",value:"__cancel__"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ttA=({identityCount:A,options:Q,dense:B=!1,onChange:$})=>{let J=Math.max(0,Q.length-ss);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:`Found ${A} distribution identit${A===1?"y":"ies"} in your Keychain. Pick one:`},void 0,!1,void 0,this),!B&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),B?EB.jsxDEV(F0,{visibleOptionCount:ss,options:Q,onChange:$},void 0,!1,void 0,this):EB.jsxDEV(F0,{options:Q,onChange:$},void 0,!1,void 0,this),B&&J>0&&EB.jsxDEV(l,{dimColor:!0,children:`… +${J} more (↑/↓ to scroll)`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},etA=({matchedCount:A,droppedCount:Q,distribution:B,options:$,dense:J=!1,onChange:Y})=>{let X=Math.max(0,$.length-ss);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:J?`Pick a profile (${A} match this app's bundle ID${B?`, ${B}`:""}):`:`Pick a provisioning profile (${A} matching this app's bundle ID${B?` and ${B} distribution`:""}):`},void 0,!1,void 0,this),Q>0&&EB.jsxDEV(l,{dimColor:!0,children:J?`(${Q} hidden — wrong bundle ID or distribution)`:`(${Q} other profile${Q===1?"":"s"} hidden — wrong bundle ID or distribution mode)`},void 0,!1,void 0,this),!J&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),J?EB.jsxDEV(F0,{visibleOptionCount:ss,options:$,onChange:Y},void 0,!1,void 0,this):EB.jsxDEV(F0,{options:$,onChange:Y},void 0,!1,void 0,this),J&&X>0&&EB.jsxDEV(l,{dimColor:!0,children:`… +${X} more (↑/↓ to scroll)`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};function M10(A,Q,B,$){switch(A){case"apple-no-cert-match":return`Apple's records don't include the certificate "${Q}". It may have been revoked, never uploaded, or belong to a different team.`;case"apple-no-profiles-linked":return`Apple has the certificate "${Q}" but no provisioning profiles are linked to it yet.`;case"apple-bundle-mismatch":return`Apple has profiles for "${Q}" but none target "${B??"this app"}".`;case"apple-distribution-mismatch":return`Apple has profiles for "${B??"this app"}" under "${Q}" but none are ${$??"the requested distribution"}.`;case"apple-other":return`Apple returned profiles for "${Q}" but none match this app.`;case"no-profile-on-disk":case void 0:return`No provisioning profile on this Mac is linked to "${Q}".`}}function N10(A,Q,B){switch(A){case"apple-no-cert-match":return"Pick a recovery path — the certificate needs to be re-issued in the Apple Developer Portal first.";case"apple-no-profiles-linked":return'Pick a recovery path — "Create a new App Store profile" makes one for this cert via the Apple API.';case"apple-bundle-mismatch":return`Pick a recovery path — "Create a new App Store profile" makes one for "${Q??"this app"}".`;case"apple-distribution-mismatch":return`Pick a recovery path — re-run with the matching distribution mode${B?` (other than ${B})`:""}, or create a new profile via the Apple API.`;case"apple-other":return"Pick a recovery path:";case"no-profile-on-disk":case void 0:return"The cert is in your Keychain but the matching profile isn't on disk. Pick a recovery path:"}}var AeA=({identityName:A,options:Q,reason:B,appId:$,importDistribution:J,onChange:Y})=>{return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(r6,{variant:"warning",children:M10(B,A,$,J)},void 0,!1,void 0,this),EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:N10(B,$,J)},void 0,!1,void 0,this),EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(F0,{options:Q,onChange:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},QeA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Creating a new App Store profile via Apple for your existing certificate..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"(Skipping cert creation — using the cert already in your Keychain.)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BeA=({identityName:A,dense:Q=!1,onChange:B})=>{let $=EB.jsxDEV(F0,{options:[{label:`\uD83D\uDD13 Export "${A}" now`,value:"go"},{label:"↩️ Back",value:"back"},{label:"✖ Exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(r6,{variant:"warning",children:"macOS will now ask permission to access your private key."},void 0,!1,void 0,this),!Q&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(GA,{flexDirection:"column",marginLeft:2,children:Q?EB.jsxDEV(EB.Fragment,{children:[EB.jsxDEV(l,{dimColor:!0,children:"1. macOS will pop up a Keychain permission dialog."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:`2. Click "Always Allow" so retries don't re-prompt.`},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"3. That's the only prompt — the rest is non-interactive."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):EB.jsxDEV(EB.Fragment,{children:[EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"1."},void 0,!1,void 0,this)," ","A Keychain dialog will pop up asking"," ",EB.jsxDEV(l,{bold:!0,children:'"security wants to use your confidential information"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"2."},void 0,!1,void 0,this)," ","Click"," ",EB.jsxDEV(l,{bold:!0,color:"green",children:'"Always Allow"'},void 0,!1,void 0,this)," ","so it doesn't ask again on retry"]},void 0,!0,void 0,this),EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"3."},void 0,!1,void 0,this)," ","That's the only prompt — the export is otherwise non-interactive"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!Q&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),$]},void 0,!0,void 0,this)},$eA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Exporting from Keychain — check for the macOS dialog..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"If you don't see a dialog, look behind other windows or check the menu bar."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var gQ=iA(M8(),1),YeA=()=>gQ.jsxDEV(GA,{marginTop:1,justifyContent:"center",children:gQ.jsxDEV(VB,{text:"Detecting project..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),XeA=({appId:A,dense:Q=!1,onChange:B})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:Q?0:1,children:[gQ.jsxDEV(BY,{text:"Detected Capacitor project",detail:A},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"Which platform do you want to set up?"},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:"\uD83C\uDF4E iOS",value:"ios"},{label:"\uD83E\uDD16 Android",value:"android"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),GeA=({iosDir:A,addIosCommand:Q,syncIosCommand:B,dense:$=!1,onChange:J})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:$?0:1,children:[gQ.jsxDEV($Y,{text:`No ${A}/ directory found.`},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:$?"Onboarding needs a generated native iOS project before creating credentials.":"This onboarding flow needs a generated native iOS project before credentials can be created."},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:$?`Suggested: ${Q} && ${B}`:`Suggested commands: ${Q} && ${B}`},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:`\uD83D\uDEE0 Run ${Q} now`,value:"run"},{label:"\uD83D\uDD04 I already fixed it, re-check",value:"recheck"},{label:"✖ Exit onboarding",value:"exit"}],onChange:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),KeA=({addIosCommand:A,doctorCommand:Q,dense:B=!1})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(VB,{text:`Running ${A}...`},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:B?`If this fails, try ${Q} and keep the support bundle path from the error screen.`:`If this still fails, try ${Q} and keep the support bundle path from the error screen.`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),WeA=({dense:A=!1,onChange:Q})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:A?0:1,children:[gQ.jsxDEV($Y,{text:"Build failed."},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:"We can analyze the build log with Capgo AI and suggest a fix."},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCE8 Email Capgo support",value:"support"},{label:"\uD83E\uDD16 Debug with AI",value:"debug"},{label:"⏭ Skip",value:"skip"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ZeA=({streamText:A,terminalRows:Q,terminalCols:B})=>{let{rows:$,hidden:J}=vi(A??"",Q,B);return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(VB,{text:"Analyzing build log with Capgo AI..."},void 0,!1,void 0,this),$.length>0&&gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(l,{dimColor:!0,children:J>0?`… ${J} earlier line${J===1?"":"s"}`:" "},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:$.join(`
|
|
1103
|
+
`)}catch{YQ=["(could not read the logs file)"]}LD(YQ),U("support-log-view");return}let jA=qZ.current;qZ.current=null,jA?.(IA==="yes")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="error"&&p&&qA&&BQ.jsxDEV(lsA,{message:p,dense:!1,hasBuildLog:!!Y$,onChoose:(IA)=>{if(IA==="support")kX().catch((jA)=>{console.error("[support-flow]",jA)});else if(IA==="ai")U("ai-analysis-prompt");else if(IA==="retry"){b(null),T.current=void 0;let jA=qA;s(null),U(jA)}else k7("Run `capgo build init --platform android` to resume.")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},UtA=Y10;import{readFile as X10,unlink as G10}from"node:fs/promises";import{homedir as K10}from"node:os";import{join as nZA}from"node:path";var W10=".capgo-credentials",Z10="onboarding";function ItA(A){let Q=A||nZA(K10(),W10);return nZA(Q,Z10)}function H10(A){let Q=A.replace(/[/\\]/g,"_").replace(/\.\./g,"_");if(!Q||Q==="."||Q==="..")throw Error(`Invalid appId for progress file: "${A}"`);return Q}function oZA(A,Q){return nZA(ItA(Q),`${H10(A)}.json`)}async function x4(A,Q){let B=oZA(A,Q);try{let $=await X10(B,"utf-8");return JSON.parse($)}catch($){if($ instanceof Error&&"code"in $&&$.code==="ENOENT")return null;throw $}}async function GG(A,Q,B){let $=ItA(B);await _V($,448);let J=oZA(A,B);await zW(J,JSON.stringify(Q,null,2),{mode:384})}async function tv(A,Q){let B=oZA(A,Q);try{await G10(B)}catch{}}function ztA(A,Q=!0){if(!A)return"welcome";let{completedSteps:B,setupMethod:$}=A;if($==="import-existing"){if(!B.apiKeyVerified){if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";if(A.importDistribution==="ad_hoc")return"import-scanning";if(A.importDistribution==="app_store")return"api-key-instructions";return"import-distribution-mode"}return"import-scanning"}if(!B.apiKeyVerified){if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";if(A.p8CreateMethod==="automated"&&Q)return"asc-key-generating";return"api-key-instructions"}if(!B.certificateCreated)return"verify-app";if(!B.profileCreated)return"creating-profile";return"saving-credentials"}function rs(A){if(!A?.importDistribution)return"import-distribution-mode";if(A.importDistribution==="ad_hoc")return"import-pick-identity";if(A.issuerId&&A.keyId&&A.p8Path)return"verifying-key";if(A.keyId&&A.p8Path)return"input-issuer-id";if(A.p8Path)return"input-key-id";return"api-key-instructions"}function $M(A){return A.match(/(?:Auth|Api)Key_([A-Z0-9]+)\.p8$/i)?.[1]?.toUpperCase()??""}import{Buffer as AI}from"node:buffer";import{spawn as B80}from"node:child_process";import{existsSync as Hj,readFileSync as sZA}from"node:fs";import{copyFile as $80,mkdir as J80,readFile as Dj,writeFile as Y80}from"node:fs/promises";import{homedir as X80}from"node:os";import{dirname as G80,join as Bg,resolve as K80}from"node:path";import U7 from"node:process";FW();var $Q=iA(_0(),1);O4();var D10=/\s+/g,F10=new Set(["bunx","npx","pnpm exec","yarn dlx"]);function G4(A,Q){return`${A} ${Q.join(" ")}`}function TF(A){let Q=A.trim().replaceAll(D10," ");if(!F10.has(Q))throw Error(`Unsupported package manager runner: "${A}"`);let B=Q.split(" ").map((Y)=>Y.trim()).filter(Boolean),[$=A,...J]=B;return{command:$,args:J}}JB();function CtA(A){let Q=A.apps.find((B)=>B.bundleId===A.releaseBundleId)??null;if(Q)return{result:"exact-match",matchedApp:Q};if(A.apps.length>0)return{result:"wrong-build-id",matchedApp:null};if(A.registeredBundleIds.includes(A.releaseBundleId))return{result:"no-app-identifier-exists",matchedApp:null};return{result:"no-app-unregistered",matchedApp:null}}var q10=3;function ev(A){if(A.satisfied)return{proceed:!0,escalationLevel:0};return{proceed:!1,escalationLevel:Math.min(A.attempt,q10)}}import{readFileSync as OtA}from"node:fs";function NtA(A){if(!A)return[];let Q=/\w+\s*\/\*[^*]*\*\/\s*=\s*\{[^{}]*(?:\{[^}]*\}[^{}]*)*\}/g,B=[];for(let $ of A.matchAll(Q)){let J=$[0];if(!J.includes("XCBuildConfiguration"))continue;let Y=J.match(/name\s*=\s*("[^"]*"|[^;\s]+)\s*;/),X=J.match(/PRODUCT_BUNDLE_IDENTIFIER\s*=\s*"?([^";\s]+)"?\s*;/);if(!Y||!X)continue;let G=Y[1].replace(/^"|"$/g,""),K=X[1];if(K.includes("$("))continue;B.push({value:K,configName:G})}return B}function MtA(A,Q){return A.filter((B)=>B.configName===Q).sort((B,$)=>B.value.length-$.value.length)[0]}function LtA(A){let Q=NtA(A),B=MtA(Q,"Release"),$=MtA(Q,"Debug"),J=B?{value:B.value,source:"pbxproj-release",label:"project.pbxproj (Release config)"}:null,Y=$?{value:$.value,source:"pbxproj-debug",label:"project.pbxproj (Debug config)"}:null;return{release:J,debug:Y,releaseResolved:J!==null}}function U10(A){let{release:Q}=LtA(A);if(Q)return Q;let B=NtA(A);if(B.length===0)return null;let $=B.slice().sort((J,Y)=>J.value.length-Y.value.length)[0];return{value:$.value,source:"pbxproj-fallback",label:`project.pbxproj (${$.configName} config)`}}function I10(A){if(!A)return null;let Q=A.match(/<key>CFBundleIdentifier<\/key>\s*<string>([^<]+)<\/string>/);if(!Q)return null;let B=Q[1].trim();if(!B||B.includes("$("))return null;return{value:B,source:"plist",label:"Info.plist (CFBundleIdentifier)"}}function Zj(A){let{cwd:Q,iosDir:B,capacitorAppId:$}=A,J={value:$,source:"capacitor-config",label:"capacitor.config.ts (appId)"},Y=null,X=null,G=!1,K=null,W=xV(`${Q}/${B}`)??xV(Q);if(W)try{let O=OtA(W,"utf-8"),V=LtA(O);X=V.debug,G=V.releaseResolved,Y=V.release??U10(O)}catch{}let H=[`${Q}/${B}/App/App/Info.plist`,`${Q}/${B}/App/Info.plist`];for(let O of H)try{let V=OtA(O,"utf-8");if(K=I10(V),K)break}catch{}let F=new Set,q=[];for(let O of[Y,K,J]){if(!O||F.has(O.value))continue;F.add(O.value),q.push(O)}let U=q[0],I=U.value!==J.value,z=G&&X!==null&&Y!==null&&X.value!==Y.value;return{pbxproj:Y,debug:X,plist:K,capacitor:J,recommended:U,mismatch:I,debugReleaseDiffer:z,releaseResolved:G,candidates:q}}function VtA(A,Q,B,$){let J=A.toLowerCase(),Y=[],X=new Set,G=new Set,K=G4(B,["cap","add","ios"]),W=G4(B,["cap","sync","ios"]),H=G4(B,["@capgo/cli@latest","doctor"]),F=G4(B,["@capgo/cli@latest","build","init"]),q=G4(B,["@capgo/cli@latest","build","request",$,"--platform","ios"]),U=G4(B,["@capgo/cli@latest","login"]);if(Q==="no-platform"||Q==="adding-platform"||J.includes("no ios/ directory"))Y.push("This project does not have a generated native iOS folder yet.","Create the iOS platform, then sync native sources before resuming onboarding."),X.add(K),X.add(W);if(J.includes("required agreement")||J.includes("agreements, tax, and banking")||J.includes("program license agreement")||J.includes("pla_not_accepted")||J.includes("pla update available"))Y.push("Apple is blocking App Store Connect API access because a required agreement is unsigned or has expired.","Your API key is fine — the Account Holder must accept the agreement in App Store Connect, then retry the saved step."),G.add("https://appstoreconnect.apple.com/agreements");else if(J.includes("api key verification failed")||J.includes("401")||J.includes("403"))Y.push("Apple rejected the App Store Connect credentials.","Double-check the .p8 file, Key ID, Issuer ID, and that the key still has Admin or Developer access."),G.add("https://capgo.app/docs/cli/cloud-build/ios/"),G.add("https://appstoreconnect.apple.com/access/integrations/api");if(J.includes("fetch failed")||J.includes("network")||J.includes("etimedout")||J.includes("enotfound")||J.includes("econnreset"))Y.push("The CLI could not reach Apple or Capgo over the network.","Check VPN, proxy, firewall, and DNS settings, then retry from the saved step."),X.add(H);if(J.includes("429")||J.includes("rate limit"))Y.push("Apple is rate-limiting the request right now.","Wait a minute, then retry from the saved step instead of restarting the whole flow.");if(J.includes("certificate limit"))Y.push("Apple has reached the maximum number of active distribution certificates for this team.");if(J.includes("duplicate profile"))Y.push("Apple still has conflicting provisioning profiles for this bundle identifier.","You can let onboarding delete the duplicates automatically, or clean them up in App Store Connect and resume."),G.add("https://appstoreconnect.apple.com/access/users");if(J.includes("bundle")&&J.includes("identifier"))Y.push("Apple reported a bundle identifier conflict or bundle registration issue.",`Verify that ${$} is the bundle ID you intend to build for in both Capgo and your Capacitor config.`),X.add(H);if(J.includes("file not found")||J.includes("could not read file")||J.includes("need .p8 file"))Y.push("The onboarding flow could not read the API key file from disk.","Re-select the .p8 file or move it somewhere stable before retrying.");if(J.includes("no capgo api key found"))Y.push("Capgo login is missing, so the first cloud build cannot be requested automatically."),X.add(U),X.add(q);if(J.includes("credentials are saved"))Y.push("Your signing material is already saved locally, so you only need to re-run the build request."),X.add(q);if(Y.length===0)Y.push("The onboarding flow hit an unexpected error.","Retry the saved step first. If it still fails, capture diagnostics and keep the support bundle when you contact support."),X.add(H),X.add(F),G.add("https://capgo.app/docs/cli/cloud-build/ios/");else X.add(F);return{summary:Y,commands:Array.from(X),docs:Array.from(G)}}var QZ={welcome:0,"resume-prompt":2,"platform-select":0,"adding-platform":0,"credentials-exist":0,"backing-up":0,"setup-method-select":5,"import-scanning":10,"import-distribution-mode":15,"import-pick-identity":40,"import-pick-profile":55,"import-validating-all-certs":38,"import-checking-apple-cert":50,"import-no-match-recovery":55,"import-portal-explanation":56,"import-provide-profile-path":58,"import-create-profile-only":60,"import-export-warning":70,"import-exporting":75,"p8-source-select":6,"asc-key-generating":22,"asc-key-created":24,"api-key-instructions":5,"p8-method-select":8,"input-p8-path":10,"input-key-id":12,"input-issuer-id":18,"verifying-key":25,"verify-app":30,"creating-certificate":45,"cert-limit-prompt":45,"revoking-certificate":48,"creating-profile":65,"duplicate-profile-prompt":65,"deleting-duplicate-profiles":68,"saving-credentials":80,"detecting-ci-secrets":82,"ci-secrets-setup":82,"ci-secrets-target-select":82,"ask-ci-secrets":82,"checking-ci-secrets":83,"confirm-ci-secret-overwrite":83,"uploading-ci-secrets":84,"ci-secrets-failed":84,"ask-github-actions-setup":82,"confirm-secrets-push":83,"ask-export-env":95,"exporting-env":96,"confirm-env-export-overwrite":96,"overwrite-and-export-env":96,"pick-package-manager":95,"pick-build-script":96,"pick-build-script-custom":96,"preview-workflow-file":97,"view-workflow-diff":97,"writing-workflow-file":98,"ask-build":85,"requesting-build":90,"ai-analysis-prompt":92,"ai-analysis-running":95,"ai-analysis-result-scroll":97,"ai-analysis-result":98,"build-complete":100,"no-platform":0,error:0,"support-confirm":0,"support-log-view":0,"support-uploading":0};function aZA(A){switch(A){case"welcome":case"platform-select":case"adding-platform":case"credentials-exist":case"backing-up":return"";case"resume-prompt":return"Resume or restart?";case"setup-method-select":return"Setup method";case"verify-app":return"Verify App Store app";case"import-scanning":return"Step 1 of 4 · Scanning your Mac";case"import-distribution-mode":return"Step 1 of 4 · Distribution mode";case"import-pick-identity":return"Step 2 of 4 · Choose certificate";case"import-validating-all-certs":return"Step 2 of 4 · Validating certificates with Apple";case"import-pick-profile":return"Step 3 of 4 · Choose provisioning profile";case"import-checking-apple-cert":return"Step 3 of 4 · Checking certificate on Apple";case"import-no-match-recovery":return"Step 3 of 4 · No matching profile — recover";case"import-portal-explanation":return"Step 3 of 4 · Manual portal walkthrough";case"import-provide-profile-path":return"Step 3 of 4 · Provide .mobileprovision file";case"import-create-profile-only":return"Step 3 of 4 · Creating profile via Apple";case"import-export-warning":case"import-exporting":return"Step 4 of 4 · Export from Keychain";case"p8-source-select":case"asc-key-generating":case"asc-key-created":case"api-key-instructions":case"p8-method-select":case"input-p8-path":case"input-key-id":case"input-issuer-id":case"verifying-key":return"Step 1 of 4 · App Store Connect API Key";case"creating-certificate":case"cert-limit-prompt":case"revoking-certificate":return"Step 2 of 4 · Distribution Certificate";case"creating-profile":case"duplicate-profile-prompt":case"deleting-duplicate-profiles":return"Step 3 of 4 · Provisioning Profile";case"saving-credentials":case"detecting-ci-secrets":case"ci-secrets-setup":case"ci-secrets-target-select":case"ask-ci-secrets":case"ask-github-actions-setup":case"confirm-secrets-push":case"checking-ci-secrets":case"confirm-ci-secret-overwrite":case"uploading-ci-secrets":case"ci-secrets-failed":case"ask-export-env":case"exporting-env":case"confirm-env-export-overwrite":case"overwrite-and-export-env":case"pick-package-manager":case"pick-build-script":case"pick-build-script-custom":case"preview-workflow-file":case"view-workflow-diff":case"writing-workflow-file":case"ask-build":case"requesting-build":return"Step 4 of 4 · Save & Build";case"ai-analysis-prompt":case"ai-analysis-running":case"ai-analysis-result":case"ai-analysis-result-scroll":return"AI debug";case"build-complete":return"Complete";case"no-platform":case"error":case"support-confirm":case"support-log-view":case"support-uploading":return""}}var T1=iA(M8(),1),z10=3,EtA=()=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:T1.jsxDEV(VB,{text:"Checking git hosting..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),RtA=({advice:A,onChange:Q})=>{let B=T1.jsxDEV(F0,{options:[{label:"I installed and logged in, check again",value:"retry"},{label:"Skip upload",value:"skip"}],onChange:Q},void 0,!1,void 0,this);return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,children:"Set up your git hosting CLI to upload env vars"},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),A.map(($)=>T1.jsxDEV(GA,{flexDirection:"column",marginBottom:1,children:[T1.jsxDEV(l,{children:$.target.label},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:$.message},void 0,!1,void 0,this),$.commands.map((J)=>T1.jsxDEV(l,{color:"cyan",children:J},`${$.target.provider}-${J}`,!1,void 0,this))]},$.target.provider,!0,void 0,this)),T1.jsxDEV(l,{dimColor:!0,children:"Run this in another terminal, then come back here."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),B]},void 0,!0,void 0,this)},jtA=({options:A,dense:Q=!1,onChange:B})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,children:"Where should Capgo upload the build env vars?"},void 0,!1,void 0,this),!Q&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),Q?T1.jsxDEV(F0,{visibleOptionCount:z10,options:A,onChange:B},void 0,!1,void 0,this):T1.jsxDEV(F0,{options:A,onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),wtA=({entryCount:A,target:Q,targetLabel:B,dense:$=!1,onChange:J})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(BY,{text:"Credentials saved"},void 0,!1,void 0,this),!$&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{bold:!0,children:`Upload ${A} build env var${A===1?"":"s"} to ${B}?`},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:$?"Capgo checks for existing names first and asks before replacing anything.":"Capgo will check for existing names first and ask before replacing anything."},void 0,!1,void 0,this),!$&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:[{label:`Upload with ${Q?.cli||"CLI"}`,value:"yes"},{label:"Skip",value:"no"}],onChange:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C10=[{label:"Replace existing env vars",value:"replace"},{label:"Skip upload",value:"skip"}],_tA=({existingKeys:A,onChange:Q})=>{return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(l,{bold:!0,color:"yellow",children:"These env vars already exist and will be replaced:"},void 0,!1,void 0,this),T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,marginLeft:2,children:A.map((B)=>T1.jsxDEV(l,{children:`• ${B}`},B,!1,void 0,this))},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:C10,onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},O10=[{label:"Try upload again",value:"retry"},{label:"Continue without upload",value:"continue"}],PtA=({error:A,onChange:Q})=>{return T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV($Y,{text:A||"Could not upload env vars."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{dimColor:!0,children:"You can continue; credentials are already saved locally."},void 0,!1,void 0,this),T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:O10,onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},TtA=({dense:A=!1,onChange:Q})=>T1.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[T1.jsxDEV(BY,{text:"Credentials saved"},void 0,!1,void 0,this),!A&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(l,{bold:!0,children:"Start your first cloud build now?"},void 0,!1,void 0,this),!A&&T1.jsxDEV(lA,{},void 0,!1,void 0,this),T1.jsxDEV(F0,{options:[{label:"\uD83D\uDE80 Yes, build now",value:"yes"},{label:"⏭️ No, I'll build later",value:"no"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var RQ=iA(M8(),1),ktA=({appId:A,dense:Q=!1,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,color:"yellow",children:["⚠ iOS credentials already exist for"," ",A]},void 0,!0,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{children:Q?"New certs and profiles will replace your existing credentials.":"Onboarding will create new certificates and profiles, replacing your existing credentials."},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCE6 Start fresh (backup existing credentials first)",value:"backup"},{label:"✖ Exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),StA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Backing up existing credentials..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),xtA=({dense:A=!1,onChange:Q})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"How do you want to set up iOS credentials?"},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83C\uDD95 Create new via App Store Connect API",value:"create"},{label:"\uD83D\uDCE5 Import existing from this Mac (Keychain + Xcode profiles)",value:"import"}],onChange:Q},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:A?"Tip: Import reuses Xcode's cert, so it skips Apple's 3-cert limit.":"Tip: Importing reuses the certificate Xcode already installed, so it doesn't count against Apple's 3-cert limit."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),btA=({dense:A=!1,canAutomate:Q,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"Do you already have an App Store Connect API key (.p8 file)?"},void 0,!1,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:Q?"✨ No — create one for me (guided, opens a window)":"\uD83C\uDD95 No — I will create one at App Store Connect",value:"create"},{label:"✓ Yes — I have a .p8 file",value:"have"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ftA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Guiding you through App Store Connect — finish in the window that opened…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),vtA=({keyId:A,onContinue:Q})=>{return u4((B,$)=>{if($.return)Q()}),RQ.jsxDEV(GA,{flexGrow:1,alignItems:"center",justifyContent:"center",children:RQ.jsxDEV(GA,{flexDirection:"column",alignItems:"center",borderStyle:"round",borderColor:"green",paddingX:6,paddingY:1,children:[RQ.jsxDEV(l,{children:"\uD83C\uDF89"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(l,{bold:!0,color:"green",children:"App Store Connect API key created"},void 0,!1,void 0,this)},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,flexDirection:"column",alignItems:"center",children:[RQ.jsxDEV(l,{children:"Your key was created and validated with Apple."},void 0,!1,void 0,this),A?RQ.jsxDEV(l,{dimColor:!0,children:`Key ID: ${A}`},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(l,{bold:!0,color:"cyan",children:"Press Enter to continue →"},void 0,!1,void 0,this)},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:"This closes the helper window and finishes your setup here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},gtA=({canUseFilePicker:A,canCreateGuided:Q=!1,dense:B=!1,onMethodChange:$,onPathSubmit:J})=>{let Y=A?RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:"How do you want to provide the .p8 file?"},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCC2 Open file picker",value:"picker"},{label:"\uD83D\uDCDD Type the path",value:"manual"},...Q?[{label:"✨ Create one for me instead (guided)",value:"guided"}]:[]],onChange:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this):RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:"Path to your .p8 file:"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"~/Downloads/AuthKey_XXXXXXXXXX.p8",onSubmit:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(r6,{variant:"info",children:"We need an App Store Connect API key to manage certificates and profiles for you."},void 0,!1,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{flexDirection:"column",marginLeft:2,children:[RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"1."},void 0,!1,void 0,this)," ","Go to"," ",RQ.jsxDEV(l,{color:"cyan",underline:!0,children:"appstoreconnect.apple.com/access/integrations/api"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"2."},void 0,!1,void 0,this)," ","Click"," ",RQ.jsxDEV(l,{bold:!0,children:'"Generate API Key"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"3."},void 0,!1,void 0,this)," ","Name it"," ",RQ.jsxDEV(l,{color:"yellow",children:'"Capgo Builder"'},void 0,!1,void 0,this)," ","· Access:"," ",RQ.jsxDEV(l,{bold:!0,color:"green",children:'"Admin"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(l,{children:[RQ.jsxDEV(l,{bold:!0,color:"white",children:"4."},void 0,!1,void 0,this)," ","Download the"," ",RQ.jsxDEV(l,{bold:!0,children:".p8"},void 0,!1,void 0,this)," ","file"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{children:[RQ.jsxDEV(l,{dimColor:!0,children:"Press "},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,color:"white",children:"Ctrl+O"},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:" to open App Store Connect in your browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(w2,{},void 0,!1,void 0,this),RQ.jsxDEV(lA,{},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this)},ytA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Opening file picker..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),htA=({onSubmit:A})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,children:"Path to your .p8 file:"},void 0,!1,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"~/Downloads/AuthKey_XXXXXXXXXX.p8",onSubmit:A},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),utA=({keyId:A,dense:Q=!1,onSubmit:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:A?RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:["Key ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:"(detected from filename)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:[RQ.jsxDEV(l,{color:"green",children:"✔ "},void 0,!1,void 0,this),RQ.jsxDEV(l,{children:A},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:Q?" — Enter to confirm, or type another":" — press Enter to confirm, or type a different one"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:A,onSubmit:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):RQ.jsxDEV(RQ.Fragment,{children:[RQ.jsxDEV(l,{bold:!0,children:["Key ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:"(shown next to the key name in App Store Connect)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"ABC123DEF",onSubmit:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),mtA=({dense:A=!1,onSubmit:Q})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(l,{bold:!0,children:["Issuer ID"," ",RQ.jsxDEV(l,{dimColor:!0,children:A?"(UUID at the top of the API keys page)":"(UUID at the very top of the API keys page, above the key list)"},void 0,!1,void 0,this),":"]},void 0,!0,void 0,this),!A&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(GA,{children:[RQ.jsxDEV(l,{dimColor:!0,children:"Press "},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,color:"white",children:"Ctrl+O"},void 0,!1,void 0,this),RQ.jsxDEV(l,{dimColor:!0,children:" to open App Store Connect in your browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),RQ.jsxDEV(GA,{marginTop:1,children:RQ.jsxDEV(O6,{placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",onSubmit:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ctA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Verifying API key with Apple..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),dtA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(VB,{text:"Generating signing key and CSR..."},void 0,!1,void 0,this),RQ.jsxDEV(VB,{text:"Creating Apple Distribution certificate..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ltA=({existingCount:A,options:Q,dense:B=!1,onChange:$})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV($Y,{text:`Apple Distribution certificate limit reached (${A} existing).`},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,children:"Select a certificate to revoke:"},void 0,!1,void 0,this),!B&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:Q,onChange:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ptA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Revoking old certificate..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),itA=({appId:A,dense:Q=!1})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV(BY,{text:"Bundle ID",detail:A},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(VB,{text:"Creating App Store provisioning profile..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ntA=({duplicateCount:A,dense:Q=!1,onChange:B})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[RQ.jsxDEV($Y,{text:`Found ${A} existing Capgo profile(s) for this app.`},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(l,{bold:!0,children:"Delete old profiles and create a new one?"},void 0,!1,void 0,this),!Q&&RQ.jsxDEV(lA,{},void 0,!1,void 0,this),RQ.jsxDEV(F0,{options:[{label:"✔ Yes, delete old profiles and recreate",value:"delete"},{label:"✖ No, exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),otA=({duplicateCount:A})=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:`Deleting ${A} old profile(s)...`},void 0,!1,void 0,this)},void 0,!1,void 0,this),atA=()=>RQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:RQ.jsxDEV(VB,{text:"Saving credentials..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);var EB=iA(M8(),1),ss=3,rtA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Scanning Keychain and provisioning profiles..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"This is read-only — no Keychain password prompt yet."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),stA=({dense:A=!1,onChange:Q})=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:"How will Capgo distribute your build?"},void 0,!1,void 0,this),!A&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:A?"• App Store: auto-uploads to TestFlight (needs an ASC API key).":"• App Store: builds upload to TestFlight automatically (requires an App Store Connect API key)"},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:A?"• Ad-hoc: signed build, downloaded from Capgo or via QR. No ASC key.":"• Ad-hoc: builds are signed and either downloaded from Capgo or installed via QR. No ASC key needed."},void 0,!1,void 0,this),!A&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(F0,{options:[{label:"\uD83D\uDEEB App Store / TestFlight",value:"app_store"},{label:"\uD83D\uDCE6 Ad-hoc (no TestFlight upload)",value:"ad_hoc"},{label:"↩️ Cancel and use Create new instead",value:"__cancel__"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ttA=({identityCount:A,options:Q,dense:B=!1,onChange:$})=>{let J=Math.max(0,Q.length-ss);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:`Found ${A} distribution identit${A===1?"y":"ies"} in your Keychain. Pick one:`},void 0,!1,void 0,this),!B&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),B?EB.jsxDEV(F0,{visibleOptionCount:ss,options:Q,onChange:$},void 0,!1,void 0,this):EB.jsxDEV(F0,{options:Q,onChange:$},void 0,!1,void 0,this),B&&J>0&&EB.jsxDEV(l,{dimColor:!0,children:`… +${J} more (↑/↓ to scroll)`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},etA=({matchedCount:A,droppedCount:Q,distribution:B,options:$,dense:J=!1,onChange:Y})=>{let X=Math.max(0,$.length-ss);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(l,{bold:!0,children:J?`Pick a profile (${A} match this app's bundle ID${B?`, ${B}`:""}):`:`Pick a provisioning profile (${A} matching this app's bundle ID${B?` and ${B} distribution`:""}):`},void 0,!1,void 0,this),Q>0&&EB.jsxDEV(l,{dimColor:!0,children:J?`(${Q} hidden — wrong bundle ID or distribution)`:`(${Q} other profile${Q===1?"":"s"} hidden — wrong bundle ID or distribution mode)`},void 0,!1,void 0,this),!J&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),J?EB.jsxDEV(F0,{visibleOptionCount:ss,options:$,onChange:Y},void 0,!1,void 0,this):EB.jsxDEV(F0,{options:$,onChange:Y},void 0,!1,void 0,this),J&&X>0&&EB.jsxDEV(l,{dimColor:!0,children:`… +${X} more (↑/↓ to scroll)`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};function M10(A,Q,B,$){switch(A){case"apple-no-cert-match":return`Apple's records don't include the certificate "${Q}". It may have been revoked, never uploaded, or belong to a different team.`;case"apple-no-profiles-linked":return`Apple has the certificate "${Q}" but no provisioning profiles are linked to it yet.`;case"apple-bundle-mismatch":return`Apple has profiles for "${Q}" but none target "${B??"this app"}".`;case"apple-distribution-mismatch":return`Apple has profiles for "${B??"this app"}" under "${Q}" but none are ${$??"the requested distribution"}.`;case"apple-other":return`Apple returned profiles for "${Q}" but none match this app.`;case"no-profile-on-disk":case void 0:return`No provisioning profile on this Mac is linked to "${Q}".`}}function N10(A,Q,B){switch(A){case"apple-no-cert-match":return"Pick a recovery path — the certificate needs to be re-issued in the Apple Developer Portal first.";case"apple-no-profiles-linked":return'Pick a recovery path — "Create a new App Store profile" makes one for this cert via the Apple API.';case"apple-bundle-mismatch":return`Pick a recovery path — "Create a new App Store profile" makes one for "${Q??"this app"}".`;case"apple-distribution-mismatch":return`Pick a recovery path — re-run with the matching distribution mode${B?` (other than ${B})`:""}, or create a new profile via the Apple API.`;case"apple-other":return"Pick a recovery path:";case"no-profile-on-disk":case void 0:return"The cert is in your Keychain but the matching profile isn't on disk. Pick a recovery path:"}}var AeA=({identityName:A,options:Q,reason:B,appId:$,importDistribution:J,onChange:Y})=>{return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(r6,{variant:"warning",children:M10(B,A,$,J)},void 0,!1,void 0,this),EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:N10(B,$,J)},void 0,!1,void 0,this),EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(F0,{options:Q,onChange:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},QeA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Creating a new App Store profile via Apple for your existing certificate..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"(Skipping cert creation — using the cert already in your Keychain.)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),BeA=({identityName:A,dense:Q=!1,onChange:B})=>{let $=EB.jsxDEV(F0,{options:[{label:`\uD83D\uDD13 Export "${A}" now`,value:"go"},{label:"↩️ Back",value:"back"},{label:"✖ Exit onboarding",value:"exit"}],onChange:B},void 0,!1,void 0,this);return EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(r6,{variant:"warning",children:"macOS will now ask permission to access your private key."},void 0,!1,void 0,this),!Q&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),EB.jsxDEV(GA,{flexDirection:"column",marginLeft:2,children:Q?EB.jsxDEV(EB.Fragment,{children:[EB.jsxDEV(l,{dimColor:!0,children:"1. macOS will pop up a Keychain permission dialog."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:`2. Click "Always Allow" so retries don't re-prompt.`},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"3. That's the only prompt — the rest is non-interactive."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):EB.jsxDEV(EB.Fragment,{children:[EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"1."},void 0,!1,void 0,this)," ","A Keychain dialog will pop up asking"," ",EB.jsxDEV(l,{bold:!0,children:'"security wants to use your confidential information"'},void 0,!1,void 0,this)]},void 0,!0,void 0,this),EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"2."},void 0,!1,void 0,this)," ","Click"," ",EB.jsxDEV(l,{bold:!0,color:"green",children:'"Always Allow"'},void 0,!1,void 0,this)," ","so it doesn't ask again on retry"]},void 0,!0,void 0,this),EB.jsxDEV(l,{children:[EB.jsxDEV(l,{bold:!0,color:"white",children:"3."},void 0,!1,void 0,this)," ","That's the only prompt — the export is otherwise non-interactive"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!Q&&EB.jsxDEV(lA,{},void 0,!1,void 0,this),$]},void 0,!0,void 0,this)},$eA=()=>EB.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[EB.jsxDEV(VB,{text:"Exporting from Keychain — check for the macOS dialog..."},void 0,!1,void 0,this),EB.jsxDEV(l,{dimColor:!0,children:"If you don't see a dialog, look behind other windows or check the menu bar."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);var gQ=iA(M8(),1),YeA=()=>gQ.jsxDEV(GA,{marginTop:1,justifyContent:"center",children:gQ.jsxDEV(VB,{text:"Detecting project..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),XeA=({appId:A,dense:Q=!1,onChange:B})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:Q?0:1,children:[gQ.jsxDEV(BY,{text:"Detected Capacitor project",detail:A},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"Which platform do you want to set up?"},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:"\uD83C\uDF4E iOS",value:"ios"},{label:"\uD83E\uDD16 Android",value:"android"}],onChange:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),GeA=({iosDir:A,addIosCommand:Q,syncIosCommand:B,dense:$=!1,onChange:J})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:$?0:1,children:[gQ.jsxDEV($Y,{text:`No ${A}/ directory found.`},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:$?"Onboarding needs a generated native iOS project before creating credentials.":"This onboarding flow needs a generated native iOS project before credentials can be created."},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:$?`Suggested: ${Q} && ${B}`:`Suggested commands: ${Q} && ${B}`},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:`\uD83D\uDEE0 Run ${Q} now`,value:"run"},{label:"\uD83D\uDD04 I already fixed it, re-check",value:"recheck"},{label:"✖ Exit onboarding",value:"exit"}],onChange:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),KeA=({addIosCommand:A,doctorCommand:Q,dense:B=!1})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(VB,{text:`Running ${A}...`},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:B?`If this fails, try ${Q} and keep the support bundle path from the error screen.`:`If this still fails, try ${Q} and keep the support bundle path from the error screen.`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),WeA=({dense:A=!1,onChange:Q})=>gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,gap:A?0:1,children:[gQ.jsxDEV($Y,{text:"Build failed."},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:"We can analyze the build log with Capgo AI and suggest a fix."},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[{label:"\uD83D\uDCE8 Email Capgo support",value:"support"},{label:"\uD83E\uDD16 Debug with AI",value:"debug"},{label:"⏭ Skip",value:"skip"}],onChange:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ZeA=({streamText:A,terminalRows:Q,terminalCols:B})=>{let{rows:$,hidden:J}=vi(A??"",Q,B);return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(VB,{text:"Analyzing build log with Capgo AI..."},void 0,!1,void 0,this),$.length>0&&gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(l,{dimColor:!0,children:J>0?`… ${J} earlier line${J===1?"":"s"}`:" "},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:$.join(`
|
|
1104
1104
|
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},HeA=({analysisText:A,collapsed:Q,result:B,canRetry:$,retriesLeft:J,maxRetries:Y,dense:X=!1,onChange:G})=>{let K=J===1?"\uD83D\uDD04 I fixed it, retry build (last retry)":`\uD83D\uDD04 I fixed it, retry build (${J} retries left)`;return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(l,{bold:!0,color:"cyan",children:"AI analysis"},void 0,!1,void 0,this),!X&&gQ.jsxDEV(lA,{},void 0,!1,void 0,this),A&&!Q&&gQ.jsxDEV(l,{children:A},void 0,!1,void 0,this),A&&Q&&gQ.jsxDEV(l,{dimColor:!0,children:"\uD83D\uDCD6 Analysis reviewed — pick an option below, or re-read it."},void 0,!1,void 0,this),B&&gQ.jsxDEV(hi,{kind:B.kind,message:B.message,dense:X},void 0,!1,void 0,this),!X&&gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{color:"yellow",children:X?"⚠ AI can make mistakes. Verify the diagnosis against the full log before applying the fix.":"⚠ AI can make mistakes. Always verify the diagnosis against the full log before applying the suggested fix."},void 0,!1,void 0,this),!$&&gQ.jsxDEV(gQ.Fragment,{children:[!X&&gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:X?`You've used all ${Y} retries. Exit and re-run the wizard for another attempt.`:`You've used all ${Y} retries. Exit and re-run the wizard if you need another attempt.`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!X&&gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:[...$?[{label:K,value:"retry"},{label:"⏭ Continue (skip retry)",value:"skip"}]:[{label:"✔ Continue",value:"continue"}],{label:"\uD83D\uDCE8 Still stuck — email Capgo support",value:"support"},...Q?[{label:"\uD83D\uDCD6 Re-read analysis",value:"reread"}]:[]],onChange:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},JeA={label:"↩️ Restart onboarding",value:"restart"},L10={label:"✨ Create a new key for me (guided)",value:"guided-key"};function DeA(A,Q=!1){let B=vs({hasBuildLog:A}),$=B.findIndex((Y)=>Y.value==="exit"),J=$===-1?[...B,JeA]:[...B.slice(0,$),JeA,...B.slice($)];return Q?[L10,...J]:J}function FeA(A,Q,B){let $=[`✖ ${A}`,""];if(Q){$.push("Recovery plan","");for(let J of Q.summary)$.push(` • ${J}`);if(Q.commands.length>0){$.push("","Helpful commands","");for(let J of Q.commands)$.push(` ${J}`)}if(Q.docs.length>0){$.push("","Docs","");for(let J of Q.docs)$.push(` ${J}`)}}if(B)$.push("","Support bundle",B);return $}function Ag(A,Q){return Math.max(1,Math.ceil(A.length/Math.max(1,Q)))}function qeA(A,Q,B,$,J,Y,X=!1){let G=1;if(G+=Ag(`✖ ${A}`,$),G+=1,Q){G+=2;for(let K of Q.summary)G+=Ag(`• ${K}`,$-2);if(Q.commands.length>0){G+=3;for(let K of Q.commands)G+=Ag(K,$-2)}if(Q.docs.length>0){G+=3;for(let K of Q.docs)G+=Ag(K,$-2)}}if(B)G+=2+Ag(B,$);if(G+=1,J)G+=2+DeA(Y,X).length;return G}var UeA=({error:A,recoveryAdvice:Q,supportBundlePath:B,showRetry:$,collapsed:J=!1,hasBuildLog:Y=!1,showGuidedKey:X=!1,onChange:G})=>{let K=DeA(Y,X);if(J)return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV($Y,{text:A},void 0,!1,void 0,this),$&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"What do you want to do?"},void 0,!1,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:K,onChange:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV($Y,{text:A},void 0,!1,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),Q&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{bold:!0,children:"Recovery plan"},void 0,!1,void 0,this),gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,marginLeft:2,children:Q.summary.map((W)=>gQ.jsxDEV(l,{children:`• ${W}`},`recovery-summary-${W}`,!1,void 0,this))},void 0,!1,void 0,this),Q.commands.length>0&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"Helpful commands"},void 0,!1,void 0,this),gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,marginLeft:2,children:Q.commands.map((W)=>gQ.jsxDEV(l,{dimColor:!0,children:W},`recovery-command-${W}`,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.docs.length>0&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"Docs"},void 0,!1,void 0,this),gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,marginLeft:2,children:Q.docs.map((W)=>gQ.jsxDEV(l,{color:"cyan",children:W},`recovery-doc-${W}`,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{bold:!0,children:"Support bundle"},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),$&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{bold:!0,children:"What do you want to do?"},void 0,!1,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(F0,{options:K,onChange:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},IeA=({buildUrl:A,ciSecretUploadSummary:Q,buildRequestCommand:B,workflowWrittenPath:$=null,envExportPath:J=null,envExportError:Y=null})=>{let X=A?gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{children:"Your iOS app is building in the cloud."},void 0,!1,void 0,this),gQ.jsxDEV(l,{children:["Track it at"," ",gQ.jsxDEV(l,{color:"cyan",underline:!0,children:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):gQ.jsxDEV(l,{children:"Your iOS credentials are saved and ready to use."},void 0,!1,void 0,this),G=gQ.jsxDEV(l,{dimColor:!0,children:["Run"," ",gQ.jsxDEV(l,{bold:!0,color:"white",children:B},void 0,!1,void 0,this)," ","anytime to start a build."]},void 0,!0,void 0,this);return gQ.jsxDEV(GA,{flexDirection:"column",marginTop:1,children:[gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(GA,{borderStyle:"round",borderColor:"green",paddingX:3,paddingY:1,flexDirection:"column",alignItems:"center",children:[gQ.jsxDEV(l,{bold:!0,color:"green",children:"\uD83C\uDF89 You're all set!"},void 0,!1,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),X,gQ.jsxDEV(lA,{},void 0,!1,void 0,this),Q&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{children:`${Q}.`},void 0,!1,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{color:"green",children:["✔ Workflow file written:"," ",$]},void 0,!0,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:["Dispatch it from GitHub Actions to kick off a build, or run"," ",gQ.jsxDEV(l,{bold:!0,children:B},void 0,!1,void 0,this)," ","locally."]},void 0,!0,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{color:"green",children:["✔ Credentials exported to:"," ",J]},void 0,!0,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:["When you're ready, push them with"," ",gQ.jsxDEV(l,{bold:!0,children:`gh secret set -f ${J.split("/").slice(-1)[0]}`},void 0,!1,void 0,this)," ","(or your CI's equivalent). Add the file to"," ",gQ.jsxDEV(l,{bold:!0,children:".gitignore"},void 0,!1,void 0,this)," ","— never commit it."]},void 0,!0,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&gQ.jsxDEV(gQ.Fragment,{children:[gQ.jsxDEV(l,{color:"yellow",children:["⚠ Could not export .env:"," ",Y]},void 0,!0,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G]},void 0,!0,void 0,this),gQ.jsxDEV(lA,{},void 0,!1,void 0,this),gQ.jsxDEV(l,{dimColor:!0,children:"Press Enter to finish ›"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};import{homedir as CeA}from"node:os";import{join as OeA}from"node:path";function V10(A){let{completedSteps:Q}=A;if(!Q.credentialsSaved)return null;if(!Q.buildRequested)return"ask-build";if(!Q.ciSecretsUploaded){if(A.setupMode==="declined")return A.envExportTargetPath?"exporting-env":"ask-export-env";if(A.ciSecretTarget){if(A.ciSecretTarget.provider==="github"&&A.setupMode===void 0)return"ask-github-actions-setup";return"checking-ci-secrets"}return"detecting-ci-secrets"}if(A.setupMode==="with-workflow"){if(!A.selectedPackageManager)return"pick-package-manager";if(!A.buildScriptChoice)return"pick-build-script";return"writing-workflow-file"}return"build-complete"}function oJ(A,Q=!0){if(!A)return"welcome";if(A._credentialsExistGate==="pending")return"credentials-exist";if(A._credentialsExistGate==="backup")return"backing-up";let B=V10(A);if(B)return B;return ztA(A,Q)}function zeA(A,Q){return{path:"",uuid:A.id,name:A.name,applicationIdentifier:"",bundleId:A.bundleIdentifier,teamId:Q.teamId,expirationDate:A.expirationDate,profileType:A.profileType==="IOS_APP_STORE"?"app_store":A.profileType==="IOS_APP_ADHOC"?"ad_hoc":"unknown",certificateSha1s:[Q.sha1],profileBase64:A.profileContent}}var E10=new Set(["saving-credentials","detecting-ci-secrets","checking-ci-secrets","uploading-ci-secrets","exporting-env","overwrite-and-export-env","writing-workflow-file","requesting-build"]),R10=new Set(["ci-secrets-setup","ci-secrets-target-select","ask-ci-secrets","confirm-ci-secret-overwrite","ci-secrets-failed","ask-github-actions-setup","confirm-secrets-push","ask-export-env","confirm-env-export-overwrite","pick-package-manager","pick-build-script","pick-build-script-custom","preview-workflow-file","view-workflow-diff","ask-build","build-complete"]),j10=new Set(["ci-secrets-target-select","ask-github-actions-setup","ask-export-env","pick-package-manager","pick-build-script","pick-build-script-custom"]);async function w10(A,Q){let B=Q.carried,$=B?.certData??A.completedSteps.certificateCreated,J=B?.profileData??A.completedSteps.profileCreated;if(!$)throw Error("iOS certificate not provisioned");if(!J)throw Error("iOS provisioning profile not created");let Y=B?.teamId??$.teamId;if(!Y)throw Error("iOS team id missing");let X=A.setupMethod==="import-existing",G=X&&B?.importedP12Password?B.importedP12Password:Fv,W={[BZ(A,Q)]:{profile:J.profileBase64,name:J.profileName}},H=X?A.importDistribution||"app_store":"app_store",F={BUILD_CERTIFICATE_BASE64:$.p12Base64,P12_PASSWORD:G,CAPGO_IOS_PROVISIONING_MAP:JSON.stringify(W),APP_STORE_CONNECT_TEAM_ID:Y,CAPGO_IOS_DISTRIBUTION:H},q=!X||A.importDistribution==="app_store",U=B?.p8Content;if(q&&!U&&A.p8Path&&Q.readFile)try{U=await Q.readFile(A.p8Path)}catch{}if(q&&!U)throw Error("iOS ASC API key (.p8) unavailable — refusing to save credentials that cannot upload to App Store Connect. Re-provide the .p8 key file to continue.");if(q&&U){let I=A.completedSteps.apiKeyVerified,z=A.keyId??I?.keyId,O=A.issuerId??I?.issuerId;if(z)F.APPLE_KEY_ID=z;if(O)F.APPLE_ISSUER_ID=O;F.APPLE_KEY_CONTENT=U.toString("base64")}return F}function _10(A,Q){let B=A.completedSteps.certificateCreated,$=A.completedSteps.profileCreated;if(!B||!$||!B.teamId)return{};let Y={[BZ(A,Q)]:{profile:$.profileBase64,name:$.profileName}},X=A.setupMethod==="import-existing"?A.importDistribution||"app_store":"app_store",G=A.completedSteps.apiKeyVerified,K=A.keyId??G?.keyId,W=A.issuerId??G?.issuerId;return{BUILD_CERTIFICATE_BASE64:B.p12Base64,P12_PASSWORD:Fv,CAPGO_IOS_PROVISIONING_MAP:JSON.stringify(Y),APP_STORE_CONNECT_TEAM_ID:B.teamId,CAPGO_IOS_DISTRIBUTION:X,...K?{APPLE_KEY_ID:K}:{},...W?{APPLE_ISSUER_ID:W}:{}}}function P10(A){return{platform:"ios",buildSavedCredentials:(Q)=>w10(Q,A),rebuildTailCredentials:(Q)=>_10(Q,A),resumeStep:oJ,updateSavedCredentials:A.updateSavedCredentials,loadProgress:A.loadProgress,saveProgress:A.saveProgress,deleteProgress:A.deleteProgress,createCiSecretEntries:A.createCiSecretEntries,detectCiSecretTargets:A.detectCiSecretTargets,getCiSecretRepoLabelAsync:A.getCiSecretRepoLabelAsync,listExistingCiSecretKeysAsync:A.listExistingCiSecretKeysAsync,uploadCiSecretsAsync:A.uploadCiSecretsAsync,exportCredentialsToEnv:A.exportCredentialsToEnv,defaultExportPath:A.defaultExportPath,generateWorkflow:A.generateWorkflow,writeWorkflowFile:A.writeWorkflowFile,requestBuildInternal:A.requestBuildInternal,logger:A.logger,onBuildOutput:A.onBuildOutput,resolveApikey:A.resolveApikey,onCiSecretUploadProgress:A.onCiSecretUploadProgress,onCiSecretCheckPhase:A.onCiSecretCheckPhase,onCiSecretError:A.onCiSecretError,getPackageScripts:A.getPackageScripts,findProjectType:A.findProjectType,findBuildCommandForProjectType:A.findBuildCommandForProjectType,trackWorkflowEvent:A.trackWorkflowEvent,carried:A.carried,onStatus:A.onStatus,onLog:A.onLog,onInternalLog:A.onInternalLog,signal:A.signal}}function T10(A,Q){return{step:Q,kind:A.kind,title:A.title,prompt:A.prompt,collect:A.collect,options:A.options,message:A.message}}var k10=[{value:"create",label:"\uD83C\uDD95 Create new via App Store Connect API"},{value:"import",label:"\uD83D\uDCE5 Import existing from this Mac (Keychain + Xcode profiles)"}],S10=[{value:"picker",label:"\uD83D\uDCC2 Open file picker"},{value:"manual",label:"\uD83D\uDCDD Type the path"}],x10=[{value:"app_store",label:"\uD83D\uDEEB App Store / TestFlight"},{value:"ad_hoc",label:"\uD83D\uDCE6 Ad-hoc (no TestFlight upload)"},{value:"__cancel__",label:"↩️ Cancel and use Create new instead"}],b10={value:"__cancel__",label:"↩️ Cancel and use Create new instead"},f10={value:"__back__",label:"↩️ Back to identity selection"};function v10(A){return{value:"create",label:A?"✨ Create a new App Store profile for this cert via Apple":"✨ Provide ASC API key, then create a new App Store profile for this cert"}}var g10={value:"provide-profile-path",label:"\uD83D\uDCC1 Use a .mobileprovision file from disk"},y10={value:"browser",label:"\uD83C\uDF10 Open Apple Developer Portal (browse / create profiles manually)"},h10={value:"back",label:"↩️ Back to identity selection"},u10={value:"use-create",label:'✨ Use "Create a new App Store profile" instead (recommended)'};function m10(A){return{value:"open-anyway",label:A?"\uD83C\uDF10 Open the portal anyway (advanced)":"\uD83C\uDF10 Open Apple Developer Portal"}}var c10={value:"use-file",label:"\uD83D\uDCC1 I already have a .mobileprovision on disk — let me pick it"},d10={value:"back",label:"↩️ Back to recovery menu"};function l10(A){return{value:"go",label:`\uD83D\uDD13 Export "${A}" now`}}var p10={value:"back",label:"↩️ Back"},i10={value:"exit",label:"✖ Exit onboarding"};function n10(A,Q,B,$){switch(A){case"apple-no-cert-match":return`Apple's records don't include the certificate "${Q}". It may have been revoked, never uploaded, or belong to a different team.`;case"apple-no-profiles-linked":return`Apple has the certificate "${Q}" but no provisioning profiles are linked to it yet.`;case"apple-bundle-mismatch":return`Apple has profiles for "${Q}" but none target "${B??"this app"}".`;case"apple-distribution-mismatch":return`Apple has profiles for "${B??"this app"}" under "${Q}" but none are ${$??"the requested distribution"}.`;case"apple-other":return`Apple returned profiles for "${Q}" but none match this app.`;case"no-profile-on-disk":default:return`No provisioning profile on this Mac is linked to "${Q}".`}}var o10={value:"__exit__",label:"✖ Exit onboarding"},a10=[{value:"delete",label:"\uD83D\uDDD1️ Delete the duplicate profile(s) and create a fresh one"},{value:"exit",label:"✖ Exit onboarding"}],r10={value:"retry",label:"\uD83D\uDD04 Try again"},s10={value:"restart",label:"↩️ Restart onboarding"},t10={value:"exit",label:"❌ Exit"};function Qg(A,Q,B){if(R10.has(A))return T10(Kj(A,Q,B??{}),A);switch(A){case"setup-method-select":return{step:A,kind:"choice",title:"How do you want to set up iOS credentials?",options:k10};case"api-key-instructions":return{step:A,kind:"choice",title:"We need an App Store Connect API key to manage certificates and profiles for you.",prompt:"How do you want to provide the .p8 file?",options:S10};case"input-p8-path":return{step:A,kind:"input",prompt:"Path to your .p8 file:",collect:["p8Path"]};case"input-key-id":{let $=Q.keyId||$M(Q.p8Path??"");return{step:A,kind:"input",prompt:$?`Key ID (detected from filename): ${$} — press Enter to confirm, or type a different one`:"Key ID (shown next to the key name in App Store Connect):",collect:["keyId"]}}case"input-issuer-id":return{step:A,kind:"input",prompt:"Issuer ID (UUID at the very top of the API keys page, above the key list):",collect:["issuerId"]};case"cert-limit-prompt":{let $=B?.existingCerts??[],J=B?.certData?.certificateId??Q.completedSteps.certificateCreated?.certificateId,Y=[...$.map((X)=>{let G=J===X.id?" · \uD83D\uDD27 Created by Capgo":"";return{value:X.id,label:`\uD83D\uDDD1️ ${X.name} · expires ${X.expirationDate.split("T")[0]}${G}`}}),o10];return{step:A,kind:"choice",title:`Certificate limit reached — ${$.length} existing Apple Distribution certificate(s).`,prompt:"Pick a certificate to revoke (frees a slot to create a new one), or exit:",options:Y}}case"duplicate-profile-prompt":{let $=(B?.duplicateProfiles??[]).length;return{step:A,kind:"choice",title:$?`Found ${$} existing Capgo provisioning profile(s) for this app.`:"Found existing Capgo provisioning profile(s) for this app.",prompt:"Delete them and create a fresh one, or exit:",options:a10}}case"import-distribution-mode":return{step:A,kind:"choice",title:"How will Capgo distribute your build?",prompt:"App Store uploads to TestFlight (needs an ASC API key); Ad-hoc is signed for direct/QR install (no ASC key).",options:x10};case"import-pick-identity":{let $=B?.importMatches??[],J=B?.identityAvailability??{},Y=Object.keys(J).length>0,X=BZ(Q),G=Q.importDistribution,W=[...$.filter((H)=>{let F=J[H.identity.sha1];return!Y||F?.available}).map((H)=>{let F=GD(H.profiles,X,G).length;return{value:H.identity.sha1,label:F>0?`\uD83D\uDD11 ${H.identity.name} · ${F} matching profile${F===1?"":"s"}`:`\uD83D\uDD11 ${H.identity.name} · ⚠ no matching profiles on this Mac (recovery available)`}}),b10];return{step:A,kind:"choice",title:"Pick a signing identity to import.",prompt:"These are the iOS Distribution certificates in your Keychain. Pick one, or switch to creating a fresh cert + profile.",options:W}}case"import-pick-profile":{let $=B?.chosenIdentity,J=B?.importMatches??[],Y=$?J.find((H)=>H.identity.sha1===$.sha1)?.profiles??[]:[],X=BZ(Q),G=Q.importDistribution,W=[...GD(Y,X,G).map((H)=>({value:H.uuid,label:`\uD83D\uDCDC ${H.name} · bundle ${H.bundleId} · ${H.profileType} · expires ${H.expirationDate.split("T")[0]}`})),f10];return{step:A,kind:"choice",title:"Pick a provisioning profile to import.",prompt:"These profiles are linked to your chosen certificate and match this app. Pick one, or go back to change the identity.",options:W}}case"import-no-match-recovery":{let $=B?.noMatchReason,J=B?.chosenIdentity?.name??"your certificate",Y=BZ(Q),X=Q.importDistribution,G=!!(B?.p8Content||Q.p8Path),K=X!=="ad_hoc",W=B?.canUseFilePicker??!0,H=[...K?[v10(G)]:[],...W?[g10]:[],y10,h10];return{step:A,kind:"choice",title:n10($,J,Y,X),prompt:"Pick a recovery path:",options:H}}case"import-portal-explanation":{let $=Q.importDistribution!=="ad_hoc",J=B?.canUseFilePicker??!0,Y=[...$?[u10]:[],m10($),...J?[c10]:[],d10];return{step:A,kind:"choice",title:$?"You can do this manually in the Apple Developer Portal — but the automatic path is much easier.":"Ad-hoc distribution is genuinely fiddly (you also need to register every target device on Apple's side). Here's what's involved — and how to get help if you're stuck.",prompt:"Create the profile manually in the portal, or let Capgo do it automatically:",options:Y}}case"import-export-warning":{let $=B?.chosenIdentity?.name??"your signing identity";return{step:A,kind:"choice",title:"macOS will now ask permission to access your private key.",prompt:`A Keychain dialog will pop up — click "Always Allow" so retries don't re-prompt. That's the only prompt; the export is otherwise non-interactive.`,options:[l10($),p10,i10]}}case"verify-app":{if(!B?.verifyResult)return{step:A,kind:"auto",title:"Checking App Store Connect for your app..."};let $=B.verifyReleaseBundleId??"";if(B.verifyPath==="fix-build-id"&&B.verifyChosenApp)return{step:A,kind:"choice",title:`Build ID doesn't match "${B.verifyChosenApp.name}"`,options:[{value:"autofix",label:"\uD83D\uDD27 Update PRODUCT_BUNDLE_IDENTIFIER for me"},{value:"continue",label:"✅ I've edited it myself — re-check"},{value:"back",label:"↩ Back — pick a different app"},{value:"cancel",label:"❌ Cancel onboarding"}]};if(B.verifyPath==="create-app"){if(B.verifyAskReopen)return{step:A,kind:"choice",title:`Still no App Store app for ${$}`,options:[{value:"recheck",label:"\uD83D\uDD01 I've created it — re-check"},{value:"reopen",label:"\uD83C\uDF10 Re-open the create-app page"},{value:"cancel",label:"❌ Cancel onboarding"}]};return{step:A,kind:"choice",title:`No App Store app exists for ${$}`,options:[{value:"open",label:"\uD83C\uDF10 Open App Store Connect to create the app"},{value:"recheck",label:"\uD83D\uDD01 I've already created it — re-check"},...(B.verifyApps?.length??0)>0?[{value:"back",label:"↩ Back — pick an existing app"}]:[],{value:"cancel",label:"❌ Cancel onboarding"}]}}return{step:A,kind:"choice",title:`No App Store app matches the bundle ID your project builds (${$}).`,options:[...(B.verifyApps??[]).map((J)=>({value:J.bundleId,label:`${J.name} — ${J.bundleId}`})),{value:"__create_new__",label:"➕ None of these — my build ID is correct, create a new app"}]}}case"error":{let $=B?.error??"An error occurred.",J=[...B?.retryStep?[r10]:[],s10,t10];return{step:A,kind:"error",title:"Something went wrong",message:$,options:J}}default:return{step:A,kind:"auto",title:A}}}function IX(A,Q,B){if(j10.has(A))return AZ(A,Q,B);switch(A){case"setup-method-select":return{...Q,setupMethod:B.value==="import"?"import-existing":"create-new"};case"api-key-instructions":return Q;case"input-p8-path":{let J=B.value.trim();if(!J)return Q;return{...Q,p8Path:J}}case"input-key-id":{let $=B,J=Q.keyId||$M(Q.p8Path??""),Y=($.value||J).trim();if(!Y)return Q;return{...Q,keyId:Y}}case"input-issuer-id":{let J=B.value.trim();if(!J)return Q;return{...Q,issuerId:J}}case"cert-limit-prompt":return Q;case"duplicate-profile-prompt":return Q;case"verify-app":return Q;case"import-distribution-mode":{let $=B;if($.value==="__cancel__"){let{importDistribution:J,...Y}=Q;return{...Y,setupMethod:"create-new"}}return{...Q,setupMethod:"import-existing",importDistribution:$.value}}case"import-pick-identity":return Q;case"import-pick-profile":return Q;case"import-no-match-recovery":return Q;case"import-portal-explanation":return Q;case"import-export-warning":return Q;default:return Q}}function B$(A,Q,B,$){return{progress:A,next:"error",transient:{error:Q,...B?{retryStep:B}:{},...$}}}async function q7(A,Q,B){if(E10.has(A)){let $=await ps(A,Q,P10(B));return{progress:$.progress,next:$.next,transient:$.transient}}switch(A){case"backing-up":{let $=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),J=A80($);try{await B.copyFile?.(e10(),J),B.onLog?.(`✔ Backup saved · ${J}`)}catch(G){B.onInternalLog?.(`credentials backup failed: ${G instanceof Error?G.message:String(G)}`),B.onLog?.("⚠ Could not backup credentials (file may not exist yet)","yellow")}let Y={...Q,_credentialsExistGate:"done"};await B.saveProgress?.(Q.appId,Y);let X=B.isMacOS?B.isMacOS():!0;return{progress:Y,next:X?"setup-method-select":"api-key-instructions"}}case"p8-method-select":{if(B.carried?.pickerOpened)return{progress:Q,next:"input-p8-path",transient:{pickerOpened:!0}};let $=await B.openP8FilePicker?.();if(!$)return{progress:Q,next:"input-p8-path",transient:{pickerOpened:!0}};let J=await B.readFile($),Y=$M($),X={...Q,p8Path:$,...Y?{keyId:Y}:{}};return await B.saveProgress?.(Q.appId,X),B.onLog?.(`✔ Key file selected · ${$}`),{progress:X,next:"input-key-id",transient:{pickerOpened:!0,p8Content:J}}}case"verifying-key":{let{keyId:$,issuerId:J}=Q;if(!$||!J)throw Error("verifying-key: keyId/issuerId not yet collected");let Y=await Q80(Q,B);try{B.onInternalLog?.(`apple key verify: keyId=${$}, issuerId=${J}`);let{teamId:X}=await B.verifyApiKey({keyId:$,issuerId:J,p8Content:Y}),G={keyId:$,issuerId:J},K=Q.pendingRecoveryAction==="import-create-profile-only",{pendingRecoveryAction:W,...H}=Q,F={...K?H:Q,completedSteps:{...Q.completedSteps,apiKeyVerified:G}};await B.saveProgress?.(Q.appId,F),B.onLog?.(`✔ API Key verified — Key: ${$}`);let q=Q.setupMethod==="import-existing",U=(B.carried?.importMatches?.length??0)>0?"import-validating-all-certs":"import-pick-identity",I=K?"import-create-profile-only":q?Q.importDistribution==="app_store"?"verify-app":U:"verify-app",z=I==="verify-app"&&q?U:void 0;return{progress:F,next:I,transient:{apiKey:G,...X?{teamId:X}:{},...z?{pendingVerifyNext:z}:{}}}}catch(X){return B.onInternalLog?.(`apple key verify failed: ${X instanceof Error?X.message:String(X)}`),B$(Q,X instanceof Error?X.message:String(X),A)}}case"verify-app":{let $=B.carried?.pendingVerifyNext??"creating-certificate",J=async(F,q)=>{let U=B.detectBundleIds?.().capacitor.value,I={...Q,iosBundleIdOverride:F,...U!==void 0?{iosBundleIdContextAppId:U}:{}};try{await B.saveProgress?.(Q.appId,I)}catch(z){B.onInternalLog?.(`failed to persist verify override (non-fatal): ${z instanceof Error?z.message:String(z)}`),B.onLog?.(q,"yellow")}return I},Y=B.carried?.verifyAction;if(Y){let F=B.carried?.verifyReleaseBundleId??"",q=B.carried?.verifyAttempt??0,U=B.carried?.verifyChosenApp??null;if(Y==="cancel")return B$(Q,"Onboarding cancelled at the App Store verification gate. Re-run `build init` to resume.");if(Y==="back")return{progress:Q,next:"verify-app",transient:{verifyPath:null,verifyChosenApp:null,verifyAttempt:0,verifyAskReopen:!1}};if(Y==="create-new")return{progress:Q,next:"verify-app",transient:{verifyPath:"create-app"}};if(Y==="pick"){if(!U)return{progress:Q,next:"verify-app",transient:{}};if(U.bundleId===F)return B.onLog?.(`✓ Building "${U.name}" (${F}) — matches your App Store app.`),{progress:await J(F,"⚠ Could not save the verified bundle ID; you may be re-prompted next run."),next:$,transient:{verifyChosenApp:U}};return{progress:Q,next:"verify-app",transient:{verifyPath:"fix-build-id",verifyChosenApp:U}}}if(Y==="autofix"||Y==="continue"){if(Y==="autofix"&&U)try{let{changed:E}=B.writeReleaseBundleId(F,U.bundleId);if(E>0)B.onLog?.(`\uD83D\uDD27 Updated PRODUCT_BUNDLE_IDENTIFIER → "${U.bundleId}" in your Xcode project.`);else B.onLog?.(`⚠ Couldn't find PRODUCT_BUNDLE_IDENTIFIER "${F}" to update — edit it in Xcode, then re-check.`,"yellow")}catch{B.onLog?.("⚠ Could not write to your Xcode project — edit PRODUCT_BUNDLE_IDENTIFIER manually, then re-check.","yellow")}let I=B.detectBundleIds?.(),z=I?.releaseResolved&&I.pbxproj?I.pbxproj.value:"",O=U!==null&&z===U.bundleId,V=q+1;if(ev({satisfied:O,attempt:V}).proceed)return B.onLog?.(`✓ Building "${U.name}" (${z}) — matches your App Store app.`),{progress:await J(z,"⚠ Verified the App Store app but could not save the bundle ID override to disk — you may be re-prompted next run."),next:$,transient:{verifyReleaseBundleId:z}};return{progress:Q,next:"verify-app",transient:{verifyReleaseBundleId:z,verifyAttempt:V}}}if(Y==="recheck"){let I=q+1;try{let z=await B.listApps(),O=z.some((V)=>V.bundleId===F);if(ev({satisfied:O,attempt:I}).proceed){let V=z.find((M)=>M.bundleId===F);return B.onLog?.(`✓ Building "${V?.name??F}" (${F}) — matches your App Store app.`),{progress:await J(F,"⚠ Verified the App Store app but could not save the bundle ID override to disk — you may be re-prompted next run."),next:$,transient:{verifyApps:z}}}return{progress:Q,next:"verify-app",transient:{verifyApps:z,verifyAttempt:I,verifyAskReopen:!0}}}catch{return B.onLog?.("⚠ Couldn't reach App Store Connect to re-check — check your connection and try again.","yellow"),{progress:Q,next:"verify-app",transient:{verifyAttempt:I,verifyAskReopen:!0}}}}try{await B.ensureBundleId?.(F)}catch{}try{await B.openExternal?.("https://appstoreconnect.apple.com/apps")}catch{B.onLog?.("⚠ Could not open your browser. Visit https://appstoreconnect.apple.com/apps to create the app.","yellow")}return{progress:Q,next:"verify-app",transient:{verifyAskReopen:!1}}}let X=B.detectBundleIds?.(),G=X?.releaseResolved&&X.pbxproj?X.pbxproj.value:"",K=X?.debugReleaseDiffer??!1,W="";if(K&&X?.debug&&X.pbxproj)W=X.debug.value,B.onLog?.(`⚠ Debug builds "${X.debug.value}" but Release builds "${X.pbxproj.value}" — Capgo Builder signs the RELEASE ID "${X.pbxproj.value}".`,"yellow");let H={verifyReleaseBundleId:G,verifyDebugBundleId:W,verifyDebugReleaseDiffer:K};try{let[F,q]=await Promise.all([B.listApps(),B.listBundleIds()]);if(!G)return B.onLog?.("⚠ Could not resolve a Release PRODUCT_BUNDLE_IDENTIFIER from your Xcode project — skipping remote App Store verification.","yellow"),{progress:Q,next:$,transient:{...H,verifyApps:F,verifyRegisteredIds:q,verifyResult:"no-release-config"}};let{result:U,matchedApp:I}=CtA({releaseBundleId:G,apps:F,registeredBundleIds:q});if(U==="exact-match"&&I)return B.onLog?.(`✓ Building "${I.name}" (${G}) — matches your App Store app.`),{progress:await J(G,"⚠ Verified the App Store app but could not save the bundle ID override to disk — you may be re-prompted next run."),next:$,transient:{...H,verifyApps:F,verifyRegisteredIds:q,verifyResult:U}};return{progress:Q,next:"verify-app",transient:{...H,verifyApps:F,verifyRegisteredIds:q,verifyResult:U,...U!=="wrong-build-id"?{verifyPath:"create-app"}:{}}}}catch(F){return B.onInternalLog?.(`verify-app: could not reach App Store Connect, skipping verification: ${F instanceof Error?F.message:String(F)}`),B.onLog?.("⚠ Couldn't reach App Store Connect to verify your app; continuing without remote verification.","yellow"),{progress:Q,next:$,transient:{...H,verifyApps:[],verifyRegisteredIds:[],verifyResult:"fetch-failed"}}}}case"creating-certificate":{let{csr:$,privateKeyPem:J}=B.generateCsr();try{let Y=await B.createCertificate({csr:$}),X=B.createP12({certificatePem:Y.certificateContent,privateKeyPem:J,password:Fv}),G={certificateId:Y.certificateId,expirationDate:Y.expirationDate,teamId:Y.teamId,p12Base64:X},K={...Q,completedSteps:{...Q.completedSteps,certificateCreated:G}};return await B.saveProgress?.(Q.appId,K),B.onLog?.(`✔ Distribution certificate created — Expires ${Y.expirationDate}`),{progress:K,next:"creating-profile",transient:{certData:G,...G.teamId?{teamId:G.teamId}:{}}}}catch(Y){if(Y instanceof gR){let X=Y.certificates?.length?Y.certificates:await B.listCertificates?.()??[];return{progress:Q,next:"cert-limit-prompt",transient:{existingCerts:X}}}return B.onLog?.(`✖ ${Y instanceof Error?Y.message:String(Y)}`,"red"),B$(Q,Y instanceof Error?Y.message:String(Y),A)}}case"creating-profile":{let $=BZ(Q,B),J=B.carried?.certData?.certificateId??Q.completedSteps.certificateCreated?.certificateId;if(!J)throw Error("creating-profile: certificate not yet created");try{let Y=await B.createProfile({bundleId:$,certificateId:J}),X=await B.checkDuplicateProfiles?.($)??[];if(X.length>0){let F={...Q,duplicateProfileOrigin:"creating-profile"};return await B.saveProgress?.(Q.appId,F),{progress:F,next:"duplicate-profile-prompt",transient:{duplicateProfiles:X}}}let G={profileId:Y.profileId,profileName:Y.profileName,profileBase64:Y.profileBase64},K=B.carried?.teamId??Q.completedSteps.certificateCreated?.teamId,W=B.carried?.certData??Q.completedSteps.certificateCreated,H={...Q,completedSteps:{...Q.completedSteps,profileCreated:G}};return await B.saveProgress?.(Q.appId,H),B.onLog?.(`✔ Provisioning profile created — "${Y.profileName}"`),{progress:H,next:"saving-credentials",transient:{profileData:G,...W?{certData:W}:{},...K?{teamId:K}:{}}}}catch(Y){if(Y instanceof Ov){let X={...Q,duplicateProfileOrigin:"creating-profile"};return await B.saveProgress?.(Q.appId,X),{progress:X,next:"duplicate-profile-prompt",transient:{duplicateProfiles:Y.profiles}}}return B.onLog?.(`✖ ${Y instanceof Error?Y.message:String(Y)}`,"red"),B$(Q,Y instanceof Error?Y.message:String(Y),A)}}case"cert-limit-prompt":{let $=B.carried?.certToRevoke;if(!$)return B$(Q,"Onboarding cancelled at the certificate-limit prompt. Re-run `build init` to resume.");return{progress:Q,next:"revoking-certificate",transient:{certToRevoke:$}}}case"revoking-certificate":{let $=B.carried?.certToRevoke;if(!$)throw Error("revoking-certificate: no certToRevoke carried");try{return await B.revokeCertificate($.id),B.onLog?.("✔ Old certificate revoked"),{progress:Q,next:"creating-certificate"}}catch(J){return B.onLog?.(`✖ ${J instanceof Error?J.message:String(J)}`,"red"),B$(Q,J instanceof Error?J.message:String(J),A)}}case"duplicate-profile-prompt":{if(!B.carried?.confirmDeleteDuplicates)return B$(Q,"Onboarding cancelled at the duplicate-profile prompt. Re-run `build init` to resume.");return{progress:Q,next:"deleting-duplicate-profiles"}}case"deleting-duplicate-profiles":{let $=B.carried?.duplicateProfiles??[];try{for(let Y of $)await B.deleteProfile(Y.id);B.onLog?.(`✔ Removed ${$.length} old profile(s)`);let J=Q.duplicateProfileOrigin??"creating-profile";return{progress:Q,next:J}}catch(J){return B.onLog?.(`✖ ${J instanceof Error?J.message:String(J)}`,"red"),B$(Q,J instanceof Error?J.message:String(J),A)}}case"import-scanning":try{let[$,J]=await Promise.all([B.listSigningIdentities(),B.scanProvisioningProfiles()]),Y=$.filter((G)=>G.type==="distribution");if(Y.length===0)return B.onLog?.(`✖ ${"No iOS Distribution identities found in your default Keychain."}`,"red"),B$(Q,"No iOS Distribution identities found in your default Keychain.","import-scanning");let X=TnA(Y,J);return B.onLog?.(`✔ Found ${Y.length} distribution identit${Y.length===1?"y":"ies"} and ${J.length} profile${J.length===1?"":"s"} on this Mac`),{progress:Q,next:rs(Q),transient:{importMatches:X,importProfiles:J}}}catch($){return B.onLog?.(`✖ ${$ instanceof Error?$.message:String($)}`,"red"),B$(Q,$ instanceof Error?$.message:String($),A)}case"import-validating-all-certs":{let $=B.carried?.importMatches??[];try{let J={};for(let K of $)J[K.identity.sha1]=await B.classifyCertAvailability(K.identity);let Y=Object.values(J).filter((K)=>K.available).length;B.onLog?.(`✔ Apple validation complete — ${Y} available, ${$.length-Y} unavailable`);let X=$.filter((K)=>{let W=J[K.identity.sha1];return W?.available&&W?.appleCertId}),G={};return await Promise.all(X.map(async(K)=>{let W=J[K.identity.sha1].appleCertId;try{let H=await B.listProfilesForCert(W);G[K.identity.sha1]=H.map((F)=>zeA(F,K.identity))}catch(H){B.onInternalLog?.(`profile prefetch failed (background): ${H instanceof Error?H.message:String(H)}`)}})),{progress:Q,next:"import-pick-identity",transient:{identityAvailability:J,profilePrefetch:G}}}catch(J){return B.onLog?.(`✖ ${J instanceof Error?J.message:String(J)}`,"red"),B$(Q,J instanceof Error?J.message:String(J),A)}}case"import-pick-identity":{let $=B.carried?.chosenIdentity;if(!$)return{progress:Q,next:"api-key-instructions"};let Y=(B.carried?.importMatches??[]).find((H)=>H.identity.sha1===$.sha1),X=BZ(Q,B),G=Q.importDistribution;if(GD(Y?.profiles??[],X,G).length>0)return{progress:Q,next:"import-pick-profile"};if(!!(B.carried?.p8Content||Q.completedSteps.apiKeyVerified))return{progress:Q,next:"import-checking-apple-cert"};return{progress:Q,next:"import-no-match-recovery",transient:{noMatchReason:"no-profile-on-disk"}}}case"import-checking-apple-cert":{let $=B.carried?.chosenIdentity;if(!$)return B$(Q,"Internal error: no identity chosen for the Apple cert check.","import-scanning");let J=BZ(Q,B),Y=Q.importDistribution,X=B.carried?.importMatches??[];try{let G=await B.findCertIdBySha1($.sha1);if(!G)return B.onLog?.(`⚠ Apple lookup returned no match for "${$.name}".`,"yellow"),{progress:Q,next:"import-no-match-recovery",transient:{noMatchReason:"apple-no-cert-match"}};B.onLog?.(`✔ Apple recognizes this certificate (ASC id ${G.slice(0,8)}…)`);let W=(await B.listProfilesForCert(G)).map((q)=>zeA(q,$));if(W.length===0)return B.onLog?.("ℹ️ Apple has the cert but no profiles linked to it yet.","yellow"),{progress:Q,next:"import-no-match-recovery",transient:{noMatchReason:"apple-no-profiles-linked",_appleCertIdForChosen:G}};let H=X.map((q)=>q.identity.sha1===$.sha1?{...q,profiles:[...q.profiles,...W]}:q),F=GD(W,J,Y);if(F.length===0){let q=W.filter((z)=>z.bundleId&&z.bundleId!==J),U=W.filter((z)=>z.bundleId===J),I;if(q.length>0)I="apple-bundle-mismatch";else if(U.length>0)I="apple-distribution-mismatch";else I="apple-other";return B.onLog?.(`⚠ Apple returned ${W.length} profile${W.length===1?"":"s"} for this cert but none match this app.`,"yellow"),{progress:Q,next:"import-no-match-recovery",transient:{noMatchReason:I,_appleCertIdForChosen:G,importMatches:H}}}return B.onLog?.(`✔ Apple has ${F.length} matching profile${F.length===1?"":"s"} for "${J}" — opening the picker`),{progress:Q,next:"import-pick-profile",transient:{_appleCertIdForChosen:G,importMatches:H}}}catch(G){return B.onLog?.(`✖ ${G instanceof Error?G.message:String(G)}`,"red"),B$(Q,G instanceof Error?G.message:String(G),A)}}case"import-pick-profile":{let $=B.carried?.chosenProfile;if(!$)return{progress:Q,next:"import-pick-identity"};let J=BZ(Q,B),Y=Q.importDistribution,X=B.carried?.chosenIdentity,G=As($.bundleId,J),K=!Y||$.profileType===Y;if(!G||!K){let W=`Profile "${$.name}" doesn't match this app: bundle ${$.bundleId} (expected ${J}), type ${$.profileType} (expected ${Y??"any"}).`;return B.onLog?.(`✖ ${W}`,"red"),B$(Q,W,"import-pick-identity")}if(X&&!$.certificateSha1s.includes(X.sha1)){let W=$.certificateSha1s.map((F)=>`${F.slice(0,8)}…`).join(", ")||"(none listed)",H=`Profile "${$.name}" doesn't trust your chosen certificate "${X.name}". The profile's allowed-certs list contains ${$.certificateSha1s.length} entr${$.certificateSha1s.length===1?"y":"ies"} (SHA1: ${W}); your cert's SHA1 starts with ${X.sha1.slice(0,8)}…. `+"Either pick a different profile, or re-create this profile in the Apple Developer Portal and tick the right cert.";return B.onLog?.(`✖ ${H}`,"red"),B$(Q,H,"import-pick-identity")}return B.onLog?.(`✔ Profile · ${$.name}`),{progress:Q,next:"import-export-warning"}}case"import-no-match-recovery":{let $=B.carried?.recoveryAction,J=B.carried?.noMatchReason,Y=J?{noMatchReason:J}:{};if(!$||$==="back")return{progress:Q,next:"import-pick-identity",transient:Y};if($==="browser")return{progress:Q,next:"import-portal-explanation",transient:Y};if($==="provide-profile-path")return{progress:Q,next:"import-provide-profile-path",transient:Y};if(!!(B.carried?.p8Content||Q.p8Path))return{progress:Q,next:"import-create-profile-only",transient:Y};let G={...Q,pendingRecoveryAction:"import-create-profile-only"};return await B.saveProgress?.(Q.appId,G),{progress:G,next:"api-key-instructions",transient:Y}}case"import-portal-explanation":{let $=B.carried?.portalAction,J=B.carried?.noMatchReason,Y=J?{noMatchReason:J}:{};if($==="use-create")return{progress:Q,next:"import-create-profile-only",transient:Y};if($==="use-file")return{progress:Q,next:"import-provide-profile-path",transient:Y};if($==="open-anyway"){try{await B.openExternal?.("https://developer.apple.com/account/resources/profiles/list"),B.onLog?.(`\uD83C\uDF10 Opened Apple Developer Portal (${"https://developer.apple.com/account/resources/profiles/list"}) — ${'once you have downloaded the .mobileprovision file, come back and pick "\uD83D\uDCC1 Use a .mobileprovision file from disk".'}`,"yellow")}catch{B.onLog?.(`⚠ Could not open your browser. Visit ${"https://developer.apple.com/account/resources/profiles/list"} — ${'once you have downloaded the .mobileprovision file, come back and pick "\uD83D\uDCC1 Use a .mobileprovision file from disk".'}`,"yellow")}return{progress:Q,next:"import-no-match-recovery",transient:Y}}return{progress:Q,next:"import-no-match-recovery",transient:Y}}case"import-provide-profile-path":{let $=B.carried?.chosenIdentity;if(!$)return B.onLog?.(`✖ ${"Internal error: no identity chosen for .mobileprovision import."}`,"red"),B$(Q,"Internal error: no identity chosen for .mobileprovision import.");let J=B.carried?.noMatchReason,Y=J?{noMatchReason:J}:{};if(B.carried?.profilePickerOpened)return{progress:Q,next:"import-no-match-recovery",transient:{...Y,profilePickerOpened:!0}};let X=BZ(Q,B),G=Q.importDistribution;try{let K=await B.openProfilePicker?.();if(!K)return{progress:Q,next:"import-no-match-recovery",transient:{...Y,profilePickerOpened:!0}};let W=await B.readFile(K),H;try{H=B.parseMobileprovisionDetailed(W)}catch(I){let z=`Couldn't parse "${K}": ${I instanceof Error?I.message:String(I)}`;return B.onLog?.(`✖ ${z}`,"red"),B$(Q,z,"import-provide-profile-path",{profilePickerOpened:!0})}if(!As(H.bundleId,X)){let I=`This .mobileprovision is for bundle ID "${H.bundleId}" but the current app is "${X}". Pick a profile that targets the right app (wildcard profiles like "com.example.*" are accepted), or use "Create a new App Store profile" in the recovery menu.`;return B.onLog?.(`✖ ${I}`,"red"),B$(Q,I,"import-provide-profile-path",{profilePickerOpened:!0})}if(G&&H.profileType!==G){let I=`This .mobileprovision is a ${H.profileType} profile but you picked ${G} distribution. Pick a profile that matches, or restart and pick the matching distribution mode.`;return B.onLog?.(`✖ ${I}`,"red"),B$(Q,I,"import-provide-profile-path",{profilePickerOpened:!0})}if(!H.certificateSha1s.includes($.sha1)){let I=H.certificateSha1s.map((O)=>`${O.slice(0,8)}…`).join(", ")||"(none listed)",z=`This .mobileprovision doesn't trust your chosen certificate "${$.name}". Allowed certs in the profile (SHA1): ${I}; your cert starts with ${$.sha1.slice(0,8)}…. `+"Either pick a different cert at the identity step, or re-create this profile in the Apple Developer Portal and tick the right one.";return B.onLog?.(`✖ ${z}`,"red"),B$(Q,z,"import-provide-profile-path",{profilePickerOpened:!0})}let F={path:K,uuid:H.uuid,name:H.name,applicationIdentifier:H.applicationIdentifier,bundleId:H.bundleId,teamId:$.teamId,expirationDate:H.expirationDate,profileType:H.profileType,certificateSha1s:H.certificateSha1s},U=(B.carried?.importMatches??[]).map((I)=>I.identity.sha1===$.sha1?{...I,profiles:[...I.profiles,F]}:I);return B.onLog?.(`✔ Loaded profile from file · ${H.name}`),{progress:Q,next:"import-pick-profile",transient:{profilePickerOpened:!0,chosenProfile:F,importMatches:U}}}catch(K){let W=K instanceof Error?K.message:String(K);return B.onLog?.(`✖ ${W}`,"red"),B$(Q,W,"import-provide-profile-path",{profilePickerOpened:!0})}}case"import-create-profile-only":{let $=B.carried?.chosenIdentity;if(!$)return B.onLog?.(`✖ ${"Internal error: no identity chosen for profile creation."}`,"red"),B$(Q,"Internal error: no identity chosen for profile creation.");if(Q.importDistribution==="ad_hoc"){let Y='Creating a new profile via Apple is not implemented for ad_hoc distribution yet. Use "Open Apple Developer Portal" instead.';return B.onLog?.(`✖ ${Y}`,"red"),B$(Q,Y)}let J=BZ(Q,B);try{let Y=await B.findCertIdBySha1($.sha1);if(!Y){let H=`Apple does not have a certificate matching "${$.name}". Cannot create a profile without an Apple-side cert ID. Use the "Create new" path instead.`;return B.onLog?.(`✖ ${H}`,"red"),B$(Q,H)}await B.ensureBundleId(J);let X=await B.createProfile({bundleId:J,certificateId:Y,distribution:"app_store"}),G={path:"",uuid:X.profileId,name:X.profileName,applicationIdentifier:"",bundleId:J,teamId:$.teamId,expirationDate:X.expirationDate??"",profileType:"app_store",certificateSha1s:[$.sha1],profileBase64:X.profileBase64},W=(B.carried?.importMatches??[]).map((H)=>H.identity.sha1===$.sha1?{...H,profiles:[...H.profiles,G]}:H);return B.onLog?.(`✔ Created new profile "${X.profileName}" on Apple, linked to your existing cert`),{progress:Q,next:"import-export-warning",transient:{chosenProfile:G,importMatches:W}}}catch(Y){if(Y instanceof Ov){let G={...Q,duplicateProfileOrigin:"import-create-profile-only"};return await B.saveProgress?.(Q.appId,G),{progress:G,next:"duplicate-profile-prompt",transient:{duplicateProfiles:Y.profiles}}}let X=Y instanceof Error?Y.message:String(Y);return B.onLog?.(`✖ ${X}`,"red"),B$(Q,X,"import-create-profile-only")}}case"import-export-warning":{let $=B.carried?.exportWarningAction;if($==="back")return{progress:Q,next:"import-pick-profile"};if($==="go")return{progress:Q,next:"import-exporting"};return B$(Q,"Onboarding cancelled. Re-run `build init` to resume.")}case"import-exporting":{let $=B.carried?.chosenIdentity,J=B.carried?.chosenProfile;if(!$||!J)return B.onLog?.(`✖ ${"Internal error: no identity or profile chosen for export."}`,"red"),B$(Q,"Internal error: no identity or profile chosen for export.");try{let Y=await B.exportP12FromKeychain($.sha1),X={certificateId:"",expirationDate:J.expirationDate,teamId:$.teamId,p12Base64:Y.base64},G=J.path?(await B.readFile(J.path)).toString("base64"):J.profileBase64||"",K={profileId:J.uuid,profileName:J.name,profileBase64:G};return B.onLog?.(`✔ Exported "${$.name}" from Keychain`),{progress:Q,next:"saving-credentials",transient:{certData:X,profileData:K,importedP12Password:Y.passphrase,...$.teamId?{teamId:$.teamId}:{}}}}catch(Y){let X=Y instanceof Error?Y.message:String(Y);return B.onLog?.(`✖ ${X}`,"red"),B$(Q,X,"import-exporting")}}case"error":{let $=B.carried?.errorAction;if($==="retry"&&B.carried?.retryStep)return{progress:Q,next:B.carried.retryStep};if($==="restart")return{progress:Q,next:"welcome"};return{progress:Q,next:"error"}}default:throw Error(`runIosEffect: not implemented for step '${A}'`)}}function e10(){return OeA(CeA(),".capgo-credentials","credentials.json")}function A80(A){return OeA(CeA(),".capgo-credentials",`credentials-${A}.copy.json`)}function BZ(A,Q){if(A.iosBundleIdOverride)return A.iosBundleIdOverride;try{let B=Q?.detectBundleIds?.();if(B?.releaseResolved&&B.pbxproj)return B.pbxproj.value}catch{}return A.appId}async function Q80(A,Q){if(Q.carried?.p8Content)return Q.carried.p8Content;if(A.p8Path&&Q.readFile)try{return await Q.readFile(A.p8Path)}catch(B){throw Q.onInternalLog?.(`saved .p8 no longer readable, re-prompting: ${B instanceof Error?B.message:String(B)}`),Error("verifying-key: .p8 content unavailable (the saved .p8 path is no longer readable — re-provide the .p8 key file)")}throw Error("verifying-key: .p8 content unavailable (no carried bytes and no readable p8Path)")}function rZA(A){if(typeof A==="object"&&A!==null&&"code"in A&&A.code==="ENOENT")return"not-found";return"other"}var zA=iA(M8(),1),tZA=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],eZA=2,W80=/\r?\n/,Z80=/\r/g;class ts extends Error{constructor(){super("Need .p8 file");this.name="NeedP8Error"}}function H80(A){if(!A)return;let Q={};for(let[B,$]of Object.entries(A))if(typeof $==="string")Q[B]=$;return Q}var D80=new Set(["backing-up","p8-method-select","verifying-key","verify-app","creating-certificate","revoking-certificate","creating-profile","deleting-duplicate-profiles"]),F80=new Set(["import-scanning","import-validating-all-certs","import-checking-apple-cert","import-provide-profile-path","import-create-profile-only","import-exporting"]),q80=new Set(["saving-credentials","detecting-ci-secrets","checking-ci-secrets","uploading-ci-secrets","exporting-env","overwrite-and-export-env","writing-workflow-file","requesting-build"]);async function U80(A,Q){let B=A,$=[];try{({command:B,args:$}=TF(A))}catch(J){return{success:!1,output:[J instanceof Error?J.message:String(J)]}}return new Promise((J)=>{let Y=B80(B,[...$,...Q],{stdio:["ignore","pipe","pipe"]}),X=[],G=(K)=>{let W=typeof K==="string"?K:K.toString("utf8");for(let H of W.split(W80)){let F=H.replaceAll(Z80,"").trim();if(F)X.push(F)}};Y.stdout?.on("data",G),Y.stderr?.on("data",G),Y.once("error",(K)=>{X.push(K.message),J({success:!1,output:X})}),Y.once("close",(K)=>{J({success:K===0,output:X})})})}var I80=({appId:A,iosBundleIdInitial:Q,initialProgress:B,iosDir:$,guidedHelperUsable:J,apikey:Y,supaHost:X,journeyId:G,onStep:K,onResult:W,onBeforeExit:H})=>{let{exit:F}=MC(),q=$Q.useCallback(()=>{aR(H,F)},[F,H]),U=oJ(B,J),[I,z]=$Q.useState(B!==null&&U!=="welcome"?"resume-prompt":U==="welcome"?"welcome":U),O=B?.iosBundleIdOverride!==void 0&&B.iosBundleIdContextAppId===Q,[V,E]=$Q.useState(O&&B?.iosBundleIdOverride?B.iosBundleIdOverride:Q),[M,L]=$Q.useState(O),[R,T]=$Q.useState(!1),[x,c]=$Q.useState(""),[p,b]=$Q.useState(""),[u,i]=$Q.useState([]),[a,qA]=$Q.useState([]),[s,h]=$Q.useState(null),[v,S]=$Q.useState(null),[y,g]=$Q.useState(0),[d,XA]=$Q.useState(!1),[t,ZA]=$Q.useState(0),PA=$Q.useRef(!1),TA=$Q.useMemo(()=>Zj({cwd:U7.cwd(),iosDir:$,capacitorAppId:Q}),[$,Q]),WA=(HA)=>{if(M)return HA;if(!TA.mismatch)return HA;if(E(TA.recommended.value),L(!0),TA.recommended.value!==Q)bQ(`ℹ Using "${TA.recommended.value}" (your Xcode Release bundle ID) for Apple operations. capacitor.config.appId ("${Q}") is the Capgo app key and is left unchanged.`);return HA},IQ=$Q.useRef({step:null,startedAt:Date.now()}),CA=$Q.useRef([]),tA=$Q.useRef([]),[rA,Q0]=$Q.useState(null),nQ=$Q.useRef(Y??null),B0=$Q.useRef(!1),xQ=$Q.useRef(void 0);$Q.useEffect(()=>{if(nQ.current)return;let HA=q6();if(HA)nQ.current=HA},[]),$Q.useEffect(()=>{if(B0.current||!nQ.current)return;B0.current=!0;let HA=!1;return(async()=>{let mA=await AB(nQ.current,void 0,void 0,!0).catch(()=>null);if(!mA||HA)return;let SA=await j$(mA,A).catch(()=>null);if(SA&&!HA)Q0(SA)})(),()=>{HA=!0}},[A]);let[WB,TB]=$Q.useState([]),[rQ,oQ]=$Q.useState(null),[XB,xB]=$Q.useState(0),[d1,p8]=$Q.useState(null),[h$,j8]=$Q.useState(!1),[X0,r0]=$Q.useState([]),[BB,J1]=$Q.useState([]),[b8,u6]=$Q.useState(null),K8=$Q.useRef(!1),R4=$Q.useRef(!1),[J$,u$]=$Q.useState(B?.p8Path||""),[e,xA]=$Q.useState(""),[PQ,sQ]=$Q.useState(B?.completedSteps.apiKeyVerified?.keyId||B?.keyId||$M(B?.p8Path||"")||""),[S0,bB]=$Q.useState(B?.completedSteps.apiKeyVerified?.issuerId||B?.issuerId||""),{stdout:s0}=s7(),[l1,A1]=$Q.useState({rows:s0?.rows??24,cols:s0?.columns??80});$Q.useEffect(()=>{if(!s0)return;let HA=()=>A1({rows:s0.rows??24,cols:s0.columns??80});return s0.on("resize",HA),()=>{s0.off("resize",HA)}},[s0]);let{rows:v1,cols:U4}=l1,k5=$Q.useRef(null),[S5,OJ]=$Q.useState({key:"",comfortable:null,dense:null}),w6=`${I}|${U4}`,E7=S5.key===w6?S5:{key:w6,comfortable:null,dense:null},w8=!1;$Q.useEffect(()=>{if(!k5.current)return;let{height:HA}=NC(k5.current);if(HA<=0)return;let mA=w8?"dense":"comfortable";OJ((SA)=>{let MQ=SA.key===w6?SA:{key:w6,comfortable:null,dense:null};if(MQ[mA]===HA)return SA;return{...MQ,[mA]:HA}})});let W4=E7.comfortable!=null&&E7.comfortable+dk+yi>v1,x5=w8?E7.dense:E7.comfortable,b5=W4?IuA:dk,hK=x5!=null?Ss(v1,b5,x5):Number.POSITIVE_INFINITY,O$=$Q.useRef(e),aJ=$Q.useRef(J$),MY=$Q.useRef(PQ),_X=$Q.useRef(S0),f5=$Q.useRef(null),M$=$Q.useRef(null),IG=$Q.useCallback((HA)=>{O$.current=HA,xA(HA)},[]);$Q.useEffect(()=>{aJ.current=J$},[J$]),$Q.useEffect(()=>{MY.current=PQ},[PQ]),$Q.useEffect(()=>{_X.current=S0},[S0]),$Q.useEffect(()=>{if(!nQ.current)return;let HA=IQ.current,mA=HA.step!==null&&HA.step===I&&I!=="error";if(rA&&CA.current.length>0){for(let UQ of CA.current)yR({apikey:nQ.current,appId:A,journeyId:G,orgId:rA,platform:"ios",...UQ});CA.current=[]}if(rA&&tA.current.length>0){for(let UQ of tA.current)hR({apikey:nQ.current,appId:A,journeyId:G,orgId:rA,platform:"ios",...UQ});tA.current=[]}if(mA)return;let SA=Date.now(),MQ=HA.step===null||HA.step===I?void 0:HA.step,qQ=MQ===void 0?void 0:SA-HA.startedAt,J0={step:I,durationMs:qQ,durationStep:MQ,errorCategory:I==="error"?xQ.current:void 0};if(IQ.current={step:I,startedAt:SA},rA)yR({apikey:nQ.current,appId:A,journeyId:G,orgId:rA,platform:"ios",...J0});else CA.current.push(J0)},[I,A,rA,rQ,G]),$Q.useEffect(()=>{K?.(I)},[I,K]);let RI=$Q.useCallback((HA,mA,SA=I)=>{if(!nQ.current)return;let MQ={step:SA,action:HA,tags:mA};if(rA)hR({apikey:nQ.current,appId:A,journeyId:G,orgId:rA,platform:"ios",...MQ});else tA.current.push(MQ)},[A,rA,I,G]),[qZ,zG]=$Q.useState(B?.completedSteps.certificateCreated?.teamId||""),[LD,UZ]=$Q.useState(B?.completedSteps.certificateCreated||null),[l0,NY]=$Q.useState(B?.completedSteps.profileCreated||null),[Y$,VD]=$Q.useState(""),[m$,Z4]=$Q.useState([]),[uK,R7]=$Q.useState(null),[CG,PX]=$Q.useState(""),v5=$Q.useRef(null),[OG,Y9]=$Q.useState([]),j7=$Q.useRef(""),[X9,BA]=$Q.useState("Uploading your logs to Capgo support…"),[AA,OA]=$Q.useState(null),[RA,yA]=$Q.useState(null),[LQ,yQ]=$Q.useState(""),[jQ,K0]=$Q.useState(null),[$0,x0]=$Q.useState(0),[$B,L1]=$Q.useState(!1),[t1,z8]=$Q.useState(!1),[e1,_9]=$Q.useState([]),[m6,P9]=$Q.useState([]),[X$,G9]=$Q.useState(null),[K9,w7]=$Q.useState([]),[g5,_7]=$Q.useState([]),[ED,eF]=$Q.useState(null),[jI,P7]=$Q.useState("Resolving GitHub repository…"),[y5,h5]=$Q.useState(null),[mK,t9]=$Q.useState(null),[N$,T7]=$Q.useState([]),[IZ,wI]=$Q.useState(null),[u5,SM]=$Q.useState(!0),[_I,PI]=$Q.useState(null),[xM,zZ]=$Q.useState(null),[bM,fM]=$Q.useState(null),[Dw,Aq]=$Q.useState("undecided"),[Qq,CZ]=$Q.useState({}),[OZ,TI]=$Q.useState(null),[RD,jD]=$Q.useState(null),[TX,vM]=$Q.useState(null),[Bq,K6]=$Q.useState(null),[$q,wD]=$Q.useState(null),[MZ,m5]=$Q.useState(""),[MG,ZB]=$Q.useState(null),[c5,k7]=$Q.useState([]),[,S7]=$Q.useState([]),[c$,G$]=$Q.useState(null),[_D,cK]=$Q.useState(null),[T9,Jq]=$Q.useState(B?.importDistribution??null),[I4,Yq]=$Q.useState(""),[NG,kX]=$Q.useState(B?.setupMethod==="import-existing"),[Xq,d5]=$Q.useState(null),[MJ,LG]=$Q.useState(null),dK=$Q.useRef(!1),[x7,NZ]=$Q.useState({}),[PD,gM]=$Q.useState({}),[yM,hM]=$Q.useState(0),IA=$Q.useRef(!1),jA=$Q.useRef(0),[YQ,U0]=$Q.useState(void 0),[cB,LB]=$Q.useState("creating-profile"),hQ=$Q.useRef({}),bQ=$Q.useCallback((HA,mA="green")=>{gB(HA),TB((SA)=>{let MQ=SA[SA.length-1];if(MQ&&MQ.text===HA&&MQ.color===mA)return SA;return[...SA,{text:HA,color:mA}]})},[]);$Q.useEffect(()=>{gB(`step → ${I}`)},[I]);let VQ=$Q.useCallback((HA,mA,SA="green")=>{TB((MQ)=>{let qQ=MQ.findIndex((UQ)=>UQ.text.startsWith(HA));if(qQ>=0){if(MQ[qQ].text===mA&&MQ[qQ].color===SA)return MQ;let UQ=[...MQ];return UQ[qQ]={text:mA,color:SA},UQ}let J0=MQ[MQ.length-1];if(J0&&J0.text===mA&&J0.color===SA)return MQ;return[...MQ,{text:mA,color:SA}]})},[]),ZQ=$Q.useCallback((HA,mA,SA={})=>{m0({channel:"bundle",event:HA,icon:mA,apikey:nQ.current??Y??void 0,appId:A,orgId:rA??void 0,tags:{step:"ios-app-verify",platform:"ios",mode:"app_store",...SA}})},[A,Y,rA]),i8=async(HA,mA)=>{hQ.current={...hQ.current,verifyAction:HA,...mA!==void 0?{verifyChosenApp:mA}:{}};let SA=hQ.current.verifyAttempt??0,MQ=HA==="recheck"||HA==="open"||HA==="reopen"||HA==="create-new"?"create-app":"fix-build-id",qQ=0;if(HA==="recheck")T(!0);try{let J0=await x4(A)??{platform:"ios",appId:A,startedAt:new Date().toISOString(),completedSteps:{}},UQ=await q7("verify-app",J0,{appId:A,listApps:async()=>zv(await c6()),listBundleIds:async()=>Cv(await c6()),detectBundleIds:()=>Zj({cwd:U7.cwd(),iosDir:$,capacitorAppId:Q}),writeReleaseBundleId:(fB,B4)=>{let d$=nT(U7.cwd(),$,fB,B4);return qQ=d$.changed,d$},ensureBundleId:async(fB)=>{await LF(await c6(),fB)},openExternal:async(fB)=>{await q9(fB)},loadProgress:x4,saveProgress:GG,carried:hQ.current,onLog:(fB,B4)=>bQ(fB,B4)}),kQ=UQ.transient;if(hQ.current={...hQ.current,...kQ??{},verifyAction:void 0},kQ){if(kQ.verifyApps!==void 0)i(kQ.verifyApps);if(kQ.verifyReleaseBundleId!==void 0)c(kQ.verifyReleaseBundleId);if(kQ.verifyPath!==void 0)h(kQ.verifyPath);if(kQ.verifyChosenApp!==void 0)S(kQ.verifyChosenApp);if(kQ.verifyAttempt!==void 0)g(kQ.verifyAttempt);if(kQ.verifyAskReopen!==void 0)XA(kQ.verifyAskReopen)}if(UQ.progress.iosBundleIdOverride&&UQ.progress.iosBundleIdOverride!==J0.iosBundleIdOverride)E(UQ.progress.iosBundleIdOverride),L(!0);if(HA==="autofix"&&qQ>0)ZQ("iOS App Verify Auto Fixed","\uD83D\uDD27",{attempt:SA,path:"fix-build-id"});if(HA==="open"||HA==="reopen")ZQ("iOS App Verify Create App Opened","\uD83C\uDF10",{attempt:SA});let G0=kQ?.verifyAttempt??SA;if(UQ.next==="verify-app"&&G0>SA)ZQ("iOS App Verify Gate Blocked","\uD83D\uDEA7",{attempt:G0,path:MQ});if(UQ.next&&UQ.next!=="verify-app"&&UQ.next!=="error")ZQ("iOS App Verify Passed","✅",{attempts:SA,path:MQ}),z(UQ.next)}catch(J0){l5(J0,"verify-app")}finally{if(HA==="recheck")T(!1)}},l4=P8(),z4=G4(l4.runner,["cap","add","ios"]),Gq=G4(l4.runner,["cap","sync","ios"]),lK=G4(l4.runner,["@capgo/cli@latest","doctor"]),pK=G4(l4.runner,["@capgo/cli@latest","build","init"]),SX=G4(l4.runner,["@capgo/cli@latest","build","request",A,"--platform","ios"]),TD=(HA,mA={})=>{let SA=mA.diff?tU(mA.diff,mA.isNew??u5):_I??tU(N$,mA.isNew??u5);ys({event:HA,appId:A,platform:"ios",apikey:Y,journeyId:G,packageManager:mK??eW(l4.pm),buildScriptType:RD?.type,decision:mA.decision,...SA})},VG=$Q.useCallback((HA)=>{if(R4.current)return;if(R4.current=!0,HA)bQ(HA,"yellow");setTimeout(q,50)},[bQ,q]);u4((HA,mA)=>{if(mA.ctrl&&HA==="c"){U7.kill(U7.pid,"SIGINT");return}if(I==="build-complete"&&ui(HA,mA)){q();return}if(mA.ctrl&&HA==="o"&&(I==="api-key-instructions"||I==="input-issuer-id"))q9("https://appstoreconnect.apple.com/access/integrations/api");if(I==="preview-workflow-file"&&mA.escape)TD("workflow-preview-action",{decision:"escape"}),T7([]),z("build-complete")});let kD=$Q.useCallback(async(HA)=>{let SA={...await x4(A)||{platform:"ios",appId:A,startedAt:new Date().toISOString(),completedSteps:{}}};if(HA.p8Path!==void 0)SA.p8Path=HA.p8Path;if(HA.keyId!==void 0)SA.keyId=HA.keyId;if(HA.issuerId!==void 0)SA.issuerId=HA.issuerId;await GG(A,SA)},[A]),LZ=$Q.useCallback(async(HA)=>{let mA=await x4(A);if(!mA)return;await GG(A,{...mA,p8CreateMethod:HA})},[A]),NJ=$Q.useCallback(async()=>{await tv(A).catch((HA)=>{gB(`restart: deleteProgress failed: ${HA instanceof Error?HA.message:String(HA)}`)}),kX(!1),k7([]),S7([]),G$(null),cK(null),Jq(null),Yq(""),d5(null),u$(""),IG(""),sQ(""),bB(""),zG(""),aJ.current="",MY.current="",_X.current="",NZ({}),gM({}),IA.current=!1,jA.current+=1,UZ(null),NY(null),oQ(null),xQ.current=void 0,xB(0),R7(null),K8.current=!1,dK.current=!1,E(Q),L(!1),LG(null),SD.current=!1,PA.current=!1,hQ.current={...hQ.current,pendingVerifyNext:void 0,verifyAction:void 0,verifyChosenApp:void 0,verifyApps:void 0,verifyRegisteredIds:void 0,verifyReleaseBundleId:void 0,verifyDebugBundleId:void 0,verifyPath:void 0,verifyAttempt:void 0,verifyAskReopen:void 0},T(!1),c(""),b(""),i([]),qA([]),h(null),S(null),g(0),XA(!1),ZA(0)},[A,Q]),Q4=$M;async function c6(){let HA=O$.current;if(!HA&&aJ.current)try{HA=await Dj(aJ.current,"utf-8"),IG(HA)}catch(mA){throw gB(`saved .p8 no longer readable, re-prompting: ${mA instanceof Error?mA.message:String(mA)}`),new ts}if(!HA)throw new ts;return mr(MY.current,_X.current,HA)}let SD=$Q.useRef(!1),EG=$Q.useCallback(()=>{if(SD.current)return;SD.current=!0,bQ("ℹ️ Ad-hoc is more involved than App Store — you also need to register every device on Apple.","yellow"),bQ(" Want hands-on help? Email support@capgo.app and we'll walk you through it.","yellow")},[bQ]),VZ=$Q.useCallback(()=>{if(!B)return;if(B.importDistribution)VQ("✔ Distribution · ",`✔ Distribution · ${B.importDistribution}`);if(B.p8Path)VQ("✔ Key file selected · ",`✔ Key file selected · ${B.p8Path}`);if(B.keyId&&!B.completedSteps.apiKeyVerified)VQ("✔ Key ID · ",`✔ Key ID · ${B.keyId}`);if(B.issuerId&&!B.completedSteps.apiKeyVerified)VQ("✔ Issuer ID · ",`✔ Issuer ID · ${B.issuerId}`);let{completedSteps:HA}=B;if(HA.apiKeyVerified)bQ(`✔ API Key verified — Key: ${HA.apiKeyVerified.keyId}`);if(HA.certificateCreated)bQ(`✔ Distribution certificate created — Expires ${HA.certificateCreated.expirationDate}`);if(HA.profileCreated)bQ(`✔ Provisioning profile created — "${HA.profileCreated.profileName}"`);if(B.importDistribution==="ad_hoc"&&!HA.profileCreated)EG()},[B,bQ,EG]),xX=$Q.useRef(I==="resume-prompt");$Q.useEffect(()=>{if(xX.current)return;VZ()},[]);let l5=$Q.useCallback((HA,mA)=>{if(HA instanceof ts){bQ("ℹ️ We need your .p8 key file to continue.","yellow"),z("api-key-instructions");return}xQ.current=ar(HA,mA);let SA=HA instanceof Error?HA.message:String(HA),MQ=XB+1,qQ=Ns({kind:"build-init",appId:A,currentStep:mA,packageManager:l4.pm,cwd:U7.cwd(),error:SA,commands:[pK,lK],docs:["https://capgo.app/docs/cli/cloud-build/ios/"],logs:[...WB.slice(-12).map((J0)=>J0.text),...m$.slice(-12)]});if(R7(qQ),oQ(SA),p8(mA),j8(mA==="verifying-key"&&J&&xQ.current!=="apple_agreements_missing"),xB(MQ),MQ>1)bQ(`⚠ Attempt ${MQ} failed. Recovery steps and a support bundle are available below.`,"yellow");z("error")},[XB,bQ,A,pK,m$,lK,WB,l4.pm]),bX=$Q.useRef(l5);$Q.useEffect(()=>{bX.current=l5},[l5]);let kI=$Q.useRef(!1),xD=$Q.useRef(!1);$Q.useEffect(()=>{kI.current=!1,xD.current=!1},[I]);let uM=$Q.useCallback((HA,mA)=>{return PX(HA),j7.current=mA,z("support-confirm"),new Promise((SA)=>{v5.current=SA})},[]),SI=$Q.useCallback(()=>{let HA=VW();if(!HA)return[];try{return sZA(HA,"utf8").split(`
|
|
1105
1105
|
`)}catch{return[]}},[]),mM=$Q.useCallback(async(HA="error")=>{let mA=$H(rQ??"unknown error");await rU({subject:`Capgo Builder support — ${A} (ios)`,body:`Hi Capgo team,
|
|
1106
1106
|
|