UNPKG

@capgo/cli

Version:
40 lines (39 loc) 2.22 MB
import{createRequire as l20}from"node:module";var module={exports:{}};var h20=Object.create;var{getPrototypeOf:b20,defineProperty:PF,getOwnPropertyNames:tu}=Object;var Rw=Object.prototype.hasOwnProperty;function Ew($){return this[$]}var q0=($,D,J)=>{var Q=tu(D);for(let X of Q)if(!Rw.call($,X)&&X!=="default")PF($,X,{get:Ew.bind(D,X),enumerable:!0});if(J){for(let X of Q)if(!Rw.call(J,X)&&X!=="default")PF(J,X,{get:Ew.bind(D,X),enumerable:!0});return J}},g20,m20,P1=($,D,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=D?g20??=new WeakMap:m20??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?h20(b20($)):{};let Z=D||!$||!$.__esModule?PF(J,"default",{value:$,enumerable:!0}):J;for(let F of tu($))if(!Rw.call(Z,F))PF(Z,F,{get:Ew.bind($,F),enumerable:!0});if(Q)X.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var d20=($)=>$;function c20($,D){this[$]=d20.bind(null,D)}var $6=($,D)=>{for(var J in D)PF($,J,{get:D[J],enumerable:!0,configurable:!0,set:c20.bind(D,J)})};var s=($,D)=>()=>($&&(D=$($=0)),D);var D0=l20(import.meta.url);var WD;var B8=s(()=>{WD={name:"@capgo/cli",type:"module",version:"8.39.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/capgo.git",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs","test:package-json-guard":"bun test/test-package-json-guard.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:authenticated-command-invocation":"bun test/test-authenticated-command-invocation.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:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:init-telemetry":"bun test/test-init-telemetry.mjs","test:capacitor-config-target":"bun test/test-capacitor-config-target.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun test/test-init-monorepo-targeting.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:manifest-path-encoding":"bun test/test-manifest-path-encoding.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-flow-contract":"bun test/test-ios-flow-contract.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:ios-marketing-version":"bun test/test-ios-marketing-version.mjs","test:android-version":"bun test/test-android-version.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:auto-bump-version && bun run test:auto-bump-ai-diff && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:package-json-guard && 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:authenticated-command-invocation && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-monorepo-targeting && bun run test:init-app-conflict && bun run test:wait-log && bun run test:init-guardrails && bun run test:init-replay && bun run test:init-telemetry && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:frame-fit-ios-shared && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-e2e && bun run test:ios-flow-contract && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run test:p8-error && bun run test:ios-tui-routing && bun run test:ios-updater-sync-validation && bun run test:ios-verify-app && bun run test:ios-marketing-version && bun run test:android-version && bun run test:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && bun run test:android-app-verification && bun run test:android-rename && bun run test:appflow-auth && bun run test:appflow-api-map && bun run test:appflow-validate && bun run test:appflow-flow && bun run test:appflow-gapfill && bun run test:appflow-engine && bun run test:appflow-tail && bun run test:appflow-fetch && bun run test:appflow-sa-decode && bun run test:app-permission-helper && bun run test:organization-set-api-host && bun run test:trial-warning && bun run test:plan-validation","test:build-platform-selection":"bun test/test-build-platform-selection.mjs","test:ai-log-capture":"bun test/test-ai-log-capture.mjs","test:ai-analyze-flow":"bun test/test-ai-analyze-flow.mjs","test:cicd-failure-help":"bun test/test-cicd-failure-help.mjs","test:ai-analyze-stream":"bun test/test-ai-analyze-stream.mjs","test:ai-sse-parser":"bun test/test-ai-sse-parser.mjs","test:ai-render-markdown":"bun test/test-ai-render-markdown.mjs","test:ai-onboarding-mode":"bun test/test-ai-onboarding-mode.mjs","test:ai-fit":"bun test/test-ai-fit.mjs","test:platform-layout":"bun test/test-platform-layout.mjs","test:frame-fit":"bun test/run-frame-fit.mjs","test:onboarding-min-size":"bun test/test-onboarding-min-size.mjs","test:min-size-gate":"bun test/test-min-size-gate.mjs","test:shell-size-gate":"bun test/test-shell-size-gate.mjs","test:build-log-sanitize":"bun test/test-build-log-sanitize.mjs","test:build-output-viewport":"bun test/test-build-output-viewport.mjs","test:diff-viewer-viewport":"bun test/test-diff-viewer-viewport.mjs","test:build-complete-exit":"bun test/test-build-complete-exit.mjs","test:ai-stream-markdown":"bun test/test-ai-stream-markdown.mjs","test:support-mailto":"bun test/test-support-mailto.mjs","test:support-redact":"bun test/test-support-redact.mjs","test:support-internal-log":"bun test/test-support-internal-log.mjs","test:support-help-menu":"bun test/test-support-help-menu.mjs","test:support-contact":"bun test/test-support-contact.mjs","test:support-upload-prompt":"bun test/test-support-upload-prompt.mjs","test:support-bundle-files":"bun test/test-support-bundle-files.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.mjs","test:app-set-options":"bun test/test-app-set-options.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-app-verification":"bun test/test-android-app-verification.mjs","test:android-rename":"bun test/test-android-rename.mjs","test:appflow-auth":"bun test/test-appflow-auth.mjs","test:appflow-api-map":"bun test/test-appflow-api-map.mjs","test:appflow-validate":"bun test/test-appflow-validate.mjs","test:appflow-flow":"bun test/test-appflow-flow.mjs","test:appflow-gapfill":"bun test/test-appflow-gapfill.mjs","test:appflow-engine":"bun test/test-appflow-engine.mjs","test:appflow-tail":"bun test/test-appflow-tail.mjs","test:appflow-fetch":"bun test/test-appflow-fetch.mjs","test:appflow-sa-decode":"bun test/test-appflow-sa-decode.mjs","test:app-permission-helper":"bun test/test-app-permission-helper.mjs","test:organization-set-api-host":"bun test/test-organization-set-api-host.mjs","test:trial-warning":"bun test/test-trial-warning.mjs","test:plan-validation":"bun test/test-plan-validation.mjs","test:auto-bump-version":"bun test/test-auto-bump-version.mjs","test:auto-bump-ai-diff":"bun test/test-auto-bump-ai-diff.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@rrweb/types":"^2.1.1","@xmldom/xmldom":"^0.9.10","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","happy-dom":"^20.11.0",ink:"^7.1.1","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.8","rrweb-snapshot":"^2.1.1","string-width":"^8.2.2",zod:"^4.4.3","@standard-schema/spec":"^1.1.0"},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.2.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.4.2","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.7.0","@modelcontextprotocol/client":"^2.0.0-beta.5","@modelcontextprotocol/server":"^2.0.0-beta.5","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.110.8","@tanstack/intent":"^0.3.6","@types/adm-zip":"^0.5.8","@types/jsonwebtoken":"^9.0.10","@types/node":"^26.1.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.17","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native-preview":"7.0.0-dev.20260707.2","@vercel/ncc":"^0.44.1","@xterm/headless":"^6.0.0","adm-zip":"^0.6.0","ci-info":"^4.4.0",commander:"^15.0.0",eslint:"^10.7.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.75.0",partysocket:"^1.3.0",prettyjson:"^1.2.5",tmp:"^0.2.7","tus-js-client":"^4.3.1",typescript:"6.0.3",ws:"^8.21.1"}}});import{platform as p20}from"node:os";import{version as i20}from"node:process";function m1($){return{capgo_api:r20,"x-cli-version":WD.version,"x-cli-command":o20,"x-cli-node":i20,"x-cli-os":p20(),...$}}var r20="2025-10-01",o20="";var o6=s(()=>{B8()});var su,eu=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},$f=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var Df=s(()=>{su=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let J=0;$.lastIndex=0;while($.test(D))J+=1;return D.length-J}})()});var a20,t20,Jf,s20,Qf,e20,$R0,DR0,Xf=($,D={},J={})=>{let Q=D.limit??1/0,X=D.ellipsis??"",Y=D?.ellipsisWidth??(X?Xf(X,DR0,J).width:0),Z=0,F=J.controlWidth??0,G=J.tabWidth??8,U=J.emojiWidth??2,W=2,q=J.regularWidth??1,z=J.wideWidth??2,H=[[e20,q],[a20,0],[t20,F],[s20,G],[Qf,U],[Jf,z]],K=0,V=0,O=$.length,N=0,B=!1,L=O,M=Math.max(0,Q-Y),w=0,R=0,P=0,v=0;$:while(!0){if(R>w||V>=O&&V>K){let A=$.slice(w,R)||$.slice(K,V);N=0;for(let _ of A.replaceAll($R0,"")){let x=_.codePointAt(0)||0;if(eu(x))v=2;else if($f(x))v=z;else v=q;if(P+v>M)L=Math.min(L,Math.max(w,K)+N);if(P+v>Q){B=!0;break $}N+=_.length,P+=v}w=R=0}if(V>=O)break $;for(let A=0,_=H.length;A<_;A++){let[x,b]=H[A];if(x.lastIndex=V,x.test($)){if(N=x===Jf?su($.slice(V,x.lastIndex)):x===Qf?1:x.lastIndex-V,v=N*b,P+v>M)L=Math.min(L,V+Math.floor((M-P)/b));if(P+v>Q){B=!0;break $}P+=v,w=K,R=V,V=K=x.lastIndex;continue $}}V+=1}return{width:B?M:P,index:B?L:O,truncated:B,ellipsed:B&&Q>=Y}},Yf;var Zf=s(()=>{Df();a20=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,t20=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Jf=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,s20=/\t{1,1000}/y,Qf=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,e20=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$R0=/\p{M}+/gu,DR0={limit:1/0,ellipsis:""},Yf=Xf});var JR0,QR0=($,D={})=>{return Yf($,JR0,D).width},R8;var Aw=s(()=>{Zf();JR0={limit:1/0,ellipsis:"",ellipsisWidth:0},R8=QR0});function H7($,D,J){return String($).normalize().split(GR0).map((Q)=>FR0(Q,D,J)).join(` `)}var Eq="\x1B",qf="›",XR0=39,Iw="\x07",zf="[",YR0="]",Hf="m",Tw,Ff,Gf=($)=>{if($>=30&&$<=37)return 39;if($>=90&&$<=97)return 39;if($>=40&&$<=47)return 49;if($>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0;return},Uf=($)=>`${Eq}${zf}${$}${Hf}`,Wf=($)=>`${Eq}${Tw}${$}${Iw}`,jw=($,D,J)=>{let Q=D[Symbol.iterator](),X=!1,Y=!1,Z=$.at(-1),F=Z===void 0?0:R8(Z),G=Q.next(),U=Q.next(),W=0;while(!G.done){let q=G.value,z=R8(q);if(F+z<=J)$[$.length-1]+=q;else $.push(q),F=0;if(q===Eq||q===qf)X=!0,Y=D.startsWith(Tw,W+1);if(X){if(Y){if(q===Iw)X=!1,Y=!1}else if(q===Hf)X=!1}else if(F+=z,F===J&&!U.done)$.push(""),F=0;G=U,U=Q.next(),W+=q.length}if(Z=$.at(-1),!F&&Z!==void 0&&Z.length&&$.length>1)$[$.length-2]+=$.pop()},ZR0=($)=>{let D=$.split(" "),J=D.length;while(J){if(R8(D[J-1]))break;J--}if(J===D.length)return $;return D.slice(0,J).join(" ")+D.slice(J).join("")},FR0=($,D,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Q="",X,Y,Z=$.split(" "),F=[""],G=0;for(let q=0;q<Z.length;q++){let z=Z[q];if(J.trim!==!1){let K=F.at(-1)??"",V=K.trimStart();if(K.length!==V.length)F[F.length-1]=V,G=R8(V)}if(q!==0){if(G>=D&&(J.wordWrap===!1||J.trim===!1))F.push(""),G=0;if(G||J.trim===!1)F[F.length-1]+=" ",G++}let H=R8(z);if(J.hard&&H>D){let K=D-G,V=1+Math.floor((H-K-1)/D);if(Math.floor((H-1)/D)<V)F.push("");jw(F,z,D),G=R8(F.at(-1)??"");continue}if(G+H>D&&G&&H){if(J.wordWrap===!1&&G<D){jw(F,z,D),G=R8(F.at(-1)??"");continue}F.push(""),G=0}if(G+H>D&&J.wordWrap===!1){jw(F,z,D),G=R8(F.at(-1)??"");continue}F[F.length-1]+=z,G+=H}if(J.trim!==!1)F=F.map((q)=>ZR0(q));let U=F.join(` `),W=!1;for(let q=0;q<U.length;q++){let z=U[q];if(Q+=z,!W){if(W=z>="\uD800"&&z<="\uDBFF",W)continue}else W=!1;if(z===Eq||z===qf){Ff.lastIndex=q+1;let K=Ff.exec(U)?.groups;if(K?.code!==void 0){let V=Number.parseFloat(K.code);X=V===XR0?void 0:V}else if(K?.uri!==void 0)Y=K.uri.length===0?void 0:K.uri}if(U[q+1]===` `){if(Y)Q+=Wf("");let H=X?Gf(X):void 0;if(X&&H)Q+=Uf(H)}else if(z===` `){if(X&&Gf(X))Q+=Uf(X);if(Y)Q+=Wf(Y)}}return Q},GR0;var Cw=s(()=>{Aw();Tw=`${YR0}8;;`,Ff=new RegExp(`(?:\\${zf}(?<code>\\d+)m|\\${Tw}(?<uri>.*)${Iw})`,"y"),GR0=/\r?\n/});var j$=E((AI1,Kf)=>{var Pw={to($,D){if(!D)return`\x1B[${$+1}G`;return`\x1B[${D+1};${$+1}H`},move($,D){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(D<0)J+=`\x1B[${-D}A`;else if(D>0)J+=`\x1B[${D}B`;return J},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},UR0={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},WR0={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let D="";for(let J=0;J<$;J++)D+=this.line+(J<$-1?Pw.up():"");if($)D+=Pw.left;return D}};Kf.exports={cursor:Pw,scroll:UR0,erase:WR0,beep:"\x07"}});import{styleText as hQ}from"node:util";import{stdout as _w,stdin as Mf}from"node:process";import*as K7 from"node:readline";import qR0 from"node:readline";import{ReadStream as Vf}from"node:tty";function fQ($,D,J){if(!J.some((Z)=>!Z.disabled))return $;let Q=$+D,X=Math.max(J.length-1,0),Y=Q<0?X:Q>X?0:Q;return J[Y]?.disabled?fQ(Y,D<0?-1:1,J):Y}function Aq($,D,J,Q){let X=Q.split(` `),Y=0,Z=$;for(let G of X){if(Z<=G.length)break;Z-=G.length+1,Y++}for(Y=Math.max(0,Math.min(X.length-1,Y+J)),Z=Math.min(Z,X[Y].length)+D;Z<0&&Y>0;)Y--,Z+=X[Y].length+1;for(;Z>X[Y].length&&Y<X.length-1;)Z-=X[Y].length+1,Y++;Z=Math.max(0,Math.min(X[Y].length,Z));let F=0;for(let G=0;G<Y;G++)F+=X[G].length+1;return F+Z}function kw($,D){if(typeof $=="string")return MD.aliases.get($)===D;for(let J of $)if(J!==void 0&&kw(J,D))return!0;return!1}function KR0($,D){if($===D)return;let J=$.split(` `),Q=D.split(` `),X=Math.max(J.length,Q.length),Y=[];for(let Z=0;Z<X;Z++)J[Z]!==Q[Z]&&Y.push(Z);return{lines:Y,numLinesBefore:J.length,numLinesAfter:Q.length,numLines:X}}function B1($){return $===xw}function jq($,D){let J=$;J.isTTY&&J.setRawMode(D)}function Nf({input:$=Mf,output:D=_w,overwrite:J=!0,hideCursor:Q=!0}={}){let X=K7.createInterface({input:$,output:D,prompt:"",tabSize:1});K7.emitKeypressEvents($,X),$ instanceof Vf&&$.isTTY&&$.setRawMode(!0);let Y=(Z,{name:F,sequence:G})=>{let U=String(Z);if(kw([U,F,G],"cancel")){Q&&D.write(nD.cursor.show),process.exit(0);return}if(!J)return;K7.moveCursor(D,F==="return"?0:-1,F==="return"?-1:0,()=>{K7.clearLine(D,1,()=>{$.once("keypress",Y)})})};return Q&&D.write(nD.cursor.hide),$.once("keypress",Y),()=>{$.off("keypress",Y),Q&&D.write(nD.cursor.show),$ instanceof Vf&&$.isTTY&&!VR0&&$.setRawMode(!1),X.terminal=!1,X.close()}}function SF($,D,J,Q=J,X=J,Y){let Z=Tq($??_w);return H7(D,Z-J.length,{hard:!0,trim:!1}).split(` `).map((F,G,U)=>{let W=Y?Y(F,G):F;return G===0?`${Q}${W}`:G===U.length-1?`${X}${W}`:`${J}${W}`}).join(` `)}function wf($,D){if("~standard"in $){let J=$["~standard"].validate(D);if(J instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return J.issues?.at(0)?.message}return $(D)}class B9{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,D=!0){let{input:J=Mf,output:Q=_w,render:X,signal:Y,...Z}=$;this.opts=Z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=X.bind(this),this._track=D,this._abortSignal=Y,this.input=J,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber($,D){let J=this._subscribers.get($)??[];J.push(D),this._subscribers.set($,J)}on($,D){this.setSubscriber($,{cb:D})}once($,D){this.setSubscriber($,{cb:D,once:!0})}emit($,...D){let J=this._subscribers.get($)??[],Q=[];for(let X of J)X.cb(...D),X.once&&Q.push(()=>J.splice(J.indexOf(X),1));for(let X of Q)X()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(xw);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=qR0.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),jq(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(nD.cursor.show),this.output.off("resize",this.render),jq(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(nD.cursor.show),this.output.off("resize",this.render),jq(this.input,!1),$(xw)})})}_isActionKey($,D){return $==="\t"}_shouldSubmit($,D){return!0}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,D){this.userInput=$??"",this.emit("userInput",this.userInput),D&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,D){if(this._track&&D.name!=="return"&&(D.name&&this._isActionKey($,D)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),D?.name&&(!this._track&&MD.aliases.has(D.name)&&this.emit("cursor",MD.aliases.get(D.name)),MD.actions.has(D.name)&&this.emit("cursor",D.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$,D),D?.name==="return"&&this._shouldSubmit($,D)){if(this.opts.validate){let J=wf(this.opts.validate,this.value);J&&(this.error=J instanceof Error?J.message:J,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}kw([$,D?.name,D?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` `),jq(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=H7(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(` `).length-1;this.output.write(nD.cursor.move(-999,$*-1))}render(){let $=H7(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(nD.cursor.hide);else{let D=KR0(this._prevFrame,$),J=yw(this.output);if(this.restoreCursor(),D){let Q=Math.max(0,D.numLinesAfter-J),X=Math.max(0,D.numLinesBefore-J),Y=D.lines.find((Z)=>Z>=Q);if(Y===void 0){this._prevFrame=$;return}if(D.lines.length===1){this.output.write(nD.cursor.move(0,Y-X)),this.output.write(nD.erase.lines(1));let Z=$.split(` `);this.output.write(Z[Y]),this._prevFrame=$,this.output.write(nD.cursor.move(0,Z.length-Y-1));return}else if(D.lines.length>1){if(Q<X)Y=Q;else{let F=Y-X;F>0&&this.output.write(nD.cursor.move(0,F))}this.output.write(nD.erase.down());let Z=$.split(` `).slice(Y);this.output.write(Z.join(` `)),this._prevFrame=$;return}}this.output.write(nD.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function OR0($,D){if($===void 0||D.length===0)return 0;let J=D.findIndex((Q)=>Q.value===$);return J!==-1?J:0}function LR0($,D){return(D.label??String(D.value)).toLowerCase().includes($.toLowerCase())}function MR0($,D){if(D)return $?D:D[0]}function Of($){return[...$].map((D)=>wR0[D])}function BR0($){let D=new Intl.DateTimeFormat($,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),J=[],Q="/";for(let X of D)X.type==="literal"?Q=X.value.trim()||X.value:(X.type==="year"||X.type==="month"||X.type==="day")&&J.push({type:X.type,len:X.type==="year"?4:2});return{segments:J,separator:Q}}function Sw($){return Number.parseInt(($||"0").replace(/_/g,"0"),10)||0}function Iq($){return{year:Sw($.year),month:Sw($.month),day:Sw($.day)}}function vw($,D){return new Date($||2001,D||1,0).getDate()}function Bf($){let{year:D,month:J,day:Q}=Iq($);if(!D||D<0||D>9999||!J||J<1||J>12||!Q||Q<1)return;let X=new Date(Date.UTC(D,J-1,Q));if(!(X.getUTCFullYear()!==D||X.getUTCMonth()!==J-1||X.getUTCDate()!==Q))return{year:D,month:J,day:Q}}function Lf($){let D=Bf($);return D?new Date(Date.UTC(D.year,D.month-1,D.day)):void 0}function RR0($,D,J,Q){let X=J?{year:J.getUTCFullYear(),month:J.getUTCMonth()+1,day:J.getUTCDate()}:null,Y=Q?{year:Q.getUTCFullYear(),month:Q.getUTCMonth()+1,day:Q.getUTCDate()}:null;return $==="year"?{min:X?.year??1,max:Y?.year??9999}:$==="month"?{min:X&&D.year===X.year?X.month:1,max:Y&&D.year===Y.year?Y.month:12}:{min:X&&D.year===X.year&&D.month===X.month?X.day:1,max:Y&&D.year===Y.year&&D.month===Y.month?Y.day:vw(D.year,D.month)}}var nD,zR0,HR0,MD,VR0,xw,Tq=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,yw=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20,NR0,uw,wR0,Rf,ER0,AR0,Ef,Af,jf,fw;var hw=s(()=>{Cw();nD=P1(j$(),1);zR0=["up","down","left","right","space","enter","cancel"],HR0=["January","February","March","April","May","June","July","August","September","October","November","December"],MD={actions:new Set(zR0),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...HR0],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:($,D)=>`There are only ${$} days in ${D}`,afterMin:($)=>`Date must be on or after ${$.toISOString().slice(0,10)}`,beforeMax:($)=>`Date must be on or before ${$.toISOString().slice(0,10)}`}}};VR0=globalThis.process.platform.startsWith("win"),xw=Symbol("clack:cancel");NR0=class extends B9{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#D=0;#X="";#$;#Y;#F;get cursor(){return this.#D}get userInputWithCursor(){if(!this.userInput)return hQ(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let D=this.userInput.slice(0,this.cursor),J=this.userInput.slice(this.cursor,this.cursor+1),Q=this.userInput.slice(this.cursor+1);return`${D}${hQ("inverse",J)}${Q}`}get options(){return typeof this.#Y=="function"?this.#Y():this.#Y}constructor(D){super(D),this.#Y=D.options,this.#F=D.placeholder;let J=this.options;this.filteredOptions=[...J],this.multiple=D.multiple===!0,this.#$=typeof D.options=="function"?D.filter:D.filter??LR0;let Q;if(D.initialValue&&Array.isArray(D.initialValue)?this.multiple?Q=D.initialValue:Q=D.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(Q=[this.options[0]?.value]),Q)for(let X of Q){let Y=J.findIndex((Z)=>Z.value===X);Y!==-1&&(this.toggleSelected(X),this.#D=Y)}this.focusedValue=this.options[this.#D]?.value,this.on("key",(X,Y)=>this.#J(X,Y)),this.on("userInput",(X)=>this.#Q(X))}_isActionKey(D,J){return D==="\t"||this.multiple&&this.isNavigating&&J.name==="space"&&D!==void 0&&D!==""}#J(D,J){let Q=J.name==="up",X=J.name==="down",Y=J.name==="return",Z=this.userInput===""||this.userInput==="\t",F=this.#F,G=this.options,U=F!==void 0&&F!==""&&G.some((W)=>!W.disabled&&(this.#$?this.#$(F,W):!0));if(J.name==="tab"&&Z&&U){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(F,!0),this.isNavigating=!1;return}Q||X?(this.#D=fQ(this.#D,Q?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#D]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):Y?this.value=MR0(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(J.name==="tab"||this.isNavigating&&J.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(D){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(D)?this.selectedValues=this.selectedValues.filter((J)=>J!==D):this.selectedValues=[...this.selectedValues,D]:this.selectedValues=[D])}#Q(D){if(D!==this.#X){this.#X=D;let J=this.options;D&&this.#$?this.filteredOptions=J.filter((Y)=>this.#$?.(D,Y)):this.filteredOptions=[...J];let Q=OR0(this.focusedValue,this.filteredOptions);this.#D=fQ(Q,0,this.filteredOptions);let X=this.filteredOptions[this.#D];X&&!X.disabled?this.focusedValue=X.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};uw=class uw extends B9{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(D)=>{this.output.write(nD.cursor.move(0,-1)),this.value=D,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};wR0={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};Rf=class Rf extends B9{#D;#X;#$;#Y;#F;#J={segmentIndex:0,positionInSegment:0};#Q=!0;#Z=null;inlineError="";get segmentCursor(){return{...this.#J}}get segmentValues(){return{...this.#$}}get segments(){return this.#D}get separator(){return this.#X}get formattedValue(){return this.#q(this.#$)}#q($){return this.#D.map((D)=>$[D.type]).join(this.#X)}#G(){this._setUserInput(this.#q(this.#$)),this._setValue(Lf(this.#$)??void 0)}constructor($){let D=$.format?{segments:Of($.format),separator:$.separator??"/"}:BR0($.locale),J=$.separator??D.separator,Q=$.format?Of($.format):D.segments,X=$.initialValue??$.defaultValue,Y=X?{year:String(X.getUTCFullYear()).padStart(4,"0"),month:String(X.getUTCMonth()+1).padStart(2,"0"),day:String(X.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},Z=Q.map((F)=>Y[F.type]).join(J);super({...$,initialUserInput:Z},!1),this.#D=Q,this.#X=J,this.#$=Y,this.#Y=$.minDate,this.#F=$.maxDate,this.#G(),this.on("cursor",(F)=>this.#K(F)),this.on("key",(F,G)=>this.#V(F,G)),this.on("finalize",()=>this.#O($))}#U(){let $=Math.max(0,Math.min(this.#J.segmentIndex,this.#D.length-1)),D=this.#D[$];if(D)return this.#J.positionInSegment=Math.max(0,Math.min(this.#J.positionInSegment,D.len-1)),{segment:D,index:$}}#W($){this.inlineError="",this.#Z=null;let D=this.#U();D&&(this.#J.segmentIndex=Math.max(0,Math.min(this.#D.length-1,D.index+$)),this.#J.positionInSegment=0,this.#Q=!0)}#z($){let D=this.#U();if(!D)return;let{segment:J}=D,Q=this.#$[J.type],X=!Q||Q.replace(/_/g,"")==="",Y=Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0,Z=RR0(J.type,Iq(this.#$),this.#Y,this.#F),F;X?F=$===1?Z.min:Z.max:F=Math.max(Math.min(Z.max,Y+$),Z.min),this.#$={...this.#$,[J.type]:F.toString().padStart(J.len,"0")},this.#Q=!0,this.#Z=null,this.#G()}#K($){if($)switch($){case"right":return this.#W(1);case"left":return this.#W(-1);case"up":return this.#z(1);case"down":return this.#z(-1)}}#V($,D){if(D?.name==="backspace"||D?.sequence===""||D?.sequence==="\b"||$===""||$==="\b"){this.inlineError="";let J=this.#U();if(!J)return;if(!this.#$[J.segment.type].replace(/_/g,"")){this.#W(-1);return}this.#$[J.segment.type]="_".repeat(J.segment.len),this.#Q=!0,this.#J.positionInSegment=0,this.#G();return}if(D?.name==="tab"){this.inlineError="";let J=this.#U();if(!J)return;let Q=D.shift?-1:1,X=J.index+Q;X>=0&&X<this.#D.length&&(this.#J.segmentIndex=X,this.#J.positionInSegment=0,this.#Q=!0);return}if($&&/^[0-9]$/.test($)){let J=this.#U();if(!J)return;let{segment:Q}=J,X=!this.#$[Q.type].replace(/_/g,"");if(this.#Q&&this.#Z!==null&&!X){let z=this.#Z+$,H={...this.#$,[Q.type]:z},K=this.#H(H,Q);if(K){this.inlineError=K,this.#Z=null,this.#Q=!1;return}this.inlineError="",this.#$[Q.type]=z,this.#Z=null,this.#Q=!1,this.#G(),J.index<this.#D.length-1&&(this.#J.segmentIndex=J.index+1,this.#J.positionInSegment=0,this.#Q=!0);return}this.#Q&&!X&&(this.#$[Q.type]="_".repeat(Q.len),this.#J.positionInSegment=0),this.#Q=!1,this.#Z=null;let Y=this.#$[Q.type],Z=Y.indexOf("_"),F=Z>=0?Z:Math.min(this.#J.positionInSegment,Q.len-1);if(F<0||F>=Q.len)return;let G=Y.slice(0,F)+$+Y.slice(F+1),U=!1;if(F===0&&Y==="__"&&(Q.type==="month"||Q.type==="day")){let z=Number.parseInt($,10);G=`0${$}`,U=z<=(Q.type==="month"?1:2)}if(Q.type==="year"&&(G=(Y.replace(/_/g,"")+$).padStart(Q.len,"_")),!G.includes("_")){let z={...this.#$,[Q.type]:G},H=this.#H(z,Q);if(H){this.inlineError=H;return}}this.inlineError="",this.#$[Q.type]=G;let W=G.includes("_")?void 0:Bf(this.#$);if(W){let{year:z,month:H}=W,K=vw(z,H);this.#$={year:String(Math.max(0,Math.min(9999,z))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,H))).padStart(2,"0"),day:String(Math.max(1,Math.min(K,W.day))).padStart(2,"0")}}this.#G();let q=G.indexOf("_");U?(this.#Q=!0,this.#Z=$):q>=0?this.#J.positionInSegment=q:Z>=0&&J.index<this.#D.length-1?(this.#J.segmentIndex=J.index+1,this.#J.positionInSegment=0,this.#Q=!0):this.#J.positionInSegment=Math.min(F+1,Q.len-1)}}#H($,D){let{month:J,day:Q}=Iq($);if(D.type==="month"&&(J<0||J>12))return MD.date.messages.invalidMonth;if(D.type==="day"&&(Q<0||Q>31))return MD.date.messages.invalidDay(31,"any month")}#O($){let{year:D,month:J,day:Q}=Iq(this.#$);if(D&&J&&Q){let X=vw(D,J);this.#$={...this.#$,day:String(Math.min(Q,X)).padStart(2,"0")}}this.value=Lf(this.#$)??$.defaultValue??void 0}};ER0=class extends B9{options;cursor=0;#D;getGroupItems(D){return this.options.filter((J)=>J.group===D)}isGroupSelected(D){let J=this.getGroupItems(D),Q=this.value;return Q===void 0?!1:J.every((X)=>Q.includes(X.value))}toggleValue(){let D=this.options[this.cursor];if(D!==void 0)if(this.value===void 0&&(this.value=[]),D.group===!0){let J=D.value,Q=this.getGroupItems(J);this.isGroupSelected(J)?this.value=this.value.filter((X)=>Q.findIndex((Y)=>Y.value===X)===-1):this.value=[...this.value,...Q.map((X)=>X.value)],this.value=Array.from(new Set(this.value))}else{let J=this.value.includes(D.value);this.value=J?this.value.filter((Q)=>Q!==D.value):[...this.value,D.value]}}constructor(D){super(D,!1);let{options:J}=D;this.#D=D.selectableGroups!==!1,this.options=Object.entries(J).flatMap(([Q,X])=>[{value:Q,group:!0,label:Q},...X.map((Y)=>({...Y,group:Q}))]),this.value=[...D.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===D.cursorAt),this.#D?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let X=this.options[this.cursor]?.group===!0;!this.#D&&X&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let X=this.options[this.cursor]?.group===!0;!this.#D&&X&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},AR0=new Set(["up","down","left","right"]);Ef=class Ef extends B9{#D=!1;#X;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${$}█`;let D=$.slice(0,this.cursor),J=$.slice(this.cursor,this.cursor+1),Q=$.slice(this.cursor+1);return J===` `?`${D}█ ${Q}`:`${D}${hQ("inverse",J)}${Q}`}get cursor(){return this._cursor}#$($){if(this.userInput.length===0){this._setUserInput($);return}this._setUserInput(this.userInput.slice(0,this.cursor)+$+this.userInput.slice(this.cursor))}#Y($){let D=this.value??"";switch($){case"up":this._cursor=Aq(this._cursor,0,-1,D);return;case"down":this._cursor=Aq(this._cursor,0,1,D);return;case"left":this._cursor=Aq(this._cursor,-1,0,D);return;case"right":this._cursor=Aq(this._cursor,1,0,D);return}}_shouldSubmit($,D){if(this.#X)return this.focused==="submit"?!0:(this.#$(` `),this._cursor++,!1);let J=this.#D;return this.#D=!0,J&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===` `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#$(` `),this._cursor++,!1)}constructor($){let D=$.initialUserInput??$.initialValue;super({...$,initialUserInput:D},!1),D!==void 0&&(this._cursor=D.length),this.#X=$.showSubmit??!1,this.on("key",(J,Q)=>{if(Q?.name&&AR0.has(Q.name)){this.#D=!1,this.#Y(Q.name);return}if(J==="\t"&&this.#X){this.focused=this.focused==="editor"?"submit":"editor";return}if(Q?.name!=="return"){if(this.#D=!1,Q?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(Q?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}J&&(this.#X&&this.focused==="submit"&&(this.focused="editor"),this.#$(J??""),this._cursor++)}}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}};Af=class extends B9{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let D=this.userInput;if(this.cursor>=D.length)return`${this.masked}${hQ(["inverse","hidden"],"_")}`;let J=this.masked,Q=J.slice(0,this.cursor),X=J.slice(this.cursor,this.cursor+1),Y=J.slice(this.cursor+1);return`${Q}${hQ("inverse",X)}${Y}`}clear(){this._clearUserInput()}constructor({mask:D,...J}){super(J),this._mask=D??"•",this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value===void 0&&(this.value="")})}},jf=class extends B9{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let D=this._selectedValue;this.value=D===void 0?void 0:D.value}constructor(D){super(D,!1),this.options=D.options;let J=this.options.findIndex(({value:X})=>X===D.initialValue),Q=J===-1?0:J;this.cursor=this.options[Q]?.disabled?fQ(Q,1,this.options):Q,this.changeValue(),this.on("cursor",(X)=>{switch(X){case"left":case"up":this.cursor=fQ(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=fQ(this.cursor,1,this.options);break}this.changeValue()})}};fw=class fw extends B9{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let D=$.slice(0,this.cursor),J=$.slice(this.cursor,this.cursor+1),Q=$.slice(this.cursor+1);return`${D}${hQ("inverse",J)}${Q}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(D)=>{this._setValue(D)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}});import{styleText as R0,stripVTControlCharacters as uI1}from"node:util";import o4 from"node:process";function jR0(){if(o4.platform!=="win32")return o4.env.TERM!=="linux";return Boolean(o4.env.CI)||Boolean(o4.env.WT_SESSION)||Boolean(o4.env.TERMINUS_SUBLIME)||o4.env.ConEmuTask==="{cmd::Cmder}"||o4.env.TERM_PROGRAM==="Terminus-Sublime"||o4.env.TERM_PROGRAM==="vscode"||o4.env.TERM==="xterm-256color"||o4.env.TERM==="alacritty"||o4.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function yR0($,D){let J=[`${D?`${R0("cyan",d1)} `:""}${$.join(" • ")}`];return D&&J.push(R0("cyan",V7)),J}var xF,bw,IR0=()=>process.env.CI==="true",F$=($,D)=>bw?$:D,TR0,Tf,Cf,mw,CR0,d1,V7,gI1,mI1,gw,Pq,dI1,cI1,lI1,PR0,nI1,pI1,iI1,rI1,oI1,aI1,SR0,xR0,vR0,_R0,Sq=($)=>{switch($){case"initial":case"active":return R0("cyan",TR0);case"cancel":return R0("red",Tf);case"error":return R0("yellow",Cf);case"submit":return R0("green",mw)}},kR0=($)=>{switch($){case"initial":case"active":return R0("cyan",d1);case"cancel":return R0("red",d1);case"error":return R0("yellow",d1);case"submit":return R0("green",d1)}},If=($,D,J,Q,X,Y=!1)=>{let Z=D,F=0;if(Y)for(let G=Q-1;G>=J;G--){let U=$[G];if(U&&(Z-=U.length),F++,Z<=X)break}else for(let G=J;G<Q;G++){let U=$[G];if(U&&(Z-=U.length),F++,Z<=X)break}return{lineCount:Z,removals:F}},uR0=({cursor:$,options:D,style:J,output:Q=process.stdout,maxItems:X=Number.POSITIVE_INFINITY,columnPadding:Y=0,rowPadding:Z=4})=>{let F=Tq(Q)-Y,G=yw(Q),U=R0("dim","..."),W=Math.max(G-Z,0),q=Math.max(Math.min(X,W),5),z=0;$>=q-3&&(z=Math.max(Math.min($-q+3,D.length-q),0));let H=q<D.length&&z>0,K=q<D.length&&z+q<D.length,V=Math.min(z+q,D.length),O=[],N=0;H&&N++,K&&N++;let B=z+(H?1:0),L=V-(K?1:0);for(let w=B;w<L;w++){let R=D[w],P=R?J(R,w===$):"",v=H7(P,F,{hard:!0,trim:!1}).split(` `);O.push(v),N+=v.length}if(N>W){let w=0,R=0,P=N,v=$-B,A=W,_=()=>If(O,P,0,v,A),x=()=>If(O,P,v+1,O.length,A,!0);H?({lineCount:P,removals:w}=_(),P>A&&(K||(A-=1),{lineCount:P,removals:R}=x())):(K||(A-=1),{lineCount:P,removals:R}=x(),P>A&&(A-=1,{lineCount:P,removals:w}=_())),w>0&&(H=!0,O.splice(0,w)),R>0&&(K=!0,O.splice(O.length-R,R))}let M=[];H&&M.push(U);for(let w of O)for(let R of w)M.push(R);return K&&M.push(U),M},I$=($)=>{let D=$.active??"Yes",J=$.inactive??"No";return new uw({active:D,inactive:J,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let Q=$.withGuide??MD.withGuide,X=`${Sq(this.state)} `,Y=Q?`${R0("gray",d1)} `:"",Z=SF($.output,$.message,Y,X),F=`${Q?`${R0("gray",d1)} `:""}${Z} `,G=this.value?D:J;switch(this.state){case"submit":{let U=Q?`${R0("gray",d1)} `:"";return`${F}${U}${R0("dim",G)}`}case"cancel":{let U=Q?`${R0("gray",d1)} `:"";return`${F}${U}${R0(["strikethrough","dim"],G)}${Q?` ${R0("gray",d1)}`:""}`}default:{let U=Q?`${R0("cyan",d1)} `:"",W=Q?R0("cyan",V7):"";return`${F}${U}${this.value?`${R0("green",gw)} ${D}`:`${R0("dim",Pq)} ${R0("dim",D)}`}${$.vertical?Q?` ${R0("cyan",d1)} `:` `:` ${R0("dim","/")} `}${this.value?`${R0("dim",Pq)} ${R0("dim",J)}`:`${R0("green",gw)} ${J}`} ${W} `}}}}).prompt()},tI1,S,p0=($="",D)=>{let J=D?.output??process.stdout,Q=D?.withGuide??MD.withGuide?`${R0("gray",CR0)} `:"";J.write(`${Q}${$} `)},o0=($="",D)=>{let J=D?.output??process.stdout,Q=D?.withGuide??MD.withGuide?`${R0("gray",d1)} ${R0("gray",V7)} `:"";J.write(`${Q}${$} `)},dw=($)=>new Af({validate:$.validate,mask:$.mask??PR0,signal:$.signal,input:$.input,output:$.output,render(){let D=$.withGuide??MD.withGuide,J=`${D?`${R0("gray",d1)} `:""}${Sq(this.state)} ${$.message} `,Q=this.userInputWithCursor,X=this.masked;switch(this.state){case"error":{let Y=D?`${R0("yellow",d1)} `:"",Z=D?`${R0("yellow",V7)} `:"",F=X??"";return $.clearOnError&&this.clear(),`${J.trim()} ${Y}${F} ${Z}${R0("yellow",this.error)} `}case"submit":{let Y=D?`${R0("gray",d1)} `:"",Z=X?R0("dim",X):"";return`${J}${Y}${Z}`}case"cancel":{let Y=D?`${R0("gray",d1)} `:"",Z=X?R0(["strikethrough","dim"],X):"";return`${J}${Y}${Z}${X&&D?` ${R0("gray",d1)}`:""}`}default:{let Y=D?`${R0("cyan",d1)} `:"",Z=D?R0("cyan",V7):"";return`${J}${Y}${Q} ${Z} `}}}}).prompt(),fR0=($)=>R0("magenta",$),f$=({indicator:$="dots",onCancel:D,output:J=process.stdout,cancelMessage:Q,errorMessage:X,frames:Y=bw?["◒","◐","◓","◑"]:["•","o","O","0"],delay:Z=bw?80:120,signal:F,...G}={})=>{let