@capgo/cli 8.53.1 → 8.53.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import type { Command } from 'commander';
2
2
  export interface OnboardingCheckOptions {
3
3
  cwd: string;
4
4
  command: string;
5
+ attemptId?: string;
5
6
  appId?: string;
6
7
  apikey?: string;
7
8
  capacitorConfig?: string;
package/dist/src/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import{createRequire as Bj0}from"node:module";var module={exports:{}};var Oj0=Object.create;var{getPrototypeOf:zj0,defineProperty:rF,getOwnPropertyNames:Ib}=Object;var H2=Object.prototype.hasOwnProperty;function V2($){return this[$]}var H0=($,D,Q)=>{var X=Ib(D);for(let J of X)if(!H2.call($,J)&&J!=="default")rF($,J,{get:V2.bind(D,J),enumerable:!0});if(Q){for(let J of X)if(!H2.call(Q,J)&&J!=="default")rF(Q,J,{get:V2.bind(D,J),enumerable:!0});return Q}},Lj0,Mj0,S1=($,D,Q)=>{var X=$!=null&&typeof $==="object";if(X){var J=D?Lj0??=new WeakMap:Mj0??=new WeakMap,Y=J.get($);if(Y)return Y}Q=$!=null?Oj0(zj0($)):{};let Z=D||!$||!$.__esModule?rF(Q,"default",{value:$,enumerable:!0}):Q;for(let F of Ib($))if(!H2.call(Z,F))rF(Z,F,{get:V2.bind($,F),enumerable:!0});if(X)J.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var Nj0=($)=>$;function wj0($,D){this[$]=Nj0.bind(null,D)}var Q6=($,D)=>{for(var Q in D)rF($,Q,{get:D[Q],enumerable:!0,configurable:!0,set:wj0.bind(D,Q)})};var t=($,D)=>()=>($&&(D=$($=0)),D);var Q0=Bj0(import.meta.url);var i$;var Q8=t(()=>{i$={name:"@capgo/cli",type:"module",version:"8.53.1",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"https://github.com/Cap-go/capgo.app",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:notify-app-ready-background":"bun test ./test/test-notify-app-ready-background.mjs","test:bundle":"bun test/test-bundle.mjs","test:bundle-validation":"bun test test/bundle/","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 && bun test/test-get-remote-dependencies.mjs","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-export":"bun test/test-credentials-export.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:cli-help":"bun test/test-cli-help.mjs","test:build-cache-payload":"bun test/test-build-cache-payload.mjs","test:build-cancellation":"bun test/test-build-cancellation.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:cli-headers":"bun test/test-cli-headers.mjs","test:min-cli-version":"bun test/test-min-cli-version.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:app-add-exists":"bun test/test-app-add-exists.mjs","test:app-list-output-text":"bun test/test-app-list-output-text.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:cli-recovery":"bun test/test-cli-recovery.mjs","test:create-supabase-client":"bun test/test-create-supabase-client.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:channel-add-exists":"bun test/test-channel-add-exists.mjs","test:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-upload-recovery":"bun test/test-init-upload-error-gate.mjs && bun test/test-init-upload-monorepo-recovery.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:capacitor-config-typescript7":"bun test/test-capacitor-config-typescript7.mjs","test:capacitor-config-native-import":"bun test/test-capacitor-config-native-import.mjs","test:cli-user-error-config":"bun test/test-cli-user-error-config.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun run test:capacitor-config-typescript7 && bun run test:capacitor-config-native-import && bun run test:cli-user-error-config && 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:notify-app-ready-background && bun run test:bundle-validation && 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-export && bun run test:ios-provisioning-map && bun run test:ios-provisioning-command && 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:cli-help && bun run test:build-cache-payload && bun run test:build-cancellation && 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:cli-headers && bun run test:min-cli-version && 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:app-add-exists && bun run test:app-list-output-text && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-supabase-client && bun run test:build-platform-selection && bun run test:builder-project-discovery && 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:channel-list && bun run test:channel-add-exists && bun run test:wait-log && bun run test:init-guardrails && bun run test:init-upload-recovery && 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-gcp && 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:2fa-compliance-network && 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:builder-project-discovery":"bun test/test-builder-project-discovery.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 && bun test/test-app-list-options.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-gcp":"bun test/test-android-gcp.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:2fa-compliance-network":"bun test/test-2fa-compliance-network.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","test:ios-provisioning-map":"bun test/test-ios-provisioning-map.mjs","test:ios-provisioning-command":"bun test/test-ios-provisioning-command.mjs","test:channel-list":"bun test/test-channel-list.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@manypkg/tools":"^2.1.2","@rrweb/types":"^2.1.1","@standard-schema/spec":"^1.1.0","@xmldom/xmldom":"^0.9.10","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","agent-cli-detector":"^0.1.6","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",typescript:"6.0.3",zod:"^4.4.3"},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","@vue/compiler-dom":"3.5.40","@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.2",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",ws:"^8.21.1"}}});var U0;var y1=t(()=>{U0=class U0 extends Error{context;constructor($,D){super($);this.name="CliUserError",this.context=D}}});import{platform as Ej0}from"node:os";import{version as jj0}from"node:process";function Tj0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function Tb($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token is missing. Re-run the build command or pass a valid log token.";return"Capgo API key is missing. Run `npx -y @capgo/cli@latest login` or pass `--apikey`."}function Cj0($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token contains invalid characters (only ASCII is allowed). Re-run the build command to get a fresh token.";if($.toLowerCase()==="authorization")return"Authorization header contains invalid characters (only ASCII is allowed). Check your Capgo API key or Supabase anon key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function z2($,D){if(D===void 0||D===null){if(O2.has($.toLowerCase()))throw new U0(Tb($));throw new U0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(O2.has($.toLowerCase()))throw new U0(Tb($));throw new U0(`HTTP header "${$}" is missing or invalid.`)}if(!Tj0(D)){if(O2.has($.toLowerCase()))throw new U0(Cj0($));throw new U0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function c1($){let D={capgo_api:Aj0,"x-cli-version":i$.version,"x-cli-command":Ij0,"x-cli-node":jj0,"x-cli-os":Ej0()};if($)for(let[Q,X]of Object.entries($))D[Q]=z2(Q,X);return D}var Aj0="2025-10-01",Ij0="",O2;var a6=t(()=>{Q8();y1();O2=new Set(["authorization","capgkey","x-capgo-log-token"])});var Cb,Pb=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},Sb=($)=>{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 xb=t(()=>{Cb=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let Q=0;$.lastIndex=0;while($.test(D))Q+=1;return D.length-Q}})()});var Pj0,Sj0,_b,xj0,vb,_j0,vj0,kj0,kb=($,D={},Q={})=>{let X=D.limit??1/0,J=D.ellipsis??"",Y=D?.ellipsisWidth??(J?kb(J,kj0,Q).width:0),Z=0,F=Q.controlWidth??0,G=Q.tabWidth??8,U=Q.emojiWidth??2,W=2,q=Q.regularWidth??1,K=Q.wideWidth??2,H=[[_j0,q],[Pj0,0],[Sj0,F],[xj0,G],[vb,U],[_b,K]],V=0,O=0,z=$.length,N=0,B=!1,L=z,M=Math.max(0,X-Y),w=0,R=0,x=0,_=0;$:while(!0){if(R>w||O>=z&&O>V){let j=$.slice(w,R)||$.slice(V,O);N=0;for(let k of j.replaceAll(vj0,"")){let v=k.codePointAt(0)||0;if(Pb(v))_=2;else if(Sb(v))_=K;else _=q;if(x+_>M)L=Math.min(L,Math.max(w,V)+N);if(x+_>X){B=!0;break $}N+=k.length,x+=_}w=R=0}if(O>=z)break $;for(let j=0,k=H.length;j<k;j++){let[v,g]=H[j];if(v.lastIndex=O,v.test($)){if(N=v===_b?Cb($.slice(O,v.lastIndex)):v===vb?1:v.lastIndex-O,_=N*g,x+_>M)L=Math.min(L,O+Math.floor((M-x)/g));if(x+_>X){B=!0;break $}x+=_,w=V,R=O,O=V=v.lastIndex;continue $}}O+=1}return{width:B?M:x,index:B?L:z,truncated:B,ellipsed:B&&X>=Y}},yb;var fb=t(()=>{xb();Pj0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Sj0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_b=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,xj0=/\t{1,1000}/y,vb=/[\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,_j0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,vj0=/\p{M}+/gu,kj0={limit:1/0,ellipsis:""},yb=kb});var yj0,fj0=($,D={})=>{return yb($,yj0,D).width},P8;var L2=t(()=>{fb();yj0={limit:1/0,ellipsis:"",ellipsisWidth:0},P8=fj0});function E7($,D,Q){return String($).normalize().split(mj0).map((X)=>gj0(X,D,Q)).join(`
1
+ import{createRequire as Bj0}from"node:module";var module={exports:{}};var Oj0=Object.create;var{getPrototypeOf:zj0,defineProperty:rF,getOwnPropertyNames:Ib}=Object;var H2=Object.prototype.hasOwnProperty;function V2($){return this[$]}var H0=($,D,Q)=>{var X=Ib(D);for(let J of X)if(!H2.call($,J)&&J!=="default")rF($,J,{get:V2.bind(D,J),enumerable:!0});if(Q){for(let J of X)if(!H2.call(Q,J)&&J!=="default")rF(Q,J,{get:V2.bind(D,J),enumerable:!0});return Q}},Lj0,Mj0,S1=($,D,Q)=>{var X=$!=null&&typeof $==="object";if(X){var J=D?Lj0??=new WeakMap:Mj0??=new WeakMap,Y=J.get($);if(Y)return Y}Q=$!=null?Oj0(zj0($)):{};let Z=D||!$||!$.__esModule?rF(Q,"default",{value:$,enumerable:!0}):Q;for(let F of Ib($))if(!H2.call(Z,F))rF(Z,F,{get:V2.bind($,F),enumerable:!0});if(X)J.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var Nj0=($)=>$;function wj0($,D){this[$]=Nj0.bind(null,D)}var Q6=($,D)=>{for(var Q in D)rF($,Q,{get:D[Q],enumerable:!0,configurable:!0,set:wj0.bind(D,Q)})};var t=($,D)=>()=>($&&(D=$($=0)),D);var Q0=Bj0(import.meta.url);var i$;var Q8=t(()=>{i$={name:"@capgo/cli",type:"module",version:"8.53.2",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"https://github.com/Cap-go/capgo.app",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:notify-app-ready-background":"bun test ./test/test-notify-app-ready-background.mjs ./test/test-background-check-shutdown.mjs","test:bundle":"bun test/test-bundle.mjs","test:bundle-validation":"bun test test/bundle/","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 && bun test/test-get-remote-dependencies.mjs","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-export":"bun test/test-credentials-export.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:cli-help":"bun test/test-cli-help.mjs","test:build-cache-payload":"bun test/test-build-cache-payload.mjs","test:build-cancellation":"bun test/test-build-cancellation.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:cli-headers":"bun test/test-cli-headers.mjs","test:min-cli-version":"bun test/test-min-cli-version.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:app-add-exists":"bun test/test-app-add-exists.mjs","test:app-list-output-text":"bun test/test-app-list-output-text.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:cli-recovery":"bun test/test-cli-recovery.mjs","test:create-supabase-client":"bun test/test-create-supabase-client.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:channel-add-exists":"bun test/test-channel-add-exists.mjs","test:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-upload-recovery":"bun test/test-init-upload-error-gate.mjs && bun test/test-init-upload-monorepo-recovery.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:capacitor-config-typescript7":"bun test/test-capacitor-config-typescript7.mjs","test:capacitor-config-native-import":"bun test/test-capacitor-config-native-import.mjs","test:cli-user-error-config":"bun test/test-cli-user-error-config.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun run test:capacitor-config-typescript7 && bun run test:capacitor-config-native-import && bun run test:cli-user-error-config && 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:notify-app-ready-background && bun run test:bundle-validation && 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-export && bun run test:ios-provisioning-map && bun run test:ios-provisioning-command && 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:cli-help && bun run test:build-cache-payload && bun run test:build-cancellation && 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:cli-headers && bun run test:min-cli-version && 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:app-add-exists && bun run test:app-list-output-text && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-supabase-client && bun run test:build-platform-selection && bun run test:builder-project-discovery && 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:channel-list && bun run test:channel-add-exists && bun run test:wait-log && bun run test:init-guardrails && bun run test:init-upload-recovery && 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-gcp && 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:2fa-compliance-network && 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:builder-project-discovery":"bun test/test-builder-project-discovery.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 && bun test/test-app-list-options.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-gcp":"bun test/test-android-gcp.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:2fa-compliance-network":"bun test/test-2fa-compliance-network.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","test:ios-provisioning-map":"bun test/test-ios-provisioning-map.mjs","test:ios-provisioning-command":"bun test/test-ios-provisioning-command.mjs","test:channel-list":"bun test/test-channel-list.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@manypkg/tools":"^2.1.2","@rrweb/types":"^2.1.1","@standard-schema/spec":"^1.1.0","@xmldom/xmldom":"^0.9.10","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","agent-cli-detector":"^0.1.6","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",typescript:"6.0.3",zod:"^4.4.3"},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","@vue/compiler-dom":"3.5.40","@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.2",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",ws:"^8.21.1"}}});var U0;var y1=t(()=>{U0=class U0 extends Error{context;constructor($,D){super($);this.name="CliUserError",this.context=D}}});import{platform as Ej0}from"node:os";import{version as jj0}from"node:process";function Tj0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function Tb($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token is missing. Re-run the build command or pass a valid log token.";return"Capgo API key is missing. Run `npx -y @capgo/cli@latest login` or pass `--apikey`."}function Cj0($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token contains invalid characters (only ASCII is allowed). Re-run the build command to get a fresh token.";if($.toLowerCase()==="authorization")return"Authorization header contains invalid characters (only ASCII is allowed). Check your Capgo API key or Supabase anon key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function z2($,D){if(D===void 0||D===null){if(O2.has($.toLowerCase()))throw new U0(Tb($));throw new U0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(O2.has($.toLowerCase()))throw new U0(Tb($));throw new U0(`HTTP header "${$}" is missing or invalid.`)}if(!Tj0(D)){if(O2.has($.toLowerCase()))throw new U0(Cj0($));throw new U0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function c1($){let D={capgo_api:Aj0,"x-cli-version":i$.version,"x-cli-command":Ij0,"x-cli-node":jj0,"x-cli-os":Ej0()};if($)for(let[Q,X]of Object.entries($))D[Q]=z2(Q,X);return D}var Aj0="2025-10-01",Ij0="",O2;var a6=t(()=>{Q8();y1();O2=new Set(["authorization","capgkey","x-capgo-log-token"])});var Cb,Pb=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},Sb=($)=>{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 xb=t(()=>{Cb=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let Q=0;$.lastIndex=0;while($.test(D))Q+=1;return D.length-Q}})()});var Pj0,Sj0,_b,xj0,vb,_j0,vj0,kj0,kb=($,D={},Q={})=>{let X=D.limit??1/0,J=D.ellipsis??"",Y=D?.ellipsisWidth??(J?kb(J,kj0,Q).width:0),Z=0,F=Q.controlWidth??0,G=Q.tabWidth??8,U=Q.emojiWidth??2,W=2,q=Q.regularWidth??1,K=Q.wideWidth??2,H=[[_j0,q],[Pj0,0],[Sj0,F],[xj0,G],[vb,U],[_b,K]],V=0,O=0,z=$.length,N=0,B=!1,L=z,M=Math.max(0,X-Y),w=0,R=0,x=0,_=0;$:while(!0){if(R>w||O>=z&&O>V){let j=$.slice(w,R)||$.slice(V,O);N=0;for(let k of j.replaceAll(vj0,"")){let v=k.codePointAt(0)||0;if(Pb(v))_=2;else if(Sb(v))_=K;else _=q;if(x+_>M)L=Math.min(L,Math.max(w,V)+N);if(x+_>X){B=!0;break $}N+=k.length,x+=_}w=R=0}if(O>=z)break $;for(let j=0,k=H.length;j<k;j++){let[v,g]=H[j];if(v.lastIndex=O,v.test($)){if(N=v===_b?Cb($.slice(O,v.lastIndex)):v===vb?1:v.lastIndex-O,_=N*g,x+_>M)L=Math.min(L,O+Math.floor((M-x)/g));if(x+_>X){B=!0;break $}x+=_,w=V,R=O,O=V=v.lastIndex;continue $}}O+=1}return{width:B?M:x,index:B?L:z,truncated:B,ellipsed:B&&X>=Y}},yb;var fb=t(()=>{xb();Pj0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Sj0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_b=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,xj0=/\t{1,1000}/y,vb=/[\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,_j0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,vj0=/\p{M}+/gu,kj0={limit:1/0,ellipsis:""},yb=kb});var yj0,fj0=($,D={})=>{return yb($,yj0,D).width},P8;var L2=t(()=>{fb();yj0={limit:1/0,ellipsis:"",ellipsisWidth:0},P8=fj0});function E7($,D,Q){return String($).normalize().split(mj0).map((X)=>gj0(X,D,Q)).join(`
2
2
  `)}var sq="\x1B",mb="›",uj0=39,N2="\x07",db="[",bj0="]",cb="m",w2,ub,bb=($)=>{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},hb=($)=>`${sq}${db}${$}${cb}`,gb=($)=>`${sq}${w2}${$}${N2}`,M2=($,D,Q)=>{let X=D[Symbol.iterator](),J=!1,Y=!1,Z=$.at(-1),F=Z===void 0?0:P8(Z),G=X.next(),U=X.next(),W=0;while(!G.done){let q=G.value,K=P8(q);if(F+K<=Q)$[$.length-1]+=q;else $.push(q),F=0;if(q===sq||q===mb)J=!0,Y=D.startsWith(w2,W+1);if(J){if(Y){if(q===N2)J=!1,Y=!1}else if(q===cb)J=!1}else if(F+=K,F===Q&&!U.done)$.push(""),F=0;G=U,U=X.next(),W+=q.length}if(Z=$.at(-1),!F&&Z!==void 0&&Z.length&&$.length>1)$[$.length-2]+=$.pop()},hj0=($)=>{let D=$.split(" "),Q=D.length;while(Q){if(P8(D[Q-1]))break;Q--}if(Q===D.length)return $;return D.slice(0,Q).join(" ")+D.slice(Q).join("")},gj0=($,D,Q={})=>{if(Q.trim!==!1&&$.trim()==="")return"";let X="",J,Y,Z=$.split(" "),F=[""],G=0;for(let q=0;q<Z.length;q++){let K=Z[q];if(Q.trim!==!1){let V=F.at(-1)??"",O=V.trimStart();if(V.length!==O.length)F[F.length-1]=O,G=P8(O)}if(q!==0){if(G>=D&&(Q.wordWrap===!1||Q.trim===!1))F.push(""),G=0;if(G||Q.trim===!1)F[F.length-1]+=" ",G++}let H=P8(K);if(Q.hard&&H>D){let V=D-G,O=1+Math.floor((H-V-1)/D);if(Math.floor((H-1)/D)<O)F.push("");M2(F,K,D),G=P8(F.at(-1)??"");continue}if(G+H>D&&G&&H){if(Q.wordWrap===!1&&G<D){M2(F,K,D),G=P8(F.at(-1)??"");continue}F.push(""),G=0}if(G+H>D&&Q.wordWrap===!1){M2(F,K,D),G=P8(F.at(-1)??"");continue}F[F.length-1]+=K,G+=H}if(Q.trim!==!1)F=F.map((q)=>hj0(q));let U=F.join(`
3
3
  `),W=!1;for(let q=0;q<U.length;q++){let K=U[q];if(X+=K,!W){if(W=K>="\uD800"&&K<="\uDBFF",W)continue}else W=!1;if(K===sq||K===mb){ub.lastIndex=q+1;let V=ub.exec(U)?.groups;if(V?.code!==void 0){let O=Number.parseFloat(V.code);J=O===uj0?void 0:O}else if(V?.uri!==void 0)Y=V.uri.length===0?void 0:V.uri}if(U[q+1]===`
4
4
  `){if(Y)X+=gb("");let H=J?bb(J):void 0;if(J&&H)X+=hb(H)}else if(K===`
@@ -408,7 +408,7 @@ To regain access:`),T0.error(` 1. Go to ${rU("/settings/account")}`),T0.error("
408
408
  For more information, visit: https://capgo.app/docs/webapp/2fa-enforcement/
409
409
  `),Error("2FA required for this organization")}async function Q51($,D,Q,X){return(await Promise.all(Q.map(async(Y)=>{return await AD($,D,X,{orgId:Y.gid})?Y:null}))).filter((Y)=>Y!==null)}async function X51($,D,Q){let{error:X,data:J}=await $.rpc("get_orgs_v7");if(X)throw T0.error("Cannot get the list of organizations - exiting"),T0.error(F0(X)),Error("Cannot get the list of organizations");if(J.length===0)throw T0.error("Could not get organization please create an organization first"),Error("No organizations available");let Y=await Q51($,D,J,Q);if(Y.length===0)throw T0.error(`Could not find organization with permission: ${Q}`),Error("Could not find organization with required permission");return{allOrganizations:J,allowedOrganizations:Y}}async function pL($,D,Q){let{allOrganizations:X,allowedOrganizations:J}=await X51($,D,Q),Y=J.length>1?await P$({message:"Please pick the organization that you want to insert to",options:J.map((G)=>{let U=G.enforcing_2fa&&!G["2fa_has_access"]?" ⚠️ (2FA required)":"";return{value:G.gid,label:`${G.name}${U}`}})}):J[0].gid;if(r0(Y))throw T0.warn("Canceled organization selection, exiting"),new U0("Organization selection cancelled");let Z=Y,F=X.find((G)=>G.gid===Z);if(F.enforcing_2fa&&!F["2fa_has_access"])x_(F.name);return T0.info(`Using the organization "${F.name}" as the app owner`),F}async function K$($,D,Q=!1){let{data:X,error:J}=await $.rpc("request_actor_user_id"),Y=(X||"").toString();if(J){if(!Q)T0.error(J.message);throw J}if(!Y){if(!Q)T0.error("Capgo authentication failed: invalid Capgo API key or insufficient Capgo permissions.");throw Error("Capgo authentication failed: invalid Capgo API key or insufficient Capgo permissions.")}return Y}async function AD($,D,Q,X={}){let{data:J,error:Y}=await $.rpc("cli_check_permission",{apikey:D,permission_key:Q,org_id:X.orgId??null,app_id:X.appId??null,channel_id:X.channelId??null});if(Y)throw T0.error(`Cannot check permission ${Q}`),T0.error(F0(Y)),Error(`Cannot check permission ${Q}`);return!!J}async function DW($,D,Q,X={},J={}){if(await AD($,D,Q,X))return;let Z=J.message||`Insufficient permissions for ${Q}`;if(!J.silent)T0.error(Z);throw new U0(`Insufficient permissions for ${Q}`,{permissionKey:Q,...X})}async function iL($,D,Q,X,J,Y){await K$($,D,Y),await DW($,D,Q,{orgId:X},{message:J,silent:Y})}async function RD($,D,Q){let{data:X,error:J}=await q1(`app/${encodeURIComponent(D)}`,{apikey:$,method:"GET",body:void 0,supaHost:Q?.supaHost,supaAnon:Q?.supaAnon});if(!X?.owner_org||J){let Y=F0(J);throw T0.error(`Cannot get organization id for app id ${D}: ${Y}`),new U0("Cannot get organization id for app",{appId:D,cause:Y})}return X.owner_org}function KX($){return new Date($||"").toLocaleString()}function FX(){if(MZ0)return{pm:DZ,command:iU,installCommand:`${DZ} ${iU}`,runner:I_};let $=$$(F4());return DZ=QQ($,"npm"),iU=sX(DZ),MZ0=!0,I_=KK($),{pm:DZ,command:iU,installCommand:`${DZ} ${iU}`,runner:I_}}function J51($,D){return{summary:`Best fix: recreate and sync ${D==="ios"?"iOS":"Android"} with this one-line command.`,command:`rm -rf ${D} && ${$} cap add ${D} && ${$} cap sync ${D}`}}function lZ0($){return JZ($,{withFileTypes:!0}).flatMap((X)=>{let J=I1($,X.name);if(X.isDirectory())return lZ0(J);else return J.split(`node_modules${EZ0}`)[1]||J})}function nZ0($){if(!F$($))return[];try{return JZ($,{withFileTypes:!0}).flatMap((X)=>{let J=I1($,X.name);if(X.isDirectory())return nZ0(J);else return J})}catch{return[]}}function Y51($,D){let Q=[];if(D==="ios"){try{let Y=JZ($);for(let Z of Y)if(Z.endsWith(".podspec"))Q.push(I1($,Z))}catch{}let X=I1($,"Package.swift"),J=I1($,"ios","Package.swift");if(F$(X))Q.push(X);if(F$(J))Q.push(J)}else if(D==="android"){let X=I1($,"android"),J=I1(X,"build.gradle"),Y=I1(X,"build.gradle.kts");if(F$(J))Q.push(J);if(F$(Y))Q.push(Y)}return Q}async function Z51($){let D=I1($,"ios"),Q=I1($,"android"),X=async(Z,F)=>{let G=F$(Z)?nZ0(Z).filter((H)=>xZ0.test(H)):[],U=Y51($,F),W=[...G,...U].sort((H,V)=>H.localeCompare(V));if(W.length===0)return;let{createHash:q}=await import("node:crypto"),K=q("sha256");for(let H of W)try{let V=RZ0($,H);K.update(V);let O=YD(H);K.update(O)}catch{}return K.digest("hex")},[J,Y]=await Promise.all([X(D,"ios"),X(Q,"android")]);return{ios_checksum:J,android_checksum:Y}}function F51($){let D=[],Q=$,X=YZ.parse(Q).root;while(!0){if(D.push(I1(Q,"node_modules")),Q===X)break;let J=QZ(Q);if(J===Q)break;Q=J}return D}async function __($,D){let Q=D?D.split(",").map((q)=>q.trim()).filter(Boolean):[],X;try{X=await hL("",$)}catch(q){throw T0.error("Invalid package.json, JSON parsing failed"),T0.error(`json parse error: ${F0(q)}`),q instanceof Error?q:Error("Invalid package.json")}let J=$?$.split(",")[0].trim():void 0,Y=!J?$$(F4()):YZ.resolve(J).replace(G4,"");if(!X)throw T0.error("Missing dependencies section in package.json"),Error("Missing dependencies section in package.json");for(let[q,K]of Object.entries(X))if(typeof K!=="string")throw T0.error(`Invalid dependency ${q}: ${K}, expected string, got ${typeof K}`),Error(`Invalid dependency ${q}: expected string version`);let Z=Q.length===0?F51(F4()):Q;if(!Z.some((q)=>F$(q))){let q=QQ(Y,"npm"),K=sX(q);throw T0.error(`Missing node_modules folder at ${Z.join(", ")}, please run ${q} ${K}`),Error("Missing node_modules folder")}let G=!1,U=await m71($$(F4()),$),W=await Promise.all(Array.from(X.entries()).map(async([q,K])=>{let H=!1,V=!1,O=K,z=U.get(q)??K,N;for(let M of Z){let w=I1(M,q);if(F$(w)){H=!0,N=w;try{let R=I1(w,G4);if(F$(R)){let x=JSON.parse(YD(R,"utf-8"));if(x.version)O=x.version}}catch{}if(!n71(w))continue;try{if(lZ0(w).some((x)=>xZ0.test(x))){V=!0;break}}catch(R){throw T0.error(`Error reading node_modules files for ${q} package in ${M}`),T0.error(F0(R)),R instanceof Error?R:Error(`Error reading node_modules files for ${q}`)}}}if(!H){G=!0;let M=QQ(Y,"npm"),w=sX(M);return T0.error(`Missing dependency ${q}, please run ${M} ${w}`),{name:q,version:O,requested_version:z}}let B,L;if(V&&N){let M=await Z51(N);B=M.ios_checksum,L=M.android_checksum}return{name:q,version:O,requested_version:z,native:V,ios_checksum:B,android_checksum:L}}));if(G||W.some((q)=>q.native===void 0))throw T0.error("Missing dependencies or invalid dependencies"),T0.error("If you use monorepo, workspace or any special package manager you can use the --package-json [path,] and --node-modules [path,] options to make the command work properly"),Error("Missing dependencies or invalid dependencies");return W}async function pZ0($,D,Q){let{data:X,error:J}=await $.from("channels").select("version:app_versions!channels_version_fkey(checksum)").eq("name",Q).eq("app_id",D).single(),Y=X;if(J||Y===null||!Y.version||!Y.version.checksum)return null;return Y.version.checksum}function NZ0($){if(!$)throw T0.error("Error parsing native packages, perhaps the metadata does not exist in Capgo?"),Error("Error parsing native packages");for(let Q of $){let X=hY0(uY0,Q);if(!X.success){let J=X.error.issues.map((Y)=>`${(Y.path??[]).join(".")}: ${Y.message}`).join(", ");throw T0.error(`Invalid remote native package data: ${J}`),Error(`Invalid remote native package data: ${J}`)}}return new Map($.map((Q)=>[Q.name,Q]))}async function iZ0($,D,Q){let{data:X,error:J}=await $.from("channels").select(`version:app_versions!channels_version_fkey(
410
410
  native_packages
411
- )`).eq("name",Q).eq("app_id",D).maybeSingle();if(J){let Z=J.code==="PGRST116"||J.message?.includes("Cannot coerce")?`Multiple channels matched for app "${D}" and channel "${Q}". Contact support if this persists.`:J.message;throw T0.error(`Error fetching native packages: ${Z}`),Error(`Error fetching native packages: ${Z}`)}if(!X)return NZ0([]);return NZ0(X.version?.native_packages??[])}function o1($,D){return $||D?.plugins?.CapacitorUpdater?.appId||D?.appId}function M5($){let D=[];if(!$.localVersion)return{compatible:!0,reasons:[],message:"Package only exists on remote (will be removed)"};if(!$.remoteVersion)return D.push("new_plugin"),{compatible:!1,reasons:D,message:"New native plugin added (requires app store update)"};let Q=!1;try{let q=NK($.localVersion),K=NK($.remoteVersion);Q=Th(q,K)}catch{Q=!1}if(!Q)D.push("version_mismatch");if($.localRequestedVersion&&$.remoteRequestedVersion&&$.localRequestedVersion.trim()!==$.remoteRequestedVersion.trim())D.push("requested_version_changed");let X=(q)=>typeof q==="string"&&q.trim().length>0,J=X($.localIosChecksum)&&X($.remoteIosChecksum)&&$.localIosChecksum!==$.remoteIosChecksum,Y=X($.localAndroidChecksum)&&X($.remoteAndroidChecksum)&&$.localAndroidChecksum!==$.remoteAndroidChecksum;if(J&&Y)D.push("both_platforms_changed");else if(J)D.push("ios_code_changed");else if(Y)D.push("android_code_changed");let Z=X($.localIosChecksum)!==X($.remoteIosChecksum),F=X($.localAndroidChecksum)!==X($.remoteAndroidChecksum);if(Z||F)D.push("platform_checksum_metadata_changed");let G=[],U=(q)=>q!=="requested_version_changed";for(let q of D)switch(q){case"version_mismatch":G.push(`version changed: ${$.remoteVersion} → ${$.localVersion}`);break;case"requested_version_changed":G.push(`requested version changed: ${$.remoteRequestedVersion??"unknown"} → ${$.localRequestedVersion??"unknown"}`);break;case"ios_code_changed":G.push("iOS native code changed");break;case"android_code_changed":G.push("Android native code changed");break;case"both_platforms_changed":G.push("iOS and Android native code changed");break;case"platform_checksum_metadata_changed":G.push("iOS/Android checksum metadata appeared or disappeared (may be Capgo CLI change — verify native code)");break;case"new_plugin":G.push("new plugin (requires app store update)");break;case"removed_plugin":G.push("plugin removed");break}if(!D.some(U))return{compatible:!0,reasons:D,message:G.length>0?G.join(", "):"Compatible"};return{compatible:!1,reasons:D,message:G.join(", ")}}function _4($){return M5($).compatible}async function rL($,D,Q,X,J){let Y=await __(X,J),Z=await iZ0($,D,Q),F=Y.filter((U)=>!!U.native).map((U)=>{let W=Z.get(U.name);if(W)return{name:U.name,localVersion:U.version,localRequestedVersion:U.requested_version,remoteVersion:W.version,remoteRequestedVersion:W.requested_version,localIosChecksum:U.ios_checksum,remoteIosChecksum:W.ios_checksum,localAndroidChecksum:U.android_checksum,remoteAndroidChecksum:W.android_checksum};return{name:U.name,localVersion:U.version,localRequestedVersion:U.requested_version,remoteVersion:void 0,localIosChecksum:U.ios_checksum,localAndroidChecksum:U.android_checksum}}),G=[...Z].filter(([U])=>!Y.some((W)=>W.name===U)).map(([U,W])=>({name:U,localVersion:void 0,remoteVersion:W.version,remoteRequestedVersion:W.requested_version,remoteIosChecksum:W.ios_checksum,remoteAndroidChecksum:W.android_checksum}));return F.push(...G),{finalCompatibility:F,localDependencies:Y}}async function QW($,D,Q,X){let J=await iZ0($,D,Q),Y=X.map((F)=>{let G=J.get(F.name);if(G)return{name:F.name,localVersion:F.version,localRequestedVersion:F.requested_version,remoteVersion:G.version,remoteRequestedVersion:G.requested_version,localIosChecksum:F.ios_checksum,remoteIosChecksum:G.ios_checksum,localAndroidChecksum:F.android_checksum,remoteAndroidChecksum:G.android_checksum};return{name:F.name,localVersion:F.version,localRequestedVersion:F.requested_version,remoteVersion:void 0,localIosChecksum:F.ios_checksum,localAndroidChecksum:F.android_checksum}}),Z=[...J].filter(([F])=>!X.some((G)=>G.name===F)).map(([F,G])=>({name:F,localVersion:void 0,remoteVersion:G.version,remoteRequestedVersion:G.requested_version,remoteIosChecksum:G.ios_checksum,remoteAndroidChecksum:G.android_checksum}));return Y.push(...Z),{finalCompatibility:Y,localDependencies:X}}function rZ0($){if(!F$($))return null;try{return JSON.parse(YD($,"utf-8"))}catch{return null}}function xL($){if(!$)return!1;return/@capgo\/capacitor-updater|CapgoCapacitorUpdater|CapacitorUpdaterPlugin/.test($)}function G51($){let D=rZ0($);if(!D)return!1;let Q=D.packageClassList;return Array.isArray(Q)&&Q.includes("CapacitorUpdaterPlugin")}function U51($,D){if(!D)return I1($,G4);return YZ.isAbsolute(D)?D:V5($,D)}function W51($=F4(),D){let Q=U51($,D),X=YZ.basename(Q)===G4?QZ(Q):Q,J=[I1(X,"ios","App"),I1($,"ios","App")].find((R)=>F$(R));if(!J)return{shouldCheck:!1,valid:!0,details:[]};let Y=rZ0(Q),Z={...Y?.dependencies,...Y?.devDependencies,...Y?.optionalDependencies},F=Object.hasOwn(Z,"@capgo/capacitor-updater"),G=[X,$].some((R)=>F$(I1(R,"node_modules","@capgo","capacitor-updater"))),U=I1(J,"Podfile"),W=I1(J,"CapApp-SPM","Package.swift"),q=F$(U)?YD(U,"utf-8"):void 0,K=F$(W)?YD(W,"utf-8"):void 0,H=xL(q)||xL(K),V=I1(J,"Podfile.lock"),O=I1(J,"App","capacitor.plugins.json"),z=I1(J,"App","capacitor.config.json"),N=F$(V)?YD(V,"utf-8"):void 0,B=F$(O)?YD(O,"utf-8"):void 0,L=xL(N)||xL(B)||G51(z);if(!(F||G||H||L))return{shouldCheck:!1,valid:!0,details:[]};let w=[];if(!H)w.push(`Missing @capgo/capacitor-updater in iOS dependency files (${U} or ${W})`);if(!L)w.push(`Missing @capgo/capacitor-updater in iOS native project outputs (${V}, ${O}, or ${z})`);return{shouldCheck:!0,valid:H&&L,details:w}}function q51($,D,Q){if(!$.shouldCheck||$.valid)return;let X=J51(D,"ios");Q?.(),T0.error("Capgo iOS dependency sync verification failed.");for(let J of $.details)T0.error(J);throw T0.error("Stop here to avoid testing on a broken native iOS project."),T0.warn(X.summary),T0.info(X.command),new U0(b2)}async function oZ0($,D,Q,X){let J=await f1({message:"Would you like to sync your project with Capacitor now? This is recommended to ensure encrypted updates work properly."});if(r0(J)){if($&&D&&Q)await wr("onboarding-v2",D,Q,"canceled");throw T0.warn("Canceled Capacitor sync"),new U0("Capacitor sync cancelled")}if(J){let Y=FX(),Z=u$();Z.start("Running the command...");let F;try{await new Promise((G,U)=>{let W=_71(Y.runner,["cap","sync"],{stdio:"pipe"});W.on("close",(q)=>{if(q===0)G();else U(Error(`Command failed with exit code ${q}`))}),W.on("error",(q)=>{U(q)})})}catch(G){F=G,T0.error(`Failed to run Capacitor sync: ${G}`),T0.warn(`Please run "${Y.runner} cap sync" manually to ensure encrypted updates work properly`)}if(X?.validateIosUpdater)q51(W51(F4(),X.packageJsonPath),Y.runner,()=>Z.stop("iOS sync check failed ❌"));if(F){Z.stop("Error");return}Z.stop("Capacitor sync completed ✅")}else{let Y=FX();T0.warn("⚠️ Important: If you upload encrypted bundles without syncing, updates will fail!"),T0.info(`Remember to run "${Y.runner} cap sync" before uploading encrypted bundles`)}}var T_,C_,IZ0,yL,T0,ZZ=".capgo_key",sD=".capgo_key_v2",fL,m6,HZ0="https://capgo.app",VZ0="https://files.capgo.app",_L="https://api.capgo.app",vL="https://console.capgo.app",TZ0=120000,k71=20971520,y71=1073741824,f71=103809024,oU,tU=1e4,P_="BundleUploadTimeoutError",G4="package.json",OZ0="Cannot connect to server please try again later",GX,xZ0,j_=null,SL=null,mL="5.10.0",dL="6.25.0",eU="7.0.30",MZ0=!1,DZ="npm",iU="install",I_="npx";var e0=t(()=>{m2();X1();_8();Oc();a6();nH();iH();Lr();Br();oH();gA();a3();wY();GK();xQ0();RL();gY0();y1();FK();g2();jL();T_=S1(dB(),1),C_=S1(nB(),1),IZ0=S1(Pl(),1),yL=S1(cH(),1);T0={error:($)=>PL("error",$),info:($)=>PL("info",$),success:($)=>PL("success",$),warn:($)=>PL("warn",$)},fL=`${ZZ}.pub`,m6=`${sD}.pub`;oU=[0,1000,3000,5000,1e4];GX=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;xZ0=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/});function FF0($,D,Q={},X){let J=`${$}:${D}`,Y=aL.get(J);if(Y)return Y;let Z=(async()=>{try{if(X?.aborted)return;if(Q.fetchOwnerOrg)return await Q.fetchOwnerOrg($,D,X);if(Q.createClient){let W=(await Q.createClient($,void 0,void 0,!0,!1)).from("apps").select("owner_org").eq("app_id",D);if(X)W=W.abortSignal(X);let{data:q}=await W.maybeSingle();return q?.owner_org??void 0}let{data:F,error:G}=await q1(`app/${encodeURIComponent(D)}`,{apikey:$,method:"GET",body:void 0,signal:X});if(G||!F?.owner_org)return;return F.owner_org}catch{return}})();return aL.set(J,Z),Z.then((F)=>{if(!F)aL.delete(J)}).catch(()=>{aL.delete(J)}),Z}var aL;var GF0=t(()=>{e0();aL=new Map});import{AsyncLocalStorage as C51}from"node:async_hooks";import{env as UF0}from"node:process";function P51(){return I7(UF0.CAPGO_DISABLE_TELEMETRY)||I7(UF0.CAPGO_DISABLE_POSTHOG)}function S51($){WF0.add($),$.finally(()=>WF0.delete($))}function x51($,D){let Q=KF0.get($);if(Q)return Q;let X=(async()=>{try{let J=await O1(!0).catch(()=>{return}),Y=o1("",J?.config)||void 0;if(!Y)return{};let Z=await FF0($,Y,{},D);return{appId:Y,orgId:Z}}catch{return{}}})();return KF0.set($,X),X}function F1($){if(P51())return Promise.resolve();let D=$.apikey??L5();if(!D)return Promise.resolve();let Q=new AbortController;qF0.add(Q);let X=(async()=>{try{let{appId:J,orgId:Y}=$;if(J===void 0&&Y===void 0){let F=await x51(D,Q.signal);J=F.appId,Y=F.orgId}let Z={...J?{app_id:J}:{},...$.tags??{}};await s0(D,{channel:$.channel,event:$.event,tracking_version:2,...Y?{org_id:Y}:{},tags:Z},!1,Q.signal).catch(()=>{})}catch{}finally{qF0.delete(Q)}})();return S51(X),X}function y51($){let D=$.durationMs>Hr;if($.ok&&!D)return;let Q=v51.getStore()??_51,X={operation:Vr($.url,$.method),method:$.method,status_code:$.status,duration_ms:$.durationMs,ok:$.ok,slow:D};if($.source)X.source=$.source;if(Q)X.command_path=Q;if(!$.ok)X.error_category=$.error!==void 0?ZK($.error):Yh($.status);F1({apikey:$.apikey,channel:k51,event:"Supabase Call",tags:X})}var WF0,qF0,KF0,_51="",v51,k51="cli-perf";var $D=t(()=>{Q8();GK();e0();GF0();iH();nH();iH();WF0=new Set,qF0=new Set;KF0=new Map;v51=new C51;Kr(y51)});var X7=E((ut1,hF0)=>{var uF0=["nodebuffer","arraybuffer","fragments"],bF0=typeof Blob<"u";if(bF0)uF0.push("blob");hF0.exports={BINARY_TYPES:uF0,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:bF0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var YW=E((bt1,JM)=>{var{EMPTY_BUFFER:AQ1}=X7(),d_=Buffer[Symbol.species];function IQ1($,D){if($.length===0)return AQ1;if($.length===1)return $[0];let Q=Buffer.allocUnsafe(D),X=0;for(let J=0;J<$.length;J++){let Y=$[J];Q.set(Y,X),X+=Y.length}if(X<D)return new d_(Q.buffer,Q.byteOffset,X);return Q}function gF0($,D,Q,X,J){for(let Y=0;Y<J;Y++)Q[X+Y]=$[Y]^D[Y&3]}function mF0($,D){for(let Q=0;Q<$.length;Q++)$[Q]^=D[Q&3]}function TQ1($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function c_($){if(c_.readOnly=!0,Buffer.isBuffer($))return $;let D;if($ instanceof ArrayBuffer)D=new d_($);else if(ArrayBuffer.isView($))D=new d_($.buffer,$.byteOffset,$.byteLength);else D=Buffer.from($),c_.readOnly=!1;return D}JM.exports={concat:IQ1,mask:gF0,toArrayBuffer:TQ1,toBuffer:c_,unmask:mF0};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();JM.exports.mask=function(D,Q,X,J,Y){if(Y<48)gF0(D,Q,X,J,Y);else $.mask(D,Q,X,J,Y)},JM.exports.unmask=function(D,Q){if(D.length<32)mF0(D,Q);else $.unmask(D,Q)}}catch($){}});var nF0=E((ht1,lF0)=>{var dF0=Symbol("kDone"),l_=Symbol("kRun");class cF0{constructor($){this[dF0]=()=>{this.pending--,this[l_]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[l_]()}[l_](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[dF0])}}}lF0.exports=cF0});var HZ=E((gt1,tF0)=>{var ZW=Q0("zlib"),pF0=YW(),CQ1=nF0(),{kStatusCode:iF0}=X7(),PQ1=Buffer[Symbol.species],SQ1=Buffer.from([0,0,255,255]),ZM=Symbol("permessage-deflate"),J7=Symbol("total-length"),qZ=Symbol("callback"),N5=Symbol("buffers"),KZ=Symbol("error"),YM;class rF0{constructor($){if(this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!YM){let D=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;YM=new CQ1(D)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[qZ];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let D=this._options,Q=$.find((X)=>{if(D.serverNoContextTakeover===!1&&X.server_no_context_takeover||X.server_max_window_bits&&(D.serverMaxWindowBits===!1||typeof D.serverMaxWindowBits==="number"&&D.serverMaxWindowBits>X.server_max_window_bits)||typeof D.clientMaxWindowBits==="number"&&!X.client_max_window_bits)return!1;return!0});if(!Q)throw Error("None of the extension offers can be accepted");if(D.serverNoContextTakeover)Q.server_no_context_takeover=!0;if(D.clientNoContextTakeover)Q.client_no_context_takeover=!0;if(typeof D.serverMaxWindowBits==="number")Q.server_max_window_bits=D.serverMaxWindowBits;if(typeof D.clientMaxWindowBits==="number")Q.client_max_window_bits=D.clientMaxWindowBits;else if(Q.client_max_window_bits===!0||D.clientMaxWindowBits===!1)delete Q.client_max_window_bits;return Q}acceptAsClient($){let D=$[0];if(this._options.clientNoContextTakeover===!1&&D.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!D.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")D.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&D.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return D}normalizeParams($){return $.forEach((D)=>{Object.keys(D).forEach((Q)=>{let X=D[Q];if(X.length>1)throw Error(`Parameter "${Q}" must have only a single value`);if(X=X[0],Q==="client_max_window_bits"){if(X!==!0){let J=+X;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${Q}": ${X}`);X=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${Q}": ${X}`)}else if(Q==="server_max_window_bits"){let J=+X;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${Q}": ${X}`);X=J}else if(Q==="client_no_context_takeover"||Q==="server_no_context_takeover"){if(X!==!0)throw TypeError(`Invalid value for parameter "${Q}": ${X}`)}else throw Error(`Unknown parameter "${Q}"`);D[Q]=X})}),$}decompress($,D,Q){YM.add((X)=>{this._decompress($,D,(J,Y)=>{X(),Q(J,Y)})})}compress($,D,Q){YM.add((X)=>{this._compress($,D,(J,Y)=>{X(),Q(J,Y)})})}_decompress($,D,Q){let X=this._isServer?"client":"server";if(!this._inflate){let J=`${X}_max_window_bits`,Y=typeof this.params[J]!=="number"?ZW.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=ZW.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Y}),this._inflate[ZM]=this,this._inflate[J7]=0,this._inflate[N5]=[],this._inflate.on("error",_Q1),this._inflate.on("data",oF0)}if(this._inflate[qZ]=Q,this._inflate.write($),D)this._inflate.write(SQ1);this._inflate.flush(()=>{let J=this._inflate[KZ];if(J){this._inflate.close(),this._inflate=null,Q(J);return}let Y=pF0.concat(this._inflate[N5],this._inflate[J7]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[J7]=0,this._inflate[N5]=[],D&&this.params[`${X}_no_context_takeover`])this._inflate.reset();Q(null,Y)})}_compress($,D,Q){let X=this._isServer?"server":"client";if(!this._deflate){let J=`${X}_max_window_bits`,Y=typeof this.params[J]!=="number"?ZW.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=ZW.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Y}),this._deflate[J7]=0,this._deflate[N5]=[],this._deflate.on("data",xQ1)}this._deflate[qZ]=Q,this._deflate.write($),this._deflate.flush(ZW.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=pF0.concat(this._deflate[N5],this._deflate[J7]);if(D)J=new PQ1(J.buffer,J.byteOffset,J.length-4);if(this._deflate[qZ]=null,this._deflate[J7]=0,this._deflate[N5]=[],D&&this.params[`${X}_no_context_takeover`])this._deflate.reset();Q(null,J)})}}tF0.exports=rF0;function xQ1($){this[N5].push($),this[J7]+=$.length}function oF0($){if(this[J7]+=$.length,this[ZM]._maxPayload<1||this[J7]<=this[ZM]._maxPayload){this[N5].push($);return}this[KZ]=RangeError("Max payload size exceeded"),this[KZ].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[KZ][iF0]=1009,this.removeListener("data",oF0),this.reset()}function _Q1($){if(this[ZM]._inflate=null,this[KZ]){this[qZ](this[KZ]);return}$[iF0]=1007,this[qZ]($)}});var VZ=E((mt1,FM)=>{var{isUtf8:aF0}=Q0("buffer"),{hasBlob:vQ1}=X7(),kQ1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function yQ1($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function n_($){let D=$.length,Q=0;while(Q<D)if(($[Q]&128)===0)Q++;else if(($[Q]&224)===192){if(Q+1===D||($[Q+1]&192)!==128||($[Q]&254)===192)return!1;Q+=2}else if(($[Q]&240)===224){if(Q+2>=D||($[Q+1]&192)!==128||($[Q+2]&192)!==128||$[Q]===224&&($[Q+1]&224)===128||$[Q]===237&&($[Q+1]&224)===160)return!1;Q+=3}else if(($[Q]&248)===240){if(Q+3>=D||($[Q+1]&192)!==128||($[Q+2]&192)!==128||($[Q+3]&192)!==128||$[Q]===240&&($[Q+1]&240)===128||$[Q]===244&&$[Q+1]>143||$[Q]>244)return!1;Q+=4}else return!1;return!0}function fQ1($){return vQ1&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}FM.exports={isBlob:fQ1,isValidStatusCode:yQ1,isValidUTF8:n_,tokenChars:kQ1};if(aF0)FM.exports.isValidUTF8=function($){return $.length<24?n_($):aF0($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();FM.exports.isValidUTF8=function(D){return D.length<32?n_(D):$(D)}}catch($){}});var i_=E((dt1,QG0)=>{var{Writable:uQ1}=Q0("stream"),sF0=HZ(),{BINARY_TYPES:bQ1,EMPTY_BUFFER:eF0,kStatusCode:hQ1,kWebSocket:gQ1}=X7(),{concat:p_,toArrayBuffer:mQ1,unmask:dQ1}=YW(),{isValidStatusCode:cQ1,isValidUTF8:$G0}=VZ(),GM=Buffer[Symbol.species];class DG0 extends uQ1{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||bQ1[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxBufferedChunks=$.maxBufferedChunks|0,this._maxFragments=$.maxFragments|0,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[gQ1]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,D,Q){if(this._opcode===8&&this._state==0)return Q();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){Q(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(Q)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let Q=this._buffers[0];return this._buffers[0]=new GM(Q.buffer,Q.byteOffset+$,Q.length-$),new GM(Q.buffer,Q.byteOffset,$)}let D=Buffer.allocUnsafe($);do{let Q=this._buffers[0],X=D.length-$;if($>=Q.length)D.set(this._buffers.shift(),X);else D.set(new Uint8Array(Q.buffer,Q.byteOffset,$),X),this._buffers[0]=new GM(Q.buffer,Q.byteOffset+$,Q.length-$);$-=Q.length}while($>0);return D}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let D=this.consume(2);if((D[0]&48)!==0){let X=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(X);return}let Q=(D[0]&64)===64;if(Q&&!this._extensions[sF0.extensionName]){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._fin=(D[0]&128)===128,this._opcode=D[0]&15,this._payloadLength=D[1]&127,this._opcode===0){if(Q){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(!this._fragmented){let X=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._compressed=Q}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let X=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(X);return}if(Q){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let X=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(X);return}}else{let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(D[1]&128)===128,this._isServer){if(!this._masked){let X=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(X);return}}else if(this._masked){let X=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(X);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let D=this.consume(8),Q=D.readUInt32BE(0);if(Q>Math.pow(2,21)-1){let X=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(X);return}this._payloadLength=Q*Math.pow(2,32)+D.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let D=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(D);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let D=eF0;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(D=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)dQ1(D,this._mask)}if(this._opcode>7){this.controlMessage(D,$);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let Q=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");$(Q);return}if(this._compressed){this._state=5,this.decompress(D,$);return}if(D.length)this._messageLength=this._totalPayloadLength,this._fragments.push(D);this.dataMessage($)}decompress($,D){this._extensions[sF0.extensionName].decompress($,this._fin,(X,J)=>{if(X)return D(X);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Y=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D(Y);return}this._fragments.push(J)}if(this.dataMessage(D),this._state===0)this.startLoop(D)})}dataMessage($){if(!this._fin){this._state=0;return}let D=this._messageLength,Q=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let X;if(this._binaryType==="nodebuffer")X=p_(Q,D);else if(this._binaryType==="arraybuffer")X=mQ1(p_(Q,D));else if(this._binaryType==="blob")X=new Blob(Q);else X=Q;if(this._allowSynchronousEvents)this.emit("message",X,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!0),this._state=0,this.startLoop($)})}else{let X=p_(Q,D);if(!this._skipUTF8Validation&&!$G0(X)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",X,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!1),this._state=0,this.startLoop($)})}}controlMessage($,D){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,eF0),this.end();else{let Q=$.readUInt16BE(0);if(!cQ1(Q)){let J=this.createError(RangeError,`invalid status code ${Q}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");D(J);return}let X=new GM($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!$G0(X)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(J);return}this._loop=!1,this.emit("conclude",Q,X),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(D)})}createError($,D,Q,X,J){this._loop=!1,this._errored=!0;let Y=new $(Q?`Invalid WebSocket frame: ${D}`:D);return Error.captureStackTrace(Y,this.createError),Y.code=J,Y[hQ1]=X,Y}}QG0.exports=DG0});var o_=E((lt1,YG0)=>{var{Duplex:ct1}=Q0("stream"),{randomFillSync:lQ1}=Q0("crypto"),{types:{isUint8Array:nQ1}}=Q0("util"),XG0=HZ(),{EMPTY_BUFFER:pQ1,kWebSocket:iQ1,NOOP:rQ1}=X7(),{isBlob:OZ,isValidStatusCode:oQ1}=VZ(),{mask:JG0,toBuffer:VX}=YW(),v4=Symbol("kByteLength"),tQ1=Buffer.alloc(4),OX,zZ=8192,L8=0,aQ1=1,sQ1=2;class w5{constructor($,D,Q){if(this._extensions=D||{},Q)this._generateMask=Q,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=L8,this.onerror=rQ1,this[iQ1]=void 0}static frame($,D){let Q,X=!1,J=2,Y=!1;if(D.mask){if(Q=D.maskBuffer||tQ1,D.generateMask)D.generateMask(Q);else{if(zZ===8192){if(OX===void 0)OX=Buffer.alloc(8192);lQ1(OX,0,8192),zZ=0}Q[0]=OX[zZ++],Q[1]=OX[zZ++],Q[2]=OX[zZ++],Q[3]=OX[zZ++]}Y=(Q[0]|Q[1]|Q[2]|Q[3])===0,J=6}let Z;if(typeof $==="string")if((!D.mask||Y)&&D[v4]!==void 0)Z=D[v4];else $=Buffer.from($),Z=$.length;else Z=$.length,X=D.mask&&D.readOnly&&!Y;let F=Z;if(Z>=65536)J+=8,F=127;else if(Z>125)J+=2,F=126;let G=Buffer.allocUnsafe(X?Z+J:J);if(G[0]=D.fin?D.opcode|128:D.opcode,D.rsv1)G[0]|=64;if(G[1]=F,F===126)G.writeUInt16BE(Z,2);else if(F===127)G[2]=G[3]=0,G.writeUIntBE(Z,4,6);if(!D.mask)return[G,$];if(G[1]|=128,G[J-4]=Q[0],G[J-3]=Q[1],G[J-2]=Q[2],G[J-1]=Q[3],Y)return[G,$];if(X)return JG0($,Q,G,J,Z),[G];return JG0($,Q,$,0,Z),[G,$]}close($,D,Q,X){let J;if($===void 0)J=pQ1;else if(typeof $!=="number"||!oQ1($))throw TypeError("First argument must be a valid error code number");else if(D===void 0||!D.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE($,0);else{let Z=Buffer.byteLength(D);if(Z>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+Z),J.writeUInt16BE($,0),typeof D==="string")J.write(D,2);else if(nQ1(D))J.set(D,2);else throw TypeError("Second argument must be a string or a Uint8Array")}let Y={[v4]:J.length,fin:!0,generateMask:this._generateMask,mask:Q,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==L8)this.enqueue([this.dispatch,J,!1,Y,X]);else this.sendFrame(w5.frame(J,Y),X)}ping($,D,Q){let X,J;if(typeof $==="string")X=Buffer.byteLength($),J=!1;else if(OZ($))X=$.size,J=!1;else $=VX($),X=$.length,J=VX.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Y={[v4]:X,fin:!0,generateMask:this._generateMask,mask:D,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,!1,Y,Q]);else this.getBlobData($,!1,Y,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,!1,Y,Q]);else this.sendFrame(w5.frame($,Y),Q)}pong($,D,Q){let X,J;if(typeof $==="string")X=Buffer.byteLength($),J=!1;else if(OZ($))X=$.size,J=!1;else $=VX($),X=$.length,J=VX.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Y={[v4]:X,fin:!0,generateMask:this._generateMask,mask:D,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,!1,Y,Q]);else this.getBlobData($,!1,Y,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,!1,Y,Q]);else this.sendFrame(w5.frame($,Y),Q)}send($,D,Q){let X=this._extensions[XG0.extensionName],J=D.binary?2:1,Y=D.compress,Z,F;if(typeof $==="string")Z=Buffer.byteLength($),F=!1;else if(OZ($))Z=$.size,F=!1;else $=VX($),Z=$.length,F=VX.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Y&&X&&X.params[X._isServer?"server_no_context_takeover":"client_no_context_takeover"])Y=Z>=X._threshold;this._compress=Y}else Y=!1,J=0;if(D.fin)this._firstFragment=!0;let G={[v4]:Z,fin:D.fin,generateMask:this._generateMask,mask:D.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:F,rsv1:Y};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,this._compress,G,Q]);else this.getBlobData($,this._compress,G,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,this._compress,G,Q]);else this.dispatch($,this._compress,G,Q)}getBlobData($,D,Q,X){this._bufferedBytes+=Q[v4],this._state=sQ1,$.arrayBuffer().then((J)=>{if(this._socket.destroyed){let Z=Error("The socket was closed while the blob was being read");process.nextTick(r_,this,Z,X);return}this._bufferedBytes-=Q[v4];let Y=VX(J);if(!D)this._state=L8,this.sendFrame(w5.frame(Y,Q),X),this.dequeue();else this.dispatch(Y,D,Q,X)}).catch((J)=>{process.nextTick(eQ1,this,J,X)})}dispatch($,D,Q,X){if(!D){this.sendFrame(w5.frame($,Q),X);return}let J=this._extensions[XG0.extensionName];this._bufferedBytes+=Q[v4],this._state=aQ1,J.compress($,Q.fin,(Y,Z)=>{if(this._socket.destroyed){let F=Error("The socket was closed while data was being compressed");r_(this,F,X);return}this._bufferedBytes-=Q[v4],this._state=L8,Q.readOnly=!1,this.sendFrame(w5.frame(Z,Q),X),this.dequeue()})}dequeue(){while(this._state===L8&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][v4],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][v4],this._queue.push($)}sendFrame($,D){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],D),this._socket.uncork();else this._socket.write($[0],D)}}YG0.exports=w5;function r_($,D,Q){if(typeof Q==="function")Q(D);for(let X=0;X<$._queue.length;X++){let J=$._queue[X],Y=J[J.length-1];if(typeof Y==="function")Y(D)}}function eQ1($,D,Q){r_($,D,Q),$.onerror(D)}});var VG0=E((nt1,HG0)=>{var{kForOnEventAttribute:FW,kListener:t_}=X7(),ZG0=Symbol("kCode"),FG0=Symbol("kData"),GG0=Symbol("kError"),UG0=Symbol("kMessage"),WG0=Symbol("kReason"),LZ=Symbol("kTarget"),qG0=Symbol("kType"),KG0=Symbol("kWasClean");class B5{constructor($){this[LZ]=null,this[qG0]=$}get target(){return this[LZ]}get type(){return this[qG0]}}Object.defineProperty(B5.prototype,"target",{enumerable:!0});Object.defineProperty(B5.prototype,"type",{enumerable:!0});class MZ extends B5{constructor($,D={}){super($);this[ZG0]=D.code===void 0?0:D.code,this[WG0]=D.reason===void 0?"":D.reason,this[KG0]=D.wasClean===void 0?!1:D.wasClean}get code(){return this[ZG0]}get reason(){return this[WG0]}get wasClean(){return this[KG0]}}Object.defineProperty(MZ.prototype,"code",{enumerable:!0});Object.defineProperty(MZ.prototype,"reason",{enumerable:!0});Object.defineProperty(MZ.prototype,"wasClean",{enumerable:!0});class GW extends B5{constructor($,D={}){super($);this[GG0]=D.error===void 0?null:D.error,this[UG0]=D.message===void 0?"":D.message}get error(){return this[GG0]}get message(){return this[UG0]}}Object.defineProperty(GW.prototype,"error",{enumerable:!0});Object.defineProperty(GW.prototype,"message",{enumerable:!0});class WM extends B5{constructor($,D={}){super($);this[FG0]=D.data===void 0?null:D.data}get data(){return this[FG0]}}Object.defineProperty(WM.prototype,"data",{enumerable:!0});var $X1={addEventListener($,D,Q={}){for(let J of this.listeners($))if(!Q[FW]&&J[t_]===D&&!J[FW])return;let X;if($==="message")X=function(Y,Z){let F=new WM("message",{data:Z?Y:Y.toString()});F[LZ]=this,UM(D,this,F)};else if($==="close")X=function(Y,Z){let F=new MZ("close",{code:Y,reason:Z.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});F[LZ]=this,UM(D,this,F)};else if($==="error")X=function(Y){let Z=new GW("error",{error:Y,message:Y.message});Z[LZ]=this,UM(D,this,Z)};else if($==="open")X=function(){let Y=new B5("open");Y[LZ]=this,UM(D,this,Y)};else return;if(X[FW]=!!Q[FW],X[t_]=D,Q.once)this.once($,X);else this.on($,X)},removeEventListener($,D){for(let Q of this.listeners($))if(Q[t_]===D&&!Q[FW]){this.removeListener($,Q);break}}};HG0.exports={CloseEvent:MZ,ErrorEvent:GW,Event:B5,EventTarget:$X1,MessageEvent:WM};function UM($,D,Q){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,Q);else $.call(D,Q)}});var qM=E((pt1,OG0)=>{var{tokenChars:UW}=VZ();function J9($,D,Q){if($[D]===void 0)$[D]=[Q];else $[D].push(Q)}function DX1($){let D=Object.create(null),Q=Object.create(null),X=!1,J=!1,Y=!1,Z,F,G=-1,U=-1,W=-1,q=0;for(;q<$.length;q++)if(U=$.charCodeAt(q),Z===void 0)if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(q!==0&&(U===32||U===9)){if(W===-1&&G!==-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;let H=$.slice(G,W);if(U===44)J9(D,H,Q),Q=Object.create(null);else Z=H;G=W=-1}else throw SyntaxError(`Unexpected character at index ${q}`);else if(F===void 0)if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(U===32||U===9){if(W===-1&&G!==-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;if(J9(Q,$.slice(G,W),!0),U===44)J9(D,Z,Q),Q=Object.create(null),Z=void 0;G=W=-1}else if(U===61&&G!==-1&&W===-1)F=$.slice(G,q),G=W=-1;else throw SyntaxError(`Unexpected character at index ${q}`);else if(J){if(UW[U]!==1)throw SyntaxError(`Unexpected character at index ${q}`);if(G===-1)G=q;else if(!X)X=!0;J=!1}else if(Y)if(UW[U]===1){if(G===-1)G=q}else if(U===34&&G!==-1)Y=!1,W=q;else if(U===92)J=!0;else throw SyntaxError(`Unexpected character at index ${q}`);else if(U===34&&$.charCodeAt(q-1)===61)Y=!0;else if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(G!==-1&&(U===32||U===9)){if(W===-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;let H=$.slice(G,W);if(X)H=H.replace(/\\/g,""),X=!1;if(J9(Q,F,H),U===44)J9(D,Z,Q),Q=Object.create(null),Z=void 0;F=void 0,G=W=-1}else throw SyntaxError(`Unexpected character at index ${q}`);if(G===-1||Y||U===32||U===9)throw SyntaxError("Unexpected end of input");if(W===-1)W=q;let K=$.slice(G,W);if(Z===void 0)J9(D,K,Q);else{if(F===void 0)J9(Q,K,!0);else if(X)J9(Q,F,K.replace(/\\/g,""));else J9(Q,F,K);J9(D,Z,Q)}return D}function QX1($){return Object.keys($).map((D)=>{let Q=$[D];if(!Array.isArray(Q))Q=[Q];return Q.map((X)=>{return[D].concat(Object.keys(X).map((J)=>{let Y=X[J];if(!Array.isArray(Y))Y=[Y];return Y.map((Z)=>Z===!0?J:`${J}=${Z}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}OG0.exports={format:QX1,parse:DX1}});var OM=E((ot1,TG0)=>{var XX1=Q0("events"),JX1=Q0("https"),YX1=Q0("http"),MG0=Q0("net"),ZX1=Q0("tls"),{randomBytes:FX1,createHash:GX1}=Q0("crypto"),{Duplex:it1,Readable:rt1}=Q0("stream"),{URL:a_}=Q0("url"),R5=HZ(),UX1=i_(),WX1=o_(),{isBlob:qX1}=VZ(),{BINARY_TYPES:zG0,CLOSE_TIMEOUT:KX1,EMPTY_BUFFER:KM,GUID:HX1,kForOnEventAttribute:s_,kListener:VX1,kStatusCode:OX1,kWebSocket:ID,NOOP:NG0}=X7(),{EventTarget:{addEventListener:zX1,removeEventListener:LX1}}=VG0(),{format:MX1,parse:NX1}=qM(),{toBuffer:wX1}=YW(),wG0=Symbol("kAborted"),e_=[8,13],Y7=["CONNECTING","OPEN","CLOSING","CLOSED"],BX1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class z1 extends XX1{constructor($,D,Q){super();if(this._binaryType=zG0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=KM,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=z1.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,D===void 0)D=[];else if(!Array.isArray(D))if(typeof D==="object"&&D!==null)Q=D,D=[];else D=[D];BG0(this,$,D,Q)}else this._autoPong=Q.autoPong,this._closeTimeout=Q.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!zG0.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,D,Q){let X=new UX1({allowSynchronousEvents:Q.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:Q.maxBufferedChunks,maxFragments:Q.maxFragments,maxPayload:Q.maxPayload,skipUTF8Validation:Q.skipUTF8Validation}),J=new WX1($,this._extensions,Q.generateMask);if(this._receiver=X,this._sender=J,this._socket=$,X[ID]=this,J[ID]=this,$[ID]=this,X.on("conclude",jX1),X.on("drain",AX1),X.on("error",IX1),X.on("message",TX1),X.on("ping",CX1),X.on("pong",PX1),J.onerror=SX1,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(D.length>0)$.unshift(D);$.on("close",jG0),$.on("data",VM),$.on("end",AG0),$.on("error",IG0),this._readyState=z1.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=z1.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[R5.extensionName])this._extensions[R5.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=z1.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,D){if(this.readyState===z1.CLOSED)return;if(this.readyState===z1.CONNECTING){W4(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===z1.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=z1.CLOSING,this._sender.close($,D,!this._isServer,(Q)=>{if(Q)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),EG0(this)}pause(){if(this.readyState===z1.CONNECTING||this.readyState===z1.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")Q=$,$=D=void 0;else if(typeof D==="function")Q=D,D=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}if(D===void 0)D=!this._isServer;this._sender.ping($||KM,D,Q)}pong($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")Q=$,$=D=void 0;else if(typeof D==="function")Q=D,D=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}if(D===void 0)D=!this._isServer;this._sender.pong($||KM,D,Q)}resume(){if(this.readyState===z1.CONNECTING||this.readyState===z1.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")Q=D,D={};if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}let X={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...D};if(!this._extensions[R5.extensionName])X.compress=!1;this._sender.send($||KM,X,Q)}terminate(){if(this.readyState===z1.CLOSED)return;if(this.readyState===z1.CONNECTING){W4(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=z1.CLOSING,this._socket.destroy()}}Object.defineProperty(z1,"CONNECTING",{enumerable:!0,value:Y7.indexOf("CONNECTING")});Object.defineProperty(z1.prototype,"CONNECTING",{enumerable:!0,value:Y7.indexOf("CONNECTING")});Object.defineProperty(z1,"OPEN",{enumerable:!0,value:Y7.indexOf("OPEN")});Object.defineProperty(z1.prototype,"OPEN",{enumerable:!0,value:Y7.indexOf("OPEN")});Object.defineProperty(z1,"CLOSING",{enumerable:!0,value:Y7.indexOf("CLOSING")});Object.defineProperty(z1.prototype,"CLOSING",{enumerable:!0,value:Y7.indexOf("CLOSING")});Object.defineProperty(z1,"CLOSED",{enumerable:!0,value:Y7.indexOf("CLOSED")});Object.defineProperty(z1.prototype,"CLOSED",{enumerable:!0,value:Y7.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(z1.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(z1.prototype,`on${$}`,{enumerable:!0,get(){for(let D of this.listeners($))if(D[s_])return D[VX1];return null},set(D){for(let Q of this.listeners($))if(Q[s_]){this.removeListener($,Q);break}if(typeof D!=="function")return;this.addEventListener($,D,{[s_]:!0})}})});z1.prototype.addEventListener=zX1;z1.prototype.removeEventListener=LX1;TG0.exports=z1;function BG0($,D,Q,X){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:KX1,protocolVersion:e_[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...X,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=J.autoPong,$._closeTimeout=J.closeTimeout,!e_.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${e_.join(", ")})`);let Y;if(D instanceof a_)Y=D;else try{Y=new a_(D)}catch{throw SyntaxError(`Invalid URL: ${D}`)}if(Y.protocol==="http:")Y.protocol="ws:";else if(Y.protocol==="https:")Y.protocol="wss:";$._url=Y.href;let Z=Y.protocol==="wss:",F=Y.protocol==="ws+unix:",G;if(Y.protocol!=="ws:"&&!Z&&!F)G=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(F&&!Y.pathname)G="The URL's pathname is empty";else if(Y.hash)G="The URL contains a fragment identifier";if(G){let O=SyntaxError(G);if($._redirects===0)throw O;else{HM($,O);return}}let U=Z?443:80,W=FX1(16).toString("base64"),q=Z?JX1.request:YX1.request,K=new Set,H;if(J.createConnection=J.createConnection||(Z?EX1:RX1),J.defaultPort=J.defaultPort||U,J.port=Y.port||U,J.host=Y.hostname.startsWith("[")?Y.hostname.slice(1,-1):Y.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":W,Connection:"Upgrade",Upgrade:"websocket"},J.path=Y.pathname+Y.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)H=new R5({...J.perMessageDeflate,isServer:!1,maxPayload:J.maxPayload}),J.headers["Sec-WebSocket-Extensions"]=MX1({[R5.extensionName]:H.offer()});if(Q.length){for(let O of Q){if(typeof O!=="string"||!BX1.test(O)||K.has(O))throw SyntaxError("An invalid or duplicated subprotocol was specified");K.add(O)}J.headers["Sec-WebSocket-Protocol"]=Q.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Y.username||Y.password)J.auth=`${Y.username}:${Y.password}`;if(F){let O=J.path.split(":");J.socketPath=O[0],J.path=O[1]}let V;if(J.followRedirects){if($._redirects===0){$._originalIpc=F,$._originalSecure=Z,$._originalHostOrSocketPath=F?J.socketPath:Y.host;let O=X&&X.headers;if(X={...X,headers:{}},O)for(let[z,N]of Object.entries(O))X.headers[z.toLowerCase()]=N}else if($.listenerCount("redirect")===0){let O=F?$._originalIpc?J.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Y.host===$._originalHostOrSocketPath;if(!O||$._originalSecure&&!Z){if(delete J.headers.authorization,delete J.headers.cookie,!O)delete J.headers.host;J.auth=void 0}}if(J.auth&&!X.headers.authorization)X.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(V=$._req=q(J),$._redirects)$.emit("redirect",$.url,V)}else V=$._req=q(J);if(J.timeout)V.on("timeout",()=>{W4($,V,"Opening handshake has timed out")});if(V.on("error",(O)=>{if(V===null||V[wG0])return;V=$._req=null,HM($,O)}),V.on("response",(O)=>{let z=O.headers.location,N=O.statusCode;if(z&&J.followRedirects&&N>=300&&N<400){if(++$._redirects>J.maxRedirects){W4($,V,"Maximum redirects exceeded");return}V.abort();let B;try{B=new a_(z,D)}catch(L){let M=SyntaxError(`Invalid URL: ${z}`);HM($,M);return}BG0($,B,Q,X)}else if(!$.emit("unexpected-response",V,O))W4($,V,`Unexpected server response: ${O.statusCode}`)}),V.on("upgrade",(O,z,N)=>{if($.emit("upgrade",O),$.readyState!==z1.CONNECTING)return;V=$._req=null;let B=O.headers.upgrade;if(B===void 0||B.toLowerCase()!=="websocket"){W4($,z,"Invalid Upgrade header");return}let L=GX1("sha1").update(W+HX1).digest("base64");if(O.headers["sec-websocket-accept"]!==L){W4($,z,"Invalid Sec-WebSocket-Accept header");return}let M=O.headers["sec-websocket-protocol"],w;if(M!==void 0){if(!K.size)w="Server sent a subprotocol but none was requested";else if(!K.has(M))w="Server sent an invalid subprotocol"}else if(K.size)w="Server sent no subprotocol";if(w){W4($,z,w);return}if(M)$._protocol=M;let R=O.headers["sec-websocket-extensions"];if(R!==void 0){if(!H){W4($,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let x;try{x=NX1(R)}catch(j){W4($,z,"Invalid Sec-WebSocket-Extensions header");return}let _=Object.keys(x);if(_.length!==1||_[0]!==R5.extensionName){W4($,z,"Server indicated an extension that was not requested");return}try{H.accept(x[R5.extensionName])}catch(j){W4($,z,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[R5.extensionName]=H}$.setSocket(z,N,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxBufferedChunks:J.maxBufferedChunks,maxFragments:J.maxFragments,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(V,$);else V.end()}function HM($,D){$._readyState=z1.CLOSING,$._errorEmitted=!0,$.emit("error",D),$.emitClose()}function RX1($){return $.path=$.socketPath,MG0.connect($)}function EX1($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=MG0.isIP($.host)?"":$.host;return ZX1.connect($)}function W4($,D,Q){$._readyState=z1.CLOSING;let X=Error(Q);if(Error.captureStackTrace(X,W4),D.setHeader){if(D[wG0]=!0,D.abort(),D.socket&&!D.socket.destroyed)D.socket.destroy();process.nextTick(HM,$,X)}else D.destroy(X),D.once("error",$.emit.bind($,"error")),D.once("close",$.emitClose.bind($))}function $v($,D,Q){if(D){let X=qX1(D)?D.size:wX1(D).length;if($._socket)$._sender._bufferedBytes+=X;else $._bufferedAmount+=X}if(Q){let X=Error(`WebSocket is not open: readyState ${$.readyState} (${Y7[$.readyState]})`);process.nextTick(Q,X)}}function jX1($,D){let Q=this[ID];if(Q._closeFrameReceived=!0,Q._closeMessage=D,Q._closeCode=$,Q._socket[ID]===void 0)return;if(Q._socket.removeListener("data",VM),process.nextTick(RG0,Q._socket),$===1005)Q.close();else Q.close($,D)}function AX1(){let $=this[ID];if(!$.isPaused)$._socket.resume()}function IX1($){let D=this[ID];if(D._socket[ID]!==void 0)D._socket.removeListener("data",VM),process.nextTick(RG0,D._socket),D.close($[OX1]);if(!D._errorEmitted)D._errorEmitted=!0,D.emit("error",$)}function LG0(){this[ID].emitClose()}function TX1($,D){this[ID].emit("message",$,D)}function CX1($){let D=this[ID];if(D._autoPong)D.pong($,!this._isServer,NG0);D.emit("ping",$)}function PX1($){this[ID].emit("pong",$)}function RG0($){$.resume()}function SX1($){let D=this[ID];if(D.readyState===z1.CLOSED)return;if(D.readyState===z1.OPEN)D._readyState=z1.CLOSING,EG0(D);if(this._socket.end(),!D._errorEmitted)D._errorEmitted=!0,D.emit("error",$)}function EG0($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function jG0(){let $=this[ID];if(this.removeListener("close",jG0),this.removeListener("data",VM),this.removeListener("end",AG0),$._readyState=z1.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let D=this.read(this._readableState.length);$._receiver.write(D)}if($._receiver.end(),this[ID]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",LG0),$._receiver.on("finish",LG0)}function VM($){if(!this[ID]._receiver.write($))this.pause()}function AG0(){let $=this[ID];$._readyState=z1.CLOSING,$._receiver.end(),this.end()}function IG0(){let $=this[ID];if(this.removeListener("error",IG0),this.on("error",NG0),$)$._readyState=z1.CLOSING,this.destroy()}});var xG0=E((at1,SG0)=>{var tt1=OM(),{Duplex:xX1}=Q0("stream");function CG0($){$.emit("close")}function _X1(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function PG0($){if(this.removeListener("error",PG0),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function vX1($,D){let Q=!0,X=new xX1({...D,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Y,Z){let F=!Z&&X._readableState.objectMode?Y.toString():Y;if(!X.push(F))$.pause()}),$.once("error",function(Y){if(X.destroyed)return;Q=!1,X.destroy(Y)}),$.once("close",function(){if(X.destroyed)return;X.push(null)}),X._destroy=function(J,Y){if($.readyState===$.CLOSED){Y(J),process.nextTick(CG0,X);return}let Z=!1;if($.once("error",function(G){Z=!0,Y(G)}),$.once("close",function(){if(!Z)Y(J);process.nextTick(CG0,X)}),Q)$.terminate()},X._final=function(J){if($.readyState===$.CONNECTING){$.once("open",function(){X._final(J)});return}if($._socket===null)return;if($._socket._writableState.finished){if(J(),X._readableState.endEmitted)X.destroy()}else $._socket.once("finish",function(){J()}),$.close()},X._read=function(){if($.isPaused)$.resume()},X._write=function(J,Y,Z){if($.readyState===$.CONNECTING){$.once("open",function(){X._write(J,Y,Z)});return}$.send(J,Z)},X.on("end",_X1),X.on("error",PG0),X}SG0.exports=vX1});var Dv=E((st1,_G0)=>{var{tokenChars:kX1}=VZ();function yX1($){let D=new Set,Q=-1,X=-1,J=0;for(J;J<$.length;J++){let Z=$.charCodeAt(J);if(X===-1&&kX1[Z]===1){if(Q===-1)Q=J}else if(J!==0&&(Z===32||Z===9)){if(X===-1&&Q!==-1)X=J}else if(Z===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(X===-1)X=J;let F=$.slice(Q,X);if(D.has(F))throw SyntaxError(`The "${F}" subprotocol is duplicated`);D.add(F),Q=X=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(Q===-1||X!==-1)throw SyntaxError("Unexpected end of input");let Y=$.slice(Q,J);if(D.has(Y))throw SyntaxError(`The "${Y}" subprotocol is duplicated`);return D.add(Y),D}_G0.exports={parse:yX1}});var uG0=E(($a1,fG0)=>{var fX1=Q0("events"),zM=Q0("http"),{Duplex:et1}=Q0("stream"),{createHash:uX1}=Q0("crypto"),vG0=qM(),zX=HZ(),bX1=Dv(),hX1=OM(),{CLOSE_TIMEOUT:gX1,GUID:mX1,kWebSocket:dX1}=X7(),cX1=/^[+/0-9A-Za-z]{22}==$/;class yG0 extends fX1{constructor($,D){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:gX1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:hX1,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=zM.createServer((Q,X)=>{let J=zM.STATUS_CODES[426];X.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),X.end(J)}),this._server.listen($.port,$.host,$.backlog,D);else if($.server)this._server=$.server;if(this._server){let Q=this.emit.bind(this,"connection");this._removeListeners=lX1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(X,J,Y)=>{this.handleUpgrade(X,J,Y,Q)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(WW,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(WW,this);else this._shouldEmitClose=!0;else process.nextTick(WW,this)}else{let D=this._server;this._removeListeners(),this._removeListeners=this._server=null,D.close(()=>{WW(this)})}}shouldHandle($){if(this.options.path){let D=$.url.indexOf("?");if((D!==-1?$.url.slice(0,D):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,D,Q,X){D.on("error",kG0);let J=$.headers["sec-websocket-key"],Y=$.headers.upgrade,Z=+$.headers["sec-websocket-version"];if($.method!=="GET"){LX(this,$,D,405,"Invalid HTTP method");return}if(Y===void 0||Y.toLowerCase()!=="websocket"){LX(this,$,D,400,"Invalid Upgrade header");return}if(J===void 0||!cX1.test(J)){LX(this,$,D,400,"Missing or invalid Sec-WebSocket-Key header");return}if(Z!==13&&Z!==8){LX(this,$,D,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){qW(D,400);return}let F=$.headers["sec-websocket-protocol"],G=new Set;if(F!==void 0)try{G=bX1.parse(F)}catch(q){LX(this,$,D,400,"Invalid Sec-WebSocket-Protocol header");return}let U=$.headers["sec-websocket-extensions"],W={};if(this.options.perMessageDeflate&&U!==void 0){let q=new zX({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let K=vG0.parse(U);if(K[zX.extensionName])q.accept(K[zX.extensionName]),W[zX.extensionName]=q}catch(K){LX(this,$,D,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let q={origin:$.headers[`${Z===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(q,(K,H,V,O)=>{if(!K)return qW(D,H||401,V,O);this.completeUpgrade(W,J,G,$,D,Q,X)});return}if(!this.options.verifyClient(q))return qW(D,401)}this.completeUpgrade(W,J,G,$,D,Q,X)}completeUpgrade($,D,Q,X,J,Y,Z){if(!J.readable||!J.writable)return J.destroy();if(J[dX1])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return qW(J,503);let G=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${uX1("sha1").update(D+mX1).digest("base64")}`],U=new this.options.WebSocket(null,void 0,this.options);if(Q.size){let W=this.options.handleProtocols?this.options.handleProtocols(Q,X):Q.values().next().value;if(W)G.push(`Sec-WebSocket-Protocol: ${W}`),U._protocol=W}if($[zX.extensionName]){let W=$[zX.extensionName].params,q=vG0.format({[zX.extensionName]:[W]});G.push(`Sec-WebSocket-Extensions: ${q}`),U._extensions=$}if(this.emit("headers",G,X),J.write(G.concat(`\r
411
+ )`).eq("name",Q).eq("app_id",D).maybeSingle();if(J){let Z=J.code==="PGRST116"||J.message?.includes("Cannot coerce")?`Multiple channels matched for app "${D}" and channel "${Q}". Contact support if this persists.`:J.message;throw T0.error(`Error fetching native packages: ${Z}`),Error(`Error fetching native packages: ${Z}`)}if(!X)return NZ0([]);return NZ0(X.version?.native_packages??[])}function o1($,D){return $||D?.plugins?.CapacitorUpdater?.appId||D?.appId}function M5($){let D=[];if(!$.localVersion)return{compatible:!0,reasons:[],message:"Package only exists on remote (will be removed)"};if(!$.remoteVersion)return D.push("new_plugin"),{compatible:!1,reasons:D,message:"New native plugin added (requires app store update)"};let Q=!1;try{let q=NK($.localVersion),K=NK($.remoteVersion);Q=Th(q,K)}catch{Q=!1}if(!Q)D.push("version_mismatch");if($.localRequestedVersion&&$.remoteRequestedVersion&&$.localRequestedVersion.trim()!==$.remoteRequestedVersion.trim())D.push("requested_version_changed");let X=(q)=>typeof q==="string"&&q.trim().length>0,J=X($.localIosChecksum)&&X($.remoteIosChecksum)&&$.localIosChecksum!==$.remoteIosChecksum,Y=X($.localAndroidChecksum)&&X($.remoteAndroidChecksum)&&$.localAndroidChecksum!==$.remoteAndroidChecksum;if(J&&Y)D.push("both_platforms_changed");else if(J)D.push("ios_code_changed");else if(Y)D.push("android_code_changed");let Z=X($.localIosChecksum)!==X($.remoteIosChecksum),F=X($.localAndroidChecksum)!==X($.remoteAndroidChecksum);if(Z||F)D.push("platform_checksum_metadata_changed");let G=[],U=(q)=>q!=="requested_version_changed";for(let q of D)switch(q){case"version_mismatch":G.push(`version changed: ${$.remoteVersion} → ${$.localVersion}`);break;case"requested_version_changed":G.push(`requested version changed: ${$.remoteRequestedVersion??"unknown"} → ${$.localRequestedVersion??"unknown"}`);break;case"ios_code_changed":G.push("iOS native code changed");break;case"android_code_changed":G.push("Android native code changed");break;case"both_platforms_changed":G.push("iOS and Android native code changed");break;case"platform_checksum_metadata_changed":G.push("iOS/Android checksum metadata appeared or disappeared (may be Capgo CLI change — verify native code)");break;case"new_plugin":G.push("new plugin (requires app store update)");break;case"removed_plugin":G.push("plugin removed");break}if(!D.some(U))return{compatible:!0,reasons:D,message:G.length>0?G.join(", "):"Compatible"};return{compatible:!1,reasons:D,message:G.join(", ")}}function _4($){return M5($).compatible}async function rL($,D,Q,X,J){let Y=await __(X,J),Z=await iZ0($,D,Q),F=Y.filter((U)=>!!U.native).map((U)=>{let W=Z.get(U.name);if(W)return{name:U.name,localVersion:U.version,localRequestedVersion:U.requested_version,remoteVersion:W.version,remoteRequestedVersion:W.requested_version,localIosChecksum:U.ios_checksum,remoteIosChecksum:W.ios_checksum,localAndroidChecksum:U.android_checksum,remoteAndroidChecksum:W.android_checksum};return{name:U.name,localVersion:U.version,localRequestedVersion:U.requested_version,remoteVersion:void 0,localIosChecksum:U.ios_checksum,localAndroidChecksum:U.android_checksum}}),G=[...Z].filter(([U])=>!Y.some((W)=>W.name===U)).map(([U,W])=>({name:U,localVersion:void 0,remoteVersion:W.version,remoteRequestedVersion:W.requested_version,remoteIosChecksum:W.ios_checksum,remoteAndroidChecksum:W.android_checksum}));return F.push(...G),{finalCompatibility:F,localDependencies:Y}}async function QW($,D,Q,X){let J=await iZ0($,D,Q),Y=X.map((F)=>{let G=J.get(F.name);if(G)return{name:F.name,localVersion:F.version,localRequestedVersion:F.requested_version,remoteVersion:G.version,remoteRequestedVersion:G.requested_version,localIosChecksum:F.ios_checksum,remoteIosChecksum:G.ios_checksum,localAndroidChecksum:F.android_checksum,remoteAndroidChecksum:G.android_checksum};return{name:F.name,localVersion:F.version,localRequestedVersion:F.requested_version,remoteVersion:void 0,localIosChecksum:F.ios_checksum,localAndroidChecksum:F.android_checksum}}),Z=[...J].filter(([F])=>!X.some((G)=>G.name===F)).map(([F,G])=>({name:F,localVersion:void 0,remoteVersion:G.version,remoteRequestedVersion:G.requested_version,remoteIosChecksum:G.ios_checksum,remoteAndroidChecksum:G.android_checksum}));return Y.push(...Z),{finalCompatibility:Y,localDependencies:X}}function rZ0($){if(!F$($))return null;try{return JSON.parse(YD($,"utf-8"))}catch{return null}}function xL($){if(!$)return!1;return/@capgo\/capacitor-updater|CapgoCapacitorUpdater|CapacitorUpdaterPlugin/.test($)}function G51($){let D=rZ0($);if(!D)return!1;let Q=D.packageClassList;return Array.isArray(Q)&&Q.includes("CapacitorUpdaterPlugin")}function U51($,D){if(!D)return I1($,G4);return YZ.isAbsolute(D)?D:V5($,D)}function W51($=F4(),D){let Q=U51($,D),X=YZ.basename(Q)===G4?QZ(Q):Q,J=[I1(X,"ios","App"),I1($,"ios","App")].find((R)=>F$(R));if(!J)return{shouldCheck:!1,valid:!0,details:[]};let Y=rZ0(Q),Z={...Y?.dependencies,...Y?.devDependencies,...Y?.optionalDependencies},F=Object.hasOwn(Z,"@capgo/capacitor-updater"),G=[X,$].some((R)=>F$(I1(R,"node_modules","@capgo","capacitor-updater"))),U=I1(J,"Podfile"),W=I1(J,"CapApp-SPM","Package.swift"),q=F$(U)?YD(U,"utf-8"):void 0,K=F$(W)?YD(W,"utf-8"):void 0,H=xL(q)||xL(K),V=I1(J,"Podfile.lock"),O=I1(J,"App","capacitor.plugins.json"),z=I1(J,"App","capacitor.config.json"),N=F$(V)?YD(V,"utf-8"):void 0,B=F$(O)?YD(O,"utf-8"):void 0,L=xL(N)||xL(B)||G51(z);if(!(F||G||H||L))return{shouldCheck:!1,valid:!0,details:[]};let w=[];if(!H)w.push(`Missing @capgo/capacitor-updater in iOS dependency files (${U} or ${W})`);if(!L)w.push(`Missing @capgo/capacitor-updater in iOS native project outputs (${V}, ${O}, or ${z})`);return{shouldCheck:!0,valid:H&&L,details:w}}function q51($,D,Q){if(!$.shouldCheck||$.valid)return;let X=J51(D,"ios");Q?.(),T0.error("Capgo iOS dependency sync verification failed.");for(let J of $.details)T0.error(J);throw T0.error("Stop here to avoid testing on a broken native iOS project."),T0.warn(X.summary),T0.info(X.command),new U0(b2)}async function oZ0($,D,Q,X){let J=await f1({message:"Would you like to sync your project with Capacitor now? This is recommended to ensure encrypted updates work properly."});if(r0(J)){if($&&D&&Q)await wr("onboarding-v2",D,Q,"canceled");throw T0.warn("Canceled Capacitor sync"),new U0("Capacitor sync cancelled")}if(J){let Y=FX(),Z=u$();Z.start("Running the command...");let F;try{await new Promise((G,U)=>{let W=_71(Y.runner,["cap","sync"],{stdio:"pipe"});W.on("close",(q)=>{if(q===0)G();else U(Error(`Command failed with exit code ${q}`))}),W.on("error",(q)=>{U(q)})})}catch(G){F=G,T0.error(`Failed to run Capacitor sync: ${G}`),T0.warn(`Please run "${Y.runner} cap sync" manually to ensure encrypted updates work properly`)}if(X?.validateIosUpdater)q51(W51(F4(),X.packageJsonPath),Y.runner,()=>Z.stop("iOS sync check failed ❌"));if(F){Z.stop("Error");return}Z.stop("Capacitor sync completed ✅")}else{let Y=FX();T0.warn("⚠️ Important: If you upload encrypted bundles without syncing, updates will fail!"),T0.info(`Remember to run "${Y.runner} cap sync" before uploading encrypted bundles`)}}var T_,C_,IZ0,yL,T0,ZZ=".capgo_key",sD=".capgo_key_v2",fL,m6,HZ0="https://capgo.app",VZ0="https://files.capgo.app",_L="https://api.capgo.app",vL="https://console.capgo.app",TZ0=120000,k71=20971520,y71=1073741824,f71=103809024,oU,tU=1e4,P_="BundleUploadTimeoutError",G4="package.json",OZ0="Cannot connect to server please try again later",GX,xZ0,j_=null,SL=null,mL="5.10.0",dL="6.25.0",eU="7.0.30",MZ0=!1,DZ="npm",iU="install",I_="npx";var e0=t(()=>{m2();X1();_8();Oc();a6();nH();iH();Lr();Br();oH();gA();a3();wY();GK();xQ0();RL();gY0();y1();FK();g2();jL();T_=S1(dB(),1),C_=S1(nB(),1),IZ0=S1(Pl(),1),yL=S1(cH(),1);T0={error:($)=>PL("error",$),info:($)=>PL("info",$),success:($)=>PL("success",$),warn:($)=>PL("warn",$)},fL=`${ZZ}.pub`,m6=`${sD}.pub`;oU=[0,1000,3000,5000,1e4];GX=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i;xZ0=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/});function FF0($,D,Q={},X){let J=`${$}:${D}`,Y=aL.get(J);if(Y)return Y;let Z=(async()=>{try{if(X?.aborted)return;if(Q.fetchOwnerOrg)return await Q.fetchOwnerOrg($,D,X);if(Q.createClient){let W=(await Q.createClient($,void 0,void 0,!0,!1)).from("apps").select("owner_org").eq("app_id",D);if(X)W=W.abortSignal(X);let{data:q}=await W.maybeSingle();return q?.owner_org??void 0}let{data:F,error:G}=await q1(`app/${encodeURIComponent(D)}`,{apikey:$,method:"GET",body:void 0,signal:X});if(G||!F?.owner_org)return;return F.owner_org}catch{return}})();return aL.set(J,Z),Z.then((F)=>{if(!F)aL.delete(J)}).catch(()=>{aL.delete(J)}),Z}var aL;var GF0=t(()=>{e0();aL=new Map});import{AsyncLocalStorage as C51}from"node:async_hooks";import{env as UF0}from"node:process";function P51(){return I7(UF0.CAPGO_DISABLE_TELEMETRY)||I7(UF0.CAPGO_DISABLE_POSTHOG)}function S51($){WF0.add($),$.finally(()=>WF0.delete($))}function x51($,D){let Q=KF0.get($);if(Q)return Q;let X=(async()=>{try{let J=await O1(!0).catch(()=>{return}),Y=o1("",J?.config)||void 0;if(!Y)return{};let Z=await FF0($,Y,{},D);return{appId:Y,orgId:Z}}catch{return{}}})();return KF0.set($,X),X}function F1($){if(P51())return Promise.resolve();let D=$.apikey??L5();if(!D)return Promise.resolve();let Q=new AbortController;qF0.add(Q);let X=(async()=>{try{let{appId:J,orgId:Y}=$;if(J===void 0&&Y===void 0){let F=await x51(D,Q.signal);J=F.appId,Y=F.orgId}let Z={...J?{app_id:J}:{},...$.tags??{}};await s0(D,{channel:$.channel,event:$.event,tracking_version:2,...$.timestamp?{timestamp:$.timestamp}:{},...Y?{org_id:Y}:{},tags:Z,...$.nonPersonTags?{nonPersonTags:$.nonPersonTags}:{}},!1,Q.signal).catch(()=>{})}catch{}finally{qF0.delete(Q)}})();return S51(X),X}function y51($){let D=$.durationMs>Hr;if($.ok&&!D)return;let Q=v51.getStore()??_51,X={operation:Vr($.url,$.method),method:$.method,status_code:$.status,duration_ms:$.durationMs,ok:$.ok,slow:D};if($.source)X.source=$.source;if(Q)X.command_path=Q;if(!$.ok)X.error_category=$.error!==void 0?ZK($.error):Yh($.status);F1({apikey:$.apikey,channel:k51,event:"Supabase Call",tags:X})}var WF0,qF0,KF0,_51="",v51,k51="cli-perf";var $D=t(()=>{Q8();GK();e0();GF0();iH();nH();iH();WF0=new Set,qF0=new Set;KF0=new Map;v51=new C51;Kr(y51)});var X7=E((ut1,hF0)=>{var uF0=["nodebuffer","arraybuffer","fragments"],bF0=typeof Blob<"u";if(bF0)uF0.push("blob");hF0.exports={BINARY_TYPES:uF0,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:bF0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var YW=E((bt1,JM)=>{var{EMPTY_BUFFER:AQ1}=X7(),d_=Buffer[Symbol.species];function IQ1($,D){if($.length===0)return AQ1;if($.length===1)return $[0];let Q=Buffer.allocUnsafe(D),X=0;for(let J=0;J<$.length;J++){let Y=$[J];Q.set(Y,X),X+=Y.length}if(X<D)return new d_(Q.buffer,Q.byteOffset,X);return Q}function gF0($,D,Q,X,J){for(let Y=0;Y<J;Y++)Q[X+Y]=$[Y]^D[Y&3]}function mF0($,D){for(let Q=0;Q<$.length;Q++)$[Q]^=D[Q&3]}function TQ1($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function c_($){if(c_.readOnly=!0,Buffer.isBuffer($))return $;let D;if($ instanceof ArrayBuffer)D=new d_($);else if(ArrayBuffer.isView($))D=new d_($.buffer,$.byteOffset,$.byteLength);else D=Buffer.from($),c_.readOnly=!1;return D}JM.exports={concat:IQ1,mask:gF0,toArrayBuffer:TQ1,toBuffer:c_,unmask:mF0};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();JM.exports.mask=function(D,Q,X,J,Y){if(Y<48)gF0(D,Q,X,J,Y);else $.mask(D,Q,X,J,Y)},JM.exports.unmask=function(D,Q){if(D.length<32)mF0(D,Q);else $.unmask(D,Q)}}catch($){}});var nF0=E((ht1,lF0)=>{var dF0=Symbol("kDone"),l_=Symbol("kRun");class cF0{constructor($){this[dF0]=()=>{this.pending--,this[l_]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[l_]()}[l_](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[dF0])}}}lF0.exports=cF0});var HZ=E((gt1,tF0)=>{var ZW=Q0("zlib"),pF0=YW(),CQ1=nF0(),{kStatusCode:iF0}=X7(),PQ1=Buffer[Symbol.species],SQ1=Buffer.from([0,0,255,255]),ZM=Symbol("permessage-deflate"),J7=Symbol("total-length"),qZ=Symbol("callback"),N5=Symbol("buffers"),KZ=Symbol("error"),YM;class rF0{constructor($){if(this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!YM){let D=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;YM=new CQ1(D)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[qZ];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let D=this._options,Q=$.find((X)=>{if(D.serverNoContextTakeover===!1&&X.server_no_context_takeover||X.server_max_window_bits&&(D.serverMaxWindowBits===!1||typeof D.serverMaxWindowBits==="number"&&D.serverMaxWindowBits>X.server_max_window_bits)||typeof D.clientMaxWindowBits==="number"&&!X.client_max_window_bits)return!1;return!0});if(!Q)throw Error("None of the extension offers can be accepted");if(D.serverNoContextTakeover)Q.server_no_context_takeover=!0;if(D.clientNoContextTakeover)Q.client_no_context_takeover=!0;if(typeof D.serverMaxWindowBits==="number")Q.server_max_window_bits=D.serverMaxWindowBits;if(typeof D.clientMaxWindowBits==="number")Q.client_max_window_bits=D.clientMaxWindowBits;else if(Q.client_max_window_bits===!0||D.clientMaxWindowBits===!1)delete Q.client_max_window_bits;return Q}acceptAsClient($){let D=$[0];if(this._options.clientNoContextTakeover===!1&&D.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!D.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")D.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&D.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return D}normalizeParams($){return $.forEach((D)=>{Object.keys(D).forEach((Q)=>{let X=D[Q];if(X.length>1)throw Error(`Parameter "${Q}" must have only a single value`);if(X=X[0],Q==="client_max_window_bits"){if(X!==!0){let J=+X;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${Q}": ${X}`);X=J}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${Q}": ${X}`)}else if(Q==="server_max_window_bits"){let J=+X;if(!Number.isInteger(J)||J<8||J>15)throw TypeError(`Invalid value for parameter "${Q}": ${X}`);X=J}else if(Q==="client_no_context_takeover"||Q==="server_no_context_takeover"){if(X!==!0)throw TypeError(`Invalid value for parameter "${Q}": ${X}`)}else throw Error(`Unknown parameter "${Q}"`);D[Q]=X})}),$}decompress($,D,Q){YM.add((X)=>{this._decompress($,D,(J,Y)=>{X(),Q(J,Y)})})}compress($,D,Q){YM.add((X)=>{this._compress($,D,(J,Y)=>{X(),Q(J,Y)})})}_decompress($,D,Q){let X=this._isServer?"client":"server";if(!this._inflate){let J=`${X}_max_window_bits`,Y=typeof this.params[J]!=="number"?ZW.Z_DEFAULT_WINDOWBITS:this.params[J];this._inflate=ZW.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Y}),this._inflate[ZM]=this,this._inflate[J7]=0,this._inflate[N5]=[],this._inflate.on("error",_Q1),this._inflate.on("data",oF0)}if(this._inflate[qZ]=Q,this._inflate.write($),D)this._inflate.write(SQ1);this._inflate.flush(()=>{let J=this._inflate[KZ];if(J){this._inflate.close(),this._inflate=null,Q(J);return}let Y=pF0.concat(this._inflate[N5],this._inflate[J7]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[J7]=0,this._inflate[N5]=[],D&&this.params[`${X}_no_context_takeover`])this._inflate.reset();Q(null,Y)})}_compress($,D,Q){let X=this._isServer?"server":"client";if(!this._deflate){let J=`${X}_max_window_bits`,Y=typeof this.params[J]!=="number"?ZW.Z_DEFAULT_WINDOWBITS:this.params[J];this._deflate=ZW.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Y}),this._deflate[J7]=0,this._deflate[N5]=[],this._deflate.on("data",xQ1)}this._deflate[qZ]=Q,this._deflate.write($),this._deflate.flush(ZW.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let J=pF0.concat(this._deflate[N5],this._deflate[J7]);if(D)J=new PQ1(J.buffer,J.byteOffset,J.length-4);if(this._deflate[qZ]=null,this._deflate[J7]=0,this._deflate[N5]=[],D&&this.params[`${X}_no_context_takeover`])this._deflate.reset();Q(null,J)})}}tF0.exports=rF0;function xQ1($){this[N5].push($),this[J7]+=$.length}function oF0($){if(this[J7]+=$.length,this[ZM]._maxPayload<1||this[J7]<=this[ZM]._maxPayload){this[N5].push($);return}this[KZ]=RangeError("Max payload size exceeded"),this[KZ].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[KZ][iF0]=1009,this.removeListener("data",oF0),this.reset()}function _Q1($){if(this[ZM]._inflate=null,this[KZ]){this[qZ](this[KZ]);return}$[iF0]=1007,this[qZ]($)}});var VZ=E((mt1,FM)=>{var{isUtf8:aF0}=Q0("buffer"),{hasBlob:vQ1}=X7(),kQ1=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function yQ1($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function n_($){let D=$.length,Q=0;while(Q<D)if(($[Q]&128)===0)Q++;else if(($[Q]&224)===192){if(Q+1===D||($[Q+1]&192)!==128||($[Q]&254)===192)return!1;Q+=2}else if(($[Q]&240)===224){if(Q+2>=D||($[Q+1]&192)!==128||($[Q+2]&192)!==128||$[Q]===224&&($[Q+1]&224)===128||$[Q]===237&&($[Q+1]&224)===160)return!1;Q+=3}else if(($[Q]&248)===240){if(Q+3>=D||($[Q+1]&192)!==128||($[Q+2]&192)!==128||($[Q+3]&192)!==128||$[Q]===240&&($[Q+1]&240)===128||$[Q]===244&&$[Q+1]>143||$[Q]>244)return!1;Q+=4}else return!1;return!0}function fQ1($){return vQ1&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}FM.exports={isBlob:fQ1,isValidStatusCode:yQ1,isValidUTF8:n_,tokenChars:kQ1};if(aF0)FM.exports.isValidUTF8=function($){return $.length<24?n_($):aF0($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();FM.exports.isValidUTF8=function(D){return D.length<32?n_(D):$(D)}}catch($){}});var i_=E((dt1,QG0)=>{var{Writable:uQ1}=Q0("stream"),sF0=HZ(),{BINARY_TYPES:bQ1,EMPTY_BUFFER:eF0,kStatusCode:hQ1,kWebSocket:gQ1}=X7(),{concat:p_,toArrayBuffer:mQ1,unmask:dQ1}=YW(),{isValidStatusCode:cQ1,isValidUTF8:$G0}=VZ(),GM=Buffer[Symbol.species];class DG0 extends uQ1{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||bQ1[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxBufferedChunks=$.maxBufferedChunks|0,this._maxFragments=$.maxFragments|0,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[gQ1]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,D,Q){if(this._opcode===8&&this._state==0)return Q();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){Q(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(Q)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let Q=this._buffers[0];return this._buffers[0]=new GM(Q.buffer,Q.byteOffset+$,Q.length-$),new GM(Q.buffer,Q.byteOffset,$)}let D=Buffer.allocUnsafe($);do{let Q=this._buffers[0],X=D.length-$;if($>=Q.length)D.set(this._buffers.shift(),X);else D.set(new Uint8Array(Q.buffer,Q.byteOffset,$),X),this._buffers[0]=new GM(Q.buffer,Q.byteOffset+$,Q.length-$);$-=Q.length}while($>0);return D}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let D=this.consume(2);if((D[0]&48)!==0){let X=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(X);return}let Q=(D[0]&64)===64;if(Q&&!this._extensions[sF0.extensionName]){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._fin=(D[0]&128)===128,this._opcode=D[0]&15,this._payloadLength=D[1]&127,this._opcode===0){if(Q){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(!this._fragmented){let X=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}this._compressed=Q}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let X=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(X);return}if(Q){let X=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(X);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let X=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(X);return}}else{let X=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(X);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(D[1]&128)===128,this._isServer){if(!this._masked){let X=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(X);return}}else if(this._masked){let X=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(X);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let D=this.consume(8),Q=D.readUInt32BE(0);if(Q>Math.pow(2,21)-1){let X=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(X);return}this._payloadLength=Q*Math.pow(2,32)+D.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let D=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(D);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let D=eF0;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(D=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)dQ1(D,this._mask)}if(this._opcode>7){this.controlMessage(D,$);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let Q=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");$(Q);return}if(this._compressed){this._state=5,this.decompress(D,$);return}if(D.length)this._messageLength=this._totalPayloadLength,this._fragments.push(D);this.dataMessage($)}decompress($,D){this._extensions[sF0.extensionName].decompress($,this._fin,(X,J)=>{if(X)return D(X);if(J.length){if(this._messageLength+=J.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Y=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D(Y);return}this._fragments.push(J)}if(this.dataMessage(D),this._state===0)this.startLoop(D)})}dataMessage($){if(!this._fin){this._state=0;return}let D=this._messageLength,Q=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let X;if(this._binaryType==="nodebuffer")X=p_(Q,D);else if(this._binaryType==="arraybuffer")X=mQ1(p_(Q,D));else if(this._binaryType==="blob")X=new Blob(Q);else X=Q;if(this._allowSynchronousEvents)this.emit("message",X,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!0),this._state=0,this.startLoop($)})}else{let X=p_(Q,D);if(!this._skipUTF8Validation&&!$G0(X)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(J);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",X,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",X,!1),this._state=0,this.startLoop($)})}}controlMessage($,D){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,eF0),this.end();else{let Q=$.readUInt16BE(0);if(!cQ1(Q)){let J=this.createError(RangeError,`invalid status code ${Q}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");D(J);return}let X=new GM($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!$G0(X)){let J=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(J);return}this._loop=!1,this.emit("conclude",Q,X),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(D)})}createError($,D,Q,X,J){this._loop=!1,this._errored=!0;let Y=new $(Q?`Invalid WebSocket frame: ${D}`:D);return Error.captureStackTrace(Y,this.createError),Y.code=J,Y[hQ1]=X,Y}}QG0.exports=DG0});var o_=E((lt1,YG0)=>{var{Duplex:ct1}=Q0("stream"),{randomFillSync:lQ1}=Q0("crypto"),{types:{isUint8Array:nQ1}}=Q0("util"),XG0=HZ(),{EMPTY_BUFFER:pQ1,kWebSocket:iQ1,NOOP:rQ1}=X7(),{isBlob:OZ,isValidStatusCode:oQ1}=VZ(),{mask:JG0,toBuffer:VX}=YW(),v4=Symbol("kByteLength"),tQ1=Buffer.alloc(4),OX,zZ=8192,L8=0,aQ1=1,sQ1=2;class w5{constructor($,D,Q){if(this._extensions=D||{},Q)this._generateMask=Q,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=L8,this.onerror=rQ1,this[iQ1]=void 0}static frame($,D){let Q,X=!1,J=2,Y=!1;if(D.mask){if(Q=D.maskBuffer||tQ1,D.generateMask)D.generateMask(Q);else{if(zZ===8192){if(OX===void 0)OX=Buffer.alloc(8192);lQ1(OX,0,8192),zZ=0}Q[0]=OX[zZ++],Q[1]=OX[zZ++],Q[2]=OX[zZ++],Q[3]=OX[zZ++]}Y=(Q[0]|Q[1]|Q[2]|Q[3])===0,J=6}let Z;if(typeof $==="string")if((!D.mask||Y)&&D[v4]!==void 0)Z=D[v4];else $=Buffer.from($),Z=$.length;else Z=$.length,X=D.mask&&D.readOnly&&!Y;let F=Z;if(Z>=65536)J+=8,F=127;else if(Z>125)J+=2,F=126;let G=Buffer.allocUnsafe(X?Z+J:J);if(G[0]=D.fin?D.opcode|128:D.opcode,D.rsv1)G[0]|=64;if(G[1]=F,F===126)G.writeUInt16BE(Z,2);else if(F===127)G[2]=G[3]=0,G.writeUIntBE(Z,4,6);if(!D.mask)return[G,$];if(G[1]|=128,G[J-4]=Q[0],G[J-3]=Q[1],G[J-2]=Q[2],G[J-1]=Q[3],Y)return[G,$];if(X)return JG0($,Q,G,J,Z),[G];return JG0($,Q,$,0,Z),[G,$]}close($,D,Q,X){let J;if($===void 0)J=pQ1;else if(typeof $!=="number"||!oQ1($))throw TypeError("First argument must be a valid error code number");else if(D===void 0||!D.length)J=Buffer.allocUnsafe(2),J.writeUInt16BE($,0);else{let Z=Buffer.byteLength(D);if(Z>123)throw RangeError("The message must not be greater than 123 bytes");if(J=Buffer.allocUnsafe(2+Z),J.writeUInt16BE($,0),typeof D==="string")J.write(D,2);else if(nQ1(D))J.set(D,2);else throw TypeError("Second argument must be a string or a Uint8Array")}let Y={[v4]:J.length,fin:!0,generateMask:this._generateMask,mask:Q,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==L8)this.enqueue([this.dispatch,J,!1,Y,X]);else this.sendFrame(w5.frame(J,Y),X)}ping($,D,Q){let X,J;if(typeof $==="string")X=Buffer.byteLength($),J=!1;else if(OZ($))X=$.size,J=!1;else $=VX($),X=$.length,J=VX.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Y={[v4]:X,fin:!0,generateMask:this._generateMask,mask:D,maskBuffer:this._maskBuffer,opcode:9,readOnly:J,rsv1:!1};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,!1,Y,Q]);else this.getBlobData($,!1,Y,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,!1,Y,Q]);else this.sendFrame(w5.frame($,Y),Q)}pong($,D,Q){let X,J;if(typeof $==="string")X=Buffer.byteLength($),J=!1;else if(OZ($))X=$.size,J=!1;else $=VX($),X=$.length,J=VX.readOnly;if(X>125)throw RangeError("The data size must not be greater than 125 bytes");let Y={[v4]:X,fin:!0,generateMask:this._generateMask,mask:D,maskBuffer:this._maskBuffer,opcode:10,readOnly:J,rsv1:!1};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,!1,Y,Q]);else this.getBlobData($,!1,Y,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,!1,Y,Q]);else this.sendFrame(w5.frame($,Y),Q)}send($,D,Q){let X=this._extensions[XG0.extensionName],J=D.binary?2:1,Y=D.compress,Z,F;if(typeof $==="string")Z=Buffer.byteLength($),F=!1;else if(OZ($))Z=$.size,F=!1;else $=VX($),Z=$.length,F=VX.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Y&&X&&X.params[X._isServer?"server_no_context_takeover":"client_no_context_takeover"])Y=Z>=X._threshold;this._compress=Y}else Y=!1,J=0;if(D.fin)this._firstFragment=!0;let G={[v4]:Z,fin:D.fin,generateMask:this._generateMask,mask:D.mask,maskBuffer:this._maskBuffer,opcode:J,readOnly:F,rsv1:Y};if(OZ($))if(this._state!==L8)this.enqueue([this.getBlobData,$,this._compress,G,Q]);else this.getBlobData($,this._compress,G,Q);else if(this._state!==L8)this.enqueue([this.dispatch,$,this._compress,G,Q]);else this.dispatch($,this._compress,G,Q)}getBlobData($,D,Q,X){this._bufferedBytes+=Q[v4],this._state=sQ1,$.arrayBuffer().then((J)=>{if(this._socket.destroyed){let Z=Error("The socket was closed while the blob was being read");process.nextTick(r_,this,Z,X);return}this._bufferedBytes-=Q[v4];let Y=VX(J);if(!D)this._state=L8,this.sendFrame(w5.frame(Y,Q),X),this.dequeue();else this.dispatch(Y,D,Q,X)}).catch((J)=>{process.nextTick(eQ1,this,J,X)})}dispatch($,D,Q,X){if(!D){this.sendFrame(w5.frame($,Q),X);return}let J=this._extensions[XG0.extensionName];this._bufferedBytes+=Q[v4],this._state=aQ1,J.compress($,Q.fin,(Y,Z)=>{if(this._socket.destroyed){let F=Error("The socket was closed while data was being compressed");r_(this,F,X);return}this._bufferedBytes-=Q[v4],this._state=L8,Q.readOnly=!1,this.sendFrame(w5.frame(Z,Q),X),this.dequeue()})}dequeue(){while(this._state===L8&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][v4],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][v4],this._queue.push($)}sendFrame($,D){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],D),this._socket.uncork();else this._socket.write($[0],D)}}YG0.exports=w5;function r_($,D,Q){if(typeof Q==="function")Q(D);for(let X=0;X<$._queue.length;X++){let J=$._queue[X],Y=J[J.length-1];if(typeof Y==="function")Y(D)}}function eQ1($,D,Q){r_($,D,Q),$.onerror(D)}});var VG0=E((nt1,HG0)=>{var{kForOnEventAttribute:FW,kListener:t_}=X7(),ZG0=Symbol("kCode"),FG0=Symbol("kData"),GG0=Symbol("kError"),UG0=Symbol("kMessage"),WG0=Symbol("kReason"),LZ=Symbol("kTarget"),qG0=Symbol("kType"),KG0=Symbol("kWasClean");class B5{constructor($){this[LZ]=null,this[qG0]=$}get target(){return this[LZ]}get type(){return this[qG0]}}Object.defineProperty(B5.prototype,"target",{enumerable:!0});Object.defineProperty(B5.prototype,"type",{enumerable:!0});class MZ extends B5{constructor($,D={}){super($);this[ZG0]=D.code===void 0?0:D.code,this[WG0]=D.reason===void 0?"":D.reason,this[KG0]=D.wasClean===void 0?!1:D.wasClean}get code(){return this[ZG0]}get reason(){return this[WG0]}get wasClean(){return this[KG0]}}Object.defineProperty(MZ.prototype,"code",{enumerable:!0});Object.defineProperty(MZ.prototype,"reason",{enumerable:!0});Object.defineProperty(MZ.prototype,"wasClean",{enumerable:!0});class GW extends B5{constructor($,D={}){super($);this[GG0]=D.error===void 0?null:D.error,this[UG0]=D.message===void 0?"":D.message}get error(){return this[GG0]}get message(){return this[UG0]}}Object.defineProperty(GW.prototype,"error",{enumerable:!0});Object.defineProperty(GW.prototype,"message",{enumerable:!0});class WM extends B5{constructor($,D={}){super($);this[FG0]=D.data===void 0?null:D.data}get data(){return this[FG0]}}Object.defineProperty(WM.prototype,"data",{enumerable:!0});var $X1={addEventListener($,D,Q={}){for(let J of this.listeners($))if(!Q[FW]&&J[t_]===D&&!J[FW])return;let X;if($==="message")X=function(Y,Z){let F=new WM("message",{data:Z?Y:Y.toString()});F[LZ]=this,UM(D,this,F)};else if($==="close")X=function(Y,Z){let F=new MZ("close",{code:Y,reason:Z.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});F[LZ]=this,UM(D,this,F)};else if($==="error")X=function(Y){let Z=new GW("error",{error:Y,message:Y.message});Z[LZ]=this,UM(D,this,Z)};else if($==="open")X=function(){let Y=new B5("open");Y[LZ]=this,UM(D,this,Y)};else return;if(X[FW]=!!Q[FW],X[t_]=D,Q.once)this.once($,X);else this.on($,X)},removeEventListener($,D){for(let Q of this.listeners($))if(Q[t_]===D&&!Q[FW]){this.removeListener($,Q);break}}};HG0.exports={CloseEvent:MZ,ErrorEvent:GW,Event:B5,EventTarget:$X1,MessageEvent:WM};function UM($,D,Q){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,Q);else $.call(D,Q)}});var qM=E((pt1,OG0)=>{var{tokenChars:UW}=VZ();function J9($,D,Q){if($[D]===void 0)$[D]=[Q];else $[D].push(Q)}function DX1($){let D=Object.create(null),Q=Object.create(null),X=!1,J=!1,Y=!1,Z,F,G=-1,U=-1,W=-1,q=0;for(;q<$.length;q++)if(U=$.charCodeAt(q),Z===void 0)if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(q!==0&&(U===32||U===9)){if(W===-1&&G!==-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;let H=$.slice(G,W);if(U===44)J9(D,H,Q),Q=Object.create(null);else Z=H;G=W=-1}else throw SyntaxError(`Unexpected character at index ${q}`);else if(F===void 0)if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(U===32||U===9){if(W===-1&&G!==-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;if(J9(Q,$.slice(G,W),!0),U===44)J9(D,Z,Q),Q=Object.create(null),Z=void 0;G=W=-1}else if(U===61&&G!==-1&&W===-1)F=$.slice(G,q),G=W=-1;else throw SyntaxError(`Unexpected character at index ${q}`);else if(J){if(UW[U]!==1)throw SyntaxError(`Unexpected character at index ${q}`);if(G===-1)G=q;else if(!X)X=!0;J=!1}else if(Y)if(UW[U]===1){if(G===-1)G=q}else if(U===34&&G!==-1)Y=!1,W=q;else if(U===92)J=!0;else throw SyntaxError(`Unexpected character at index ${q}`);else if(U===34&&$.charCodeAt(q-1)===61)Y=!0;else if(W===-1&&UW[U]===1){if(G===-1)G=q}else if(G!==-1&&(U===32||U===9)){if(W===-1)W=q}else if(U===59||U===44){if(G===-1)throw SyntaxError(`Unexpected character at index ${q}`);if(W===-1)W=q;let H=$.slice(G,W);if(X)H=H.replace(/\\/g,""),X=!1;if(J9(Q,F,H),U===44)J9(D,Z,Q),Q=Object.create(null),Z=void 0;F=void 0,G=W=-1}else throw SyntaxError(`Unexpected character at index ${q}`);if(G===-1||Y||U===32||U===9)throw SyntaxError("Unexpected end of input");if(W===-1)W=q;let K=$.slice(G,W);if(Z===void 0)J9(D,K,Q);else{if(F===void 0)J9(Q,K,!0);else if(X)J9(Q,F,K.replace(/\\/g,""));else J9(Q,F,K);J9(D,Z,Q)}return D}function QX1($){return Object.keys($).map((D)=>{let Q=$[D];if(!Array.isArray(Q))Q=[Q];return Q.map((X)=>{return[D].concat(Object.keys(X).map((J)=>{let Y=X[J];if(!Array.isArray(Y))Y=[Y];return Y.map((Z)=>Z===!0?J:`${J}=${Z}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}OG0.exports={format:QX1,parse:DX1}});var OM=E((ot1,TG0)=>{var XX1=Q0("events"),JX1=Q0("https"),YX1=Q0("http"),MG0=Q0("net"),ZX1=Q0("tls"),{randomBytes:FX1,createHash:GX1}=Q0("crypto"),{Duplex:it1,Readable:rt1}=Q0("stream"),{URL:a_}=Q0("url"),R5=HZ(),UX1=i_(),WX1=o_(),{isBlob:qX1}=VZ(),{BINARY_TYPES:zG0,CLOSE_TIMEOUT:KX1,EMPTY_BUFFER:KM,GUID:HX1,kForOnEventAttribute:s_,kListener:VX1,kStatusCode:OX1,kWebSocket:ID,NOOP:NG0}=X7(),{EventTarget:{addEventListener:zX1,removeEventListener:LX1}}=VG0(),{format:MX1,parse:NX1}=qM(),{toBuffer:wX1}=YW(),wG0=Symbol("kAborted"),e_=[8,13],Y7=["CONNECTING","OPEN","CLOSING","CLOSED"],BX1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class z1 extends XX1{constructor($,D,Q){super();if(this._binaryType=zG0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=KM,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=z1.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,D===void 0)D=[];else if(!Array.isArray(D))if(typeof D==="object"&&D!==null)Q=D,D=[];else D=[D];BG0(this,$,D,Q)}else this._autoPong=Q.autoPong,this._closeTimeout=Q.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!zG0.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,D,Q){let X=new UX1({allowSynchronousEvents:Q.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:Q.maxBufferedChunks,maxFragments:Q.maxFragments,maxPayload:Q.maxPayload,skipUTF8Validation:Q.skipUTF8Validation}),J=new WX1($,this._extensions,Q.generateMask);if(this._receiver=X,this._sender=J,this._socket=$,X[ID]=this,J[ID]=this,$[ID]=this,X.on("conclude",jX1),X.on("drain",AX1),X.on("error",IX1),X.on("message",TX1),X.on("ping",CX1),X.on("pong",PX1),J.onerror=SX1,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(D.length>0)$.unshift(D);$.on("close",jG0),$.on("data",VM),$.on("end",AG0),$.on("error",IG0),this._readyState=z1.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=z1.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[R5.extensionName])this._extensions[R5.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=z1.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,D){if(this.readyState===z1.CLOSED)return;if(this.readyState===z1.CONNECTING){W4(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===z1.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=z1.CLOSING,this._sender.close($,D,!this._isServer,(Q)=>{if(Q)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),EG0(this)}pause(){if(this.readyState===z1.CONNECTING||this.readyState===z1.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")Q=$,$=D=void 0;else if(typeof D==="function")Q=D,D=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}if(D===void 0)D=!this._isServer;this._sender.ping($||KM,D,Q)}pong($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")Q=$,$=D=void 0;else if(typeof D==="function")Q=D,D=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}if(D===void 0)D=!this._isServer;this._sender.pong($||KM,D,Q)}resume(){if(this.readyState===z1.CONNECTING||this.readyState===z1.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,D,Q){if(this.readyState===z1.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")Q=D,D={};if(typeof $==="number")$=$.toString();if(this.readyState!==z1.OPEN){$v(this,$,Q);return}let X={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...D};if(!this._extensions[R5.extensionName])X.compress=!1;this._sender.send($||KM,X,Q)}terminate(){if(this.readyState===z1.CLOSED)return;if(this.readyState===z1.CONNECTING){W4(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=z1.CLOSING,this._socket.destroy()}}Object.defineProperty(z1,"CONNECTING",{enumerable:!0,value:Y7.indexOf("CONNECTING")});Object.defineProperty(z1.prototype,"CONNECTING",{enumerable:!0,value:Y7.indexOf("CONNECTING")});Object.defineProperty(z1,"OPEN",{enumerable:!0,value:Y7.indexOf("OPEN")});Object.defineProperty(z1.prototype,"OPEN",{enumerable:!0,value:Y7.indexOf("OPEN")});Object.defineProperty(z1,"CLOSING",{enumerable:!0,value:Y7.indexOf("CLOSING")});Object.defineProperty(z1.prototype,"CLOSING",{enumerable:!0,value:Y7.indexOf("CLOSING")});Object.defineProperty(z1,"CLOSED",{enumerable:!0,value:Y7.indexOf("CLOSED")});Object.defineProperty(z1.prototype,"CLOSED",{enumerable:!0,value:Y7.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(z1.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(z1.prototype,`on${$}`,{enumerable:!0,get(){for(let D of this.listeners($))if(D[s_])return D[VX1];return null},set(D){for(let Q of this.listeners($))if(Q[s_]){this.removeListener($,Q);break}if(typeof D!=="function")return;this.addEventListener($,D,{[s_]:!0})}})});z1.prototype.addEventListener=zX1;z1.prototype.removeEventListener=LX1;TG0.exports=z1;function BG0($,D,Q,X){let J={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:KX1,protocolVersion:e_[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...X,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=J.autoPong,$._closeTimeout=J.closeTimeout,!e_.includes(J.protocolVersion))throw RangeError(`Unsupported protocol version: ${J.protocolVersion} (supported versions: ${e_.join(", ")})`);let Y;if(D instanceof a_)Y=D;else try{Y=new a_(D)}catch{throw SyntaxError(`Invalid URL: ${D}`)}if(Y.protocol==="http:")Y.protocol="ws:";else if(Y.protocol==="https:")Y.protocol="wss:";$._url=Y.href;let Z=Y.protocol==="wss:",F=Y.protocol==="ws+unix:",G;if(Y.protocol!=="ws:"&&!Z&&!F)G=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(F&&!Y.pathname)G="The URL's pathname is empty";else if(Y.hash)G="The URL contains a fragment identifier";if(G){let O=SyntaxError(G);if($._redirects===0)throw O;else{HM($,O);return}}let U=Z?443:80,W=FX1(16).toString("base64"),q=Z?JX1.request:YX1.request,K=new Set,H;if(J.createConnection=J.createConnection||(Z?EX1:RX1),J.defaultPort=J.defaultPort||U,J.port=Y.port||U,J.host=Y.hostname.startsWith("[")?Y.hostname.slice(1,-1):Y.hostname,J.headers={...J.headers,"Sec-WebSocket-Version":J.protocolVersion,"Sec-WebSocket-Key":W,Connection:"Upgrade",Upgrade:"websocket"},J.path=Y.pathname+Y.search,J.timeout=J.handshakeTimeout,J.perMessageDeflate)H=new R5({...J.perMessageDeflate,isServer:!1,maxPayload:J.maxPayload}),J.headers["Sec-WebSocket-Extensions"]=MX1({[R5.extensionName]:H.offer()});if(Q.length){for(let O of Q){if(typeof O!=="string"||!BX1.test(O)||K.has(O))throw SyntaxError("An invalid or duplicated subprotocol was specified");K.add(O)}J.headers["Sec-WebSocket-Protocol"]=Q.join(",")}if(J.origin)if(J.protocolVersion<13)J.headers["Sec-WebSocket-Origin"]=J.origin;else J.headers.Origin=J.origin;if(Y.username||Y.password)J.auth=`${Y.username}:${Y.password}`;if(F){let O=J.path.split(":");J.socketPath=O[0],J.path=O[1]}let V;if(J.followRedirects){if($._redirects===0){$._originalIpc=F,$._originalSecure=Z,$._originalHostOrSocketPath=F?J.socketPath:Y.host;let O=X&&X.headers;if(X={...X,headers:{}},O)for(let[z,N]of Object.entries(O))X.headers[z.toLowerCase()]=N}else if($.listenerCount("redirect")===0){let O=F?$._originalIpc?J.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:Y.host===$._originalHostOrSocketPath;if(!O||$._originalSecure&&!Z){if(delete J.headers.authorization,delete J.headers.cookie,!O)delete J.headers.host;J.auth=void 0}}if(J.auth&&!X.headers.authorization)X.headers.authorization="Basic "+Buffer.from(J.auth).toString("base64");if(V=$._req=q(J),$._redirects)$.emit("redirect",$.url,V)}else V=$._req=q(J);if(J.timeout)V.on("timeout",()=>{W4($,V,"Opening handshake has timed out")});if(V.on("error",(O)=>{if(V===null||V[wG0])return;V=$._req=null,HM($,O)}),V.on("response",(O)=>{let z=O.headers.location,N=O.statusCode;if(z&&J.followRedirects&&N>=300&&N<400){if(++$._redirects>J.maxRedirects){W4($,V,"Maximum redirects exceeded");return}V.abort();let B;try{B=new a_(z,D)}catch(L){let M=SyntaxError(`Invalid URL: ${z}`);HM($,M);return}BG0($,B,Q,X)}else if(!$.emit("unexpected-response",V,O))W4($,V,`Unexpected server response: ${O.statusCode}`)}),V.on("upgrade",(O,z,N)=>{if($.emit("upgrade",O),$.readyState!==z1.CONNECTING)return;V=$._req=null;let B=O.headers.upgrade;if(B===void 0||B.toLowerCase()!=="websocket"){W4($,z,"Invalid Upgrade header");return}let L=GX1("sha1").update(W+HX1).digest("base64");if(O.headers["sec-websocket-accept"]!==L){W4($,z,"Invalid Sec-WebSocket-Accept header");return}let M=O.headers["sec-websocket-protocol"],w;if(M!==void 0){if(!K.size)w="Server sent a subprotocol but none was requested";else if(!K.has(M))w="Server sent an invalid subprotocol"}else if(K.size)w="Server sent no subprotocol";if(w){W4($,z,w);return}if(M)$._protocol=M;let R=O.headers["sec-websocket-extensions"];if(R!==void 0){if(!H){W4($,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let x;try{x=NX1(R)}catch(j){W4($,z,"Invalid Sec-WebSocket-Extensions header");return}let _=Object.keys(x);if(_.length!==1||_[0]!==R5.extensionName){W4($,z,"Server indicated an extension that was not requested");return}try{H.accept(x[R5.extensionName])}catch(j){W4($,z,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[R5.extensionName]=H}$.setSocket(z,N,{allowSynchronousEvents:J.allowSynchronousEvents,generateMask:J.generateMask,maxBufferedChunks:J.maxBufferedChunks,maxFragments:J.maxFragments,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation})}),J.finishRequest)J.finishRequest(V,$);else V.end()}function HM($,D){$._readyState=z1.CLOSING,$._errorEmitted=!0,$.emit("error",D),$.emitClose()}function RX1($){return $.path=$.socketPath,MG0.connect($)}function EX1($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=MG0.isIP($.host)?"":$.host;return ZX1.connect($)}function W4($,D,Q){$._readyState=z1.CLOSING;let X=Error(Q);if(Error.captureStackTrace(X,W4),D.setHeader){if(D[wG0]=!0,D.abort(),D.socket&&!D.socket.destroyed)D.socket.destroy();process.nextTick(HM,$,X)}else D.destroy(X),D.once("error",$.emit.bind($,"error")),D.once("close",$.emitClose.bind($))}function $v($,D,Q){if(D){let X=qX1(D)?D.size:wX1(D).length;if($._socket)$._sender._bufferedBytes+=X;else $._bufferedAmount+=X}if(Q){let X=Error(`WebSocket is not open: readyState ${$.readyState} (${Y7[$.readyState]})`);process.nextTick(Q,X)}}function jX1($,D){let Q=this[ID];if(Q._closeFrameReceived=!0,Q._closeMessage=D,Q._closeCode=$,Q._socket[ID]===void 0)return;if(Q._socket.removeListener("data",VM),process.nextTick(RG0,Q._socket),$===1005)Q.close();else Q.close($,D)}function AX1(){let $=this[ID];if(!$.isPaused)$._socket.resume()}function IX1($){let D=this[ID];if(D._socket[ID]!==void 0)D._socket.removeListener("data",VM),process.nextTick(RG0,D._socket),D.close($[OX1]);if(!D._errorEmitted)D._errorEmitted=!0,D.emit("error",$)}function LG0(){this[ID].emitClose()}function TX1($,D){this[ID].emit("message",$,D)}function CX1($){let D=this[ID];if(D._autoPong)D.pong($,!this._isServer,NG0);D.emit("ping",$)}function PX1($){this[ID].emit("pong",$)}function RG0($){$.resume()}function SX1($){let D=this[ID];if(D.readyState===z1.CLOSED)return;if(D.readyState===z1.OPEN)D._readyState=z1.CLOSING,EG0(D);if(this._socket.end(),!D._errorEmitted)D._errorEmitted=!0,D.emit("error",$)}function EG0($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function jG0(){let $=this[ID];if(this.removeListener("close",jG0),this.removeListener("data",VM),this.removeListener("end",AG0),$._readyState=z1.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let D=this.read(this._readableState.length);$._receiver.write(D)}if($._receiver.end(),this[ID]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",LG0),$._receiver.on("finish",LG0)}function VM($){if(!this[ID]._receiver.write($))this.pause()}function AG0(){let $=this[ID];$._readyState=z1.CLOSING,$._receiver.end(),this.end()}function IG0(){let $=this[ID];if(this.removeListener("error",IG0),this.on("error",NG0),$)$._readyState=z1.CLOSING,this.destroy()}});var xG0=E((at1,SG0)=>{var tt1=OM(),{Duplex:xX1}=Q0("stream");function CG0($){$.emit("close")}function _X1(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function PG0($){if(this.removeListener("error",PG0),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function vX1($,D){let Q=!0,X=new xX1({...D,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(Y,Z){let F=!Z&&X._readableState.objectMode?Y.toString():Y;if(!X.push(F))$.pause()}),$.once("error",function(Y){if(X.destroyed)return;Q=!1,X.destroy(Y)}),$.once("close",function(){if(X.destroyed)return;X.push(null)}),X._destroy=function(J,Y){if($.readyState===$.CLOSED){Y(J),process.nextTick(CG0,X);return}let Z=!1;if($.once("error",function(G){Z=!0,Y(G)}),$.once("close",function(){if(!Z)Y(J);process.nextTick(CG0,X)}),Q)$.terminate()},X._final=function(J){if($.readyState===$.CONNECTING){$.once("open",function(){X._final(J)});return}if($._socket===null)return;if($._socket._writableState.finished){if(J(),X._readableState.endEmitted)X.destroy()}else $._socket.once("finish",function(){J()}),$.close()},X._read=function(){if($.isPaused)$.resume()},X._write=function(J,Y,Z){if($.readyState===$.CONNECTING){$.once("open",function(){X._write(J,Y,Z)});return}$.send(J,Z)},X.on("end",_X1),X.on("error",PG0),X}SG0.exports=vX1});var Dv=E((st1,_G0)=>{var{tokenChars:kX1}=VZ();function yX1($){let D=new Set,Q=-1,X=-1,J=0;for(J;J<$.length;J++){let Z=$.charCodeAt(J);if(X===-1&&kX1[Z]===1){if(Q===-1)Q=J}else if(J!==0&&(Z===32||Z===9)){if(X===-1&&Q!==-1)X=J}else if(Z===44){if(Q===-1)throw SyntaxError(`Unexpected character at index ${J}`);if(X===-1)X=J;let F=$.slice(Q,X);if(D.has(F))throw SyntaxError(`The "${F}" subprotocol is duplicated`);D.add(F),Q=X=-1}else throw SyntaxError(`Unexpected character at index ${J}`)}if(Q===-1||X!==-1)throw SyntaxError("Unexpected end of input");let Y=$.slice(Q,J);if(D.has(Y))throw SyntaxError(`The "${Y}" subprotocol is duplicated`);return D.add(Y),D}_G0.exports={parse:yX1}});var uG0=E(($a1,fG0)=>{var fX1=Q0("events"),zM=Q0("http"),{Duplex:et1}=Q0("stream"),{createHash:uX1}=Q0("crypto"),vG0=qM(),zX=HZ(),bX1=Dv(),hX1=OM(),{CLOSE_TIMEOUT:gX1,GUID:mX1,kWebSocket:dX1}=X7(),cX1=/^[+/0-9A-Za-z]{22}==$/;class yG0 extends fX1{constructor($,D){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:gX1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:hX1,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=zM.createServer((Q,X)=>{let J=zM.STATUS_CODES[426];X.writeHead(426,{"Content-Length":J.length,"Content-Type":"text/plain"}),X.end(J)}),this._server.listen($.port,$.host,$.backlog,D);else if($.server)this._server=$.server;if(this._server){let Q=this.emit.bind(this,"connection");this._removeListeners=lX1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(X,J,Y)=>{this.handleUpgrade(X,J,Y,Q)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(WW,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(WW,this);else this._shouldEmitClose=!0;else process.nextTick(WW,this)}else{let D=this._server;this._removeListeners(),this._removeListeners=this._server=null,D.close(()=>{WW(this)})}}shouldHandle($){if(this.options.path){let D=$.url.indexOf("?");if((D!==-1?$.url.slice(0,D):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,D,Q,X){D.on("error",kG0);let J=$.headers["sec-websocket-key"],Y=$.headers.upgrade,Z=+$.headers["sec-websocket-version"];if($.method!=="GET"){LX(this,$,D,405,"Invalid HTTP method");return}if(Y===void 0||Y.toLowerCase()!=="websocket"){LX(this,$,D,400,"Invalid Upgrade header");return}if(J===void 0||!cX1.test(J)){LX(this,$,D,400,"Missing or invalid Sec-WebSocket-Key header");return}if(Z!==13&&Z!==8){LX(this,$,D,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){qW(D,400);return}let F=$.headers["sec-websocket-protocol"],G=new Set;if(F!==void 0)try{G=bX1.parse(F)}catch(q){LX(this,$,D,400,"Invalid Sec-WebSocket-Protocol header");return}let U=$.headers["sec-websocket-extensions"],W={};if(this.options.perMessageDeflate&&U!==void 0){let q=new zX({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let K=vG0.parse(U);if(K[zX.extensionName])q.accept(K[zX.extensionName]),W[zX.extensionName]=q}catch(K){LX(this,$,D,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let q={origin:$.headers[`${Z===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(q,(K,H,V,O)=>{if(!K)return qW(D,H||401,V,O);this.completeUpgrade(W,J,G,$,D,Q,X)});return}if(!this.options.verifyClient(q))return qW(D,401)}this.completeUpgrade(W,J,G,$,D,Q,X)}completeUpgrade($,D,Q,X,J,Y,Z){if(!J.readable||!J.writable)return J.destroy();if(J[dX1])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return qW(J,503);let G=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${uX1("sha1").update(D+mX1).digest("base64")}`],U=new this.options.WebSocket(null,void 0,this.options);if(Q.size){let W=this.options.handleProtocols?this.options.handleProtocols(Q,X):Q.values().next().value;if(W)G.push(`Sec-WebSocket-Protocol: ${W}`),U._protocol=W}if($[zX.extensionName]){let W=$[zX.extensionName].params,q=vG0.format({[zX.extensionName]:[W]});G.push(`Sec-WebSocket-Extensions: ${q}`),U._extensions=$}if(this.emit("headers",G,X),J.write(G.concat(`\r
412
412
  `).join(`\r
413
413
  `)),J.removeListener("error",kG0),U.setSocket(J,Y,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(U),U.on("close",()=>{if(this.clients.delete(U),this._shouldEmitClose&&!this.clients.size)process.nextTick(WW,this)});Z(U,X)}}fG0.exports=yG0;function lX1($,D){for(let Q of Object.keys(D))$.on(Q,D[Q]);return function(){for(let X of Object.keys(D))$.removeListener(X,D[X])}}function WW($){$._state=2,$.emit("close")}function kG0(){this.destroy()}function qW($,D,Q,X){Q=Q||zM.STATUS_CODES[D],X={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(Q),...X},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${D} ${zM.STATUS_CODES[D]}\r
414
414
  `+Object.keys(X).map((J)=>`${J}: ${X[J]}`).join(`\r