zevairouter 1.0.149 → 1.0.151

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.
Files changed (333) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cli/app/.next-cli-build/BUILD_ID +1 -1
  3. package/cli/app/.next-cli-build/app-path-routes-manifest.json +11 -11
  4. package/cli/app/.next-cli-build/build-manifest.json +2 -2
  5. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/automation/page_client-reference-manifest.js +1 -1
  6. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  11. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/context/page_client-reference-manifest.js +1 -1
  12. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  17. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  18. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  19. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  20. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  22. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  23. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  24. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
  25. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
  26. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  27. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/terminal/page_client-reference-manifest.js +1 -1
  28. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  29. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/cli/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/cli/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  32. package/cli/app/.next-cli-build/server/app/_global-error.html +1 -1
  33. package/cli/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  34. package/cli/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  35. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  36. package/cli/app/.next-cli-build/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  37. package/cli/app/.next-cli-build/server/app/_global-error.segments/_head.segment.rsc +1 -1
  38. package/cli/app/.next-cli-build/server/app/_global-error.segments/_index.segment.rsc +1 -1
  39. package/cli/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  40. package/cli/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  41. package/cli/app/.next-cli-build/server/app/_not-found.html +1 -1
  42. package/cli/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  43. package/cli/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  44. package/cli/app/.next-cli-build/server/app/_not-found.segments/_head.segment.rsc +1 -1
  45. package/cli/app/.next-cli-build/server/app/_not-found.segments/_index.segment.rsc +3 -3
  46. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  47. package/cli/app/.next-cli-build/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  48. package/cli/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  49. package/cli/app/.next-cli-build/server/app/api/models/route.js +1 -1
  50. package/cli/app/.next-cli-build/server/app/api/oauth/cloudflare-ai/bulk-import/[jobId]/cancel/route.js +1 -1
  51. package/cli/app/.next-cli-build/server/app/api/oauth/cloudflare-ai/bulk-import/[jobId]/manual/[workerId]/route.js +1 -1
  52. package/cli/app/.next-cli-build/server/app/api/oauth/cloudflare-ai/bulk-import/[jobId]/route.js +1 -1
  53. package/cli/app/.next-cli-build/server/app/api/oauth/cloudflare-ai/bulk-import/latest/route.js +1 -1
  54. package/cli/app/.next-cli-build/server/app/api/oauth/cloudflare-ai/bulk-import/route.js +1 -1
  55. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/cancel/route.js +1 -1
  56. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/manual/[workerId]/route.js +1 -1
  57. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/[jobId]/route.js +1 -1
  58. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/latest/route.js +1 -1
  59. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/bulk-import/route.js +1 -1
  60. package/cli/app/.next-cli-build/server/app/api/oauth/kiro/import/route.js +1 -1
  61. package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/cancel/route.js +1 -1
  62. package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/manual/[workerId]/route.js +1 -1
  63. package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/[jobId]/route.js +1 -1
  64. package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/latest/route.js +1 -1
  65. package/cli/app/.next-cli-build/server/app/api/oauth/qoder/bulk-import/route.js +1 -1
  66. package/cli/app/.next-cli-build/server/app/api/providers/route.js +1 -1
  67. package/cli/app/.next-cli-build/server/app/api/providers/validate/route.js +1 -1
  68. package/cli/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
  69. package/cli/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
  70. package/cli/app/.next-cli-build/server/app/api/version/route.js +1 -1
  71. package/cli/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
  72. package/cli/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
  73. package/cli/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  74. package/cli/app/.next-cli-build/server/app/callback.html +1 -1
  75. package/cli/app/.next-cli-build/server/app/callback.rsc +3 -3
  76. package/cli/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  77. package/cli/app/.next-cli-build/server/app/callback.segments/_head.segment.rsc +1 -1
  78. package/cli/app/.next-cli-build/server/app/callback.segments/_index.segment.rsc +3 -3
  79. package/cli/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  80. package/cli/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
  81. package/cli/app/.next-cli-build/server/app/callback.segments/callback.segment.rsc +1 -1
  82. package/cli/app/.next-cli-build/server/app/dashboard/automation.html +1 -1
  83. package/cli/app/.next-cli-build/server/app/dashboard/automation.rsc +5 -5
  84. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation/__PAGE__.segment.rsc +2 -2
  85. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard/automation.segment.rsc +1 -1
  86. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  87. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  88. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_full.segment.rsc +5 -5
  89. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_head.segment.rsc +1 -1
  90. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_index.segment.rsc +3 -3
  91. package/cli/app/.next-cli-build/server/app/dashboard/automation.segments/_tree.segment.rsc +1 -1
  92. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
  93. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
  94. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +2 -2
  95. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat.segment.rsc +1 -1
  96. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  97. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  98. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
  99. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_head.segment.rsc +1 -1
  100. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_index.segment.rsc +3 -3
  101. package/cli/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
  102. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
  103. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
  104. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +2 -2
  105. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools.segment.rsc +1 -1
  106. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  107. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  108. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
  109. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_head.segment.rsc +1 -1
  110. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_index.segment.rsc +3 -3
  111. package/cli/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
  112. package/cli/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
  113. package/cli/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
  114. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +2 -2
  115. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos.segment.rsc +1 -1
  116. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  117. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  118. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
  119. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_head.segment.rsc +1 -1
  120. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_index.segment.rsc +3 -3
  121. package/cli/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
  122. package/cli/app/.next-cli-build/server/app/dashboard/context.html +1 -1
  123. package/cli/app/.next-cli-build/server/app/dashboard/context.rsc +5 -5
  124. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context/__PAGE__.segment.rsc +2 -2
  125. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard/context.segment.rsc +1 -1
  126. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  127. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  128. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_full.segment.rsc +5 -5
  129. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_head.segment.rsc +1 -1
  130. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_index.segment.rsc +3 -3
  131. package/cli/app/.next-cli-build/server/app/dashboard/context.segments/_tree.segment.rsc +1 -1
  132. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
  133. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
  134. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +2 -2
  135. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint.segment.rsc +1 -1
  136. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  137. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  138. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
  139. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_head.segment.rsc +1 -1
  140. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_index.segment.rsc +3 -3
  141. package/cli/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
  142. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
  143. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
  144. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +2 -2
  145. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web.segment.rsc +1 -1
  146. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers.segment.rsc +1 -1
  147. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  148. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  149. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
  150. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_head.segment.rsc +1 -1
  151. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_index.segment.rsc +3 -3
  152. package/cli/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
  153. package/cli/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
  154. package/cli/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
  155. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +2 -2
  156. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm.segment.rsc +1 -1
  157. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  158. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  159. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
  160. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_head.segment.rsc +1 -1
  161. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_index.segment.rsc +3 -3
  162. package/cli/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
  163. package/cli/app/.next-cli-build/server/app/dashboard/playground.html +1 -1
  164. package/cli/app/.next-cli-build/server/app/dashboard/playground.rsc +5 -5
  165. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground/__PAGE__.segment.rsc +2 -2
  166. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard/playground.segment.rsc +1 -1
  167. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  168. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  169. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_full.segment.rsc +5 -5
  170. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_head.segment.rsc +1 -1
  171. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_index.segment.rsc +3 -3
  172. package/cli/app/.next-cli-build/server/app/dashboard/playground.segments/_tree.segment.rsc +1 -1
  173. package/cli/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
  174. package/cli/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
  175. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +2 -2
  176. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile.segment.rsc +1 -1
  177. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  178. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  179. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
  180. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_head.segment.rsc +1 -1
  181. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_index.segment.rsc +3 -3
  182. package/cli/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
  183. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
  184. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
  185. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +2 -2
  186. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new.segment.rsc +1 -1
  187. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  188. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  189. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  190. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
  191. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_head.segment.rsc +1 -1
  192. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_index.segment.rsc +3 -3
  193. package/cli/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
  194. package/cli/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
  195. package/cli/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
  196. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +2 -2
  197. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers.segment.rsc +1 -1
  198. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  199. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  200. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
  201. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_head.segment.rsc +1 -1
  202. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_index.segment.rsc +3 -3
  203. package/cli/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
  204. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
  205. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
  206. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +2 -2
  207. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools.segment.rsc +1 -1
  208. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  209. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  210. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
  211. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_head.segment.rsc +1 -1
  212. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_index.segment.rsc +3 -3
  213. package/cli/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
  214. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
  215. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
  216. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +2 -2
  217. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe.segment.rsc +1 -1
  218. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  219. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  220. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
  221. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_head.segment.rsc +1 -1
  222. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_index.segment.rsc +3 -3
  223. package/cli/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
  224. package/cli/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
  225. package/cli/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
  226. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +3 -3
  227. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota.segment.rsc +1 -1
  228. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  229. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  230. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
  231. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_head.segment.rsc +1 -1
  232. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_index.segment.rsc +3 -3
  233. package/cli/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
  234. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  235. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  236. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  237. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  238. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
  239. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +3 -3
  240. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  241. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
  242. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
  243. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
  244. package/cli/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
  245. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
  246. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
  247. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +2 -2
  248. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver.segment.rsc +1 -1
  249. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  250. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  251. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
  252. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_head.segment.rsc +1 -1
  253. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_index.segment.rsc +3 -3
  254. package/cli/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
  255. package/cli/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
  256. package/cli/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
  257. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +2 -2
  258. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator.segment.rsc +1 -1
  259. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  260. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  261. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
  262. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_head.segment.rsc +1 -1
  263. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_index.segment.rsc +3 -3
  264. package/cli/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
  265. package/cli/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
  266. package/cli/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
  267. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +2 -2
  268. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage.segment.rsc +1 -1
  269. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  270. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  271. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
  272. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_head.segment.rsc +1 -1
  273. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_index.segment.rsc +3 -3
  274. package/cli/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
  275. package/cli/app/.next-cli-build/server/app/dashboard.html +1 -1
  276. package/cli/app/.next-cli-build/server/app/dashboard.rsc +5 -5
  277. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +2 -2
  278. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard.segment.rsc +1 -1
  279. package/cli/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  280. package/cli/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
  281. package/cli/app/.next-cli-build/server/app/dashboard.segments/_head.segment.rsc +1 -1
  282. package/cli/app/.next-cli-build/server/app/dashboard.segments/_index.segment.rsc +3 -3
  283. package/cli/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
  284. package/cli/app/.next-cli-build/server/app/index.html +1 -1
  285. package/cli/app/.next-cli-build/server/app/index.rsc +3 -3
  286. package/cli/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  287. package/cli/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  288. package/cli/app/.next-cli-build/server/app/index.segments/_head.segment.rsc +1 -1
  289. package/cli/app/.next-cli-build/server/app/index.segments/_index.segment.rsc +3 -3
  290. package/cli/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  291. package/cli/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  292. package/cli/app/.next-cli-build/server/app/landing.html +1 -1
  293. package/cli/app/.next-cli-build/server/app/landing.rsc +4 -4
  294. package/cli/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +4 -4
  295. package/cli/app/.next-cli-build/server/app/landing.segments/_head.segment.rsc +1 -1
  296. package/cli/app/.next-cli-build/server/app/landing.segments/_index.segment.rsc +3 -3
  297. package/cli/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  298. package/cli/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +2 -2
  299. package/cli/app/.next-cli-build/server/app/landing.segments/landing.segment.rsc +1 -1
  300. package/cli/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  301. package/cli/app/.next-cli-build/server/app/login.html +1 -1
  302. package/cli/app/.next-cli-build/server/app/login.rsc +4 -4
  303. package/cli/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
  304. package/cli/app/.next-cli-build/server/app/login.segments/_head.segment.rsc +1 -1
  305. package/cli/app/.next-cli-build/server/app/login.segments/_index.segment.rsc +3 -3
  306. package/cli/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  307. package/cli/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  308. package/cli/app/.next-cli-build/server/app/login.segments/login.segment.rsc +1 -1
  309. package/cli/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  310. package/cli/app/.next-cli-build/server/app-paths-manifest.json +11 -11
  311. package/cli/app/.next-cli-build/server/chunks/1019.js +1 -1
  312. package/cli/app/.next-cli-build/server/chunks/3155.js +1 -1
  313. package/cli/app/.next-cli-build/server/chunks/4566.js +1 -1
  314. package/cli/app/.next-cli-build/server/chunks/4746.js +1 -1
  315. package/cli/app/.next-cli-build/server/chunks/5000.js +1 -1
  316. package/cli/app/.next-cli-build/server/chunks/5307.js +1 -1
  317. package/cli/app/.next-cli-build/server/chunks/5949.js +3 -3
  318. package/cli/app/.next-cli-build/server/chunks/8306.js +1 -1
  319. package/cli/app/.next-cli-build/server/chunks/8371.js +1 -1
  320. package/cli/app/.next-cli-build/server/chunks/9621.js +1 -1
  321. package/cli/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  322. package/cli/app/.next-cli-build/server/pages/404.html +1 -1
  323. package/cli/app/.next-cli-build/server/pages/500.html +1 -1
  324. package/cli/app/.next-cli-build/static/chunks/{620-104e711e028e5a60.js → 620-e4b9eeb811dd9f2e.js} +1 -1
  325. package/cli/app/CHANGELOG.md +14 -0
  326. package/cli/app/package.json +1 -1
  327. package/cli/package.json +1 -1
  328. package/package.json +1 -1
  329. package/src/lib/oauth/services/bulkImportBrowserEngine.js +287 -4
  330. package/src/lib/oauth/services/codebuddyCnBulkImportManager.js +216 -7
  331. package/src/lib/oauth/services/kiroBulkImportManager.js +12 -9
  332. /package/cli/app/.next-cli-build/static/{w0fFe0wlenV7JedZI_N94 → nSCRy0gnXuQuQ0zz0lV8w}/_buildManifest.js +0 -0
  333. /package/cli/app/.next-cli-build/static/{w0fFe0wlenV7JedZI_N94 → nSCRy0gnXuQuQ0zz0lV8w}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- exports.id=8306,exports.ids=[8306],exports.modules={30869:(a,b,c)=>{"use strict";c.d(b,{UY:()=>h,X3:()=>i,eh:()=>f.eh,fg:()=>e.fg,h0:()=>g});var d=c(39006),e=c(75681),f=c(81329);d.version;let g={npmPackageName:"zevairouter",installCmd:"npm i -g zevairouter",installCmdLatest:"npm i -g zevairouter@latest --prefer-online",shutdownCountdownSec:3,exitDelayMs:500,statusPort:20129,statusPollIntervalMs:1e3,statusLogTailLines:8,installRetries:3,installRetryDelayMs:5e3,lingerAfterDoneMs:3e4,waitForExitMinMs:5e3,waitForExitMaxMs:2e4,waitForExitCheckMs:500,appPort:1997},h={maxLines:200,pollIntervalMs:1e3},i={openrouter:"https://openrouter.ai/api/v1/chat/completions",glm:"https://api.z.ai/api/anthropic/v1/messages","glm-cn":"https://open.bigmodel.cn/api/coding/paas/v4/chat/completions",kimi:"https://api.kimi.com/coding/v1/messages",minimax:"https://api.minimax.io/anthropic/v1/messages","minimax-cn":"https://api.minimaxi.com/anthropic/v1/messages",alicode:"https://coding.dashscope.aliyuncs.com/v1/chat/completions","alicode-intl":"https://coding-intl.dashscope.aliyuncs.com/v1/chat/completions","volcengine-ark":"https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions",byteplus:"https://ark.ap-southeast.bytepluses.com/api/coding/v3/chat/completions",openai:"https://api.openai.com/v1/chat/completions","vercel-ai-gateway":"https://ai-gateway.vercel.sh/v1/chat/completions",anthropic:"https://api.anthropic.com/v1/messages",gemini:"https://generativelanguage.googleapis.com/v1beta/models",ollama:"https://ollama.com/api/chat","ollama-local":"http://localhost:11434/api/chat"}},38238:(a,b,c)=>{"use strict";c.d(b,{P:()=>h});var d=c(89718),e=c(30869),f=c(54603);async function g(){let a=null;try{let b=await (0,d.PX)(!0);a=b.find(a=>!1!==a.isActive)?.key||null}catch{}let b={"Content-Type":"application/json"};return a&&(b.Authorization=`Bearer ${a}`),b["x-zevai-cli-token"]=await (0,f.Xj)("zevai-cli-auth"),b}async function h(a,b,c=`http://127.0.0.1:${process.env.PORT||e.h0.appPort}`){let d=await g(),f=Date.now();if("embedding"===b){let b=await fetch(`${c}/api/v1/embeddings`,{method:"POST",headers:d,body:JSON.stringify({model:a,input:"test"}),signal:AbortSignal.timeout(15e3)}),e=Date.now()-f,g=await b.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{}if(!b.ok){let a=h?.error?.message||h?.error||g;return{ok:!1,latencyMs:e,error:`HTTP ${b.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:b.status}}return Array.isArray(h?.data)&&h.data.length>0&&Array.isArray(h.data[0]?.embedding)?{ok:!0,latencyMs:e,error:null,status:b.status}:{ok:!1,latencyMs:e,status:b.status,error:"Provider returned no embedding data"}}if("image"===b){let b=await fetch(`${c}/api/v1/images/generations`,{method:"POST",headers:d,body:JSON.stringify({model:a,prompt:"test"}),signal:AbortSignal.timeout(15e3)}),e=Date.now()-f,g=await b.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{}if(!b.ok){let a=h?.error?.message||h?.msg||h?.message||h?.error||g;return{ok:!1,latencyMs:e,error:`HTTP ${b.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:b.status}}return Array.isArray(h?.data)&&h.data.length>0?{ok:!0,latencyMs:e,error:null,status:b.status}:{ok:!1,latencyMs:e,status:b.status,error:"Provider returned no image data for this model"}}if("stt"===b){let b,e,g,h,i=new FormData,j=(g=new DataView(e=new ArrayBuffer(44+(b=2*Math.max(1,Math.floor(4e3))))),(h=(a,b)=>{for(let c=0;c<b.length;c+=1)g.setUint8(a+c,b.charCodeAt(c))})(0,"RIFF"),g.setUint32(4,36+b,!0),h(8,"WAVE"),h(12,"fmt "),g.setUint32(16,16,!0),g.setUint16(20,1,!0),g.setUint16(22,1,!0),g.setUint32(24,16e3,!0),g.setUint32(28,32e3,!0),g.setUint16(32,2,!0),g.setUint16(34,16,!0),h(36,"data"),g.setUint32(40,b,!0),new Blob([e],{type:"audio/wav"}));i.append("file",j,"test.wav"),i.append("model",a);let k=await fetch(`${c}/api/v1/audio/transcriptions`,{method:"POST",headers:Object.fromEntries(Object.entries(d).filter(([a])=>"content-type"!==a.toLowerCase())),body:i,signal:AbortSignal.timeout(15e3)}),l=Date.now()-f,m=await k.text().catch(()=>""),n=null;try{n=m?JSON.parse(m):null}catch{}if(!k.ok){let a=n?.error?.message||n?.msg||n?.message||n?.error||m;return{ok:!1,latencyMs:l,error:`HTTP ${k.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:k.status}}return("string"==typeof n?.text?n.text:"").trim()?{ok:!0,latencyMs:l,error:null,status:k.status}:{ok:!1,latencyMs:l,status:k.status,error:"Provider returned no transcription text for this model"}}let i=await fetch(`${c}/api/v1/chat/completions`,{method:"POST",headers:d,body:JSON.stringify({model:a,max_tokens:1,stream:!1,messages:[{role:"user",content:"hi"}]}),signal:AbortSignal.timeout(15e3)}),j=Date.now()-f,k=await i.text().catch(()=>""),l=null;try{l=k?JSON.parse(k):null}catch{}if(!i.ok){let a=l?.error?.message||l?.msg||l?.message||l?.error||k;return{ok:!1,latencyMs:j,error:`HTTP ${i.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:i.status}}let m=l?.status,n=l?.msg||l?.message;if(null!=m&&"200"!==String(m)&&"0"!==String(m)&&n)return{ok:!1,latencyMs:j,status:i.status,error:`Provider status ${m}: ${String(n).slice(0,240)}`};if(l?.error){let a=l?.error?.message||l?.error||"Provider returned an error";return{ok:!1,latencyMs:j,status:i.status,error:String(a).slice(0,240)}}return Array.isArray(l?.choices)&&l.choices.length>0?{ok:!0,latencyMs:j,error:null,status:i.status}:{ok:!1,latencyMs:j,status:i.status,error:"Provider returned no completion choices for this model"}}},39006:a=>{"use strict";a.exports=JSON.parse('{"name":"zevairouter","version":"1.0.149","description":"Self-hosted AI router: many providers, one OpenAI-compatible /v1 endpoint and dashboard","bin":{"zevai":"./cli/cli.js"},"files":["cli/","src/","public/","scripts/","i18n/","assets/","images/","open-sse/","next.config.mjs","postcss.config.mjs","jsconfig.json","start.sh","package.json","README.md","LICENSE","CHANGELOG.md"],"scripts":{"dev":"next dev --webpack --port 1997","build":"next build --webpack","start":"node ./scripts/start-standalone.mjs","dev:bun":"bun --bun next dev --webpack --port 1997","build:bun":"bun --bun next build --webpack","start:bun":"bun ./.next/standalone/server.js","build:cli":"node cli/scripts/build-cli.js","release":"node cli/scripts/release.js","prepack":"node cli/scripts/build-cli.js","postinstall":"node cli/hooks/postinstall.js || exit 0"},"dependencies":{"@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@monaco-editor/react":"^4.7.0","@xterm/addon-fit":"^0.11.0","@xterm/addon-web-links":"^0.12.0","@xterm/xterm":"^6.0.0","@xyflow/react":"^12.10.1","bcryptjs":"^3.0.3","confbox":"^0.2.4","express":"^5.2.1","http-proxy-middleware":"^3.0.7","jose":"^6.1.3","marked":"^18.0.1","material-symbols":"^0.45.1","monaco-editor":"^0.55.1","next":"^16.2.12","node-forge":"^1.3.3","node-machine-id":"^1.1.12","open":"^11.0.0","ora":"^9.1.0","react":"19.2.4","react-dom":"19.2.4","react-is":"^19.2.7","recharts":"^3.7.0","selfsigned":"^5.5.0","socks":"^2.8.9","socks-proxy-agent":"^10.1.0","sql.js":"^1.14.1","undici":"^8.7.0","uuid":"^14.0.1","zustand":"^5.0.10"},"comment_optional_runtime":"Heavy packages are installed into ~/.zevai/runtime instead of the published tarball. Automation uses Playwright Chromium only; ZEVAI_MINIMAL_POSTINSTALL=1 skips its browser download. Other lazy runtimes are better-sqlite3 and node-pty.","overrides":{"dompurify":"^3.4.12","postcss":"^8.5.10"},"comment_overrides":"dompurify: monaco-editor@0.55.1 pins vulnerable dompurify@3.2.7 (multiple mXSS advisories, all fixed in 3.4.x). Override forces the patched 3.4.12 until monaco ships a stable release with the fix (currently only in 0.56.0-dev). We don\'t use dompurify directly; monaco only uses it to sanitize HTML hover/completion output.","devDependencies":{"@tailwindcss/postcss":"^4.1.18","better-sqlite3":"^12.6.2","esbuild":"^0.28.1","eslint":"^9","eslint-config-next":"16.2.9","postcss":"^8.5.10","tailwindcss":"^4"},"engines":{"node":">=22.5.0"},"keywords":["zevairouter","zevai","ai","router","proxy","kiro","codebuddy","claude","openai","api","quota","automation"],"license":"MIT","repository":{"type":"git","url":"https://github.com/Verifiedlabs/zevairouter"},"homepage":"https://github.com/Verifiedlabs/zevairouter"}')},54603:(a,b,c)=>{"use strict";c.d(b,{Xj:()=>q});var d=c(19713),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(77598),j=c.n(i),k=c(49120);let l=h().join(k.DATA_DIR,"machine-id"),m=h().join(k.DATA_DIR,"auth"),n=h().join(m,"cli-secret"),o=null,p=null;async function q(a=null){let b=a||process.env.MACHINE_ID_SALT||"endpoint-proxy-salt",c=function(){if(o)return o;try{if(o=f().readFileSync(l,"utf8").trim())return o}catch{}try{o=(0,d.machineIdSync)()}catch{o=j().randomUUID()}try{f().mkdirSync(k.DATA_DIR,{recursive:!0}),f().writeFileSync(l,o,{mode:384})}catch{}return o}(),e="zevai-cli-auth"===b?function(){if(p)return p;try{if(p=f().readFileSync(n,"utf8").trim())return p}catch{}p=j().randomBytes(32).toString("hex");try{f().mkdirSync(m,{recursive:!0}),f().writeFileSync(n,p,{mode:384})}catch{}return p}():"";return j().createHash("sha256").update(c+b+e).digest("hex").substring(0,16)}},78335:()=>{},81329:(a,b,c)=>{"use strict";c.d(b,{Xg:()=>d.Xg,eh:()=>e,vq:()=>d.vq});var d=c(44404);Object.entries(c(75681).AI_PROVIDERS).filter(([,a])=>a.passthroughModels).map(([a])=>a);let e=Object.entries(d.vq).flatMap(([a,b])=>b.map(b=>({provider:a,model:b.id,name:b.name})))},89718:(a,b,c)=>{"use strict";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,PX:()=>d.PX,Pb:()=>d.Pb,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,deleteModelAlias:()=>d.fv,ek:()=>d.ek,fK:()=>d.fK,getModelAliases:()=>d.OM,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,tV:()=>d.tV,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(80601)},96487:()=>{}};
1
+ exports.id=8306,exports.ids=[8306],exports.modules={30869:(a,b,c)=>{"use strict";c.d(b,{UY:()=>h,X3:()=>i,eh:()=>f.eh,fg:()=>e.fg,h0:()=>g});var d=c(39006),e=c(75681),f=c(81329);d.version;let g={npmPackageName:"zevairouter",installCmd:"npm i -g zevairouter",installCmdLatest:"npm i -g zevairouter@latest --prefer-online",shutdownCountdownSec:3,exitDelayMs:500,statusPort:20129,statusPollIntervalMs:1e3,statusLogTailLines:8,installRetries:3,installRetryDelayMs:5e3,lingerAfterDoneMs:3e4,waitForExitMinMs:5e3,waitForExitMaxMs:2e4,waitForExitCheckMs:500,appPort:1997},h={maxLines:200,pollIntervalMs:1e3},i={openrouter:"https://openrouter.ai/api/v1/chat/completions",glm:"https://api.z.ai/api/anthropic/v1/messages","glm-cn":"https://open.bigmodel.cn/api/coding/paas/v4/chat/completions",kimi:"https://api.kimi.com/coding/v1/messages",minimax:"https://api.minimax.io/anthropic/v1/messages","minimax-cn":"https://api.minimaxi.com/anthropic/v1/messages",alicode:"https://coding.dashscope.aliyuncs.com/v1/chat/completions","alicode-intl":"https://coding-intl.dashscope.aliyuncs.com/v1/chat/completions","volcengine-ark":"https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions",byteplus:"https://ark.ap-southeast.bytepluses.com/api/coding/v3/chat/completions",openai:"https://api.openai.com/v1/chat/completions","vercel-ai-gateway":"https://ai-gateway.vercel.sh/v1/chat/completions",anthropic:"https://api.anthropic.com/v1/messages",gemini:"https://generativelanguage.googleapis.com/v1beta/models",ollama:"https://ollama.com/api/chat","ollama-local":"http://localhost:11434/api/chat"}},38238:(a,b,c)=>{"use strict";c.d(b,{P:()=>h});var d=c(89718),e=c(30869),f=c(54603);async function g(){let a=null;try{let b=await (0,d.PX)(!0);a=b.find(a=>!1!==a.isActive)?.key||null}catch{}let b={"Content-Type":"application/json"};return a&&(b.Authorization=`Bearer ${a}`),b["x-zevai-cli-token"]=await (0,f.Xj)("zevai-cli-auth"),b}async function h(a,b,c=`http://127.0.0.1:${process.env.PORT||e.h0.appPort}`){let d=await g(),f=Date.now();if("embedding"===b){let b=await fetch(`${c}/api/v1/embeddings`,{method:"POST",headers:d,body:JSON.stringify({model:a,input:"test"}),signal:AbortSignal.timeout(15e3)}),e=Date.now()-f,g=await b.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{}if(!b.ok){let a=h?.error?.message||h?.error||g;return{ok:!1,latencyMs:e,error:`HTTP ${b.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:b.status}}return Array.isArray(h?.data)&&h.data.length>0&&Array.isArray(h.data[0]?.embedding)?{ok:!0,latencyMs:e,error:null,status:b.status}:{ok:!1,latencyMs:e,status:b.status,error:"Provider returned no embedding data"}}if("image"===b){let b=await fetch(`${c}/api/v1/images/generations`,{method:"POST",headers:d,body:JSON.stringify({model:a,prompt:"test"}),signal:AbortSignal.timeout(15e3)}),e=Date.now()-f,g=await b.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{}if(!b.ok){let a=h?.error?.message||h?.msg||h?.message||h?.error||g;return{ok:!1,latencyMs:e,error:`HTTP ${b.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:b.status}}return Array.isArray(h?.data)&&h.data.length>0?{ok:!0,latencyMs:e,error:null,status:b.status}:{ok:!1,latencyMs:e,status:b.status,error:"Provider returned no image data for this model"}}if("stt"===b){let b,e,g,h,i=new FormData,j=(g=new DataView(e=new ArrayBuffer(44+(b=2*Math.max(1,Math.floor(4e3))))),(h=(a,b)=>{for(let c=0;c<b.length;c+=1)g.setUint8(a+c,b.charCodeAt(c))})(0,"RIFF"),g.setUint32(4,36+b,!0),h(8,"WAVE"),h(12,"fmt "),g.setUint32(16,16,!0),g.setUint16(20,1,!0),g.setUint16(22,1,!0),g.setUint32(24,16e3,!0),g.setUint32(28,32e3,!0),g.setUint16(32,2,!0),g.setUint16(34,16,!0),h(36,"data"),g.setUint32(40,b,!0),new Blob([e],{type:"audio/wav"}));i.append("file",j,"test.wav"),i.append("model",a);let k=await fetch(`${c}/api/v1/audio/transcriptions`,{method:"POST",headers:Object.fromEntries(Object.entries(d).filter(([a])=>"content-type"!==a.toLowerCase())),body:i,signal:AbortSignal.timeout(15e3)}),l=Date.now()-f,m=await k.text().catch(()=>""),n=null;try{n=m?JSON.parse(m):null}catch{}if(!k.ok){let a=n?.error?.message||n?.msg||n?.message||n?.error||m;return{ok:!1,latencyMs:l,error:`HTTP ${k.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:k.status}}return("string"==typeof n?.text?n.text:"").trim()?{ok:!0,latencyMs:l,error:null,status:k.status}:{ok:!1,latencyMs:l,status:k.status,error:"Provider returned no transcription text for this model"}}let i=await fetch(`${c}/api/v1/chat/completions`,{method:"POST",headers:d,body:JSON.stringify({model:a,max_tokens:1,stream:!1,messages:[{role:"user",content:"hi"}]}),signal:AbortSignal.timeout(15e3)}),j=Date.now()-f,k=await i.text().catch(()=>""),l=null;try{l=k?JSON.parse(k):null}catch{}if(!i.ok){let a=l?.error?.message||l?.msg||l?.message||l?.error||k;return{ok:!1,latencyMs:j,error:`HTTP ${i.status}${a?`: ${String(a).slice(0,240)}`:""}`,status:i.status}}let m=l?.status,n=l?.msg||l?.message;if(null!=m&&"200"!==String(m)&&"0"!==String(m)&&n)return{ok:!1,latencyMs:j,status:i.status,error:`Provider status ${m}: ${String(n).slice(0,240)}`};if(l?.error){let a=l?.error?.message||l?.error||"Provider returned an error";return{ok:!1,latencyMs:j,status:i.status,error:String(a).slice(0,240)}}return Array.isArray(l?.choices)&&l.choices.length>0?{ok:!0,latencyMs:j,error:null,status:i.status}:{ok:!1,latencyMs:j,status:i.status,error:"Provider returned no completion choices for this model"}}},39006:a=>{"use strict";a.exports=JSON.parse('{"name":"zevairouter","version":"1.0.151","description":"Self-hosted AI router: many providers, one OpenAI-compatible /v1 endpoint and dashboard","bin":{"zevai":"./cli/cli.js"},"files":["cli/","src/","public/","scripts/","i18n/","assets/","images/","open-sse/","next.config.mjs","postcss.config.mjs","jsconfig.json","start.sh","package.json","README.md","LICENSE","CHANGELOG.md"],"scripts":{"dev":"next dev --webpack --port 1997","build":"next build --webpack","start":"node ./scripts/start-standalone.mjs","dev:bun":"bun --bun next dev --webpack --port 1997","build:bun":"bun --bun next build --webpack","start:bun":"bun ./.next/standalone/server.js","build:cli":"node cli/scripts/build-cli.js","release":"node cli/scripts/release.js","prepack":"node cli/scripts/build-cli.js","postinstall":"node cli/hooks/postinstall.js || exit 0"},"dependencies":{"@dnd-kit/core":"^6.3.1","@dnd-kit/modifiers":"^9.0.0","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@monaco-editor/react":"^4.7.0","@xterm/addon-fit":"^0.11.0","@xterm/addon-web-links":"^0.12.0","@xterm/xterm":"^6.0.0","@xyflow/react":"^12.10.1","bcryptjs":"^3.0.3","confbox":"^0.2.4","express":"^5.2.1","http-proxy-middleware":"^3.0.7","jose":"^6.1.3","marked":"^18.0.1","material-symbols":"^0.45.1","monaco-editor":"^0.55.1","next":"^16.2.12","node-forge":"^1.3.3","node-machine-id":"^1.1.12","open":"^11.0.0","ora":"^9.1.0","react":"19.2.4","react-dom":"19.2.4","react-is":"^19.2.7","recharts":"^3.7.0","selfsigned":"^5.5.0","socks":"^2.8.9","socks-proxy-agent":"^10.1.0","sql.js":"^1.14.1","undici":"^8.7.0","uuid":"^14.0.1","zustand":"^5.0.10"},"comment_optional_runtime":"Heavy packages are installed into ~/.zevai/runtime instead of the published tarball. Automation uses Playwright Chromium only; ZEVAI_MINIMAL_POSTINSTALL=1 skips its browser download. Other lazy runtimes are better-sqlite3 and node-pty.","overrides":{"dompurify":"^3.4.12","postcss":"^8.5.10"},"comment_overrides":"dompurify: monaco-editor@0.55.1 pins vulnerable dompurify@3.2.7 (multiple mXSS advisories, all fixed in 3.4.x). Override forces the patched 3.4.12 until monaco ships a stable release with the fix (currently only in 0.56.0-dev). We don\'t use dompurify directly; monaco only uses it to sanitize HTML hover/completion output.","devDependencies":{"@tailwindcss/postcss":"^4.1.18","better-sqlite3":"^12.6.2","esbuild":"^0.28.1","eslint":"^9","eslint-config-next":"16.2.9","postcss":"^8.5.10","tailwindcss":"^4"},"engines":{"node":">=22.5.0"},"keywords":["zevairouter","zevai","ai","router","proxy","kiro","codebuddy","claude","openai","api","quota","automation"],"license":"MIT","repository":{"type":"git","url":"https://github.com/Verifiedlabs/zevairouter"},"homepage":"https://github.com/Verifiedlabs/zevairouter"}')},54603:(a,b,c)=>{"use strict";c.d(b,{Xj:()=>q});var d=c(19713),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(77598),j=c.n(i),k=c(49120);let l=h().join(k.DATA_DIR,"machine-id"),m=h().join(k.DATA_DIR,"auth"),n=h().join(m,"cli-secret"),o=null,p=null;async function q(a=null){let b=a||process.env.MACHINE_ID_SALT||"endpoint-proxy-salt",c=function(){if(o)return o;try{if(o=f().readFileSync(l,"utf8").trim())return o}catch{}try{o=(0,d.machineIdSync)()}catch{o=j().randomUUID()}try{f().mkdirSync(k.DATA_DIR,{recursive:!0}),f().writeFileSync(l,o,{mode:384})}catch{}return o}(),e="zevai-cli-auth"===b?function(){if(p)return p;try{if(p=f().readFileSync(n,"utf8").trim())return p}catch{}p=j().randomBytes(32).toString("hex");try{f().mkdirSync(m,{recursive:!0}),f().writeFileSync(n,p,{mode:384})}catch{}return p}():"";return j().createHash("sha256").update(c+b+e).digest("hex").substring(0,16)}},78335:()=>{},81329:(a,b,c)=>{"use strict";c.d(b,{Xg:()=>d.Xg,eh:()=>e,vq:()=>d.vq});var d=c(44404);Object.entries(c(75681).AI_PROVIDERS).filter(([,a])=>a.passthroughModels).map(([a])=>a);let e=Object.entries(d.vq).flatMap(([a,b])=>b.map(b=>({provider:a,model:b.id,name:b.name})))},89718:(a,b,c)=>{"use strict";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,PX:()=>d.PX,Pb:()=>d.Pb,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,deleteModelAlias:()=>d.fv,ek:()=>d.ek,fK:()=>d.fK,getModelAliases:()=>d.OM,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,tV:()=>d.tV,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(80601)},96487:()=>{}};
@@ -1 +1 @@
1
- "use strict";exports.id=8371,exports.ids=[8371],exports.modules={48371:(a,b,c)=>{c.d(b,{xM:()=>_,t9:()=>ae,TK:()=>ad,cO:()=>e.cO,VU:()=>as});var d=c(55511),e=c(13868),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=["button:has-text('同意')","text=同意并继续","text=同意"],x="#phone-iframe",y="#phoneNumber",z=".kc-country-option",A=".kc-country-code-text",B="#code",C=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],D=['[class*="avatar"]','[class*="user-info"]','[class*="logout"]',"text=退出登录","text=Logout","text=Sign out"],E=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"],F=new Set(["login_risk_state"]),G=["账号访问受限","安全策略限制","访问受限","account restricted","access restricted"];function H(a=[]){return a.some(a=>F.has(a?.name))}function I(a="Tencent risk policy rejected the post-OTP session"){return{status:"failed_restricted",error:`Account restricted after OTP (${a}). Use a different residential CN/HK proxy with concurrency 1; do not retry this number on the same egress IP.`}}async function J({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=>{var b,c;let d,e=a.request();return(b=e.url(),c=e.resourceType(),d=String(b||""),/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(d)||"media"===c||"image"===c&&!/captcha|tcaptcha|challenge|verify|qrcode/i.test(d))?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.waitForFunction(()=>"loading"!==document.readyState,{timeout:1e4}).catch(()=>{}),p();let d=await M(a,w,{timeout:6e3});d&&(await d.click().catch(()=>{}),o("cn_consent_dismissed","Privacy consent dialog dismissed (同意)"),await a.waitForTimeout(1e3));let e=await N(a,v,25e3);if(p(),!e){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 f=await M(a,u,{timeout:12e3});if(f?(await f.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(x).waitFor({state:"attached",timeout:18e3}).catch(()=>{}),i=await K(a)){if(await i.waitForSelector(y,{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(y,{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:z,localNumber:A}=(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 ${z} for phone ${s}`),await L(i,z,l,o),o("cn_entering_phone",`Entering phone number: ${A}`);let C=i.locator(y).first();try{await C.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}await O(C,A),o("cn_phone_entered",`Phone number entered: ${A}`);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 D=i.locator("input.btn-lg.code-btn").first(),E=!1;try{await D.waitFor({state:"visible",timeout:5e3}),E=!0}catch{let a=i.locator(".code-btn").first();try{await a.waitFor({state:"visible",timeout:5e3}),E=!0}catch{E=!1}}if(!E)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};await D.click().catch(()=>{}),o("cn_send_code_clicked","Send code button clicked"),await i.waitForSelector(B,{state:"visible",timeout:5e3}).catch(()=>{});let F=await W(i);if(F)return{status:"failed",error:`Form error after sending code: ${F}`};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 G=i.locator(B).first();try{await G.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}await O(G,f),o("cn_code_entered","Verification code entered");let J=1200+Math.floor(1800*Math.random());o("cn_pre_submit_pause",`Waiting ${J}ms before submit (humanize)`),await a.waitForTimeout(J);let P=Math.max(n,12e3),Q=!1;for(let b=0;b<2;b++){o("cn_submitting",`Clicking submit button (attempt ${b+1}/2)`);let c=await K(a);if(!c){let b=await R(a,{timeoutMs:5e3,reportStep:o});if(b.ok)return o("cn_session_cookies",`Keycloak session after iframe detach (${b.cookie})`),{status:"success"};if(H(b.cookies))return o("cn_account_restricted","Tencent login_risk_state present after iframe detached"),I("login_risk_state cookie present");return{status:"failed",error:"Lost phone iframe after submit"}}if(await c.locator(y).first().isVisible({timeout:3e3}).catch(()=>!1)&&b>0){o("cn_re_entering_after_refresh",`Re-entering phone + code after refresh (retry ${b})`),await L(c,z,l,o);let d=c.locator(y).first();await O(d,A);try{let b=a.locator(".t-checkbox").first();await b.isVisible({timeout:2e3}).catch(()=>!1)&&await b.click().catch(()=>{})}catch{}let e=c.locator(B).first();await e.isVisible({timeout:3e3}).catch(()=>!1)&&await O(e,f),await a.waitForTimeout(800+Math.floor(700*Math.random()))}if(await S(c,l),o("cn_submitted",`Registration form submitted (attempt ${b+1})`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1800),c=await K(a)||c,await V(a,c))return o("cn_account_restricted",`Account restricted after submit (attempt ${b+1}) — stopping automatic retries`),I("restriction message detected");if(o("cn_checking_captcha","Checking for captcha"),await X(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 W(c);if(d)return{status:"failed",error:`Form error after submit: ${d}`};o("cn_waiting_session",`Waiting up to ${Math.round(P/1e3)}s for Keycloak session cookies`);let e=await R(a,{timeoutMs:P,reportStep:o,alsoCheckFrame:()=>K(a)});if(e.ok)return o("cn_session_cookies",`Keycloak session cookies present (${e.cookie}) — registration success`),{status:"success"};if("restricted"===e.reason)return o("cn_account_restricted","Restriction detected while waiting for Keycloak session"),I("restriction message detected during session handoff");if(await T(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 R(a,{timeoutMs:1e4,reportStep:o});if(g.ok)return o("cn_session_cookies",`Keycloak session after home nudge (${g.cookie})`),{status:"success"};if("restricted"===g.reason)return o("cn_account_restricted","Restriction detected after home handoff"),I("restriction message detected after OIDC handoff");if(H(g.cookies))return o("cn_account_restricted","Home handoff returned no authenticated session and login_risk_state is present"),I("login_risk_state persisted after OIDC handoff");Q=!0;break}if(!Q)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 Z=await R(a,{timeoutMs:5e3});if(Z.ok)return o("cn_registration_success",`Phone registration completed (Keycloak session: ${Z.cookie})`),{status:"success"};if(H(Z.cookies))return o("cn_account_restricted","No authenticated session and Tencent login_risk_state is present — account restricted"),I("login_risk_state without an authenticated session");if(await Y(a,i,1e4))return o("cn_registration_success","Phone registration completed successfully (UI markers)"),{status:"success"};let $=await U(a);return o("cn_success_unconfirmed",`No Keycloak session after submit — ${$.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${$.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 K(a){try{await a.locator(x).waitFor({state:"attached",timeout:5e3});let b=await a.locator(x).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 L(a,b,c,d){if(!b)return;let e=Math.min(Number(c)||15e3,1e4),f=async()=>{let c=a.locator(A).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(z).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(`${z}: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(A).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 M(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 N(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 O(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 P=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];function Q(a=[]){for(let b of P)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 R(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=Q(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{}let h=d?await d().catch(()=>null):null;if(await V(a,h))return{ok:!1,cookies:b,reason:"restricted"};if(h){let a=await W(h);if(a)return{ok:!1,cookies:b,reason:`form_error:${a}`}}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 S(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(B).first().press("Enter").catch(()=>{})}}async function T(a){let b=await K(a);return!!b&&b.locator(y).first().isVisible({timeout:1500}).catch(()=>!1)}async function U(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 K(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 V(a,b){for(let c of[b,a])if(c)try{let a=await c.evaluate(()=>document.body?.innerText||"");if(function(a){let b=String(a||"").toLowerCase();return G.some(a=>b.includes(a.toLowerCase()))}(a))return!0}catch{}return!1}async function W(a){for(let b of E)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 X(a,b,c=5e3){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{}if(b)for(let a of C)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 Y(a,b,c=15e3){let d=[];try{if(d=await a.context().cookies().catch(()=>[]),Q(d))return!0}catch{}if(H(d)||await T(a).catch(()=>!1))return!1;for(let b of D)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=new Set(d.map(a=>a.name));if(b&&!b.includes("/login")&&!b.includes("/auth/realms")&&(c.has("qcloud_uid")||c.has("qcmainCSRFToken"))&&!c.has("login_risk_state")&&!await T(a).catch(()=>!1))return!0}catch{}return!1}var Z=c(40891),$=c(75949);let _=200,aa=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||3e5,ab="CN_API_KEY_OUTCOME_UNKNOWN",ac="CN_ACCOUNT_RESTRICTED",ad=new Set(["hongkong","china","any"]),ae="hongkong";function af(a){return String(a||"").trim()}function ag(){try{let{totalMemGb:a}=(0,h.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}async function ah(a,{timeoutMs:b,message:c,code:d,onTimeout:e,onLateResolve:f}){let g=Promise.resolve(a),h=null,i=!1,j=new Promise((a,f)=>{"function"==typeof(h=setTimeout(()=>{i=!0;try{"function"==typeof e&&e()}catch{}f(Object.assign(Error(c),{code:d}))},b)).unref&&h.unref()});try{return await Promise.race([g,j])}finally{h&&clearTimeout(h),i&&"function"==typeof f&&g.then(f).catch(()=>null)}}function ai(a){let b=`${a?.text||""} ${a?.data?._raw||""} ${a?.url||""}`;return/<!doctype html|<html|login-pf|\/auth\/realms\//i.test(b)}function aj(a,b=[]){let c=b instanceof Set?b:new Set(b),d=`${a?.text||""} ${a?.data?._raw||""}`;return!!/账号访问受限|安全策略限制|访问受限|account restricted|access restricted/i.test(d)||!!c.has("login_risk_state")&&(ai(a)||a?.status===0||a?.status===401||a?.status===403)}async function ak({context:a,page:b,timeoutMs:c=1e4}){let d={Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},e=null;try{e=a?.request||null}catch{e=null}if(e&&"function"==typeof e.get)try{let a=await e.get("https://www.codebuddy.cn/console/accounts",{headers:d,timeout:c,failOnStatusCode:!1}),b=await a.text().catch(()=>"");return function(a,b,c={}){let d=String(b||""),e=null;try{e=d?JSON.parse(d):null}catch{e={_raw:d.slice(0,240),_notJson:!0}}return{status:Number(a)||0,data:e,text:d.slice(0,240),...c}}(a.status(),b,{source:"context-request",url:a.url(),contentType:a.headers()?.["content-type"]||""})}catch{}return ah(b.evaluate(async({requestTimeoutMs:a,requestHeaders:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),a);try{let a=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===a?`${window.location.origin}`:"https://www.codebuddy.cn",e=await fetch(`${d}/console/accounts`,{credentials:"include",signal:c.signal,headers:b}),f=await e.text().catch(()=>""),g=null;try{g=f?JSON.parse(f):null}catch{g={_raw:String(f||"").slice(0,240),_notJson:!0}}return{status:e.status,data:g,text:String(f||"").slice(0,240),source:"page-fetch",url:e.url,contentType:e.headers.get("content-type")||""}}catch(a){return{status:0,timedOut:a?.name==="AbortError",error:a?.message||String(a),source:"page-fetch"}}finally{clearTimeout(d)}},{requestTimeoutMs:c,requestHeaders:d}),{timeoutMs:c,message:`Console account probe timed out after ${c/1e3}s`,code:"CN_CONSOLE_PROBE_TIMEOUT"}).catch(a=>({status:0,timedOut:a?.code==="CN_CONSOLE_PROBE_TIMEOUT",error:a?.message||String(a),source:"page-fetch"}))}async function al(a){if(!a||"function"!=typeof a.close)return!0;try{return await ah(Promise.resolve().then(()=>a.close()),{timeoutMs:5e3,message:"Browser resource close timed out after 5s",code:"CN_RESOURCE_CLOSE_TIMEOUT"}),!0}catch{return!1}}async function am(a,b){if(await al(a)||!b?.browser)return;let c=b.browser;b.browser=null,await (0,$.forceCloseBrowser)(c).catch(()=>null)}async function an(a){try{return await ah(Promise.resolve().then(a),{timeoutMs:12e3,message:"5sim order settlement timed out after 12s",code:"CN_FIVESIM_SETTLE_TIMEOUT"})}catch{return!1}}async function ao({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 ap extends e.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=Z.cT,pollToken:d=Z.ZV,fetchLoginAccountFn:e=Z.w8,saveConnection:f=ao,fiveSimClientFactory:g=aq,phoneAutomation:h=J,phoneFormatter:j=af,pollIntervalMs:k=i.ne.pollInterval,storageName:l="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{forceCloseBrowser:b,launchBulkImportBrowser:d}=await Promise.resolve().then(c.bind(c,75949)),e=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null,f=process.env.ZEVAI_CN_HEADLESS,g=!1;return("0"===f||"false"===f)&&(g=!1),("1"===f||"true"===f)&&(g=!0),ah(d({engine:a?.engine||"cloakbrowser",proxyUrl:e,headless:g,windowSize:{width:1280,height:900}}),{timeoutMs:9e4,message:"CloakBrowser launch timed out after 90s",code:"CN_BROWSER_LAUNCH_TIMEOUT",onLateResolve:a=>b(a)})}),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,proxyPoolMode:c,proxyPoolId:g,manualProxyUrl:i,region:j}){let k=Number.parseInt(a,10);if(!Number.isFinite(k)||k<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(k>_)throw Object.assign(Error(`Count exceeds maximum of ${_}`),{error:`Count exceeds maximum of ${_}`});let l=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(l)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${l.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${l.jobId}). Cancel it or wait before starting again.`});let m=ad.has(j)?j:ae,n=[],o="string"==typeof i?i.trim():"";if(o){if(!/^(https?|socks4|socks5):\/\/.+/i.test(o))throw Object.assign(Error("manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"),{error:"manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"});n=[o]}else if("all"===c)n=(await (0,f.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===c&&g){let a=await (0,f.hr)(g);a?.isActive&&a?.proxyUrl&&(n=[a.proxyUrl])}let p=(0,d.randomUUID)(),q=(0,e.kF)(),r={jobId:p,status:"running",concurrency:function(a){let b=ag()?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),proxyPoolMode:o?"manual":c||"none",proxyUrls:n,region:m,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:k},(a,b)=>({line:b+1,region:m,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,fingerprintSeed:(0,d.randomUUID)(),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,r),this.latestJobId=p,await this.persistJobSnapshot(r,{forcePreview:!1}),this.runJob(p),ar(r)}getJob(a){let b=this.jobs.get(a);return b?ar(b):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),ar(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 f=null,h=null,i=!1,j=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let k=(await (0,g.mt)()).fiveSimApiKey;if(!k||!k.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}f=this.fiveSimClientFactory({apiKey:k,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0}),b.fingerprintSeed||(b.fingerprintSeed=(0,d.randomUUID)());let l=(0,e.go)(a.browser,b.proxyUrl,{profile:"codebuddy-cn",region:a.region||"hongkong",fingerprintSeed:b.fingerprintSeed,lowMemory:ag()}),m=await ah(l,{timeoutMs:3e4,message:"Browser context creation timed out after 30s",code:"CN_CONTEXT_TIMEOUT",onLateResolve:a=>Promise.resolve(a?.context?.close?.()).catch(()=>null)});j=m.context;let n=m.page;if(b.runtimeSession={context:j,page:n},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{n.setDefaultTimeout(2e4),n.setDefaultNavigationTimeout(45e3)}catch{}let o=null,p=new Promise((a,b)=>{o=setTimeout(()=>{b(Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(aa/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"}))},aa),"function"==typeof o.unref&&o.unref()});try{c=await Promise.race([this.phoneAutomation({page:n,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 f.buyNumber({country:a.region,product:"codebuddy",allowProductFallback:!1});return h=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(!h)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 f.pollCode(h,{timeoutMs:9e4,signal:b.abortController?.signal});return i=!0,c},onStep:(c,d)=>{this.setAccountStep(b,c,d),this.persistJobSnapshot(a,{forcePreview:!1})},phoneFormatter:this.phoneFormatter}),p])}finally{o&&clearTimeout(o)}if(String(c.status||"").startsWith("failed")){let d=c.error||"Phone registration failed before submit",e=c.status||"failed";this.finalizeAccount(b,e,{error:d,step:e,message:d}),f&&h&&(i?await an(()=>f.finishOrder(h)):await an(()=>f.cancelOrder(h))),b.runtimeSession=null,await am(j,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}await this.captureApiKey(a,b,j,n,f,h);return}catch(e){let c=e instanceof n,d=c?"SMS OTP not received within 90s — number banned":e.message||"Unexpected CodeBuddy CN bulk import failure";if(this.finalizeAccount(b,"failed",{error:d,step:c?"sms_timeout":"failed",message:d}),f&&h&&(i?await an(()=>f.finishOrder(h)):c?await an(()=>f.banOrder(h)):await an(()=>f.cancelOrder(h))),b.runtimeSession=null,await am(j,a),(e?.code==="CN_ACCOUNT_HARD_TIMEOUT"||e?.code==="CN_CONTEXT_TIMEOUT"||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,$.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id",h=async(a,{timeout:b=12e3,interval:c=150}={})=>{let d=Date.now()+b;for(;Date.now()<d;){try{if(await a())return!0}catch{}await new Promise(a=>setTimeout(a,c))}return!1};try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let i=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},j=a=>a.has("KEYCLOAK_IDENTITY")||a.has("KEYCLOAK_SESSION")||a.has("KEYCLOAK_IDENTITY_LEGACY")||a.has("KEYCLOAK_SESSION_LEGACY"),k=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken")||a.has("x_host_key_access"),l=()=>ak({context:c,page:d}),m=a=>{let b=a?.data;if(!b||"object"!=typeof b)return[];for(let a of[b?.data?.accounts,b?.accounts,b?.data?.list,b?.list,b?.data?.result,b?.result,b?.data?.items,b?.items,Array.isArray(b?.data)?b.data:null,Array.isArray(b)?b:null])if(Array.isArray(a)&&a.length>0)return a;return[]},n=async(a=2500)=>{let b=!1,c=null;try{await Promise.race([d.waitForLoadState("domcontentloaded",{timeout:a}).catch(()=>null),h(async()=>{if(b)return!0;let a=await i();return j(a.names)},{timeout:a,interval:200}),new Promise(b=>{c=setTimeout(b,a)})])}finally{b=!0,c&&clearTimeout(c)}},o=async a=>{let b=Date.now();try{await d.goto(a,{waitUntil:"commit",timeout:18e3});let c=18e3-(Date.now()-b);return c>0&&await n(Math.min(2500,c)),!0}catch{return!1}},p=["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/console/","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],q=[],r=null,s=!1,t="",u=null,v=0;for(let c=0;c<6;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await i(),f=j(e.names),g=k(e.names),h=p[Math.min(c,p.length-1)];c<3||c%2==0||!g?(this.setAccountStep(b,"waiting_session",`OIDC handoff ${c+1}/6 → ${h.replace("https://www.codebuddy.cn","")} (${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await o(h)):await new Promise(a=>setTimeout(a,300)),/^https:\/\/www\.codebuddy\.cn(?:[/:]|$)/i.test(d.url?.()||"")||await o("https://www.codebuddy.cn/console"),r=await l(),q=m(r),(r?.status>0||r?.text||r?.data)&&(u=r),t=JSON.stringify(r?.data??r?.text??r?.error??null).slice(0,180);let n=ai(r),w=await i();if(!j(w.names)&&aj(r,w.names)?v+=1:v=0,v>=2)throw Object.assign(Error(`Tencent restricted the post-OTP session (${v} console probes returned login/risk evidence; source=${r?.source||"unknown"})`),{code:ac});if(r?.status===200&&!n&&Array.isArray(q)&&q.length>0){s=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${q.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}if(g&&r?.status===200&&!n&&r?.data?._notJson!==!0&&Array.isArray(q)&&0===q.length&&c>=3){this.setAccountStep(b,"session_soft","Console HTTP 200 but 0 accounts — trying personal API key with soft session (cookies ok)"),await this.persistJobSnapshot(a,{forcePreview:!0}),s=!0;break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${r?.status||0}, accounts=${q.length}${n?", login HTML":""}, source=${r?.source||"unknown"}) — ${c+1}/6 body=${t.slice(0,80)}`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!s){let a=await i(),b=u||r,c=aj(b,a.names)||a.names.has("login_risk_state")&&v>0;throw Object.assign(Error(c?`Tencent restricted the post-OTP session (HTTP ${b?.status||0}; login_risk_state present; source=${b?.source||"unknown"})`:`Console accounts unavailable after login (HTTP ${b?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}; body=${t.slice(0,120)}; probeError=${r?.error||"none"}) — session not accepted for API key`),{code:c?ac:"CN_CONSOLE_SESSION_UNAVAILABLE"})}let w=g;if(Array.isArray(q)&&q.length>0){let a=q.find(a=>a?.lastLogin)||q[0];a?.type&&"personal"!==a.type&&a.enterpriseId?w=a.enterpriseId:a?.enterpriseId&&a?.type!=="personal"&&(w=a.enterpriseId)}this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${w}, accounts=${q.length})`),await this.persistJobSnapshot(a,{forcePreview:!0});let x=`zevai-router-${b.workerId||"account"}-${Date.now()}`,y=async a=>d.evaluate(async({enterpriseId:a,keyName:b,timeoutMs:c})=>{let d=new AbortController,e=setTimeout(()=>d.abort(),c);try{let c=window.location.hostname||"www.codebuddy.cn",e="www.codebuddy.cn"===c?window.location.origin:"https://www.codebuddy.cn",f=await fetch(`${e}/console/api/client/v1/api-keys`,{method:"POST",credentials:"include",signal:d.signal,headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:b,expire_in_days:365,user_enterprise_id:a})}),g=await f.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{h={_raw:String(g||"").slice(0,200)}}return{ok:f.ok,status:f.status,data:h}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,timedOut:a?.name==="AbortError",error:a?.message||String(a)}}finally{clearTimeout(e)}},{enterpriseId:a,keyName:x,timeoutMs:6e4}),z=async(c,d)=>{let e,f=Date.now(),g=null,h=setInterval(()=>{if(g)return;let c=Math.max(5,Math.round((Date.now()-f)/1e3));this.setAccountStep(b,"creating_api_key",`${d} — waiting for CodeBuddy (${c}s)`),g=this.persistJobSnapshot(a,{forcePreview:!1}).catch(()=>null).finally(()=>{g=null})},5e3);"function"==typeof h.unref&&h.unref();try{e=await ah(y(c),{timeoutMs:6e4,message:"API key request timed out after 60s; creation outcome is unknown",code:ab})}catch(a){if(a?.code===ab)throw a;throw Object.assign(Error(`API key request lost its response; creation outcome is unknown: ${a?.message||String(a)}`),{code:ab})}finally{clearInterval(h),g&&await g.catch(()=>null)}if(e?.outcomeUnknown){let a=e.timedOut?"timed out after 60s":`lost its response (${e.error||"network error"})`;throw Object.assign(Error(`API key request ${a}; creation outcome is unknown`),{code:ab})}return e};if(!await o("https://www.codebuddy.cn/profile/keys"))throw Object.assign(Error("Keys page navigation timed out after 18s"),{code:"CN_CONSOLE_NAV_TIMEOUT"});let A=await z(w,"Creating API key");A?.status===400&&w!==g&&(this.setAccountStep(b,"retrying_api_key","Retrying with personal-edition enterprise id"),await this.persistJobSnapshot(a,{forcePreview:!1}),A=await z(g,"Retrying personal API key"));let B=a=>a?.ok===!1&&(401===a.status||403===a.status);for(let c=1;c<=2&&B(A);c+=1){for(let d of(this.setAccountStep(b,"retrying_api_key",`API key 401/403 — OIDC re-handoff round ${c}/2 (waiting strong session)`),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await o(d);await h(async()=>{let a=await i();return j(a.names)},{timeout:8e3*c,interval:300}).catch(()=>null),A=await z(g,`Retrying API key after OIDC handoff ${c}/2`)}let C=A?.data?.code;if(!A||!A.ok||!A.data||0!==C&&200!==C&&void 0!==C){let a="string"==typeof A?.data?._raw?A.data._raw.replace(/\s+/g," ").slice(0,120):null,b=a&&/openresty|nginx|Authorization Required/i.test(a)?" [edge proxy blocked — session half-baked]":"";throw Error(`API key creation failed (HTTP ${A?.status??"no-response"}, code=${C??"n/a"})${b}: ${JSON.stringify(A?.data??null).slice(0,200)}`)}let D=A.data?.data||A.data,E=D?.apiKey||D?.key||D?.token||D?.secret||D?.api_key||("string"==typeof D?D:null)||A.data.apiKey||A.data.key||A.data.token||A.data.secret;if(!E||"string"!=typeof E)throw Object.assign(Error(`API key response did not contain a key field; creation outcome is unknown: ${JSON.stringify(A.data).slice(0,300)}`),{code:ab});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:F}=await this.saveConnection({apiKey:E,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await an(()=>e.finishOrder(f)),this.finalizeAccount(b,"success",{connectionId:F.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await am(c,a),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(j){let g=j?.code===ac,h=j?.code===ab;if(g){this.finalizeAccount(b,"failed_restricted",{error:`${j.message}. Use a different residential CN/HK proxy with concurrency 1.`,step:"failed_restricted",message:"Tencent restricted the post-OTP session; API-key capture was not attempted"}),await an(()=>e.finishOrder(f)),b.runtimeSession=null,await am(c,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}let i=h?`${j.message}. Check the CodeBuddy keys page before creating another key.`:j.message;if(this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${i}`,step:h?"api_key_outcome_unknown":"awaiting_manual",message:h?"Registration done; API key request outcome is unknown. Check existing keys before retrying.":`Registration done, API key capture failed: ${j.message}`}),await an(()=>e.finishOrder(f)),await this.persistJobSnapshot(a,{forcePreview:!0}),h){b.runtimeSession=null,await am(c,a);return}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 c=b.manualSession,e=c?.context||d,f=c?.headedBrowser||null;await am(e,a),f&&await (0,$.forceCloseBrowser)(f).catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let c=ag()?18e4:48e4,d=Date.now()+c,f=null,h=`zevai-router-manual-${b.workerId||"account"}-${Date.now()}`;for(;Date.now()<d&&!a.cancelRequested;){await new Promise(a=>setTimeout(a,1e4));try{if(!e.url().includes("codebuddy.cn"))continue;let a=await ah(e.evaluate(async({keyName:a,timeoutMs:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{let b=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===b?window.location.origin:"https://www.codebuddy.cn",e=await fetch(`${d}/console/api/client/v1/api-keys`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",signal:c.signal,body:JSON.stringify({name:a,expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),f=await e.json().catch(()=>null);return{ok:e.ok,status:e.status,data:f}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,error:a?.message||String(a)}}finally{clearTimeout(d)}},{keyName:h,timeoutMs:6e4}),{timeoutMs:6e4,message:"Manual API key request timed out; creation outcome is unknown",code:ab});if(a?.outcomeUnknown)throw Object.assign(Error(`Manual API key request lost its response; creation outcome is unknown: ${a.error||"network error"}`),{code:ab});if(a?.ok){let b=a.data?.data||a.data;if((f=b?.apiKey||b?.key||b?.token||b?.secret||b?.api_key||("string"==typeof b?b:null))&&"string"==typeof f)break;throw Object.assign(Error("Manual API key response was successful but did not contain the key; creation outcome is unknown"),{code:ab})}}catch(a){if(a?.code===ab)throw a}}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(!f)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:i}=await this.saveConnection({apiKey:f,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:i.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"}):c?.code===ab?this.finalizeAccount(b,"needs_manual",{error:`${c.message}. Check existing CodeBuddy keys before retrying.`,step:"api_key_outcome_unknown",message:"Manual API key request outcome is unknown; automatic retries stopped"}):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,$.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}),ar(b)}}function aq({apiKey:a,proxyOptions:b}){return new q({apiKey:a,proxyOptions:b})}function ar(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):a.startsWith("failed")?(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,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 as(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new ap}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};
1
+ "use strict";exports.id=8371,exports.ids=[8371],exports.modules={48371:(a,b,c)=>{c.d(b,{xM:()=>_,t9:()=>ae,TK:()=>ad,cO:()=>e.cO,VU:()=>au});var d=c(55511),e=c(13868),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=["button:has-text('同意')","text=同意并继续","text=同意"],x="#phone-iframe",y="#phoneNumber",z=".kc-country-option",A=".kc-country-code-text",B="#code",C=['iframe[src*="captcha"]','iframe[src*="tcaptcha"]',"#tcaptcha","#tcaptcha_transform",".nc_iconfont",".nc_wrapper",'[class*="captcha"]','[id*="captcha"]',"text=滑块","text=拖动"],D=['[class*="avatar"]','[class*="user-info"]','[class*="logout"]',"text=退出登录","text=Logout","text=Sign out"],E=["#input-error",".pf-c-form__helper-text.pf-m-error",".kc-feedback-text"],F=new Set(["login_risk_state"]),G=["账号访问受限","安全策略限制","访问受限","account restricted","access restricted"];function H(a=[]){return a.some(a=>F.has(a?.name))}function I(a="Tencent risk policy rejected the post-OTP session"){return{status:"failed_restricted",error:`Account restricted after OTP (${a}). Use a different residential CN/HK proxy with concurrency 1; do not retry this number on the same egress IP.`}}async function J({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=>{var b,c;let d,e=a.request();return(b=e.url(),c=e.resourceType(),d=String(b||""),/googletagmanager|googleadservices|google-analytics|doubleclick|facebook|hotjar|clarity\.ms|hm\.baidu|google\.com\/rmkt/i.test(d)||"media"===c||"image"===c&&!/captcha|tcaptcha|challenge|verify|qrcode/i.test(d))?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.waitForFunction(()=>"loading"!==document.readyState,{timeout:1e4}).catch(()=>{}),p();let d=await M(a,w,{timeout:6e3});d&&(await d.click().catch(()=>{}),o("cn_consent_dismissed","Privacy consent dialog dismissed (同意)"),await a.waitForTimeout(1e3));let e=await N(a,v,25e3);if(p(),!e){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 f=await M(a,u,{timeout:12e3});if(f?(await f.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(x).waitFor({state:"attached",timeout:18e3}).catch(()=>{}),i=await K(a)){if(await i.waitForSelector(y,{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(y,{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:z,localNumber:A}=(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 ${z} for phone ${s}`),await L(i,z,l,o),o("cn_entering_phone",`Entering phone number: ${A}`);let C=i.locator(y).first();try{await C.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the phone number input (#phoneNumber) inside the iframe"}}await O(C,A),o("cn_phone_entered",`Phone number entered: ${A}`);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 D=i.locator("input.btn-lg.code-btn").first(),E=!1;try{await D.waitFor({state:"visible",timeout:5e3}),E=!0}catch{let a=i.locator(".code-btn").first();try{await a.waitFor({state:"visible",timeout:5e3}),E=!0}catch{E=!1}}if(!E)return{status:"failed",error:"Could not find the send-SMS-code button (.code-btn) inside the iframe"};await D.click().catch(()=>{}),o("cn_send_code_clicked","Send code button clicked"),await i.waitForSelector(B,{state:"visible",timeout:5e3}).catch(()=>{});let F=await W(i);if(F)return{status:"failed",error:`Form error after sending code: ${F}`};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 G=i.locator(B).first();try{await G.waitFor({state:"visible",timeout:l})}catch{return{status:"failed",error:"Could not find the verification code input (#code) inside the iframe"}}await O(G,f),o("cn_code_entered","Verification code entered");let J=1200+Math.floor(1800*Math.random());o("cn_pre_submit_pause",`Waiting ${J}ms before submit (humanize)`),await a.waitForTimeout(J);let P=Math.max(n,12e3),Q=!1;for(let b=0;b<2;b++){o("cn_submitting",`Clicking submit button (attempt ${b+1}/2)`);let c=await K(a);if(!c){let b=await R(a,{timeoutMs:5e3,reportStep:o});if(b.ok)return o("cn_session_cookies",`Keycloak session after iframe detach (${b.cookie})`),{status:"success"};if(H(b.cookies))return o("cn_account_restricted","Tencent login_risk_state present after iframe detached"),I("login_risk_state cookie present");return{status:"failed",error:"Lost phone iframe after submit"}}if(await c.locator(y).first().isVisible({timeout:3e3}).catch(()=>!1)&&b>0){o("cn_re_entering_after_refresh",`Re-entering phone + code after refresh (retry ${b})`),await L(c,z,l,o);let d=c.locator(y).first();await O(d,A);try{let b=a.locator(".t-checkbox").first();await b.isVisible({timeout:2e3}).catch(()=>!1)&&await b.click().catch(()=>{})}catch{}let e=c.locator(B).first();await e.isVisible({timeout:3e3}).catch(()=>!1)&&await O(e,f),await a.waitForTimeout(800+Math.floor(700*Math.random()))}if(await S(c,l),o("cn_submitted",`Registration form submitted (attempt ${b+1})`),await a.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await a.waitForTimeout(1800),c=await K(a)||c,await V(a,c))return o("cn_account_restricted",`Account restricted after submit (attempt ${b+1}) — stopping automatic retries`),I("restriction message detected");if(o("cn_checking_captcha","Checking for captcha"),await X(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 W(c);if(d)return{status:"failed",error:`Form error after submit: ${d}`};o("cn_waiting_session",`Waiting up to ${Math.round(P/1e3)}s for Keycloak session cookies`);let e=await R(a,{timeoutMs:P,reportStep:o,alsoCheckFrame:()=>K(a)});if(e.ok)return o("cn_session_cookies",`Keycloak session cookies present (${e.cookie}) — registration success`),{status:"success"};if("restricted"===e.reason)return o("cn_account_restricted","Restriction detected while waiting for Keycloak session"),I("restriction message detected during session handoff");if(await T(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 R(a,{timeoutMs:1e4,reportStep:o});if(g.ok)return o("cn_session_cookies",`Keycloak session after home nudge (${g.cookie})`),{status:"success"};if("restricted"===g.reason)return o("cn_account_restricted","Restriction detected after home handoff"),I("restriction message detected after OIDC handoff");if(H(g.cookies))return o("cn_account_restricted","Home handoff returned no authenticated session and login_risk_state is present"),I("login_risk_state persisted after OIDC handoff");Q=!0;break}if(!Q)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 Z=await R(a,{timeoutMs:5e3});if(Z.ok)return o("cn_registration_success",`Phone registration completed (Keycloak session: ${Z.cookie})`),{status:"success"};if(H(Z.cookies))return o("cn_account_restricted","No authenticated session and Tencent login_risk_state is present — account restricted"),I("login_risk_state without an authenticated session");if(await Y(a,i,1e4))return o("cn_registration_success","Phone registration completed successfully (UI markers)"),{status:"success"};let $=await U(a);return o("cn_success_unconfirmed",`No Keycloak session after submit — ${$.summary}`),{status:"needs_manual",error:`Login submit finished but no Keycloak session yet (${$.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 K(a){try{await a.locator(x).waitFor({state:"attached",timeout:5e3});let b=await a.locator(x).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 L(a,b,c,d){if(!b)return;let e=Math.min(Number(c)||15e3,1e4),f=async()=>{let c=a.locator(A).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(z).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(`${z}: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(A).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 M(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 N(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 O(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 P=["KEYCLOAK_IDENTITY","KEYCLOAK_SESSION","KEYCLOAK_IDENTITY_LEGACY","KEYCLOAK_SESSION_LEGACY"];function Q(a=[]){for(let b of P)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 R(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=Q(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{}let h=d?await d().catch(()=>null):null;if(await V(a,h))return{ok:!1,cookies:b,reason:"restricted"};if(h){let a=await W(h);if(a)return{ok:!1,cookies:b,reason:`form_error:${a}`}}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 S(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(B).first().press("Enter").catch(()=>{})}}async function T(a){let b=await K(a);return!!b&&b.locator(y).first().isVisible({timeout:1500}).catch(()=>!1)}async function U(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 K(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 V(a,b){for(let c of[b,a])if(c)try{let a=await c.evaluate(()=>document.body?.innerText||"");if(function(a){let b=String(a||"").toLowerCase();return G.some(a=>b.includes(a.toLowerCase()))}(a))return!0}catch{}return!1}async function W(a){for(let b of E)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 X(a,b,c=5e3){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{}if(b)for(let a of C)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 Y(a,b,c=15e3){let d=[];try{if(d=await a.context().cookies().catch(()=>[]),Q(d))return!0}catch{}if(H(d)||await T(a).catch(()=>!1))return!1;for(let b of D)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=new Set(d.map(a=>a.name));if(b&&!b.includes("/login")&&!b.includes("/auth/realms")&&(c.has("qcloud_uid")||c.has("qcmainCSRFToken"))&&!c.has("login_risk_state")&&!await T(a).catch(()=>!1))return!0}catch{}return!1}var Z=c(40891),$=c(75949);let _=200,aa=Number.parseInt(process.env.ZEVAI_CN_ACCOUNT_TIMEOUT_MS||"",10)||3e5,ab="CN_API_KEY_OUTCOME_UNKNOWN",ac="CN_ACCOUNT_RESTRICTED",ad=new Set(["hongkong","china","any"]),ae="hongkong";function af(a){return String(a||"").trim()}function ag(){try{let{totalMemGb:a}=(0,h.si)();return Number.isFinite(a)&&a>0&&a<3}catch{return!1}}async function ah(a,{timeoutMs:b=6e3}={}){let c=null;try{c=a?.request||null}catch{c=null}if(!c||"function"!=typeof c.get)return{ok:!1,ip:null,ips:[],samples:0,error:"context request unavailable"};let d=[],e=null;for(let a of $.PROXY_EGRESS_ECHO_URLS){d.push(a);let g=null;try{var f;if(g=await c.get(a,{timeout:b,failOnStatusCode:!1,headers:{Accept:"text/plain, application/json;q=0.9, */*;q=0.1","Cache-Control":"no-cache"}}),200>g.status()||g.status()>=300){e=`HTTP ${g.status()}`;continue}let h=(f=await g.text().catch(()=>""),(0,$.parseProxyEgressIp)(f));if(!h){e="exit-IP response was not recognized";continue}return{ok:!0,ip:h,ips:[h],samples:1,attempts:d.length,attemptedUrls:d,unstable:!1,error:null}}catch(a){e=a?.name==="TimeoutError"?`timed out after ${b}ms`:"request failed"}finally{"function"==typeof g?.dispose&&await Promise.resolve(g.dispose()).catch(()=>null)}}return{ok:!1,ip:null,ips:[],samples:0,attempts:d.length,attemptedUrls:d,unstable:!1,error:e||"all exit-IP services failed"}}function ai(a,b=null){if(a?.unstable)throw Object.assign(Error("Manual proxy rotated between exit IPs during preflight; no phone number was purchased"),{code:"CN_PROXY_EGRESS_UNSTABLE"});if(!a?.ok||!a?.ip)throw Object.assign(Error(`Manual proxy exit IP could not be verified (${a?.error||"no response"}); no phone number was purchased`),{code:"CN_PROXY_EGRESS_UNVERIFIED"});if(b&&a.ip!==b)throw Object.assign(Error("Manual proxy exit IP changed after CloakBrowser GeoIP alignment; no phone number was purchased"),{code:"CN_PROXY_EGRESS_CHANGED"});return a.ip}async function aj(a,{timeoutMs:b,message:c,code:d,onTimeout:e,onLateResolve:f}){let g=Promise.resolve(a),h=null,i=!1,j=new Promise((a,f)=>{"function"==typeof(h=setTimeout(()=>{i=!0;try{"function"==typeof e&&e()}catch{}f(Object.assign(Error(c),{code:d}))},b)).unref&&h.unref()});try{return await Promise.race([g,j])}finally{h&&clearTimeout(h),i&&"function"==typeof f&&g.then(f).catch(()=>null)}}function ak(a){let b=`${a?.text||""} ${a?.data?._raw||""} ${a?.url||""}`;return/<!doctype html|<html|login-pf|\/auth\/realms\//i.test(b)}function al(a,b=[]){let c=b instanceof Set?b:new Set(b),d=`${a?.text||""} ${a?.data?._raw||""}`;return!!/账号访问受限|安全策略限制|访问受限|account restricted|access restricted/i.test(d)||!!c.has("login_risk_state")&&(ak(a)||a?.status===0||a?.status===401||a?.status===403)}async function am({context:a,page:b,timeoutMs:c=1e4}){let d={Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},e=null;try{e=a?.request||null}catch{e=null}if(e&&"function"==typeof e.get)try{let a=await e.get("https://www.codebuddy.cn/console/accounts",{headers:d,timeout:c,failOnStatusCode:!1}),b=await a.text().catch(()=>"");return function(a,b,c={}){let d=String(b||""),e=null;try{e=d?JSON.parse(d):null}catch{e={_raw:d.slice(0,240),_notJson:!0}}return{status:Number(a)||0,data:e,text:d.slice(0,240),...c}}(a.status(),b,{source:"context-request",url:a.url(),contentType:a.headers()?.["content-type"]||""})}catch{}return aj(b.evaluate(async({requestTimeoutMs:a,requestHeaders:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),a);try{let a=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===a?`${window.location.origin}`:"https://www.codebuddy.cn",e=await fetch(`${d}/console/accounts`,{credentials:"include",signal:c.signal,headers:b}),f=await e.text().catch(()=>""),g=null;try{g=f?JSON.parse(f):null}catch{g={_raw:String(f||"").slice(0,240),_notJson:!0}}return{status:e.status,data:g,text:String(f||"").slice(0,240),source:"page-fetch",url:e.url,contentType:e.headers.get("content-type")||""}}catch(a){return{status:0,timedOut:a?.name==="AbortError",error:a?.message||String(a),source:"page-fetch"}}finally{clearTimeout(d)}},{requestTimeoutMs:c,requestHeaders:d}),{timeoutMs:c,message:`Console account probe timed out after ${c/1e3}s`,code:"CN_CONSOLE_PROBE_TIMEOUT"}).catch(a=>({status:0,timedOut:a?.code==="CN_CONSOLE_PROBE_TIMEOUT",error:a?.message||String(a),source:"page-fetch"}))}async function an(a){if(!a||"function"!=typeof a.close)return!0;try{return await aj(Promise.resolve().then(()=>a.close()),{timeoutMs:5e3,message:"Browser resource close timed out after 5s",code:"CN_RESOURCE_CLOSE_TIMEOUT"}),!0}catch{return!1}}async function ao(a,b){if(await an(a)||!b?.browser)return;let c=b.browser;b.browser=null,await (0,$.forceCloseBrowser)(c).catch(()=>null)}async function ap(a){try{return await aj(Promise.resolve().then(a),{timeoutMs:12e3,message:"5sim order settlement timed out after 12s",code:"CN_FIVESIM_SETTLE_TIMEOUT"})}catch{return!1}}async function aq({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 ar extends e.Q6{constructor({browserLauncher:a,requestDeviceCodeFn:b=Z.cT,pollToken:d=Z.ZV,fetchLoginAccountFn:e=Z.w8,saveConnection:f=aq,fiveSimClientFactory:g=as,phoneAutomation:h=J,phoneFormatter:j=af,pollIntervalMs:k=i.ne.pollInterval,storageName:l="codebuddy-cn-bulk-import"}={}){super({browserLauncher:a||(async a=>{let{forceCloseBrowser:b,launchBulkImportBrowser:d}=await Promise.resolve().then(c.bind(c,75949)),e=Array.isArray(a?.proxyUrls)&&a.proxyUrls.length?a.proxyUrls[0]:null,f=process.env.ZEVAI_CN_HEADLESS,g=!1;return("0"===f||"false"===f)&&(g=!1),("1"===f||"true"===f)&&(g=!0),aj(d({engine:a?.engine||"cloakbrowser",proxyUrl:e,headless:g,windowSize:{width:1280,height:900},requireProxyGeoip:a?.proxyPoolMode==="manual"&&!!e}),{timeoutMs:9e4,message:"CloakBrowser launch timed out after 90s",code:"CN_BROWSER_LAUNCH_TIMEOUT",onLateResolve:a=>b(a)})}),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,proxyPoolMode:c,proxyPoolId:g,manualProxyUrl:i,region:j}){let k=Number.parseInt(a,10);if(!Number.isFinite(k)||k<1)throw Object.assign(Error("At least one account is required (count >= 1)"),{error:"At least one account is required (count >= 1)"});if(k>_)throw Object.assign(Error(`Count exceeds maximum of ${_}`),{error:`Count exceeds maximum of ${_}`});let l=[...this.jobs.values()].find(a=>a&&("running"===a.status||"queued"===a.status||"needs_manual"===a.status)&&!a.cancelRequested);if(l)throw Object.assign(Error(`Another CodeBuddy CN job is still active (${l.jobId}). Cancel it or wait before starting again.`),{error:`Another CodeBuddy CN job is still active (${l.jobId}). Cancel it or wait before starting again.`});let m=ad.has(j)?j:ae,n=[],o="string"==typeof i?i.trim():"";if(o){if(!/^(https?|socks4|socks5):\/\/.+/i.test(o))throw Object.assign(Error("manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"),{error:"manualProxyUrl must be a valid proxy URL (http://, https://, socks4://, or socks5://)"});n=[o]}else if("all"===c)n=(await (0,f.ui)({isActive:!0})).map(a=>a.proxyUrl).filter(Boolean);else if("single"===c&&g){let a=await (0,f.hr)(g);a?.isActive&&a?.proxyUrl&&(n=[a.proxyUrl])}let p=(0,d.randomUUID)(),q=(0,e.kF)(),r={jobId:p,status:"running",concurrency:function(a,{manualProxy:b=!1}={}){return b?1:function(a){let b=ag()?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)}(a)}(b,{manualProxy:!!o}),proxyPoolMode:o?"manual":c||"none",proxyUrls:n,region:m,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:k},(a,b)=>({line:b+1,region:m,phone:null,fiveSimOrderId:null,fiveSimActivationId:null,fingerprintSeed:(0,d.randomUUID)(),proxyUrl:null,egressIp:null,proxyTimezone:null,proxyLocale: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,r),this.latestJobId=p,await this.persistJobSnapshot(r,{forcePreview:!1}),this.runJob(p),at(r)}getJob(a){let b=this.jobs.get(a);return b?at(b):null}async getJobWithPreview(a){let b=this.jobs.get(a);return b?(await this.persistJobSnapshot(b,{forcePreview:!1}),at(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,j=null;try{let c;this.setAccountStep(b,"reading_settings","Reading 5sim API key from settings"),await this.persistJobSnapshot(a,{forcePreview:!0});let k=(await (0,g.mt)()).fiveSimApiKey;if(!k||!k.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:k,proxyOptions:null}),this.setAccountStep(b,"creating_browser","Creating browser context (before 5sim order)"),await this.persistJobSnapshot(a,{forcePreview:!0});let l=(0,e.go)(a.browser,b.proxyUrl,{profile:"codebuddy-cn",region:a.region||"hongkong",fingerprintSeed:b.fingerprintSeed,lowMemory:ag(),nativeCloakProfile:"manual"===a.proxyPoolMode}),m=await aj(l,{timeoutMs:3e4,message:"Browser context creation timed out after 30s",code:"CN_CONTEXT_TIMEOUT",onLateResolve:a=>Promise.resolve(a?.context?.close?.()).catch(()=>null)});i=m.context;let n=m.page;if(b.runtimeSession={context:i,page:n},"manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"checking_proxy_egress","Verifying pasted proxy exit IP before opening the registration form"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=(0,$.getCloakProxyProfile)(a.browser),d=await ah(i);b.egressIp=j=ai(d,c?.egressIp||null),b.proxyTimezone=c?.timezone||null,b.proxyLocale=c?.locale||null,this.setAccountStep(b,"proxy_egress_ready",`Manual proxy verified: ${j} (${d.samples} checks, ${b.proxyTimezone||"timezone unknown"}, ${b.proxyLocale||"locale unknown"})`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(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{n.setDefaultTimeout(2e4),n.setDefaultNavigationTimeout(45e3)}catch{}let o=null,p=new Promise((a,b)=>{o=setTimeout(()=>{b(Object.assign(Error(`CodeBuddy CN account hard timeout after ${Math.round(aa/1e3)}s (browser will be force-closed)`),{code:"CN_ACCOUNT_HARD_TIMEOUT"}))},aa),"function"==typeof o.unref&&o.unref()});try{c=await Promise.race([this.phoneAutomation({page:n,signal:b.abortController?.signal,isCancelled:()=>!0===a.cancelRequested,resolvePhone:async()=>{if(a.cancelRequested)throw Error("Job cancelled before ordering phone number");if("manual"===a.proxyPoolMode&&b.proxyUrl){this.setAccountStep(b,"rechecking_proxy_egress","Registration form is ready — confirming the pasted proxy stayed sticky"),await this.persistJobSnapshot(a,{forcePreview:!1});let c=await ah(i);ai(c,j),this.setAccountStep(b,"proxy_egress_confirmed",`Manual proxy remained on ${j}; safe to purchase one phone number`),await this.persistJobSnapshot(a,{forcePreview:!1})}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}),p])}finally{o&&clearTimeout(o)}if(String(c.status||"").startsWith("failed")){let e=c.error||"Phone registration failed before submit",g=c.status||"failed";this.finalizeAccount(b,g,{error:e,step:g,message:e}),d&&f&&(h?await ap(()=>d.finishOrder(f)):await ap(()=>d.cancelOrder(f))),b.runtimeSession=null,await ao(i,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}await this.captureApiKey(a,b,i,n,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 ap(()=>d.finishOrder(f)):c?await ap(()=>d.banOrder(f)):await ap(()=>d.cancelOrder(f))),b.runtimeSession=null,await ao(i,a),(g?.code==="CN_ACCOUNT_HARD_TIMEOUT"||g?.code==="CN_CONTEXT_TIMEOUT"||a.cancelRequested)&&a.browser){let b=a.browser;a.browser=null,await (0,$.forceCloseBrowser)(b).catch(()=>null)}await this.persistJobSnapshot(a,{forcePreview:!0})}}async captureApiKey(a,b,c,d,e,f){let g="personal-edition-user-id",h=async(a,{timeout:b=12e3,interval:c=150}={})=>{let d=Date.now()+b;for(;Date.now()<d;){try{if(await a())return!0}catch{}await new Promise(a=>setTimeout(a,c))}return!1};try{this.setAccountStep(b,"waiting_session","Establishing CodeBuddy console session (probe APIs, not just cookies)"),await this.persistJobSnapshot(a,{forcePreview:!0});let i=async()=>{let a=await c.cookies().catch(()=>[]);return{cookies:a,names:new Set(a.map(a=>a.name)),list:a.map(a=>a.name)}},j=a=>a.has("KEYCLOAK_IDENTITY")||a.has("KEYCLOAK_SESSION")||a.has("KEYCLOAK_IDENTITY_LEGACY")||a.has("KEYCLOAK_SESSION_LEGACY"),k=a=>a.has("AUTH_SESSION_ID")||a.has("session")||a.has("qcloud_uid")||a.has("qcmainCSRFToken")||a.has("x_host_key_access"),l=()=>am({context:c,page:d}),m=a=>{let b=a?.data;if(!b||"object"!=typeof b)return[];for(let a of[b?.data?.accounts,b?.accounts,b?.data?.list,b?.list,b?.data?.result,b?.result,b?.data?.items,b?.items,Array.isArray(b?.data)?b.data:null,Array.isArray(b)?b:null])if(Array.isArray(a)&&a.length>0)return a;return[]},n=async(a=2500)=>{let b=!1,c=null;try{await Promise.race([d.waitForLoadState("domcontentloaded",{timeout:a}).catch(()=>null),h(async()=>{if(b)return!0;let a=await i();return j(a.names)},{timeout:a,interval:200}),new Promise(b=>{c=setTimeout(b,a)})])}finally{b=!0,c&&clearTimeout(c)}},o=async a=>{let b=Date.now();try{await d.goto(a,{waitUntil:"commit",timeout:18e3});let c=18e3-(Date.now()-b);return c>0&&await n(Math.min(2500,c)),!0}catch{return!1}},p=["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/console/","https://www.codebuddy.cn/profile","https://www.codebuddy.cn/profile/keys"],q=[],r=null,s=!1,t="",u=null,v=0;for(let c=0;c<6;c+=1){if(a.cancelRequested)throw Error("Job cancelled while establishing session");let e=await i(),f=j(e.names),g=k(e.names),h=p[Math.min(c,p.length-1)];c<3||c%2==0||!g?(this.setAccountStep(b,"waiting_session",`OIDC handoff ${c+1}/6 → ${h.replace("https://www.codebuddy.cn","")} (${f?"KEYCLOAK":g?"soft-session":"weak"})`),await this.persistJobSnapshot(a,{forcePreview:!1}),await o(h)):await new Promise(a=>setTimeout(a,300)),/^https:\/\/www\.codebuddy\.cn(?:[/:]|$)/i.test(d.url?.()||"")||await o("https://www.codebuddy.cn/console"),r=await l(),q=m(r),(r?.status>0||r?.text||r?.data)&&(u=r),t=JSON.stringify(r?.data??r?.text??r?.error??null).slice(0,180);let n=ak(r),w=await i();if(!j(w.names)&&al(r,w.names)?v+=1:v=0,v>=2)throw Object.assign(Error(`Tencent restricted the post-OTP session (${v} console probes returned login/risk evidence; source=${r?.source||"unknown"})`),{code:ac});if(r?.status===200&&!n&&Array.isArray(q)&&q.length>0){s=!0,this.setAccountStep(b,"session_ready",`Console session accepted (HTTP 200, ${q.length} account(s)${f?", KEYCLOAK ok":", soft session"})`),await this.persistJobSnapshot(a,{forcePreview:!0});break}if(g&&r?.status===200&&!n&&r?.data?._notJson!==!0&&Array.isArray(q)&&0===q.length&&c>=3){this.setAccountStep(b,"session_soft","Console HTTP 200 but 0 accounts — trying personal API key with soft session (cookies ok)"),await this.persistJobSnapshot(a,{forcePreview:!0}),s=!0;break}this.setAccountStep(b,"resolving_enterprise",`Console not ready (HTTP ${r?.status||0}, accounts=${q.length}${n?", login HTML":""}, source=${r?.source||"unknown"}) — ${c+1}/6 body=${t.slice(0,80)}`),await this.persistJobSnapshot(a,{forcePreview:!1})}if(!s){let a=await i(),b=u||r,c=al(b,a.names)||a.names.has("login_risk_state")&&v>0;throw Object.assign(Error(c?`Tencent restricted the post-OTP session (HTTP ${b?.status||0}; login_risk_state present; source=${b?.source||"unknown"})`:`Console accounts unavailable after login (HTTP ${b?.status||0}; cookies: ${a.list.slice(0,18).join(",")||"(none)"}; body=${t.slice(0,120)}; probeError=${r?.error||"none"}) — session not accepted for API key`),{code:c?ac:"CN_CONSOLE_SESSION_UNAVAILABLE"})}let w=g;if(Array.isArray(q)&&q.length>0){let a=q.find(a=>a?.lastLogin)||q[0];a?.type&&"personal"!==a.type&&a.enterpriseId?w=a.enterpriseId:a?.enterpriseId&&a?.type!=="personal"&&(w=a.enterpriseId)}this.setAccountStep(b,"creating_api_key",`Creating API key (enterprise=${w}, accounts=${q.length})`),await this.persistJobSnapshot(a,{forcePreview:!0});let x=`zevai-router-${b.workerId||"account"}-${Date.now()}`,y=async a=>d.evaluate(async({enterpriseId:a,keyName:b,timeoutMs:c})=>{let d=new AbortController,e=setTimeout(()=>d.abort(),c);try{let c=window.location.hostname||"www.codebuddy.cn",e="www.codebuddy.cn"===c?window.location.origin:"https://www.codebuddy.cn",f=await fetch(`${e}/console/api/client/v1/api-keys`,{method:"POST",credentials:"include",signal:d.signal,headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},body:JSON.stringify({name:b,expire_in_days:365,user_enterprise_id:a})}),g=await f.text().catch(()=>""),h=null;try{h=g?JSON.parse(g):null}catch{h={_raw:String(g||"").slice(0,200)}}return{ok:f.ok,status:f.status,data:h}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,timedOut:a?.name==="AbortError",error:a?.message||String(a)}}finally{clearTimeout(e)}},{enterpriseId:a,keyName:x,timeoutMs:6e4}),z=async(c,d)=>{let e,f=Date.now(),g=null,h=setInterval(()=>{if(g)return;let c=Math.max(5,Math.round((Date.now()-f)/1e3));this.setAccountStep(b,"creating_api_key",`${d} — waiting for CodeBuddy (${c}s)`),g=this.persistJobSnapshot(a,{forcePreview:!1}).catch(()=>null).finally(()=>{g=null})},5e3);"function"==typeof h.unref&&h.unref();try{e=await aj(y(c),{timeoutMs:6e4,message:"API key request timed out after 60s; creation outcome is unknown",code:ab})}catch(a){if(a?.code===ab)throw a;throw Object.assign(Error(`API key request lost its response; creation outcome is unknown: ${a?.message||String(a)}`),{code:ab})}finally{clearInterval(h),g&&await g.catch(()=>null)}if(e?.outcomeUnknown){let a=e.timedOut?"timed out after 60s":`lost its response (${e.error||"network error"})`;throw Object.assign(Error(`API key request ${a}; creation outcome is unknown`),{code:ab})}return e};if(!await o("https://www.codebuddy.cn/profile/keys"))throw Object.assign(Error("Keys page navigation timed out after 18s"),{code:"CN_CONSOLE_NAV_TIMEOUT"});let A=await z(w,"Creating API key");A?.status===400&&w!==g&&(this.setAccountStep(b,"retrying_api_key","Retrying with personal-edition enterprise id"),await this.persistJobSnapshot(a,{forcePreview:!1}),A=await z(g,"Retrying personal API key"));let B=a=>a?.ok===!1&&(401===a.status||403===a.status);for(let c=1;c<=2&&B(A);c+=1){for(let d of(this.setAccountStep(b,"retrying_api_key",`API key 401/403 — OIDC re-handoff round ${c}/2 (waiting strong session)`),await this.persistJobSnapshot(a,{forcePreview:!0}),["https://www.codebuddy.cn/","https://www.codebuddy.cn/console","https://www.codebuddy.cn/profile/keys"]))await o(d);await h(async()=>{let a=await i();return j(a.names)},{timeout:8e3*c,interval:300}).catch(()=>null),A=await z(g,`Retrying API key after OIDC handoff ${c}/2`)}let C=A?.data?.code;if(!A||!A.ok||!A.data||0!==C&&200!==C&&void 0!==C){let a="string"==typeof A?.data?._raw?A.data._raw.replace(/\s+/g," ").slice(0,120):null,b=a&&/openresty|nginx|Authorization Required/i.test(a)?" [edge proxy blocked — session half-baked]":"";throw Error(`API key creation failed (HTTP ${A?.status??"no-response"}, code=${C??"n/a"})${b}: ${JSON.stringify(A?.data??null).slice(0,200)}`)}let D=A.data?.data||A.data,E=D?.apiKey||D?.key||D?.token||D?.secret||D?.api_key||("string"==typeof D?D:null)||A.data.apiKey||A.data.key||A.data.token||A.data.secret;if(!E||"string"!=typeof E)throw Object.assign(Error(`API key response did not contain a key field; creation outcome is unknown: ${JSON.stringify(A.data).slice(0,300)}`),{code:ab});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:F}=await this.saveConnection({apiKey:E,phone:b.phone,region:b.region,fiveSimOrderId:f,account:b});await ap(()=>e.finishOrder(f)),this.finalizeAccount(b,"success",{connectionId:F.id,step:"connection_saved",message:`CodeBuddy CN connection saved (phone: ${b.phone})`}),b.runtimeSession=null,await ao(c,a),await this.persistJobSnapshot(a,{forcePreview:!0})}catch(j){let g=j?.code===ac,h=j?.code===ab;if(g){this.finalizeAccount(b,"failed_restricted",{error:`${j.message}. Use a different residential CN/HK proxy with concurrency 1.`,step:"failed_restricted",message:"Tencent restricted the post-OTP session; API-key capture was not attempted"}),await ap(()=>e.finishOrder(f)),b.runtimeSession=null,await ao(c,a),await this.persistJobSnapshot(a,{forcePreview:!0});return}let i=h?`${j.message}. Check the CodeBuddy keys page before creating another key.`:j.message;if(this.finalizeAccount(b,"needs_manual",{error:`Registration succeeded but API key capture failed: ${i}`,step:h?"api_key_outcome_unknown":"awaiting_manual",message:h?"Registration done; API key request outcome is unknown. Check existing keys before retrying.":`Registration done, API key capture failed: ${j.message}`}),await ap(()=>e.finishOrder(f)),await this.persistJobSnapshot(a,{forcePreview:!0}),h){b.runtimeSession=null,await ao(c,a);return}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 c=b.manualSession,e=c?.context||d,f=c?.headedBrowser||null;await ao(e,a),f&&await (0,$.forceCloseBrowser)(f).catch(()=>null)};try{this.setAccountStep(b,"manual_waiting","Waiting for operator to complete in headed browser"),await this.persistJobSnapshot(a,{forcePreview:!0});let c=ag()?18e4:48e4,d=Date.now()+c,f=null,h=`zevai-router-manual-${b.workerId||"account"}-${Date.now()}`;for(;Date.now()<d&&!a.cancelRequested;){await new Promise(a=>setTimeout(a,1e4));try{if(!e.url().includes("codebuddy.cn"))continue;let a=await aj(e.evaluate(async({keyName:a,timeoutMs:b})=>{let c=new AbortController,d=setTimeout(()=>c.abort(),b);try{let b=window.location.hostname||"www.codebuddy.cn",d="www.codebuddy.cn"===b?window.location.origin:"https://www.codebuddy.cn",e=await fetch(`${d}/console/api/client/v1/api-keys`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json, text/plain, */*","x-requested-with":"XMLHttpRequest","X-Domain":"www.codebuddy.cn","X-Product":"SaaS"},credentials:"include",signal:c.signal,body:JSON.stringify({name:a,expire_in_days:365,user_enterprise_id:"personal-edition-user-id"})}),f=await e.json().catch(()=>null);return{ok:e.ok,status:e.status,data:f}}catch(a){return{ok:!1,status:0,outcomeUnknown:!0,error:a?.message||String(a)}}finally{clearTimeout(d)}},{keyName:h,timeoutMs:6e4}),{timeoutMs:6e4,message:"Manual API key request timed out; creation outcome is unknown",code:ab});if(a?.outcomeUnknown)throw Object.assign(Error(`Manual API key request lost its response; creation outcome is unknown: ${a.error||"network error"}`),{code:ab});if(a?.ok){let b=a.data?.data||a.data;if((f=b?.apiKey||b?.key||b?.token||b?.secret||b?.api_key||("string"==typeof b?b:null))&&"string"==typeof f)break;throw Object.assign(Error("Manual API key response was successful but did not contain the key; creation outcome is unknown"),{code:ab})}}catch(a){if(a?.code===ab)throw a}}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(!f)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:i}=await this.saveConnection({apiKey:f,phone:b.phone,region:b.region,fiveSimOrderId:g,account:b});this.finalizeAccount(b,"success",{connectionId:i.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"}):c?.code===ab?this.finalizeAccount(b,"needs_manual",{error:`${c.message}. Check existing CodeBuddy keys before retrying.`,step:"api_key_outcome_unknown",message:"Manual API key request outcome is unknown; automatic retries stopped"}):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)}async runWorker(a,b){if("manual"!==a.proxyPoolMode)return super.runWorker(a,b);for(;!a.cancelRequested;){let c=this.dequeueAccount(a,b);if(!c)return;if(!a.browser)try{a.browser=await this.browserLauncher({...a,proxyUrls:c.proxyUrl?[c.proxyUrl]:a.proxyUrls})}catch(b){this.finalizeAccount(c,"failed",{error:b?.message||"Manual proxy browser launch failed",step:"failed",message:b?.message||"Manual proxy browser launch failed"}),await this.persistJobSnapshot(a,{forcePreview:!0});continue}try{await this.processAccount(a,c,b)}catch(b){"running"===c.status&&(this.finalizeAccount(c,"failed",{error:b?.message||"Unexpected manual proxy worker failure",step:"failed",message:b?.message||"Unexpected manual proxy worker failure"}),await this.persistJobSnapshot(a,{forcePreview:!0}))}finally{if(a.manualFollowups.size>0&&await Promise.allSettled([...a.manualFollowups]),a.browser){let b=a.browser;a.browser=null,await (0,$.forceCloseBrowser)(b).catch(()=>null)}}}}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,$.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}),at(b)}}function as({apiKey:a,proxyOptions:b}){return new q({apiKey:a,proxyOptions:b})}function at(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):a.startsWith("failed")?(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,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,egressIp:a.egressIp||null,proxyTimezone:a.proxyTimezone||null,proxyLocale:a.proxyLocale||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 au(){return(!globalThis.__codeBuddyCnBulkImportSingleton&&(globalThis.__codeBuddyCnBulkImportSingleton={manager:new ar}),globalThis.__codeBuddyCnBulkImportSingleton).manager}}};