zevairouter 1.0.83 → 1.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/cli/app/.next-cli-build/BUILD_ID +1 -1
- package/cli/app/.next-cli-build/app-path-routes-manifest.json +5 -5
- package/cli/app/.next-cli-build/build-manifest.json +2 -2
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/login/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/oidc/callback/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/oidc/start/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/oidc/test/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/auth/status/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/claude-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/codex-gateway/accounts/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/copilot-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/combos/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/combos/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/context/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/context/bulk/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/context/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/dashboard/chat/completions/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/extras/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/proxy/[...path]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/restart/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/start/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/status/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/headroom/stop/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/health/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/init/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/keys/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/keys/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/locale/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/mcp/[plugin]/message/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/mcp/[plugin]/sse/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/deepgram/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/elevenlabs/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/inworld/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/minimax/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/media-providers/tts/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/alias/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/availability/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/custom/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/disabled/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/test/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/models/test/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/antigravity/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/autoclaw/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/autoclaw/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/autoclaw/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/autoclaw/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/autoclaw/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/bulk-token/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy/quota-cookie/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/bulk-token/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codebuddy-cn/quota-cookie/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/codex/import-token/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/cursor/auto-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/cursor/import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/gitlab/pat/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/grok-cli/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/iflow/cookie/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/auto-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/social-authorize/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/kiro/social-exchange/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/cancel/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/manual/[workerId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/latest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pricing/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/provider-nodes/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/provider-nodes/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/provider-nodes/validate/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/test/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/[id]/test-models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/bulk-delete/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/client/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/kilo/free-models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/suggested-models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/test-batch/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/providers/validate/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/[id]/test/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/cloudflare-deploy/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/deno-deploy/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/proxy-pools/vercel-deploy/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/health/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/install/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/restart/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/start/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/stats/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/status/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/pxpipe/stop/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/settings/database/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/settings/proxy-test/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/settings/proxy-test/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/settings/require-login/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/settings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/shutdown/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tags/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/auth/setup/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/auth/status/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/auth/unlock/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/input/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/resize/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/[id]/stream/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/terminal/session/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/load/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/save/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/send/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/translator/translate/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/disable/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/enable/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/status/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-check/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-disable/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-enable/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/tunnel/tailscale-install/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/[connectionId]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/aggregate/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/chart/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/history/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/providers/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/request-details/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/request-logs/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/stats/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/usage/stream/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/api/chat/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/audio/speech/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/audio/transcriptions/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/audio/voices/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/embeddings/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/images/generations/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/messages/count_tokens/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/messages/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/models/[kind]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/models/info/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/responses/compact/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/responses/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/search/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1/web/fetch/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/v1beta/models/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/shutdown/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
- package/cli/app/.next-cli-build/server/app/api/version/update/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/callback.html +1 -1
- package/cli/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.html +1 -1
- package/cli/app/.next-cli-build/server/app/index.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/landing.html +1 -1
- package/cli/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app/login.html +1 -1
- package/cli/app/.next-cli-build/server/app/login.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
- package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
- package/cli/app/.next-cli-build/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/page.js.nft.json +1 -1
- package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/app-paths-manifest.json +5 -5
- package/cli/app/.next-cli-build/server/chunks/1396.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/2130.js +1 -0
- package/cli/app/.next-cli-build/server/chunks/3155.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3407.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/3487.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/4746.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/5000.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/6896.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/7774.js +2 -2
- package/cli/app/.next-cli-build/server/chunks/8157.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8371.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/8590.js +1 -1
- package/cli/app/.next-cli-build/server/chunks/891.js +1 -1
- package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/cli/app/.next-cli-build/server/pages/404.html +1 -1
- package/cli/app/.next-cli-build/server/pages/500.html +1 -1
- package/cli/app/.next-cli-build/static/chunks/{3702-790d0c6b750c193e.js → 3702-c33199d84eed99f9.js} +1 -1
- package/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/src/lib/terminal/ptyBridge.py +163 -0
- package/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/cli/app/src/lib/terminal/ptyBridge.py +163 -0
- package/cli/app/package.json +1 -1
- package/cli/package.json +1 -1
- package/package.json +1 -1
- package/src/lib/oauth/services/grokCliBulkImportManager.js +110 -59
- package/src/lib/oauth/services/grokXaiEmailAutomation.js +428 -34
- package/src/lib/oauth/services/kiroGoogleAutomation.js +629 -164
- package/src/lib/oauth/services/tempmailClient.js +146 -18
- /package/cli/app/.next-cli-build/static/{FlRjqQtzHVNvcFcCzVDTM → R1kyWZTqGzBl4VyH_Yizr}/_buildManifest.js +0 -0
- /package/cli/app/.next-cli-build/static/{FlRjqQtzHVNvcFcCzVDTM → R1kyWZTqGzBl4VyH_Yizr}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=8157,exports.ids=[1998,8157],exports.modules={20116:(a,b,c)=>{c.d(b,{q:()=>h,si:()=>g,uT:()=>i});var d=c(21820),e=c.n(d);function f(a){return Number.isFinite(a)?Math.max(0,Math.floor(a)):0}function g(){let a=[];try{a=e().cpus()||[]}catch{a=[]}let b=0,c=0;try{b=e().totalmem()}catch{b=0}try{c=e().freemem()}catch{c=0}let d=Array.isArray(a)?a.length:0,f=a[0]?.model?String(a[0].model).trim():null,g=b/0x40000000,h=c/0x40000000,i="unknown",j="unknown";try{i=e().platform()}catch{}try{j=e().arch()}catch{}return{cpuCount:d,cpuModel:f,totalMemBytes:b,totalMemGb:g,freeMemBytes:c,freeMemGb:h,platform:i,arch:j}}function h(){return function(a=null){let b=a||g(),{cpuCount:c,totalMemGb:d}=b,e=f(d/4),h=f(c/2),i="fallback",j=0;return e>0&&h>0?(j=Math.min(e,h),i=e<=h?"ram":"cpu"):e>0?(j=e,i="ram"):h>0?(j=h,i="cpu"):(j=4,i="fallback"),{recommended:Math.min(8,Math.max(1,j||4)),limitedBy:i,ramBudget:e,cpuBudget:h,minWorkers:1,maxWorkers:8,ramGbPerWorker:4,cpuDivisor:2,specs:b}}().recommended}function i(a){return!0===a||"string"==typeof a&&"auto"===a.trim().toLowerCase()}Object.freeze({RAM_GB_PER_WORKER:4,CPU_DIVISOR:2,SAFE_MIN_WORKERS:1,SAFE_MAX_WORKERS:8,FALLBACK_WORKERS:4})},47293:(a,b,c)=>{c.d(b,{A:()=>f});let d=new Uint8Array(16);var e=c(50122);let f=function(a,b,c){return b||a||!crypto.randomUUID?function(a,b,c){let f=(a=a||{}).random??a.rng?.()??crypto.getRandomValues(d);if(f.length<16)throw Error("Random bytes length must be >= 16");if(f[6]=15&f[6]|64,f[8]=63&f[8]|128,b){if((c=c||0)<0||c+16>b.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let a=0;a<16;++a)b[c+a]=f[a];return b}return(0,e.k)(f)}(a,b,c):crypto.randomUUID()}},50122:(a,b,c)=>{c.d(b,{k:()=>e});let d=[];for(let a=0;a<256;++a)d.push((a+256).toString(16).slice(1));function e(a,b=0){return(d[a[b+0]]+d[a[b+1]]+d[a[b+2]]+d[a[b+3]]+"-"+d[a[b+4]]+d[a[b+5]]+"-"+d[a[b+6]]+d[a[b+7]]+"-"+d[a[b+8]]+d[a[b+9]]+"-"+d[a[b+10]]+d[a[b+11]]+d[a[b+12]]+d[a[b+13]]+d[a[b+14]]+d[a[b+15]]).toLowerCase()}},53041:(a,b,c)=>{c.d(b,{$w:()=>C,KY:()=>S,Q6:()=>R,cO:()=>L,go:()=>O,hn:()=>E,kF:()=>s});var d=c(55511),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(49120),j=c(71998),k=c(20116),l=c(62409),m=c(82506),n=c(66307);let o=new Set(["success","failed","failed_invalid_credentials","failed_exchange","failed_timeout","failed_restricted","failed_browser_blocked","cancelled"]),p=h().join(i.DATA_DIR,"kiro-bulk-import"),q=h().join(p,"meta.json"),r=new Set(["queued","running","needs_manual"]);function s(){return new Date().toISOString()}function t(a=p){f().mkdirSync(a,{recursive:!0})}function u(a,b=p){return t(b),h().join(b,`${a}.json`)}function v(a){try{if(!f().existsSync(a))return null;return JSON.parse(f().readFileSync(a,"utf8"))}catch{return null}}function w(a,b){t(h().dirname(a));let c=`${a}.${process.pid}.tmp`;f().writeFileSync(c,JSON.stringify(b,null,2),"utf8"),f().renameSync(c,a)}function x(a,b=p){return t(b),h().join(b,`${a}.resume.enc`)}function y(){return(0,d.createHash)("sha256").update(String(function(){if(process.env.BULK_IMPORT_RESUME_SECRET)return process.env.BULK_IMPORT_RESUME_SECRET;let a=h().join(i.DATA_DIR,"bulk-import-resume-key");try{return f().readFileSync(a,"utf8").trim()}catch{}try{t(i.DATA_DIR);let b=(0,d.randomBytes)(32).toString("hex");return f().writeFileSync(a,b,{mode:384}),b}catch{return(0,d.randomBytes)(32).toString("hex")}}())).digest()}function z(a){try{f().existsSync(a)&&f().rmSync(a)}catch{}}function A(a=q){return v(a)?.latestJobId||null}function B(a){if((0,k.uT)(a))return Math.min(8,Math.max(1,(0,k.q)()));let b=Number.parseInt(a,10);return Number.isFinite(b)?Math.min(8,Math.max(1,b)):4}function C(a=[]){let b=Array.isArray(a)?a:[],c=[],d=[];return b.forEach((a,b)=>{let e=String(a||"").trim();if(!e||e.startsWith("#"))return;let f="",g="";if(e.includes("|")){let[a="",...b]=e.split("|");f=a.trim(),g=b.join("|").trim()}else if(e.includes(" ")){let a=e.indexOf(" ");f=e.substring(0,a).trim(),g=e.substring(a+1).trim()}else if(e.includes(":")){let a=e.indexOf(":"),b=e.substring(0,a).trim();b.includes("@")&&(f=b,g=e.substring(a+1).trim())}f&&g?c.push({line:b+1,email:f,password:g}):d.push(b+1)}),{parsed:c,invalidLines:d}}function D(a){return{total:a.length,queued:a.filter(a=>"queued"===a.status).length,running:a.filter(a=>"running"===a.status).length,success:a.filter(a=>"success"===a.status).length,failed:a.filter(a=>"failed"===a.status||"failed_invalid_credentials"===a.status||"failed_exchange"===a.status||"failed_timeout"===a.status||"failed_restricted"===a.status||"failed_browser_blocked"===a.status).length,needs_manual:a.filter(a=>"needs_manual"===a.status).length}}function E(a,b,c="info"){return{id:(0,d.randomUUID)(),at:s(),step:a,message:b,level:c}}function F(a,b,c,d="info"){let e=E(b,c,d);return a.currentStep=b,a.updatedAt=e.at,a.logs=a.logs||[],a.logs.push(e),a.logs.length>40&&a.logs.splice(0,a.logs.length-40),e}function G(a){return a.flatMap(a=>(a.logs||[]).map(b=>({...b,email:a.email,line:a.line,workerId:a.workerId||null,status:a.status}))).sort((a,b)=>String(a.at).localeCompare(String(b.at))).slice(-80)}function H(a){if(!a)return null;try{let b=new URL(a);return(b.username||b.password)&&(b.username="***",b.password="***"),b.toString()}catch{return a.length>20?`${a.slice(0,10)}***${a.slice(-10)}`:a}}function I(a){return{email:a.email,status:a.status,error:a.error||null,connectionId:a.connectionId||null,workerId:a.workerId||null,line:a.line,proxyUrl:H(a.proxyUrl)||null,currentStep:a.currentStep||null,updatedAt:a.updatedAt||null,logs:(a.logs||[]).slice(-20),manualSessionAvailable:!!a.manualSession?.page&&"needs_manual"===a.status,manualSessionOpened:!!a.manualSession?.opened}}function J(a,b={}){return{jobId:a.jobId,status:a.status,summary:D(a.accounts),concurrency:a.concurrency,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,accounts:a.accounts.map(I),activity:G(a.accounts),error:a.error||null,preview:b.preview||null}}function K(a){if(!a||r.has(a.status))return!1;let b=a.finishedAt?Date.parse(a.finishedAt):NaN;return!!Number.isFinite(b)&&Date.now()-b<=18e5}function L(a,b={}){return a?{found:!0,stale:!1,recoverable:r.has(a.status)||K(a),job:a}:{found:!1,stale:!!b.stale,recoverable:!1,job:null}}async function M(a){let b,{launchBulkImportBrowser:d}=await c.e(5949).then(c.bind(c,75949)),e=a?.engine||"chromium",f=process.env.ZEVAI_KIRO_HEADLESS;return b="1"===f||"true"===f||"0"!==f&&"false"!==f&&"camoufox"===e,d({engine:e,headless:b,windowSize:{width:1280,height:900}})}async function N(a){let{exchangeAndSaveKiroSocialConnection:b}=await c.e(4136).then(c.bind(c,34136));return b(a)}async function O(a,b){let d=b,e=null;if(b)try{let{ensureSocksHttpBridge:a,isSocksProxyUrl:f}=await Promise.all([c.e(3092),c.e(6652)]).then(c.bind(c,76652));f(b)&&(e=await a(b),e?.httpProxyUrl&&(d=e.httpProxyUrl))}catch(a){console.warn("[bulk-import] SOCKS bridge unavailable:",a?.message||a)}let f=(0,n.parsePlaywrightProxy)(d),g=f?{proxy:f}:{},h="";try{h=a.browserType().name()}catch{}"firefox"===h?g.viewport=null:g.viewport||(g.viewport={width:900,height:700}),g.ignoreHTTPSErrors=!0;let i=await a.newContext(g);if(e){let a=i.close.bind(i);i.close=async(...b)=>{try{return await a(...b)}finally{await e.release().catch(()=>null)}}}let j=await i.newPage();try{await j.route(/facebook\.net|hotjar|clarity\.ms|hm\.baidu|sentry\.io|browser\.sentry-cdn|doubleclick\.net/i,a=>a.abort())}catch{}return{context:i,page:j}}async function P(a){let b,d;if(!a?.manualSession?.context)return!1;let e=a.manualSession.context,f=a.manualSession.page,g=e.browser?.(),h=null,i="";try{h=await e.storageState()}catch{h=null}try{i=f?.url?.()||""}catch{i=""}let{chromium:j}=await Promise.resolve().then(c.bind(c,83237));try{b=await j.launch({headless:!1,args:["--start-maximized"]})}catch{return!1}try{d=await b.newContext({viewport:null,...h?{storageState:h}:{}})}catch{return await b.close().catch(()=>null),!1}let k=await d.newPage();if(i)try{await k.goto(i,{waitUntil:"domcontentloaded",timeout:2e4})}catch{}let l=a.manualSession.rebind;if(a.manualSession.context=d,a.manualSession.page=k,a.manualSession.headedBrowser=b,"function"==typeof l)try{await l({context:d,page:k})}catch{}return e.close().catch(()=>null),g&&g!==b&&g.close().catch(()=>null),!0}async function Q(a,{account:b}={}){if(!a)return!1;try{let c=a.context?.(),d=c?.browser?.();if(b&&function(a){if(!a)return!0;let b=a._options||a._initializer||{};return"boolean"!=typeof b.headless||b.headless}(d)&&await P(b))return await b.manualSession.page.bringToFront?.().catch(()=>null),!0;if(!c?.newCDPSession)return await a.bringToFront?.().catch(()=>null),!0;let e=await c.newCDPSession(a),f=null;try{let a=await e.send("Target.getTargetInfo"),b=a?.targetInfo?.targetId,c=await e.send("Browser.getWindowForTarget",b?{targetId:b}:{});f=c?.windowId??null}catch{f=null}return null!=f&&await e.send("Browser.setWindowBounds",{windowId:f,bounds:{windowState:"normal",left:80,top:80,width:1280,height:960}}).catch(()=>null),await a.bringToFront?.().catch(()=>null),await e.detach?.().catch(()=>null),!0}catch{return await a.bringToFront?.().catch(()=>null),!0}}class R{constructor({browserLauncher:a=M,googleAutomation:b=m.Th,socialExchange:c=N,kiroServiceFactory:d=()=>new l.v,storageName:e="kiro-bulk-import"}={}){this.browserLauncher=a,this.googleAutomation=b,this.socialExchange=c,this.kiroServiceFactory=d,this.storageDir=h().join(i.DATA_DIR,e),this.metaFile=h().join(this.storageDir,"meta.json"),this.jobs=new Map,this.latestJobId=A(this.metaFile)}persistResumeBlob(a){try{!function(a,b){try{let c,e,g,i,j;t(h().dirname(a));let k=`${a}.${process.pid}.tmp`;f().writeFileSync(k,JSON.stringify((c=(0,d.randomBytes)(12),e=(0,d.createCipheriv)("aes-256-gcm",y(),c),g=Buffer.from(JSON.stringify(b),"utf8"),i=Buffer.concat([e.update(g),e.final()]),j=e.getAuthTag(),{v:1,alg:"aes-256-gcm",iv:c.toString("base64"),tag:j.toString("base64"),data:i.toString("base64")})),{mode:384}),f().renameSync(k,a)}catch{}}(x(a.jobId,this.storageDir),{jobId:a.jobId,concurrency:a.concurrency,engine:a.engine,proxyPoolMode:a.proxyPoolMode,proxyUrls:a.proxyUrls||[],createdAt:a.createdAt,accounts:a.accounts.map(a=>({line:a.line,email:a.email,password:a.password}))})}catch{}}hydrateInterruptedJob(a){if(!a||this.jobs.has(a))return!1;let b=v(u(a,this.storageDir));if(!b||!r.has(b.status))return!1;let c=function(a){let b=v(a);if(!b)return null;if(!b||"aes-256-gcm"!==b.alg||!b.iv||!b.tag||!b.data)return null;try{let a=(0,d.createDecipheriv)("aes-256-gcm",y(),Buffer.from(b.iv,"base64"));a.setAuthTag(Buffer.from(b.tag,"base64"));let c=Buffer.concat([a.update(Buffer.from(b.data,"base64")),a.final()]);return JSON.parse(c.toString("utf8"))}catch{return null}}(x(a,this.storageDir));if(!c||!Array.isArray(c.accounts)||0===c.accounts.length)return this.markJobInterrupted(a,b),!1;let e=new Map(c.accounts.map(a=>[a.line,a.password])),f=new Map(c.accounts.map(a=>[a.line,a.email])),g=b.createdAt||c.createdAt||s(),h=(b.accounts||[]).map(a=>{let b=o.has(a.status),c=Array.isArray(a.logs)?[...a.logs]:[],d={line:a.line,email:a.email||f.get(a.line)||"",password:b?void 0:e.get(a.line)??null,proxyUrl:null,status:a.status,error:a.error||null,connectionId:a.connectionId||null,workerId:b&&a.workerId||null,manualSession:null,runtimeSession:null,currentStep:a.currentStep||null,updatedAt:a.updatedAt||g,logs:c};return b||(d.status="queued",d.currentStep="queued",d.error=null,d.logs.push(E("resumed","Re-queued after a server restart to continue automatically"))),d}),i={jobId:a,status:"running",concurrency:B(c.concurrency),engine:c.engine||"chromium",proxyPoolMode:c.proxyPoolMode||"none",proxyUrls:Array.isArray(c.proxyUrls)?c.proxyUrls:[],createdAt:g,startedAt:b.startedAt||g,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:b.preview||null,lastPreviewCapturedAt:0,accounts:h};return(this.jobs.set(a,i),this.latestJobId||(this.latestJobId=a),h.some(a=>"queued"===a.status))?this.runJob(a):(i.status="completed",i.finishedAt=s(),this.persistJobSnapshot(i,{forcePreview:!1}),z(x(a,this.storageDir))),!0}markJobInterrupted(a,b){let c="Job was interrupted by a server restart and could not be auto-resumed (saved credentials were unavailable). Please start a new bulk login.",d=(b.accounts||[]).map(a=>{if(o.has(a.status))return a;let b=Array.isArray(a.logs)?[...a.logs]:[];return b.push(E("failed",c,"error")),{...a,status:"failed",error:c,currentStep:"failed",updatedAt:s(),manualSessionAvailable:!1,logs:b}}),e={...b,status:"failed",error:b.error||c,finishedAt:b.finishedAt||s(),accounts:d,summary:D(d),activity:G(d)};try{w(u(a,this.storageDir),e)}catch{}z(x(a,this.storageDir))}async startJob({accounts:a,concurrency:b,engine:e,proxyPoolMode:f,proxyPoolId:g}){let{parsed:h,invalidLines:i}=C(a);if(!h.length){let a=i.length>0?"Invalid account format. Use one account per line: gmail@example.com|password":"At least one account entry is required",b={error:a};throw i.length>0&&(b.invalidLines=i),Object.assign(Error(a),b)}if(i.length>0){let a="Invalid account format. Use one account per line: gmail@example.com|password";throw Object.assign(Error(a),{error:a,invalidLines:i})}let k=[];if("all"===f)k=(await (0,j.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===f&&g){let a=await (0,j.hr)(g);a?.isActive&&a?.proxyUrl&&(k=[a.proxyUrl])}let l=(0,d.randomUUID)(),m=s(),{normalizeBulkImportEngine:n,DEFAULT_BULK_IMPORT_ENGINE:o}=await c.e(5949).then(c.bind(c,75949)),p=e?n(e):o,r={jobId:l,status:"running",concurrency:B(b),engine:p,proxyPoolMode:f||"none",proxyUrls:k,createdAt:m,startedAt:m,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:h.map(a=>({line:a.line,email:a.email,password:a.password,proxyUrl:null,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:m,logs:[E("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(l,r),this.latestJobId=l,!function(a,b=q){w(b,{latestJobId:a||null,updatedAt:s()})}(l,this.metaFile),await this.persistJobSnapshot(r,{forcePreview:!1}),this.persistResumeBlob(r),this.runJob(l),J(r)}getJob(a){this.hydrateInterruptedJob(a);let b=this.jobs.get(a);return b?J(b,{preview:b.lastPreview||null}):v(u(a,this.storageDir))}async getJobWithPreview(a){this.hydrateInterruptedJob(a);let b=this.jobs.get(a);if(!b)return v(u(a,this.storageDir));let c=await this.capturePreview(b);return b.lastPreview=c||b.lastPreview||null,await this.persistJobSnapshot(b,{forcePreview:!1}),J(b,{preview:b.lastPreview||null})}async getLatestJobWithPreview({includeRecentTerminal:a=!1}={}){let b=this.latestJobId||A(this.metaFile);if(!b)return null;let c=await this.getJobWithPreview(b);return c&&(r.has(c.status)||a&&K(c))?c:null}cancelJob(a){let b=this.jobs.get(a);if(!b)return v(u(a,this.storageDir));for(let a of(b.cancelRequested=!0,b.accounts||[]))if("queued"===a.status||"running"===a.status||"needs_manual"===a.status){let b=a.manualSession,c=a.runtimeSession,d=b?.context||c?.context||null,e=b?.headedBrowser||null;d&&d.close().catch(()=>null),e&&e.close().catch(()=>null),a.manualSession=null,a.runtimeSession=null,this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled by user"})}if(b.browser){let a=b.browser;b.browser=null,c.e(5949).then(c.bind(c,75949)).then(({forceCloseBrowser:b})=>b(a)).catch(()=>a.close().catch(()=>null))}return("queued"===b.status||"running"===b.status)&&(b.status="cancelled",b.finishedAt=b.finishedAt||s()),this.persistJobSnapshot(b,{forcePreview:!0}),J(b)}async openManualSession(a,b){let c=this.jobs.get(a);if(!c)return null;let d=Number.parseInt(b,10),e=c.accounts.find(a=>a.workerId===d&&"needs_manual"===a.status&&a.manualSession?.page);if(!e)return{ok:!1,error:"Manual session not found for this worker",job:J(c)};let f=await Q(e.manualSession.page,{account:e});return e.manualSession.opened=f,e.manualSession.openedAt=f?e.manualSession.openedAt||s():e.manualSession.openedAt||null,await this.persistJobSnapshot(c,{forcePreview:!0}),{ok:!0,job:J(c),account:I(e)}}dequeueAccount(a,b){for(;a.nextIndex<a.accounts.length;){let c=a.accounts[a.nextIndex];if(a.nextIndex+=1,"queued"===c.status)return c.status="running",c.workerId=b,c.error=null,a.proxyUrls?.length&&(c.proxyUrl=a.proxyUrls[(a.nextIndex-1)%a.proxyUrls.length]),F(c,"worker_assigned",`Worker ${b} picked up this account${c.proxyUrl?` (proxy: ${H(c.proxyUrl)})`:""}`),this.persistJobSnapshot(a,{forcePreview:!1}),c}return null}finalizeAccount(a,b,c={}){return a.status=b,a.error=c.error||null,a.connectionId=c.connectionId||null,(c.step||c.message)&&F(a,c.step||b,c.message||c.error||b.replaceAll("_"," ")),a}setAccountStep(a,b,c,d="info"){F(a,b,c,d)}async persistJobSnapshot(a,{forcePreview:b=!1}={}){if(!a)return;let c=async()=>{if(b||Date.now()-(a.lastPreviewCapturedAt||0)>=1500){let b=await this.capturePreview(a);b&&(a.lastPreview=b),a.lastPreviewCapturedAt=Date.now()}w(u(a.jobId,this.storageDir),J(a,{preview:a.lastPreview||null}))};a.persistPromise=Promise.resolve(a.persistPromise).catch(()=>null).then(c),await a.persistPromise}async capturePreview(a){let b=a.accounts.find(a=>"running"===a.status&&a.runtimeSession?.page)||a.accounts.find(a=>"needs_manual"===a.status&&a.manualSession?.page);if(!b)return null;let c=b.runtimeSession?.page||b.manualSession?.page;if(!c)return null;try{let a=await c.screenshot({type:"jpeg",quality:55,fullPage:!1,animations:"disabled",caret:"hide"});return{email:b.email||null,phone:b.phone||null,workerId:b.workerId||null,status:b.status,step:b.currentStep||null,updatedAt:b.updatedAt||s(),imageData:`data:image/jpeg;base64,${a.toString("base64")}`}}catch{return{email:b.email||null,phone:b.phone||null,workerId:b.workerId||null,status:b.status,step:b.currentStep||null,updatedAt:b.updatedAt||s(),imageData:null}}}async runManualFollowup(a,b,c,d,e,f){let g=(async()=>{let c=async()=>{let a=b.manualSession,c=a?.context||d,e=a?.headedBrowser||null;c&&await c.close().catch(()=>null),e&&await e.close().catch(()=>null)};try{let c=await e;if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}this.setAccountStep(b,"exchanging_tokens","Exchanging Kiro callback for OAuth tokens"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:d}=await this.socialExchange({code:c.code,codeVerifier:f,provider:"google"});this.finalizeAccount(b,"success",{connectionId:d.id,step:"connection_saved",message:"Kiro connection saved successfully"}),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){a.cancelRequested?this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}):this.finalizeAccount(b,"failed_exchange",{error:c.message||"Manual assist flow failed during token exchange.",step:"exchange_failed",message:c.message||"Manual assist flow failed during token exchange."}),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{await c(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(g),await this.persistJobSnapshot(a,{forcePreview:!0})}})();a.manualFollowups.add(g)}async processAccount(a,b,c){if(a.cancelRequested||!a.browser)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});let d=this.kiroServiceFactory().createSocialAuthorization("google"),{context:e,page:f}=await O(a.browser,b.proxyUrl),g=(0,m.zZ)(e,f);b.runtimeSession={context:e,page:f};try{this.setAccountStep(b,"preparing_worker",`Worker ${c} is preparing a browser context`),await this.persistJobSnapshot(a,{forcePreview:!0});let h=await this.googleAutomation({page:f,authUrl:d.authUrl,email:b.email,password:b.password,callbackPromise:g,onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})}});if("success"===h.status){this.setAccountStep(b,"exchanging_tokens","Exchanging Kiro callback for OAuth tokens"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:c}=await this.socialExchange({code:h.code,codeVerifier:d.codeVerifier,provider:"google"});this.finalizeAccount(b,"success",{connectionId:c.id,step:"connection_saved",message:"Kiro connection saved successfully"}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0});return}if("needs_manual"===h.status){b.manualSession={context:e,page:f,opened:!1,openedAt:null,rebind:"function"==typeof g?.rebind?g.rebind:null},this.setAccountStep(b,"awaiting_manual","Waiting for manual completion in the browser session"),this.finalizeAccount(b,"needs_manual",{error:h.error,step:"awaiting_manual",message:h.error}),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runManualFollowup(a,b,c,e,g,d.codeVerifier);return}let i=o.has(h.status)?h.status:"failed";this.finalizeAccount(b,i,{error:h.error||"Kiro Google automation failed.",step:i,message:h.error||"Kiro Google automation failed."}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){this.finalizeAccount(b,"failed",{error:c.message||"Unexpected Kiro bulk import failure.",step:"failed",message:c.message||"Unexpected Kiro bulk import failure."}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{b.password=void 0}}async runWorker(a,b){for(;!a.cancelRequested;){let c=this.dequeueAccount(a,b);if(!c)return;await this.processAccount(a,c,b)}}async runJob(a){let b=this.jobs.get(a);if(b)try{b.browser=await this.browserLauncher(b),b.accounts.forEach(a=>{"queued"===a.status&&1===(a.logs||[]).length&&this.setAccountStep(a,"waiting_for_worker","Waiting for a free worker")}),await this.persistJobSnapshot(b,{forcePreview:!1});let a=Math.min(b.concurrency,Math.max(b.accounts.length,1)),c=Array.from({length:a},(a,c)=>this.runWorker(b,c+1));await Promise.allSettled(c),b.manualFollowups.size>0&&await Promise.allSettled([...b.manualFollowups]),b.cancelRequested?(b.status="cancelled",b.accounts.forEach(a=>{("queued"===a.status||"running"===a.status||"needs_manual"===a.status)&&this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled before completion"})})):b.status="completed",await this.persistJobSnapshot(b,{forcePreview:!0})}catch(a){b.status="failed",b.error=a.message||"Failed to start Kiro bulk import job.",b.accounts.forEach(a=>{("queued"===a.status||"running"===a.status)&&(this.finalizeAccount(a,"failed",{error:b.error,step:"failed",message:b.error}),a.password=void 0)}),await this.persistJobSnapshot(b,{forcePreview:!0})}finally{if(b.browser){let a=b.browser;b.browser=null;try{let{forceCloseBrowser:b}=await c.e(5949).then(c.bind(c,75949));await b(a)}catch{await a.close().catch(()=>null)}}b.finishedAt=s(),await this.persistJobSnapshot(b,{forcePreview:!0}),z(x(b.jobId,this.storageDir))}}}function S(){return(!globalThis.__kiroBulkImportSingleton&&(globalThis.__kiroBulkImportSingleton={manager:new R}),globalThis.__kiroBulkImportSingleton).manager}},66307:(a,b,c)=>{c.d(b,{parsePlaywrightProxy:()=>d});function d(a){if(!a)return null;let b=String(a).trim();if(!b)return null;try{let a=new URL(b),c=(a.protocol||"http:").replace(/:$/,"")||"http",d={server:`${c}://${a.hostname}${a.port?`:${a.port}`:""}`};return a.username&&(d.username=decodeURIComponent(a.username)),a.password&&(d.password=decodeURIComponent(a.password)),d}catch{return{server:b}}}},71998:(a,b,c)=>{c.d(b,{Fh:()=>d.Fh,L9:()=>d.L9,Mc:()=>d.Mc,OM:()=>d.OM,Pc:()=>d.Pc,Q_:()=>d.Q_,Qu:()=>d.Qu,S8:()=>d.S8,Yd:()=>d.Yd,ZO:()=>d.ZO,c:()=>d.c,createProviderConnection:()=>d.iE,fK:()=>d.fK,fv:()=>d.fv,getProviderConnections:()=>d.getProviderConnections,ho:()=>d.ho,hr:()=>d.hr,i0:()=>d.i0,o5:()=>d.o5,op:()=>d.op,rj:()=>d.updateProviderConnection,uL:()=>d.uL,ui:()=>d.ui,uv:()=>d.uv});var d=c(89718)},82506:(a,b,c)=>{c.d(b,{$K:()=>T,Jl:()=>H,PB:()=>W,Th:()=>Y,i_:()=>S,np:()=>R,rk:()=>X,zZ:()=>V});let d='input[type="email"], input[autocomplete="username"], input#identifierId, input[name="identifier"], input[name="Email"], input[type="text"][autofocus], input[aria-label*="Email" i], input[aria-label*="email" i], input[aria-label*="phone" i], input[aria-label*="telepon" i]',e=['button:has-text("Next")','button:has-text("Berikutnya")','button:has-text("Continue")','div[role="button"]:has-text("Next")','div[role="button"]:has-text("Berikutnya")',"#identifierNext button","#passwordNext button"],f=["#submit_approve_access","#submit_approve_access button","#confirm",'form#tos_form input[type="submit"]','button[jsname]:has-text("Allow")','button:has-text("Allow")','[role="button"]:has-text("Allow")','input[type="submit"][value="Allow"]','input[type="button"][value="Allow"]','button[jsname]:has-text("Izinkan")','button:has-text("Izinkan")','[role="button"]:has-text("Izinkan")','button:has-text("Continue")','button:has-text("Next")','button:has-text("Yes")','button:has-text("Accept")','button:has-text("Lanjutkan")','button:has-text("Berikutnya")','button:has-text("Setuju")','button:has-text("Saya mengerti")','button:has-text("Oke")','button:has-text("OK")','button:has-text("Got it")','button:has-text("I understand")','div[role="button"]:has-text("Continue")','div[role="button"]:has-text("Next")','div[role="button"]:has-text("Allow")','div[role="button"]:has-text("Lanjutkan")','div[role="button"]:has-text("Berikutnya")','div[role="button"]:has-text("Izinkan")','div[role="button"]:has-text("Setuju")','div[role="button"]:has-text("Saya mengerti")','div[role="button"]:has-text("Oke")','div[role="button"]:has-text("OK")','div[role="button"]:has-text("Got it")','div[role="button"]:has-text("I understand")','input[type="button"][value="Saya mengerti"]','input[type="submit"][value="Saya mengerti"]'],g=['button:has-text("Skip")','button:has-text("Lewati")','button:has-text("Not now")','button:has-text("Bukan sekarang")','button:has-text("No thanks")','button:has-text("Tidak sekarang")','div[role="button"]:has-text("Skip")','div[role="button"]:has-text("Not now")'],h=["#social-google","a#social-google",'a:has-text("Sign up with Google")','a:has-text("Log in with Google")','button:has-text("Sign up with Google")','button:has-text("Log in with Google")','button:has-text("Google")','a:has-text("Google")','div[role="button"]:has-text("Google")','span:has-text("Google")','[aria-label*="Google"]','[data-provider*="google" i]'],i=["#agree-policy-account","#agree-policy","#agree-policy-sso",'input[type="checkbox"][id*="agree" i]','input[type="checkbox"][name*="agree" i]','input[type="checkbox"][id*="policy" i]','input[type="checkbox"][name*="policy" i]','input[type="checkbox"][id*="terms" i]','input[type="checkbox"][name*="terms" i]','.login-checkbox input[type="checkbox"]','[class*="checkbox"] input[type="checkbox"]','[class*="agree"] input[type="checkbox"]','input[type="checkbox"]'],j=['.ui-dialog button:has-text("Confirm")','dialog button:has-text("Confirm")','button:has-text("Confirm")','button:has-text("I agree")','button:has-text("Agree")','button:has-text("同意")','button:has-text("确认")'],k=['button:has-text("Continue")','[role="button"]:has-text("Continue")','button:has-text("Get started")','button:has-text("GET STARTED")','input[type="submit"][value="GET STARTED"]','button:has-text("Start")','button:has-text("Confirm")','button:has-text("Done")','button:has-text("Next")','button:has-text("Skip")','button:has-text("Not now")','button:has-text("Save")','button:has-text("Create")','button:has-text("Enter")','button:has-text("Launch")','button:has-text("Use CodeBuddy")','button:has-text("Go to CodeBuddy")'],l=["select",'[role="combobox"]','.page-region [role="combobox"]',".page-region .t-select",'.page-region [class*="t-select"]','.page-region [class*="select"]',".page-region input[placeholder]",'button:has-text("Region")','[role="button"]:has-text("Region")','button:has-text("Select region")','[role="button"]:has-text("Select region")','button:has-text("Data region")','[aria-label*="region" i]','[placeholder*="region" i]'],m=["text=/^Indonesia$/i","text=/^ID$/i","text=/^Singapore$/i","text=/^SG$/i","text=/^Japan$/i","text=/^JP$/i","text=/^Thailand$/i","text=/^TH$/i","text=/^Global$/i","text=/^International$/i","text=/^United States$/i","text=/^US$/i","text=/^Asia Pacific$/i","text=/^Hong Kong$/i","text=/^Default$/i"],n=[{selector:'input[name*="workspace" i]',value:"Default"},{selector:'input[placeholder*="workspace" i]',value:"Default"},{selector:'input[name*="team" i]',value:"Default"},{selector:'input[placeholder*="team" i]',value:"Default"},{selector:'input[name*="name" i]',value:"Default"},{selector:'input[placeholder*="name" i]',value:"Default"}],o=["wrong password","incorrect password","couldn't find your google account","couldn’t find your google account","enter a valid email","couldn’t sign you in","couldn't sign you in","invalid email or password","password is incorrect"],p=["2-step verification","2-step verification required","verify it’s you","verify it's you","check your phone","confirm it’s you","confirm it's you","recovery email","recovery phone","suspicious sign-in prevented","unusual activity detected","captcha","i'm not a robot","im not a robot","not a robot","recaptcha","select all images","select all squares","try again later","browser or app may not be secure","try using a different browser","couldn’t sign you in","couldn't sign you in","this browser or app may not be secure"],q=["restricted","account has been restricted","account is restricted","account has been suspended","account is suspended","account has been disabled","account is disabled","account has been banned","account is banned","access denied","account blocked","your account has been","violation of terms","terms of service violation","temporarily locked","permanently locked","account locked","akun dibatasi","akun diblokir","akun ditangguhkan"],r=["welcome to your new google account","selamat datang di akun google baru anda","welcome to your new account","selamat datang di akun baru","privacy and terms","privasi dan persyaratan","personalize your google services","personalisasikan layanan google anda","add recovery phone","tambahkan nomor telepon pemulihan","choose your settings","pilih setelan anda"],s=["welcome to your new account","selamat datang di akun baru","your administrator decides which","administrator anda memutuskan layanan","your organisation administrator manages","your organization administrator manages"];function t(a){if(!a||!a.startsWith("kiro://kiro.kiroAgent/authenticate-success"))return null;let b=a.indexOf("?"),c=new URLSearchParams(b>=0?a.slice(b+1):""),d=c.get("code"),e=c.get("state");return d?{callbackUrl:a,code:d,state:e}:null}function u(a){let b="function"==typeof a.frames?a.frames():[];return[a,...b.filter(b=>b!==a.mainFrame?.())]}async function v(a,b){for(let c of u(a))for(let a of b){let b=c.locator(a).first();if(await b.count().catch(()=>0)&&await b.isVisible().catch(()=>!1))return await b.click({timeout:5e3}).catch(()=>null),!0}return!1}async function w(a,b){for(let c of u(a))for(let a of b){let b=c.locator(a).first();if(await b.count().catch(()=>0)){if((await b.scrollIntoViewIfNeeded().catch(()=>null),await b.isVisible().catch(()=>!1)&&await b.isEnabled().catch(()=>!0))&&await b.click({timeout:5e3}).then(()=>!0).catch(()=>!1))return!0}}return!1}async function x(a,b){for(let c of u(a))for(let a of b){let b=c.locator(a).first();if(!await b.count().catch(()=>0))continue;if(await b.isChecked().catch(()=>!1))return!0;let d=await b.isVisible().catch(()=>!1);if(d&&await b.check({force:!0,timeout:5e3}).then(()=>!0).catch(()=>!1)||d&&await b.click({force:!0,timeout:5e3}).then(()=>!0).catch(()=>!1)||await c.evaluate(a=>{let b=document.querySelector(a);return b instanceof HTMLInputElement&&(b.checked=!0,b.dispatchEvent(new Event("input",{bubbles:!0})),b.dispatchEvent(new Event("change",{bubbles:!0})),b.checked)},a).catch(()=>!1))return!0}return!1}async function y(a,b){for(let c of u(a)){let a=c.locator(b).first();if(await a.count().catch(()=>0)&&await a.isVisible().catch(()=>!1))return a}return null}async function z(a,b,{timeout:c=15e3,pollInterval:d=500}={}){let e=Date.now()+c;for(;Date.now()<e;){let c=await y(a,b);if(c)return c;let f=e-Date.now();if(f<=0)break;await new Promise(a=>setTimeout(a,Math.min(d,f)))}return null}async function A(a,b,{timeout:c=15e3}={}){if(!a||null==b)return!1;try{await a.click({timeout:5e3})}catch{}try{await a.fill("",{timeout:3e3})}catch{}try{let d=Math.floor(40+80*Math.random());await a.type(b,{delay:d,timeout:c})}catch{try{await a.fill(b,{timeout:c})}catch{return!1}}let d="";try{d=await a.inputValue()}catch{d=""}if(d===b)return!0;try{await a.click({timeout:5e3})}catch{}try{await a.fill("")}catch{}try{await a.type(b,{delay:50,timeout:c})}catch{return!1}try{d=await a.inputValue()}catch{d=""}return d===b}async function B(a){let b=[];for(let c of u(a))try{b.push(await c.evaluate(()=>document.body?.innerText||""))}catch{}return b.join("\n")}function C(a,b){let c=String(a||"").toLowerCase();return b.some(a=>c.includes(a))}function D(a){try{let b=new URL(a.url());return"accounts.google.com"===b.hostname||b.hostname.endsWith(".accounts.google.com")}catch{return!1}}async function E(a){return!!function(a){try{let b=new URL(a.url());if(b.pathname.startsWith("/not-supported")||b.pathname.includes("/signin/rejected")||b.pathname.includes("/rejected")||"about.google"===b.hostname||b.hostname.endsWith(".about.google"))return!0}catch{}return!1}(a)||C(await B(a).catch(()=>""),["browser or app may not be secure","try using a different browser","couldn't sign you in","couldn’t sign you in","this browser or app may not be secure","browser is not secure"])}function F(a){return!!(a&&a.__zevaiSettled)}async function G(a,b,{maxWaitMs:c=2e4,successPromise:d=null}={}){let e=Date.now(),f="";for(d&&"function"==typeof d.then&&(d.__zevaiSettledHooked||(d.__zevaiSettledHooked=!0,d.then(()=>{d.__zevaiSettled=!0},()=>{d.__zevaiSettled=!0})));Date.now()-e<c;){if(F(d))return b?.("waiting_google_redirect","OAuth callback already received — leaving interstitial wait"),!1;let c=a.url?.()||"",e=String(await B(a).catch(()=>"")).trim(),g=/\/accounts\/SetSID/i.test(c),h=/\/AccountChooser/i.test(c),i=e.length<30;if(!(g||i&&/accounts\.google\./i.test(c))&&!h)return!1;if(c!==f&&(b?.("waiting_google_redirect",`Waiting for Google redirect (url=${c.slice(0,120)} empty=${i})`),f=c),h&&await w(a,["div[data-identifier]","div[data-email]","li[data-identifier]",'div[role="link"]','div[role="button"]'])){b?.("selecting_google_account","Selected account from Google AccountChooser"),await a.waitForTimeout(1200);continue}let j=[a.waitForNavigation({waitUntil:"domcontentloaded",timeout:4e3}).catch(()=>null),a.waitForTimeout(1200)];d&&!F(d)&&j.push(d.then(()=>null).catch(()=>null)),await Promise.race(j)}return!0}function H(a){try{let b=new URL(a.url());return/codebuddy\.(ai|cn)$/.test(b.hostname)||b.hostname.endsWith(".codebuddy.ai")||b.hostname.endsWith(".codebuddy.cn")}catch{return!1}}async function I(a,b){if(!D(a))return!1;let c=await B(a);return!!/wants to access|ingin mengakses|akses ke akun google|allow/i.test(c)&&(await a.evaluate(()=>{let a=document.scrollingElement||document.documentElement||document.body;a&&(a.scrollTop=a.scrollHeight),window.scrollTo(0,document.body?.scrollHeight||document.documentElement?.scrollHeight||0)}).catch(()=>null),await a.waitForTimeout(300),!!await w(a,f)&&(b("approving_google_consent","Approving Google OAuth consent"),await a.waitForTimeout(1e3),!0))}async function J(a,b){let c=String(b||"");if(!C(c,r))return!1;if(await a.evaluate(()=>{let a=document.scrollingElement||document.documentElement||document.body;a&&(a.scrollTop=a.scrollHeight),window.scrollTo(0,document.body?.scrollHeight||document.documentElement?.scrollHeight||0)}).catch(()=>null),await a.waitForTimeout(500),C(c,s)){if(await w(a,f))return await a.waitForTimeout(700),!0;if(await a.evaluate(()=>{let a=[document.getElementById("confirm"),document.querySelector('form#tos_form input[type="submit"]'),document.querySelector('input[type="submit"][value="Saya mengerti"]'),document.querySelector('input[type="submit"][value="I understand"]')].filter(Boolean)[0];return!!a&&(a.scrollIntoView({block:"center"}),a.click(),!0)}).catch(()=>!1)||await a.evaluate(()=>{let a=document.getElementById("tos_form");return!!a&&(a.submit(),!0)}).catch(()=>!1))return await a.waitForTimeout(800),!0}return!!(await w(a,g)||await w(a,f))&&(await a.waitForTimeout(700),!0)}async function K(a){let b=/global|international|singapore|united states|^us$|asia|hong kong|default/i;for(let c of u(a)){let a=c.locator("select"),d=await a.count().catch(()=>0);for(let c=0;c<d;c+=1){let d=a.nth(c),e=await d.isVisible().catch(()=>!1),f=await d.isEnabled().catch(()=>!0);if(!e||!f)continue;let g=await d.evaluate((a,b)=>{let c=RegExp(b,"i"),d=[...a.options].filter(a=>!a.disabled&&""!==a.value),e=d.find(a=>c.test(`${a.label} ${a.textContent} ${a.value}`));return(e||d[0])?.value||""},b.source).catch(()=>"");if(g&&await d.selectOption(g).then(()=>!0).catch(()=>!1))return!0}}return!1}async function L(a){let b=!1;for(let c of u(a))for(let{selector:a,value:d}of n){let e=c.locator(a).first();if(!await e.count().catch(()=>0))continue;let f=await e.isVisible().catch(()=>!1),g=await e.isEnabled().catch(()=>!0);!(!f||!g||await e.inputValue().catch(()=>""))&&await e.fill(d,{timeout:5e3}).then(()=>!0).catch(()=>!1)&&(b=!0)}return b}async function M(a,b){await b.scrollIntoViewIfNeeded().catch(()=>null);let c=await b.isVisible().catch(()=>!1),d=await b.isEnabled().catch(()=>!0);if(!c||!d)return!1;let e=await b.boundingBox().catch(()=>null);if(!e||e.width<=0||e.height<=0)return!1;let f=e.x+e.width/2,g=e.y+e.height/2;return await a.mouse.move(f,g),await a.mouse.down(),await a.mouse.up(),!0}async function N(a,b,c){for(let d of u(a)){let e=d.locator(b),f=Math.min(await e.count().catch(()=>0),80),g=[];for(let a=0;a<f;a+=1){let b=e.nth(a);if(!await b.isVisible().catch(()=>!1))continue;let c=(await b.innerText({timeout:1e3}).catch(()=>"")||await b.textContent({timeout:1e3}).catch(()=>"")||"").trim();c&&g.push({locator:b,text:c})}for(let b of c){let c=g.find(a=>b.test(a.text));if(c&&await M(a,c.locator).catch(()=>!1))return c.text}if(g[0]&&await M(a,g[0].locator).catch(()=>!1))return g[0].text}return""}async function O(a,b){for(let c of u(a))for(let d of b){let b=c.locator(d),e=Math.min(await b.count().catch(()=>0),20);for(let c=0;c<e;c+=1){let d=b.nth(c);if(await M(a,d).catch(()=>!1))return!0}}return!1}async function P(a,b){if(!H(a)||D(a))return!1;let c=await a.evaluate(async()=>{let a=document.body?.innerText||"";if(!(document.querySelector(".page-region")||/select\s+region|region|country|area|get started|complete/i.test(a)))return null;try{let a=await fetch("https://www.codebuddy.ai/console/login/account",{method:"POST",credentials:"include",headers:{accept:"application/json, text/plain, */*","content-type":"application/json","x-requested-with":"XMLHttpRequest","x-domain":window.location.hostname||"www.codebuddy.ai"},referrer:"https://www.codebuddy.ai/register/user/complete",body:JSON.stringify({attributes:{countryCode:["62"],countryFullName:["Indonesia"],countryName:["ID"]}})}),b=await a.text().catch(()=>""),c=null;try{c=b?JSON.parse(b):null}catch{c={raw:b}}if(a.ok&&(!c||0===c.code||200===c.code||void 0===c.code))return{action:"submitted_via_api"};return{action:"api_failed",status:a.status,code:c?.code,message:c?.msg||c?.message||b||`HTTP ${a.status}`}}catch(a){return{action:"api_failed",message:a?.message||"region submit request failed"}}}).catch(()=>null);return!!c?.action&&("submitted_via_api"===c.action?(b("submitting_codebuddy_region","Submitted CodeBuddy region via account API"),await a.waitForTimeout(1500),!0):(b("codebuddy_region_api_failed",c.message?`CodeBuddy region API submit failed: ${c.message}`:"CodeBuddy region API submit failed"),!1))}async function Q(a,b){if(!H(a)||D(a)||!await a.locator(".page-region").first().count().then(Boolean).catch(()=>!1))return!1;let c=[/indonesia|^id$|\u5370\u5ea6\u5c3c\u897f\u4e9a/i,/singapore|^sg$|\u65b0\u52a0\u5761/i,/japan|^jp$|\u65e5\u672c/i,/thailand|^th$|\u6cf0\u56fd/i,/global|international|default/i];if(await O(a,[".page-region [class*='28B894']",".page-region button:has-text('Get started')",".page-region button:has-text('Start')",".page-region button:has-text('Submit')",".page-region button:has-text('Continue')",".page-region [role='button']:has-text('Get started')",".page-region [role='button']:has-text('Start')",".page-region [role='button']:has-text('Submit')",".page-region [role='button']:has-text('Continue')"]))return b("submitting_codebuddy_region","Submitted CodeBuddy region selection"),await a.waitForTimeout(1200),!0;let d=await N(a,"ul.dropdown-section li, .dropdown-section li, [role='option'], .t-select-option, [class*='option']",c);if(d)return b("selecting_codebuddy_region",`Selected CodeBuddy region: ${d}`),await a.waitForTimeout(900),!0;if(!await O(a,[".page-region .t-select",".page-region [class*='t-select']",".page-region [role='combobox']",".page-region input[placeholder]",".page-region [class*='select']",".page-region [class*='cursor-pointer']"]))return!1;b("opening_codebuddy_region_selector","Opening CodeBuddy region selector"),await a.waitForTimeout(600);let e=await N(a,"ul.dropdown-section li, .dropdown-section li, [role='option'], .t-select-option, [class*='option']",c);return e&&(b("selecting_codebuddy_region",`Selected CodeBuddy region: ${e}`),await a.waitForTimeout(900)),!0}async function R(a,b){if(!H(a)||D(a))return!1;if(await P(a,b)||await Q(a,b))return!0;for(let c of u(a)){let d=await c.evaluate(()=>{let a=a=>{if(!(a instanceof HTMLElement))return!1;let b=window.getComputedStyle(a);if("hidden"===b.visibility||"none"===b.display||0===Number(b.opacity))return!1;let c=a.getBoundingClientRect();return c.width>0&&c.height>0},b=document.querySelector(".page-region"),c=document.body?.innerText||"";if(!(b||/select\s+region|region|country|area|get started|complete/i.test(c)))return null;let d=a=>{for(let b of(a.scrollIntoView({block:"center",inline:"center"}),["pointerdown","mousedown","pointerup","mouseup","click"]))a.dispatchEvent(new MouseEvent(b,{bubbles:!0,cancelable:!0,view:window,buttons:+!!b.endsWith("down")}))},e=[/indonesia|^id$|\u5370\u5ea6\u5c3c\u897f\u4e9a/i,/singapore|^sg$|\u65b0\u52a0\u5761/i,/japan|^jp$|\u65e5\u672c/i,/thailand|^th$|\u6cf0\u56fd/i,/global|international|default/i],f=b||document.body,g=["button","[role='button']","input[type='submit']",".t-button","[class*='button']","[class*='28B894']"],h=[...f.querySelectorAll(g.join(","))].filter(a).filter(a=>{let b=`${a.innerText||""} ${a.getAttribute("aria-label")||""} ${a.getAttribute("value")||""}`,c=a.getAttribute("class")||"";return/submit|start|continue|confirm|done|get started|complete|\u5b8c\u6210|\u5f00\u59cb|\u786e\u5b9a|\u4e0b\u4e00\u6b65/i.test(b)||c.includes("28B894")});if(h.length)return d(h[0]),{action:"submitted"};let i=["ul.dropdown-section li",".dropdown-section li","[role='option']",".t-select-option","[class*='option']","[class*='dropdown'] li"],j=[...document.querySelectorAll(i.join(","))].filter(a).filter(a=>(a.innerText||a.textContent||"").trim());if(j.length){let a=e.map(a=>j.find(b=>a.test((b.innerText||b.textContent||"").trim()))).find(Boolean)||j[0],b=(a.innerText||a.textContent||"").trim();return d(a),{action:"selected",label:b}}let k=["[role='combobox']",".t-select","[class*='t-select']","[class*='select']","input[placeholder]",".text-sm","[class*='cursor-pointer']"],l=[...f.querySelectorAll(k.join(","))].filter(a).filter(a=>{let b=`${a.innerText||""} ${a.getAttribute("placeholder")||""} ${a.getAttribute("aria-label")||""}`;return/region|country|area|select|placeholder|\u5730\u533a|\u56fd\u5bb6|\u9009\u62e9/i.test(b)||a.matches?.(".t-select,[class*='t-select'],input[placeholder],[class*='select']")});return l.length?(d(l[0]),{action:"opened"}):null}).catch(()=>null);if(d?.action){if("selected"===d.action)return b("selecting_codebuddy_region",`Selected CodeBuddy region${d.label?`: ${d.label}`:""}`),await a.waitForTimeout(700),!0;if("submitted"===d.action)return b("submitting_codebuddy_region","Submitted CodeBuddy region selection"),await a.waitForTimeout(1200),!0;return b("opening_codebuddy_region_selector","Opening CodeBuddy region selector"),await a.waitForTimeout(700),!0}}return!1}async function S(a,b){if(!H(a)||D(a))return!1;let c=await a.evaluate(async()=>{let a=new URL(window.location.href);if(!/\/started\/?$/.test(a.pathname))return null;let b=a.searchParams.get("platform")||"CLI",c=a.searchParams.get("state");if(!c)return null;for(let a of[...new Set([window.location.hostname||"www.codebuddy.ai"].filter(Boolean))]){let d=new URL("/console/auth/login",window.location.origin);d.searchParams.set("platform",b),d.searchParams.set("state",c),d.searchParams.set("domain",a);try{let b=await fetch(d.toString(),{method:"GET",credentials:"include",redirect:"manual",headers:{"x-requested-with":"XMLHttpRequest","X-Domain":a}});if("opaqueredirect"===b.type||b.status>=300&&b.status<400)return{action:"attempted",domain:a,message:"redirected"};let c=await b.text(),e=null;try{e=c?JSON.parse(c):null}catch{e={raw:c}}if(b.ok&&(!e||0===e.code||200===e.code||void 0===e.code))return{action:"authorized",domain:a};if(b.ok)return{action:"attempted",domain:a,code:e?.code,message:e?.msg||e?.message||""}}catch(a){}}return{action:"failed"}}).catch(()=>null);return!!c?.action&&"failed"!==c.action&&("authorized"===c.action?b("authorizing_codebuddy_cli_state","Authorized CodeBuddy CLI login state"):b("authorizing_codebuddy_cli_state",c.message?`Attempted CodeBuddy CLI login state authorization: ${c.message}`:"Attempted CodeBuddy CLI login state authorization"),await a.waitForTimeout(1200),!0)}async function T(a,b,c){return!(!H(a)||D(a))&&(await w(a,j)?(b("accepting_provider_privacy_dialog",`Confirmed ${c} privacy or terms dialog`),await a.waitForTimeout(800),!0):!!(await S(a,b)||await R(a,b))||(await K(a)?(b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700),!0):await w(a,l)?(b("opening_provider_region_selector",`Opening ${c} region selector`),await a.waitForTimeout(500),await w(a,m)&&(b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700)),!0):await w(a,m)?(b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700),!0):await L(a)?(b("filling_provider_onboarding",`Filled ${c} onboarding defaults`),await a.waitForTimeout(500),!0):!!await w(a,k)&&(b("continuing_provider_onboarding",`Continuing ${c} onboarding`),await a.waitForTimeout(1e3),!0)))}async function U(a,b){return!D(a)&&(await w(a,j)?(b("accepting_provider_privacy_dialog","Confirmed provider privacy agreement dialog"),await a.waitForTimeout(1e3),!0):(await x(a,i)&&(b("accepting_provider_terms","Accepted provider terms for Google login"),await a.waitForTimeout(400)),!!await w(a,h)&&(b("selecting_google_login","Selecting Google login"),await a.waitForTimeout(1e3),await w(a,j)&&(b("accepting_provider_privacy_dialog","Confirmed provider privacy agreement dialog"),await a.waitForTimeout(1e3)),!0)))}function V(a,b,c=9e5){let d,e,f=new Promise((a,b)=>{d=a,e=b}),g=!1,h=new Set,i=new Map,j=setTimeout(()=>{k(null,Error("Timed out waiting for Kiro callback"))},c);function k(a,b=null){if(!g){for(let a of(g=!0,clearTimeout(j),i.values()))for(let b of a)try{b()}catch{}i.clear(),b?e(b):d(a)}}function l(a){let b=t(a||"");return b&&k(b),!!b}function m(a){try{l(a?.url?.()||"");let b="function"==typeof a?.headers?a.headers():null,c=b?.location||b?.Location||"";c&&l(c)}catch{}}function n(a,b){if(!a||h.has(a))return;h.add(a);let c=a=>l(a?.url?.()||""),d=a=>l(a?.url?.()||""),e=a=>l(a?.url?.()||""),f=a=>m(a),i=()=>l(a.url?.()||""),j=()=>{k(null,Error("Browser session closed while waiting for Kiro callback"))};a.on("framenavigated",c),a.on("request",d),a.on("requestfailed",e),a.on("response",f),a.on("domcontentloaded",i),a.on("load",i),a.on("close",j),b.push(()=>{a.off("framenavigated",c),a.off("request",d),a.off("requestfailed",e),a.off("response",f),a.off("domcontentloaded",i),a.off("load",i),a.off("close",j)}),(async()=>{try{if(g)return;let c=a.context?.();if(!c?.newCDPSession)return;let d=await c.newCDPSession(a);await d.send("Network.enable").catch(()=>null);let e=a=>{try{let b=a?.response?.headers||{},c=b.location||b.Location||"";c&&l(c),l(a?.response?.url||"")}catch{}},f=a=>{try{l(a?.request?.url||"")}catch{}};d.on("Network.responseReceived",e),d.on("Network.requestWillBeSent",f),b.push(()=>{try{d.off?.("Network.responseReceived",e)}catch{}try{d.off?.("Network.requestWillBeSent",f)}catch{}d.detach?.().catch(()=>null)})}catch{}})();let n=t(a.url?.()||"");n&&k(n)}function o(a,b){if(g||i.has(a))return;let c=[];i.set(a,c);let d=a=>n(a,c),e=()=>{k(null,Error("Browser context closed while waiting for Kiro callback"))},f=a=>l(a?.url?.()||""),h=a=>l(a?.url?.()||""),j=a=>m(a);a.on("page",d),a.on("close",e),a.on("request",f),a.on("requestfailed",h),a.on("response",j),c.push(()=>a.off("page",d)),c.push(()=>a.off("close",e)),c.push(()=>a.off("request",f)),c.push(()=>a.off("requestfailed",h)),c.push(()=>a.off("response",j)),b&&n(b,c)}return o(a,b),f.rebind=({context:a,page:b}={})=>{a&&o(a,b)},f.abort=(a="Job cancelled")=>{k(null,Error(a))},f}function W(a,b,{prefix:c,timeoutMs:d=9e5}={}){let e,f,g=new Promise((a,b)=>{e=a,f=b}),h=!1,i=new Set,j=new Map,k=setTimeout(()=>{l(null,Error("Timed out waiting for OAuth callback"))},d);function l(a,b=null){if(!h){for(let a of(h=!0,clearTimeout(k),j.values()))for(let b of a)try{b()}catch{}j.clear(),b?f(b):e(a)}}function m(a,b){if(!a||i.has(a))return;i.add(a);let d=a=>{let b=function(a,b){if(!a||!b||!a.startsWith(b))return null;let c=a.indexOf("?"),d=new URLSearchParams(c>=0?a.slice(c+1):""),e=d.get("code"),f=d.get("state");return e?{callbackUrl:a,code:e,state:f}:null}(a||"",c);b&&l(b)},e=a=>d(a?.url?.()||""),f=a=>d(a?.url?.()||""),g=a=>d(a?.url?.()||""),h=()=>d(a.url?.()||"");a.on("framenavigated",e),a.on("request",f),a.on("requestfailed",g),a.on("domcontentloaded",h),a.on("load",h),b.push(()=>{a.off("framenavigated",e),a.off("request",f),a.off("requestfailed",g),a.off("domcontentloaded",h),a.off("load",h)}),d(a.url?.()||"")}function n(a,b){if(h||j.has(a))return;let c=[];j.set(a,c);let d=a=>m(a,c);a.on("page",d),c.push(()=>a.off("page",d)),b&&m(b,c)}return n(a,b),g.rebind=({context:a,page:b}={})=>{a&&n(a,b)},g}async function X({page:a,authUrl:b,email:c,password:g,successPromise:h,shortTimeoutMs:i=9e4,serviceLabel:j="provider",openingStep:k="opening_google_oauth",openingMessage:l="Opening Google OAuth page",successStep:m="oauth_success_received",successMessage:n="OAuth success received",onStep:r}){let s=Date.now(),t=(a,b)=>{r?.(a,b)},u=a=>({maxWaitMs:a,successPromise:h}),w=0,x=0;t(k,l),await a.goto(b,{waitUntil:"domcontentloaded",timeout:6e4}),await a.waitForTimeout(2e3),await G(a,t,u(12e3)),await U(a,t),await G(a,t,u(8e3));let D=await z(a,d,{timeout:15e3});for(D&&(t("entering_email","Entering Google email"),await A(D,c)?(t("submitting_email","Submitting email"),await v(a,e),x=Date.now(),await a.waitForTimeout(1500),await G(a,t,u(12e3))):t("email_fill_failed","Could not fill the Google email field; will retry in the polling loop"));Date.now()-s<i;){let b=await Promise.race([h.then(a=>({kind:"success",result:a})).catch(a=>({kind:"success_error",error:a})),new Promise(a=>setTimeout(()=>a(null),800))]);if(b?.kind==="success")return t(m,n),{status:"success",...b.result};if(b?.kind==="success_error")return t("oauth_timeout",`Timed out waiting for ${j} authorization`),{status:"failed_timeout",error:b.error?.message||`Timed out waiting for ${j} authorization`};if(await G(a,t,u(8e3)))continue;if(await I(a,t)){await G(a,t,u(12e3));continue}if(await E(a)){let b=a.url?.()||"";return t("browser_blocked_by_google",`Google blocked this browser (url=${b.slice(0,120)}). Headless Chromium is rejected — use headed mode or Camoufox.`),{status:"failed_browser_blocked",error:'Google blocked the automated browser ("This browser or app may not be secure" / signin rejected). Kiro bulk must use headed Chromium (Xvfb on Linux) or the Camoufox engine — not headless Chrome.'}}let i=await B(a);if(C(i,o))return t("invalid_credentials","Google rejected the supplied email or password"),{status:"failed_invalid_credentials",error:"Google rejected the supplied email or password."};if(C(i,q))return t("account_restricted","Account is restricted, suspended, or banned by the provider"),{status:"failed_restricted",error:"Account is restricted, suspended, or banned. Skipping."};if(C(i,p)){let a=/captcha|recaptcha|not a robot|select all images|select all squares/i.test(i);return t(a?"google_captcha":"manual_assist_required",a?"Google CAPTCHA / bot check":"Google requested CAPTCHA, 2FA, or recovery verification"),{status:"needs_manual",error:a?"Google CAPTCHA (bot check). Not fixed by lowering workers — use headed Chromium+Xvfb or Camoufox, residential proxy, and avoid blocking Google domains. Open manual assist to solve CAPTCHA once.":"Manual assist required in the browser session (CAPTCHA, 2FA, recovery, or suspicious-login challenge)."}}if(await J(a,i)){t("google_onboarding","Accepted Google onboarding or privacy prompt");continue}if(await T(a,t,j))continue;let k=await y(a,'input[type="password"], input[name="Passwd"], input[name="password"], input[aria-label*="Password" i], input[aria-label*="password" i], input[aria-label*="Sandi" i], input[aria-label*="kata sandi" i]');if(k){let b=Date.now()-w;if(w&&b<25e3){t("waiting_after_password",`Password already submitted ${Math.round(b/1e3)}s ago — waiting for Google redirect`),await G(a,t,u(8e3)),await a.waitForTimeout(500);continue}t("entering_password","Entering Google password"),await A(k,g)?(t("submitting_password","Submitting password"),await v(a,e),w=Date.now(),await Promise.race([a.waitForNavigation({waitUntil:"domcontentloaded",timeout:8e3}).catch(()=>null),a.waitForTimeout(2500)]),await G(a,t,u(25e3))):(t("password_fill_failed","Could not fill the Google password field; retrying loop"),await a.waitForTimeout(700));continue}let l=await y(a,d);if(l){let b=Date.now()-x;if(x&&b<12e3){t("waiting_after_email",`Email already submitted ${Math.round(b/1e3)}s ago — waiting for password/next screen`),await a.waitForTimeout(800);continue}t("entering_email","Entering Google email"),await A(l,c)?(t("submitting_email","Submitting email"),await v(a,e),x=Date.now(),await a.waitForTimeout(1500)):t("email_fill_failed","Could not fill the Google email field; retrying loop"),await a.waitForTimeout(700);continue}if(!await U(a,t)){if(await v(a,f)){t("approving_consent",`Approving Google or ${j} consent`),await a.waitForTimeout(700);continue}if(Math.floor((Date.now()-s)/5e3)!==Math.floor((Date.now()-s-700)/5e3)){let b=a.url?.()||"",c=String(i||await B(a).catch(()=>"")).slice(0,100).replace(/\s+/g," ");t("waiting_for_next_screen",`Waiting for the next Google or ${j} screen (url=${b.slice(0,100)} body=${c})`)}else t("waiting_for_next_screen",`Waiting for the next Google or ${j} screen`);await a.waitForTimeout(700)}}if(await E(a))return t("browser_blocked_by_google","Google blocked browser at end of automation window"),{status:"failed_browser_blocked",error:'Google blocked the automated browser ("This browser or app may not be secure"). Use headed Chromium (Xvfb) or Camoufox engine.'};let F=a.url?.()||"",H=String(await B(a).catch(()=>"")).slice(0,120).replace(/\s+/g," ");return t("manual_assist_required",`Flow did not complete ${j} authorization automatically (url=${F.slice(0,100)} body=${H})`),{status:"needs_manual",error:`Manual assist required — ${j} authorization did not finish automatically (last url: ${F.slice(0,140)}). If you see "browser may not be secure", switch to headed Chromium/Camoufox.`}}async function Y({page:a,authUrl:b,email:c,password:d,callbackPromise:e,shortTimeoutMs:f=9e4,onStep:g}){return X({page:a,authUrl:b,email:c,password:d,successPromise:e,shortTimeoutMs:f,serviceLabel:"Kiro",openingStep:"opening_google_oauth",openingMessage:"Opening Google OAuth page",successStep:"kiro_callback_received",successMessage:"Kiro callback received",onStep:g})}},89718:(a,b,c)=>{c.d(b,{CG:()=>d.CG,Dj:()=>d.Dj,Fh:()=>d.Fh,Iq:()=>d.Iq,K1:()=>d.K1,KJ:()=>d.KJ,KK:()=>d.KK,L:()=>d.L,L9:()=>d.L9,Lh:()=>d.Lh,Mc:()=>d.Mc,NR:()=>d.NR,OM:()=>d.OM,PX:()=>d.PX,Pc:()=>d.Pc,QI:()=>d.QI,Q_:()=>d.Q_,Qu:()=>d.Qu,S8:()=>d.S8,Uv:()=>d.Uv,VT:()=>d.VT,XW:()=>d.XW,Xx:()=>d.Xx,Yd:()=>d.Yd,ZO:()=>d.ZO,bI:()=>d.bI,c:()=>d.c,dK:()=>d.dK,ek:()=>d.ek,fK:()=>d.fK,fv:()=>d.fv,getProviderConnections:()=>d.P,getQuotaSnapshot:()=>d.LF,ho:()=>d.ho,hr:()=>d.hr,i0:()=>d.i0,iE:()=>d.iE,jd:()=>d.jd,mt:()=>d.mt,o5:()=>d.o5,oG:()=>d.oG,op:()=>d.op,p3:()=>d.p3,qd:()=>d.qd,r4:()=>d.r4,uL:()=>d.uL,ui:()=>d.ui,updateProviderConnection:()=>d.rj,uv:()=>d.uv,yF:()=>d.yF,yW:()=>d.yW,yg:()=>d.yg,zP:()=>d.zP,zY:()=>d.zY});var d=c(93999)}};
|
|
1
|
+
"use strict";exports.id=8157,exports.ids=[1998,8157],exports.modules={20116:(a,b,c)=>{c.d(b,{q:()=>h,si:()=>g,uT:()=>i});var d=c(21820),e=c.n(d);function f(a){return Number.isFinite(a)?Math.max(0,Math.floor(a)):0}function g(){let a=[];try{a=e().cpus()||[]}catch{a=[]}let b=0,c=0;try{b=e().totalmem()}catch{b=0}try{c=e().freemem()}catch{c=0}let d=Array.isArray(a)?a.length:0,f=a[0]?.model?String(a[0].model).trim():null,g=b/0x40000000,h=c/0x40000000,i="unknown",j="unknown";try{i=e().platform()}catch{}try{j=e().arch()}catch{}return{cpuCount:d,cpuModel:f,totalMemBytes:b,totalMemGb:g,freeMemBytes:c,freeMemGb:h,platform:i,arch:j}}function h(){return function(a=null){let b=a||g(),{cpuCount:c,totalMemGb:d}=b,e=f(d/4),h=f(c/2),i="fallback",j=0;return e>0&&h>0?(j=Math.min(e,h),i=e<=h?"ram":"cpu"):e>0?(j=e,i="ram"):h>0?(j=h,i="cpu"):(j=4,i="fallback"),{recommended:Math.min(8,Math.max(1,j||4)),limitedBy:i,ramBudget:e,cpuBudget:h,minWorkers:1,maxWorkers:8,ramGbPerWorker:4,cpuDivisor:2,specs:b}}().recommended}function i(a){return!0===a||"string"==typeof a&&"auto"===a.trim().toLowerCase()}Object.freeze({RAM_GB_PER_WORKER:4,CPU_DIVISOR:2,SAFE_MIN_WORKERS:1,SAFE_MAX_WORKERS:8,FALLBACK_WORKERS:4})},47293:(a,b,c)=>{c.d(b,{A:()=>f});let d=new Uint8Array(16);var e=c(50122);let f=function(a,b,c){return b||a||!crypto.randomUUID?function(a,b,c){let f=(a=a||{}).random??a.rng?.()??crypto.getRandomValues(d);if(f.length<16)throw Error("Random bytes length must be >= 16");if(f[6]=15&f[6]|64,f[8]=63&f[8]|128,b){if((c=c||0)<0||c+16>b.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let a=0;a<16;++a)b[c+a]=f[a];return b}return(0,e.k)(f)}(a,b,c):crypto.randomUUID()}},50122:(a,b,c)=>{c.d(b,{k:()=>e});let d=[];for(let a=0;a<256;++a)d.push((a+256).toString(16).slice(1));function e(a,b=0){return(d[a[b+0]]+d[a[b+1]]+d[a[b+2]]+d[a[b+3]]+"-"+d[a[b+4]]+d[a[b+5]]+"-"+d[a[b+6]]+d[a[b+7]]+"-"+d[a[b+8]]+d[a[b+9]]+"-"+d[a[b+10]]+d[a[b+11]]+d[a[b+12]]+d[a[b+13]]+d[a[b+14]]+d[a[b+15]]).toLowerCase()}},53041:(a,b,c)=>{c.d(b,{$w:()=>C,KY:()=>S,Q6:()=>R,cO:()=>L,go:()=>O,hn:()=>E,kF:()=>s});var d=c(55511),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(49120),j=c(71998),k=c(20116),l=c(62409),m=c(82506),n=c(66307);let o=new Set(["success","failed","failed_invalid_credentials","failed_exchange","failed_timeout","failed_restricted","failed_browser_blocked","cancelled"]),p=h().join(i.DATA_DIR,"kiro-bulk-import"),q=h().join(p,"meta.json"),r=new Set(["queued","running","needs_manual"]);function s(){return new Date().toISOString()}function t(a=p){f().mkdirSync(a,{recursive:!0})}function u(a,b=p){return t(b),h().join(b,`${a}.json`)}function v(a){try{if(!f().existsSync(a))return null;return JSON.parse(f().readFileSync(a,"utf8"))}catch{return null}}function w(a,b){t(h().dirname(a));let c=`${a}.${process.pid}.tmp`;f().writeFileSync(c,JSON.stringify(b,null,2),"utf8"),f().renameSync(c,a)}function x(a,b=p){return t(b),h().join(b,`${a}.resume.enc`)}function y(){return(0,d.createHash)("sha256").update(String(function(){if(process.env.BULK_IMPORT_RESUME_SECRET)return process.env.BULK_IMPORT_RESUME_SECRET;let a=h().join(i.DATA_DIR,"bulk-import-resume-key");try{return f().readFileSync(a,"utf8").trim()}catch{}try{t(i.DATA_DIR);let b=(0,d.randomBytes)(32).toString("hex");return f().writeFileSync(a,b,{mode:384}),b}catch{return(0,d.randomBytes)(32).toString("hex")}}())).digest()}function z(a){try{f().existsSync(a)&&f().rmSync(a)}catch{}}function A(a=q){return v(a)?.latestJobId||null}function B(a){if((0,k.uT)(a))return Math.min(8,Math.max(1,(0,k.q)()));let b=Number.parseInt(a,10);return Number.isFinite(b)?Math.min(8,Math.max(1,b)):4}function C(a=[]){let b=Array.isArray(a)?a:[],c=[],d=[];return b.forEach((a,b)=>{let e=String(a||"").trim();if(!e||e.startsWith("#"))return;let f="",g="";if(e.includes("|")){let[a="",...b]=e.split("|");f=a.trim(),g=b.join("|").trim()}else if(e.includes(" ")){let a=e.indexOf(" ");f=e.substring(0,a).trim(),g=e.substring(a+1).trim()}else if(e.includes(":")){let a=e.indexOf(":"),b=e.substring(0,a).trim();b.includes("@")&&(f=b,g=e.substring(a+1).trim())}f&&g?c.push({line:b+1,email:f,password:g}):d.push(b+1)}),{parsed:c,invalidLines:d}}function D(a){return{total:a.length,queued:a.filter(a=>"queued"===a.status).length,running:a.filter(a=>"running"===a.status).length,success:a.filter(a=>"success"===a.status).length,failed:a.filter(a=>"failed"===a.status||"failed_invalid_credentials"===a.status||"failed_exchange"===a.status||"failed_timeout"===a.status||"failed_restricted"===a.status||"failed_browser_blocked"===a.status).length,needs_manual:a.filter(a=>"needs_manual"===a.status).length}}function E(a,b,c="info"){return{id:(0,d.randomUUID)(),at:s(),step:a,message:b,level:c}}function F(a,b,c,d="info"){let e=E(b,c,d);return a.currentStep=b,a.updatedAt=e.at,a.logs=a.logs||[],a.logs.push(e),a.logs.length>40&&a.logs.splice(0,a.logs.length-40),e}function G(a){return a.flatMap(a=>(a.logs||[]).map(b=>({...b,email:a.email,line:a.line,workerId:a.workerId||null,status:a.status}))).sort((a,b)=>String(a.at).localeCompare(String(b.at))).slice(-80)}function H(a){if(!a)return null;try{let b=new URL(a);return(b.username||b.password)&&(b.username="***",b.password="***"),b.toString()}catch{return a.length>20?`${a.slice(0,10)}***${a.slice(-10)}`:a}}function I(a){return{email:a.email,status:a.status,error:a.error||null,connectionId:a.connectionId||null,workerId:a.workerId||null,line:a.line,proxyUrl:H(a.proxyUrl)||null,currentStep:a.currentStep||null,updatedAt:a.updatedAt||null,logs:(a.logs||[]).slice(-20),manualSessionAvailable:!!a.manualSession?.page&&"needs_manual"===a.status,manualSessionOpened:!!a.manualSession?.opened}}function J(a,b={}){return{jobId:a.jobId,status:a.status,summary:D(a.accounts),concurrency:a.concurrency,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,accounts:a.accounts.map(I),activity:G(a.accounts),error:a.error||null,preview:b.preview||null}}function K(a){if(!a||r.has(a.status))return!1;let b=a.finishedAt?Date.parse(a.finishedAt):NaN;return!!Number.isFinite(b)&&Date.now()-b<=18e5}function L(a,b={}){return a?{found:!0,stale:!1,recoverable:r.has(a.status)||K(a),job:a}:{found:!1,stale:!!b.stale,recoverable:!1,job:null}}async function M(a){let b,{launchBulkImportBrowser:d}=await c.e(5949).then(c.bind(c,75949)),e=a?.engine||"chromium",f=process.env.ZEVAI_KIRO_HEADLESS;return b="1"===f||"true"===f||"0"!==f&&"false"!==f&&"camoufox"===e,d({engine:e,headless:b,windowSize:{width:1280,height:900}})}async function N(a){let{exchangeAndSaveKiroSocialConnection:b}=await c.e(4136).then(c.bind(c,34136));return b(a)}async function O(a,b){let d=b,e=null;if(b)try{let{ensureSocksHttpBridge:a,isSocksProxyUrl:f}=await Promise.all([c.e(3092),c.e(6652)]).then(c.bind(c,76652));f(b)&&(e=await a(b),e?.httpProxyUrl&&(d=e.httpProxyUrl))}catch(a){console.warn("[bulk-import] SOCKS bridge unavailable:",a?.message||a)}let f=(0,n.parsePlaywrightProxy)(d),g=f?{proxy:f}:{},h="";try{h=a.browserType().name()}catch{}"firefox"===h?g.viewport=null:g.viewport||(g.viewport={width:900,height:700}),g.ignoreHTTPSErrors=!0;let i=await a.newContext(g);if(e){let a=i.close.bind(i);i.close=async(...b)=>{try{return await a(...b)}finally{await e.release().catch(()=>null)}}}let j=await i.newPage();try{await j.route(/facebook\.net|hotjar|clarity\.ms|hm\.baidu|sentry\.io|browser\.sentry-cdn|doubleclick\.net/i,a=>a.abort())}catch{}return{context:i,page:j}}async function P(a){let b,d;if(!a?.manualSession?.context)return!1;let e=a.manualSession.context,f=a.manualSession.page,g=e.browser?.(),h=null,i="";try{h=await e.storageState()}catch{h=null}try{i=f?.url?.()||""}catch{i=""}let{chromium:j}=await Promise.resolve().then(c.bind(c,83237));try{b=await j.launch({headless:!1,args:["--start-maximized"]})}catch{return!1}try{d=await b.newContext({viewport:null,...h?{storageState:h}:{}})}catch{return await b.close().catch(()=>null),!1}let k=await d.newPage();if(i)try{await k.goto(i,{waitUntil:"domcontentloaded",timeout:2e4})}catch{}let l=a.manualSession.rebind;if(a.manualSession.context=d,a.manualSession.page=k,a.manualSession.headedBrowser=b,"function"==typeof l)try{await l({context:d,page:k})}catch{}return e.close().catch(()=>null),g&&g!==b&&g.close().catch(()=>null),!0}async function Q(a,{account:b}={}){if(!a)return!1;try{let c=a.context?.(),d=c?.browser?.();if(b&&function(a){if(!a)return!0;let b=a._options||a._initializer||{};return"boolean"!=typeof b.headless||b.headless}(d)&&await P(b))return await b.manualSession.page.bringToFront?.().catch(()=>null),!0;if(!c?.newCDPSession)return await a.bringToFront?.().catch(()=>null),!0;let e=await c.newCDPSession(a),f=null;try{let a=await e.send("Target.getTargetInfo"),b=a?.targetInfo?.targetId,c=await e.send("Browser.getWindowForTarget",b?{targetId:b}:{});f=c?.windowId??null}catch{f=null}return null!=f&&await e.send("Browser.setWindowBounds",{windowId:f,bounds:{windowState:"normal",left:80,top:80,width:1280,height:960}}).catch(()=>null),await a.bringToFront?.().catch(()=>null),await e.detach?.().catch(()=>null),!0}catch{return await a.bringToFront?.().catch(()=>null),!0}}class R{constructor({browserLauncher:a=M,googleAutomation:b=m.Th,socialExchange:c=N,kiroServiceFactory:d=()=>new l.v,storageName:e="kiro-bulk-import"}={}){this.browserLauncher=a,this.googleAutomation=b,this.socialExchange=c,this.kiroServiceFactory=d,this.storageDir=h().join(i.DATA_DIR,e),this.metaFile=h().join(this.storageDir,"meta.json"),this.jobs=new Map,this.latestJobId=A(this.metaFile)}persistResumeBlob(a){try{!function(a,b){try{let c,e,g,i,j;t(h().dirname(a));let k=`${a}.${process.pid}.tmp`;f().writeFileSync(k,JSON.stringify((c=(0,d.randomBytes)(12),e=(0,d.createCipheriv)("aes-256-gcm",y(),c),g=Buffer.from(JSON.stringify(b),"utf8"),i=Buffer.concat([e.update(g),e.final()]),j=e.getAuthTag(),{v:1,alg:"aes-256-gcm",iv:c.toString("base64"),tag:j.toString("base64"),data:i.toString("base64")})),{mode:384}),f().renameSync(k,a)}catch{}}(x(a.jobId,this.storageDir),{jobId:a.jobId,concurrency:a.concurrency,engine:a.engine,proxyPoolMode:a.proxyPoolMode,proxyUrls:a.proxyUrls||[],createdAt:a.createdAt,accounts:a.accounts.map(a=>({line:a.line,email:a.email,password:a.password}))})}catch{}}hydrateInterruptedJob(a){if(!a||this.jobs.has(a))return!1;let b=v(u(a,this.storageDir));if(!b||!r.has(b.status))return!1;let c=function(a){let b=v(a);if(!b)return null;if(!b||"aes-256-gcm"!==b.alg||!b.iv||!b.tag||!b.data)return null;try{let a=(0,d.createDecipheriv)("aes-256-gcm",y(),Buffer.from(b.iv,"base64"));a.setAuthTag(Buffer.from(b.tag,"base64"));let c=Buffer.concat([a.update(Buffer.from(b.data,"base64")),a.final()]);return JSON.parse(c.toString("utf8"))}catch{return null}}(x(a,this.storageDir));if(!c||!Array.isArray(c.accounts)||0===c.accounts.length)return this.markJobInterrupted(a,b),!1;let e=new Map(c.accounts.map(a=>[a.line,a.password])),f=new Map(c.accounts.map(a=>[a.line,a.email])),g=b.createdAt||c.createdAt||s(),h=(b.accounts||[]).map(a=>{let b=o.has(a.status),c=Array.isArray(a.logs)?[...a.logs]:[],d={line:a.line,email:a.email||f.get(a.line)||"",password:b?void 0:e.get(a.line)??null,proxyUrl:null,status:a.status,error:a.error||null,connectionId:a.connectionId||null,workerId:b&&a.workerId||null,manualSession:null,runtimeSession:null,currentStep:a.currentStep||null,updatedAt:a.updatedAt||g,logs:c};return b||(d.status="queued",d.currentStep="queued",d.error=null,d.logs.push(E("resumed","Re-queued after a server restart to continue automatically"))),d}),i={jobId:a,status:"running",concurrency:B(c.concurrency),engine:c.engine||"chromium",proxyPoolMode:c.proxyPoolMode||"none",proxyUrls:Array.isArray(c.proxyUrls)?c.proxyUrls:[],createdAt:g,startedAt:b.startedAt||g,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:b.preview||null,lastPreviewCapturedAt:0,accounts:h};return(this.jobs.set(a,i),this.latestJobId||(this.latestJobId=a),h.some(a=>"queued"===a.status))?this.runJob(a):(i.status="completed",i.finishedAt=s(),this.persistJobSnapshot(i,{forcePreview:!1}),z(x(a,this.storageDir))),!0}markJobInterrupted(a,b){let c="Job was interrupted by a server restart and could not be auto-resumed (saved credentials were unavailable). Please start a new bulk login.",d=(b.accounts||[]).map(a=>{if(o.has(a.status))return a;let b=Array.isArray(a.logs)?[...a.logs]:[];return b.push(E("failed",c,"error")),{...a,status:"failed",error:c,currentStep:"failed",updatedAt:s(),manualSessionAvailable:!1,logs:b}}),e={...b,status:"failed",error:b.error||c,finishedAt:b.finishedAt||s(),accounts:d,summary:D(d),activity:G(d)};try{w(u(a,this.storageDir),e)}catch{}z(x(a,this.storageDir))}async startJob({accounts:a,concurrency:b,engine:e,proxyPoolMode:f,proxyPoolId:g}){let{parsed:h,invalidLines:i}=C(a);if(!h.length){let a=i.length>0?"Invalid account format. Use one account per line: gmail@example.com|password":"At least one account entry is required",b={error:a};throw i.length>0&&(b.invalidLines=i),Object.assign(Error(a),b)}if(i.length>0){let a="Invalid account format. Use one account per line: gmail@example.com|password";throw Object.assign(Error(a),{error:a,invalidLines:i})}let k=[];if("all"===f)k=(await (0,j.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===f&&g){let a=await (0,j.hr)(g);a?.isActive&&a?.proxyUrl&&(k=[a.proxyUrl])}let l=(0,d.randomUUID)(),m=s(),{normalizeBulkImportEngine:n,DEFAULT_BULK_IMPORT_ENGINE:o}=await c.e(5949).then(c.bind(c,75949)),p=e?n(e):o,r={jobId:l,status:"running",concurrency:B(b),engine:p,proxyPoolMode:f||"none",proxyUrls:k,createdAt:m,startedAt:m,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:h.map(a=>({line:a.line,email:a.email,password:a.password,proxyUrl:null,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:m,logs:[E("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(l,r),this.latestJobId=l,!function(a,b=q){w(b,{latestJobId:a||null,updatedAt:s()})}(l,this.metaFile),await this.persistJobSnapshot(r,{forcePreview:!1}),this.persistResumeBlob(r),this.runJob(l),J(r)}getJob(a){this.hydrateInterruptedJob(a);let b=this.jobs.get(a);return b?J(b,{preview:b.lastPreview||null}):v(u(a,this.storageDir))}async getJobWithPreview(a){this.hydrateInterruptedJob(a);let b=this.jobs.get(a);if(!b)return v(u(a,this.storageDir));let c=await this.capturePreview(b);return b.lastPreview=c||b.lastPreview||null,await this.persistJobSnapshot(b,{forcePreview:!1}),J(b,{preview:b.lastPreview||null})}async getLatestJobWithPreview({includeRecentTerminal:a=!1}={}){let b=this.latestJobId||A(this.metaFile);if(!b)return null;let c=await this.getJobWithPreview(b);return c&&(r.has(c.status)||a&&K(c))?c:null}cancelJob(a){let b=this.jobs.get(a);if(!b)return v(u(a,this.storageDir));for(let a of(b.cancelRequested=!0,b.accounts||[]))if("queued"===a.status||"running"===a.status||"needs_manual"===a.status){let b=a.manualSession,c=a.runtimeSession,d=b?.context||c?.context||null,e=b?.headedBrowser||null;d&&d.close().catch(()=>null),e&&e.close().catch(()=>null),a.manualSession=null,a.runtimeSession=null,this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled by user"})}if(b.browser){let a=b.browser;b.browser=null,c.e(5949).then(c.bind(c,75949)).then(({forceCloseBrowser:b})=>b(a)).catch(()=>a.close().catch(()=>null))}return("queued"===b.status||"running"===b.status)&&(b.status="cancelled",b.finishedAt=b.finishedAt||s()),this.persistJobSnapshot(b,{forcePreview:!0}),J(b)}async openManualSession(a,b){let c=this.jobs.get(a);if(!c)return null;let d=Number.parseInt(b,10),e=c.accounts.find(a=>a.workerId===d&&"needs_manual"===a.status&&a.manualSession?.page);if(!e)return{ok:!1,error:"Manual session not found for this worker",job:J(c)};let f=await Q(e.manualSession.page,{account:e});return e.manualSession.opened=f,e.manualSession.openedAt=f?e.manualSession.openedAt||s():e.manualSession.openedAt||null,await this.persistJobSnapshot(c,{forcePreview:!0}),{ok:!0,job:J(c),account:I(e)}}dequeueAccount(a,b){for(;a.nextIndex<a.accounts.length;){let c=a.accounts[a.nextIndex];if(a.nextIndex+=1,"queued"===c.status)return c.status="running",c.workerId=b,c.error=null,a.proxyUrls?.length&&(c.proxyUrl=a.proxyUrls[(a.nextIndex-1)%a.proxyUrls.length]),F(c,"worker_assigned",`Worker ${b} picked up this account${c.proxyUrl?` (proxy: ${H(c.proxyUrl)})`:""}`),this.persistJobSnapshot(a,{forcePreview:!1}),c}return null}finalizeAccount(a,b,c={}){return a.status=b,a.error=c.error||null,a.connectionId=c.connectionId||null,(c.step||c.message)&&F(a,c.step||b,c.message||c.error||b.replaceAll("_"," ")),a}setAccountStep(a,b,c,d="info"){F(a,b,c,d)}async persistJobSnapshot(a,{forcePreview:b=!1}={}){if(!a)return;let c=async()=>{if(b||Date.now()-(a.lastPreviewCapturedAt||0)>=1500){let b=await this.capturePreview(a);b&&(a.lastPreview=b),a.lastPreviewCapturedAt=Date.now()}w(u(a.jobId,this.storageDir),J(a,{preview:a.lastPreview||null}))};a.persistPromise=Promise.resolve(a.persistPromise).catch(()=>null).then(c),await a.persistPromise}async capturePreview(a){let b=a.accounts.find(a=>"running"===a.status&&a.runtimeSession?.page)||a.accounts.find(a=>"needs_manual"===a.status&&a.manualSession?.page);if(!b)return null;let c=b.runtimeSession?.page||b.manualSession?.page;if(!c)return null;try{let a=await c.screenshot({type:"jpeg",quality:55,fullPage:!1,animations:"disabled",caret:"hide"});return{email:b.email||null,phone:b.phone||null,workerId:b.workerId||null,status:b.status,step:b.currentStep||null,updatedAt:b.updatedAt||s(),imageData:`data:image/jpeg;base64,${a.toString("base64")}`}}catch{return{email:b.email||null,phone:b.phone||null,workerId:b.workerId||null,status:b.status,step:b.currentStep||null,updatedAt:b.updatedAt||s(),imageData:null}}}async runManualFollowup(a,b,c,d,e,f){let g=(async()=>{let c=async()=>{let a=b.manualSession,c=a?.context||d,e=a?.headedBrowser||null;c&&await c.close().catch(()=>null),e&&await e.close().catch(()=>null)};try{let c=await e;if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}this.setAccountStep(b,"exchanging_tokens","Exchanging Kiro callback for OAuth tokens"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:d}=await this.socialExchange({code:c.code,codeVerifier:f,provider:"google"});this.finalizeAccount(b,"success",{connectionId:d.id,step:"connection_saved",message:"Kiro connection saved successfully"}),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){a.cancelRequested?this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}):this.finalizeAccount(b,"failed_exchange",{error:c.message||"Manual assist flow failed during token exchange.",step:"exchange_failed",message:c.message||"Manual assist flow failed during token exchange."}),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{await c(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(g),await this.persistJobSnapshot(a,{forcePreview:!0})}})();a.manualFollowups.add(g)}async processAccount(a,b,c){if(a.cancelRequested||!a.browser)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});let d=this.kiroServiceFactory().createSocialAuthorization("google"),{context:e,page:f}=await O(a.browser,b.proxyUrl),g=(0,m.zZ)(e,f);b.runtimeSession={context:e,page:f};try{this.setAccountStep(b,"preparing_worker",`Worker ${c} is preparing a browser context`),await this.persistJobSnapshot(a,{forcePreview:!0});let h=await this.googleAutomation({page:f,authUrl:d.authUrl,email:b.email,password:b.password,callbackPromise:g,onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})}});if("success"===h.status){this.setAccountStep(b,"exchanging_tokens","Exchanging Kiro callback for OAuth tokens"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:c}=await this.socialExchange({code:h.code,codeVerifier:d.codeVerifier,provider:"google"});this.finalizeAccount(b,"success",{connectionId:c.id,step:"connection_saved",message:"Kiro connection saved successfully"}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0});return}if("needs_manual"===h.status){b.manualSession={context:e,page:f,opened:!1,openedAt:null,rebind:"function"==typeof g?.rebind?g.rebind:null},this.setAccountStep(b,"awaiting_manual","Waiting for manual completion in the browser session"),this.finalizeAccount(b,"needs_manual",{error:h.error,step:"awaiting_manual",message:h.error}),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runManualFollowup(a,b,c,e,g,d.codeVerifier);return}let i=o.has(h.status)?h.status:"failed";this.finalizeAccount(b,i,{error:h.error||"Kiro Google automation failed.",step:i,message:h.error||"Kiro Google automation failed."}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){this.finalizeAccount(b,"failed",{error:c.message||"Unexpected Kiro bulk import failure.",step:"failed",message:c.message||"Unexpected Kiro bulk import failure."}),b.runtimeSession=null,await e.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{b.password=void 0}}async runWorker(a,b){for(;!a.cancelRequested;){let c=this.dequeueAccount(a,b);if(!c)return;await this.processAccount(a,c,b)}}async runJob(a){let b=this.jobs.get(a);if(b)try{b.browser=await this.browserLauncher(b),b.accounts.forEach(a=>{"queued"===a.status&&1===(a.logs||[]).length&&this.setAccountStep(a,"waiting_for_worker","Waiting for a free worker")}),await this.persistJobSnapshot(b,{forcePreview:!1});let a=Math.min(b.concurrency,Math.max(b.accounts.length,1)),c=Array.from({length:a},(a,c)=>this.runWorker(b,c+1));await Promise.allSettled(c),b.manualFollowups.size>0&&await Promise.allSettled([...b.manualFollowups]),b.cancelRequested?(b.status="cancelled",b.accounts.forEach(a=>{("queued"===a.status||"running"===a.status||"needs_manual"===a.status)&&this.finalizeAccount(a,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled before completion"})})):b.status="completed",await this.persistJobSnapshot(b,{forcePreview:!0})}catch(a){b.status="failed",b.error=a.message||"Failed to start Kiro bulk import job.",b.accounts.forEach(a=>{("queued"===a.status||"running"===a.status)&&(this.finalizeAccount(a,"failed",{error:b.error,step:"failed",message:b.error}),a.password=void 0)}),await this.persistJobSnapshot(b,{forcePreview:!0})}finally{if(b.browser){let a=b.browser;b.browser=null;try{let{forceCloseBrowser:b}=await c.e(5949).then(c.bind(c,75949));await b(a)}catch{await a.close().catch(()=>null)}}b.finishedAt=s(),await this.persistJobSnapshot(b,{forcePreview:!0}),z(x(b.jobId,this.storageDir))}}}function S(){return(!globalThis.__kiroBulkImportSingleton&&(globalThis.__kiroBulkImportSingleton={manager:new R}),globalThis.__kiroBulkImportSingleton).manager}},66307:(a,b,c)=>{c.d(b,{parsePlaywrightProxy:()=>d});function d(a){if(!a)return null;let b=String(a).trim();if(!b)return null;try{let a=new URL(b),c=(a.protocol||"http:").replace(/:$/,"")||"http",d={server:`${c}://${a.hostname}${a.port?`:${a.port}`:""}`};return a.username&&(d.username=decodeURIComponent(a.username)),a.password&&(d.password=decodeURIComponent(a.password)),d}catch{return{server:b}}}},71998:(a,b,c)=>{c.d(b,{Fh:()=>d.Fh,L9:()=>d.L9,Mc:()=>d.Mc,OM:()=>d.OM,Pc:()=>d.Pc,Q_:()=>d.Q_,Qu:()=>d.Qu,S8:()=>d.S8,Yd:()=>d.Yd,ZO:()=>d.ZO,c:()=>d.c,createProviderConnection:()=>d.iE,fK:()=>d.fK,fv:()=>d.fv,getProviderConnections:()=>d.getProviderConnections,ho:()=>d.ho,hr:()=>d.hr,i0:()=>d.i0,o5:()=>d.o5,op:()=>d.op,rj:()=>d.updateProviderConnection,uL:()=>d.uL,ui:()=>d.ui,uv:()=>d.uv});var d=c(89718)},82506:(a,b,c)=>{c.d(b,{$K:()=>$,Jl:()=>M,PB:()=>af,Th:()=>ah,i_:()=>X,np:()=>W,rk:()=>ag,zZ:()=>ae});let d='input[type="email"], input[autocomplete="username"], input#identifierId, input[name="identifier"], input[name="Email"], input[type="text"][autofocus], input[aria-label*="Email" i], input[aria-label*="email" i], input[aria-label*="phone" i], input[aria-label*="telepon" i]',e='input[type="password"], input[name="Passwd"], input[name="password"], input[aria-label*="Password" i], input[aria-label*="password" i], input[aria-label*="Sandi" i], input[aria-label*="kata sandi" i]',f=['button:has-text("Next")','button:has-text("Berikutnya")','button:has-text("Continue")','div[role="button"]:has-text("Next")','div[role="button"]:has-text("Berikutnya")',"#identifierNext button","#passwordNext button"],g=["#submit_approve_access","#submit_approve_access button","#confirm",'form#tos_form input[type="submit"]','button[jsname]:has-text("Allow")','button:has-text("Allow")','[role="button"]:has-text("Allow")','input[type="submit"][value="Allow"]','input[type="button"][value="Allow"]','button[jsname]:has-text("Izinkan")','button:has-text("Izinkan")','[role="button"]:has-text("Izinkan")','button:has-text("Continue")','button:has-text("Next")','button:has-text("Yes")','button:has-text("Accept")','button:has-text("Lanjutkan")','button:has-text("Berikutnya")','button:has-text("Setuju")','button:has-text("Saya mengerti")','button:has-text("Oke")','button:has-text("OK")','button:has-text("Got it")','button:has-text("I understand")','div[role="button"]:has-text("Continue")','div[role="button"]:has-text("Next")','div[role="button"]:has-text("Allow")','div[role="button"]:has-text("Lanjutkan")','div[role="button"]:has-text("Berikutnya")','div[role="button"]:has-text("Izinkan")','div[role="button"]:has-text("Setuju")','div[role="button"]:has-text("Saya mengerti")','div[role="button"]:has-text("Oke")','div[role="button"]:has-text("OK")','div[role="button"]:has-text("Got it")','div[role="button"]:has-text("I understand")','input[type="button"][value="Saya mengerti"]','input[type="submit"][value="Saya mengerti"]'],h=['button:has-text("Skip")','button:has-text("Lewati")','button:has-text("Not now")','button:has-text("Bukan sekarang")','button:has-text("No thanks")','button:has-text("Tidak sekarang")','div[role="button"]:has-text("Skip")','div[role="button"]:has-text("Not now")'],i=["#social-google","a#social-google",'a:has-text("Sign up with Google")','a:has-text("Log in with Google")','a:has-text("Login with Google")','a:has-text("Continue with Google")','a:has-text("Sign in with Google")','button:has-text("Sign up with Google")','button:has-text("Log in with Google")','button:has-text("Login with Google")','button:has-text("Continue with Google")','button:has-text("Sign in with Google")','button:has-text("Google")','a:has-text("Google")','div[role="button"]:has-text("Continue with Google")','div[role="button"]:has-text("Login with Google")','div[role="button"]:has-text("Google")','span:has-text("Continue with Google")','span:has-text("Login with Google")','span:has-text("Google")','[aria-label*="Google"]','[data-provider*="google" i]','button:has-text("Login with Google")','button:has-text("Continue with Google")','[data-testid*="google" i]'],j=["#agree-policy-account","#agree-policy","#agree-policy-sso",'input[type="checkbox"][id*="agree" i]','input[type="checkbox"][name*="agree" i]','input[type="checkbox"][id*="policy" i]','input[type="checkbox"][name*="policy" i]','input[type="checkbox"][id*="terms" i]','input[type="checkbox"][name*="terms" i]','.login-checkbox input[type="checkbox"]','[class*="checkbox"] input[type="checkbox"]','[class*="agree"] input[type="checkbox"]','input[type="checkbox"]'],k=['.ui-dialog button:has-text("Confirm")','dialog button:has-text("Confirm")','button:has-text("Confirm")','button:has-text("I agree")','button:has-text("Agree")','button:has-text("同意")','button:has-text("确认")'],l=['button:has-text("Continue")','[role="button"]:has-text("Continue")','button:has-text("Get started")','button:has-text("GET STARTED")','input[type="submit"][value="GET STARTED"]','button:has-text("Start")','button:has-text("Confirm")','button:has-text("Done")','button:has-text("Next")','button:has-text("Skip")','button:has-text("Not now")','button:has-text("Save")','button:has-text("Create")','button:has-text("Enter")','button:has-text("Launch")','button:has-text("Use CodeBuddy")','button:has-text("Go to CodeBuddy")'],m=["select",'[role="combobox"]','.page-region [role="combobox"]',".page-region .t-select",'.page-region [class*="t-select"]','.page-region [class*="select"]',".page-region input[placeholder]",'button:has-text("Region")','[role="button"]:has-text("Region")','button:has-text("Select region")','[role="button"]:has-text("Select region")','button:has-text("Data region")','[aria-label*="region" i]','[placeholder*="region" i]'],n=["text=/^Indonesia$/i","text=/^ID$/i","text=/^Singapore$/i","text=/^SG$/i","text=/^Japan$/i","text=/^JP$/i","text=/^Thailand$/i","text=/^TH$/i","text=/^Global$/i","text=/^International$/i","text=/^United States$/i","text=/^US$/i","text=/^Asia Pacific$/i","text=/^Hong Kong$/i","text=/^Default$/i"],o=[{selector:'input[name*="workspace" i]',value:"Default"},{selector:'input[placeholder*="workspace" i]',value:"Default"},{selector:'input[name*="team" i]',value:"Default"},{selector:'input[placeholder*="team" i]',value:"Default"},{selector:'input[name*="name" i]',value:"Default"},{selector:'input[placeholder*="name" i]',value:"Default"}],p=["wrong password","incorrect password","couldn't find your google account","couldn’t find your google account","enter a valid email","couldn’t sign you in","couldn't sign you in","invalid email or password","password is incorrect"],q=["2-step verification","2-step verification required","verify it’s you","verify it's you","check your phone","confirm it’s you","confirm it's you","recovery email","recovery phone","suspicious sign-in prevented","unusual activity detected","captcha","i'm not a robot","im not a robot","not a robot","recaptcha","select all images","select all squares","try again later","browser or app may not be secure","try using a different browser","couldn’t sign you in","couldn't sign you in","this browser or app may not be secure"],r=["restricted","account has been restricted","account is restricted","account has been suspended","account is suspended","account has been disabled","account is disabled","account has been banned","account is banned","access denied","account blocked","your account has been","violation of terms","terms of service violation","temporarily locked","permanently locked","account locked","akun dibatasi","akun diblokir","akun ditangguhkan"],s=["welcome to your new google account","selamat datang di akun google baru anda","welcome to your new account","selamat datang di akun baru","privacy and terms","privasi dan persyaratan","personalize your google services","personalisasikan layanan google anda","add recovery phone","tambahkan nomor telepon pemulihan","choose your settings","pilih setelan anda"],t=["welcome to your new account","selamat datang di akun baru","your administrator decides which","administrator anda memutuskan layanan","your organisation administrator manages","your organization administrator manages"];function u(a){if(!a||!a.startsWith("kiro://kiro.kiroAgent/authenticate-success"))return null;let b=a.indexOf("?"),c=new URLSearchParams(b>=0?a.slice(b+1):""),d=c.get("code"),e=c.get("state");return d?{callbackUrl:a,code:d,state:e}:null}function v(a){let b="function"==typeof a.frames?a.frames():[];return[a,...b.filter(b=>b!==a.mainFrame?.())]}async function w(a,b){for(let c of v(a))for(let a of b){let b=c.locator(a).first();if(await b.count().catch(()=>0)&&await b.isVisible().catch(()=>!1))return await b.click({timeout:5e3}).catch(()=>null),!0}return!1}async function x(a,b){for(let c of v(a))for(let a of b){let b=c.locator(a).first();if(await b.count().catch(()=>0)){if((await b.scrollIntoViewIfNeeded().catch(()=>null),await b.isVisible().catch(()=>!1)&&await b.isEnabled().catch(()=>!0))&&await b.click({timeout:5e3}).then(()=>!0).catch(()=>!1))return!0}}return!1}async function y(a,b){for(let c of v(a)){let a=c.locator(b).first();if(await a.count().catch(()=>0)&&await a.isVisible().catch(()=>!1))return a}return null}async function z(a,b,{timeout:c=15e3,pollInterval:d=150}={}){let e=Date.now()+c;for(;Date.now()<e;){let c=await y(a,b);if(c)return c;let f=e-Date.now();if(f<=0)break;await new Promise(a=>setTimeout(a,Math.min(d,f)))}return null}function A(a=50){return new Promise(b=>setTimeout(b,a))}async function B(a,{timeout:b=8e3,interval:c=100}={}){let d=Date.now()+b;for(;Date.now()<d;){try{if(await a())return!0}catch{}await A(c)}return!1}function C(a){try{let b=new URL(a).hostname;return"accounts.google.com"===b||b.endsWith(".accounts.google.com")||/^accounts\.google\./i.test(b)}catch{return!1}}async function D(a,{fromUrl:b="",urlMatch:c=null,selector:d=null,timeout:e=8e3}={}){let f=b||a.url?.()||"";return B(async()=>{let b=a.url?.()||"";return!!(c&&("function"==typeof c&&c(b)||c instanceof RegExp&&c.test(b))||b&&b!==f&&!b.startsWith("about:")||d&&await y(a,d))||!1},{timeout:e,interval:80})}async function E(a,b,{timeout:c=15e3}={}){if(!a||null==b)return!1;try{await a.click({timeout:3e3})}catch{}try{if(await a.fill(String(b),{timeout:Math.min(c,8e3)}),await a.inputValue().catch(()=>"")===b)return!0}catch{}try{await a.fill("",{timeout:2e3})}catch{}try{let d=Math.floor(15+20*Math.random());await a.type(String(b),{delay:d,timeout:c})}catch{try{await a.fill(String(b),{timeout:c})}catch{return!1}}let d="";try{d=await a.inputValue()}catch{d=""}return d===b}async function F(a){let b=[];for(let c of v(a))try{b.push(await c.evaluate(()=>document.body?.innerText||""))}catch{}return b.join("\n")}function G(a,b){let c=String(a||"").toLowerCase();return b.some(a=>c.includes(a))}function H(a){try{let b=new URL(a.url());return"accounts.google.com"===b.hostname||b.hostname.endsWith(".accounts.google.com")||/^accounts\.google\./i.test(b.hostname)}catch{return!1}}function I(a){return/grok/i.test(String(a||""))}async function J(a){return!!function(a){try{let b=new URL(a.url());if(b.pathname.startsWith("/not-supported")||b.pathname.includes("/signin/rejected")||b.pathname.includes("/rejected")||"about.google"===b.hostname||b.hostname.endsWith(".about.google"))return!0}catch{}return!1}(a)||G(await F(a).catch(()=>""),["browser or app may not be secure","try using a different browser","couldn't sign you in","couldn’t sign you in","this browser or app may not be secure","browser is not secure"])}function K(a){return!!(a&&a.__zevaiSettled)}async function L(a,b,{maxWaitMs:c=2e4,successPromise:d=null}={}){let e=Date.now(),f="";for(d&&"function"==typeof d.then&&(d.__zevaiSettledHooked||(d.__zevaiSettledHooked=!0,d.then(()=>{d.__zevaiSettled=!0},()=>{d.__zevaiSettled=!0})));Date.now()-e<c;){if(K(d))return b?.("waiting_google_redirect","OAuth callback already received — leaving interstitial wait"),!1;let c=a.url?.()||"",e=String(await F(a).catch(()=>"")).trim(),g=/\/accounts\/SetSID/i.test(c),h=/\/AccountChooser/i.test(c),i=e.length<30;if(!(g||i&&/accounts\.google\./i.test(c))&&!h)return!1;if(c!==f&&(b?.("waiting_google_redirect",`Waiting for Google redirect (url=${c.slice(0,120)} empty=${i})`),f=c),h&&await x(a,["div[data-identifier]","div[data-email]","li[data-identifier]",'div[role="link"]','div[role="button"]'])){b?.("selecting_google_account","Selected account from Google AccountChooser"),await D(a,{timeout:5e3});continue}let j=[a.waitForNavigation({waitUntil:"domcontentloaded",timeout:3e3}).catch(()=>null),A(400)];d&&!K(d)&&j.push(d.then(()=>null).catch(()=>null)),await Promise.race(j)}return!0}function M(a){try{let b=new URL(a.url()).hostname||"";return/codebuddy\.(ai|cn)$/.test(b)||b.endsWith(".codebuddy.ai")||b.endsWith(".codebuddy.cn")||"accounts.x.ai"===b||"auth.x.ai"===b||b.endsWith(".x.ai")||"grok.com"===b||b.endsWith(".grok.com")}catch{return!1}}async function N(a,b){if(!H(a))return!1;let c=await F(a);return!!/wants to access|ingin mengakses|akses ke akun google|allow/i.test(c)&&(await a.evaluate(()=>{let a=document.scrollingElement||document.documentElement||document.body;a&&(a.scrollTop=a.scrollHeight),window.scrollTo(0,document.body?.scrollHeight||document.documentElement?.scrollHeight||0)}).catch(()=>null),await a.waitForTimeout(300),!!await x(a,g)&&(b("approving_google_consent","Approving Google OAuth consent"),await a.waitForTimeout(1e3),!0))}async function O(a,b){let c=String(b||"");if(!G(c,s))return!1;if(await a.evaluate(()=>{let a=document.scrollingElement||document.documentElement||document.body;a&&(a.scrollTop=a.scrollHeight),window.scrollTo(0,document.body?.scrollHeight||document.documentElement?.scrollHeight||0)}).catch(()=>null),await a.waitForTimeout(500),G(c,t)){if(await x(a,g))return await a.waitForTimeout(700),!0;if(await a.evaluate(()=>{let a=[document.getElementById("confirm"),document.querySelector('form#tos_form input[type="submit"]'),document.querySelector('input[type="submit"][value="Saya mengerti"]'),document.querySelector('input[type="submit"][value="I understand"]')].filter(Boolean)[0];return!!a&&(a.scrollIntoView({block:"center"}),a.click(),!0)}).catch(()=>!1)||await a.evaluate(()=>{let a=document.getElementById("tos_form");return!!a&&(a.submit(),!0)}).catch(()=>!1))return await a.waitForTimeout(800),!0}return!!(await x(a,h)||await x(a,g))&&(await a.waitForTimeout(700),!0)}async function P(a){let b=/global|international|singapore|united states|^us$|asia|hong kong|default/i;for(let c of v(a)){let a=c.locator("select"),d=await a.count().catch(()=>0);for(let c=0;c<d;c+=1){let d=a.nth(c),e=await d.isVisible().catch(()=>!1),f=await d.isEnabled().catch(()=>!0);if(!e||!f)continue;let g=await d.evaluate((a,b)=>{let c=RegExp(b,"i"),d=[...a.options].filter(a=>!a.disabled&&""!==a.value),e=d.find(a=>c.test(`${a.label} ${a.textContent} ${a.value}`));return(e||d[0])?.value||""},b.source).catch(()=>"");if(g&&await d.selectOption(g).then(()=>!0).catch(()=>!1))return!0}}return!1}async function Q(a){let b=!1;for(let c of v(a))for(let{selector:a,value:d}of o){let e=c.locator(a).first();if(!await e.count().catch(()=>0))continue;let f=await e.isVisible().catch(()=>!1),g=await e.isEnabled().catch(()=>!0);!(!f||!g||await e.inputValue().catch(()=>""))&&await e.fill(d,{timeout:5e3}).then(()=>!0).catch(()=>!1)&&(b=!0)}return b}async function R(a,b){await b.scrollIntoViewIfNeeded().catch(()=>null);let c=await b.isVisible().catch(()=>!1),d=await b.isEnabled().catch(()=>!0);if(!c||!d)return!1;let e=await b.boundingBox().catch(()=>null);if(!e||e.width<=0||e.height<=0)return!1;let f=e.x+e.width/2,g=e.y+e.height/2;return await a.mouse.move(f,g),await a.mouse.down(),await a.mouse.up(),!0}async function S(a,b,c){for(let d of v(a)){let e=d.locator(b),f=Math.min(await e.count().catch(()=>0),80),g=[];for(let a=0;a<f;a+=1){let b=e.nth(a);if(!await b.isVisible().catch(()=>!1))continue;let c=(await b.innerText({timeout:1e3}).catch(()=>"")||await b.textContent({timeout:1e3}).catch(()=>"")||"").trim();c&&g.push({locator:b,text:c})}for(let b of c){let c=g.find(a=>b.test(a.text));if(c&&await R(a,c.locator).catch(()=>!1))return c.text}if(g[0]&&await R(a,g[0].locator).catch(()=>!1))return g[0].text}return""}async function T(a,b){for(let c of v(a))for(let d of b){let b=c.locator(d),e=Math.min(await b.count().catch(()=>0),20);for(let c=0;c<e;c+=1){let d=b.nth(c);if(await R(a,d).catch(()=>!1))return!0}}return!1}async function U(a,b){if(!M(a)||H(a))return!1;let c=await a.evaluate(async()=>{let a=document.body?.innerText||"";if(!(document.querySelector(".page-region")||/select\s+region|region|country|area|get started|complete/i.test(a)))return null;try{let a=await fetch("https://www.codebuddy.ai/console/login/account",{method:"POST",credentials:"include",headers:{accept:"application/json, text/plain, */*","content-type":"application/json","x-requested-with":"XMLHttpRequest","x-domain":window.location.hostname||"www.codebuddy.ai"},referrer:"https://www.codebuddy.ai/register/user/complete",body:JSON.stringify({attributes:{countryCode:["62"],countryFullName:["Indonesia"],countryName:["ID"]}})}),b=await a.text().catch(()=>""),c=null;try{c=b?JSON.parse(b):null}catch{c={raw:b}}if(a.ok&&(!c||0===c.code||200===c.code||void 0===c.code))return{action:"submitted_via_api"};return{action:"api_failed",status:a.status,code:c?.code,message:c?.msg||c?.message||b||`HTTP ${a.status}`}}catch(a){return{action:"api_failed",message:a?.message||"region submit request failed"}}}).catch(()=>null);return!!c?.action&&("submitted_via_api"===c.action?(b("submitting_codebuddy_region","Submitted CodeBuddy region via account API"),await a.waitForTimeout(1500),!0):(b("codebuddy_region_api_failed",c.message?`CodeBuddy region API submit failed: ${c.message}`:"CodeBuddy region API submit failed"),!1))}async function V(a,b){if(!M(a)||H(a)||!await a.locator(".page-region").first().count().then(Boolean).catch(()=>!1))return!1;let c=[/indonesia|^id$|\u5370\u5ea6\u5c3c\u897f\u4e9a/i,/singapore|^sg$|\u65b0\u52a0\u5761/i,/japan|^jp$|\u65e5\u672c/i,/thailand|^th$|\u6cf0\u56fd/i,/global|international|default/i];if(await T(a,[".page-region [class*='28B894']",".page-region button:has-text('Get started')",".page-region button:has-text('Start')",".page-region button:has-text('Submit')",".page-region button:has-text('Continue')",".page-region [role='button']:has-text('Get started')",".page-region [role='button']:has-text('Start')",".page-region [role='button']:has-text('Submit')",".page-region [role='button']:has-text('Continue')"]))return b("submitting_codebuddy_region","Submitted CodeBuddy region selection"),await a.waitForTimeout(1200),!0;let d=await S(a,"ul.dropdown-section li, .dropdown-section li, [role='option'], .t-select-option, [class*='option']",c);if(d)return b("selecting_codebuddy_region",`Selected CodeBuddy region: ${d}`),await a.waitForTimeout(900),!0;if(!await T(a,[".page-region .t-select",".page-region [class*='t-select']",".page-region [role='combobox']",".page-region input[placeholder]",".page-region [class*='select']",".page-region [class*='cursor-pointer']"]))return!1;b("opening_codebuddy_region_selector","Opening CodeBuddy region selector"),await a.waitForTimeout(600);let e=await S(a,"ul.dropdown-section li, .dropdown-section li, [role='option'], .t-select-option, [class*='option']",c);return e&&(b("selecting_codebuddy_region",`Selected CodeBuddy region: ${e}`),await a.waitForTimeout(900)),!0}async function W(a,b){if(!M(a)||H(a))return!1;if(await U(a,b)||await V(a,b))return!0;for(let c of v(a)){let d=await c.evaluate(()=>{let a=a=>{if(!(a instanceof HTMLElement))return!1;let b=window.getComputedStyle(a);if("hidden"===b.visibility||"none"===b.display||0===Number(b.opacity))return!1;let c=a.getBoundingClientRect();return c.width>0&&c.height>0},b=document.querySelector(".page-region"),c=document.body?.innerText||"";if(!(b||/select\s+region|region|country|area|get started|complete/i.test(c)))return null;let d=a=>{for(let b of(a.scrollIntoView({block:"center",inline:"center"}),["pointerdown","mousedown","pointerup","mouseup","click"]))a.dispatchEvent(new MouseEvent(b,{bubbles:!0,cancelable:!0,view:window,buttons:+!!b.endsWith("down")}))},e=[/indonesia|^id$|\u5370\u5ea6\u5c3c\u897f\u4e9a/i,/singapore|^sg$|\u65b0\u52a0\u5761/i,/japan|^jp$|\u65e5\u672c/i,/thailand|^th$|\u6cf0\u56fd/i,/global|international|default/i],f=b||document.body,g=["button","[role='button']","input[type='submit']",".t-button","[class*='button']","[class*='28B894']"],h=[...f.querySelectorAll(g.join(","))].filter(a).filter(a=>{let b=`${a.innerText||""} ${a.getAttribute("aria-label")||""} ${a.getAttribute("value")||""}`,c=a.getAttribute("class")||"";return/submit|start|continue|confirm|done|get started|complete|\u5b8c\u6210|\u5f00\u59cb|\u786e\u5b9a|\u4e0b\u4e00\u6b65/i.test(b)||c.includes("28B894")});if(h.length)return d(h[0]),{action:"submitted"};let i=["ul.dropdown-section li",".dropdown-section li","[role='option']",".t-select-option","[class*='option']","[class*='dropdown'] li"],j=[...document.querySelectorAll(i.join(","))].filter(a).filter(a=>(a.innerText||a.textContent||"").trim());if(j.length){let a=e.map(a=>j.find(b=>a.test((b.innerText||b.textContent||"").trim()))).find(Boolean)||j[0],b=(a.innerText||a.textContent||"").trim();return d(a),{action:"selected",label:b}}let k=["[role='combobox']",".t-select","[class*='t-select']","[class*='select']","input[placeholder]",".text-sm","[class*='cursor-pointer']"],l=[...f.querySelectorAll(k.join(","))].filter(a).filter(a=>{let b=`${a.innerText||""} ${a.getAttribute("placeholder")||""} ${a.getAttribute("aria-label")||""}`;return/region|country|area|select|placeholder|\u5730\u533a|\u56fd\u5bb6|\u9009\u62e9/i.test(b)||a.matches?.(".t-select,[class*='t-select'],input[placeholder],[class*='select']")});return l.length?(d(l[0]),{action:"opened"}):null}).catch(()=>null);if(d?.action){if("selected"===d.action)return b("selecting_codebuddy_region",`Selected CodeBuddy region${d.label?`: ${d.label}`:""}`),await a.waitForTimeout(700),!0;if("submitted"===d.action)return b("submitting_codebuddy_region","Submitted CodeBuddy region selection"),await a.waitForTimeout(1200),!0;return b("opening_codebuddy_region_selector","Opening CodeBuddy region selector"),await a.waitForTimeout(700),!0}}return!1}async function X(a,b){if(!M(a)||H(a))return!1;let c=await a.evaluate(async()=>{let a=new URL(window.location.href);if(!/\/started\/?$/.test(a.pathname))return null;let b=a.searchParams.get("platform")||"CLI",c=a.searchParams.get("state");if(!c)return null;for(let a of[...new Set([window.location.hostname||"www.codebuddy.ai"].filter(Boolean))]){let d=new URL("/console/auth/login",window.location.origin);d.searchParams.set("platform",b),d.searchParams.set("state",c),d.searchParams.set("domain",a);try{let b=await fetch(d.toString(),{method:"GET",credentials:"include",redirect:"manual",headers:{"x-requested-with":"XMLHttpRequest","X-Domain":a}});if("opaqueredirect"===b.type||b.status>=300&&b.status<400)return{action:"attempted",domain:a,message:"redirected"};let c=await b.text(),e=null;try{e=c?JSON.parse(c):null}catch{e={raw:c}}if(b.ok&&(!e||0===e.code||200===e.code||void 0===e.code))return{action:"authorized",domain:a};if(b.ok)return{action:"attempted",domain:a,code:e?.code,message:e?.msg||e?.message||""}}catch(a){}}return{action:"failed"}}).catch(()=>null);return!!c?.action&&"failed"!==c.action&&("authorized"===c.action?b("authorizing_codebuddy_cli_state","Authorized CodeBuddy CLI login state"):b("authorizing_codebuddy_cli_state",c.message?`Attempted CodeBuddy CLI login state authorization: ${c.message}`:"Attempted CodeBuddy CLI login state authorization"),await a.waitForTimeout(1200),!0)}async function Y(a){try{for(let b of[/continue with google/i,/sign in with google/i,/sign up with google/i,/^google$/i]){let c=a.getByRole("button",{name:b}).first();if(await c.isVisible({timeout:300}).catch(()=>!1))return!0;let d=a.getByRole("link",{name:b}).first();if(await d.isVisible({timeout:200}).catch(()=>!1))return!0}}catch{}for(let b of i)try{let c=a.locator(b).first();if(await c.isVisible({timeout:200}).catch(()=>!1))return!0}catch{}return!1}function Z(a){try{let b=new URL(a.url()).hostname||"";return"accounts.x.ai"===b||"auth.x.ai"===b||b.endsWith(".x.ai")||"grok.com"===b||b.endsWith(".grok.com")}catch{return!1}}async function $(a,b,c){if(!M(a)||H(a))return!1;if(await x(a,k))return b("accepting_provider_privacy_dialog",`Confirmed ${c} privacy or terms dialog`),await a.waitForTimeout(800),!0;if(await X(a,b)||await W(a,b))return!0;if(!Z(a)){if(await P(a))return b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700),!0;if(await x(a,m))return b("opening_provider_region_selector",`Opening ${c} region selector`),await a.waitForTimeout(500),await x(a,n)&&(b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700)),!0;if(await x(a,n))return b("selecting_provider_region",`Selected ${c} region`),await a.waitForTimeout(700),!0;if(await Q(a))return b("filling_provider_onboarding",`Filled ${c} onboarding defaults`),await a.waitForTimeout(500),!0}return!(Z(a)||await Y(a))&&!!await x(a,l)&&(b("continuing_provider_onboarding",`Continuing ${c} onboarding`),await a.waitForTimeout(1e3),!0)}async function _(a,b,{alreadyAuthed:c=!1}={}){if(!Z(a)||c||await Y(a))return!1;let d=await F(a).catch(()=>"");if(/sign out|log out|device authorized|you can close|invalid action/i.test(d)||!(/enter the code shown in your terminal/i.test(d)||/only enter this code if you just initiated/i.test(d)||/sign in to grok/i.test(d)&&/continue/i.test(d)&&!/login with/i.test(d)))return!1;let e=a.url?.()||"",f=!1;try{let b=a.getByRole("button",{name:/^Continue$/i}).first();await b.isVisible({timeout:300}).catch(()=>!1)&&(await b.click({timeout:5e3}),f=!0)}catch{}return f||(f=await x(a,['button[type="submit"]:has-text("Continue")','button:has-text("Continue")'])),!!f&&(b?.("confirming_device_code","Confirmed device user code on xAI"),await D(a,{fromUrl:e,urlMatch:a=>/sign-in|login|oauth/i.test(a)&&a!==e,selector:[...i.split(", ").slice(0,8),'button:has-text("Login with Google")','button:has-text("Login with email")'].join(", "),timeout:1e4}),!0)}async function aa(a){for(let b of[/login with google/i,/log in with google/i,/continue with google/i,/sign up with google/i,/sign in with google/i,/^google$/i]){try{let c=a.getByRole("button",{name:b}).first();if(await c.isVisible({timeout:250}).catch(()=>!1)){if(!await c.isEnabled().catch(()=>!0))continue;return await c.click({timeout:5e3}),!0}}catch{}try{let c=a.getByRole("link",{name:b}).first();if(await c.isVisible({timeout:200}).catch(()=>!1))return await c.click({timeout:5e3}),!0}catch{}}return!1}async function ab(a,b){for(let c of v(a))for(let d of j)try{let e=c.locator(d).first();if(!await e.count().catch(()=>0)||!await e.isVisible().catch(()=>!1))continue;if(await e.isChecked().catch(()=>!1))return!1;if(await e.check({force:!0,timeout:3e3}).then(()=>!0).catch(()=>!1)||await e.click({force:!0,timeout:3e3}).then(()=>!0).catch(()=>!1))return b?.("accepting_provider_terms","Accepted provider terms for Google login"),await B(async()=>{try{let b=a.getByRole("button",{name:/google/i}).first();return await b.isVisible().catch(()=>!1)&&await b.isEnabled().catch(()=>!0)}catch{return!0}},{timeout:2e3,interval:80}),!0}catch{}return!1}async function ac(a,b,{allowGoogleClick:c=!0}={}){if(H(a))return!1;if(await x(a,k))return b("accepting_provider_privacy_dialog","Confirmed provider privacy agreement dialog"),!0;let e=await ab(a,b);if(!c)return e;if(await aa(a)||await x(a,i)){if(b("selecting_google_login","Selecting Google login"),await x(a,k)&&b("accepting_provider_privacy_dialog","Confirmed provider privacy agreement dialog"),await D(a,{urlMatch:a=>C(a),selector:d,timeout:12e3})||H(a))b("google_login_page","Reached Google sign-in after provider SSO");else try{let c=a.context?.(),d=c?.pages?.()||[];for(let a=d.length-1;a>=0;a-=1){let c=d[a],e=c.url?.()||"";if(C(e)){b("google_login_popup","Google sign-in opened in a popup");break}}}catch{}return!0}return e}async function ad(a,b){if(!Z(a)||await Y(a))return!1;for(let c of[/^(Allow|Authorize|Approve|Confirm)$/i,/^(Allow|Authorize|Approve)\b/i])try{let d=a.getByRole("button",{name:c}).first();if(await d.isVisible({timeout:200}).catch(()=>!1)){let a=await d.innerText().catch(()=>"")||"";if(/google/i.test(a))continue;return await d.click({timeout:3e3}),b?.("approving_consent","Approving xAI device authorization"),!0}}catch{}return!1}function ae(a,b,c=9e5){let d,e,f=new Promise((a,b)=>{d=a,e=b}),g=!1,h=new Set,i=new Map,j=setTimeout(()=>{k(null,Error("Timed out waiting for Kiro callback"))},c);function k(a,b=null){if(!g){for(let a of(g=!0,clearTimeout(j),i.values()))for(let b of a)try{b()}catch{}i.clear(),b?e(b):d(a)}}function l(a){let b=u(a||"");return b&&k(b),!!b}function m(a){try{l(a?.url?.()||"");let b="function"==typeof a?.headers?a.headers():null,c=b?.location||b?.Location||"";c&&l(c)}catch{}}function n(a,b){if(!a||h.has(a))return;h.add(a);let c=a=>l(a?.url?.()||""),d=a=>l(a?.url?.()||""),e=a=>l(a?.url?.()||""),f=a=>m(a),i=()=>l(a.url?.()||""),j=()=>{k(null,Error("Browser session closed while waiting for Kiro callback"))};a.on("framenavigated",c),a.on("request",d),a.on("requestfailed",e),a.on("response",f),a.on("domcontentloaded",i),a.on("load",i),a.on("close",j),b.push(()=>{a.off("framenavigated",c),a.off("request",d),a.off("requestfailed",e),a.off("response",f),a.off("domcontentloaded",i),a.off("load",i),a.off("close",j)}),(async()=>{try{if(g)return;let c=a.context?.();if(!c?.newCDPSession)return;let d=await c.newCDPSession(a);await d.send("Network.enable").catch(()=>null);let e=a=>{try{let b=a?.response?.headers||{},c=b.location||b.Location||"";c&&l(c),l(a?.response?.url||"")}catch{}},f=a=>{try{l(a?.request?.url||"")}catch{}};d.on("Network.responseReceived",e),d.on("Network.requestWillBeSent",f),b.push(()=>{try{d.off?.("Network.responseReceived",e)}catch{}try{d.off?.("Network.requestWillBeSent",f)}catch{}d.detach?.().catch(()=>null)})}catch{}})();let n=u(a.url?.()||"");n&&k(n)}function o(a,b){if(g||i.has(a))return;let c=[];i.set(a,c);let d=a=>n(a,c),e=()=>{k(null,Error("Browser context closed while waiting for Kiro callback"))},f=a=>l(a?.url?.()||""),h=a=>l(a?.url?.()||""),j=a=>m(a);a.on("page",d),a.on("close",e),a.on("request",f),a.on("requestfailed",h),a.on("response",j),c.push(()=>a.off("page",d)),c.push(()=>a.off("close",e)),c.push(()=>a.off("request",f)),c.push(()=>a.off("requestfailed",h)),c.push(()=>a.off("response",j)),b&&n(b,c)}return o(a,b),f.rebind=({context:a,page:b}={})=>{a&&o(a,b)},f.abort=(a="Job cancelled")=>{k(null,Error(a))},f}function af(a,b,{prefix:c,timeoutMs:d=9e5}={}){let e,f,g=new Promise((a,b)=>{e=a,f=b}),h=!1,i=new Set,j=new Map,k=setTimeout(()=>{l(null,Error("Timed out waiting for OAuth callback"))},d);function l(a,b=null){if(!h){for(let a of(h=!0,clearTimeout(k),j.values()))for(let b of a)try{b()}catch{}j.clear(),b?f(b):e(a)}}function m(a,b){if(!a||i.has(a))return;i.add(a);let d=a=>{let b=function(a,b){if(!a||!b||!a.startsWith(b))return null;let c=a.indexOf("?"),d=new URLSearchParams(c>=0?a.slice(c+1):""),e=d.get("code"),f=d.get("state");return e?{callbackUrl:a,code:e,state:f}:null}(a||"",c);b&&l(b)},e=a=>d(a?.url?.()||""),f=a=>d(a?.url?.()||""),g=a=>d(a?.url?.()||""),h=()=>d(a.url?.()||"");a.on("framenavigated",e),a.on("request",f),a.on("requestfailed",g),a.on("domcontentloaded",h),a.on("load",h),b.push(()=>{a.off("framenavigated",e),a.off("request",f),a.off("requestfailed",g),a.off("domcontentloaded",h),a.off("load",h)}),d(a.url?.()||"")}function n(a,b){if(h||j.has(a))return;let c=[];j.set(a,c);let d=a=>m(a,c);a.on("page",d),c.push(()=>a.off("page",d)),b&&m(b,c)}return n(a,b),g.rebind=({context:a,page:b}={})=>{a&&n(a,b)},g}async function ag({page:a,authUrl:b,email:c,password:h,successPromise:i,shortTimeoutMs:j=9e4,serviceLabel:k="provider",openingStep:l="opening_google_oauth",openingMessage:m="Opening Google OAuth page",successStep:n="oauth_success_received",successMessage:o="OAuth success received",onStep:s}){let t=Date.now(),u=(a,b)=>{s?.(a,b)},v=a=>({maxWaitMs:a,successPromise:i}),x=0,C=0,K=0,P=!1,Q=0,R=0,S=0,T=I(k)?6e3:18e3,U=I(k)?3e3:8e3,V=I(k)?3e3:8e3,W=I(k),X=W?4e3:25e3,Z=W?120:500;u(l,m),await a.goto(b,{waitUntil:"domcontentloaded",timeout:6e4}),await B(async()=>H(a)||await y(a,'button:has-text("Continue"), button:has-text("Login with Google"), button:has-text("Google")')||await y(a,d),{timeout:W?6e3:12e3,interval:80}),W||await L(a,u,v(8e3));for(let b=0;b<(W?6:2)&&!H(a);b+=1)if(!await _(a,u)){if(await ac(a,u)){if(K=Date.now(),H(a))break;await A(50);continue}await B(async()=>await Y(a)||/enter the code|login with google|continue/i.test(await F(a).catch(()=>"")),{timeout:800,interval:80})||await A(100)}if(W||await L(a,u,v(6e3)),H(a)){P=!0;let b=await z(a,d,{timeout:1e4});b&&(u("entering_email","Entering Google email"),await E(b,c)?(u("submitting_email","Submitting email"),await w(a,f),C=Date.now(),await D(a,{selector:e,timeout:W?8e3:12e3}),W||await L(a,u,v(8e3))):u("email_fill_failed","Could not fill the Google email field; will retry in the polling loop"))}else M(a)&&u("waiting_for_google_sso",`Provider page still open (${(a.url?.()||"").slice(0,80)}) — will keep selecting Google login`);for(;Date.now()-t<j;){let j=await Promise.race([i.then(a=>({kind:"success",result:a})).catch(a=>({kind:"success_error",error:a})),new Promise(a=>setTimeout(()=>a(null),Z))]);if(j?.kind==="success")return u(n,o),{status:"success",...j.result};if(j?.kind==="success_error")return u("oauth_timeout",`Timed out waiting for ${k} authorization`),{status:"failed_timeout",error:j.error?.message||`Timed out waiting for ${k} authorization`};if(await L(a,u,v(W?2500:8e3)))continue;if(await N(a,u)){W?await D(a,{timeout:4e3}):await L(a,u,v(12e3));continue}if(await J(a)){let b=a.url?.()||"";return u("browser_blocked_by_google",`Google blocked this browser (url=${b.slice(0,120)}). Headless Chromium is rejected — use headed mode or Camoufox.`),{status:"failed_browser_blocked",error:'Google blocked the automated browser ("This browser or app may not be secure" / signin rejected). Kiro bulk must use headed Chromium (Xvfb on Linux) or the Camoufox engine — not headless Chrome.'}}let l=await F(a);if(G(l,p))return u("invalid_credentials","Google rejected the supplied email or password"),{status:"failed_invalid_credentials",error:"Google rejected the supplied email or password."};if(G(l,r))return u("account_restricted","Account is restricted, suspended, or banned by the provider"),{status:"failed_restricted",error:"Account is restricted, suspended, or banned. Skipping."};if(G(l,q)){let a=/captcha|recaptcha|not a robot|select all images|select all squares/i.test(l);return u(a?"google_captcha":"manual_assist_required",a?"Google CAPTCHA / bot check":"Google requested CAPTCHA, 2FA, or recovery verification"),{status:"needs_manual",error:a?"Google CAPTCHA (bot check). Not fixed by lowering workers — use headed Chromium+Xvfb or Camoufox, residential proxy, and avoid blocking Google domains. Open manual assist to solve CAPTCHA once.":"Manual assist required in the browser session (CAPTCHA, 2FA, recovery, or suspicious-login challenge)."}}if(await O(a,l)){u("google_onboarding","Accepted Google onboarding or privacy prompt");continue}if(M(a)&&(/rate[_ ]?limit/i.test(l)||/error=rate_limited/i.test(a.url?.()||"")))return u("device_rate_limited","xAI device authorization rate-limited"),{status:"failed",error:"xAI rate-limited device authorization. Wait a few minutes and retry (too many rapid device-code attempts)."};if(M(a)&&/invalid action|invalid[_ ]?code|code (has )?expired|expired code/i.test(l)&&b&&P&&S<3&&Date.now()-R>4e3){S+=1,R=Date.now(),Q=0,u("device_invalid_reopen",`Device page error — reopening auth URL (${S}/3)`),await a.goto(b,{waitUntil:"domcontentloaded",timeout:6e4}).catch(()=>null),await B(async()=>await y(a,'button:has-text("Continue"), button:has-text("Allow"), button:has-text("Authorize")')||await Y(a),{timeout:4e3,interval:80});continue}let m=!!(P&&x);if(await _(a,u,{alreadyAuthed:m}))continue;let s=!m&&(!K||Date.now()-K>V);if(await ac(a,u,{allowGoogleClick:s})){s&&(K=Date.now());continue}if(m&&Date.now()-Q>3e3&&await ad(a,u)){Q=Date.now();continue}if(!await $(a,u,k)){if(H(a)){P=!0;let b=await y(a,e);if(b){let c=Date.now()-x;if(x&&c<T){u("waiting_after_password",`Password already submitted ${Math.round(c/1e3)}s ago — waiting for Google redirect`),await L(a,u,v(W?2e3:6e3));continue}if(u("entering_password","Entering Google password"),await E(b,h)){u("submitting_password","Submitting password");let b=a.url?.()||"";await w(a,f),x=Date.now(),await Promise.race([a.waitForNavigation({waitUntil:"domcontentloaded",timeout:W?6e3:1e4}).catch(()=>null),D(a,{fromUrl:b,timeout:W?6e3:1e4}),i.then(()=>null).catch(()=>null)]),await L(a,u,v(X))}else u("password_fill_failed","Could not fill the Google password field; retrying loop"),await A(100);continue}let g=await y(a,d);if(g){let b=Date.now()-C;if(C&&b<U){u("waiting_after_email",`Email already submitted ${Math.round(b/1e3)}s ago — waiting for password/next screen`),await D(a,{selector:e,timeout:Math.max(200,U-b)});continue}u("entering_email","Entering Google email"),await E(g,c)?(u("submitting_email","Submitting email"),await w(a,f),C=Date.now(),await D(a,{selector:e,timeout:W?6e3:1e4})):(u("email_fill_failed","Could not fill the Google email field; retrying loop"),await A(80));continue}}if((H(a)||P&&x&&!await Y(a))&&await w(a,g)){u("approving_consent",`Approving Google or ${k} consent`),Q=Date.now(),await D(a,{timeout:W?2e3:4e3});continue}if(Math.floor((Date.now()-t)/5e3)!==Math.floor((Date.now()-t-Z)/5e3)){let b=a.url?.()||"",c=String(l||await F(a).catch(()=>"")).slice(0,100).replace(/\s+/g," ");u("waiting_for_next_screen",`Waiting for the next Google or ${k} screen (url=${b.slice(0,100)} body=${c})`)}else u("waiting_for_next_screen",`Waiting for the next Google or ${k} screen`);await A(Z)}}if(await J(a))return u("browser_blocked_by_google","Google blocked browser at end of automation window"),{status:"failed_browser_blocked",error:'Google blocked the automated browser ("This browser or app may not be secure"). Use headed Chromium (Xvfb) or Camoufox engine.'};let aa=a.url?.()||"",ab=String(await F(a).catch(()=>"")).slice(0,120).replace(/\s+/g," ");return u("manual_assist_required",`Flow did not complete ${k} authorization automatically (url=${aa.slice(0,100)} body=${ab})`),{status:"needs_manual",error:`Manual assist required — ${k} authorization did not finish automatically (last url: ${aa.slice(0,140)}). If you see "browser may not be secure", switch to headed Chromium/Camoufox.`}}async function ah({page:a,authUrl:b,email:c,password:d,callbackPromise:e,shortTimeoutMs:f=9e4,onStep:g}){return ag({page:a,authUrl:b,email:c,password:d,successPromise:e,shortTimeoutMs:f,serviceLabel:"Kiro",openingStep:"opening_google_oauth",openingMessage:"Opening Google OAuth page",successStep:"kiro_callback_received",successMessage:"Kiro callback received",onStep:g})}},89718:(a,b,c)=>{c.d(b,{CG:()=>d.CG,Dj:()=>d.Dj,Fh:()=>d.Fh,Iq:()=>d.Iq,K1:()=>d.K1,KJ:()=>d.KJ,KK:()=>d.KK,L:()=>d.L,L9:()=>d.L9,Lh:()=>d.Lh,Mc:()=>d.Mc,NR:()=>d.NR,OM:()=>d.OM,PX:()=>d.PX,Pc:()=>d.Pc,QI:()=>d.QI,Q_:()=>d.Q_,Qu:()=>d.Qu,S8:()=>d.S8,Uv:()=>d.Uv,VT:()=>d.VT,XW:()=>d.XW,Xx:()=>d.Xx,Yd:()=>d.Yd,ZO:()=>d.ZO,bI:()=>d.bI,c:()=>d.c,dK:()=>d.dK,ek:()=>d.ek,fK:()=>d.fK,fv:()=>d.fv,getProviderConnections:()=>d.P,getQuotaSnapshot:()=>d.LF,ho:()=>d.ho,hr:()=>d.hr,i0:()=>d.i0,iE:()=>d.iE,jd:()=>d.jd,mt:()=>d.mt,o5:()=>d.o5,oG:()=>d.oG,op:()=>d.op,p3:()=>d.p3,qd:()=>d.qd,r4:()=>d.r4,uL:()=>d.uL,ui:()=>d.ui,updateProviderConnection:()=>d.rj,uv:()=>d.uv,yF:()=>d.yF,yW:()=>d.yW,yg:()=>d.yg,zP:()=>d.zP,zY:()=>d.zY});var d=c(93999)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=8371,exports.ids=[8371],exports.modules={3662:(a,b,c)=>{c.d(b,{EQ:()=>f,LY:()=>d,O:()=>e,fh:()=>h,t2:()=>i,wf:()=>g});let d={400:{type:"invalid_request_error",code:"bad_request"},401:{type:"authentication_error",code:"invalid_api_key"},402:{type:"billing_error",code:"payment_required"},403:{type:"permission_error",code:"insufficient_quota"},404:{type:"invalid_request_error",code:"model_not_found"},406:{type:"invalid_request_error",code:"model_not_supported"},429:{type:"rate_limit_error",code:"rate_limit_exceeded"},500:{type:"server_error",code:"internal_server_error"},502:{type:"server_error",code:"bad_gateway"},503:{type:"server_error",code:"service_unavailable"},504:{type:"server_error",code:"gateway_timeout"}},e={400:"Bad request",401:"Invalid API key provided",402:"Payment required",403:"You exceeded your current quota",404:"Model not found",406:"Model not supported",429:"Rate limit exceeded",500:"Internal server error",502:"Bad gateway - upstream provider error",503:"Service temporarily unavailable",504:"Gateway timeout"},f={base:2e3,max:3e5,maxLevel:15},g=3e4,h=18e5,i=[{text:"no credentials",cooldownMs:12e4},{text:"request not allowed",cooldownMs:5e3},{text:"improperly formed request",cooldownMs:12e4},{text:"rate limit",backoff:!0},{text:"too many requests",backoff:!0},{text:"quota exceeded",backoff:!0},{text:"capacity",backoff:!0},{text:"overloaded",backoff:!0},{status:401,cooldownMs:12e4},{status:402,cooldownMs:12e4},{status:403,cooldownMs:12e4},{status:404,cooldownMs:12e4},{status:429,backoff:!0}]},39609:(a,b,c)=>{c.d(b,{proxyAwareFetch:()=>r});var d=c(47774),e=c(27910),f=c(41004);let g=globalThis.fetch,h=new Map,i=new Map,j=["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","api2.cursor.sh"],k=["8.8.8.8","8.8.4.4"];function l(a){return null==a?"":String(a).trim()}async function m(a){let b=i.get(a);if(b&&Date.now()<b.expiry)return b.ip;try{let b=await Promise.resolve().then(c.t.bind(c,14985,23)),{promisify:d}=await Promise.resolve().then(c.t.bind(c,28354,23)),e=new b.Resolver;e.setServers(k);let g=d(e.resolve4.bind(e)),h=await g(a);return i.set(a,{ip:h[0],expiry:Date.now()+f.v1.dnsCacheTtlMs}),h[0]}catch(b){return console.warn(`[ProxyFetch] DNS resolve failed for ${a}:`,b.message),null}}function n(a,b){let c,d=l(b);if(!d)return!1;try{c=new URL(a).hostname.toLowerCase()}catch{return!1}return d.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>"*"===a||(a.startsWith(".")?c.endsWith(a)||c===a.slice(1):c===a||c.endsWith(`.${a}`)))}function o(a){let b=l(a);if(!b)return null;try{return new URL(b),b}catch{return`http://${b}`}}async function p(a){let b=o(a);if(!b)return null;if(!h.has(b)){h.size>=f.v1.proxyDispatchersMaxSize&&h.delete(h.keys().next().value);let{ProxyAgent:a}=await Promise.resolve().then(c.t.bind(c,47774,19));h.set(b,new a({uri:b}))}return h.get(b)}async function q(a,b,d){let f=await Promise.resolve().then(c.t.bind(c,55591,23)),g=await Promise.resolve().then(c.t.bind(c,91645,23)),h=f.default??f,i=g.default??g;return new Promise((c,f)=>{let g=new i.Socket;g.connect(443,b,()=>{let b={socket:g,servername:a.hostname,path:a.pathname+a.search,method:d.method||"POST",headers:{...d.headers,Host:a.hostname}},i=h.request(b,a=>{let b={ok:a.statusCode>=200&&a.statusCode<300,status:a.statusCode,statusText:a.statusMessage,headers:new Map(Object.entries(a.headers)),body:e.Readable.toWeb(a),text:async()=>{let b=[];for await(let c of a)b.push(c);return Buffer.concat(b).toString()},json:async()=>JSON.parse(await b.text())};c(b)});i.on("error",f),d.body&&i.write("string"==typeof d.body?d.body:JSON.stringify(d.body)),i.end()}),g.on("error",f)})}async function r(a,b={},c=null){let e="string"==typeof a?a:a.toString(),f=l(c?.vercelRelayUrl);if(f){let a=new URL(e),c={...b.headers,"x-relay-target":`${a.protocol}//${a.host}`,"x-relay-path":`${a.pathname}${a.search}`};return g(f,{...b,headers:c})}let h=function(a,b){if(b?.enabled!==!0&&b?.connectionProxyEnabled!==!0)return null;let c=l(b?.url??b?.connectionProxyUrl);if(!c)return null;let d=l(b?.noProxy??b?.connectionNoProxy);return d&&n(a,d)?null:o(c)}(e,c),i=h?null:o(function(a){let b;if(n(a,process.env.NO_PROXY||process.env.no_proxy))return null;try{b=new URL(a).protocol}catch{return null}return"https:"===b?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy}(e)),k=h||i;if(function(a){try{let b=new URL(a).hostname;return j.some(a=>b.includes(a))}catch{return!1}}(e)){if(k)try{let c=await p(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct bypass: ${a.message}`)}try{let a=new URL(e),c=await m(a.hostname);if(c)return await q(a,c,b)}catch(a){console.warn(`[ProxyFetch] MITM bypass failed: ${a.message}`)}}if(k)try{let c=await p(k);return await (0,d.hd)(a,{...b,dispatcher:c})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct: ${a.message}`)}return g(a,b)}async function s(a,b={}){return r(a,b,null)}globalThis.fetch!==s&&(globalThis.fetch=s)},41004:(a,b,c)=>{c.d(b,{C8:()=>l,DR:()=>k,Uc:()=>h,cI:()=>j,eo:()=>i,gx:()=>d,pH:()=>g,v1:()=>e,xM:()=>f}),c(3662);let d={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,NOT_ACCEPTABLE:406,REQUEST_TIMEOUT:408,RATE_LIMITED:429,SERVER_ERROR:500,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},e={sessionTtlMs:72e5,sessionCleanupIntervalMs:18e5,dnsCacheTtlMs:3e5,proxyDispatchersMaxSize:20},f=6e4,g=6e4,h=64e3,i=32e3,j={429:{attempts:0,delayMs:0},502:{attempts:3,delayMs:3e3},503:{attempts:3,delayMs:2e3},504:{attempts:2,delayMs:3e3}};function k(a){return null==a?{attempts:0,delayMs:2e3}:"number"==typeof a?{attempts:a,delayMs:2e3}:{attempts:a.attempts||0,delayMs:null!=a.delayMs?a.delayMs:2e3}}let l=["Please write a 5-10 word title for the following conversation:"]},48371:(a,b,c)=>{c.d(b,{xM:()=>W,t9:()=>Z,TK:()=>Y,cO:()=>e.cO,VU:()=>ad});var d=c(55511),e=c(53041),f=c(71998),g=c(89718),h=c(20116),i=c(92990),j=c(39609);let k=globalThis.fetch,l=new Set(["a timeout","is cancelled","is complete","number banned, when number already used"]);class m extends Error{constructor(a,{status:b,body:c}={}){super(a),this.name="FiveSimError",this.status=b,this.body=c}}class n extends m{constructor(a){super(`5sim order ${a} timed out waiting for SMS`),this.name="FiveSimTimeoutError",this.orderId=a}}class o extends m{constructor(a,b){super(`5sim order ${a} cancelled: ${b}`),this.name="FiveSimCancelledError",this.orderId=a}}class p extends m{constructor(a){super(`5sim order ${a} number was already used (banned)`),this.name="FiveSimBannedError",this.orderId=a}}class q{constructor({apiKey:a,proxyOptions:b=null}={}){if(!a||"string"!=typeof a||!a.trim())throw new m("5sim API key is required");this.apiKey=a.trim(),this.proxyOptions=b}_headers(a={}){return{Authorization:`Bearer ${this.apiKey}`,Accept:"application/json",...a}}async _get(a,{headers:b,...c}={}){let d=`https://5sim.net/v1${a}`,e=this.proxyOptions?.enabled?j.proxyAwareFetch:k,f=await e(d,{method:"GET",headers:this._headers(b),...c},this.proxyOptions);if(!f.ok){let b=await f.text().catch(()=>"");throw new m(`5sim request to ${a} failed (HTTP ${f.status}): ${b.slice(0,200)}`,{status:f.status,body:b})}let g=await f.text();try{return JSON.parse(g)}catch{if(g&&!g.startsWith("{"))throw new m(`5sim ${a} returned non-JSON: ${g.slice(0,200)}`,{status:f.status,body:g});return null}}async buyNumber({country:a="hongkong",operator:b="any",product:c="codebuddy",allowProductFallback:d=!1}={}){let e="codebuddy"===c&&d?["codebuddy","other"]:[c],f=null;for(let c of e){let g=`/user/buy/activation/${encodeURIComponent(a)}/${encodeURIComponent(b)}/${encodeURIComponent(c)}`;try{let a=await this._get(g);if(!a||!a.id||!a.phone)throw new m(`5sim buyNumber returned unexpected shape: ${JSON.stringify(a).slice(0,200)}`,{body:a});return a}catch(g){f=g;let a=g?.status,b=String(g?.body||g?.message||"").toLowerCase();if(!(d&&"codebuddy"===c&&e.includes("other")&&(400===a||404===a||b.includes("no free")||b.includes("not enough")||b.includes("no product"))))throw g}}throw f||new m("5sim buyNumber failed for all product candidates")}async checkOrder(a){return this._get(`/user/check/${a}`)}async pollCode(a,{timeoutMs:b=9e5,intervalMs:c=6e3,signal:d}={}){let e=Math.max(5e3,c),f=Date.now()+b,g=0;for(;Date.now()<f;){let b;if(d?.aborted)throw new o(a,"aborted by caller");try{b=await this.checkOrder(a)}catch(a){if(a instanceof m&&a.status>=500){if(++g>5)throw a;await s(e);continue}throw a}if(g=0,Array.isArray(b.sms)&&b.sms.length>0){let a=r(b.sms[b.sms.length-1]);if(a)return a}if(b.status&&l.has(b.status)){if("a timeout"===b.status)throw new n(a);if("number banned, when number already used"===b.status)throw new p(a);if("is cancelled"===b.status)throw new o(a,b.status);if("is complete"===b.status){let c=function(a){if(!Array.isArray(a))return null;for(let b=a.length-1;b>=0;b--){let c=r(a[b]);if(c)return c}return null}(b.sms);if(c)return c;throw new m(`5sim order ${a} completed but no SMS code found`,{body:b})}}await s(e)}throw new n(a)}async finishOrder(a){try{return await this._get(`/user/finish/${a}`),!0}catch(b){return console.warn(`[5sim] finishOrder(${a}) failed (best-effort): ${b.message}`),!1}}async cancelOrder(a){try{return await this._get(`/user/cancel/${a}`),!0}catch(b){return console.warn(`[5sim] cancelOrder(${a}) failed (best-effort): ${b.message}`),!1}}async banOrder(a){try{return await this._get(`/user/ban/${a}`),!0}catch(b){return console.warn(`[5sim] banOrder(${a}) failed (best-effort): ${b.message}`),!1}}async getBalance(){try{let a=await this._get("/user/profile");return{balance:a?.balance??null,rating:a?.rating??null}}catch(a){return console.warn(`[5sim] getBalance failed: ${a.message}`),{balance:null,rating:null}}}}function r(a){return a?a.code&&/\d{4,8}/.test(String(a.code))?String(a.code).match(/\d{4,8}/)[0]:a.text?function(a){if(!a)return null;let b=String(a).match(/\b(\d{4,8})\b/);return b?b[1]:null}(a.text):null:null}function s(a){return new Promise(b=>setTimeout(b,a))}let t=["https://www.codebuddy.cn/login/","https://www.codebuddy.cn/login","https://www.codebuddy.cn/register/","https://copilot.tencent.com/login/"],u=["text=手机号","div:has-text('手机号')","span:has-text('手机号')","[class*='phone']:has-text('手机号')","div.kc-phone-tab:has-text('手机号')"],v=["text=手机号","text=其他登录方式","text=微信","#phone-iframe",".login-phone-box"],w="#phone-iframe",x="#phoneNumber",y=".kc-country-option",z=".kc-country-code-text",A="#code",B=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],C=['[class*="avatar"]','[class*="user-info"]','[class*="logout"]',"text=退出登录","text=Logout","text=Sign out"],D=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"];async function E({page:a,phone:b,resolvePhone:c,pollSmsPromise:d,waitForSms:e,onStep:f,phoneFormatter:g=a=>a,timeouts:h={},signal:i=null,isCancelled:j=null}){let k=h.nav??3e4,l=h.action??15e3,m=h.codeWait??9e5,n=h.postSubmit??1e4,o=(a,b)=>f?.(a,b),p=()=>{if(i?.aborted||"function"==typeof j&&j()){let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}};try{var q;let f,h;o("cn_opening_login_page","Opening CodeBuddy CN login page"),p();try{a.setDefaultNavigationTimeout(k),a.setDefaultTimeout(l)}catch{}try{await a.context().route("**/*",a=>{let b=a.request().url();return/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(b)?a.abort():a.continue()})}catch{}let i=null,j=[];for(let b=1;b<=2;b++){p();try{let c=t[(b-1)%t.length];o("cn_nav_attempt",`Navigation attempt ${b}/2 → ${c}`),b>1&&(await a.context().clearCookies().catch(()=>{}),await a.waitForTimeout(800)),await a.goto(c,{waitUntil:"commit",timeout:k}),p(),await a.waitForTimeout(1500),p();let d=await I(a,v,25e3);if(p(),!d){let b=await a.locator("body").innerText().catch(()=>""),d=await a.evaluate(()=>document.documentElement?.outerHTML?.length||0).catch(()=>0),e=a.url();o("cn_spa_not_ready",`SPA not ready after 25s (url=${e}, body=${String(b).slice(0,80)}, html=${d})`),!b&&d<200?(o("cn_proxy_empty_page","Empty page body — proxy may be blocking codebuddy.cn"),j.push({code:"proxy_empty",detail:`empty page via ${c} (html=${d})`})):j.push({code:"spa_timeout",detail:`SPA not ready url=${e} html=${d}`});continue}o("cn_spa_ready","Login SPA ready"),o("cn_selecting_phone_tab","Selecting phone-number tab");let e=await H(a,u,{timeout:12e3});if(e?(await e.click().catch(()=>{}),o("cn_phone_tab_selected","Phone tab selected"),await a.waitForTimeout(800)):o("cn_phone_tab_not_found","Phone tab not found — checking if iframe already present"),o("cn_waiting_for_iframe","Waiting for phone iframe to load"),await a.locator(w).waitFor({state:"attached",timeout:18e3}).catch(()=>{}),i=await F(a)){if(await i.waitForSelector(x,{state:"visible",timeout:15e3}).then(()=>!0).catch(()=>!1)){o("cn_iframe_ready","Phone iframe + #phoneNumber ready");break}o("cn_iframe_empty","Iframe found but #phoneNumber not visible yet"),j.push({code:"iframe_empty",detail:"phone iframe attached but #phoneNumber not visible"}),i=null}else o("cn_iframe_missing",`No #phone-iframe (attempt ${b}/2)`),j.push({code:"iframe_missing",detail:"SPA loaded but #phone-iframe never appeared"})}catch(e){if(e?.code==="JOB_CANCELLED")throw e;let a=String(e?.message||e||"");o("cn_nav_retry",`Navigation attempt ${b}/2 failed: ${a.slice(0,120)}`);let c=/timeout|exceeded|ETIMEDOUT|net::ERR/i.test(a),d=/ERR_PROXY|ERR_TUNNEL|ERR_CONNECTION|NS_ERROR_PROXY|proxy/i.test(a);j.push({code:d?"proxy_network":c?"nav_timeout":"nav_error",detail:a.slice(0,160)})}}if(!i)return{status:"failed",error:function(a=[],b=2){let c=a.map(a=>a.code),d=a[a.length-1],e="Fix: use a live residential CN proxy (proxyPoolMode=single), concurrency 1, then retry. 5sim is not charged until the form loads.";return c.includes("proxy_empty")||c.includes("proxy_network")?`CodeBuddy CN login page empty/blocked via proxy after ${b} attempts (${d?.detail||"proxy blackhole"}). ${e}`:c.includes("nav_timeout")?`CodeBuddy CN navigation timed out after ${b} attempts (${d?.detail||"goto timeout"}). Proxy is too slow or dead. ${e}`:c.includes("spa_timeout")?`CodeBuddy CN SPA did not boot after ${b} attempts (${d?.detail||"no login UI"}). Proxy/CDN may be filtering JS. ${e}`:c.includes("iframe_missing")||c.includes("iframe_empty")?`CodeBuddy CN page opened but phone form iframe never appeared after ${b} attempts (${d?.detail||"no #phone-iframe"}). Site layout change or half-loaded SPA — retry with another CN exit IP. ${e}`:c.includes("nav_error")&&d?.detail?`CodeBuddy CN phone form failed after ${b} attempts: ${d.detail}. ${e}`:`Could not load CodeBuddy CN phone form after ${b} attempts (${d?.code||"unknown"}: ${d?.detail||"proxy/SPA"}). ${e}`}(j,2)};await i.waitForSelector("#kc-form-login",{timeout:l}).catch(()=>{}),await i.waitForSelector(x,{state:"visible",timeout:l}).catch(()=>{});let r=b;if("function"==typeof c&&(o("cn_ordering_after_form","Login form ready — ordering 5sim number now (not before nav)"),r=await c()),!r)return{status:"failed",error:"No phone number available (resolvePhone/phone missing)"};let s=g(r),{countryCode:y,localNumber:z}=(q=s,(!(h=String(q).replace(/[\s\-()]/g,"")).startsWith("+")&&/^\d+$/.test(h)&&(h="+"+h),h.startsWith("+852"))?{countryCode:"+852",localNumber:h.slice(4)}:h.startsWith("+86")?{countryCode:"+86",localNumber:h.slice(3)}:h.startsWith("+1")?{countryCode:"+1",localNumber:h.slice(2)}:{countryCode:"",localNumber:h.replace(/^\+/,"")});o("cn_selecting_country",`Selecting country code ${y} for phone ${s}`),await G(i,y,l,o),o("cn_entering_phone",`Entering phone number: ${z}`);let B=i.locator(x).first();try{await B.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}await J(B,z),o("cn_phone_entered",`Phone number entered: ${z}`);try{let b=a.locator(".t-checkbox").last();await b.isVisible({timeout:3e3}).catch(()=>!1)&&(await b.click().catch(()=>{}),o("cn_agreement_checked","Agreement checkbox checked"))}catch{}o("cn_clicking_send_code","Clicking send SMS code button");let C=i.locator("input.btn-lg.code-btn").first(),D=!1;try{await C.waitFor({state:"visible",timeout:5e3}),D=!0}catch{let a=i.locator(".code-btn").first();try{await a.waitFor({state:"visible",timeout:5e3}),D=!0}catch{D=!1}}if(!D)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};await C.click().catch(()=>{}),o("cn_send_code_clicked","Send code button clicked"),await i.waitForSelector(A,{state:"visible",timeout:5e3}).catch(()=>{});let E=await R(i);if(E)return{status:"failed",error:`Form error after sending code: ${E}`};o("cn_waiting_for_sms","Waiting for SMS verification code from 5sim (timer starts now)");try{let a;if("function"==typeof e)a=Promise.resolve().then(()=>e());else if(d)a=d;else throw Error("No waitForSms/pollSmsPromise provided");let b=new Promise((a,b)=>setTimeout(()=>b(Error("Timed out waiting for SMS code")),m));f=await Promise.race([a,b])}catch(a){if(a&&"FiveSimTimeoutError"===a.name)throw a;return{status:"failed",error:`Failed to receive SMS code: ${a.message}`}}if(!f)return{status:"failed",error:"Received empty SMS code from 5sim"};o("cn_sms_received",`SMS code received: ${f}`),o("cn_entering_code","Entering SMS verification code");let K=i.locator(A).first();try{await K.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}await J(K,f),o("cn_code_entered","Verification code entered");let L=Math.max(n,12e3),U=!1;for(let b=0;b<2;b++){o("cn_submitting",`Clicking submit button (attempt ${b+1}/2)`);let c=await F(a);if(!c){let b=await M(a,{timeoutMs:5e3,reportStep:o});if(b.ok)return o("cn_session_cookies",`Keycloak session after iframe detach (${b.cookie})`),{status:"success"};return{status:"failed",error:"Lost phone iframe after submit"}}if(await c.locator(x).first().isVisible({timeout:3e3}).catch(()=>!1)&&b>0){o("cn_re_entering_after_refresh",`Re-entering phone + code after refresh (retry ${b})`),await G(c,y,l,o);let d=c.locator(x).first();await J(d,z);try{let b=a.locator(".t-checkbox").first();await b.isVisible({timeout:2e3}).catch(()=>!1)&&await b.click().catch(()=>{})}catch{}let e=c.locator(A).first();await e.isVisible({timeout:3e3}).catch(()=>!1)&&await J(e,f)}if(await N(c,l),o("cn_submitted",`Registration form submitted (attempt ${b+1})`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1e3),c=await F(a)||c,await Q(c)){if(b>=1)return{status:"failed",error:"Account restricted (账号访问受限) after submit. Datacenter/VPS IP is usually blocked — use a residential CN proxy pool (proxyPoolMode=single) and retry."};o("cn_account_restricted",`Account restricted (attempt ${b+1}) — refreshing page and retrying`),await a.reload({waitUntil:"commit",timeout:k}).catch(()=>{}),await I(a,v,12e3);let c=await H(a,u,{timeout:8e3});c&&(await c.click().catch(()=>{}),await a.locator(w).waitFor({state:"attached",timeout:8e3}).catch(()=>{}));continue}if(o("cn_checking_captcha","Checking for captcha"),await S(a,c,3e3))return o("cn_captcha_detected","Captcha appeared during registration — manual assist needed"),{status:"needs_manual",error:"A captcha appeared during registration. Please complete it manually in the opened browser window.",captcha:!0};let d=await R(c);if(d)return{status:"failed",error:`Form error after submit: ${d}`};o("cn_waiting_session",`Waiting up to ${Math.round(L/1e3)}s for Keycloak session cookies`);let e=await M(a,{timeoutMs:L,reportStep:o,alsoCheckFrame:()=>F(a)});if(e.ok)return o("cn_session_cookies",`Keycloak session cookies present (${e.cookie}) — registration success`),{status:"success"};if(await O(a)&&b<1){o("cn_submit_no_effect","Login form still visible after submit — retrying");continue}o("cn_session_nudge","No session yet — navigating to home to complete OIDC handoff"),await a.goto("https://www.codebuddy.cn/",{waitUntil:"domcontentloaded",timeout:k}).catch(()=>{}),await a.waitForTimeout(2e3);let g=await M(a,{timeoutMs:1e4,reportStep:o});if(g.ok)return o("cn_session_cookies",`Keycloak session after home nudge (${g.cookie})`),{status:"success"};U=!0;break}if(!U)return o("cn_submit_retries_exhausted","Account restricted after 2 retries — needs manual"),{status:"needs_manual",error:"Account restricted after 2 refresh retries. Please try with a different VPN/proxy or complete manually."};o("cn_confirming_success","Confirming registration success");let V=await M(a,{timeoutMs:5e3});if(V.ok)return o("cn_registration_success",`Phone registration completed (Keycloak session: ${V.cookie})`),{status:"success"};if(await T(a,i,1e4))return o("cn_registration_success","Phone registration completed successfully (UI markers)"),{status:"success"};let W=await P(a);return o("cn_success_unconfirmed",`No Keycloak session after submit — ${W.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${W.summary}). Complete login in the headed browser or retry with a fresh China proxy.`}}catch(a){if(a&&"FiveSimTimeoutError"===a.name)throw a;return o("cn_automation_error",`Phone registration automation error: ${a.message}`),{status:"failed",error:a.message||"Unexpected error during phone registration"}}}async function F(a){try{await a.locator(w).waitFor({state:"attached",timeout:5e3});let b=await a.locator(w).elementHandle({timeout:2e3});if(b){let a=await b.contentFrame();if(a)return a}}catch{}for(let b of a.frames()){let a=b.url();if(a.includes("codebuddy.cn/auth/realms/copilot")||a.includes("protocol/openid-connect"))return b}return null}async function G(a,b,c,d){if(!b)return;let e=Math.min(Number(c)||15e3,1e4),f=async()=>{let c=a.locator(z).first(),f=String(await c.textContent({timeout:3e3}).catch(()=>"")).trim();if(f===b)return void d?.("cn_country_already_selected",`Country code already ${b}`);d?.("cn_opening_country_dropdown",`Opening country dropdown (current: ${f}, target: ${b})`);let g=a.locator(".kc-country-selector").first();for(let c of(await g.waitFor({state:"visible",timeout:Math.min(e,5e3)}),await g.click({timeout:3e3}).catch(()=>{}),await a.locator(y).first().waitFor({state:"visible",timeout:3e3}).catch(()=>{}),({"+852":["中国香港","香港","Hong Kong","+852"],"+86":["中国大陆","中国","China","+86"],"+853":["中国澳门","澳门","Macau","+853"],"+886":["中国台湾","台湾","Taiwan","+886"]})[b]||[b]))for(let e of[a.locator(`${y}:has-text("${c}")`).first(),a.getByText(c,{exact:!1}).first()]){if(!await e.isVisible({timeout:1500}).catch(()=>!1))continue;let f=await e.textContent({timeout:1500}).catch(()=>c);await e.click({timeout:2e3}).catch(()=>{}),await a.locator(z).filter({hasText:b}).first().waitFor({state:"visible",timeout:2e3}).catch(()=>{}),d?.("cn_country_selected",`Country selected: ${String(f||c).trim()}`);return}d?.("cn_country_not_found",`Country code ${b} not found in dropdown; using default`),await a.locator("body").click({timeout:1e3}).catch(()=>{})};try{await Promise.race([f(),new Promise((a,b)=>{let c=setTimeout(()=>b(Error(`selectCountry timed out after ${e}ms`)),e);"function"==typeof c.unref&&c.unref()})])}catch(a){d?.("cn_country_select_error",`Country selection error: ${a.message}`)}}async function H(a,b,{timeout:c=1e4}={}){for(let d of b)try{let b=a.locator(d).first();return await b.waitFor({state:"visible",timeout:Math.min(c,5e3)}),b}catch{}return null}async function I(a,b,c=15e3){let d=Date.now()+c;for(;Date.now()<d;){for(let c of b)try{let b=a.locator(c).first();if(await b.isVisible().catch(()=>!1))return!0}catch{}await new Promise(a=>setTimeout(a,250))}return!1}async function J(a,b){try{return await a.click(),await a.fill(""),await a.fill(b),!0}catch{try{return await a.click(),await a.press("Control+a"),await a.type(b,{delay:50}),!0}catch{return!1}}}let K=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];function L(a=[]){for(let b of K)if(a.some(a=>a.name===b))return b;let b=a.find(a=>a.name.startsWith("KEYCLOAK_")&&!/locale|theme|restart/i.test(a.name));return b?.name||null}async function M(a,{timeoutMs:b=2e4,reportStep:c,alsoCheckFrame:d}={}){let e=Date.now()+b,f=0;for(;Date.now()<e;){let b=await a.context().cookies().catch(()=>[]),g=L(b);if(g)return{ok:!0,cookie:g,cookies:b};try{let c=a.url();if(c&&!c.includes("/login")&&!c.includes("/auth/realms")){let a=b.find(a=>/^(access_token|cb_token|codebuddy)/i.test(a.name)||"token"===a.name&&a.domain?.includes("codebuddy"));if(a)return{ok:!0,cookie:a.name,cookies:b}}}catch{}if(d){let a=await d().catch(()=>null);if(a){if(await Q(a))return{ok:!1,cookies:b,reason:"restricted"};let c=await R(a);if(c)return{ok:!1,cookies:b,reason:`form_error:${c}`}}}if(c&&Date.now()-f>4e3){f=Date.now();let a=Math.max(0,Math.round((e-Date.now())/1e3));c("cn_waiting_session",`Still waiting for Keycloak session… ${a}s left`)}await a.waitForTimeout(500)}return{ok:!1,cookies:await a.context().cookies().catch(()=>[])}}async function N(a,b=15e3){let c=a.locator("#kc-login").first();try{await c.waitFor({state:"visible",timeout:b}),await c.click({timeout:5e3}).catch(()=>{})}catch{}try{await a.evaluate(()=>{let a=document.querySelector("#kc-form-login")||document.querySelector("form");if(a)if("function"==typeof a.requestSubmit){let b=a.querySelector("#kc-login")||a.querySelector('[type="submit"]');b?a.requestSubmit(b):a.requestSubmit()}else a.submit()})}catch{await a.locator(A).first().press("Enter").catch(()=>{})}}async function O(a){let b=await F(a);return!!b&&b.locator(x).first().isVisible({timeout:1500}).catch(()=>!1)}async function P(a){let b="";try{b=a.url()}catch{b="(unknown)"}let c=(await a.context().cookies().catch(()=>[])).map(a=>a.name).slice(0,20).join(",")||"(none)",d="";try{d=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim().slice(0,120))}catch{d=""}let e=await F(a),f="no-iframe";if(e)try{f=(await e.url()).slice(0,80)}catch{f="iframe-detached"}return{summary:`url=${b.slice(0,60)} cookies=[${c}] frame=${f}${d?` text="${d}"`:""}`,url:b,cookieNames:c,bodySnippet:d}}async function Q(a){try{let b=await a.evaluate(()=>document.body?.innerText||"");if(b.includes("账号访问受限")||b.includes("安全策略限制")||b.includes("访问受限"))return!0}catch{}return!1}async function R(a){for(let b of D)try{let c=a.locator(b).first();if(await c.isVisible({timeout:1500}).catch(()=>!1)){let a=await c.textContent().catch(()=>""),b=String(a).trim();if(b&&b.length>1)return b}}catch{}try{let b=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim());for(let a of["验证码错误","验证码已过期","验证码无效","请输入正确的验证码","手机号格式","发送过于频繁","Invalid","incorrect"])if(b.includes(a)){let c=b.indexOf(a);return b.slice(Math.max(0,c-10),c+a.length+40).trim()}}catch{}return null}async function S(a,b,c=5e3){for(let b of B)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}if(b)for(let a of B)try{let d=b.locator(a).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}return!1}async function T(a,b,c=15e3){try{let b=await a.context().cookies().catch(()=>[]);if(L(b))return!0}catch{}for(let b of C)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}try{let b=a.url(),c=await a.context().cookies().catch(()=>[]),d=new Set(c.map(a=>a.name));if(b&&!b.includes("/login")&&!b.includes("/auth/realms")&&(d.has("qcloud_uid")||d.has("qcmainCSRFToken"))&&!d.has("login_risk_state")&&!await O(a).catch(()=>!1))return!0}catch{}return!1}var U=c(40891),V=c(75949);let W=200,X=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||72e4,Y=new Set(["hongkong","china","any"]),Z="hongkong";function $(a){return String(a||"").trim()}async function _({apiKey:a,phone:b,region:d,fiveSimOrderId:e,account:f}){let{createProviderConnection:g}=await Promise.resolve().then(c.bind(c,71998)),h={provider:"codebuddy-cn",authType:"apikey",apiKey:a,accessToken:a,name:b||`5sim-${e}`,email:b||`5sim-${e}`,providerSpecificData:{domain:"www.codebuddy.cn",phoneNumber:b,fiveSimOrderId:e,region:d,automation:"5sim-phone-bulk"},testStatus:"active"};return{connection:await g(h)}}class aa extends e.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=U.cT,pollToken:d=U.ZV,fetchLoginAccountFn:e=U.w8,saveConnection:f=_,fiveSimClientFactory:g=ab,phoneAutomation:h=E,phoneFormatter:j=$,pollIntervalMs:k=i.ne.pollInterval,storageName:l="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{launchBulkImportBrowser:b}=await Promise.resolve().then(c.bind(c,75949)),d=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null,e=process.env.ZEVAI_CN_HEADLESS,f="linux"===process.platform;return("0"===e||"false"===e)&&(f=!1),("1"===e||"true"===e)&&(f=!0),b({engine:a?.engine||"camoufox",proxyUrl:d,headless:f,windowSize:{width:900,height:700}})}),storageName:l}),this.requestDeviceCode=b,this.pollToken=d,this.fetchLoginAccount=e,this.saveConnection=f,this.fiveSimClientFactory=g,this.phoneAutomation=h,this.phoneFormatter=j,this.pollIntervalMs=k}async startJob({count:a,concurrency:b,engine:g,proxyPoolMode:i,proxyPoolId:j,region:k}){let l=Number.parseInt(a,10);if(!Number.isFinite(l)||l<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(l>W)throw Object.assign(Error(`Count exceeds maximum of ${W}`),{error:`Count exceeds maximum of ${W}`});let m=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(m)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${m.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${m.jobId}). Cancel it or wait before starting again.`});let n=Y.has(k)?k:Z,o=[];if("all"===i)o=(await (0,f.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===i&&j){let a=await (0,f.hr)(j);a?.isActive&&a?.proxyUrl&&(o=[a.proxyUrl])}let p=(0,d.randomUUID)(),q=(0,e.kF)(),{normalizeBulkImportEngine:r}=await Promise.resolve().then(c.bind(c,75949)),s=g?r(g):"camoufox",t={jobId:p,status:"running",concurrency:function(a){let b=function(){try{let{totalMemGb:a}=(0,h.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}()?1:8;if((0,h.uT)(a))return Math.min(b,Math.max(1,(0,h.q)()));let c=Number.parseInt(a,10);return Number.isFinite(c)?Math.min(b,Math.max(1,c)):Math.min(b,1)}(b),engine:s,proxyPoolMode:i||"none",proxyUrls:o,region:n,createdAt:q,startedAt:q,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:Array.from({length:l},(a,b)=>({line:b+1,region:n,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,proxyUrl:null,abortController:new AbortController,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:q,logs:[(0,e.hn)("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(p,t),this.latestJobId=p,await this.persistJobSnapshot(t,{forcePreview:!1}),this.runJob(p),ac(t)}getJob(a){let b=this.jobs.get(a);return b?ac(b):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),ac(b,{preview:b.lastPreview||null})):null}async processAccount(a,b,c){if(a.cancelRequested||!a.browser)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});let d=null,f=null,h=!1,i=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let j=(await (0,g.mt)()).fiveSimApiKey;if(!j||!j.trim()){this.finalizeAccount(b,"failed",{error:"5sim API key not configured. Set it in the automation modal or dashboard settings.",step:"failed",message:"5sim API key not configured"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}d=this.fiveSimClientFactory({apiKey:j,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0});let k=await (0,e.go)(a.browser,b.proxyUrl);i=k.context;let l=k.page;if(b.runtimeSession={context:i,page:l},a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"registering","Running phone registration on CodeBuddy CN"),await this.persistJobSnapshot(a,{forcePreview:!0});try{l.setDefaultTimeout(2e4),l.setDefaultNavigationTimeout(45e3)}catch{}let m=null,n=new Promise((a,b)=>{m=setTimeout(()=>{b(Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(X/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"}))},X),"function"==typeof m.unref&&m.unref()});try{c=await Promise.race([this.phoneAutomation({page:l,signal:b.abortController?.signal,isCancelled:()=>!0===a.cancelRequested,resolvePhone:async()=>{if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"ordering_number",`Form ready — ordering ${a.region} phone from 5sim (single buy)`),await this.persistJobSnapshot(a,{forcePreview:!0});let c=await d.buyNumber({country:a.region,product:"codebuddy",allowProductFallback:!1});return f=c.id,b.phone=c.phone,b.fiveSimOrderId=c.id,b.fiveSimActivationId=c.id,this.setAccountStep(b,"number_ordered",`Phone number ordered: ${c.phone} (1 buy, no re-order)`),await this.persistJobSnapshot(a,{forcePreview:!0}),c.phone},waitForSms:async()=>{if(!f)throw Error("Cannot poll SMS — no 5sim order id");this.setAccountStep(b,"sms_poll_started","SMS poll started (full 90s window after send-code)"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await d.pollCode(f,{timeoutMs:9e4,signal:b.abortController?.signal});return h=!0,c},onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})},phoneFormatter:this.phoneFormatter}),n])}finally{m&&clearTimeout(m)}if("failed"===c.status){let e=c.error||"Phone registration failed before submit";this.finalizeAccount(b,"failed",{error:e,step:"failed",message:e}),d&&f&&(h?await d.finishOrder(f):await d.cancelOrder(f)),b.runtimeSession=null,await i.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0});return}await this.captureApiKey(a,b,i,l,d,f);return}catch(g){let c=g instanceof n,e=c?"SMS OTP not received within 90s — number banned":g.message||"Unexpected CodeBuddy CN bulk import failure";if(this.finalizeAccount(b,"failed",{error:e,step:c?"sms_timeout":"failed",message:e}),d&&f&&(h?await d.finishOrder(f):c?await d.banOrder(f):await d.cancelOrder(f)),b.runtimeSession=null,i&&await i.close().catch(()=>null),(g?.code==="CN_ACCOUNT_HARD_TIMEOUT"||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,V.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id";try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let h=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},i=a=>a.has("KEYCLOAK_IDENTITY")||a.has("KEYCLOAK_SESSION")||a.has("KEYCLOAK_IDENTITY_LEGACY")||a.has("KEYCLOAK_SESSION_LEGACY"),j=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken"),k=async()=>d.evaluate(async()=>{try{let a=await fetch("/console/accounts",{credentials:"include",headers:{Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn"}}),b=await a.json().catch(()=>null);return{status:a.status,data:b}}catch(a){return{status:0,error:a?.message||String(a)}}}).catch(()=>null),l=a=>a?.data?.data?.accounts||a?.data?.accounts||[],m=["https://www.codebuddy.cn/","https://www.codebuddy.cn/login/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],n=[],o=null,p=!1;for(let c=0;c<8;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await h(),f=i(e.names),g=j(e.names),q=m[Math.min(c,m.length-1)];if(0===c||2===c||4===c||6===c?(this.setAccountStep(b,"waiting_session",`OIDC handoff attempt ${c+1}/8 → ${q} (cookies: ${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await d.goto(q,{waitUntil:"domcontentloaded",timeout:25e3}).catch(()=>null),await d.waitForTimeout(1500)):await d.waitForTimeout(1e3),c>=2&&!String(d.url()||"").includes("/console")&&(await d.goto("https://www.codebuddy.cn/console",{waitUntil:"domcontentloaded",timeout:25e3}).catch(()=>null),await d.waitForTimeout(1e3)),o=await k(),n=l(o),o?.status===200&&Array.isArray(n)&&n.length>0){p=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${n.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${o?.status||0}) — retry ${c+1}/8`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!p||!Array.isArray(n)||0===n.length){let a=await h();throw Error(`Console accounts unavailable after login (HTTP ${o?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}) — session not accepted for API key`)}let q=g,r=n.find(a=>a?.lastLogin)||n[0];r?.type&&"personal"!==r.type&&r.enterpriseId&&(q=r.enterpriseId),this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${q})`),await this.persistJobSnapshot(a,{forcePreview:!0});let s=async a=>d.evaluate(async({enterpriseId:a})=>{let b=await fetch("/console/api/client/v1/api-keys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:`zevai-router-${Date.now()}`,expire_in_days:365,user_enterprise_id:a})}),c=await b.json().catch(()=>null);return{ok:b.ok,status:b.status,data:c}},{enterpriseId:a}),t=await s(q).catch(()=>null);t&&t.ok||(this.setAccountStep(b,"retrying_api_key","Retrying API key creation from profile/keys"),await this.persistJobSnapshot(a,{forcePreview:!0}),await d.goto("https://www.codebuddy.cn/profile/keys",{waitUntil:"domcontentloaded",timeout:45e3}).catch(()=>null),await d.waitForTimeout(2500),t=await s(q).catch(()=>null)),t&&t.ok||q===g||(t=await s(g).catch(()=>null));let u=t?.status;if(!t?.ok&&(401===u||403===u||0===u||!t)){for(let c of(this.setAccountStep(b,"retrying_api_key","API key 401/403 — re-running OIDC handoff then retry"),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/login/","https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await d.goto(c,{waitUntil:"domcontentloaded",timeout:45e3}).catch(()=>null),await d.waitForTimeout(2e3);t=await s(g).catch(()=>null)}let v=t?.data?.code;if(!t||!t.ok||!t.data||0!==v&&200!==v&&void 0!==v)throw Error(`API key creation failed (HTTP ${t?.status??"no-response"}, code=${v??"n/a"}): ${JSON.stringify(t?.data??null).slice(0,200)}`);let w=t.data?.data||t.data,x=w?.apiKey||w?.key||w?.token||w?.secret||w?.api_key||("string"==typeof w?w:null)||t.data.apiKey||t.data.key||t.data.token||t.data.secret;if(!x||"string"!=typeof x)throw Error(`API key response did not contain a key field: ${JSON.stringify(t.data).slice(0,300)}`);this.setAccountStep(b,"api_key_created","API key created successfully"),await this.persistJobSnapshot(a,{forcePreview:!0}),this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:y}=await this.saveConnection({apiKey:x,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await e.finishOrder(f),this.finalizeAccount(b,"success",{connectionId:y.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await c.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(g){this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${g.message}`,step:"awaiting_manual",message:`Registration done, API key capture failed: ${g.message}`}),await e.finishOrder(f).catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runCnManualFollowup(a,b,b.workerId,c,d,e,f)}}async runCnManualFollowup(a,b,c,d,e,f,g){let h=(async()=>{let c=async()=>{let a=b.manualSession,c=a?.context||d,e=a?.headedBrowser||null;c&&await c.close().catch(()=>null),e&&await e.close().catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let c=Date.now()+9e5,d=null;for(;Date.now()<c&&!a.cancelRequested;){await new Promise(a=>setTimeout(a,1e4));try{if(!e.url().includes("codebuddy.cn"))continue;let a=await e.evaluate(async()=>{let a=await fetch("/console/api/client/v1/api-keys",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",body:JSON.stringify({name:"zevai-router-manual-"+Date.now(),expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),b=await a.json().catch(()=>null);return{ok:a.ok,status:a.status,data:b}});if(a?.ok&&a.data){let b=a.data?.data||a.data;if((d=b?.apiKey||b?.key||b?.token||b?.secret||b?.api_key||("string"==typeof b?b:null))&&"string"==typeof d)break}}catch{}}if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(!d)throw Error("Manual assist timed out — could not capture API key");this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection (manual)"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:f}=await this.saveConnection({apiKey:d,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:f.id,step:"connection_saved",message:`CodeBuddy CN connection saved via manual assist (phone: ${b.phone||"N/A"})`}),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){a.cancelRequested?this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}):this.finalizeAccount(b,"failed",{error:c.message||"Manual assist flow failed",step:"failed",message:c.message||"Manual assist flow failed"}),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{await c(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(h),await this.persistJobSnapshot(a,{forcePreview:!0})}})();a.manualFollowups.add(h)}cancelJob(a){let b=this.jobs.get(a);if(!b)return null;for(let a of(b.cancelRequested=!0,b.accounts)){a.abortController&&!a.abortController.signal.aborted&&a.abortController.abort();let b=a.runtimeSession?.context;b&&b.close().catch(()=>null),a.runtimeSession=null,a.manualSession=null}if(b.browser){let a=b.browser;b.browser=null,(0,V.forceCloseBrowser)(a).catch(()=>null)}return"queued"===b.status&&(b.status="cancelled",b.finishedAt=(0,e.kF)(),b.accounts.forEach(a=>{"queued"===a.status&&(a.status="cancelled")})),this.persistJobSnapshot(b,{forcePreview:!0}),ac(b)}}function ab({apiKey:a,proxyOptions:b}){return new q({apiKey:a,proxyOptions:b})}function ac(a,b={}){return a?{jobId:a.jobId,status:a.status,summary:function(a=[]){let b={total:a.length,queued:0,running:0,completed:0,success:0,failed:0,needs_manual:0,cancelled:0};for(let c of a){let a=c.status||"queued";"success"===a?(b.success+=1,b.completed+=1):"failed"===a||"failed_exchange"===a?(b.failed+=1,b.completed+=1):"needs_manual"===a?b.needs_manual+=1:"cancelled"===a?(b.cancelled+=1,b.completed+=1):"running"===a?b.running+=1:b.queued+=1}return b}(a.accounts),concurrency:a.concurrency,engine:a.engine,proxyPoolMode:a.proxyPoolMode,region:a.region,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,error:a.error,cancelRequested:a.cancelRequested,accounts:(a.accounts||[]).map(a=>({line:a.line,region:a.region,phone:a.phone,fiveSimOrderId:a.fiveSimOrderId,proxyUrl:a.proxyUrl?function(a){if(!a)return null;try{let b=new URL(a);return b.password&&(b.password="***"),b.toString()}catch{return a}}(a.proxyUrl):null,status:a.status,error:a.error,connectionId:a.connectionId,workerId:a.workerId,manualSessionAvailable:!!a.manualSession,currentStep:a.currentStep,updatedAt:a.updatedAt,logs:a.logs||[]})),preview:void 0!==b.preview?b.preview:a.lastPreview||null,...b}:null}function ad(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new aa}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};
|
|
1
|
+
"use strict";exports.id=8371,exports.ids=[8371],exports.modules={3662:(a,b,c)=>{c.d(b,{EQ:()=>f,LY:()=>d,O:()=>e,fh:()=>h,t2:()=>i,wf:()=>g});let d={400:{type:"invalid_request_error",code:"bad_request"},401:{type:"authentication_error",code:"invalid_api_key"},402:{type:"billing_error",code:"payment_required"},403:{type:"permission_error",code:"insufficient_quota"},404:{type:"invalid_request_error",code:"model_not_found"},406:{type:"invalid_request_error",code:"model_not_supported"},429:{type:"rate_limit_error",code:"rate_limit_exceeded"},500:{type:"server_error",code:"internal_server_error"},502:{type:"server_error",code:"bad_gateway"},503:{type:"server_error",code:"service_unavailable"},504:{type:"server_error",code:"gateway_timeout"}},e={400:"Bad request",401:"Invalid API key provided",402:"Payment required",403:"You exceeded your current quota",404:"Model not found",406:"Model not supported",429:"Rate limit exceeded",500:"Internal server error",502:"Bad gateway - upstream provider error",503:"Service temporarily unavailable",504:"Gateway timeout"},f={base:2e3,max:3e5,maxLevel:15},g=3e4,h=18e5,i=[{text:"no credentials",cooldownMs:12e4},{text:"request not allowed",cooldownMs:5e3},{text:"improperly formed request",cooldownMs:12e4},{text:"rate limit",backoff:!0},{text:"too many requests",backoff:!0},{text:"quota exceeded",backoff:!0},{text:"capacity",backoff:!0},{text:"overloaded",backoff:!0},{status:401,cooldownMs:12e4},{status:402,cooldownMs:12e4},{status:403,cooldownMs:12e4},{status:404,cooldownMs:12e4},{status:429,backoff:!0}]},39609:(a,b,c)=>{c.d(b,{proxyAwareFetch:()=>r});var d=c(47774),e=c(27910),f=c(41004);let g=globalThis.fetch,h=new Map,i=new Map,j=["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","api2.cursor.sh"],k=["8.8.8.8","8.8.4.4"];function l(a){return null==a?"":String(a).trim()}async function m(a){let b=i.get(a);if(b&&Date.now()<b.expiry)return b.ip;try{let b=await Promise.resolve().then(c.t.bind(c,14985,23)),{promisify:d}=await Promise.resolve().then(c.t.bind(c,28354,23)),e=new b.Resolver;e.setServers(k);let g=d(e.resolve4.bind(e)),h=await g(a);return i.set(a,{ip:h[0],expiry:Date.now()+f.v1.dnsCacheTtlMs}),h[0]}catch(b){return console.warn(`[ProxyFetch] DNS resolve failed for ${a}:`,b.message),null}}function n(a,b){let c,d=l(b);if(!d)return!1;try{c=new URL(a).hostname.toLowerCase()}catch{return!1}return d.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>"*"===a||(a.startsWith(".")?c.endsWith(a)||c===a.slice(1):c===a||c.endsWith(`.${a}`)))}function o(a){let b=l(a);if(!b)return null;try{return new URL(b),b}catch{return`http://${b}`}}async function p(a){let b=o(a);if(!b)return null;if(!h.has(b)){h.size>=f.v1.proxyDispatchersMaxSize&&h.delete(h.keys().next().value);let{ProxyAgent:a}=await Promise.resolve().then(c.t.bind(c,47774,19));h.set(b,new a({uri:b}))}return h.get(b)}async function q(a,b,d){let f=await Promise.resolve().then(c.t.bind(c,55591,23)),g=await Promise.resolve().then(c.t.bind(c,91645,23)),h=f.default??f,i=g.default??g;return new Promise((c,f)=>{let g=new i.Socket;g.connect(443,b,()=>{let b={socket:g,servername:a.hostname,path:a.pathname+a.search,method:d.method||"POST",headers:{...d.headers,Host:a.hostname}},i=h.request(b,a=>{let b={ok:a.statusCode>=200&&a.statusCode<300,status:a.statusCode,statusText:a.statusMessage,headers:new Map(Object.entries(a.headers)),body:e.Readable.toWeb(a),text:async()=>{let b=[];for await(let c of a)b.push(c);return Buffer.concat(b).toString()},json:async()=>JSON.parse(await b.text())};c(b)});i.on("error",f),d.body&&i.write("string"==typeof d.body?d.body:JSON.stringify(d.body)),i.end()}),g.on("error",f)})}async function r(a,b={},c=null){let e="string"==typeof a?a:a.toString(),f=l(c?.vercelRelayUrl);if(f){let a=new URL(e),c={...b.headers,"x-relay-target":`${a.protocol}//${a.host}`,"x-relay-path":`${a.pathname}${a.search}`};return g(f,{...b,headers:c})}let h=function(a,b){if(b?.enabled!==!0&&b?.connectionProxyEnabled!==!0)return null;let c=l(b?.url??b?.connectionProxyUrl);if(!c)return null;let d=l(b?.noProxy??b?.connectionNoProxy);return d&&n(a,d)?null:o(c)}(e,c),i=h?null:o(function(a){let b;if(n(a,process.env.NO_PROXY||process.env.no_proxy))return null;try{b=new URL(a).protocol}catch{return null}return"https:"===b?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy}(e)),k=h||i;if(function(a){try{let b=new URL(a).hostname;return j.some(a=>b.includes(a))}catch{return!1}}(e)){if(k)try{let c=await p(k);return await (0,d.fetch)(a,{...b,dispatcher:c})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct bypass: ${a.message}`)}try{let a=new URL(e),c=await m(a.hostname);if(c)return await q(a,c,b)}catch(a){console.warn(`[ProxyFetch] MITM bypass failed: ${a.message}`)}}if(k)try{let c=await p(k);return await (0,d.fetch)(a,{...b,dispatcher:c})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct: ${a.message}`)}return g(a,b)}async function s(a,b={}){return r(a,b,null)}globalThis.fetch!==s&&(globalThis.fetch=s)},41004:(a,b,c)=>{c.d(b,{C8:()=>l,DR:()=>k,Uc:()=>h,cI:()=>j,eo:()=>i,gx:()=>d,pH:()=>g,v1:()=>e,xM:()=>f}),c(3662);let d={BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,NOT_ACCEPTABLE:406,REQUEST_TIMEOUT:408,RATE_LIMITED:429,SERVER_ERROR:500,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},e={sessionTtlMs:72e5,sessionCleanupIntervalMs:18e5,dnsCacheTtlMs:3e5,proxyDispatchersMaxSize:20},f=6e4,g=6e4,h=64e3,i=32e3,j={429:{attempts:0,delayMs:0},502:{attempts:3,delayMs:3e3},503:{attempts:3,delayMs:2e3},504:{attempts:2,delayMs:3e3}};function k(a){return null==a?{attempts:0,delayMs:2e3}:"number"==typeof a?{attempts:a,delayMs:2e3}:{attempts:a.attempts||0,delayMs:null!=a.delayMs?a.delayMs:2e3}}let l=["Please write a 5-10 word title for the following conversation:"]},48371:(a,b,c)=>{c.d(b,{xM:()=>W,t9:()=>Z,TK:()=>Y,cO:()=>e.cO,VU:()=>ad});var d=c(55511),e=c(53041),f=c(71998),g=c(89718),h=c(20116),i=c(92990),j=c(39609);let k=globalThis.fetch,l=new Set(["a timeout","is cancelled","is complete","number banned, when number already used"]);class m extends Error{constructor(a,{status:b,body:c}={}){super(a),this.name="FiveSimError",this.status=b,this.body=c}}class n extends m{constructor(a){super(`5sim order ${a} timed out waiting for SMS`),this.name="FiveSimTimeoutError",this.orderId=a}}class o extends m{constructor(a,b){super(`5sim order ${a} cancelled: ${b}`),this.name="FiveSimCancelledError",this.orderId=a}}class p extends m{constructor(a){super(`5sim order ${a} number was already used (banned)`),this.name="FiveSimBannedError",this.orderId=a}}class q{constructor({apiKey:a,proxyOptions:b=null}={}){if(!a||"string"!=typeof a||!a.trim())throw new m("5sim API key is required");this.apiKey=a.trim(),this.proxyOptions=b}_headers(a={}){return{Authorization:`Bearer ${this.apiKey}`,Accept:"application/json",...a}}async _get(a,{headers:b,...c}={}){let d=`https://5sim.net/v1${a}`,e=this.proxyOptions?.enabled?j.proxyAwareFetch:k,f=await e(d,{method:"GET",headers:this._headers(b),...c},this.proxyOptions);if(!f.ok){let b=await f.text().catch(()=>"");throw new m(`5sim request to ${a} failed (HTTP ${f.status}): ${b.slice(0,200)}`,{status:f.status,body:b})}let g=await f.text();try{return JSON.parse(g)}catch{if(g&&!g.startsWith("{"))throw new m(`5sim ${a} returned non-JSON: ${g.slice(0,200)}`,{status:f.status,body:g});return null}}async buyNumber({country:a="hongkong",operator:b="any",product:c="codebuddy",allowProductFallback:d=!1}={}){let e="codebuddy"===c&&d?["codebuddy","other"]:[c],f=null;for(let c of e){let g=`/user/buy/activation/${encodeURIComponent(a)}/${encodeURIComponent(b)}/${encodeURIComponent(c)}`;try{let a=await this._get(g);if(!a||!a.id||!a.phone)throw new m(`5sim buyNumber returned unexpected shape: ${JSON.stringify(a).slice(0,200)}`,{body:a});return a}catch(g){f=g;let a=g?.status,b=String(g?.body||g?.message||"").toLowerCase();if(!(d&&"codebuddy"===c&&e.includes("other")&&(400===a||404===a||b.includes("no free")||b.includes("not enough")||b.includes("no product"))))throw g}}throw f||new m("5sim buyNumber failed for all product candidates")}async checkOrder(a){return this._get(`/user/check/${a}`)}async pollCode(a,{timeoutMs:b=9e5,intervalMs:c=6e3,signal:d}={}){let e=Math.max(5e3,c),f=Date.now()+b,g=0;for(;Date.now()<f;){let b;if(d?.aborted)throw new o(a,"aborted by caller");try{b=await this.checkOrder(a)}catch(a){if(a instanceof m&&a.status>=500){if(++g>5)throw a;await s(e);continue}throw a}if(g=0,Array.isArray(b.sms)&&b.sms.length>0){let a=r(b.sms[b.sms.length-1]);if(a)return a}if(b.status&&l.has(b.status)){if("a timeout"===b.status)throw new n(a);if("number banned, when number already used"===b.status)throw new p(a);if("is cancelled"===b.status)throw new o(a,b.status);if("is complete"===b.status){let c=function(a){if(!Array.isArray(a))return null;for(let b=a.length-1;b>=0;b--){let c=r(a[b]);if(c)return c}return null}(b.sms);if(c)return c;throw new m(`5sim order ${a} completed but no SMS code found`,{body:b})}}await s(e)}throw new n(a)}async finishOrder(a){try{return await this._get(`/user/finish/${a}`),!0}catch(b){return console.warn(`[5sim] finishOrder(${a}) failed (best-effort): ${b.message}`),!1}}async cancelOrder(a){try{return await this._get(`/user/cancel/${a}`),!0}catch(b){return console.warn(`[5sim] cancelOrder(${a}) failed (best-effort): ${b.message}`),!1}}async banOrder(a){try{return await this._get(`/user/ban/${a}`),!0}catch(b){return console.warn(`[5sim] banOrder(${a}) failed (best-effort): ${b.message}`),!1}}async getBalance(){try{let a=await this._get("/user/profile");return{balance:a?.balance??null,rating:a?.rating??null}}catch(a){return console.warn(`[5sim] getBalance failed: ${a.message}`),{balance:null,rating:null}}}}function r(a){return a?a.code&&/\d{4,8}/.test(String(a.code))?String(a.code).match(/\d{4,8}/)[0]:a.text?function(a){if(!a)return null;let b=String(a).match(/\b(\d{4,8})\b/);return b?b[1]:null}(a.text):null:null}function s(a){return new Promise(b=>setTimeout(b,a))}let t=["https://www.codebuddy.cn/login/","https://www.codebuddy.cn/login","https://www.codebuddy.cn/register/","https://copilot.tencent.com/login/"],u=["text=手机号","div:has-text('手机号')","span:has-text('手机号')","[class*='phone']:has-text('手机号')","div.kc-phone-tab:has-text('手机号')"],v=["text=手机号","text=其他登录方式","text=微信","#phone-iframe",".login-phone-box"],w="#phone-iframe",x="#phoneNumber",y=".kc-country-option",z=".kc-country-code-text",A="#code",B=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],C=['[class*="avatar"]','[class*="user-info"]','[class*="logout"]',"text=退出登录","text=Logout","text=Sign out"],D=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"];async function E({page:a,phone:b,resolvePhone:c,pollSmsPromise:d,waitForSms:e,onStep:f,phoneFormatter:g=a=>a,timeouts:h={},signal:i=null,isCancelled:j=null}){let k=h.nav??3e4,l=h.action??15e3,m=h.codeWait??9e5,n=h.postSubmit??1e4,o=(a,b)=>f?.(a,b),p=()=>{if(i?.aborted||"function"==typeof j&&j()){let a=Error("Job cancelled");throw a.code="JOB_CANCELLED",a}};try{var q;let f,h;o("cn_opening_login_page","Opening CodeBuddy CN login page"),p();try{a.setDefaultNavigationTimeout(k),a.setDefaultTimeout(l)}catch{}try{await a.context().route("**/*",a=>{let b=a.request().url();return/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(b)?a.abort():a.continue()})}catch{}let i=null,j=[];for(let b=1;b<=2;b++){p();try{let c=t[(b-1)%t.length];o("cn_nav_attempt",`Navigation attempt ${b}/2 → ${c}`),b>1&&(await a.context().clearCookies().catch(()=>{}),await a.waitForTimeout(800)),await a.goto(c,{waitUntil:"commit",timeout:k}),p(),await a.waitForTimeout(1500),p();let d=await I(a,v,25e3);if(p(),!d){let b=await a.locator("body").innerText().catch(()=>""),d=await a.evaluate(()=>document.documentElement?.outerHTML?.length||0).catch(()=>0),e=a.url();o("cn_spa_not_ready",`SPA not ready after 25s (url=${e}, body=${String(b).slice(0,80)}, html=${d})`),!b&&d<200?(o("cn_proxy_empty_page","Empty page body — proxy may be blocking codebuddy.cn"),j.push({code:"proxy_empty",detail:`empty page via ${c} (html=${d})`})):j.push({code:"spa_timeout",detail:`SPA not ready url=${e} html=${d}`});continue}o("cn_spa_ready","Login SPA ready"),o("cn_selecting_phone_tab","Selecting phone-number tab");let e=await H(a,u,{timeout:12e3});if(e?(await e.click().catch(()=>{}),o("cn_phone_tab_selected","Phone tab selected"),await a.waitForTimeout(800)):o("cn_phone_tab_not_found","Phone tab not found — checking if iframe already present"),o("cn_waiting_for_iframe","Waiting for phone iframe to load"),await a.locator(w).waitFor({state:"attached",timeout:18e3}).catch(()=>{}),i=await F(a)){if(await i.waitForSelector(x,{state:"visible",timeout:15e3}).then(()=>!0).catch(()=>!1)){o("cn_iframe_ready","Phone iframe + #phoneNumber ready");break}o("cn_iframe_empty","Iframe found but #phoneNumber not visible yet"),j.push({code:"iframe_empty",detail:"phone iframe attached but #phoneNumber not visible"}),i=null}else o("cn_iframe_missing",`No #phone-iframe (attempt ${b}/2)`),j.push({code:"iframe_missing",detail:"SPA loaded but #phone-iframe never appeared"})}catch(e){if(e?.code==="JOB_CANCELLED")throw e;let a=String(e?.message||e||"");o("cn_nav_retry",`Navigation attempt ${b}/2 failed: ${a.slice(0,120)}`);let c=/timeout|exceeded|ETIMEDOUT|net::ERR/i.test(a),d=/ERR_PROXY|ERR_TUNNEL|ERR_CONNECTION|NS_ERROR_PROXY|proxy/i.test(a);j.push({code:d?"proxy_network":c?"nav_timeout":"nav_error",detail:a.slice(0,160)})}}if(!i)return{status:"failed",error:function(a=[],b=2){let c=a.map(a=>a.code),d=a[a.length-1],e="Fix: use a live residential CN proxy (proxyPoolMode=single), concurrency 1, then retry. 5sim is not charged until the form loads.";return c.includes("proxy_empty")||c.includes("proxy_network")?`CodeBuddy CN login page empty/blocked via proxy after ${b} attempts (${d?.detail||"proxy blackhole"}). ${e}`:c.includes("nav_timeout")?`CodeBuddy CN navigation timed out after ${b} attempts (${d?.detail||"goto timeout"}). Proxy is too slow or dead. ${e}`:c.includes("spa_timeout")?`CodeBuddy CN SPA did not boot after ${b} attempts (${d?.detail||"no login UI"}). Proxy/CDN may be filtering JS. ${e}`:c.includes("iframe_missing")||c.includes("iframe_empty")?`CodeBuddy CN page opened but phone form iframe never appeared after ${b} attempts (${d?.detail||"no #phone-iframe"}). Site layout change or half-loaded SPA — retry with another CN exit IP. ${e}`:c.includes("nav_error")&&d?.detail?`CodeBuddy CN phone form failed after ${b} attempts: ${d.detail}. ${e}`:`Could not load CodeBuddy CN phone form after ${b} attempts (${d?.code||"unknown"}: ${d?.detail||"proxy/SPA"}). ${e}`}(j,2)};await i.waitForSelector("#kc-form-login",{timeout:l}).catch(()=>{}),await i.waitForSelector(x,{state:"visible",timeout:l}).catch(()=>{});let r=b;if("function"==typeof c&&(o("cn_ordering_after_form","Login form ready — ordering 5sim number now (not before nav)"),r=await c()),!r)return{status:"failed",error:"No phone number available (resolvePhone/phone missing)"};let s=g(r),{countryCode:y,localNumber:z}=(q=s,(!(h=String(q).replace(/[\s\-()]/g,"")).startsWith("+")&&/^\d+$/.test(h)&&(h="+"+h),h.startsWith("+852"))?{countryCode:"+852",localNumber:h.slice(4)}:h.startsWith("+86")?{countryCode:"+86",localNumber:h.slice(3)}:h.startsWith("+1")?{countryCode:"+1",localNumber:h.slice(2)}:{countryCode:"",localNumber:h.replace(/^\+/,"")});o("cn_selecting_country",`Selecting country code ${y} for phone ${s}`),await G(i,y,l,o),o("cn_entering_phone",`Entering phone number: ${z}`);let B=i.locator(x).first();try{await B.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}await J(B,z),o("cn_phone_entered",`Phone number entered: ${z}`);try{let b=a.locator(".t-checkbox").last();await b.isVisible({timeout:3e3}).catch(()=>!1)&&(await b.click().catch(()=>{}),o("cn_agreement_checked","Agreement checkbox checked"))}catch{}o("cn_clicking_send_code","Clicking send SMS code button");let C=i.locator("input.btn-lg.code-btn").first(),D=!1;try{await C.waitFor({state:"visible",timeout:5e3}),D=!0}catch{let a=i.locator(".code-btn").first();try{await a.waitFor({state:"visible",timeout:5e3}),D=!0}catch{D=!1}}if(!D)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};await C.click().catch(()=>{}),o("cn_send_code_clicked","Send code button clicked"),await i.waitForSelector(A,{state:"visible",timeout:5e3}).catch(()=>{});let E=await R(i);if(E)return{status:"failed",error:`Form error after sending code: ${E}`};o("cn_waiting_for_sms","Waiting for SMS verification code from 5sim (timer starts now)");try{let a;if("function"==typeof e)a=Promise.resolve().then(()=>e());else if(d)a=d;else throw Error("No waitForSms/pollSmsPromise provided");let b=new Promise((a,b)=>setTimeout(()=>b(Error("Timed out waiting for SMS code")),m));f=await Promise.race([a,b])}catch(a){if(a&&"FiveSimTimeoutError"===a.name)throw a;return{status:"failed",error:`Failed to receive SMS code: ${a.message}`}}if(!f)return{status:"failed",error:"Received empty SMS code from 5sim"};o("cn_sms_received",`SMS code received: ${f}`),o("cn_entering_code","Entering SMS verification code");let K=i.locator(A).first();try{await K.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}await J(K,f),o("cn_code_entered","Verification code entered");let L=Math.max(n,12e3),U=!1;for(let b=0;b<2;b++){o("cn_submitting",`Clicking submit button (attempt ${b+1}/2)`);let c=await F(a);if(!c){let b=await M(a,{timeoutMs:5e3,reportStep:o});if(b.ok)return o("cn_session_cookies",`Keycloak session after iframe detach (${b.cookie})`),{status:"success"};return{status:"failed",error:"Lost phone iframe after submit"}}if(await c.locator(x).first().isVisible({timeout:3e3}).catch(()=>!1)&&b>0){o("cn_re_entering_after_refresh",`Re-entering phone + code after refresh (retry ${b})`),await G(c,y,l,o);let d=c.locator(x).first();await J(d,z);try{let b=a.locator(".t-checkbox").first();await b.isVisible({timeout:2e3}).catch(()=>!1)&&await b.click().catch(()=>{})}catch{}let e=c.locator(A).first();await e.isVisible({timeout:3e3}).catch(()=>!1)&&await J(e,f)}if(await N(c,l),o("cn_submitted",`Registration form submitted (attempt ${b+1})`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1e3),c=await F(a)||c,await Q(c)){if(b>=1)return{status:"failed",error:"Account restricted (账号访问受限) after submit. Datacenter/VPS IP is usually blocked — use a residential CN proxy pool (proxyPoolMode=single) and retry."};o("cn_account_restricted",`Account restricted (attempt ${b+1}) — refreshing page and retrying`),await a.reload({waitUntil:"commit",timeout:k}).catch(()=>{}),await I(a,v,12e3);let c=await H(a,u,{timeout:8e3});c&&(await c.click().catch(()=>{}),await a.locator(w).waitFor({state:"attached",timeout:8e3}).catch(()=>{}));continue}if(o("cn_checking_captcha","Checking for captcha"),await S(a,c,3e3))return o("cn_captcha_detected","Captcha appeared during registration — manual assist needed"),{status:"needs_manual",error:"A captcha appeared during registration. Please complete it manually in the opened browser window.",captcha:!0};let d=await R(c);if(d)return{status:"failed",error:`Form error after submit: ${d}`};o("cn_waiting_session",`Waiting up to ${Math.round(L/1e3)}s for Keycloak session cookies`);let e=await M(a,{timeoutMs:L,reportStep:o,alsoCheckFrame:()=>F(a)});if(e.ok)return o("cn_session_cookies",`Keycloak session cookies present (${e.cookie}) — registration success`),{status:"success"};if(await O(a)&&b<1){o("cn_submit_no_effect","Login form still visible after submit — retrying");continue}o("cn_session_nudge","No session yet — navigating to home to complete OIDC handoff"),await a.goto("https://www.codebuddy.cn/",{waitUntil:"domcontentloaded",timeout:k}).catch(()=>{}),await a.waitForTimeout(2e3);let g=await M(a,{timeoutMs:1e4,reportStep:o});if(g.ok)return o("cn_session_cookies",`Keycloak session after home nudge (${g.cookie})`),{status:"success"};U=!0;break}if(!U)return o("cn_submit_retries_exhausted","Account restricted after 2 retries — needs manual"),{status:"needs_manual",error:"Account restricted after 2 refresh retries. Please try with a different VPN/proxy or complete manually."};o("cn_confirming_success","Confirming registration success");let V=await M(a,{timeoutMs:5e3});if(V.ok)return o("cn_registration_success",`Phone registration completed (Keycloak session: ${V.cookie})`),{status:"success"};if(await T(a,i,1e4))return o("cn_registration_success","Phone registration completed successfully (UI markers)"),{status:"success"};let W=await P(a);return o("cn_success_unconfirmed",`No Keycloak session after submit — ${W.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${W.summary}). Complete login in the headed browser or retry with a fresh China proxy.`}}catch(a){if(a&&"FiveSimTimeoutError"===a.name)throw a;return o("cn_automation_error",`Phone registration automation error: ${a.message}`),{status:"failed",error:a.message||"Unexpected error during phone registration"}}}async function F(a){try{await a.locator(w).waitFor({state:"attached",timeout:5e3});let b=await a.locator(w).elementHandle({timeout:2e3});if(b){let a=await b.contentFrame();if(a)return a}}catch{}for(let b of a.frames()){let a=b.url();if(a.includes("codebuddy.cn/auth/realms/copilot")||a.includes("protocol/openid-connect"))return b}return null}async function G(a,b,c,d){if(!b)return;let e=Math.min(Number(c)||15e3,1e4),f=async()=>{let c=a.locator(z).first(),f=String(await c.textContent({timeout:3e3}).catch(()=>"")).trim();if(f===b)return void d?.("cn_country_already_selected",`Country code already ${b}`);d?.("cn_opening_country_dropdown",`Opening country dropdown (current: ${f}, target: ${b})`);let g=a.locator(".kc-country-selector").first();for(let c of(await g.waitFor({state:"visible",timeout:Math.min(e,5e3)}),await g.click({timeout:3e3}).catch(()=>{}),await a.locator(y).first().waitFor({state:"visible",timeout:3e3}).catch(()=>{}),({"+852":["中国香港","香港","Hong Kong","+852"],"+86":["中国大陆","中国","China","+86"],"+853":["中国澳门","澳门","Macau","+853"],"+886":["中国台湾","台湾","Taiwan","+886"]})[b]||[b]))for(let e of[a.locator(`${y}:has-text("${c}")`).first(),a.getByText(c,{exact:!1}).first()]){if(!await e.isVisible({timeout:1500}).catch(()=>!1))continue;let f=await e.textContent({timeout:1500}).catch(()=>c);await e.click({timeout:2e3}).catch(()=>{}),await a.locator(z).filter({hasText:b}).first().waitFor({state:"visible",timeout:2e3}).catch(()=>{}),d?.("cn_country_selected",`Country selected: ${String(f||c).trim()}`);return}d?.("cn_country_not_found",`Country code ${b} not found in dropdown; using default`),await a.locator("body").click({timeout:1e3}).catch(()=>{})};try{await Promise.race([f(),new Promise((a,b)=>{let c=setTimeout(()=>b(Error(`selectCountry timed out after ${e}ms`)),e);"function"==typeof c.unref&&c.unref()})])}catch(a){d?.("cn_country_select_error",`Country selection error: ${a.message}`)}}async function H(a,b,{timeout:c=1e4}={}){for(let d of b)try{let b=a.locator(d).first();return await b.waitFor({state:"visible",timeout:Math.min(c,5e3)}),b}catch{}return null}async function I(a,b,c=15e3){let d=Date.now()+c;for(;Date.now()<d;){for(let c of b)try{let b=a.locator(c).first();if(await b.isVisible().catch(()=>!1))return!0}catch{}await new Promise(a=>setTimeout(a,250))}return!1}async function J(a,b){try{return await a.click(),await a.fill(""),await a.fill(b),!0}catch{try{return await a.click(),await a.press("Control+a"),await a.type(b,{delay:50}),!0}catch{return!1}}}let K=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];function L(a=[]){for(let b of K)if(a.some(a=>a.name===b))return b;let b=a.find(a=>a.name.startsWith("KEYCLOAK_")&&!/locale|theme|restart/i.test(a.name));return b?.name||null}async function M(a,{timeoutMs:b=2e4,reportStep:c,alsoCheckFrame:d}={}){let e=Date.now()+b,f=0;for(;Date.now()<e;){let b=await a.context().cookies().catch(()=>[]),g=L(b);if(g)return{ok:!0,cookie:g,cookies:b};try{let c=a.url();if(c&&!c.includes("/login")&&!c.includes("/auth/realms")){let a=b.find(a=>/^(access_token|cb_token|codebuddy)/i.test(a.name)||"token"===a.name&&a.domain?.includes("codebuddy"));if(a)return{ok:!0,cookie:a.name,cookies:b}}}catch{}if(d){let a=await d().catch(()=>null);if(a){if(await Q(a))return{ok:!1,cookies:b,reason:"restricted"};let c=await R(a);if(c)return{ok:!1,cookies:b,reason:`form_error:${c}`}}}if(c&&Date.now()-f>4e3){f=Date.now();let a=Math.max(0,Math.round((e-Date.now())/1e3));c("cn_waiting_session",`Still waiting for Keycloak session… ${a}s left`)}await a.waitForTimeout(500)}return{ok:!1,cookies:await a.context().cookies().catch(()=>[])}}async function N(a,b=15e3){let c=a.locator("#kc-login").first();try{await c.waitFor({state:"visible",timeout:b}),await c.click({timeout:5e3}).catch(()=>{})}catch{}try{await a.evaluate(()=>{let a=document.querySelector("#kc-form-login")||document.querySelector("form");if(a)if("function"==typeof a.requestSubmit){let b=a.querySelector("#kc-login")||a.querySelector('[type="submit"]');b?a.requestSubmit(b):a.requestSubmit()}else a.submit()})}catch{await a.locator(A).first().press("Enter").catch(()=>{})}}async function O(a){let b=await F(a);return!!b&&b.locator(x).first().isVisible({timeout:1500}).catch(()=>!1)}async function P(a){let b="";try{b=a.url()}catch{b="(unknown)"}let c=(await a.context().cookies().catch(()=>[])).map(a=>a.name).slice(0,20).join(",")||"(none)",d="";try{d=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim().slice(0,120))}catch{d=""}let e=await F(a),f="no-iframe";if(e)try{f=(await e.url()).slice(0,80)}catch{f="iframe-detached"}return{summary:`url=${b.slice(0,60)} cookies=[${c}] frame=${f}${d?` text="${d}"`:""}`,url:b,cookieNames:c,bodySnippet:d}}async function Q(a){try{let b=await a.evaluate(()=>document.body?.innerText||"");if(b.includes("账号访问受限")||b.includes("安全策略限制")||b.includes("访问受限"))return!0}catch{}return!1}async function R(a){for(let b of D)try{let c=a.locator(b).first();if(await c.isVisible({timeout:1500}).catch(()=>!1)){let a=await c.textContent().catch(()=>""),b=String(a).trim();if(b&&b.length>1)return b}}catch{}try{let b=await a.evaluate(()=>(document.body?.innerText||"").replace(/\s+/g," ").trim());for(let a of["验证码错误","验证码已过期","验证码无效","请输入正确的验证码","手机号格式","发送过于频繁","Invalid","incorrect"])if(b.includes(a)){let c=b.indexOf(a);return b.slice(Math.max(0,c-10),c+a.length+40).trim()}}catch{}return null}async function S(a,b,c=5e3){for(let b of B)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}if(b)for(let a of B)try{let d=b.locator(a).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}return!1}async function T(a,b,c=15e3){try{let b=await a.context().cookies().catch(()=>[]);if(L(b))return!0}catch{}for(let b of C)try{let d=a.locator(b).first();if(await d.isVisible({timeout:Math.min(c,2e3)}).catch(()=>!1))return!0}catch{}try{let b=a.url(),c=await a.context().cookies().catch(()=>[]),d=new Set(c.map(a=>a.name));if(b&&!b.includes("/login")&&!b.includes("/auth/realms")&&(d.has("qcloud_uid")||d.has("qcmainCSRFToken"))&&!d.has("login_risk_state")&&!await O(a).catch(()=>!1))return!0}catch{}return!1}var U=c(40891),V=c(75949);let W=200,X=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||72e4,Y=new Set(["hongkong","china","any"]),Z="hongkong";function $(a){return String(a||"").trim()}async function _({apiKey:a,phone:b,region:d,fiveSimOrderId:e,account:f}){let{createProviderConnection:g}=await Promise.resolve().then(c.bind(c,71998)),h={provider:"codebuddy-cn",authType:"apikey",apiKey:a,accessToken:a,name:b||`5sim-${e}`,email:b||`5sim-${e}`,providerSpecificData:{domain:"www.codebuddy.cn",phoneNumber:b,fiveSimOrderId:e,region:d,automation:"5sim-phone-bulk"},testStatus:"active"};return{connection:await g(h)}}class aa extends e.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=U.cT,pollToken:d=U.ZV,fetchLoginAccountFn:e=U.w8,saveConnection:f=_,fiveSimClientFactory:g=ab,phoneAutomation:h=E,phoneFormatter:j=$,pollIntervalMs:k=i.ne.pollInterval,storageName:l="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{launchBulkImportBrowser:b}=await Promise.resolve().then(c.bind(c,75949)),d=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null,e=process.env.ZEVAI_CN_HEADLESS,f="linux"===process.platform;return("0"===e||"false"===e)&&(f=!1),("1"===e||"true"===e)&&(f=!0),b({engine:a?.engine||"camoufox",proxyUrl:d,headless:f,windowSize:{width:900,height:700}})}),storageName:l}),this.requestDeviceCode=b,this.pollToken=d,this.fetchLoginAccount=e,this.saveConnection=f,this.fiveSimClientFactory=g,this.phoneAutomation=h,this.phoneFormatter=j,this.pollIntervalMs=k}async startJob({count:a,concurrency:b,engine:g,proxyPoolMode:i,proxyPoolId:j,region:k}){let l=Number.parseInt(a,10);if(!Number.isFinite(l)||l<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(l>W)throw Object.assign(Error(`Count exceeds maximum of ${W}`),{error:`Count exceeds maximum of ${W}`});let m=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(m)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${m.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${m.jobId}). Cancel it or wait before starting again.`});let n=Y.has(k)?k:Z,o=[];if("all"===i)o=(await (0,f.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===i&&j){let a=await (0,f.hr)(j);a?.isActive&&a?.proxyUrl&&(o=[a.proxyUrl])}let p=(0,d.randomUUID)(),q=(0,e.kF)(),{normalizeBulkImportEngine:r}=await Promise.resolve().then(c.bind(c,75949)),s=g?r(g):"camoufox",t={jobId:p,status:"running",concurrency:function(a){let b=function(){try{let{totalMemGb:a}=(0,h.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}()?1:8;if((0,h.uT)(a))return Math.min(b,Math.max(1,(0,h.q)()));let c=Number.parseInt(a,10);return Number.isFinite(c)?Math.min(b,Math.max(1,c)):Math.min(b,1)}(b),engine:s,proxyPoolMode:i||"none",proxyUrls:o,region:n,createdAt:q,startedAt:q,finishedAt:null,error:null,cancelRequested:!1,browser:null,nextIndex:0,manualFollowups:new Set,persistPromise:Promise.resolve(),lastPreview:null,lastPreviewCapturedAt:0,accounts:Array.from({length:l},(a,b)=>({line:b+1,region:n,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,proxyUrl:null,abortController:new AbortController,status:"queued",error:null,connectionId:null,workerId:null,manualSession:null,runtimeSession:null,currentStep:"queued",updatedAt:q,logs:[(0,e.hn)("queued","Queued and waiting for an available worker")]}))};return this.jobs.set(p,t),this.latestJobId=p,await this.persistJobSnapshot(t,{forcePreview:!1}),this.runJob(p),ac(t)}getJob(a){let b=this.jobs.get(a);return b?ac(b):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),ac(b,{preview:b.lastPreview||null})):null}async processAccount(a,b,c){if(a.cancelRequested||!a.browser)return void this.finalizeAccount(b,"cancelled",{error:"Job cancelled"});let d=null,f=null,h=!1,i=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let j=(await (0,g.mt)()).fiveSimApiKey;if(!j||!j.trim()){this.finalizeAccount(b,"failed",{error:"5sim API key not configured. Set it in the automation modal or dashboard settings.",step:"failed",message:"5sim API key not configured"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}d=this.fiveSimClientFactory({apiKey:j,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0});let k=await (0,e.go)(a.browser,b.proxyUrl);i=k.context;let l=k.page;if(b.runtimeSession={context:i,page:l},a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"registering","Running phone registration on CodeBuddy CN"),await this.persistJobSnapshot(a,{forcePreview:!0});try{l.setDefaultTimeout(2e4),l.setDefaultNavigationTimeout(45e3)}catch{}let m=null,n=new Promise((a,b)=>{m=setTimeout(()=>{b(Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(X/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"}))},X),"function"==typeof m.unref&&m.unref()});try{c=await Promise.race([this.phoneAutomation({page:l,signal:b.abortController?.signal,isCancelled:()=>!0===a.cancelRequested,resolvePhone:async()=>{if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");this.setAccountStep(b,"ordering_number",`Form ready — ordering ${a.region} phone from 5sim (single buy)`),await this.persistJobSnapshot(a,{forcePreview:!0});let c=await d.buyNumber({country:a.region,product:"codebuddy",allowProductFallback:!1});return f=c.id,b.phone=c.phone,b.fiveSimOrderId=c.id,b.fiveSimActivationId=c.id,this.setAccountStep(b,"number_ordered",`Phone number ordered: ${c.phone} (1 buy, no re-order)`),await this.persistJobSnapshot(a,{forcePreview:!0}),c.phone},waitForSms:async()=>{if(!f)throw Error("Cannot poll SMS — no 5sim order id");this.setAccountStep(b,"sms_poll_started","SMS poll started (full 90s window after send-code)"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await d.pollCode(f,{timeoutMs:9e4,signal:b.abortController?.signal});return h=!0,c},onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})},phoneFormatter:this.phoneFormatter}),n])}finally{m&&clearTimeout(m)}if("failed"===c.status){let e=c.error||"Phone registration failed before submit";this.finalizeAccount(b,"failed",{error:e,step:"failed",message:e}),d&&f&&(h?await d.finishOrder(f):await d.cancelOrder(f)),b.runtimeSession=null,await i.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0});return}await this.captureApiKey(a,b,i,l,d,f);return}catch(g){let c=g instanceof n,e=c?"SMS OTP not received within 90s — number banned":g.message||"Unexpected CodeBuddy CN bulk import failure";if(this.finalizeAccount(b,"failed",{error:e,step:c?"sms_timeout":"failed",message:e}),d&&f&&(h?await d.finishOrder(f):c?await d.banOrder(f):await d.cancelOrder(f)),b.runtimeSession=null,i&&await i.close().catch(()=>null),(g?.code==="CN_ACCOUNT_HARD_TIMEOUT"||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,V.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id";try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let h=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},i=a=>a.has("KEYCLOAK_IDENTITY")||a.has("KEYCLOAK_SESSION")||a.has("KEYCLOAK_IDENTITY_LEGACY")||a.has("KEYCLOAK_SESSION_LEGACY"),j=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken"),k=async()=>d.evaluate(async()=>{try{let a=await fetch("/console/accounts",{credentials:"include",headers:{Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn"}}),b=await a.json().catch(()=>null);return{status:a.status,data:b}}catch(a){return{status:0,error:a?.message||String(a)}}}).catch(()=>null),l=a=>a?.data?.data?.accounts||a?.data?.accounts||[],m=["https://www.codebuddy.cn/","https://www.codebuddy.cn/login/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],n=[],o=null,p=!1;for(let c=0;c<8;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await h(),f=i(e.names),g=j(e.names),q=m[Math.min(c,m.length-1)];if(0===c||2===c||4===c||6===c?(this.setAccountStep(b,"waiting_session",`OIDC handoff attempt ${c+1}/8 → ${q} (cookies: ${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await d.goto(q,{waitUntil:"domcontentloaded",timeout:25e3}).catch(()=>null),await d.waitForTimeout(1500)):await d.waitForTimeout(1e3),c>=2&&!String(d.url()||"").includes("/console")&&(await d.goto("https://www.codebuddy.cn/console",{waitUntil:"domcontentloaded",timeout:25e3}).catch(()=>null),await d.waitForTimeout(1e3)),o=await k(),n=l(o),o?.status===200&&Array.isArray(n)&&n.length>0){p=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${n.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${o?.status||0}) — retry ${c+1}/8`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!p||!Array.isArray(n)||0===n.length){let a=await h();throw Error(`Console accounts unavailable after login (HTTP ${o?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}) — session not accepted for API key`)}let q=g,r=n.find(a=>a?.lastLogin)||n[0];r?.type&&"personal"!==r.type&&r.enterpriseId&&(q=r.enterpriseId),this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${q})`),await this.persistJobSnapshot(a,{forcePreview:!0});let s=async a=>d.evaluate(async({enterpriseId:a})=>{let b=await fetch("/console/api/client/v1/api-keys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:`zevai-router-${Date.now()}`,expire_in_days:365,user_enterprise_id:a})}),c=await b.json().catch(()=>null);return{ok:b.ok,status:b.status,data:c}},{enterpriseId:a}),t=await s(q).catch(()=>null);t&&t.ok||(this.setAccountStep(b,"retrying_api_key","Retrying API key creation from profile/keys"),await this.persistJobSnapshot(a,{forcePreview:!0}),await d.goto("https://www.codebuddy.cn/profile/keys",{waitUntil:"domcontentloaded",timeout:45e3}).catch(()=>null),await d.waitForTimeout(2500),t=await s(q).catch(()=>null)),t&&t.ok||q===g||(t=await s(g).catch(()=>null));let u=t?.status;if(!t?.ok&&(401===u||403===u||0===u||!t)){for(let c of(this.setAccountStep(b,"retrying_api_key","API key 401/403 — re-running OIDC handoff then retry"),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/login/","https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await d.goto(c,{waitUntil:"domcontentloaded",timeout:45e3}).catch(()=>null),await d.waitForTimeout(2e3);t=await s(g).catch(()=>null)}let v=t?.data?.code;if(!t||!t.ok||!t.data||0!==v&&200!==v&&void 0!==v)throw Error(`API key creation failed (HTTP ${t?.status??"no-response"}, code=${v??"n/a"}): ${JSON.stringify(t?.data??null).slice(0,200)}`);let w=t.data?.data||t.data,x=w?.apiKey||w?.key||w?.token||w?.secret||w?.api_key||("string"==typeof w?w:null)||t.data.apiKey||t.data.key||t.data.token||t.data.secret;if(!x||"string"!=typeof x)throw Error(`API key response did not contain a key field: ${JSON.stringify(t.data).slice(0,300)}`);this.setAccountStep(b,"api_key_created","API key created successfully"),await this.persistJobSnapshot(a,{forcePreview:!0}),this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:y}=await this.saveConnection({apiKey:x,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await e.finishOrder(f),this.finalizeAccount(b,"success",{connectionId:y.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await c.close().catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(g){this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${g.message}`,step:"awaiting_manual",message:`Registration done, API key capture failed: ${g.message}`}),await e.finishOrder(f).catch(()=>null),await this.persistJobSnapshot(a,{forcePreview:!0}),await this.runCnManualFollowup(a,b,b.workerId,c,d,e,f)}}async runCnManualFollowup(a,b,c,d,e,f,g){let h=(async()=>{let c=async()=>{let a=b.manualSession,c=a?.context||d,e=a?.headedBrowser||null;c&&await c.close().catch(()=>null),e&&await e.close().catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let c=Date.now()+9e5,d=null;for(;Date.now()<c&&!a.cancelRequested;){await new Promise(a=>setTimeout(a,1e4));try{if(!e.url().includes("codebuddy.cn"))continue;let a=await e.evaluate(async()=>{let a=await fetch("/console/api/client/v1/api-keys",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":window.location.hostname||"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",body:JSON.stringify({name:"zevai-router-manual-"+Date.now(),expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),b=await a.json().catch(()=>null);return{ok:a.ok,status:a.status,data:b}});if(a?.ok&&a.data){let b=a.data?.data||a.data;if((d=b?.apiKey||b?.key||b?.token||b?.secret||b?.api_key||("string"==typeof b?b:null))&&"string"==typeof d)break}}catch{}}if(a.cancelRequested){this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}),await this.persistJobSnapshot(a,{forcePreview:!0});return}if(!d)throw Error("Manual assist timed out — could not capture API key");this.setAccountStep(b,"saving_connection","Saving CodeBuddy CN connection (manual)"),await this.persistJobSnapshot(a,{forcePreview:!0});let{connection:f}=await this.saveConnection({apiKey:d,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:f.id,step:"connection_saved",message:`CodeBuddy CN connection saved via manual assist (phone: ${b.phone||"N/A"})`}),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(c){a.cancelRequested?this.finalizeAccount(b,"cancelled",{error:"Job cancelled",step:"cancelled",message:"Job cancelled while waiting for manual completion"}):this.finalizeAccount(b,"failed",{error:c.message||"Manual assist flow failed",step:"failed",message:c.message||"Manual assist flow failed"}),await this.persistJobSnapshot(a,{forcePreview:!0})}finally{await c(),b.manualSession=null,b.runtimeSession=null,a.manualFollowups.delete(h),await this.persistJobSnapshot(a,{forcePreview:!0})}})();a.manualFollowups.add(h)}cancelJob(a){let b=this.jobs.get(a);if(!b)return null;for(let a of(b.cancelRequested=!0,b.accounts)){a.abortController&&!a.abortController.signal.aborted&&a.abortController.abort();let b=a.runtimeSession?.context;b&&b.close().catch(()=>null),a.runtimeSession=null,a.manualSession=null}if(b.browser){let a=b.browser;b.browser=null,(0,V.forceCloseBrowser)(a).catch(()=>null)}return"queued"===b.status&&(b.status="cancelled",b.finishedAt=(0,e.kF)(),b.accounts.forEach(a=>{"queued"===a.status&&(a.status="cancelled")})),this.persistJobSnapshot(b,{forcePreview:!0}),ac(b)}}function ab({apiKey:a,proxyOptions:b}){return new q({apiKey:a,proxyOptions:b})}function ac(a,b={}){return a?{jobId:a.jobId,status:a.status,summary:function(a=[]){let b={total:a.length,queued:0,running:0,completed:0,success:0,failed:0,needs_manual:0,cancelled:0};for(let c of a){let a=c.status||"queued";"success"===a?(b.success+=1,b.completed+=1):"failed"===a||"failed_exchange"===a?(b.failed+=1,b.completed+=1):"needs_manual"===a?b.needs_manual+=1:"cancelled"===a?(b.cancelled+=1,b.completed+=1):"running"===a?b.running+=1:b.queued+=1}return b}(a.accounts),concurrency:a.concurrency,engine:a.engine,proxyPoolMode:a.proxyPoolMode,region:a.region,createdAt:a.createdAt,startedAt:a.startedAt,finishedAt:a.finishedAt,error:a.error,cancelRequested:a.cancelRequested,accounts:(a.accounts||[]).map(a=>({line:a.line,region:a.region,phone:a.phone,fiveSimOrderId:a.fiveSimOrderId,proxyUrl:a.proxyUrl?function(a){if(!a)return null;try{let b=new URL(a);return b.password&&(b.password="***"),b.toString()}catch{return a}}(a.proxyUrl):null,status:a.status,error:a.error,connectionId:a.connectionId,workerId:a.workerId,manualSessionAvailable:!!a.manualSession,currentStep:a.currentStep,updatedAt:a.updatedAt,logs:a.logs||[]})),preview:void 0!==b.preview?b.preview:a.lastPreview||null,...b}:null}function ad(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new aa}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};
|