@vellumai/web 0.10.8-staging.1 → 0.10.8-staging.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/assets/{AnimatePresence-C8APSgIu.js → AnimatePresence-s1Z1HHWx.js} +1 -1
  2. package/dist/assets/{BundleConfirmPage-M2tkzwiz.js → BundleConfirmPage-C6bP7QB3.js} +1 -1
  3. package/dist/assets/{about-page-C-kIVb7a.js → about-page-XGv9RAQu.js} +1 -1
  4. package/dist/assets/{account-page-DOSnPXjP.js → account-page-Dno1SeJN.js} +1 -1
  5. package/dist/assets/{account-shell-74OchOxg.js → account-shell-CdhP9l8T.js} +1 -1
  6. package/dist/assets/{acp-run-detail-panel-DFoD_DVJ.js → acp-run-detail-panel-B1-zyOUe.js} +4 -4
  7. package/dist/assets/{activity-steps-panel-jztC4BRv.js → activity-steps-panel-BGyfMCXK.js} +1 -1
  8. package/dist/assets/{add-credits-modal-daNASKHJ.js → add-credits-modal-PP1PX8Qv.js} +1 -1
  9. package/dist/assets/{advanced-page-B8h5sAe5.js → advanced-page-vCbMVJsK.js} +1 -1
  10. package/dist/assets/{ai-page-BInYrZV7.js → ai-page-BIYybKux.js} +1 -1
  11. package/dist/assets/{animated-avatar-CrlodWQr.js → animated-avatar-Cqpzb8O4.js} +1 -1
  12. package/dist/assets/{api-key-screen-Cynx0r0g.js → api-key-screen-DTSP_-Da.js} +1 -1
  13. package/dist/assets/{archive-page-DqXRVFoF.js → archive-page-RZ2VP63A.js} +1 -1
  14. package/dist/assets/{assistant-feature-flag-store-CKUjJHuh.js → assistant-feature-flag-store-DA8Oj9Mf.js} +1 -1
  15. package/dist/assets/{assistant-status-panel-eNWJodpn.js → assistant-status-panel-BC0RTDls.js} +1 -1
  16. package/dist/assets/{auth-store-CD7PGb3q.js → auth-store-C09YAZEu.js} +2 -2
  17. package/dist/assets/{background-task-detail-panel-Bsi8IoaY.js → background-task-detail-panel-BfnsD-3B.js} +1 -1
  18. package/dist/assets/{billing-page-dpKYjJH3.js → billing-page-1z_L2m6q.js} +3 -3
  19. package/dist/assets/{bookmarks-page-BI92Y3eM.js → bookmarks-page-CjcavZv8.js} +1 -1
  20. package/dist/assets/{browser-BPZAXjRE.js → browser-C6a_nhhZ.js} +2 -2
  21. package/dist/assets/{build-state-DGsKGdpj.js → build-state-PUXrUU4W.js} +1 -1
  22. package/dist/assets/channels-page-route-WjNmd0sS.js +9 -0
  23. package/dist/assets/chat-markdown-message-BnX6bhgs.js +2 -0
  24. package/dist/assets/{client-feature-flag-store-C0g8zi1W.js → client-feature-flag-store-DkJl-g9A.js} +1 -1
  25. package/dist/assets/{command-palette-Dk6UsSlv.js → command-palette-6o4m7BM9.js} +1 -1
  26. package/dist/assets/{command-palette-window-page-zDow8o4K.js → command-palette-window-page-BsJlr5bh.js} +1 -1
  27. package/dist/assets/community-page-CJA4JfuC.js +1 -0
  28. package/dist/assets/{connect-page-BXTqYbdY.js → connect-page-DZgU3jCf.js} +1 -1
  29. package/dist/assets/{consent-controls-BZMxm0n3.js → consent-controls-Cnr1DzCr.js} +1 -1
  30. package/dist/assets/contacts-page-route-P0neH-PV.js +1 -0
  31. package/dist/assets/{credentials-page-0S5ifTFC.js → credentials-page-MkKE_19-.js} +1 -1
  32. package/dist/assets/debug-page-B88f4aDU.js +4 -0
  33. package/dist/assets/{deploy-dialogs-BBHNKgDi.js → deploy-dialogs-paL_zcvG.js} +1 -1
  34. package/dist/assets/{detail-card-RGTjHkZ8.js → detail-card-xKZlkbz5.js} +1 -1
  35. package/dist/assets/{detail-panel-stop-button-oIDUq-kJ.js → detail-panel-stop-button-y7O3HqJj.js} +1 -1
  36. package/dist/assets/{developer-page-Djolz4Fg.js → developer-page-BFMS6pwU.js} +1 -1
  37. package/dist/assets/{devices-page-XJJSA97y.js → devices-page-B3D5iLhD.js} +1 -1
  38. package/dist/assets/{dictation-overlay-page-cqsEjyx_.js → dictation-overlay-page-BkEBWrWm.js} +1 -1
  39. package/dist/assets/{document-viewer-page-jInmb33M.js → document-viewer-page-B631L6-3.js} +1 -1
  40. package/dist/assets/{earn-credits-modal-C_jhLLw5.js → earn-credits-modal-CFla-iKl.js} +1 -1
  41. package/dist/assets/edge-swipe-arbiter-store-BeOhrE7M.js +1 -0
  42. package/dist/assets/{emails-page-fov7ihfj.js → emails-page-7c9kVi_k.js} +1 -1
  43. package/dist/assets/{esm-Ddmch1KU.js → esm-Bzs_witt.js} +2 -2
  44. package/dist/assets/{esm-CYMQv-VS.js → esm-C5J59K0j.js} +2 -2
  45. package/dist/assets/{esm-CTXnt94k.js → esm-CT8NUp3h.js} +2 -2
  46. package/dist/assets/esm-DEu9JbAE.js +2 -0
  47. package/dist/assets/{esm-BciT3LGF.js → esm-DZkj1VLJ.js} +2 -2
  48. package/dist/assets/{esm-CvWQdH3L.js → esm-DtJz1M8R.js} +2 -2
  49. package/dist/assets/{feature-flag-catalog-CHuc71P8.js → feature-flag-catalog-GgSNKkqP.js} +1 -1
  50. package/dist/assets/{file-markdown-BXUvAQ24.js → file-markdown-Bq97tNxs.js} +1 -1
  51. package/dist/assets/{general-page-gojItIOd.js → general-page-D-Gr2lkW.js} +1 -1
  52. package/dist/assets/{haptics-DKVhthJo.js → haptics-lMERs7us.js} +2 -2
  53. package/dist/assets/hatching-screen-BlwicgIz.js +1 -0
  54. package/dist/assets/home-page-route-D24x4A0S.js +1 -0
  55. package/dist/assets/{hosting-screen-BTLHWS2M.js → hosting-screen-BZLZular.js} +1 -1
  56. package/dist/assets/identity-page-route-BwOJeenx.js +1 -0
  57. package/dist/assets/{index-BjtwYdrT.css → index-C9GrLGul.css} +1 -1
  58. package/dist/assets/{index-CSefSVJO.js → index-yu6nDHvG.js} +21 -21
  59. package/dist/assets/{inspect-page-CT8NspqC.js → inspect-page-1RejwSP_.js} +4 -4
  60. package/dist/assets/{integrations-page-DtClqS91.js → integrations-page-BV5BiHPD.js} +1 -1
  61. package/dist/assets/{intelligence-layout-D9ReVcK0.js → intelligence-layout-iQFO8in_.js} +1 -1
  62. package/dist/assets/{keyboard-shortcuts-page-CovdLPhh.js → keyboard-shortcuts-page-jt13JtxS.js} +1 -1
  63. package/dist/assets/{library-detail-page-MAsxHH08.js → library-detail-page-BAGWt1Lw.js} +1 -1
  64. package/dist/assets/{library-page-CYuSc92M.js → library-page-CqeoBhDY.js} +1 -1
  65. package/dist/assets/{login-flow-CHNlba5i.js → login-flow-B6q00uIW.js} +1 -1
  66. package/dist/assets/{login-page-CK1TxruP.js → login-page-BQVTWuQc.js} +1 -1
  67. package/dist/assets/{logout-page-W3gl_1Ax.js → logout-page-BV0URcAd.js} +1 -1
  68. package/dist/assets/{logs-layout-CR7u05YO.js → logs-layout-DO3yfZqD.js} +1 -1
  69. package/dist/assets/{memory-router-playground-page-eDjKwsbG.js → memory-router-playground-page-CQxX6mCn.js} +1 -1
  70. package/dist/assets/{metric-card-BN23geOu.js → metric-card-DvXjHVCV.js} +1 -1
  71. package/dist/assets/{mobile-sidebar-drawer-3LqMCZgK.js → mobile-sidebar-drawer-Epbt6p-k.js} +1 -1
  72. package/dist/assets/{native-file-Cn3RbQbT.js → native-file-DI99Emal.js} +2 -2
  73. package/dist/assets/{notifications-page-CtyUuC15.js → notifications-page-CXaZpD3s.js} +1 -1
  74. package/dist/assets/{oauth-complete-page-3DcY6Or3.js → oauth-complete-page-BlJm9tRJ.js} +1 -1
  75. package/dist/assets/{oauth-popup-complete-page-Cn-1bOwa.js → oauth-popup-complete-page-BqUopTat.js} +1 -1
  76. package/dist/assets/{page-shell-C2TBO8M8.js → page-shell-BUGBKCmv.js} +1 -1
  77. package/dist/assets/{pairing-page-Bb-_q_zP.js → pairing-page-B5GrCx4C.js} +1 -1
  78. package/dist/assets/{platform-loopback-page-Dfl_gjZm.js → platform-loopback-page-MZdCPXRI.js} +1 -1
  79. package/dist/assets/{plugin-detail-page-C_vv0F7O.js → plugin-detail-page-Byuqbr1N.js} +1 -1
  80. package/dist/assets/plugins-page-Ci0CoSAN.js +1 -0
  81. package/dist/assets/{prechat-route-CgCradwf.js → prechat-route-9JFn-w_1.js} +1 -1
  82. package/dist/assets/{prefs-DYaOj-dg.js → prefs-B1Y3q3c8.js} +1 -1
  83. package/dist/assets/{privacy-page-BqYdFos7.js → privacy-page-BTpvj9ZP.js} +1 -1
  84. package/dist/assets/{privacy-screen-DBMkRqiF.js → privacy-screen-CUbVcDf_.js} +1 -1
  85. package/dist/assets/{provider-callback-page-B-aDgII8.js → provider-callback-page-fB2tIyqL.js} +1 -1
  86. package/dist/assets/{provider-signup-page-CYK4VNf0.js → provider-signup-page-C4Dn-wtJ.js} +1 -1
  87. package/dist/assets/{quick-input-page-oif3WEFT.js → quick-input-page-Cv_CzapK.js} +1 -1
  88. package/dist/assets/{research-mock-page-CooZPqtv.js → research-mock-page-1T92rXz3.js} +1 -1
  89. package/dist/assets/{research-onboarding-route-BJqAsTdE.js → research-onboarding-route-CmWgwOFk.js} +3 -3
  90. package/dist/assets/{review-terms-screen-CVRYEl6e.js → review-terms-screen-DrD4vywk.js} +1 -1
  91. package/dist/assets/{risk-Dsj4oM8c.js → risk-Dopd25rc.js} +1 -1
  92. package/dist/assets/{security-page-DN5BI6Ag.js → security-page-BYI7twYM.js} +1 -1
  93. package/dist/assets/select-assistant-screen-Br-PNDO1.js +1 -0
  94. package/dist/assets/{settings-layout-BNwCqvBi.js → settings-layout-lddMUg7A.js} +1 -1
  95. package/dist/assets/share-feedback-modal-DSwfhMsV.js +1 -0
  96. package/dist/assets/{sidebar-tree-Bh-tcSsp.js → sidebar-tree-C1_LiBB9.js} +1 -1
  97. package/dist/assets/{signup-page-D6cMhBxv.js → signup-page-D6hAK-Us.js} +1 -1
  98. package/dist/assets/{signup-shell-D4Afeijm.js → signup-shell-DufHA5do.js} +1 -1
  99. package/dist/assets/{site-favicon-DSzk4cg0.js → site-favicon-fQHLTT6F.js} +1 -1
  100. package/dist/assets/{skill-detail-page-Jisds_Gs.js → skill-detail-page-BlfgTyFC.js} +1 -1
  101. package/dist/assets/{skill-detail-panel-BEJqfJig.js → skill-detail-panel-BGoRUWNU.js} +1 -1
  102. package/dist/assets/{skills-CSlvOB79.js → skills-AtSQBwXr.js} +1 -1
  103. package/dist/assets/{skills-page-Cs1EG4X5.js → skills-page-DeIiyhVc.js} +1 -1
  104. package/dist/assets/{sounds-page-ChFJ0OPm.js → sounds-page-BgLLJ-o9.js} +1 -1
  105. package/dist/assets/{src-B2IjVySQ.js → src-zsLiFPw3.js} +1 -1
  106. package/dist/assets/{subagent-detail-panel-ACj_B6Id.js → subagent-detail-panel-BGuVa8-m.js} +1 -1
  107. package/dist/assets/{system-events-page-JhzC5xhW.js → system-events-page-C1hXOYmg.js} +1 -1
  108. package/dist/assets/{tiptap-document-editor-DSny-IjF.js → tiptap-document-editor-C-eOEBR_.js} +1 -1
  109. package/dist/assets/tool-detail-panel-wAuQ7gi8.js +2 -0
  110. package/dist/assets/{upgrade-cancel-page-D_YziHQs.js → upgrade-cancel-page-BGgPmDmT.js} +1 -1
  111. package/dist/assets/{upgrade-success-page-Cg7IIDei.js → upgrade-success-page-TJBopZ0Z.js} +1 -1
  112. package/dist/assets/{usage-page-DB3LFuYw.js → usage-page-DLWFk2P0.js} +1 -1
  113. package/dist/assets/use-edge-swipe-back-B4XlZ1Iu.js +1 -0
  114. package/dist/assets/use-invite-link-dialog-BdnW1BHj.js +1 -0
  115. package/dist/assets/use-is-org-ready-jhEM-4rY.js +1 -0
  116. package/dist/assets/{use-onboarding-login-Bo_t51AV.js → use-onboarding-login-B-1jrjFL.js} +1 -1
  117. package/dist/assets/{use-reduced-motion-CcGT6CHV.js → use-reduced-motion-Cj0Z8KSf.js} +1 -1
  118. package/dist/assets/{use-skill-actions-e6TfdF23.js → use-skill-actions-BpVxiQZY.js} +1 -1
  119. package/dist/assets/{use-skill-categories-i_9x26zg.js → use-skill-categories-CCxtjMC_.js} +1 -1
  120. package/dist/assets/{use-skill-detail-files-Cu4nrHPA.js → use-skill-detail-files-Dpp521cY.js} +1 -1
  121. package/dist/assets/{voice-page-wTcwV9j9.js → voice-page-BoCTB8Jx.js} +1 -1
  122. package/dist/assets/{weather-forecast-display-C_3DSHxa.js → weather-forecast-display-Bix8rpji.js} +1 -1
  123. package/dist/assets/{web-DlbBHOna.js → web-C1L-cpPj.js} +1 -1
  124. package/dist/assets/{web-BpBQ3Cf2.js → web-RhBklijR.js} +1 -1
  125. package/dist/assets/{welcome-screen-BF3r_rfT.js → welcome-screen-CVI4Hjnt.js} +1 -1
  126. package/dist/assets/{workflow-detail-panel-DzvDXyoD.js → workflow-detail-panel-CwZH3tDl.js} +1 -1
  127. package/dist/assets/workspace-page-CwIsXk1j.js +1 -0
  128. package/dist/index.html +28 -27
  129. package/package.json +1 -1
  130. package/dist/assets/channels-page-route-6cT6U3pZ.js +0 -9
  131. package/dist/assets/chat-markdown-message-CItp7csw.js +0 -2
  132. package/dist/assets/community-page-BVJxxP10.js +0 -1
  133. package/dist/assets/contacts-page-route-WXG6_xo2.js +0 -1
  134. package/dist/assets/debug-page-C-HWHD-3.js +0 -4
  135. package/dist/assets/esm-DsIXwGm7.js +0 -2
  136. package/dist/assets/hatching-screen-C0MNyetb.js +0 -1
  137. package/dist/assets/home-page-route-X4KYSdMI.js +0 -1
  138. package/dist/assets/identity-page-route-D5xzlpim.js +0 -1
  139. package/dist/assets/plugins-page-Cv0FXn1j.js +0 -1
  140. package/dist/assets/select-assistant-screen-B63mlflD.js +0 -1
  141. package/dist/assets/share-feedback-modal-BloP-1QE.js +0 -1
  142. package/dist/assets/tool-detail-panel-z5iYNIYq.js +0 -2
  143. package/dist/assets/use-edge-swipe-back-AcKDuMrX.js +0 -1
  144. package/dist/assets/use-invite-link-dialog-CExxDwnZ.js +0 -1
  145. package/dist/assets/use-is-org-ready-BtwH2--_.js +0 -1
  146. package/dist/assets/workspace-page-DCcsRyQz.js +0 -1
  147. /package/dist/assets/{a2a-invite-BriFFHnO.js → a2a-invite-B9cylfIO.js} +0 -0
  148. /package/dist/assets/{app-info-LSjlWG3w.js → app-info-Clwt3pCt.js} +0 -0
  149. /package/dist/assets/{build.umd-wlq6sZjw.js → build.umd-CxdKgGWo.js} +0 -0
  150. /package/dist/assets/{contacts-gateway-CNqVHBQ3.js → contacts-gateway-CW5CipBv.js} +0 -0
  151. /package/dist/assets/{credential-entry-page-jJzKVnQk.js → credential-entry-page-9H2HOu88.js} +0 -0
  152. /package/dist/assets/{danger-zone-redirect-page-DL5S8CAN.js → danger-zone-redirect-page-BWg7rn8D.js} +0 -0
  153. /package/dist/assets/{definitions-alqf_FBK.js → definitions-CaYcW4Yq.js} +0 -0
  154. /package/dist/assets/{definitions-B1DK4OsQ.js → definitions-DScTW2c-.js} +0 -0
  155. /package/dist/assets/{emoji-catalog-data-D_xqkMQV.js → emoji-catalog-data-D8lRMt3A.js} +0 -0
  156. /package/dist/assets/{environment-store-fb1I8_0E.js → environment-store-C0f32873.js} +0 -0
  157. /package/dist/assets/{esm-DwTCNETa.js → esm-B54gzHCZ.js} +0 -0
  158. /package/dist/assets/{file-editor-BbrbkQCm.js → file-editor-sT7eHxsw.js} +0 -0
  159. /package/dist/assets/{format-date-BczUbfC1.js → format-date-CghpPTDc.js} +0 -0
  160. /package/dist/assets/{format-file-size-D7iZejgy.js → format-file-size-DzVEncaw.js} +0 -0
  161. /package/dist/assets/{llm-dimension-Bu_nHMF_.js → llm-dimension-DyYwG3mU.js} +0 -0
  162. /package/dist/assets/{mutation-error-CrhKyTkx.js → mutation-error-DYv0eJ_i.js} +0 -0
  163. /package/dist/assets/{onboarding-step-layout-zvLUIT7j.js → onboarding-step-layout-2XcmxqFN.js} +0 -0
  164. /package/dist/assets/{optimistic-lifecycle-DTggtDfs.js → optimistic-lifecycle-BvfDBY8o.js} +0 -0
  165. /package/dist/assets/{password-reset-page-DVIt7mWy.js → password-reset-page-BCk9Si73.js} +0 -0
  166. /package/dist/assets/{pdf-CuY9CA7Q.js → pdf-C3Qukw-J.js} +0 -0
  167. /package/dist/assets/{plugins-surface-C7NU-_rg.js → plugins-surface-z3RTZS4H.js} +0 -0
  168. /package/dist/assets/{prechat-names-b5RkG_F-.js → prechat-names-clVy5Mee.js} +0 -0
  169. /package/dist/assets/{provider-key-DBiHV_K5.js → provider-key-3AHnKoz9.js} +0 -0
  170. /package/dist/assets/{proxy-BzlH_XAe.js → proxy-o6cPThl2.js} +0 -0
  171. /package/dist/assets/{public-asset-Di3QykUd.js → public-asset-GKv5zCfZ.js} +0 -0
  172. /package/dist/assets/{schedules-Dj3YQqG5.js → schedules-BfKi12EZ.js} +0 -0
  173. /package/dist/assets/{setting-row-QKgqbQ4U.js → setting-row-CUka7_L9.js} +0 -0
  174. /package/dist/assets/{skill-icon-CEEEqpSq.js → skill-icon-cNkD2w1X.js} +0 -0
  175. /package/dist/assets/{status-badge-pill-BopXdkRS.js → status-badge-pill-0N6rTEBg.js} +0 -0
  176. /package/dist/assets/{step-indicator-dots-Cou0-IgA.js → step-indicator-dots-D03TmFKG.js} +0 -0
  177. /package/dist/assets/{system-events-redirect-page-D5EfWOEK.js → system-events-redirect-page-DbaFKRXH.js} +0 -0
  178. /package/dist/assets/{three-dot-indicator-BVtP8eei.js → three-dot-indicator-DNuHHwtA.js} +0 -0
  179. /package/dist/assets/{usage-window-Btqj3Jpn.js → usage-window-C6gWu5Qu.js} +0 -0
  180. /package/dist/assets/{use-active-assistant-id-BNRMo_Mi.js → use-active-assistant-id-BWXi63qg.js} +0 -0
  181. /package/dist/assets/{use-copy-to-clipboard-tXJpCn2M.js → use-copy-to-clipboard-BCTXSMa-.js} +0 -0
  182. /package/dist/assets/{web-CsaTwTXy.js → web-BD2N6zhd.js} +0 -0
  183. /package/dist/assets/{web-Xex3K4gk.js → web-BaubW4Pp.js} +0 -0
  184. /package/dist/assets/{web-U-rR-rZR.js → web-CJiP8Lg6.js} +0 -0
  185. /package/dist/assets/{web-D5_lKOWn.js → web-D8PpvYf_.js} +0 -0
  186. /package/dist/assets/{web-B9ZvD-Tt.js → web-Duw5A2aP.js} +0 -0
  187. /package/dist/assets/{web-Bi2V5gD3.js → web-O1LOb-o9.js} +0 -0
  188. /package/dist/assets/{xterm-D9pOJCAq.js → xterm-CBmd_y-b.js} +0 -0
  189. /package/dist/assets/{xterm-addon-fit-BTV6oL76.js → xterm-addon-fit-THPW0uy0.js} +0 -0
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-Cn3RbQbT.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-DS5iJwBJ2.js"])))=>i.map(i=>d[i]);
2
- import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Dhiismgm.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-amTXFI-2.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./typography-D5f7kt80.js";import{t as m}from"./card-Bv5O5juh.js";import{t as h}from"./createLucideIcon-IRfcSUxS.js";import{t as g}from"./arrow-left-DI9551VI.js";import{t as _}from"./check-DFNrQERi.js";import{t as v}from"./circle-alert-zOqdmf25.js";import{t as y}from"./circle-check-VSiny8yl.js";import{t as b}from"./copy-Cn1FKrEp.js";import{t as x}from"./cpu-BJuB2Khn.js";import{t as S}from"./credit-card-BuyWdO9t.js";import{n as C,t as w}from"./domain-field-C5a2iMot.js";import{t as T}from"./download-CAuK-nZ6.js";import{t as E}from"./external-link-Dqpx9nRm.js";import{t as D}from"./file-text-CYJz-GvF.js";import{t as O}from"./hard-drive-rDxhoRUm.js";import{t as k}from"./info-DsOyuMO9.js";import{t as A}from"./loader-circle-Cz7opInR.js";import{a as j,c as M,i as N,n as P,r as F,t as ee}from"./resize-errors-DqIkO0UI.js";import{t as te}from"./triangle-alert-Z0Gq0IuB.js";import{t as I}from"./notice-DkcNAP8O.js";import{t as ne}from"./tag-CV4v7fRF.js";import{t as L}from"./input-CoUmPnRU.js";import{t as re}from"./toggle-CDfguvUz.js";import{n as R,t as z}from"./stat-square-CTHnQ1jc.js";import{t as B}from"./modal-D5nLWNN9.js";import{n as V}from"./toast-xTp-xwYL.js";import{t as ie}from"./confirm-dialog-CSkhRFRk.js";import{t as H}from"./dropdown-ByHOpeOU.js";import{ot as ae,st as oe}from"./sdk.gen-CmKfVpgB.js";import{c as se}from"./routes-BbeIx_F9.js";import{n as ce,t as le}from"./browser-BPZAXjRE.js";import{t as U}from"./effective-timezone-C4nukIC4.js";import{$ as ue,B as de,Dt as fe,Et as pe,G as me,H as he,J as ge,K as _e,O as ve,Q as ye,R as be,U as xe,V as W,W as Se,X as Ce,Y as we,Z as Te,at as Ee,c as De,ct as Oe,dt as ke,et as Ae,it as G,nt as je,ot as Me,q as Ne,r as K,rt as Pe,st as Fe,tt as Ie,ut as Le,wt as Re,y as ze,yt as Be,z as Ve}from"./react-query.gen-DPzPS206.js";import{D as He,Hr as Ue,Ji as We,Pn as Ge,Ur as Ke,Wr as qe,gi as Je,ha as Ye,ja as Xe,vr as Ze,yi as Qe}from"./index-CSefSVJO.js";import{t as $e}from"./add-credits-modal-daNASKHJ.js";import{t as et}from"./format-date-BczUbfC1.js";import{a as tt,n as nt,t as rt}from"./llm-dimension-Bu_nHMF_.js";import{r as it,t as at}from"./usage-window-Btqj3Jpn.js";import{t as ot}from"./environment-store-fb1I8_0E.js";var st=h(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),ct=h(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),lt=h(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),ut=h(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),dt=h(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),q=e(r(),1),J=f();function ft({onBack:e}){let t=o(),{data:n}=u(K()),r=n?.name||`your assistant`;return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(lt,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(se.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,J.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`})})]})}function pt({current:e,total:t=2}){return(0,J.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function mt({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,J.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,J.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var ht=1e3,gt=1e4;function _t(e){return N[e]??N.medium}var vt=[`machine_size`,`subdomain`,`non_field_errors`],yt={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`};function bt(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=yt[t.error];if(e)return e}for(let e of vt){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}function xt({onBack:e,onExit:t}){let n=l(),r=ot.use.emailRootDomain(),{data:a}=u(K()),o=a?.id,{data:s}=u({...De({path:{assistant_id:o??``}}),enabled:!!o}),c=s?.results?.[0],[f,m]=(0,q.useState)(``),[h,_]=(0,q.useState)(`hi`),[v,y]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!v){if(c){m(c.subdomain),y(!0);return}!a?.handle||f||(m(a.handle),y(!0))}},[a?.handle,c,v,f]);let[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(!1),T=d(Ie()),E=!!c||S,D=T.isPending||S;return(0,q.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(mt,{icon:We}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,J.jsx)(w,{subdomain:f,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:D,error:b,locked:E,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{value:h,onChange:e=>_(e.target.value.toLowerCase().trim()),disabled:D||E,readOnly:E,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(h.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(h.length,2)+1.5}ch`}}),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!E&&(0,J.jsxs)(I,{tone:`info`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:f||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,J.jsx)(I,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,J.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:D,onClick:e,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(pt,{current:0})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:E?(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:D,onClick:()=>{D||T.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||D,onClick:()=>{D||!f||T.mutate({body:{subdomain:f,...h?{email_username:h}:{}}},{onSuccess:()=>{x(null),C(!0),n.invalidateQueries({queryKey:ze()})},onError:e=>{x(bt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function St({onGoToBilling:e}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(mt,{icon:v,tone:`negative`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function Ct({message:e,onRetry:t,onGoToBilling:n}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(mt,{icon:v,tone:`warning`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,J.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function wt({title:e,body:t}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,J.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,J.jsx)(A,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:e}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function Tt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,J.jsx)(Xe,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function Et({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=u(K()),c=s?.machine_size||`small`,l=s?.provisioned_storage_gib??null,f=_t(t),m=f.length>0?f[f.length-1]:c,h=m!==c,_=e!=null&&(l==null||l<e),[v,y]=(0,q.useState)(null),b=d(ve());return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(mt,{icon:x}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h&&(0,J.jsx)(Tt,{icon:x,label:`Machine`,from:F[c],fromDetail:P[c],to:F[m],toDetail:P[m]}),_&&(0,J.jsx)(Tt,{icon:O,label:`Storage`,from:l==null?`—`:`${l} GiB`,to:`${e} GiB`}),!h&&!_&&(0,J.jsx)(I,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,J.jsx)(I,{tone:`error`,children:v}):null]}),(0,J.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(pt,{current:a,total:o})}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(bt(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Dt({onContinue:e,continueDisabled:t=!1}){return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(C,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,J.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function Ot({open:e,onClose:t}){let n=l(),[r,i]=(0,q.useState)(`confirm-pro`),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(0);(0,q.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:Ee()}),n.invalidateQueries({queryKey:Pe()}))},[e,n]);let d=(0,q.useCallback)(()=>{o(!1),c(e=>e+1),n.invalidateQueries({queryKey:Ee()})},[n]),f=u({...G(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:ht,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,q.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),gt);return()=>clearTimeout(t)},[e,r,s]),(0,q.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=u({...je(),enabled:e&&r!==`confirm-pro`});u({...K(),enabled:e});let m=p.data?.domain_setup_available,h=(0,q.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,q.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsx)(B.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,J.jsx)(St,{onGoToBilling:t}):a?(0,J.jsx)(Ct,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,J.jsx)(wt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,J.jsx)(St,{onGoToBilling:t}):(0,J.jsx)(Dt,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,J.jsx)(xt,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,J.jsx)(St,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,J.jsx)(Et,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,J.jsx)(ft,{onBack:()=>i(`setup`)}):null}}var kt=`billing-portal-return-snapshot`;function At(e){try{sessionStorage.removeItem(kt),sessionStorage.setItem(kt,JSON.stringify(e))}catch{}}function jt(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(kt);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Mt(){try{sessionStorage.removeItem(kt)}catch{}}function Nt(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Pt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function Ft(e){return e?e.cancel_at??e.current_period_end??null:null}function It(e){let t=l();return(0,q.useEffect)(()=>ce(()=>{t.invalidateQueries(G())}),[t]),pe({onSuccess:t=>{e&&At(e),le(t.portal_url)},onError:()=>{V.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Lt(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Lt(e)}/mo`}function Rt(e){return`${e>0?`+`:`−`}${Lt(Math.abs(e))}/mo`}var zt={medium:`Medium`,large:`Large`,xl:`XL`};function Bt(e){return e.disabled===!0}function Vt({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,q.useMemo)(()=>e.map(e=>{let t=zt[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Rt(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:Bt(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Rt(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:Bt(e)}}),[t,s]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,J.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,J.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Ht=new Set([`active`,`trialing`,`past_due`]),Ut=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function Wt(e,t){if(e&&typeof e==`object`){for(let t of Ut)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Gt(e,t){let n=e.filter(e=>!Bt(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Kt(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function qt(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Jt({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,J.jsxs)(B.Content,{size:`md`,hideCloseButton:!0,children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{icon:te,children:`Downgrade to Base?`})}),(0,J.jsxs)(B.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,J.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Yt=`__none__`;function Xt(e){return`${e.label} — ${Y(e.price_cents)}`}function Zt({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,q.useMemo)(()=>[{value:Yt,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:Xt(e)}))],[e]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,J.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Yt,onChange:e=>n(e===Yt?null:e),options:i})]})}function Qt({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,J.jsx)(J.Fragment,{children:e.slice(0,r).join(`, `)}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(y,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function $t({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:f,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,machineTiersForPicker:y,storageTiersForPicker:b,currentMachinePrice:x,currentStoragePrice:S,currentCreditPriceUnknown:w,proCurrentTotalCents:T,proLiveTotalCents:E,proTotalDelta:D,onboardingLoading:O,tierChangePending:j,machineChanged:M,storageChanged:N,creditChanged:P,tierChangeError:F,upgradePending:ee,portalPending:te,onUpgrade:L,onApplyTierChange:re,onDowngradeClick:R,onKeepPlan:z}){let B=e.id===`pro`,V=e.id===`base`,ie=B&&n&&r&&!a,H=B&&(!t||t&&c),ae=B&&t&&c;return(0,J.jsxs)(m,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:B?(0,J.jsx)(C,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,J.jsx)(dt,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,J.jsx)(p,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,J.jsx)(ne,{tone:`positive`,children:`Current`})]}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:V?`All you need for a capable assistant`:`More features, more compute, more storage`}),ie&&o&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:V?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Free`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(H&&E!=null)&&(T==null||w)?O?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:H&&E!=null?(0,J.jsxs)(J.Fragment,{children:[Y(E),D!=null&&D!==0&&(0,J.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Rt(D),`)`]})]}):T==null?e.id===`pro`?`From ${Y(e.base_price_cents+qt(e.machine_tiers)+qt(e.storage_tiers))}`:null:`Currently ${Y(T)}`}),H&&D!=null&&D!==0&&(0,J.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(T)} to ${Y(E)}.`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Lt(e.base_price_cents),` base fee`]})]})}),(0,J.jsx)(Qt,{features:e.included_features,variant:`checklist`}),B&&!l&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&B&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(Zt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:ee}),(0,J.jsx)(Vt,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:L,disabled:ee||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),ae&&(O?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(Zt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:j}),(0,J.jsx)(Vt,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,currentMachinePriceCents:x,currentStoragePriceCents:S}),F&&(0,J.jsx)(I,{tone:`error`,children:F}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:re,disabled:j||!M&&!N&&!P,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&V&&n&&!r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:R,disabled:te,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),ie&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:z,disabled:te,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function en({open:e,onClose:t,onTierUpgraded:n}){let r=l(),a=u(Ce()),o=u(G()),s=d(Me()),c=d(ue()),f=d(Ae()),m=d(ye()),h=It(Nt(o.data)),[_,v]=(0,q.useState)(`plans`),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(void 0);(0,q.useEffect)(()=>ce(()=>{r.invalidateQueries({queryKey:Ee()}),r.invalidateQueries({queryKey:Te()}),r.invalidateQueries({queryKey:Pe()}),t()}),[r,t]);let D=o.data?.plan_id,O=D===`pro`,k=u({...je(),enabled:O}),j=k.data?.max_machine_tier??null,M=k.data?.selected_storage_tier??null,N=k.data?.selected_storage_gib??null,P=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,F=o.data?.status===`canceled`,ee=Ft(o.data),ne=o.data?.status,L=ne!=null&&Ht.has(ne),re=O&&L&&!P&&!F,R=a.data?.plans.find(e=>e.id===`pro`),z=R?.credit_tiers??[],ie=z.length>0,H=o.data?.selected_credit_tier??null,ae=e=>z.find(t=>t.tier===e)?.price_cents??0,oe=ae(H),se=H!=null&&!z.some(e=>e.tier===H),U=T===void 0?H:T,de=ae(U),fe=R?.machine_tiers??[],pe=re&&N!=null?(R?.storage_tiers??[]).map(e=>e.storage_gib<N?{...e,disabled:!0}:e):R?.storage_tiers??[];(0,q.useEffect)(()=>{if(!e){S(null),w(null),E(void 0);return}if(R){if(re){if(j==null||M==null)return;S(e=>Gt(fe,e??j)),w(e=>Gt(pe,e??M)),E(e=>Kt(z,e,H));return}S(e=>Gt(R.machine_tiers,e)),w(e=>Gt(R.storage_tiers,e)),E(e=>Kt(z,e,null))}},[e,R,re,j,M,H]);let me=a.data?.plans.find(e=>e.id===`base`),he=new Set(me?.included_features??[]),ge=(R?.included_features??[]).filter(e=>!he.has(e)),_e=()=>{if(!s.isPending){if(!x||!C){V.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:C,credit_tier:U}},{onSuccess:e=>{if(e.checkout_url){le(e.checkout_url);return}if(e.status===`no_op`){V.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}V.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{V.error(Wt(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ve=()=>{h.isPending||(v(`plans`),h.mutate({}))},be=()=>{r.invalidateQueries({queryKey:Ee()}),r.invalidateQueries({queryKey:Pe()}),r.invalidateQueries({queryKey:Te()})},xe=c.isPending||f.isPending||m.isPending,W=x!=null&&x!==j,Se=C!=null&&C!==M,we=ie&&T!==void 0&&T!==H,De=e=>fe.find(t=>t.tier===e)?.price_cents??null,Oe=e=>pe.find(t=>t.tier===e)?.price_cents??null,ke=De(x),Ne=Oe(C),K=De(j),Fe=Oe(M),Ie=W&&ke!=null&&K!=null&&ke<K,Le=()=>{if(xe)return;let e=[];W&&x&&e.push(new Promise(e=>{c.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),Se&&C&&e.push(new Promise(e=>{f.mutate({body:{storage_tier:C}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),we&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:U}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{be();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Ie,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>Wt(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);V.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):V.success(we&&!W&&!Se?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Re=()=>{if(!xe){if(Ie){b(!0);return}Le()}},ze=()=>{b(!1),Le()},Be=e=>ke!=null&&Ne!=null?e.base_price_cents+ke+Ne+de:null,Ve=e=>K!=null&&Fe!=null?e.base_price_cents+K+Fe+oe:null,He=c.isError||f.isError||m.isError?Wt(c.error??f.error??m.error,`Failed to update plan. Please try again.`):null,Ue=a.isLoading||o.isLoading,We=a.isError||o.isError||!a.data||!o.data;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,J.jsx)(B.Content,{size:_===`plans`?`lg`:`md`,children:_===`downgrade-confirm`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{icon:te,children:`Downgrade to Base?`})}),(0,J.jsxs)(B.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:ge.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:h.isPending,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(i,{variant:`danger`,onClick:ve,disabled:h.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,J.jsx)(B.Body,{children:Ue?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):We?(0,J.jsx)(I,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===D,n=e.id===`pro`&&R?Be(R):null,r=e.id===`pro`&&R?Ve(R):null;return(0,J.jsx)($t,{plan:e,isCurrent:t,onPro:O,cancelAtPeriodEnd:P,isCanceled:F,cancelDate:ee,formatGraceDate:Pt,proTierChangeMode:re,creditTiersEnabled:ie,creditTiers:z,displayCreditTier:U,onCreditTierChange:E,selectedMachineTier:x,selectedStorageTier:C,onMachineTierChange:S,onStorageTierChange:w,machineTiersForPicker:fe,storageTiersForPicker:pe,currentMachinePrice:K,currentStoragePrice:Fe,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:k.isLoading,tierChangePending:xe,machineChanged:W,storageChanged:Se,creditChanged:we,tierChangeError:He,upgradePending:s.isPending,portalPending:h.isPending,onUpgrade:_e,onApplyTierChange:Re,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>h.mutate({})},e.id)})})]})}),(0,J.jsxs)(B.Footer,{className:`relative items-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,J.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,J.jsx)(Jt,{open:y,onCancel:()=>b(!1),onConfirm:ze,confirming:xe,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var tn={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function nn(e){return tn[e.toLowerCase()]??e}function rn(e,t){return`${nn(e??`card`)} •••• ${t??`????`}`}function an({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,J.jsx)(ie,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var on={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function sn(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function cn(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function ln(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function un({initialValues:e=on,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,q.useState)(e),[c,l]=(0,q.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=cn(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:sn(t[e])}))},p=e=>ln(e,u,n,c[e]);return(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(L,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(L,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(L,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,J.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:sn(o.threshold_usd),amount_usd:sn(o.amount_usd),monthly_cap_usd:sn(o.monthly_cap_usd)};s(e);let t=cn(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function dn(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function fn(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var pn={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function mn(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function hn(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${rn(t,n)}`:`Charged to ${nn(t??`card`)}`}function gn(){let e=l(),t=u(de()),n=d(Se()),r=d(be()),[a,o]=(0,q.useState)(`view`),[s,c]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,_=g.enabled===!0,v=g.disabled_due_to_repeated_failures===!0&&!_,y=()=>{n.reset(),r.reset(),o(`form`)},b=()=>{o(`view`),c(!1)},x=()=>{r.reset(),p(!1)},S=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{he(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:W()}),b()}})},C=()=>{r.mutate({},{onSuccess:()=>{he(e,void 0,e=>({...pn,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),c(!1)}})},w=e=>{if(e&&!_){if(!g.has_payment_method||v){h(!0);return}h(!1),c(!0),y();return}if(!e&&!_&&s){b();return}!e&&_&&p(!0)},T=a===`form`,E=mn(n.error),D=n.isError&&Object.keys(E).length===0,O=_||s,k=hn({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,J.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsx)(re,{checked:O,onChange:w,label:`Enable Auto-Reload`}),_&&!T&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`text-right`,children:[(0,J.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,fn(g.amount_usd),` when the balance falls under `,fn(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,J.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[fn(g.current_month_credits_purchased_usd),` of`,` `,fn(g.monthly_cap_usd),` this month`]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:y,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),v&&(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,J.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!v?`1fr`:`0fr`},children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),D&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),T&&(0,J.jsx)(un,{initialValues:_?{threshold_usd:dn(g.threshold_usd),amount_usd:dn(g.amount_usd),monthly_cap_usd:dn(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:E,onCancel:b,onSave:S}),_&&!g.has_payment_method&&(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),_&&g.has_payment_method&&(0,J.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:k??`Charged to a saved card`}),(_||T)&&(0,J.jsx)(I,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,J.jsx)(an,{open:f,confirming:r.isPending,onCancel:x,onConfirm:C})]})}function _n(e){let t=parseFloat(e);return Number.isFinite(t)?`$${t.toFixed(2)}`:`$${e}`}function vn(e){if(e.trim()===``)return;let t=parseFloat(e);if(!Number.isFinite(t)||t<1||t>1e3)return`Must be between $1 and $1,000`;if(!/^\d+(\.\d{1,2})?$/.test(e.trim()))return`Use at most two decimal places`}function yn(){let e=l(),t=u(_e()),n=d(we()),[r,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1);if(t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load low-balance alert settings.`})});let c=t.data,f=r??c.threshold_usd??``,p=vn(f),m=e=>{a(e.target.value)},h=t=>{n.mutate({body:{threshold_usd:t}},{onSuccess:t=>{ge(e,void 0,t),e.invalidateQueries({queryKey:Ne()}),a(null),s(!1)}})},g=()=>{if(s(!0),p)return;let e=f.trim();h(e===``?null:parseFloat(e).toFixed(2))},_=()=>{a(``),s(!1),h(null)},v=n.isError,y=o?p:void 0;return(0,J.jsxs)(`div`,{"data-testid":`low-balance-alert-card`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[12rem] flex-1`,children:(0,J.jsx)(L,{type:`number`,step:`0.01`,label:`Alert me when my balance drops below`,helperText:`Default is ${_n(c.default_threshold_usd)} when unset`,placeholder:c.effective_threshold_usd,value:f,onChange:m,onBlur:()=>s(!0),errorText:y,"data-testid":`low-balance-alert-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[c.threshold_usd!=null&&(0,J.jsx)(i,{variant:`outlined`,onClick:_,disabled:n.isPending,"data-testid":`low-balance-alert-reset-button`,children:`Reset to default`}),(0,J.jsx)(i,{variant:`primary`,onClick:g,disabled:n.isPending,"data-testid":`low-balance-alert-save-button`,children:`Save`})]})]}),v&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`low-balance-alert-update-error`,children:`Failed to save low-balance alert. Please try again.`})]})}var bn=2e3;function xn(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function Sn(){let e=l(),{data:t,isLoading:n,isError:r}=u(Fe()),a=t??null,[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(0),d=(0,q.useRef)(null),f=fe({onSuccess:()=>{e.invalidateQueries({queryKey:Oe()})},onError:()=>{c.current<3&&(d.current=setTimeout(()=>{f.reset()},bn))}});(0,q.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=f.mutate;(0,q.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&c.current<3&&!f.isPending&&!f.isError&&!f.isSuccess&&(c.current+=1,h({}))},[a,f.isPending,f.isError,f.isSuccess,h]);let g=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(m,{padding:`md`,children:[g,n?(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(z,{icon:(0,J.jsx)(Ye,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`effective-balance`,children:xn(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,J.jsx)(z,{icon:(0,J.jsx)(st,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`settled-balance`,children:xn(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,J.jsx)(z,{icon:(0,J.jsx)(ct,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`pending-charges`,children:xn(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,J.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(gn,{})}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(yn,{})})]}),(0,J.jsx)($e,{open:o,onOpenChange:s})]})}var Cn=1e3,wn=15e3,Tn=3e3,En=45e3,Dn=`billing-portal-return`;function On(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?Pt(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function kn(){let[e]=s(),t=o(),n=l(),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,q.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=jt(),o=G(),s=Ee(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<wn&&(await new Promise(e=>setTimeout(e,Cn)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=On(a,e);t===`success`?V.success(n,{id:Dn}):V.info(n,{id:Dn})}catch{if(i.current)return;V.info(`Subscription updated.`,{id:Dn})}finally{if(!i.current){Mt(),t(se.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=En){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},Tn)}}})(),()=>{i.current=!0}},[e,t,n]),null}var An=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function jn(e,t=U()){let{fromDate:n,toDate:r}=at(e,t);return{from:n,to:r}}function Mn(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function Nn({from:e,to:t}){let n=Mn(e,t);return n===7?7:n===90?90:30}function Pn({value:e,onChange:t}){let n=Ge(),r=(0,q.useMemo)(()=>`${Nn(e)}`,[e]);return(0,J.jsx)(H,{options:An,value:r,onChange:e=>{let r=Number(e);t(jn(r,n),r)},"aria-label":`Date range`})}var Fn={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},In={fontSize:12,fill:`var(--content-tertiary)`},Ln={stroke:`var(--border-subtle)`,strokeOpacity:.4},Rn=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function zn({item:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Bn({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,J.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??it)(String(r))}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(zn,{item:u}),d.length>0&&(0,J.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,J.jsx)(zn,{item:e},e.key)),s&&(0,J.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,J.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Vn(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Hn(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function Un(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Wn(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Hn(n/r)*r}function Gn(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function Kn(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function qn(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Jn=40,Yn={fontSize:11,fill:`var(--content-tertiary)`},Xn={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function Zn(e,t){return Xn[e]??Rn[t%Rn.length]??`#6b7280`}function Qn(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function $n({stackKeys:e,labelMap:t}){return(0,J.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:Zn(e,n)}}),(0,J.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var er=350,tr={top:8,right:4,bottom:32,left:0},nr=.2,rr=5,ir=12,ar=200;function or({buckets:e,metric:t,onBarClick:n}){let r=Ze(),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,q.useMemo)(()=>Qn(e,t),[e,t]),u=(0,q.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=Zn(c[t],t);return e},[c]),d=(0,q.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,q.useState)(null),m=r?Jn:56,h=r?Yn:In,g=tr.left+m,_=Math.max(0,a-g-tr.right),v=tr.top,y=er-tr.top-tr.bottom,b=(0,q.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,q.useMemo)(()=>Wn(b,{integerOnly:x,tickCount:rr}),[b,x]),C=(0,q.useMemo)(()=>Gn(S,rr),[S]),w=(0,q.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/rr,n=Math.max(t<1?2:0,Un(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,q.useMemo)(()=>Vn([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-nr),k=(D-O)/2,A=(0,q.useMemo)(()=>qn(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:Zn(t,i),isLast:u}})}}),N=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},P=()=>p(null),F=e=>{n&&n(e)},ee=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],te={left:f?Math.max(0,Math.min(f.x+ir,a-ar)):0,top:f?f.y-ir:0,visibility:f?`visible`:`hidden`};return(0,J.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:er},children:j?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{width:a,height:er,className:`block`,children:[C.map(e=>(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:Fn.stroke,strokeOpacity:Fn.strokeOpacity,strokeDasharray:Fn.strokeDasharray},e)),(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:Ln.stroke,strokeOpacity:Ln.strokeOpacity}),C.map(e=>(0,J.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,J.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:it(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>N(n,e,t.key),onMouseLeave:P,onClick:()=>F(t.key)};return t.isLast?(0,J.jsx)(`path`,{...i,d:Kn(t.x,t.y,O,t.h,3)}):(0,J.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:te,children:(0,J.jsx)(Bn,{active:!!f,payload:ee,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,J.jsx)($n,{stackKeys:c,labelMap:l})]})}function sr(e=U()){return jn(30,e)}function cr(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:tt(e.llmDimension??`model`)}function lr(e,t=U()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:cr(e.drilldown)}:{}}}function ur(e,t=U()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function dr(e){let t=Ge(),n=u(Le({query:lr(e,t)})),r=u(ke({query:ur(e,t)}));return{series:n.data,totals:r.data,isLoading:n.isLoading||r.isLoading,isError:n.isError||r.isError}}var fr=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function pr(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function mr(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function hr(){let e=Ge(),[t,n]=(0,q.useState)(30),[r,i]=(0,q.useState)(()=>sr(e)),a=(0,q.useMemo)(()=>t===null?r:jn(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`spend`),{series:d,totals:f,isLoading:h,isError:_}=dr({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),v=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:rt}:{}})};return(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,J.jsx)(Pn,{value:a,onChange:o}),(0,J.jsx)(`div`,{className:`w-44`,children:(0,J.jsx)(R,{items:fr,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(z,{icon:(0,J.jsx)(Ye,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):pr(f?.total_usd),label:`Spend`}),(0,J.jsx)(z,{icon:(0,J.jsx)(ut,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):mr(f?.event_count),label:`Events`})]}),s&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,J.jsx)(g,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Back to all usage`}),(0,J.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,J.jsx)(`div`,{className:`w-56`,children:(0,J.jsx)(R,{items:nt,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),h?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,J.jsx)(A,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):_?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,J.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,J.jsx)(or,{buckets:d.buckets,metric:l,onBarClick:v})}):null]})})}function gr(){let{data:e}=u(G()),t=It((0,q.useMemo)(()=>Nt(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=Ft(e);return n?(0,J.jsx)(I,{tone:`info`,title:`Your Pro plan will end on ${Pt(n)}.`,actions:(0,J.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,J.jsx)(A,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var _r=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),vr=t(((e,t)=>{var n=_r();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=vr()()}))(),1);function yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function br(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yr(Object(n),!0).forEach(function(t){Sr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xr(e){"@babel/helpers - typeof";return xr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xr(e)}function Sr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cr(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function wr(e,t){if(e==null)return{};var n=Cr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Tr(e,t){return Er(e)||Dr(e,t)||Or(e,t)||Ar()}function Er(e){if(Array.isArray(e))return e}function Dr(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Or(e,t){if(e){if(typeof e==`string`)return kr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kr(e,t)}}function kr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ar(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Z=function(e,t,n){var r=!!n,i=q.useRef(n);q.useEffect(function(){i.current=n},[n]),q.useEffect(function(){if(!r||!e)return function(){};var n=function(){i.current&&i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},jr=function(e){var t=q.useRef(e);return q.useEffect(function(){t.current=e},[e]),t.current},Mr=function(e){return e!==null&&xr(e)===`object`},Nr=function(e){return Mr(e)&&typeof e.then==`function`},Pr=function(e){return Mr(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Fr=`[object Object]`,Ir=function e(t,n){if(!Mr(t)||!Mr(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Fr;if(i!==(Object.prototype.toString.call(n)===Fr))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Lr=function(e,t,n){return Mr(e)?Object.keys(e).reduce(function(r,i){var a=!Mr(t)||!Ir(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?br(br({},r||{}),{},Sr({},i,e[i])):r},null):null},Rr="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",zr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rr;if(e===null||Pr(e))return e;throw Error(t)},Br=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rr;if(Nr(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return zr(e,t)})};var n=zr(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Vr=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Hr=q.createContext(null);Hr.displayName=`ElementsContext`;var Ur=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e},Wr=function(e){var t=e.stripe,n=e.options,r=e.children,i=q.useMemo(function(){return Br(t)},[t]),a=Tr(q.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];q.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=jr(t);q.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=jr(n);return q.useEffect(function(){if(o.elements){var e=Lr(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),q.useEffect(function(){Vr(o.stripe)},[o.stripe]),q.createElement(Hr.Provider,{value:o},r)};Wr.propTypes={stripe:X.default.any,options:X.default.object};var Gr=function(e){return Ur(q.useContext(Hr),e)},Kr=function(e){var t=e.children;return t(Gr(`mounts <ElementsConsumer>`))};Kr.propTypes={children:X.default.func.isRequired};var qr=q.createContext(null);qr.displayName=`CheckoutContext`;var Jr=function(e){var t=q.useContext(qr),n=q.useContext(Hr);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}else return Ur(n,e)},Yr=[`mode`],Xr=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,t,n){var r=`${Xr(e)}Element`,i=t?function(e){Jr(`mounts <${r}>`);var t=e.id,n=e.className;return q.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=Jr(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=Tr(q.useState(null),2),O=D[0],k=D[1],A=q.useRef(null),j=q.useRef(null);Z(O,`blur`,s),Z(O,`focus`,c),Z(O,`escape`,d),Z(O,`click`,f),Z(O,`loaderror`,p),Z(O,`loaderstart`,m),Z(O,`networkschange`,h),Z(O,`confirm`,g),Z(O,`cancel`,_),Z(O,`shippingaddresschange`,v),Z(O,`shippingratechange`,y),Z(O,`savedpaymentmethodremove`,b),Z(O,`savedpaymentmethodupdate`,x),Z(O,`availablepaymentmethodschange`,S),Z(O,`change`,u);var M;l&&(M=e===`expressCheckout`?l:function(){l(O)}),Z(O,`ready`,M),q.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=wr(o,Yr);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var N=jr(o);return q.useEffect(function(){if(A.current){var e=Lr(o,N,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,N]),q.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),q.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:X.default.string,className:X.default.string,onChange:X.default.func,onBlur:X.default.func,onFocus:X.default.func,onReady:X.default.func,onEscape:X.default.func,onClick:X.default.func,onLoadError:X.default.func,onLoaderStart:X.default.func,onNetworksChange:X.default.func,onConfirm:X.default.func,onCancel:X.default.func,onShippingAddressChange:X.default.func,onShippingRateChange:X.default.func,onSavedPaymentMethodRemove:X.default.func,onSavedPaymentMethodUpdate:X.default.func,onAvailablePaymentMethodsChange:X.default.func,options:X.default.object},i.displayName=r,i.__elementType=e,i},$=typeof window>`u`,Zr=q.createContext(null);Zr.displayName=`EmbeddedCheckoutProviderContext`,Q(`auBankAccount`,$),Q(`card`,$),Q(`cardNumber`,$),Q(`cardExpiry`,$),Q(`cardCvc`,$),Q(`iban`,$),Q(`payment`,$),Q(`expressCheckout`,$),Q(`paymentRequestButton`,$),Q(`linkAuthentication`,$),Q(`contactDetails`,$),Q(`address`,$),Q(`shippingAddress`,$),Q(`paymentMethodMessaging`,$),Q(`taxId`,$),Q(`issuingCardNumberDisplay`,$),Q(`issuingCardCvcDisplay`,$),Q(`issuingCardExpiryDisplay`,$),Q(`issuingCardPinDisplay`,$),Q(`issuingCardCopyButton`,$);var Qr=`dahlia`,$r=`https://js.stripe.com`,ei=`${$r}/${Qr}/stripe.js`,ti=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,ni=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,ri=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,ii=function(e){return ti.test(e)||ni.test(e)},ai=function(){for(var e=document.querySelectorAll(`script[src^="${$r}"]`),t=0;t<e.length;t++){var n=e[t];if(ii(n.src))return n}return null},oi=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${ei}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},si=null,ci=null,li=null,ui=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},di=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},fi=function(e){return si===null?(si=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(ri),window.Stripe){t(window.Stripe);return}try{var r=ai();if(r&&e)console.warn(ri);else if(!r)r=oi(e);else if(r&&li!==null&&ci!==null){var i;r.removeEventListener(`load`,li),r.removeEventListener(`error`,ci),(i=r.parentNode)==null||i.removeChild(r),r=oi(e)}li=di(t,n),ci=ui(n),r.addEventListener(`load`,li),r.addEventListener(`error`,ci)}catch(e){n(e);return}}),si.catch(function(e){return si=null,Promise.reject(e)})):si},pi,mi=!1,hi=function(){return pi||(pi=fi(null).catch(function(e){return pi=null,Promise.reject(e)}),pi)};Promise.resolve().then(function(){return hi()}).catch(function(e){mi||console.warn(e)});function gi(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{theme:`night`}:{theme:`stripe`}}function _i({open:e,onClose:t,onSavedOptimistic:n}){let r=d(xe()),{mutate:i,reset:a}=r;return(0,q.useEffect)(()=>{e||a()},[e,i,a]),(0,q.useMemo)(()=>gi(),[r.data?.client_secret??null]),(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(B.Content,{size:`sm`,children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{children:`Save Payment Method`})}),(0,J.jsx)(B.Body,{className:`min-h-[260px]`,children:(0,J.jsx)(vi,{})})]})})}function vi(){return(0,q.useEffect)(()=>{console.warn(`[AutoTopUpPaymentMethodModal] VITE_STRIPE_PUBLISHABLE_KEY is not set; the payment-method modal cannot mount Stripe Elements.`)},[]),(0,J.jsx)(I,{tone:`error`,children:`Payment method setup is currently unavailable. Please try again later.`})}function yi(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Payment Method`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`This is the payment method that will be used for automated credit reloads.`})]})}function bi(){let e=l(),t=u(de()),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=d(Ve()),c=async()=>{let t=Date.now(),n=e=>e?.stripe_payment_method_updated_at??null,r=n(e.getQueryData(W()));try{await e.invalidateQueries({queryKey:W()})}catch{}for(;Date.now()-t<2e4;){try{let t=await e.fetchQuery(de());if(t.has_payment_method&&n(t)!==r)return}catch{}await new Promise(e=>setTimeout(e,1500))}};if(t.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(yi,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading…`]})]});if(t.isError||!t.data)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(yi,{}),(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load payment method.`})})]});let f=t.data,h=nn(f.payment_method_brand??`card`),g=f.payment_method_last4;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(yi,{}),f.has_payment_method?(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,children:h}),g?(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[`Ending in `,g]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>r(!0),children:`Change`}),(0,J.jsx)(i,{variant:`ghost`,onClick:()=>o(!0),disabled:a||s.isPending,leftIcon:(0,J.jsx)(Qe,{className:`h-3.5 w-3.5`}),children:`Remove`})]})]}):(0,J.jsx)(i,{className:`self-start`,onClick:()=>r(!0),children:`Add Card`})]})}),(0,J.jsx)(ie,{open:a,title:`Remove payment method?`,message:`Removing your payment method will disable automatic top-ups. You can re-enable them after adding a new payment method.`,confirmLabel:s.isPending?`Removing…`:`Remove`,cancelLabel:`Keep`,destructive:!0,onConfirm:()=>{s.isPending||s.mutate({},{onSuccess:()=>{he(e,void 0,e=>e?{...e,enabled:!1,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null}:pn),o(!1)},onError:()=>{V.error(`Failed to remove payment method. Please try again.`),o(!1)}})},onCancel:()=>{s.isPending||o(!1)}}),(0,J.jsx)(_i,{open:n,onClose:()=>r(!1),onSavedOptimistic:c})]})}var xi={invoices:[]};function Si(e){switch(e){case`paid`:return`positive`;case`open`:return`warning`;case`uncollectible`:return`negative`;default:return`neutral`}}function Ci(e,t){let n=t.toUpperCase();try{let t=new Intl.NumberFormat(void 0,{style:`currency`,currency:n}),r=t.resolvedOptions().maximumFractionDigits??2;return t.format(e/10**r)}catch{return`${(e/100).toFixed(2)} ${n}`}}function wi(e){return et(new Date(e*1e3),{alwaysShowYear:!0})}function Ti(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function Ei({open:e,onOpenChange:t}){let[r,o]=(0,q.useState)(!1),s=u({queryKey:me(),enabled:e,queryFn:async({signal:e})=>{let{data:t,response:n}=await oe({throwOnError:!1,signal:e});if(n?.status===404)return xi;if(!n?.ok||!t)throw Error(`Failed to load invoices (${n?.status??`network error`})`);return t}}),c=s.data?.invoices??[],l=c.some(e=>e.invoice_pdf!=null);async function d(){o(!0);try{let{data:e,response:t}=await ae({throwOnError:!1,parseAs:`blob`});if(!t?.ok||!(e instanceof Blob))throw Error(`Failed to download invoices (${t?.status??`network error`})`);let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-Cn3RbQbT.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await n(e,`invoices.zip`)}catch(e){n(e,{context:`download_all_invoices`}),V.error(`Failed to download invoices.`)}finally{o(!1)}}return(0,J.jsx)(B.Root,{open:e,onOpenChange:t,children:(0,J.jsxs)(B.Content,{size:`lg`,children:[(0,J.jsxs)(B.Header,{children:[(0,J.jsx)(B.Title,{icon:D,children:`Invoices`}),(0,J.jsx)(B.Description,{children:`Your billing history. Open an invoice for full details or download it as a PDF.`})]}),(0,J.jsx)(B.Body,{children:s.isLoading?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading invoices...`})]}):s.isError?(0,J.jsx)(I,{tone:`error`,children:`Failed to load invoices.`}):c.length===0?(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`py-6 text-center text-[var(--content-tertiary)]`,"data-testid":`invoices-empty`,children:`No Invoices Found`}):(0,J.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,"data-testid":`invoice-row`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,className:`text-[var(--content-default)]`,children:e.number??`Invoice`}),e.status&&(0,J.jsx)(ne,{tone:Si(e.status),children:e.status})]}),(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[wi(e.created),` ·`,` `,Ci(e.amount_due,e.currency)]})]}),e.hosted_invoice_url&&(0,J.jsx)(i,{asChild:!0,variant:`ghost`,size:`compact`,leftIcon:(0,J.jsx)(E,{}),children:(0,J.jsx)(`a`,{href:e.hosted_invoice_url,target:`_blank`,rel:`noopener noreferrer`,children:`View`})}),e.invoice_pdf&&(0,J.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,J.jsx)(T,{}),"aria-label":`Download invoice PDF`,onClick:()=>Ti(e.invoice_pdf)})]},e.id))})}),(0,J.jsxs)(B.Footer,{children:[l&&(0,J.jsx)(i,{variant:`outlined`,leftIcon:r?(0,J.jsx)(A,{className:`animate-spin`}):(0,J.jsx)(T,{}),disabled:r,onClick:d,children:`Download all`}),(0,J.jsx)(B.Close,{asChild:!0,children:(0,J.jsx)(i,{variant:`primary`,children:`Done`})})]})]})})}var Di={pro:{icon:C,actionLabel:`Manage`,actionVariant:`outlined`,actionTestId:`plan-card-manage-button`,showsRenewal:!0},base:{icon:dt,actionLabel:`Upgrade to Pro`,actionVariant:`primary`,actionTestId:`plan-card-upgrade-button`,showsRenewal:!1}},Oi=Di.base;function ki(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Plan`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Manage which Vellum plan you're on.`})]})}function Ai({onManage:e}){let[t,n]=(0,q.useState)(!1),r=u(G()),a=u(Ce());if(r.isLoading||a.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(ki,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading plan...`})]})]});let o=r.data,s=a.data?.plans,c=s?.find(e=>e.id===o?.plan_id);if(r.isError||a.isError||!o||!s||!c)return(0,J.jsx)(I,{tone:`error`,children:`Failed to load plan.`});let l=Di[c.id]??Oi,d=l.icon,f=c.name??c.id,h=l.showsRenewal&&(o.cancel_at_period_end===!0||!!o.cancel_at),g=o.status===`canceled`,_=Ft(o),v=l.showsRenewal&&!h&&!g&&o.current_period_end,y=l.showsRenewal&&h&&!g&&_,b=c.id===`pro`?c:void 0,x=o.selected_credit_tier??null,S=x==null?void 0:b?.credit_tiers,C=S?.find(e=>e.tier===x),w=C?`${C.label} (${Y(C.price_cents)})`:S?.length?x:null;return(0,J.jsxs)(m,{padding:`lg`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(i,{variant:`outlined`,leftIcon:(0,J.jsx)(D,{}),onClick:()=>n(!0),"data-testid":`plan-card-invoices-button`,children:`Invoices`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:(0,J.jsx)(d,{className:`h-4 w-4 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`div`,"data-testid":`plan-card-name`,children:f}),(0,J.jsx)(p,{variant:`body-small-default`,as:`div`,className:`leading-snug text-[var(--content-tertiary)]`,children:(0,J.jsx)(Qt,{features:c.included_features,variant:`inline`})})]}),(0,J.jsx)(i,{variant:l.actionVariant,onClick:e,"data-testid":l.actionTestId,children:l.actionLabel})]}),w&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-credit-bundle`,children:[`Monthly credits: `,w]}),v&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-renews`,children:[`Renews on `,Pt(o.current_period_end),`.`]}),y&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`plan-card-cancels`,children:[`Your plan ends on `,Pt(_),`.`]})]}),(0,J.jsx)(Ei,{open:t,onOpenChange:n})]})}var ji=`settings-referral-panel`;function Mi(e){return e.replace(/\.00$/,``)}function Ni(){let{data:e,isLoading:t,isError:n}=u(Be()),[r,a]=(0,q.useState)(!1),o=(0,q.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{a(!0),V.success(`Copied to clipboard!`),setTimeout(()=>a(!1),2e3)})},[]),s=e?.is_eligible_for_credits===!1,c=s?`Invite friends to Vellum. You'll start earning referral credits once you've purchased credits or upgraded to Pro.`:e?`Share Vellum with friends - you'll each earn ${Mi(e.referrer_credit_amount)} credits when they sign up, up to ${Mi(e.earning_cap)} total.`:`Share Vellum with friends and earn credits for every signup.`;return(0,J.jsx)(m,{padding:`md`,id:ji,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Earn Free Credits`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:c})]}),s&&(0,J.jsx)(I,{tone:`info`,children:`You're not currently earning referral credits. Buy credits or upgrade to Pro to start earning — your invite link still works in the meantime.`}),t?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading...`]}):n||!e?(0,J.jsx)(I,{tone:`error`,children:`Failed to load referral information.`}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Ye,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:Mi(e.total_earned)}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Credits Earned`})]})]}),(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Je,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:e.referred_count}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Friends Referred`})]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:()=>o(e.referral_url),leftIcon:r?(0,J.jsx)(_,{className:`h-3.5 w-3.5`}):(0,J.jsx)(b,{className:`h-3.5 w-3.5`}),"data-testid":`referral-copy-button`,children:r?`Copied!`:`Copy Share Link`})]})]})})}function Pi({icon:e,label:t,from:n,to:r}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),(0,J.jsx)(Xe,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:r})]})]})]})}function Fi({open:e,onClose:t}){let n=u({...K(),enabled:e}),r=u({...je(),enabled:e}),a=n.data,o=a?.machine_size||`small`,s=a?.provisioned_storage_gib??null,c=r.data?.max_machine_tier??null,l=r.data?.selected_storage_gib??null,d=j(c),f=d.length>0?d[d.length-1]:o,p=f!==o,m=l!=null&&(s==null||s<l),h=p||m,[g,_]=(0,q.useState)(null),v=Re({onSuccess:()=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),_(null),t()},onError:e=>{_(ee(e,`Failed to resize assistant. Please try again.`))}}),y=v.isPending,b=n.isLoading||r.isLoading;return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(_(null),t())},children:(0,J.jsxs)(B.Content,{size:`sm`,children:[(0,J.jsxs)(B.Header,{children:[(0,J.jsx)(B.Title,{icon:M,children:`Plan Updated`}),(0,J.jsx)(B.Description,{children:`Your new resources are ready. Apply them now to resize your assistant — it will briefly restart.`})]}),(0,J.jsxs)(B.Body,{children:[b?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,J.jsx)(A,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):h?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Pi,{icon:x,label:`Machine`,from:F[o],to:F[f]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`CPU`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:P[f].split(`,`)[0].trim()})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`Memory`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:P[f].split(`,`)[1].trim()})]})]})]}),m&&(0,J.jsx)(Pi,{icon:O,label:`Storage`,from:s==null?`—`:`${s} GiB`,to:`${l} GiB`})]}):(0,J.jsx)(I,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`}),g&&(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(I,{tone:`error`,children:g})})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>{_(null),t()},children:`Do Later`}),(0,J.jsx)(i,{disabled:b||!h||y||!a?.id,leftIcon:y?(0,J.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>{if(!a?.id)return;_(null);let e={};p&&(e.machine_size=f),m&&l!=null&&(e.storage_gib=l),v.mutate({path:{id:a.id},body:e})},children:g?`Retry`:`Apply & Restart`})]})]})})}function Ii(){let[e]=s(),t=o(),n=l();return(0,q.useEffect)(()=>{let r=e.get(`billing_status`);r&&(r===`success`?(V.success(`Payment received! Your credit balance will update shortly.`,{id:`billing-status`}),n.invalidateQueries({queryKey:Fe().queryKey})):r===`cancel`&&V.info(`Checkout was cancelled. No credits were added.`,{id:`billing-status`}),t(se.settings.billing,{replace:!0}))},[e,t,n]),null}function Li(){let e=qe({platformHostedOnly:!0}),t=qe(),n=Ue(),r=Ke(),[i,a]=s(),[o,l]=(0,q.useState)(!1),u=(0,q.useCallback)(()=>l(!0),[]),d=(0,q.useCallback)(()=>l(!1),[]),[f,p]=(0,q.useState)(!1),m=(0,q.useCallback)(()=>p(!0),[]);(0,q.useEffect)(()=>{i.has(`adjust_plan`)&&(l(!0),a(e=>{let t=new URLSearchParams(e);return t.delete(`adjust_plan`),t},{replace:!0}))},[i,a]);let h=i.has(`session_id`),g=(0,q.useCallback)(()=>{a(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})},[a]);if(t===`gated`)return(0,J.jsx)(c,{replace:!0,to:se.settings.general});if(t===`disabled`)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(He,{children:`Log in to the Vellum platform to manage billing and usage.`})});if(r)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading billing…`]})});let _=n;return!n&&e!==`gated`?(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(I,{tone:`warning`,children:`Billing isn't available for the current assistant state.`})}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(q.Suspense,{fallback:null,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(kn,{})]}),_&&(0,J.jsx)(gr,{}),_&&(0,J.jsx)(Ai,{onManage:u}),_&&(0,J.jsx)(en,{open:o,onClose:d,onTierUpgraded:m}),(0,J.jsx)(bi,{}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Sn,{})}),(0,J.jsx)(Ni,{}),(0,J.jsx)(hr,{}),_&&(0,J.jsx)(Ot,{open:h,onClose:g}),_&&(0,J.jsx)(Fi,{open:f,onClose:()=>p(!1)})]})}export{Li as BillingPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-DI99Emal.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-DS5iJwBJ2.js"])))=>i.map(i=>d[i]);
2
+ import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Dhiismgm.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-amTXFI-2.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./typography-D5f7kt80.js";import{t as m}from"./card-Bv5O5juh.js";import{t as h}from"./createLucideIcon-IRfcSUxS.js";import{t as g}from"./arrow-left-DI9551VI.js";import{t as _}from"./check-DFNrQERi.js";import{t as v}from"./circle-alert-zOqdmf25.js";import{t as y}from"./circle-check-VSiny8yl.js";import{t as b}from"./copy-Cn1FKrEp.js";import{t as x}from"./cpu-BJuB2Khn.js";import{t as S}from"./credit-card-BuyWdO9t.js";import{n as C,t as w}from"./domain-field-C5a2iMot.js";import{t as T}from"./download-CAuK-nZ6.js";import{t as E}from"./external-link-Dqpx9nRm.js";import{t as D}from"./file-text-CYJz-GvF.js";import{t as O}from"./hard-drive-rDxhoRUm.js";import{t as k}from"./info-DsOyuMO9.js";import{t as A}from"./loader-circle-Cz7opInR.js";import{a as j,c as M,i as N,n as P,r as F,t as ee}from"./resize-errors-DqIkO0UI.js";import{t as te}from"./triangle-alert-Z0Gq0IuB.js";import{t as I}from"./notice-DkcNAP8O.js";import{t as ne}from"./tag-CV4v7fRF.js";import{t as re}from"./input-CoUmPnRU.js";import{t as L}from"./toggle-CDfguvUz.js";import{n as R,t as z}from"./stat-square-CTHnQ1jc.js";import{t as B}from"./modal-D5nLWNN9.js";import{n as V}from"./toast-xTp-xwYL.js";import{t as ie}from"./confirm-dialog-CSkhRFRk.js";import{t as H}from"./dropdown-ByHOpeOU.js";import{ot as ae,st as oe}from"./sdk.gen-CmKfVpgB.js";import{c as se}from"./routes-BbeIx_F9.js";import{n as ce,t as le}from"./browser-C6a_nhhZ.js";import{t as U}from"./effective-timezone-C4nukIC4.js";import{$ as ue,B as de,Dt as fe,Et as pe,G as me,H as he,J as ge,K as _e,O as ve,Q as ye,R as be,U as xe,V as W,W as Se,X as Ce,Y as we,Z as Te,at as Ee,c as De,ct as Oe,dt as ke,et as Ae,it as G,nt as je,ot as Me,q as Ne,r as K,rt as Pe,st as Fe,tt as Ie,ut as Le,wt as Re,y as ze,yt as Be,z as Ve}from"./react-query.gen-DPzPS206.js";import{Aa as He,D as Ue,Hr as We,Nn as Ge,Ur as Ke,Vr as qe,_r as Je,hi as Ye,ma as Xe,qi as Ze,vi as Qe}from"./index-yu6nDHvG.js";import{t as $e}from"./add-credits-modal-PP1PX8Qv.js";import{t as et}from"./format-date-CghpPTDc.js";import{a as tt,n as nt,t as rt}from"./llm-dimension-DyYwG3mU.js";import{r as it,t as at}from"./usage-window-C6gWu5Qu.js";import{t as ot}from"./environment-store-C0f32873.js";var st=h(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),ct=h(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),lt=h(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),ut=h(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),dt=h(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),q=e(r(),1),J=f();function ft({onBack:e}){let t=o(),{data:n}=u(K()),r=n?.name||`your assistant`;return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(lt,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(se.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,J.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`})})]})}function pt({current:e,total:t=2}){return(0,J.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function mt({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,J.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,J.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var ht=1e3,gt=1e4;function _t(e){return N[e]??N.medium}var vt=[`machine_size`,`subdomain`,`non_field_errors`],yt={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`};function bt(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=yt[t.error];if(e)return e}for(let e of vt){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}function xt({onBack:e,onExit:t}){let n=l(),r=ot.use.emailRootDomain(),{data:a}=u(K()),o=a?.id,{data:s}=u({...De({path:{assistant_id:o??``}}),enabled:!!o}),c=s?.results?.[0],[f,m]=(0,q.useState)(``),[h,_]=(0,q.useState)(`hi`),[v,y]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!v){if(c){m(c.subdomain),y(!0);return}!a?.handle||f||(m(a.handle),y(!0))}},[a?.handle,c,v,f]);let[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(!1),T=d(Ie()),E=!!c||S,D=T.isPending||S;return(0,q.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(mt,{icon:Ze}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,J.jsx)(w,{subdomain:f,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:D,error:b,locked:E,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{value:h,onChange:e=>_(e.target.value.toLowerCase().trim()),disabled:D||E,readOnly:E,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(h.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(h.length,2)+1.5}ch`}}),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!E&&(0,J.jsxs)(I,{tone:`info`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:f||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,J.jsx)(I,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,J.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:D,onClick:e,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(pt,{current:0})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:E?(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:D,onClick:()=>{D||T.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||D,onClick:()=>{D||!f||T.mutate({body:{subdomain:f,...h?{email_username:h}:{}}},{onSuccess:()=>{x(null),C(!0),n.invalidateQueries({queryKey:ze()})},onError:e=>{x(bt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function St({onGoToBilling:e}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(mt,{icon:v,tone:`negative`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function Ct({message:e,onRetry:t,onGoToBilling:n}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(mt,{icon:v,tone:`warning`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,J.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function wt({title:e,body:t}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,J.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,J.jsx)(A,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:e}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function Tt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,J.jsx)(He,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function Et({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=u(K()),c=s?.machine_size||`small`,l=s?.provisioned_storage_gib??null,f=_t(t),m=f.length>0?f[f.length-1]:c,h=m!==c,_=e!=null&&(l==null||l<e),[v,y]=(0,q.useState)(null),b=d(ve());return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(B.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(mt,{icon:x}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h&&(0,J.jsx)(Tt,{icon:x,label:`Machine`,from:F[c],fromDetail:P[c],to:F[m],toDetail:P[m]}),_&&(0,J.jsx)(Tt,{icon:O,label:`Storage`,from:l==null?`—`:`${l} GiB`,to:`${e} GiB`}),!h&&!_&&(0,J.jsx)(I,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,J.jsx)(I,{tone:`error`,children:v}):null]}),(0,J.jsxs)(B.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(pt,{current:a,total:o})}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(bt(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Dt({onContinue:e,continueDisabled:t=!1}){return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(C,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,J.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function Ot({open:e,onClose:t}){let n=l(),[r,i]=(0,q.useState)(`confirm-pro`),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(0);(0,q.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:Ee()}),n.invalidateQueries({queryKey:Pe()}))},[e,n]);let d=(0,q.useCallback)(()=>{o(!1),c(e=>e+1),n.invalidateQueries({queryKey:Ee()})},[n]),f=u({...G(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:ht,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,q.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),gt);return()=>clearTimeout(t)},[e,r,s]),(0,q.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=u({...je(),enabled:e&&r!==`confirm-pro`});u({...K(),enabled:e});let m=p.data?.domain_setup_available,h=(0,q.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,q.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsx)(B.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,J.jsx)(St,{onGoToBilling:t}):a?(0,J.jsx)(Ct,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,J.jsx)(wt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,J.jsx)(St,{onGoToBilling:t}):(0,J.jsx)(Dt,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,J.jsx)(xt,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,J.jsx)(St,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,J.jsx)(Et,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,J.jsx)(ft,{onBack:()=>i(`setup`)}):null}}var kt=`billing-portal-return-snapshot`;function At(e){try{sessionStorage.removeItem(kt),sessionStorage.setItem(kt,JSON.stringify(e))}catch{}}function jt(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(kt);if(!e)return null;let t=JSON.parse(e);return typeof t.cancel_at_period_end!=`boolean`||typeof t.plan_id!=`string`?null:{cancel_at_period_end:t.cancel_at_period_end,cancel_at:t.cancel_at??null,plan_id:t.plan_id}}catch{return null}}function Mt(){try{sessionStorage.removeItem(kt)}catch{}}function Nt(e){return e?{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at??null,plan_id:e.plan_id}:null}function Pt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function Ft(e){return e?e.cancel_at??e.current_period_end??null:null}function It(e){let t=l();return(0,q.useEffect)(()=>ce(()=>{t.invalidateQueries(G())}),[t]),pe({onSuccess:t=>{e&&At(e),le(t.portal_url)},onError:()=>{V.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Lt(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Lt(e)}/mo`}function Rt(e){return`${e>0?`+`:`−`}${Lt(Math.abs(e))}/mo`}var zt={medium:`Medium`,large:`Large`,xl:`XL`};function Bt(e){return e.disabled===!0}function Vt({machineTiers:e,storageTiers:t,selectedMachineTier:n,selectedStorageTier:r,onMachineTierChange:i,onStorageTierChange:a,currentMachinePriceCents:o,currentStoragePriceCents:s}){let c=(0,q.useMemo)(()=>e.map(e=>{let t=zt[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Rt(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:Bt(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Rt(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:Bt(e)}}),[t,s]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,J.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,J.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Ht=new Set([`active`,`trialing`,`past_due`]),Ut=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function Wt(e,t){if(e&&typeof e==`object`){for(let t of Ut)if(t in e){let n=e[t];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(`detail`in e&&typeof e.detail==`string`)return e.detail}return t}function Gt(e,t){let n=e.filter(e=>!Bt(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Kt(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function qt(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Jt({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,J.jsxs)(B.Content,{size:`md`,hideCloseButton:!0,children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{icon:te,children:`Downgrade to Base?`})}),(0,J.jsxs)(B.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,J.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Yt=`__none__`;function Xt(e){return`${e.label} — ${Y(e.price_cents)}`}function Zt({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,q.useMemo)(()=>[{value:Yt,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:Xt(e)}))],[e]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,J.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(H,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Yt,onChange:e=>n(e===Yt?null:e),options:i})]})}function Qt({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,J.jsx)(J.Fragment,{children:e.slice(0,r).join(`, `)}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(y,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function $t({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:f,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,machineTiersForPicker:y,storageTiersForPicker:b,currentMachinePrice:x,currentStoragePrice:S,currentCreditPriceUnknown:w,proCurrentTotalCents:T,proLiveTotalCents:E,proTotalDelta:D,onboardingLoading:O,tierChangePending:j,machineChanged:M,storageChanged:N,creditChanged:P,tierChangeError:F,upgradePending:ee,portalPending:te,onUpgrade:re,onApplyTierChange:L,onDowngradeClick:R,onKeepPlan:z}){let B=e.id===`pro`,V=e.id===`base`,ie=B&&n&&r&&!a,H=B&&(!t||t&&c),ae=B&&t&&c;return(0,J.jsxs)(m,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:B?(0,J.jsx)(C,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,J.jsx)(dt,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,J.jsx)(p,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,J.jsx)(ne,{tone:`positive`,children:`Current`})]}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:V?`All you need for a capable assistant`:`More features, more compute, more storage`}),ie&&o&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:V?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Free`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(H&&E!=null)&&(T==null||w)?O?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:H&&E!=null?(0,J.jsxs)(J.Fragment,{children:[Y(E),D!=null&&D!==0&&(0,J.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Rt(D),`)`]})]}):T==null?e.id===`pro`?`From ${Y(e.base_price_cents+qt(e.machine_tiers)+qt(e.storage_tiers))}`:null:`Currently ${Y(T)}`}),H&&D!=null&&D!==0&&(0,J.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(T)} to ${Y(E)}.`,children:(0,J.jsx)(k,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Lt(e.base_price_cents),` base fee`]})]})}),(0,J.jsx)(Qt,{features:e.included_features,variant:`checklist`}),B&&!l&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&B&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(Zt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:ee}),(0,J.jsx)(Vt,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:re,disabled:ee||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),ae&&(O?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(Zt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:j}),(0,J.jsx)(Vt,{machineTiers:y,storageTiers:b,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:_,onStorageTierChange:v,currentMachinePriceCents:x,currentStoragePriceCents:S}),F&&(0,J.jsx)(I,{tone:`error`,children:F}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:L,disabled:j||!M&&!N&&!P,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&V&&n&&!r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:R,disabled:te,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),ie&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:z,disabled:te,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function en({open:e,onClose:t,onTierUpgraded:n}){let r=l(),a=u(Ce()),o=u(G()),s=d(Me()),c=d(ue()),f=d(Ae()),m=d(ye()),h=It(Nt(o.data)),[_,v]=(0,q.useState)(`plans`),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(void 0);(0,q.useEffect)(()=>ce(()=>{r.invalidateQueries({queryKey:Ee()}),r.invalidateQueries({queryKey:Te()}),r.invalidateQueries({queryKey:Pe()}),t()}),[r,t]);let D=o.data?.plan_id,O=D===`pro`,k=u({...je(),enabled:O}),j=k.data?.max_machine_tier??null,M=k.data?.selected_storage_tier??null,N=k.data?.selected_storage_gib??null,P=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,F=o.data?.status===`canceled`,ee=Ft(o.data),ne=o.data?.status,re=ne!=null&&Ht.has(ne),L=O&&re&&!P&&!F,R=a.data?.plans.find(e=>e.id===`pro`),z=R?.credit_tiers??[],ie=z.length>0,H=o.data?.selected_credit_tier??null,ae=e=>z.find(t=>t.tier===e)?.price_cents??0,oe=ae(H),se=H!=null&&!z.some(e=>e.tier===H),U=T===void 0?H:T,de=ae(U),fe=R?.machine_tiers??[],pe=L&&N!=null?(R?.storage_tiers??[]).map(e=>e.storage_gib<N?{...e,disabled:!0}:e):R?.storage_tiers??[];(0,q.useEffect)(()=>{if(!e){S(null),w(null),E(void 0);return}if(R){if(L){if(j==null||M==null)return;S(e=>Gt(fe,e??j)),w(e=>Gt(pe,e??M)),E(e=>Kt(z,e,H));return}S(e=>Gt(R.machine_tiers,e)),w(e=>Gt(R.storage_tiers,e)),E(e=>Kt(z,e,null))}},[e,R,L,j,M,H]);let me=a.data?.plans.find(e=>e.id===`base`),he=new Set(me?.included_features??[]),ge=(R?.included_features??[]).filter(e=>!he.has(e)),_e=()=>{if(!s.isPending){if(!x||!C){V.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:C,credit_tier:U}},{onSuccess:e=>{if(e.checkout_url){le(e.checkout_url);return}if(e.status===`no_op`){V.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}V.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{V.error(Wt(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ve=()=>{h.isPending||(v(`plans`),h.mutate({}))},be=()=>{r.invalidateQueries({queryKey:Ee()}),r.invalidateQueries({queryKey:Pe()}),r.invalidateQueries({queryKey:Te()})},xe=c.isPending||f.isPending||m.isPending,W=x!=null&&x!==j,Se=C!=null&&C!==M,we=ie&&T!==void 0&&T!==H,De=e=>fe.find(t=>t.tier===e)?.price_cents??null,Oe=e=>pe.find(t=>t.tier===e)?.price_cents??null,ke=De(x),Ne=Oe(C),K=De(j),Fe=Oe(M),Ie=W&&ke!=null&&K!=null&&ke<K,Le=()=>{if(xe)return;let e=[];W&&x&&e.push(new Promise(e=>{c.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),Se&&C&&e.push(new Promise(e=>{f.mutate({body:{storage_tier:C}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),we&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:U}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{be();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Ie,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>Wt(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);V.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):V.success(we&&!W&&!Se?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Re=()=>{if(!xe){if(Ie){b(!0);return}Le()}},ze=()=>{b(!1),Le()},Be=e=>ke!=null&&Ne!=null?e.base_price_cents+ke+Ne+de:null,Ve=e=>K!=null&&Fe!=null?e.base_price_cents+K+Fe+oe:null,He=c.isError||f.isError||m.isError?Wt(c.error??f.error??m.error,`Failed to update plan. Please try again.`):null,Ue=a.isLoading||o.isLoading,We=a.isError||o.isError||!a.data||!o.data;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,J.jsx)(B.Content,{size:_===`plans`?`lg`:`md`,children:_===`downgrade-confirm`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{icon:te,children:`Downgrade to Base?`})}),(0,J.jsxs)(B.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:ge.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:h.isPending,leftIcon:(0,J.jsx)(g,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(i,{variant:`danger`,onClick:ve,disabled:h.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,J.jsx)(B.Body,{children:Ue?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):We?(0,J.jsx)(I,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===D,n=e.id===`pro`&&R?Be(R):null,r=e.id===`pro`&&R?Ve(R):null;return(0,J.jsx)($t,{plan:e,isCurrent:t,onPro:O,cancelAtPeriodEnd:P,isCanceled:F,cancelDate:ee,formatGraceDate:Pt,proTierChangeMode:L,creditTiersEnabled:ie,creditTiers:z,displayCreditTier:U,onCreditTierChange:E,selectedMachineTier:x,selectedStorageTier:C,onMachineTierChange:S,onStorageTierChange:w,machineTiersForPicker:fe,storageTiersForPicker:pe,currentMachinePrice:K,currentStoragePrice:Fe,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:k.isLoading,tierChangePending:xe,machineChanged:W,storageChanged:Se,creditChanged:we,tierChangeError:He,upgradePending:s.isPending,portalPending:h.isPending,onUpgrade:_e,onApplyTierChange:Re,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>h.mutate({})},e.id)})})]})}),(0,J.jsxs)(B.Footer,{className:`relative items-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,J.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,J.jsx)(Jt,{open:y,onCancel:()=>b(!1),onConfirm:ze,confirming:xe,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var tn={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function nn(e){return tn[e.toLowerCase()]??e}function rn(e,t){return`${nn(e??`card`)} •••• ${t??`????`}`}function an({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,J.jsx)(ie,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var on={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function sn(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function cn(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function ln(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function un({initialValues:e=on,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,q.useState)(e),[c,l]=(0,q.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=cn(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:sn(t[e])}))},p=e=>ln(e,u,n,c[e]);return(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(re,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(re,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(re,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,J.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:sn(o.threshold_usd),amount_usd:sn(o.amount_usd),monthly_cap_usd:sn(o.monthly_cap_usd)};s(e);let t=cn(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function dn(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function fn(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var pn={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function mn(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function hn(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${rn(t,n)}`:`Charged to ${nn(t??`card`)}`}function gn(){let e=l(),t=u(de()),n=d(Se()),r=d(be()),[a,o]=(0,q.useState)(`view`),[s,c]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,_=g.enabled===!0,v=g.disabled_due_to_repeated_failures===!0&&!_,y=()=>{n.reset(),r.reset(),o(`form`)},b=()=>{o(`view`),c(!1)},x=()=>{r.reset(),p(!1)},S=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{he(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:W()}),b()}})},C=()=>{r.mutate({},{onSuccess:()=>{he(e,void 0,e=>({...pn,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),c(!1)}})},w=e=>{if(e&&!_){if(!g.has_payment_method||v){h(!0);return}h(!1),c(!0),y();return}if(!e&&!_&&s){b();return}!e&&_&&p(!0)},T=a===`form`,E=mn(n.error),D=n.isError&&Object.keys(E).length===0,O=_||s,k=hn({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,J.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsx)(L,{checked:O,onChange:w,label:`Enable Auto-Reload`}),_&&!T&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`text-right`,children:[(0,J.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,fn(g.amount_usd),` when the balance falls under `,fn(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,J.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[fn(g.current_month_credits_purchased_usd),` of`,` `,fn(g.monthly_cap_usd),` this month`]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:y,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),v&&(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,J.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!v?`1fr`:`0fr`},children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),D&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),T&&(0,J.jsx)(un,{initialValues:_?{threshold_usd:dn(g.threshold_usd),amount_usd:dn(g.amount_usd),monthly_cap_usd:dn(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:E,onCancel:b,onSave:S}),_&&!g.has_payment_method&&(0,J.jsx)(I,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),_&&g.has_payment_method&&(0,J.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:k??`Charged to a saved card`}),(_||T)&&(0,J.jsx)(I,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,J.jsx)(an,{open:f,confirming:r.isPending,onCancel:x,onConfirm:C})]})}function _n(e){let t=parseFloat(e);return Number.isFinite(t)?`$${t.toFixed(2)}`:`$${e}`}function vn(e){if(e.trim()===``)return;let t=parseFloat(e);if(!Number.isFinite(t)||t<1||t>1e3)return`Must be between $1 and $1,000`;if(!/^\d+(\.\d{1,2})?$/.test(e.trim()))return`Use at most two decimal places`}function yn(){let e=l(),t=u(_e()),n=d(we()),[r,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(!1);if(t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`low-balance-alert-card`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load low-balance alert settings.`})});let c=t.data,f=r??c.threshold_usd??``,p=vn(f),m=e=>{a(e.target.value)},h=t=>{n.mutate({body:{threshold_usd:t}},{onSuccess:t=>{ge(e,void 0,t),e.invalidateQueries({queryKey:Ne()}),a(null),s(!1)}})},g=()=>{if(s(!0),p)return;let e=f.trim();h(e===``?null:parseFloat(e).toFixed(2))},_=()=>{a(``),s(!1),h(null)},v=n.isError,y=o?p:void 0;return(0,J.jsxs)(`div`,{"data-testid":`low-balance-alert-card`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[12rem] flex-1`,children:(0,J.jsx)(re,{type:`number`,step:`0.01`,label:`Alert me when my balance drops below`,helperText:`Default is ${_n(c.default_threshold_usd)} when unset`,placeholder:c.effective_threshold_usd,value:f,onChange:m,onBlur:()=>s(!0),errorText:y,"data-testid":`low-balance-alert-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[c.threshold_usd!=null&&(0,J.jsx)(i,{variant:`outlined`,onClick:_,disabled:n.isPending,"data-testid":`low-balance-alert-reset-button`,children:`Reset to default`}),(0,J.jsx)(i,{variant:`primary`,onClick:g,disabled:n.isPending,"data-testid":`low-balance-alert-save-button`,children:`Save`})]})]}),v&&(0,J.jsx)(I,{tone:`error`,className:`mt-4`,"data-testid":`low-balance-alert-update-error`,children:`Failed to save low-balance alert. Please try again.`})]})}var bn=2e3;function xn(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function Sn(){let e=l(),{data:t,isLoading:n,isError:r}=u(Fe()),a=t??null,[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(0),d=(0,q.useRef)(null),f=fe({onSuccess:()=>{e.invalidateQueries({queryKey:Oe()})},onError:()=>{c.current<3&&(d.current=setTimeout(()=>{f.reset()},bn))}});(0,q.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=f.mutate;(0,q.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&c.current<3&&!f.isPending&&!f.isError&&!f.isSuccess&&(c.current+=1,h({}))},[a,f.isPending,f.isError,f.isSuccess,h]);let g=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(m,{padding:`md`,children:[g,n?(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(z,{icon:(0,J.jsx)(Xe,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`effective-balance`,children:xn(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,J.jsx)(z,{icon:(0,J.jsx)(st,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`settled-balance`,children:xn(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,J.jsx)(z,{icon:(0,J.jsx)(ct,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`pending-charges`,children:xn(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,J.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(gn,{})}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(yn,{})})]}),(0,J.jsx)($e,{open:o,onOpenChange:s})]})}var Cn=1e3,wn=15e3,Tn=3e3,En=45e3,Dn=`billing-portal-return`;function On(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?Pt(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function kn(){let[e]=s(),t=o(),n=l(),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,q.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=jt(),o=G(),s=Ee(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<wn&&(await new Promise(e=>setTimeout(e,Cn)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=On(a,e);t===`success`?V.success(n,{id:Dn}):V.info(n,{id:Dn})}catch{if(i.current)return;V.info(`Subscription updated.`,{id:Dn})}finally{if(!i.current){Mt(),t(se.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=En){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},Tn)}}})(),()=>{i.current=!0}},[e,t,n]),null}var An=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function jn(e,t=U()){let{fromDate:n,toDate:r}=at(e,t);return{from:n,to:r}}function Mn(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function Nn({from:e,to:t}){let n=Mn(e,t);return n===7?7:n===90?90:30}function Pn({value:e,onChange:t}){let n=Ge(),r=(0,q.useMemo)(()=>`${Nn(e)}`,[e]);return(0,J.jsx)(H,{options:An,value:r,onChange:e=>{let r=Number(e);t(jn(r,n),r)},"aria-label":`Date range`})}var Fn={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},In={fontSize:12,fill:`var(--content-tertiary)`},Ln={stroke:`var(--border-subtle)`,strokeOpacity:.4},Rn=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function zn({item:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Bn({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,J.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??it)(String(r))}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(zn,{item:u}),d.length>0&&(0,J.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,J.jsx)(zn,{item:e},e.key)),s&&(0,J.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,J.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Vn(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Hn(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function Un(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Wn(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Hn(n/r)*r}function Gn(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function Kn(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function qn(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Jn=40,Yn={fontSize:11,fill:`var(--content-tertiary)`},Xn={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function Zn(e,t){return Xn[e]??Rn[t%Rn.length]??`#6b7280`}function Qn(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function $n({stackKeys:e,labelMap:t}){return(0,J.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:Zn(e,n)}}),(0,J.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var er=350,tr={top:8,right:4,bottom:32,left:0},nr=.2,rr=5,ir=12,ar=200;function or({buckets:e,metric:t,onBarClick:n}){let r=Je(),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,q.useMemo)(()=>Qn(e,t),[e,t]),u=(0,q.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=Zn(c[t],t);return e},[c]),d=(0,q.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,q.useState)(null),m=r?Jn:56,h=r?Yn:In,g=tr.left+m,_=Math.max(0,a-g-tr.right),v=tr.top,y=er-tr.top-tr.bottom,b=(0,q.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,q.useMemo)(()=>Wn(b,{integerOnly:x,tickCount:rr}),[b,x]),C=(0,q.useMemo)(()=>Gn(S,rr),[S]),w=(0,q.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/rr,n=Math.max(t<1?2:0,Un(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,q.useMemo)(()=>Vn([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-nr),k=(D-O)/2,A=(0,q.useMemo)(()=>qn(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:Zn(t,i),isLast:u}})}}),N=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},P=()=>p(null),F=e=>{n&&n(e)},ee=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],te={left:f?Math.max(0,Math.min(f.x+ir,a-ar)):0,top:f?f.y-ir:0,visibility:f?`visible`:`hidden`};return(0,J.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:er},children:j?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{width:a,height:er,className:`block`,children:[C.map(e=>(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:Fn.stroke,strokeOpacity:Fn.strokeOpacity,strokeDasharray:Fn.strokeDasharray},e)),(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:Ln.stroke,strokeOpacity:Ln.strokeOpacity}),C.map(e=>(0,J.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,J.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:it(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>N(n,e,t.key),onMouseLeave:P,onClick:()=>F(t.key)};return t.isLast?(0,J.jsx)(`path`,{...i,d:Kn(t.x,t.y,O,t.h,3)}):(0,J.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:te,children:(0,J.jsx)(Bn,{active:!!f,payload:ee,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,J.jsx)($n,{stackKeys:c,labelMap:l})]})}function sr(e=U()){return jn(30,e)}function cr(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:tt(e.llmDimension??`model`)}function lr(e,t=U()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:cr(e.drilldown)}:{}}}function ur(e,t=U()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function dr(e){let t=Ge(),n=u(Le({query:lr(e,t)})),r=u(ke({query:ur(e,t)}));return{series:n.data,totals:r.data,isLoading:n.isLoading||r.isLoading,isError:n.isError||r.isError}}var fr=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function pr(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function mr(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function hr(){let e=Ge(),[t,n]=(0,q.useState)(30),[r,i]=(0,q.useState)(()=>sr(e)),a=(0,q.useMemo)(()=>t===null?r:jn(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`spend`),{series:d,totals:f,isLoading:h,isError:_}=dr({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),v=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:rt}:{}})};return(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,J.jsx)(Pn,{value:a,onChange:o}),(0,J.jsx)(`div`,{className:`w-44`,children:(0,J.jsx)(R,{items:fr,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(z,{icon:(0,J.jsx)(Xe,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):pr(f?.total_usd),label:`Spend`}),(0,J.jsx)(z,{icon:(0,J.jsx)(ut,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):mr(f?.event_count),label:`Events`})]}),s&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,J.jsx)(g,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Back to all usage`}),(0,J.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,J.jsx)(`div`,{className:`w-56`,children:(0,J.jsx)(R,{items:nt,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),h?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,J.jsx)(A,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):_?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,J.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,J.jsx)(or,{buckets:d.buckets,metric:l,onBarClick:v})}):null]})})}function gr(){let{data:e}=u(G()),t=It((0,q.useMemo)(()=>Nt(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=Ft(e);return n?(0,J.jsx)(I,{tone:`info`,title:`Your Pro plan will end on ${Pt(n)}.`,actions:(0,J.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,J.jsx)(A,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var _r=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),vr=t(((e,t)=>{var n=_r();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=vr()()}))(),1);function yr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function br(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yr(Object(n),!0).forEach(function(t){Sr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xr(e){"@babel/helpers - typeof";return xr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xr(e)}function Sr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cr(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function wr(e,t){if(e==null)return{};var n=Cr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Tr(e,t){return Er(e)||Dr(e,t)||Or(e,t)||Ar()}function Er(e){if(Array.isArray(e))return e}function Dr(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Or(e,t){if(e){if(typeof e==`string`)return kr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kr(e,t)}}function kr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ar(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Z=function(e,t,n){var r=!!n,i=q.useRef(n);q.useEffect(function(){i.current=n},[n]),q.useEffect(function(){if(!r||!e)return function(){};var n=function(){i.current&&i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},jr=function(e){var t=q.useRef(e);return q.useEffect(function(){t.current=e},[e]),t.current},Mr=function(e){return e!==null&&xr(e)===`object`},Nr=function(e){return Mr(e)&&typeof e.then==`function`},Pr=function(e){return Mr(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Fr=`[object Object]`,Ir=function e(t,n){if(!Mr(t)||!Mr(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Fr;if(i!==(Object.prototype.toString.call(n)===Fr))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Lr=function(e,t,n){return Mr(e)?Object.keys(e).reduce(function(r,i){var a=!Mr(t)||!Ir(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?br(br({},r||{}),{},Sr({},i,e[i])):r},null):null},Rr="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",zr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rr;if(e===null||Pr(e))return e;throw Error(t)},Br=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rr;if(Nr(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return zr(e,t)})};var n=zr(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Vr=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Hr=q.createContext(null);Hr.displayName=`ElementsContext`;var Ur=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e},Wr=function(e){var t=e.stripe,n=e.options,r=e.children,i=q.useMemo(function(){return Br(t)},[t]),a=Tr(q.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];q.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=jr(t);q.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=jr(n);return q.useEffect(function(){if(o.elements){var e=Lr(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),q.useEffect(function(){Vr(o.stripe)},[o.stripe]),q.createElement(Hr.Provider,{value:o},r)};Wr.propTypes={stripe:X.default.any,options:X.default.object};var Gr=function(e){return Ur(q.useContext(Hr),e)},Kr=function(e){var t=e.children;return t(Gr(`mounts <ElementsConsumer>`))};Kr.propTypes={children:X.default.func.isRequired};var qr=q.createContext(null);qr.displayName=`CheckoutContext`;var Jr=function(e){var t=q.useContext(qr),n=q.useContext(Hr);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}else return Ur(n,e)},Yr=[`mode`],Xr=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,t,n){var r=`${Xr(e)}Element`,i=t?function(e){Jr(`mounts <${r}>`);var t=e.id,n=e.className;return q.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=Jr(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=Tr(q.useState(null),2),O=D[0],k=D[1],A=q.useRef(null),j=q.useRef(null);Z(O,`blur`,s),Z(O,`focus`,c),Z(O,`escape`,d),Z(O,`click`,f),Z(O,`loaderror`,p),Z(O,`loaderstart`,m),Z(O,`networkschange`,h),Z(O,`confirm`,g),Z(O,`cancel`,_),Z(O,`shippingaddresschange`,v),Z(O,`shippingratechange`,y),Z(O,`savedpaymentmethodremove`,b),Z(O,`savedpaymentmethodupdate`,x),Z(O,`availablepaymentmethodschange`,S),Z(O,`change`,u);var M;l&&(M=e===`expressCheckout`?l:function(){l(O)}),Z(O,`ready`,M),q.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=wr(o,Yr);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var N=jr(o);return q.useEffect(function(){if(A.current){var e=Lr(o,N,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,N]),q.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),q.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:X.default.string,className:X.default.string,onChange:X.default.func,onBlur:X.default.func,onFocus:X.default.func,onReady:X.default.func,onEscape:X.default.func,onClick:X.default.func,onLoadError:X.default.func,onLoaderStart:X.default.func,onNetworksChange:X.default.func,onConfirm:X.default.func,onCancel:X.default.func,onShippingAddressChange:X.default.func,onShippingRateChange:X.default.func,onSavedPaymentMethodRemove:X.default.func,onSavedPaymentMethodUpdate:X.default.func,onAvailablePaymentMethodsChange:X.default.func,options:X.default.object},i.displayName=r,i.__elementType=e,i},$=typeof window>`u`,Zr=q.createContext(null);Zr.displayName=`EmbeddedCheckoutProviderContext`,Q(`auBankAccount`,$),Q(`card`,$),Q(`cardNumber`,$),Q(`cardExpiry`,$),Q(`cardCvc`,$),Q(`iban`,$),Q(`payment`,$),Q(`expressCheckout`,$),Q(`paymentRequestButton`,$),Q(`linkAuthentication`,$),Q(`contactDetails`,$),Q(`address`,$),Q(`shippingAddress`,$),Q(`paymentMethodMessaging`,$),Q(`taxId`,$),Q(`issuingCardNumberDisplay`,$),Q(`issuingCardCvcDisplay`,$),Q(`issuingCardExpiryDisplay`,$),Q(`issuingCardPinDisplay`,$),Q(`issuingCardCopyButton`,$);var Qr=`dahlia`,$r=`https://js.stripe.com`,ei=`${$r}/${Qr}/stripe.js`,ti=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,ni=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,ri=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,ii=function(e){return ti.test(e)||ni.test(e)},ai=function(){for(var e=document.querySelectorAll(`script[src^="${$r}"]`),t=0;t<e.length;t++){var n=e[t];if(ii(n.src))return n}return null},oi=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${ei}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},si=null,ci=null,li=null,ui=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},di=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},fi=function(e){return si===null?(si=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(ri),window.Stripe){t(window.Stripe);return}try{var r=ai();if(r&&e)console.warn(ri);else if(!r)r=oi(e);else if(r&&li!==null&&ci!==null){var i;r.removeEventListener(`load`,li),r.removeEventListener(`error`,ci),(i=r.parentNode)==null||i.removeChild(r),r=oi(e)}li=di(t,n),ci=ui(n),r.addEventListener(`load`,li),r.addEventListener(`error`,ci)}catch(e){n(e);return}}),si.catch(function(e){return si=null,Promise.reject(e)})):si},pi,mi=!1,hi=function(){return pi||(pi=fi(null).catch(function(e){return pi=null,Promise.reject(e)}),pi)};Promise.resolve().then(function(){return hi()}).catch(function(e){mi||console.warn(e)});function gi(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{theme:`night`}:{theme:`stripe`}}function _i({open:e,onClose:t,onSavedOptimistic:n}){let r=d(xe()),{mutate:i,reset:a}=r;return(0,q.useEffect)(()=>{e||a()},[e,i,a]),(0,q.useMemo)(()=>gi(),[r.data?.client_secret??null]),(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(B.Content,{size:`sm`,children:[(0,J.jsx)(B.Header,{children:(0,J.jsx)(B.Title,{children:`Save Payment Method`})}),(0,J.jsx)(B.Body,{className:`min-h-[260px]`,children:(0,J.jsx)(vi,{})})]})})}function vi(){return(0,q.useEffect)(()=>{console.warn(`[AutoTopUpPaymentMethodModal] VITE_STRIPE_PUBLISHABLE_KEY is not set; the payment-method modal cannot mount Stripe Elements.`)},[]),(0,J.jsx)(I,{tone:`error`,children:`Payment method setup is currently unavailable. Please try again later.`})}function yi(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Payment Method`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`This is the payment method that will be used for automated credit reloads.`})]})}function bi(){let e=l(),t=u(de()),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=d(Ve()),c=async()=>{let t=Date.now(),n=e=>e?.stripe_payment_method_updated_at??null,r=n(e.getQueryData(W()));try{await e.invalidateQueries({queryKey:W()})}catch{}for(;Date.now()-t<2e4;){try{let t=await e.fetchQuery(de());if(t.has_payment_method&&n(t)!==r)return}catch{}await new Promise(e=>setTimeout(e,1500))}};if(t.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(yi,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading…`]})]});if(t.isError||!t.data)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(yi,{}),(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(I,{tone:`error`,children:`Failed to load payment method.`})})]});let f=t.data,h=nn(f.payment_method_brand??`card`),g=f.payment_method_last4;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(yi,{}),f.has_payment_method?(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,children:h}),g?(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[`Ending in `,g]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>r(!0),children:`Change`}),(0,J.jsx)(i,{variant:`ghost`,onClick:()=>o(!0),disabled:a||s.isPending,leftIcon:(0,J.jsx)(Qe,{className:`h-3.5 w-3.5`}),children:`Remove`})]})]}):(0,J.jsx)(i,{className:`self-start`,onClick:()=>r(!0),children:`Add Card`})]})}),(0,J.jsx)(ie,{open:a,title:`Remove payment method?`,message:`Removing your payment method will disable automatic top-ups. You can re-enable them after adding a new payment method.`,confirmLabel:s.isPending?`Removing…`:`Remove`,cancelLabel:`Keep`,destructive:!0,onConfirm:()=>{s.isPending||s.mutate({},{onSuccess:()=>{he(e,void 0,e=>e?{...e,enabled:!1,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null}:pn),o(!1)},onError:()=>{V.error(`Failed to remove payment method. Please try again.`),o(!1)}})},onCancel:()=>{s.isPending||o(!1)}}),(0,J.jsx)(_i,{open:n,onClose:()=>r(!1),onSavedOptimistic:c})]})}var xi={invoices:[]};function Si(e){switch(e){case`paid`:return`positive`;case`open`:return`warning`;case`uncollectible`:return`negative`;default:return`neutral`}}function Ci(e,t){let n=t.toUpperCase();try{let t=new Intl.NumberFormat(void 0,{style:`currency`,currency:n}),r=t.resolvedOptions().maximumFractionDigits??2;return t.format(e/10**r)}catch{return`${(e/100).toFixed(2)} ${n}`}}function wi(e){return et(new Date(e*1e3),{alwaysShowYear:!0})}function Ti(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function Ei({open:e,onOpenChange:t}){let[r,o]=(0,q.useState)(!1),s=u({queryKey:me(),enabled:e,queryFn:async({signal:e})=>{let{data:t,response:n}=await oe({throwOnError:!1,signal:e});if(n?.status===404)return xi;if(!n?.ok||!t)throw Error(`Failed to load invoices (${n?.status??`network error`})`);return t}}),c=s.data?.invoices??[],l=c.some(e=>e.invoice_pdf!=null);async function d(){o(!0);try{let{data:e,response:t}=await ae({throwOnError:!1,parseAs:`blob`});if(!t?.ok||!(e instanceof Blob))throw Error(`Failed to download invoices (${t?.status??`network error`})`);let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-DI99Emal.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await n(e,`invoices.zip`)}catch(e){n(e,{context:`download_all_invoices`}),V.error(`Failed to download invoices.`)}finally{o(!1)}}return(0,J.jsx)(B.Root,{open:e,onOpenChange:t,children:(0,J.jsxs)(B.Content,{size:`lg`,children:[(0,J.jsxs)(B.Header,{children:[(0,J.jsx)(B.Title,{icon:D,children:`Invoices`}),(0,J.jsx)(B.Description,{children:`Your billing history. Open an invoice for full details or download it as a PDF.`})]}),(0,J.jsx)(B.Body,{children:s.isLoading?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading invoices...`})]}):s.isError?(0,J.jsx)(I,{tone:`error`,children:`Failed to load invoices.`}):c.length===0?(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`py-6 text-center text-[var(--content-tertiary)]`,"data-testid":`invoices-empty`,children:`No Invoices Found`}):(0,J.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,"data-testid":`invoice-row`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,className:`text-[var(--content-default)]`,children:e.number??`Invoice`}),e.status&&(0,J.jsx)(ne,{tone:Si(e.status),children:e.status})]}),(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[wi(e.created),` ·`,` `,Ci(e.amount_due,e.currency)]})]}),e.hosted_invoice_url&&(0,J.jsx)(i,{asChild:!0,variant:`ghost`,size:`compact`,leftIcon:(0,J.jsx)(E,{}),children:(0,J.jsx)(`a`,{href:e.hosted_invoice_url,target:`_blank`,rel:`noopener noreferrer`,children:`View`})}),e.invoice_pdf&&(0,J.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,J.jsx)(T,{}),"aria-label":`Download invoice PDF`,onClick:()=>Ti(e.invoice_pdf)})]},e.id))})}),(0,J.jsxs)(B.Footer,{children:[l&&(0,J.jsx)(i,{variant:`outlined`,leftIcon:r?(0,J.jsx)(A,{className:`animate-spin`}):(0,J.jsx)(T,{}),disabled:r,onClick:d,children:`Download all`}),(0,J.jsx)(B.Close,{asChild:!0,children:(0,J.jsx)(i,{variant:`primary`,children:`Done`})})]})]})})}var Di={pro:{icon:C,actionLabel:`Manage`,actionVariant:`outlined`,actionTestId:`plan-card-manage-button`,showsRenewal:!0},base:{icon:dt,actionLabel:`Upgrade to Pro`,actionVariant:`primary`,actionTestId:`plan-card-upgrade-button`,showsRenewal:!1}},Oi=Di.base;function ki(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Plan`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Manage which Vellum plan you're on.`})]})}function Ai({onManage:e}){let[t,n]=(0,q.useState)(!1),r=u(G()),a=u(Ce());if(r.isLoading||a.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(ki,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading plan...`})]})]});let o=r.data,s=a.data?.plans,c=s?.find(e=>e.id===o?.plan_id);if(r.isError||a.isError||!o||!s||!c)return(0,J.jsx)(I,{tone:`error`,children:`Failed to load plan.`});let l=Di[c.id]??Oi,d=l.icon,f=c.name??c.id,h=l.showsRenewal&&(o.cancel_at_period_end===!0||!!o.cancel_at),g=o.status===`canceled`,_=Ft(o),v=l.showsRenewal&&!h&&!g&&o.current_period_end,y=l.showsRenewal&&h&&!g&&_,b=c.id===`pro`?c:void 0,x=o.selected_credit_tier??null,S=x==null?void 0:b?.credit_tiers,C=S?.find(e=>e.tier===x),w=C?`${C.label} (${Y(C.price_cents)})`:S?.length?x:null;return(0,J.jsxs)(m,{padding:`lg`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(i,{variant:`outlined`,leftIcon:(0,J.jsx)(D,{}),onClick:()=>n(!0),"data-testid":`plan-card-invoices-button`,children:`Invoices`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:(0,J.jsx)(d,{className:`h-4 w-4 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`div`,"data-testid":`plan-card-name`,children:f}),(0,J.jsx)(p,{variant:`body-small-default`,as:`div`,className:`leading-snug text-[var(--content-tertiary)]`,children:(0,J.jsx)(Qt,{features:c.included_features,variant:`inline`})})]}),(0,J.jsx)(i,{variant:l.actionVariant,onClick:e,"data-testid":l.actionTestId,children:l.actionLabel})]}),w&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-credit-bundle`,children:[`Monthly credits: `,w]}),v&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-renews`,children:[`Renews on `,Pt(o.current_period_end),`.`]}),y&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`plan-card-cancels`,children:[`Your plan ends on `,Pt(_),`.`]})]}),(0,J.jsx)(Ei,{open:t,onOpenChange:n})]})}var ji=`settings-referral-panel`;function Mi(e){return e.replace(/\.00$/,``)}function Ni(){let{data:e,isLoading:t,isError:n}=u(Be()),[r,a]=(0,q.useState)(!1),o=(0,q.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{a(!0),V.success(`Copied to clipboard!`),setTimeout(()=>a(!1),2e3)})},[]),s=e?.is_eligible_for_credits===!1,c=s?`Invite friends to Vellum. You'll start earning referral credits once you've purchased credits or upgraded to Pro.`:e?`Share Vellum with friends - you'll each earn ${Mi(e.referrer_credit_amount)} credits when they sign up, up to ${Mi(e.earning_cap)} total.`:`Share Vellum with friends and earn credits for every signup.`;return(0,J.jsx)(m,{padding:`md`,id:ji,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Earn Free Credits`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:c})]}),s&&(0,J.jsx)(I,{tone:`info`,children:`You're not currently earning referral credits. Buy credits or upgrade to Pro to start earning — your invite link still works in the meantime.`}),t?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading...`]}):n||!e?(0,J.jsx)(I,{tone:`error`,children:`Failed to load referral information.`}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Xe,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:Mi(e.total_earned)}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Credits Earned`})]})]}),(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Ye,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:e.referred_count}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Friends Referred`})]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:()=>o(e.referral_url),leftIcon:r?(0,J.jsx)(_,{className:`h-3.5 w-3.5`}):(0,J.jsx)(b,{className:`h-3.5 w-3.5`}),"data-testid":`referral-copy-button`,children:r?`Copied!`:`Copy Share Link`})]})]})})}function Pi({icon:e,label:t,from:n,to:r}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),(0,J.jsx)(He,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:r})]})]})]})}function Fi({open:e,onClose:t}){let n=u({...K(),enabled:e}),r=u({...je(),enabled:e}),a=n.data,o=a?.machine_size||`small`,s=a?.provisioned_storage_gib??null,c=r.data?.max_machine_tier??null,l=r.data?.selected_storage_gib??null,d=j(c),f=d.length>0?d[d.length-1]:o,p=f!==o,m=l!=null&&(s==null||s<l),h=p||m,[g,_]=(0,q.useState)(null),v=Re({onSuccess:()=>{V.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),_(null),t()},onError:e=>{_(ee(e,`Failed to resize assistant. Please try again.`))}}),y=v.isPending,b=n.isLoading||r.isLoading;return(0,J.jsx)(B.Root,{open:e,onOpenChange:e=>{e||(_(null),t())},children:(0,J.jsxs)(B.Content,{size:`sm`,children:[(0,J.jsxs)(B.Header,{children:[(0,J.jsx)(B.Title,{icon:M,children:`Plan Updated`}),(0,J.jsx)(B.Description,{children:`Your new resources are ready. Apply them now to resize your assistant — it will briefly restart.`})]}),(0,J.jsxs)(B.Body,{children:[b?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,J.jsx)(A,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):h?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Pi,{icon:x,label:`Machine`,from:F[o],to:F[f]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`CPU`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:P[f].split(`,`)[0].trim()})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`Memory`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:P[f].split(`,`)[1].trim()})]})]})]}),m&&(0,J.jsx)(Pi,{icon:O,label:`Storage`,from:s==null?`—`:`${s} GiB`,to:`${l} GiB`})]}):(0,J.jsx)(I,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`}),g&&(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(I,{tone:`error`,children:g})})]}),(0,J.jsxs)(B.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>{_(null),t()},children:`Do Later`}),(0,J.jsx)(i,{disabled:b||!h||y||!a?.id,leftIcon:y?(0,J.jsx)(A,{className:`animate-spin`}):void 0,onClick:()=>{if(!a?.id)return;_(null);let e={};p&&(e.machine_size=f),m&&l!=null&&(e.storage_gib=l),v.mutate({path:{id:a.id},body:e})},children:g?`Retry`:`Apply & Restart`})]})]})})}function Ii(){let[e]=s(),t=o(),n=l();return(0,q.useEffect)(()=>{let r=e.get(`billing_status`);r&&(r===`success`?(V.success(`Payment received! Your credit balance will update shortly.`,{id:`billing-status`}),n.invalidateQueries({queryKey:Fe().queryKey})):r===`cancel`&&V.info(`Checkout was cancelled. No credits were added.`,{id:`billing-status`}),t(se.settings.billing,{replace:!0}))},[e,t,n]),null}function Li(){let e=Ke({platformHostedOnly:!0}),t=Ke(),n=qe(),r=We(),[i,a]=s(),[o,l]=(0,q.useState)(!1),u=(0,q.useCallback)(()=>l(!0),[]),d=(0,q.useCallback)(()=>l(!1),[]),[f,p]=(0,q.useState)(!1),m=(0,q.useCallback)(()=>p(!0),[]);(0,q.useEffect)(()=>{i.has(`adjust_plan`)&&(l(!0),a(e=>{let t=new URLSearchParams(e);return t.delete(`adjust_plan`),t},{replace:!0}))},[i,a]);let h=i.has(`session_id`),g=(0,q.useCallback)(()=>{a(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})},[a]);if(t===`gated`)return(0,J.jsx)(c,{replace:!0,to:se.settings.general});if(t===`disabled`)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(Ue,{children:`Log in to the Vellum platform to manage billing and usage.`})});if(r)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,J.jsx)(A,{className:`h-4 w-4 animate-spin`}),`Loading billing…`]})});let _=n;return!n&&e!==`gated`?(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(I,{tone:`warning`,children:`Billing isn't available for the current assistant state.`})}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(q.Suspense,{fallback:null,children:[(0,J.jsx)(Ii,{}),(0,J.jsx)(kn,{})]}),_&&(0,J.jsx)(gr,{}),_&&(0,J.jsx)(Ai,{onManage:u}),_&&(0,J.jsx)(en,{open:o,onClose:d,onTierUpgraded:m}),(0,J.jsx)(bi,{}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Sn,{})}),(0,J.jsx)(Ni,{}),(0,J.jsx)(hr,{}),_&&(0,J.jsx)(Ot,{open:h,onClose:g}),_&&(0,J.jsx)(Fi,{open:f,onClose:()=>p(!1)})]})}export{Li as BillingPage};
@@ -1 +1 @@
1
- import{t as e}from"./button-amTXFI-2.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-Bv5O5juh.js";import{t as i}from"./bookmark-CNrithFf.js";import{t as a}from"./loader-circle-Cz7opInR.js";import{t as o}from"./triangle-alert-Z0Gq0IuB.js";import{t as s}from"./x-CkSVp1Ok.js";import{c}from"./routes-BbeIx_F9.js";import{Ni as l,R as u,z as d}from"./index-CSefSVJO.js";var f=n();function p(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function m(){return(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,f.jsx)(i,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Hover any message and click the bookmark icon to save it here.`})]})})}function h({bookmark:t,isFirst:n,onOpen:r,onRemove:i}){let a=t.conversationTitle&&t.conversationTitle.trim().length>0?t.conversationTitle:`Untitled conversation`,o=t.messageRole!==`user`,c=p(t.createdAt);return(0,f.jsxs)(`div`,{className:`flex items-start gap-3 py-3 ${n?``:`border-t border-[var(--border-base)]`}`,children:[(0,f.jsx)(`span`,{"aria-hidden":!0,className:`mt-1 h-8 w-1 shrink-0 rounded-full`,style:{backgroundColor:o?`var(--content-default)`:`var(--content-tertiary)`}}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,f.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),c?(0,f.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:c}):null]}),t.messagePreview?(0,f.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-small-default text-[var(--content-tertiary)]`,children:t.messagePreview}):null]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,f.jsx)(e,{variant:`outlined`,onClick:r,children:`Open`}),(0,f.jsx)(`button`,{type:`button`,onClick:i,title:`Remove bookmark`,"aria-label":`Remove bookmark`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-active)] hover:text-[var(--content-default)]`,children:(0,f.jsx)(s,{className:`h-4 w-4`})})]})]})}function g(){let n=t(),{bookmarks:i,isLoading:s,isError:p,refetch:g}=d(),_=u();return s?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,f.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):p?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,f.jsx)(o,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,f.jsxs)(e,{variant:`outlined`,onClick:g,className:`mt-4`,children:[(0,f.jsx)(l,{className:`h-4 w-4`}),`Retry`]})]})})}):i.length===0?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(m,{})}):(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{noPadding:!0,className:`px-4`,children:i.map((e,t)=>(0,f.jsx)(h,{bookmark:e,isFirst:t===0,onOpen:()=>{n(c.conversationAtMessage(e.conversationId,e.messageId))},onRemove:()=>{_(e.messageId,e.conversationId,!0)}},e.id))})})}export{g as BookmarksPage};
1
+ import{t as e}from"./button-amTXFI-2.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-Bv5O5juh.js";import{t as i}from"./bookmark-CNrithFf.js";import{t as a}from"./loader-circle-Cz7opInR.js";import{t as o}from"./triangle-alert-Z0Gq0IuB.js";import{t as s}from"./x-CkSVp1Ok.js";import{c}from"./routes-BbeIx_F9.js";import{Mi as l,R as u,z as d}from"./index-yu6nDHvG.js";var f=n();function p(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function m(){return(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,f.jsx)(i,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Hover any message and click the bookmark icon to save it here.`})]})})}function h({bookmark:t,isFirst:n,onOpen:r,onRemove:i}){let a=t.conversationTitle&&t.conversationTitle.trim().length>0?t.conversationTitle:`Untitled conversation`,o=t.messageRole!==`user`,c=p(t.createdAt);return(0,f.jsxs)(`div`,{className:`flex items-start gap-3 py-3 ${n?``:`border-t border-[var(--border-base)]`}`,children:[(0,f.jsx)(`span`,{"aria-hidden":!0,className:`mt-1 h-8 w-1 shrink-0 rounded-full`,style:{backgroundColor:o?`var(--content-default)`:`var(--content-tertiary)`}}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,f.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),c?(0,f.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:c}):null]}),t.messagePreview?(0,f.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-small-default text-[var(--content-tertiary)]`,children:t.messagePreview}):null]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,f.jsx)(e,{variant:`outlined`,onClick:r,children:`Open`}),(0,f.jsx)(`button`,{type:`button`,onClick:i,title:`Remove bookmark`,"aria-label":`Remove bookmark`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-active)] hover:text-[var(--content-default)]`,children:(0,f.jsx)(s,{className:`h-4 w-4`})})]})]})}function g(){let n=t(),{bookmarks:i,isLoading:s,isError:p,refetch:g}=d(),_=u();return s?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,f.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):p?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,f.jsx)(o,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,f.jsxs)(e,{variant:`outlined`,onClick:g,className:`mt-4`,children:[(0,f.jsx)(l,{className:`h-4 w-4`}),`Retry`]})]})})}):i.length===0?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(m,{})}):(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{noPadding:!0,className:`px-4`,children:i.map((e,t)=>(0,f.jsx)(h,{bookmark:e,isFirst:t===0,onOpen:()=>{n(c.conversationAtMessage(e.conversationId,e.messageId))},onRemove:()=>{_(e.messageId,e.conversationId,!0)}},e.id))})})}export{g as BookmarksPage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-Ddmch1KU.js","assets/preload-helper-BewR0kVT.js","assets/dist-DS5iJwBJ2.js"])))=>i.map(i=>d[i]);
2
- import{u as e}from"./native-biometric-Czaf9IqI.js";import{t}from"./capture-error-Dhiismgm.js";import{t as n}from"./preload-helper-BewR0kVT.js";import{t as r}from"./is-electron-y5bNUVyG.js";import{t as i}from"./dist-DS5iJwBJ2.js";function a(n,r){if(!e())return()=>void 0;let i=null,a=!1;return r().then(e=>{if(a){e.remove();return}i=e}).catch(e=>{t(e,{context:n,level:`warning`})}),()=>{a=!0,i?.remove()}}var o=async e=>{if(r()){window.open(e,`_blank`);return}if(i.isNativePlatform())try{let{Browser:t}=await n(async()=>{let{Browser:e}=await import(`./esm-Ddmch1KU.js`);return{Browser:e}},__vite__mapDeps([0,1,2]));await t.open({url:e,presentationStyle:`popover`})}catch{window.location.href=e}else window.location.href=e},s=e=>a(`capacitor_browser_finished`,async()=>{let{Browser:t}=await n(async()=>{let{Browser:e}=await import(`./esm-Ddmch1KU.js`);return{Browser:e}},__vite__mapDeps([0,1,2]));return t.addListener(`browserFinished`,e)});export{s as n,a as r,o as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-Bzs_witt.js","assets/preload-helper-BewR0kVT.js","assets/dist-DS5iJwBJ2.js"])))=>i.map(i=>d[i]);
2
+ import{u as e}from"./native-biometric-Czaf9IqI.js";import{t}from"./capture-error-Dhiismgm.js";import{t as n}from"./preload-helper-BewR0kVT.js";import{t as r}from"./is-electron-y5bNUVyG.js";import{t as i}from"./dist-DS5iJwBJ2.js";function a(n,r){if(!e())return()=>void 0;let i=null,a=!1;return r().then(e=>{if(a){e.remove();return}i=e}).catch(e=>{t(e,{context:n,level:`warning`})}),()=>{a=!0,i?.remove()}}var o=async e=>{if(r()){window.open(e,`_blank`);return}if(i.isNativePlatform())try{let{Browser:t}=await n(async()=>{let{Browser:e}=await import(`./esm-Bzs_witt.js`);return{Browser:e}},__vite__mapDeps([0,1,2]));await t.open({url:e,presentationStyle:`popover`})}catch{window.location.href=e}else window.location.href=e},s=e=>a(`capacitor_browser_finished`,async()=>{let{Browser:t}=await n(async()=>{let{Browser:e}=await import(`./esm-Bzs_witt.js`);return{Browser:e}},__vite__mapDeps([0,1,2]));return t.addListener(`browserFinished`,e)});export{s as n,a as r,o as t};
@@ -1 +1 @@
1
- import{ct as e,g as t,h as n,p as r}from"./local-mode-grqHUoNh.js";import{n as i}from"./resolved-assistants-store-BSZbT8Ju.js";import{M as a,P as o,n as s}from"./auth-store-CD7PGb3q.js";import{c}from"./remote-gateway-session-CbBWrPZH.js";import{t as l}from"./return-to-BwxkOGDI.js";import{c as u}from"./routes-BbeIx_F9.js";import{i as d,n as f,r as p,s as m,t as h}from"./prefs-DYaOj-dg.js";function g(e){return e.tosAccepted&&e.privacyConsent}function _(e){return g(e)&&e.analyticsConsentCurrent&&e.diagnosticsConsentCurrent}var v=`${u.assistant}/onboarding`,y=new Set([u.onboarding.hosting,u.onboarding.apiKey]),b=new Set([u.welcome,u.selectAssistant]);function x(e){return e.startsWith(`${v}/`)||e===v}function S(e){return e?u.welcome:u.onboarding.privacy}function C(e){if(e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`//`))try{return new URL(e,`http://placeholder.invalid`).pathname}catch{return e}return e}function w(e,t){return t===u.welcome?e.hasAssistants?u.selectAssistant:u.onboarding.hosting:t===u.selectAssistant?`${t}?fromLogin=1`:t}function T(e,t){switch(t.kind){case`route-guard`:return D(e,t.pathname);case`onboarding-intercept`:return L(e,t.intendedDestination);case`hatch-gate`:return R(e);case`post-auth`:return z(t.authIntent,t.returnTo,t.fallback);case`post-retire`:return B(e)}}var E=[O,k,j,M,N,P,F,I];function D(e,t){let n=t.indexOf(`?`),r=n>=0?t.slice(0,n):t;for(let n of E){let i=n(e,r,t);if(i)return i}return{action:`allow`}}function O(e){return e.sessionSettled?null:{action:`wait`}}function k(e){return e.isGatewayAuth?{action:`allow`}:null}function A(e,t){let n=e.remoteGatewayPublicPathPrefix;return!e.isRemoteGateway||!n?t:t===n?u.assistant:t.startsWith(`${n}/`)?t.slice(n.length):t}function j(e,t,n){if(!e.isRemoteGateway||e.isAuthenticated)return null;let r=A(e,n);return{action:`redirect`,to:`${u.remotePair}?returnTo=${encodeURIComponent(r)}`}}function M(e,t,n){return e.isAuthenticated?null:e.isLocalMode&&(x(t)||b.has(t))?t===u.selectAssistant&&!e.hasAssistants?{action:`redirect`,to:u.onboarding.hosting}:{action:`allow`}:e.isLocalMode&&!e.hasAssistants?{action:`redirect`,to:u.welcome}:e.isLocalMode?{action:`redirect`,to:u.selectAssistant}:{action:`redirect`,to:`${u.account.login}?returnTo=${encodeURIComponent(n)}`}}function N(e,t){return b.has(t)?e.isLocalMode?t===u.selectAssistant&&!e.hasAssistants?{action:`redirect`,to:u.onboarding.hosting}:{action:`allow`}:{action:`redirect`,to:u.assistant}:y.has(t)&&!e.isLocalMode?{action:`redirect`,to:u.assistant}:null}function P(e,t){return t===u.reviewTerms?{action:`allow`}:x(t)?t===u.onboarding.hatching&&!g(e)?{action:`redirect`,to:S(e.isLocalMode)}:{action:`allow`}:null}function F(e,t,n){if(e.hasAssistants)return null;if(e.isLocalMode)return e.platformSession===`unknown`?{action:`wait`}:e.platformSession===`present`?{action:`redirect`,to:u.onboarding.hosting}:{action:`redirect`,to:u.welcome};if(!e.assistantsHydrated||!e.consentHydrated)return{action:`wait`};if(!g(e))return{action:`redirect`,to:u.onboarding.privacy};if(!_(e)){let e=encodeURIComponent(n);return{action:`redirect`,to:`${u.reviewTerms}?returnTo=${e}`}}return{action:`redirect`,to:u.onboarding.hatching}}function I(e,t,n){if(e.isPlatformDisabled||e.platformSession!==`present`||_(e))return null;if(!e.consentHydrated&&!e.isLocalMode)return{action:`wait`};let r=encodeURIComponent(n);return{action:`redirect`,to:`${u.reviewTerms}?returnTo=${r}`}}function L(e,t){if(e.isLocalMode&&e.hasAssistants||g(e))return{action:`allow`};let n=C(t);return!n.startsWith(u.assistant)||n.startsWith(`${u.assistant}/onboarding`)||n===u.reviewTerms?{action:`allow`}:{action:`redirect`,to:S(e.isLocalMode)}}function R(e){return e.sessionSettled?!e.isAuthenticated&&!e.isLocalMode?{action:`redirect`,to:u.account.login}:g(e)?!e.isLocalMode&&!_(e)?{action:`redirect`,to:u.reviewTerms}:{action:`allow`}:{action:`redirect`,to:S(e.isLocalMode)}:{action:`wait`}}function z(e,t,n){return e===`signup`?{action:`redirect`,to:u.onboarding.privacy}:{action:`redirect`,to:l(t,n)}}function B(e){return e.hasAssistants?{action:`redirect`,to:e.isLocalMode?u.selectAssistant:u.assistant}:e.isLocalMode?e.platformSession===`present`?{action:`redirect`,to:u.onboarding.hosting}:{action:`redirect`,to:u.welcome}:{action:`redirect`,to:u.onboarding.privacy}}function V(l){let{sessionStatus:u,platformSession:g}=s.getState(),{assistants:_,assistantsHydrated:v}=i.getState(),y=t();return{isLocalMode:r(),isPlatformDisabled:n(),isRemoteGateway:y,remoteGatewayPublicPathPrefix:y?c():``,isGatewayAuth:e(),hasAssistants:_.length>0,sessionSettled:o(u),isAuthenticated:a(u),platformSession:g,tosAccepted:m(),privacyConsent:d(),analyticsConsentCurrent:h(),diagnosticsConsentCurrent:p(),consentHydrated:f(),assistantsHydrated:v,...l}}export{w as n,T as r,V as t};
1
+ import{ct as e,g as t,h as n,p as r}from"./local-mode-grqHUoNh.js";import{n as i}from"./resolved-assistants-store-BSZbT8Ju.js";import{M as a,P as o,n as s}from"./auth-store-C09YAZEu.js";import{c}from"./remote-gateway-session-CbBWrPZH.js";import{t as l}from"./return-to-BwxkOGDI.js";import{c as u}from"./routes-BbeIx_F9.js";import{i as d,n as f,r as p,s as m,t as h}from"./prefs-B1Y3q3c8.js";function g(e){return e.tosAccepted&&e.privacyConsent}function _(e){return g(e)&&e.analyticsConsentCurrent&&e.diagnosticsConsentCurrent}var v=`${u.assistant}/onboarding`,y=new Set([u.onboarding.hosting,u.onboarding.apiKey]),b=new Set([u.welcome,u.selectAssistant]);function x(e){return e.startsWith(`${v}/`)||e===v}function S(e){return e?u.welcome:u.onboarding.privacy}function C(e){if(e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`//`))try{return new URL(e,`http://placeholder.invalid`).pathname}catch{return e}return e}function w(e,t){return t===u.welcome?e.hasAssistants?u.selectAssistant:u.onboarding.hosting:t===u.selectAssistant?`${t}?fromLogin=1`:t}function T(e,t){switch(t.kind){case`route-guard`:return D(e,t.pathname);case`onboarding-intercept`:return L(e,t.intendedDestination);case`hatch-gate`:return R(e);case`post-auth`:return z(t.authIntent,t.returnTo,t.fallback);case`post-retire`:return B(e)}}var E=[O,k,j,M,N,P,F,I];function D(e,t){let n=t.indexOf(`?`),r=n>=0?t.slice(0,n):t;for(let n of E){let i=n(e,r,t);if(i)return i}return{action:`allow`}}function O(e){return e.sessionSettled?null:{action:`wait`}}function k(e){return e.isGatewayAuth?{action:`allow`}:null}function A(e,t){let n=e.remoteGatewayPublicPathPrefix;return!e.isRemoteGateway||!n?t:t===n?u.assistant:t.startsWith(`${n}/`)?t.slice(n.length):t}function j(e,t,n){if(!e.isRemoteGateway||e.isAuthenticated)return null;let r=A(e,n);return{action:`redirect`,to:`${u.remotePair}?returnTo=${encodeURIComponent(r)}`}}function M(e,t,n){return e.isAuthenticated?null:e.isLocalMode&&(x(t)||b.has(t))?t===u.selectAssistant&&!e.hasAssistants?{action:`redirect`,to:u.onboarding.hosting}:{action:`allow`}:e.isLocalMode&&!e.hasAssistants?{action:`redirect`,to:u.welcome}:e.isLocalMode?{action:`redirect`,to:u.selectAssistant}:{action:`redirect`,to:`${u.account.login}?returnTo=${encodeURIComponent(n)}`}}function N(e,t){return b.has(t)?e.isLocalMode?t===u.selectAssistant&&!e.hasAssistants?{action:`redirect`,to:u.onboarding.hosting}:{action:`allow`}:{action:`redirect`,to:u.assistant}:y.has(t)&&!e.isLocalMode?{action:`redirect`,to:u.assistant}:null}function P(e,t){return t===u.reviewTerms?{action:`allow`}:x(t)?t===u.onboarding.hatching&&!g(e)?{action:`redirect`,to:S(e.isLocalMode)}:{action:`allow`}:null}function F(e,t,n){if(e.hasAssistants)return null;if(e.isLocalMode)return e.platformSession===`unknown`?{action:`wait`}:e.platformSession===`present`?{action:`redirect`,to:u.onboarding.hosting}:{action:`redirect`,to:u.welcome};if(!e.assistantsHydrated||!e.consentHydrated)return{action:`wait`};if(!g(e))return{action:`redirect`,to:u.onboarding.privacy};if(!_(e)){let e=encodeURIComponent(n);return{action:`redirect`,to:`${u.reviewTerms}?returnTo=${e}`}}return{action:`redirect`,to:u.onboarding.hatching}}function I(e,t,n){if(e.isPlatformDisabled||e.platformSession!==`present`||_(e))return null;if(!e.consentHydrated&&!e.isLocalMode)return{action:`wait`};let r=encodeURIComponent(n);return{action:`redirect`,to:`${u.reviewTerms}?returnTo=${r}`}}function L(e,t){if(e.isLocalMode&&e.hasAssistants||g(e))return{action:`allow`};let n=C(t);return!n.startsWith(u.assistant)||n.startsWith(`${u.assistant}/onboarding`)||n===u.reviewTerms?{action:`allow`}:{action:`redirect`,to:S(e.isLocalMode)}}function R(e){return e.sessionSettled?!e.isAuthenticated&&!e.isLocalMode?{action:`redirect`,to:u.account.login}:g(e)?!e.isLocalMode&&!_(e)?{action:`redirect`,to:u.reviewTerms}:{action:`allow`}:{action:`redirect`,to:S(e.isLocalMode)}:{action:`wait`}}function z(e,t,n){return e===`signup`?{action:`redirect`,to:u.onboarding.privacy}:{action:`redirect`,to:l(t,n)}}function B(e){return e.hasAssistants?{action:`redirect`,to:e.isLocalMode?u.selectAssistant:u.assistant}:e.isLocalMode?e.platformSession===`present`?{action:`redirect`,to:u.onboarding.hosting}:{action:`redirect`,to:u.welcome}:{action:`redirect`,to:u.onboarding.privacy}}function V(l){let{sessionStatus:u,platformSession:g}=s.getState(),{assistants:_,assistantsHydrated:v}=i.getState(),y=t();return{isLocalMode:r(),isPlatformDisabled:n(),isRemoteGateway:y,remoteGatewayPublicPathPrefix:y?c():``,isGatewayAuth:e(),hasAssistants:_.length>0,sessionSettled:o(u),isAuthenticated:a(u),platformSession:g,tosAccepted:m(),privacyConsent:d(),analyticsConsentCurrent:h(),diagnosticsConsentCurrent:p(),consentHydrated:f(),assistantsHydrated:v,...l}}export{w as n,T as r,V as t};