@vellumai/web 0.11.2-staging.2 → 0.11.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 (159) hide show
  1. package/dist/assets/{Combination-CWTYp834.js → Combination-TPH8qx8I.js} +1 -1
  2. package/dist/assets/{access-CVnesk0m.js → access-PKx6h0AJ.js} +1 -1
  3. package/dist/assets/{account-page-mMG1nL1O.js → account-page-DucijMvM.js} +1 -1
  4. package/dist/assets/{account-shell-BmH96-Ie.js → account-shell-BBDh-DzD.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-SN6NIuW5.js → acp-run-detail-panel-DJ6moBbf.js} +1 -1
  6. package/dist/assets/{activity-steps-panel-bduSS8_d.js → activity-steps-panel-C95hN_fd.js} +1 -1
  7. package/dist/assets/{add-credential-modal-4zzd0MPK.js → add-credential-modal-BbvTHJmF.js} +1 -1
  8. package/dist/assets/{add-credits-modal-DNYP2NMD.js → add-credits-modal-C5d63VSi.js} +1 -1
  9. package/dist/assets/{ai-page-BMqECtJX.js → ai-page-CbNTYziv.js} +1 -1
  10. package/dist/assets/{api-key-screen-tqtaQUVf.js → api-key-screen-B5zgGiwa.js} +1 -1
  11. package/dist/assets/{app-card-BJigGog3.js → app-card-CxO44OqN.js} +1 -1
  12. package/dist/assets/{assistant-feature-flag-store-BvLDPeej.js → assistant-feature-flag-store-BojuHxUH.js} +1 -1
  13. package/dist/assets/{assistant-status-panel-DyjhJvK6.js → assistant-status-panel-ZdWgKADH.js} +1 -1
  14. package/dist/assets/{background-task-detail-panel-DCtBOnvF.js → background-task-detail-panel-BvgkgKs6.js} +1 -1
  15. package/dist/assets/{billing-page-TF_LgX6K.js → billing-page-CSxWbmCW.js} +2 -2
  16. package/dist/assets/{bookmarks-page-Brvj5Jf6.js → bookmarks-page-hFDlAWts.js} +1 -1
  17. package/dist/assets/{button-Dy5001j6.js → button-BwFudwM5.js} +1 -1
  18. package/dist/assets/{channels-page-route-8vJJE2LN.js → channels-page-route-Cxn_zS-J.js} +1 -1
  19. package/dist/assets/{chat-markdown-message-B7qvlO44.js → chat-markdown-message-BZZsrGyj.js} +1 -1
  20. package/dist/assets/{checkbox-PU47Djxg.js → checkbox-fzrjTRTI.js} +1 -1
  21. package/dist/assets/{checkout-page-MpIPAAgf.js → checkout-page-lDrK4V11.js} +1 -1
  22. package/dist/assets/{command-palette-Bd1GTwZQ.js → command-palette-Bzsl-t3p.js} +1 -1
  23. package/dist/assets/{command-palette-window-page-CoweYsZl.js → command-palette-window-page-DjfAe-7N.js} +1 -1
  24. package/dist/assets/{community-page-BWMwSeEZ.js → community-page-CktLEQl7.js} +1 -1
  25. package/dist/assets/{confirm-dialog-j9o2h3xs.js → confirm-dialog-B7WBNDbT.js} +1 -1
  26. package/dist/assets/{connect-page-BxSNhZ8N.js → connect-page-hrIJuX_v.js} +1 -1
  27. package/dist/assets/{consent-controls-Bs63UL5k.js → consent-controls-HYcVhQZ2.js} +1 -1
  28. package/dist/assets/{contacts-page-route-BOpVOsYK.js → contacts-page-route-CX57wU3L.js} +1 -1
  29. package/dist/assets/{conversation-navigation-Bf3cDRKh.js → conversation-navigation-CIHBMx2t.js} +1 -1
  30. package/dist/assets/{copy-to-clipboard-DgY-nZpm.js → copy-to-clipboard-Y0mxY68V.js} +1 -1
  31. package/dist/assets/{credential-entry-page-CreYYbwf.js → credential-entry-page-DQOv-Jyx.js} +1 -1
  32. package/dist/assets/credentials-page-C0eeGia5.js +1 -0
  33. package/dist/assets/{csv-preview-cEf_PW-P.js → csv-preview-C4T5JLx3.js} +1 -1
  34. package/dist/assets/{debug-page-DfPZPo6D.js → debug-page-DzXHo3zM.js} +2 -2
  35. package/dist/assets/{deploy-dialogs-CuaO05wL.js → deploy-dialogs-DQGwptOi.js} +1 -1
  36. package/dist/assets/{deploy-store-BDIOP-i9.js → deploy-store-BJh0AR_u.js} +1 -1
  37. package/dist/assets/{detail-card-BElAV1cp.js → detail-card-Br_T-73R.js} +1 -1
  38. package/dist/assets/{detail-drawer-Cd_EQJkJ.js → detail-drawer-Cbj_q7o7.js} +1 -1
  39. package/dist/assets/{detail-panel-stop-button-Bhew_kym.js → detail-panel-stop-button-DN2NrxEh.js} +1 -1
  40. package/dist/assets/{detail-shell-BjqibXNX.js → detail-shell-BuJMM-9z.js} +1 -1
  41. package/dist/assets/{developer-page-DwBmhm09.js → developer-page-Cj9JWAsX.js} +1 -1
  42. package/dist/assets/{dist-EanpjdWC.js → dist-B5IUaBWa.js} +1 -1
  43. package/dist/assets/{dist-C68qFSny.js → dist-BrrL0-_M.js} +1 -1
  44. package/dist/assets/dist-DWcXIgDR.js +1 -0
  45. package/dist/assets/{document-viewer-container-iB63ww7P.js → document-viewer-container-CPc9KTln.js} +2 -2
  46. package/dist/assets/{document-viewer-page-CA1ParJ6.js → document-viewer-page-BqJvQQmH.js} +1 -1
  47. package/dist/assets/{dropdown-B3FHWc_n.js → dropdown-CJVkL1Yp.js} +1 -1
  48. package/dist/assets/{emails-page-Bo0Bwem2.js → emails-page-DwQ-FnOD.js} +1 -1
  49. package/dist/assets/{file-editor-BfJR0ScX.js → file-editor-BigdI9HF.js} +1 -1
  50. package/dist/assets/{file-markdown-DnVLY_b_.js → file-markdown-eU8RUJQZ.js} +1 -1
  51. package/dist/assets/{first-run-scope-CPJpXaWU.js → first-run-scope-DqdWmMO-.js} +1 -1
  52. package/dist/assets/{general-page-BXeIQDGi.js → general-page-uFG7UTqR.js} +1 -1
  53. package/dist/assets/hatching-screen-CWZvcZVI.js +1 -0
  54. package/dist/assets/{home-page-route-BPht0PNp.js → home-page-route-zQaUf7gb.js} +1 -1
  55. package/dist/assets/{hosting-screen-DxtyBx0I.js → hosting-screen-lGuLVQVG.js} +1 -1
  56. package/dist/assets/{identity-page-route-DgmrXhhV.js → identity-page-route-C64OsL5_.js} +1 -1
  57. package/dist/assets/index-Cn_k9u0x.css +2 -0
  58. package/dist/assets/{index-CPeIfypI.js → index-D-1mlWsA.js} +1 -1
  59. package/dist/assets/{input-tXUFa7Eo.js → input-CgGeKtja.js} +1 -1
  60. package/dist/assets/{inspect-page-C8aLJOd6.js → inspect-page-DdXP831Q.js} +1 -1
  61. package/dist/assets/integrations-page-DmQCd8GV.js +1 -0
  62. package/dist/assets/{intelligence-layout-BRC0qkZ7.js → intelligence-layout-IptAIgHy.js} +1 -1
  63. package/dist/assets/{library-detail-page-gC4yIWnV.js → library-detail-page-Ddel5wXb.js} +1 -1
  64. package/dist/assets/{library-page-B10gnbXU.js → library-page-B4k0PNa8.js} +1 -1
  65. package/dist/assets/{login-page-CbWRbJDE.js → login-page-CRIed3qa.js} +1 -1
  66. package/dist/assets/{logout-page-DCyzi0V6.js → logout-page-Ne05SAbm.js} +1 -1
  67. package/dist/assets/{logs-layout-CYkqau4S.js → logs-layout-BN5HA58-.js} +1 -1
  68. package/dist/assets/{memory-page-route-j_3602nh.js → memory-page-route-Mz8GlpcX.js} +1 -1
  69. package/dist/assets/{memory-router-playground-page-x5X662qi.js → memory-router-playground-page-CeIkpuOW.js} +1 -1
  70. package/dist/assets/{menu-wESJw6y3.js → menu-Cfi4A3sw.js} +1 -1
  71. package/dist/assets/{message-files-panel-C8JokH6e.js → message-files-panel-C8sWLQ58.js} +1 -1
  72. package/dist/assets/{messages-Dyp1xUqz.js → messages-BTSYvzWZ.js} +1 -1
  73. package/dist/assets/{metric-card-DpZFp8-q.js → metric-card-CczTqF_s.js} +1 -1
  74. package/dist/assets/{mobile-sidebar-drawer-BwCIAm23.js → mobile-sidebar-drawer-CSAugzxJ.js} +1 -1
  75. package/dist/assets/{modal-xr_vw1ZO.js → modal-DagTZ8xj.js} +1 -1
  76. package/dist/assets/mutation-error-Cp0Jaqnt.js +1 -0
  77. package/dist/assets/{not-found-Bh7ZsdAo.js → not-found-C1zvwDkh.js} +1 -1
  78. package/dist/assets/{notifications-page-BA2BW5y6.js → notifications-page-BzoWNM1e.js} +1 -1
  79. package/dist/assets/{onboarding-layout-iPzXbZk1.js → onboarding-layout-CNKJRWfe.js} +1 -1
  80. package/dist/assets/{open-workspace-file-CivxJWcw.js → open-workspace-file-DAlt8chN.js} +2 -2
  81. package/dist/assets/{page-shell-ZNQR4ZTn.js → page-shell-Dx-efyAO.js} +1 -1
  82. package/dist/assets/pairing-page-BqjYohpZ.js +1 -0
  83. package/dist/assets/{panel-item-CJh95P_q.js → panel-item-5YQ3jbso.js} +1 -1
  84. package/dist/assets/{personality-page-Bz_rNBSs.js → personality-page-CB98MeIQ.js} +1 -1
  85. package/dist/assets/{plans-page-BfyCgy38.js → plans-page-BcR_kjJL.js} +1 -1
  86. package/dist/assets/{platform-login-notice-DFmjUE9q.js → platform-login-notice-DvWjpI2S.js} +1 -1
  87. package/dist/assets/popover-CBYgK7Wt.js +1 -0
  88. package/dist/assets/{preview-error-BrLE2D3A.js → preview-error-DzUxX6Jy.js} +1 -1
  89. package/dist/assets/{privacy-page-BhEGh78C.js → privacy-page-B9zfD9a-.js} +1 -1
  90. package/dist/assets/{privacy-screen-CWVCI_KU.js → privacy-screen-Btqk8OjG.js} +1 -1
  91. package/dist/assets/{provider-callback-page-DP5cKqPE.js → provider-callback-page-Jul4gNdZ.js} +1 -1
  92. package/dist/assets/provider-key-BZOwvE14.js +1 -0
  93. package/dist/assets/{provider-signup-page-BjiiJWS_.js → provider-signup-page-C47ij2Um.js} +1 -1
  94. package/dist/assets/{research-mock-page-CGkqkXHp.js → research-mock-page-DthnGXhi.js} +1 -1
  95. package/dist/assets/{research-onboarding-route-DZF-B2Rk.js → research-onboarding-route-Cql_2-1F.js} +1 -1
  96. package/dist/assets/{research-results-view-BFZFPpev.js → research-results-view-BYpW36E0.js} +1 -1
  97. package/dist/assets/{retire-confirm-dialog-8xlq4bkx.js → retire-confirm-dialog-PvFzzHrQ.js} +1 -1
  98. package/dist/assets/{review-terms-screen-C5BAI3Rx.js → review-terms-screen-BpE_z8HY.js} +1 -1
  99. package/dist/assets/routes-DRAnvlxS.js +23 -0
  100. package/dist/assets/{runtime-upgrade-banner-DjFuJawk.js → runtime-upgrade-banner-Blp8EyfL.js} +1 -1
  101. package/dist/assets/{schedules-page-3ZE1nR6I.js → schedules-page-D6KPJIUP.js} +1 -1
  102. package/dist/assets/{select-assistant-screen-D4WHHv61.js → select-assistant-screen-DH6QRKdk.js} +1 -1
  103. package/dist/assets/{settings-divider-BkLQFMlW.js → settings-divider-COV4-sHz.js} +1 -1
  104. package/dist/assets/{settings-layout-BmOglXDq.js → settings-layout-CyMD8Ey7.js} +1 -1
  105. package/dist/assets/{share-feedback-modal-Rwuho_1S.js → share-feedback-modal-NfuDPoEg.js} +1 -1
  106. package/dist/assets/{sidebar-tree-Dxx5qLMQ.js → sidebar-tree-DTcPYrOG.js} +1 -1
  107. package/dist/assets/{site-favicon-CDH0mg6Q.js → site-favicon-DkjZF9mC.js} +1 -1
  108. package/dist/assets/{skill-detail-page-DswXTTyb.js → skill-detail-page-CzCcXCkp.js} +1 -1
  109. package/dist/assets/{skill-detail-panel-DhQFBAFF.js → skill-detail-panel-B1Kxa3zf.js} +1 -1
  110. package/dist/assets/{skills-CbF2uKXV.js → skills-CrZ3GlyK.js} +1 -1
  111. package/dist/assets/{slack-setup-wizard-DPzdheN0.js → slack-setup-wizard-CeBY_rKV.js} +1 -1
  112. package/dist/assets/src-CwGlaCIx.js +293 -0
  113. package/dist/assets/{start-screen-CSxaBn88.js → start-screen-wyemTUjV.js} +1 -1
  114. package/dist/assets/{subagent-detail-panel-CidisBCf.js → subagent-detail-panel-C3II8umu.js} +1 -1
  115. package/dist/assets/{superpowers-page-BouZK3P4.js → superpowers-page-DmIZ_ed4.js} +1 -1
  116. package/dist/assets/{system-events-page-BrvTNeiN.js → system-events-page-DAbap4FJ.js} +1 -1
  117. package/dist/assets/{tag-gOOX7fbA.js → tag-G0ELn_cq.js} +1 -1
  118. package/dist/assets/{text-preview-DwgKh8PW.js → text-preview-DLiOtb-y.js} +1 -1
  119. package/dist/assets/{theme-stage-page-LIhQbqRQ.js → theme-stage-page-Dt0ShS5G.js} +1 -1
  120. package/dist/assets/{tiptap-document-editor-BvGaiGeN.js → tiptap-document-editor-LwU6S_hn.js} +2 -2
  121. package/dist/assets/{toast-BtFgiPe3.js → toast-BHjG1kP8.js} +1 -1
  122. package/dist/assets/{tool-detail-panel-B2CIRZkB.js → tool-detail-panel-tFQRRPbP.js} +1 -1
  123. package/dist/assets/{transcript-message-body-shared-BfKwS5qD.js → transcript-message-body-shared-DdXeU1D-.js} +1 -1
  124. package/dist/assets/{upgrade-cancel-page-DjeqfvTa.js → upgrade-cancel-page-isK2Rvv6.js} +1 -1
  125. package/dist/assets/{upgrade-success-page-B4TCn340.js → upgrade-success-page-B7ZaoDsy.js} +1 -1
  126. package/dist/assets/{use-assistant-identity-details-D-7oN9gr.js → use-assistant-identity-details-BLHiMTpS.js} +1 -1
  127. package/dist/assets/{use-attachment-preview-CQjpDfsc.js → use-attachment-preview-TAzqhvwh.js} +1 -1
  128. package/dist/assets/{use-attachment-squares-8Hx-p8ls.js → use-attachment-squares-Cnn6a6er.js} +1 -1
  129. package/dist/assets/{use-bookmarks-DO9wmU-2.js → use-bookmarks-BKYsQrf9.js} +1 -1
  130. package/dist/assets/{use-checkout-dismiss-refresh-CV_H4uEB.js → use-checkout-dismiss-refresh-ChquCG4n.js} +1 -1
  131. package/dist/assets/{use-edit-app-Bd1eXXFq.js → use-edit-app-LCywIVb9.js} +1 -1
  132. package/dist/assets/{use-invite-link-dialog-TNGI1l4g.js → use-invite-link-dialog-CnOeFYBH.js} +1 -1
  133. package/dist/assets/{use-ios-app-nudge-CadXZRJC.js → use-ios-app-nudge-9Qqz96FD.js} +1 -1
  134. package/dist/assets/{use-skill-actions-B_tz3CI7.js → use-skill-actions-Ik0rj4or.js} +1 -1
  135. package/dist/assets/{use-sticky-profiles-D5TVHOgw.js → use-sticky-profiles-BwaZUy6p.js} +1 -1
  136. package/dist/assets/{use-subagent-card-data-bjGydvhR.js → use-subagent-card-data-1nEhEj8_.js} +1 -1
  137. package/dist/assets/{use-transcript-message-by-id-BgyP3Ki5.js → use-transcript-message-by-id-RhDDYgbY.js} +1 -1
  138. package/dist/assets/{use-transcript-messages-C2uwkjKL.js → use-transcript-messages-C5t358ZW.js} +1 -1
  139. package/dist/assets/{utils-3IBGVjNS.js → utils-B6xfBCpN.js} +1 -1
  140. package/dist/assets/{viewer-store-DbIS4l8d.js → viewer-store-DxLOGAkL.js} +1 -1
  141. package/dist/assets/{voice-list-D26Lzbpv.js → voice-list-DP4_zhJe.js} +1 -1
  142. package/dist/assets/{voice-page-CQ2Vp8p4.js → voice-page-Bn0QH4eT.js} +1 -1
  143. package/dist/assets/{voice-providers-note-Ck7hNTfp.js → voice-providers-note-F4pLO3zK.js} +1 -1
  144. package/dist/assets/{welcome-screen-CdsjDVfi.js → welcome-screen-B6BjQt9n.js} +1 -1
  145. package/dist/assets/{workflow-detail-panel-CsRhUrbM.js → workflow-detail-panel-H3N7Md_X.js} +1 -1
  146. package/dist/assets/{workspace-page-CFuSxp5s.js → workspace-page-B4sn6pzo.js} +1 -1
  147. package/dist/index.html +55 -55
  148. package/package.json +1 -1
  149. package/dist/assets/credentials-page-DBLT8nUI.js +0 -1
  150. package/dist/assets/dist-BDdp8zqz.js +0 -1
  151. package/dist/assets/hatching-screen-BUpSlvBy.js +0 -1
  152. package/dist/assets/index-C7_04HXM.css +0 -2
  153. package/dist/assets/integrations-page-Bp2Q81Qt.js +0 -1
  154. package/dist/assets/mutation-error-YLfUU5XL.js +0 -1
  155. package/dist/assets/pairing-page-P5ghxF0M.js +0 -1
  156. package/dist/assets/popover-B-3isZCV.js +0 -1
  157. package/dist/assets/provider-key-CgC-RLmR.js +0 -1
  158. package/dist/assets/routes-uGHUgv4F.js +0 -23
  159. package/dist/assets/src-Da9g8qsW.js +0 -293
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-xr_vw1ZO.js";import{n as E}from"./toast-BtFgiPe3.js";import{t as ee}from"./confirm-dialog-j9o2h3xs.js";import{t as D}from"./dropdown-B3FHWc_n.js";import{n as O}from"./resolved-assistants-store-C6oDdTxB.js";import{at as k,d as A,f as j,l as te,tt as M,u as N}from"./auth-store-C9aYqB9U.js";import{S as ne,b as re}from"./native-biometric-DetUqtjl.js";import{d as ie}from"./routes-DrfnNoYS.js";import{d as P}from"./platform-detection-AHYibqOx.js";import{n as F}from"./use-assistant-avatar-Bjqx8JUy.js";import{r as ae}from"./use-is-org-ready-3vHDbj4G.js";import{n as oe,r as I}from"./browser-CcdNg0HN.js";import{$ as se,C as ce,O as le,at as ue,c as de,ct as L,et as R,it as fe,jt as z,l as pe,lt as me,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as be,ut as B,y as xe}from"./react-query.gen-BtYBixpk.js";import{t as V}from"./avatar-bundled-components-BvKt7I7O.js";import{r as Se}from"./use-avatar-accent-var-BafXGBXW.js";import{t as H}from"./misc-BBsGq1IU.js";import{n as Ce,t as we}from"./avatar-tone-D99t9DAP.js";import{t as Te}from"./chat-avatar-B5fx9Xm3.js";import{t as Ee}from"./avatar-renderer-TpNgmnU1.js";import{n as U}from"./use-bundled-avatar-components-BcyasJwu.js";import{t as De}from"./android-consumption-only-D3L1Nc41.js";import{c as Oe,i as W,l as ke,n as G,r as Ae,t as je}from"./machine-sizes-B9nt_h-U.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./provisioning-targets-Cah9jNBe.js";import{t as Le}from"./environment-store-DxX3xxt2.js";var Re=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),K=u();function ze({children:e,redirectToBilling:t=!1}){return P()?t?(0,K.jsx)(r,{replace:!0,to:ie.settings.usageBilling}):(0,K.jsx)(w,{tone:`info`,children:De}):e}var q=e(t(),1);function Be({icon:e}){return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var J={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function Y({title:e,subtitle:t}){return(0,K.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],He=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function Ue({variant:e=`full`}){let t=U();return t?(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?He:Ve).map((e,n)=>(0,K.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,K.jsx)(Ee,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var X={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Z={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Q={upgrade:X,downgrade:Z,change:Z};function We(e=`upgrade`){return Q[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...le({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ae())?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,K.jsx)(Ue,{variant:`full`}),(0,K.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,K.jsx)(Y,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,K.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,K.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&M(e),r(ie.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={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.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){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}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Le.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(`hi`),[g,_]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=l(ue()),C=!!d||b,E=S.isPending||b;return(0,q.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,K.jsx)(Ue,{variant:`top`}),(0,K.jsx)(Y,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,K.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,K.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,K.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,K.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,K.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,K.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,K.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,K.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:xe()}),i.invalidateQueries({queryKey:pe({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:L()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(Be,{icon:h}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:W[n.machineSize],to:W[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:W[n.machineSize],to:W[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,K.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,K.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ae(),{data:n}=c({...se(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=F(n),s=(0,q.useMemo)(()=>A(),[j()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=Se(f,p)??(m?null:(f??V).colors?.[0]?.hex??null);return{tintHex:h&&g?Ce(g):we,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,q.useState)(e),i=(0,q.useRef)(0);return(0,q.useEffect)(()=>{i.current=performance.now()},[]),(0,q.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${we})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,q.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,q.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=U(),o=jt(),s=t===`working`||t===`settling`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,K.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,K.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,K.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,K.jsx)(`div`,{className:`provision-avatar-current`,children:(0,K.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,K.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,K.jsx)(Te,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,K.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,K.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,K.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,K.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,K.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,K.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{children:r}),i?(0,K.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,K.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,K.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,K.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,K.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,q.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,K.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,K.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,K.jsx)(zt,{children:(0,K.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,K.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,K.jsx)(Lt,{icon:v,label:`Machine`,to:G[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,K.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,K.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,q.useRef)(d);(0,q.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,q.useRef)(h);(0,q.useEffect)(()=>{T.current=h},[h]),(0,q.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,q.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,K.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,K.jsx)(mt,{imageUrl:ee}),(0,K.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,K.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,K.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,K.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,K.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!Me(n,i);if(Me(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ae(),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),[E,ee]=(0,q.useState)(Jt),[D,O]=(0,q.useState)(null),[A,j]=(0,q.useState)(!1),te=(0,q.useRef)(!1),M=(0,q.useRef)(!1),N=(0,q.useRef)(0),[ne,re]=(0,q.useState)(!1),[ie,P]=(0,q.useState)(null),[F,oe]=(0,q.useState)(null),[I,se]=(0,q.useState)(null),[ue,de]=(0,q.useState)(()=>Date.now()),[R,fe]=(0,q.useState)(!0);(0,q.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),P(null),oe(null),se(null),fe(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),te.current=!1,M.current=!1,N.current+=1)},[e]),(0,q.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:B()}),r.invalidateQueries({queryKey:L()}))},[e,r]);let z=g!=null,pe=c({...me(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!z}),he=(m!=null&&pe.dataUpdatedAt>=m?pe.data?.plan_id:null)??null;(0,q.useEffect)(()=>{if(!e||z||he!==`pro`)return;let t=Date.now();_(t),de(t)},[e,z,he]),(0,q.useEffect)(()=>{if(!e||z)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,z,f]);let ve=(0,q.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:B()})},[r]),be=(0,q.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:xe}=l(ge()),V=(0,q.useCallback)(e=>{let t=N.current;xe({},{onSuccess:n=>{t===N.current&&(O(null),Pe(n)?M.current?O({error:n.reason??`no_active_pro`}):(M.current=!0,j(!0),e===`escape`&&be()):(x(n.state),e===`escape`&&be()))},onError:e=>{t===N.current&&O(e)}})},[xe,be]);(0,q.useEffect)(()=>{!e||!i||!z||te.current||(te.current=!0,V(`auto`))},[e,i,z,V]),(0,q.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&V(`auto`)},Ze);return()=>clearTimeout(t)},[A,V]);let Se=(0,q.useCallback)(()=>V(`escape`),[V]),H=c({...ye(),enabled:e&&i&&z}),Ce=R?Gt:!1,we=c({..._e(),enabled:e&&i&&z,refetchInterval:e=>e.state.data?.id==null?Ce:!1,retry:!1}),Te=z&&m!=null&&H.dataUpdatedAt>=m,Ee=Te&&!H.isPending&&!H.isFetching,U=(Te?H.data?.primary_assistant_id:null)??(H.isPending?null:we.data?.id??null),De=c({...le({path:{id:U??`unresolved`}}),enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),W=ce({path:{id:U??`unresolved`}}),G=c({...W,enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),Ae=(0,q.useRef)(0),[Le,Re]=(0,q.useState)(0),K=o(W.queryKey);(0,q.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==K)){if(t.action.type===`fetch`)Ae.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=Ae.current,r=e&&Fe(t.action.data);a.schedule(()=>{Re(n),r&&(re(!0),P(U))})}}}),[r,K,e,U]);let ze=Fe(G.data),Be=ie===U,J=H.data,Y=(0,q.useMemo)(()=>J?{machineSize:Oe(J.max_machine_tier),storageGib:J.selected_storage_gib??null}:null,[J]),Ve=J!=null&&J.max_machine_tier==null?je:null,He=J?J.domain_setup_available&&J.primary_assistant_id!=null:void 0,Ue=De.data,X=(0,q.useMemo)(()=>Ue?{machineSize:Ue.machine_size??null,storageGib:Ue.provisioned_storage_gib??null}:null,[Ue]),Z=I===U,Q=(0,q.useMemo)(()=>{let e=Ie(Y,X),t=Y?.machineSize??Ve;if(t==null)return e;let n=X?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Z?F?.machineSize:null)??n,i=ke(t)<ke(r);return{...e,machine:i?ke(n)<=ke(t):ke(n)>=ke(t)}},[Y,X,F,Z,Ve]),We=Me(Y,X),Ge=w===U;(0,q.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(U)):(C(null),T(null)))},[e,We,U,Ge]);let Ke=E.assistantId===U;(0,q.useEffect)(()=>{if(!e)return;let t=Ae.current;ee(e=>{let n=e.assistantId===U?e:Jt,r=Q.machine?n.machine??t:null,i=Q.storage?n.storage??t:null;return e.assistantId===U&&e.machine===r&&e.storage===i?e:{assistantId:U,machine:r,storage:i}})},[e,Q,U]);let qe=(0,q.useMemo)(()=>{let e=Ne(G.data),t=e=>e!=null&&Ke&&Le>e;return{machine:Q.machine&&!e.machine&&t(E.machine),storage:Q.storage&&!e.storage&&t(E.storage)}},[Q,E,Ke,Le,G.data]);(0,q.useEffect)(()=>{!e||!X||F!=null&&Z||(oe(X),se(U))},[e,X,U,F,Z]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:z?`pro`:he,targets:Y,actuals:X,initialActuals:Z?F:null,resizeOperationInFlight:ze,sawOperation:ne&&Be,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&G.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&z&&!rt;(0,q.useEffect)(()=>{fe(it)},[it]),(0,q.useEffect)(()=>{if(!e||!z||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,z,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&Be);return(0,q.useEffect)(()=>{if(!e||!z||rt||!at)return;let t=setInterval(()=>V(`auto`),n);return()=>clearInterval(t)},[e,z,rt,at,n,V]),{state:tt,softWaiting:nt,targets:Y,actualsSnapshot:F,machineFloor:Ve,landed:qe,assistantId:U,domainStepAvailable:He,onboardingSettled:Ee,confirmError:!z&&pe.isError,targetsError:z&&H.isError&&(!J||!Te),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:Se,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,q.useState)(`provisioning`),[d,f]=(0,q.useState)(`idle`),p=(0,q.useRef)([]),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,q.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,q.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,ie=o?a?.fromSnapshot:void 0,P=w.actualsSnapshot,F={machineSize:ie?.machineSize??P?.machineSize??null,storageGib:ie?.storageGib??P?.storageGib??null},{tintHex:ae,backdropImageUrl:oe}=xt(j),I=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&I,j),L=(se?.results.length??0)>0,R=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!e){R.current=null;return}!I||j==null||R.current!==j&&(R.current=j,c.invalidateQueries({queryKey:pe({path:{assistant_id:j}})}))},[e,I,j,c]);let fe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[z,me]=(0,q.useState)(!1),he=N&&(!I||fe);(0,q.useEffect)(()=>{if(!e){me(!1);return}he&&me(!0)},[e,he]);let ge=(0,q.useCallback)(()=>{let e=o?M===!0&&!L?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,L]),_e=(0,q.useCallback)(()=>{x(!0)},[]),ve=(0,q.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,q.useCallback)(()=>{x(!1)},[]),be=l===`provisioning`&&(w.confirmError||w.targetsError),B=l===`provisioning`&&!be,xe=B&&!k,V=`transition-[background-color] duration-300 ease-out${B?` bg-black p-0`:``}`,Se=B?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!xe,onEscapeKeyDown:xe?e=>e.preventDefault():void 0,onInteractOutside:xe?e=>e.preventDefault():void 0,"data-theme":B?`dark`:void 0,overlayClassName:V,className:B?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ae},children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${Se}`,children:H()},l),d!==`idle`&&(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:oe&&(0,K.jsx)(mt,{imageUrl:oe,animateIn:!1})})]})}),(0,K.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function H(){return l===`provisioning`?w.confirmError||w.targetsError?(0,K.jsx)(ot,{onGoToBilling:t,direction:S}):(0,K.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:F,machineFloor:w.machineFloor,landed:w.landed,celebrating:z,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,K.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,K.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=U();return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,K.jsx)(Ee,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,K.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?W[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Re,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=Ae[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?G[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);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 Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(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 Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,q.useEffect)(()=>I(()=>{t.invalidateQueries(me())}),[t]),z({onSuccess:t=>{e&&xn(e),oe(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({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=G[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)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 Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(ve());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ae(),r=e&&n,i=c({...me(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...ye(),enabled:r&&o}),d=c({...se(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(he()),m=l(fe()),h=l(be()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:B()}),t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:R()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,K.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,q.useState)(()=>c?.machineTier??``),[d,f]=(0,q.useState)(()=>c?.storageTier??``),[p,m]=(0,q.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,q.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,q.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,q.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,K.jsx)(Re,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],te=x.find(e=>e.tier===l)??null,M=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(M||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,ie=te!=null&&N!=null&&re!=null,P=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),F=(0,q.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,K.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,K.jsx)(T.Body,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,K.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,K.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,K.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,K.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,K.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,K.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(F.totalCents)}),F.deltaCents!=null&&F.deltaCents!==0&&F.previousTotalCents!=null&&(0,K.jsxs)(`span`,{className:`text-[12px] font-medium ${F.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(F.deltaCents),` compared to previous (`,st(F.previousTotalCents),`)`]}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.rows.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,K.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,K.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,K.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!ie||P||r,onClick:()=>{!ie||P||r||s({machineTier:te.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,K.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:H(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,K.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,K.jsx)(Te,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,q.useRef)(null),l=(0,q.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,K.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,K.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,K.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,K.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,K.jsx)(Kn,{}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,K.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,K.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,K.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,K.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,K.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,K.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,K.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,K.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,q.useEffect)(()=>I(()=>{e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,ze as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-BwFudwM5.js";import{n as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{c as a,g as o,n as s}from"./QueryClientProvider-CMu7CkQU.js";import{t as c}from"./useQuery-Bz-fbQ-m.js";import{t as l}from"./useMutation-CXGTrp4W.js";import{t as u}from"./jsx-runtime-D3ZM-ToX.js";import{t as d}from"./typography-DEI9Ra9z.js";import{t as f}from"./createLucideIcon-CAM1RhH8.js";import{t as p}from"./arrow-right-ChqGeAaW.js";import{t as m}from"./check-Dt2rQhdg.js";import{t as h}from"./circle-alert-DQMH8VJH.js";import{t as g}from"./circle-check-DvrCdroD.js";import{t as _}from"./coins-CcTuNVlN.js";import{n as v,t as y}from"./sliders-horizontal-BwdOIxz8.js";import{t as b}from"./hard-drive-sI2ZzmqM.js";import{t as x}from"./info-DkhVkzmK.js";import{t as S}from"./loader-circle-DWWXcfTQ.js";import{t as C}from"./triangle-alert-D6bAGtMw.js";import{t as w}from"./notice-Dslxs3H6.js";import{t as T}from"./modal-DagTZ8xj.js";import{n as E}from"./toast-BHjG1kP8.js";import{t as ee}from"./confirm-dialog-B7WBNDbT.js";import{t as D}from"./dropdown-CJVkL1Yp.js";import{n as O}from"./resolved-assistants-store-C6oDdTxB.js";import{at as k,d as A,f as j,l as te,tt as M,u as N}from"./auth-store-C9aYqB9U.js";import{S as ne,b as re}from"./native-biometric-DetUqtjl.js";import{d as ie}from"./routes-DrfnNoYS.js";import{d as P}from"./platform-detection-AHYibqOx.js";import{n as F}from"./use-assistant-avatar-Bjqx8JUy.js";import{r as ae}from"./use-is-org-ready-3vHDbj4G.js";import{n as oe,r as I}from"./browser-CcdNg0HN.js";import{$ as se,C as ce,O as le,at as ue,c as de,ct as L,et as R,it as fe,jt as z,l as pe,lt as me,nt as he,ot as ge,r as _e,rt as ve,st as ye,tt as be,ut as B,y as xe}from"./react-query.gen-BtYBixpk.js";import{t as V}from"./avatar-bundled-components-BvKt7I7O.js";import{r as Se}from"./use-avatar-accent-var-BafXGBXW.js";import{t as H}from"./misc-BBsGq1IU.js";import{n as Ce,t as we}from"./avatar-tone-D99t9DAP.js";import{t as Te}from"./chat-avatar-B5fx9Xm3.js";import{t as Ee}from"./avatar-renderer-TpNgmnU1.js";import{n as U}from"./use-bundled-avatar-components-BcyasJwu.js";import{t as De}from"./android-consumption-only-D3L1Nc41.js";import{c as Oe,i as W,l as ke,n as G,r as Ae,t as je}from"./machine-sizes-B9nt_h-U.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./provisioning-targets-Cah9jNBe.js";import{t as Le}from"./environment-store-DxX3xxt2.js";var Re=f(`computer`,[[`rect`,{width:`14`,height:`8`,x:`5`,y:`2`,rx:`2`,key:`wc9tft`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h2`,key:`rwmk9e`}],[`path`,{d:`M12 18h6`,key:`aqd8w3`}]]),K=u();function ze({children:e,redirectToBilling:t=!1}){return P()?t?(0,K.jsx)(r,{replace:!0,to:ie.settings.usageBilling}):(0,K.jsx)(w,{tone:`info`,children:De}):e}var q=e(t(),1);function Be({icon:e}){return(0,K.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-negative-strong) 12%, transparent)`},children:(0,K.jsx)(e,{className:`h-5 w-5`,style:{color:`var(--system-negative-strong)`},"aria-hidden":`true`})})}var J={fontFamily:`var(--font-serif)`,fontSize:`32px`,fontWeight:400,lineHeight:1.2,letterSpacing:`0.64px`};function Y({title:e,subtitle:t}){return(0,K.jsxs)(`header`,{className:`flex flex-col items-center gap-2 pt-12 text-center`,children:[(0,K.jsx)(`h2`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(`p`,{className:`text-[14px] font-normal text-[var(--content-secondary)]`,children:t})]})}var Ve=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1},{bodyShape:`stack`,eyeStyle:`gentle`,color:`purple`,size:110,position:`-left-[39px] top-[74%]`,rotate:0},{bodyShape:`urchin`,eyeStyle:`goofy`,color:`pink`,size:137,position:`-right-[42px] -bottom-[40px]`,rotate:180},{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`,size:72,position:`left-[37%] -bottom-[22px] -translate-x-1/2`,rotate:0}],He=[{bodyShape:`star`,eyeStyle:`curious`,color:`yellow`,size:103,position:`-left-[28px] -top-[33px]`,rotate:180},{bodyShape:`star`,eyeStyle:`curious`,color:`orange`,size:109,position:`left-[63%] -top-[62px] -translate-x-1/2`,rotate:-8},{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`,size:76,position:`-right-[25px] top-[60px]`,rotate:1}];function Ue({variant:e=`full`}){let t=U();return t?(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`creature-corners`,className:`pointer-events-none absolute inset-0 select-none`,children:(e===`top`?He:Ve).map((e,n)=>(0,K.jsx)(`span`,{className:`absolute ${e.position}`,style:{rotate:`${e.rotate}deg`},children:(0,K.jsx)(Ee,{components:t,bodyShapeId:e.bodyShape,eyeStyleId:e.eyeStyle,colorId:e.color,size:e.size})},n))}):null}var X={waitingStatus:`Upgrading your assistant…`,snagStatus:`We hit a snag upgrading your assistant`,snagCaption:`Retry in the background and we'll keep working on your upgrade.`,confirmingStatus:`Confirming your upgrade…`,confirmTimeoutStatus:`Still confirming your upgrade`,confirmTimeoutCaption:`Your payment went through safely. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still upgrading. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your upgrade continues in the background.`,backgroundRetryToast:`We'll retry your upgrade in the background.`,completeSubtitle:`Enjoy the new found power.`,fetchErrorBody:`We hit a problem checking your subscription. Your upgrade may still be processing. Return to billing to refresh.`},Z={waitingStatus:`Updating your assistant…`,snagStatus:`We hit a snag updating your assistant`,snagCaption:`Retry in the background and we'll keep working on your plan change.`,confirmingStatus:`Confirming your plan change…`,confirmTimeoutStatus:`Still confirming your plan change`,confirmTimeoutCaption:`Your plan change was submitted. This can take a minute.`,backgroundConfirmMessage:`Your assistant is still updating. Chatting won't be available until it finishes. You can keep waiting here, or continue and we'll let you know when it's ready.`,backgroundExitToast:`Your plan change continues in the background.`,backgroundRetryToast:`We'll retry your plan change in the background.`,completeSubtitle:`Your plan changes are live.`,fetchErrorBody:`We hit a problem checking your subscription. Your plan change may still be processing. Return to billing to refresh.`},Q={upgrade:X,downgrade:Z,change:Z};function We(e=`upgrade`){return Q[e]}function Ge(e,t=!0){let{data:n}=c({..._e(),enabled:t&&e==null}),{data:r}=c({...le({path:{id:e??``}}),enabled:t&&e!=null});return e==null?n:r}function Ke({assistantId:e,direction:t}){let r=i(),a=Ge(e,ae())?.name||`your assistant`;return(0,K.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 pb-16 [animation:onboarding-step-in_350ms_ease-out] motion-reduce:[animation:none]`,children:[(0,K.jsx)(Ue,{variant:`full`}),(0,K.jsxs)(`div`,{className:`relative flex w-full flex-col items-center`,children:[(0,K.jsx)(Y,{title:`You're all set!`,subtitle:We(t).completeSubtitle}),(0,K.jsx)(`div`,{className:`mt-10 flex w-full flex-col items-center gap-10`,children:(0,K.jsxs)(n,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>{e!=null&&M(e),r(ie.assistant,{replace:!0})},children:[`Return to `,a]})})]})]})}function qe(e=!0,t){let n=Ge(t,e),r=t??n?.id,{data:i,isError:a,isFetching:o,dataUpdatedAt:s,errorUpdatedAt:l}=c({...de({path:{assistant_id:r??``}}),enabled:e&&!!r});return{assistant:n,assistantId:r,domains:i,domainsError:a,domainsFetching:o,domainsUpdatedAt:s,domainsErrorUpdatedAt:l}}var Je=1e3,Ye=1e4,Xe=2500,Ze=2e3,Qe=1e4,$e=[`machine_size`,`subdomain`,`non_field_errors`],et={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.`,provisioning_submission_failed:`We couldn't queue your upgrade just now. Try again in a moment.`,no_active_pro:`We couldn't confirm your Pro plan yet. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to upgrade yet. Try again in a moment.`},tt={provisioning_submission_failed:`We couldn't queue your plan change just now. Try again in a moment.`,no_provisionable_assistants:`We couldn't find an assistant to update yet. Try again in a moment.`};function nt(e,t,n=`upgrade`){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=(n===`upgrade`?void 0:tt[t.error])??et[t.error];if(e)return e}for(let e of $e){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}var rt=`h-8 rounded-lg border border-[var(--border-element)] bg-[var(--field-bg)] px-2.5 text-[14px] text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none transition-[border-color] duration-150 focus:border-[var(--border-active)] disabled:cursor-not-allowed disabled:opacity-60`,it=`text-[11px] font-medium text-[var(--content-secondary)]`;function at({onExit:e,machineBusy:t=!1,assistantId:r}){let i=s(),a=Le.use.emailRootDomain(),{assistant:o,assistantId:c,domains:u}=qe(!0,r),d=u?.results[0],[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(`hi`),[g,_]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!g){if(d){p(d.subdomain),_(!0);return}!o?.handle||f||(p(o.handle),_(!0))}},[o?.handle,d,g,f]);let[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=l(ue()),C=!!d||b,E=S.isPending||b;return(0,q.useEffect)(()=>{if(!b)return;let t=setTimeout(e,800);return()=>clearTimeout(t)},[b,e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(T.Body,{className:`animate-[onboarding-step-in_350ms_ease-out] space-y-6 pb-0 motion-reduce:animate-none`,children:[(0,K.jsx)(Ue,{variant:`top`}),(0,K.jsx)(Y,{title:`Assistant Email`,subtitle:`Set up an email for your assistant.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-prefix`,className:it,children:`Prefix`}),(0,K.jsx)(`input`,{id:`onboarding-email-prefix`,value:m,onChange:e=>h(e.target.value.toLowerCase().trim()),disabled:E||C,readOnly:C,placeholder:`hi`,className:`${rt} w-24`})]}),(0,K.jsx)(`span`,{className:`flex h-8 items-center text-[var(--content-secondary)]`,children:`@`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(`label`,{htmlFor:`onboarding-email-handle`,className:it,children:`Handle (public)`}),(0,K.jsx)(`input`,{id:`onboarding-email-handle`,value:f,onChange:e=>{p(e.target.value.toLowerCase().trim()),v&&y(null)},disabled:E||C,readOnly:C,autoFocus:!0,placeholder:`my-assistant`,"aria-invalid":!!v,className:`${rt} w-full min-w-0`})]}),(0,K.jsxs)(`span`,{className:`flex h-8 shrink-0 items-center text-[14px] text-[var(--content-tertiary)]`,children:[`.`,a]})]}),v&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:v}),C&&(0,K.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`This domain has been set and cannot be changed.`})]}),t&&!C&&(0,K.jsx)(w,{tone:`neutral`,children:`Your assistant is restarting — you can set the domain in a moment.`}),!C&&(0,K.jsx)(w,{tone:`info`,className:`border-transparent bg-[var(--surface-active)]`,children:(0,K.jsx)(`span`,{className:`font-medium text-[var(--content-tertiary)]`,children:`You won't be able to change the handle once set.`})}),b?(0,K.jsx)(w,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,K.jsx)(T.Footer,{className:`items-center pt-6`,children:C?(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:e,children:`Continue`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-domain-skip`,disabled:E,onClick:()=>{E||S.mutate({body:{skipped:!0}},{onSuccess:e,onError:()=>e()})},children:`Skip`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||E||t,onClick:()=>{E||t||!f||S.mutate({body:{subdomain:f,...m?{email_username:m}:{}}},{onSuccess:()=>{y(null),x(!0),i.invalidateQueries({queryKey:xe()}),i.invalidateQueries({queryKey:pe({path:{assistant_id:c??``}})}),i.invalidateQueries({queryKey:L()})},onError:e=>{y(nt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Next`})]})})]})}function ot({onGoToBilling:e,direction:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,K.jsx)(Be,{icon:h}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(d,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:We(t).fetchErrorBody})]}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function st(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function $(e){return`${st(e)}/mo`}function ct(e){return`${e>0?`+`:`−`}${st(Math.abs(e))}/mo`}function lt(e){return`${e} GB storage`}function ut(e){return`${st(e*100)} of bundled credits`}function dt(e){let{targets:t,fromSnapshot:n,machineFloor:r,credits:i}=e,a=[];return t.machineSize==null?r!=null&&n.machineSize!=null&&n.machineSize!==r&&a.push({key:`machine`,label:`Machine`,from:W[n.machineSize],to:W[r]}):n.machineSize!==t.machineSize&&a.push({key:`machine`,label:`Machine`,from:n.machineSize==null?void 0:W[n.machineSize],to:W[t.machineSize]}),t.storageGib!=null&&(n.storageGib==null||t.storageGib>n.storageGib)&&a.push({key:`storage`,label:`Storage`,from:n.storageGib==null?void 0:`${n.storageGib} GB`,to:`${t.storageGib} GB`}),i!=null&&a.push({key:`credits`,label:`Credits`,from:i.from,to:i.to}),a}var ft=60,pt=ft*2;function mt({imageUrl:e,animateIn:t=!0}){return(0,K.jsxs)(`div`,{"aria-hidden":!0,"data-testid":`takeover-backdrop`,className:`pointer-events-none absolute inset-0 overflow-hidden${t?` provision-avatar-reveal`:``}`,children:[(0,K.jsx)(`img`,{src:e,alt:``,decoding:`async`,draggable:!1,className:`absolute left-1/2 top-1/2 max-w-none -translate-x-1/2 -translate-y-1/2 object-cover object-center`,style:{filter:`blur(${ft}px)`,width:`calc(100% + ${pt*2}px)`,height:`calc(100% + ${pt*2}px)`}}),(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/55`})]})}function ht(e){let t=e?.match(/^credits_(\d+)$/)?.[1];return t==null?null:Number(t)}function gt(e,t){if(t!=null)return e?.credit_tiers?.find(e=>e.tier===t)}function _t(e){let t=ae(),{data:n}=c({...se(),enabled:t&&e});return n?.plans.find(e=>e.id===`pro`)}function vt(e,t){return t==null?0:gt(e,t)?.credits_usd??ht(t)}function yt(e){let t=_t(e!=null);if(e==null||t==null)return null;let n;if(e.kind===`package`){let r=t.packages.find(t=>t.key===e.packageKey);n=r?.credits_usd??gt(t,r?.credit_tier)?.credits_usd}else n=gt(t,e.creditTier)?.credits_usd;return n==null?null:{fromUsd:0,toUsd:n}}function bt(e){let t=_t(e!=null);if(e==null)return null;let n=vt(t,e.fromTier),r=vt(t,e.toTier);return n==null||r==null?null:{fromUsd:n,toUsd:r}}function xt(e){let t=O.use.activeAssistantId(),n=e===void 0?t:e,{components:r,traits:i,customImageUrl:a,isLoading:o}=F(n),s=(0,q.useMemo)(()=>A(),[j()]),c=s!=null&&N(s)?s:null,l=n!=null&&!o,u=c!=null&&(n==null||n===c.assistantId),d=u&&!(l&&(r!=null||i!=null||a!=null))?c:null,f=d?d.components:r,p=d?d.traits:i,m=d?null:a,h=l||u,g=Se(f,p)??(m?null:(f??V).colors?.[0]?.hex??null);return{tintHex:h&&g?Ce(g):we,backdropImageUrl:h?m:null,ready:h,avatar:{components:f,traits:p,customImageUrl:m}}}function St(e,t){let[n,r]=(0,q.useState)(e),i=(0,q.useRef)(0);return(0,q.useEffect)(()=>{i.current=performance.now()},[]),(0,q.useEffect)(()=>{if(t<=0||e===n)return;let a=t-(performance.now()-i.current);if(a<=0){i.current=performance.now(),r(e);return}let o=setTimeout(()=>{i.current=performance.now(),r(e)},a);return()=>clearTimeout(o)},[e,n,t]),t<=0?e:n}var Ct=`--takeover-surface`,wt=`var(${Ct},${we})`,Tt=`color-mix(in srgb, var(--content-emphasised) 10%, transparent)`,Et=240,Dt=1.414,Ot=[{minHeight:680,size:Et},{minHeight:600,size:184}],kt=132;function At(e){for(let t of Ot)if(e>=t.minHeight)return t.size;return kt}function jt(){let[e,t]=(0,q.useState)(()=>At(typeof window>`u`?1/0:window.innerHeight));return(0,q.useEffect)(()=>{let e=()=>t(At(window.innerHeight));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var Mt={machine:v,storage:b,credits:_},Nt={idle:``,working:` is-working`,settling:` is-settling`,stalled:` is-stalled`,grown:` is-evolved`};function Pt(e,t){return e===`DONE`||e===`NOT_APPLICABLE`?`grown`:e===`STALLED`?`stalled`:e===`WAITING`||e===`RESIZING`?t?`settling`:`working`:`idle`}function Ft({assistantId:e,mode:t,downsizing:n=!1}){let{avatar:r,ready:i}=xt(e),a=U(),o=jt(),s=t===`working`||t===`settling`;return(0,K.jsxs)(`div`,{"aria-hidden":!0,className:`provision-avatar-evolve relative z-10 flex flex-col items-center${Nt[i?t:`idle`]}${n?` is-downsizing`:``}`,style:{"--provision-avatar-size":`${o}px`,"--provision-avatar-growth":Dt},children:[(0,K.jsxs)(`div`,{className:`provision-avatar-stage`,children:[(0,K.jsx)(`div`,{"data-testid":`provision-avatar-placeholder`,className:`provision-avatar-placeholder${i?` is-resolved`:``}`}),(0,K.jsx)(`div`,{className:`provision-avatar-layer`,children:(0,K.jsx)(`div`,{className:`provision-avatar-current`,children:(0,K.jsx)(`div`,{className:`provision-avatar-strain`,children:i&&(0,K.jsx)(`div`,{className:`provision-avatar-reveal`,children:(0,K.jsx)(Te,{components:r.components??a,traits:r.traits,customImageUrl:r.customImageUrl,size:o,isAssistantBusy:s})})})})})]}),(0,K.jsx)(`div`,{className:`provision-avatar-shadow`})]})}function It({status:e,caption:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,K.jsx)(`h1`,{className:`text-[var(--content-emphasised)]`,style:J,children:e}),t&&(0,K.jsx)(d,{variant:`body-medium-lighter`,as:`p`,className:`max-w-sm text-[var(--content-secondary)]`,children:t})]})}function Lt({icon:e,label:t,from:n,to:r,done:i=!1,pending:a=!1,testId:o}){let s=null;return i?s=`Complete`:a&&(s=`Pending`),(0,K.jsxs)(`div`,{"data-testid":o,className:`flex min-w-0 flex-auto items-center gap-2 rounded-lg px-2 py-1.5${a?` opacity-70`:``}`,style:{backgroundColor:Tt},children:[(0,K.jsx)(`span`,{className:`hidden h-6 w-6 shrink-0 items-center justify-center min-[420px]:flex`,children:(0,K.jsx)(e,{className:`h-3.5 w-3.5 text-[var(--content-tertiary)]`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-left wrap-anywhere`,children:[(0,K.jsx)(`span`,{className:`text-[12px] font-medium leading-tight text-[var(--content-tertiary)]`,children:t}),(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-[14px] font-medium leading-[18px] text-[var(--content-emphasised)]`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`span`,{className:`sr-only`,children:`to`}),(0,K.jsx)(p,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":`true`})]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{children:r}),i?(0,K.jsx)(m,{"data-testid":`chip-check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--system-positive-strong)]`,"aria-hidden":`true`}):a&&(0,K.jsx)(S,{"data-testid":`chip-spinner`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-[var(--content-tertiary)] motion-reduce:animate-none`,"aria-hidden":`true`})]}),s&&(0,K.jsx)(`span`,{className:`sr-only`,children:s})]})]})]})}function Rt({label:e}){return(0,K.jsx)(`span`,{className:`rounded-lg px-3 py-2 text-[14px] text-[var(--content-emphasised)]`,style:{backgroundColor:Tt},children:e})}function zt({children:e,wide:t=!1,testId:n}){return(0,K.jsx)(`div`,{"data-testid":n,className:`flex w-full ${t?`max-w-2xl`:`max-w-sm`} items-stretch justify-center gap-2`,children:e})}function Bt(e,t){return e===`credits`?!0:t?.[e]===!0}function Vt({intent:e,creditsChange:t,targets:n,fromSnapshot:r,machineFloor:i,landed:a,allDone:o=!1,creditsOnly:s=!1}){let c=yt(e),l=bt(t),u=c??l,d=dt({targets:n,fromSnapshot:r,machineFloor:i,credits:u==null?null:{from:$(u.fromUsd*100),to:$(u.toUsd*100)}}),f=s?d.filter(e=>e.key===`credits`):d,p=f.filter(e=>o||Bt(e.key,a)).map(e=>e.label).join(`, `),[m]=(0,q.useState)(p),h=p===m?``:`${p} complete`;return f.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zt,{testId:`resource-chips`,wide:f.length>=3,children:f.map(e=>{let t=o||Bt(e.key,a);return(0,K.jsx)(Lt,{testId:`chip-${e.key}`,icon:Mt[e.key],label:e.label,from:e.from,to:e.to,done:t,pending:!t},e.key)})}),(0,K.jsx)(`p`,{"aria-live":`polite`,className:`sr-only`,"data-testid":`chip-announcement`,children:h})]})}function Ht({intent:e}){if(e.kind===`package`)return(0,K.jsx)(zt,{children:(0,K.jsx)(Rt,{label:`${e.packageKey.charAt(0).toUpperCase()+e.packageKey.slice(1)} package`})});let t=[e.machineTier,e.storageTier,e.creditTier].filter(e=>e!=null).length;return(0,K.jsxs)(zt,{wide:t>=3,children:[e.machineTier!=null&&(0,K.jsx)(Lt,{icon:v,label:`Machine`,to:G[e.machineTier]??e.machineTier}),e.storageTier!=null&&(0,K.jsx)(Lt,{icon:b,label:`Storage`,to:e.storageTier.toUpperCase()}),e.creditTier!=null&&(0,K.jsx)(Rt,{label:`${e.creditTier.replace(`credits_`,``)} credits`})]})}function Ut({state:e,direction:t,softWaiting:r,intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,celebrating:u,onCelebrationEnd:d,assistantId:f,escapeAvailable:p,onEscape:m,onPhaseChange:h,kickError:g,confirm:_,dwellMs:v=Xe,phaseMinMs:y=900}){let b=We(t),x=(0,q.useRef)(d);(0,q.useEffect)(()=>{x.current=d},[d]);let S=St(e,y),C=S===`DONE`||S===`NOT_APPLICABLE`,w=S===`RESIZING`?`WAITING`:S,T=(0,q.useRef)(h);(0,q.useEffect)(()=>{T.current=h},[h]),(0,q.useEffect)(()=>{T.current?.(S)},[S]);let{tintHex:E,backdropImageUrl:ee}=xt(f),D=u&&C;return(0,q.useEffect)(()=>{if(!D)return;let e=setTimeout(()=>x.current(),v);return()=>clearTimeout(e)},[D,v]),(0,K.jsxs)(`div`,{"data-theme":`dark`,className:`provision-surface-settle relative flex h-full min-h-[420px] w-full flex-col items-center [justify-content:safe_center] gap-10 px-6 py-10 text-center`,style:{[Ct]:E,backgroundColor:wt},children:[ee&&(0,K.jsx)(mt,{imageUrl:ee}),(0,K.jsx)(Ft,{assistantId:f,mode:Pt(S,r),downsizing:t===`downgrade`}),(0,K.jsx)(`div`,{className:`relative z-10 flex min-h-[144px] w-full flex-col items-center gap-8 [animation:onboarding-step-in_420ms_ease-out] motion-reduce:[animation:none]`,children:A()},w)]});function O(e=`Continue in the background`){return p?(0,K.jsx)(n,{variant:`ghost`,"data-testid":`provisioning-escape`,onClick:m,children:e}):null}function k({allDone:e=!1,creditsOnly:t=!1}={}){return(0,K.jsx)(Vt,{intent:i,creditsChange:a,targets:o,fromSnapshot:s,machineFloor:c,landed:l,allDone:e,creditsOnly:t})}function A(){if(S===`CONFIRMING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmingStatus,caption:`This might take a couple seconds.`}),i&&(0,K.jsx)(Ht,{intent:i}),O()]});if(S===`WAITING`||S===`RESIZING`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.waitingStatus,caption:r?`Still working — this can take a minute or two.`:`This might take a couple seconds.`}),k(),O()]});if(S===`DONE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`All done!`}),k({allDone:!0})]});if(S===`NOT_APPLICABLE`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:`Your plan is ready`}),k({allDone:!0,creditsOnly:!0})]});if(S===`STALLED`){let e=g!=null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:e?b.snagStatus:`This is taking longer than expected`,caption:e?nt(g,b.snagCaption,t):`This may take a couple of minutes.`}),k(),e?O(`Retry in the background`):O()]})}return S===`CONFIRM_TIMEOUT`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(It,{status:b.confirmTimeoutStatus,caption:b.confirmTimeoutCaption}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,K.jsx)(n,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:_.onGoToBilling,children:`Go to billing`}),(0,K.jsx)(n,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:_.onRetry,children:`Try again`})]})]}):null}}function Wt(e){let{planId:t,targets:n,actuals:r,initialActuals:i,resizeOperationInFlight:a,sawOperation:o,msSinceWatchStart:s,confirmExpired:c,serverVerdict:l=null,statusObservedSinceTargetsMet:u=!0,targetsProveNoop:d=!0}=e;if(t!==`pro`)return{state:c?`CONFIRM_TIMEOUT`:`CONFIRMING`,softWaiting:!1};let f=o||a,p=l===`started`||l===`in_progress`,m=o||d&&u;if(!a){let e=p?m:f||l===`already_done`||i!=null&&!Me(n,i);if(Me(n,r)){if(e)return{state:`DONE`,softWaiting:!1};if(!p&&(d||l===`not_applicable`))return{state:`NOT_APPLICABLE`,softWaiting:!1}}else{if(l===`already_done`)return{state:`DONE`,softWaiting:!1};if(l===`not_applicable`)return{state:`NOT_APPLICABLE`,softWaiting:!1}}}return s!=null&&s>=9e4?{state:`STALLED`,softWaiting:!1}:f||l===`started`||l===`in_progress`?{state:`RESIZING`,softWaiting:!1}:{state:`WAITING`,softWaiting:s!=null&&s>=3e4}}var Gt=2e3,Kt=1e3,qt=[`DONE`,`NOT_APPLICABLE`,`CONFIRM_TIMEOUT`],Jt={assistantId:null,machine:null,storage:null};function Yt({open:e,canLowerResources:t=!1,verdictRecheckMs:n=Qe}){let r=s(),i=ae(),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),[E,ee]=(0,q.useState)(Jt),[D,O]=(0,q.useState)(null),[A,j]=(0,q.useState)(!1),te=(0,q.useRef)(!1),M=(0,q.useRef)(!1),N=(0,q.useRef)(0),[ne,re]=(0,q.useState)(!1),[ie,P]=(0,q.useState)(null),[F,oe]=(0,q.useState)(null),[I,se]=(0,q.useState)(null),[ue,de]=(0,q.useState)(()=>Date.now()),[R,fe]=(0,q.useState)(!0);(0,q.useEffect)(()=>{e||(d(!1),p(0),h(null),_(null),y(null),re(!1),P(null),oe(null),se(null),fe(!0),x(null),C(null),T(null),ee(Jt),O(null),j(!1),te.current=!1,M.current=!1,N.current+=1)},[e]),(0,q.useEffect)(()=>{e&&(h(Date.now()),r.invalidateQueries({queryKey:B()}),r.invalidateQueries({queryKey:L()}))},[e,r]);let z=g!=null,pe=c({...me(),refetchInterval:e=>e.state.data?.plan_id===`pro`||u?!1:Je,refetchIntervalInBackground:!1,enabled:e&&i&&!z}),he=(m!=null&&pe.dataUpdatedAt>=m?pe.data?.plan_id:null)??null;(0,q.useEffect)(()=>{if(!e||z||he!==`pro`)return;let t=Date.now();_(t),de(t)},[e,z,he]),(0,q.useEffect)(()=>{if(!e||z)return;let t=setTimeout(()=>d(!0),Ye);return()=>clearTimeout(t)},[e,z,f]);let ve=(0,q.useCallback)(()=>{d(!1),p(e=>e+1),k.getState().fetchOrganizations(),r.invalidateQueries({queryKey:B()})},[r]),be=(0,q.useCallback)(()=>{let e=Date.now();y(e),de(e)},[]),{mutate:xe}=l(ge()),V=(0,q.useCallback)(e=>{let t=N.current;xe({},{onSuccess:n=>{t===N.current&&(O(null),Pe(n)?M.current?O({error:n.reason??`no_active_pro`}):(M.current=!0,j(!0),e===`escape`&&be()):(x(n.state),e===`escape`&&be()))},onError:e=>{t===N.current&&O(e)}})},[xe,be]);(0,q.useEffect)(()=>{!e||!i||!z||te.current||(te.current=!0,V(`auto`))},[e,i,z,V]),(0,q.useEffect)(()=>{if(!A)return;let e=N.current,t=setTimeout(()=>{j(!1),e===N.current&&V(`auto`)},Ze);return()=>clearTimeout(t)},[A,V]);let Se=(0,q.useCallback)(()=>V(`escape`),[V]),H=c({...ye(),enabled:e&&i&&z}),Ce=R?Gt:!1,we=c({..._e(),enabled:e&&i&&z,refetchInterval:e=>e.state.data?.id==null?Ce:!1,retry:!1}),Te=z&&m!=null&&H.dataUpdatedAt>=m,Ee=Te&&!H.isPending&&!H.isFetching,U=(Te?H.data?.primary_assistant_id:null)??(H.isPending?null:we.data?.id??null),De=c({...le({path:{id:U??`unresolved`}}),enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),W=ce({path:{id:U??`unresolved`}}),G=c({...W,enabled:e&&i&&z&&U!=null,refetchInterval:Ce,retry:!1}),Ae=(0,q.useRef)(0),[Le,Re]=(0,q.useState)(0),K=o(W.queryKey);(0,q.useEffect)(()=>r.getQueryCache().subscribe(t=>{if(!(t.type!==`updated`||t.query.queryHash!==K)){if(t.action.type===`fetch`)Ae.current+=1;else if(t.action.type===`success`&&!t.action.manual){let n=Ae.current,r=e&&Fe(t.action.data);a.schedule(()=>{Re(n),r&&(re(!0),P(U))})}}}),[r,K,e,U]);let ze=Fe(G.data),Be=ie===U,J=H.data,Y=(0,q.useMemo)(()=>J?{machineSize:Oe(J.max_machine_tier),storageGib:J.selected_storage_gib??null}:null,[J]),Ve=J!=null&&J.max_machine_tier==null?je:null,He=J?J.domain_setup_available&&J.primary_assistant_id!=null:void 0,Ue=De.data,X=(0,q.useMemo)(()=>Ue?{machineSize:Ue.machine_size??null,storageGib:Ue.provisioned_storage_gib??null}:null,[Ue]),Z=I===U,Q=(0,q.useMemo)(()=>{let e=Ie(Y,X),t=Y?.machineSize??Ve;if(t==null)return e;let n=X?.machineSize??null;if(n==null)return{...e,machine:!1};let r=(Z?F?.machineSize:null)??n,i=ke(t)<ke(r);return{...e,machine:i?ke(n)<=ke(t):ke(n)>=ke(t)}},[Y,X,F,Z,Ve]),We=Me(Y,X),Ge=w===U;(0,q.useEffect)(()=>{e&&(We?(C(e=>e!=null&&Ge?e:Date.now()),T(U)):(C(null),T(null)))},[e,We,U,Ge]);let Ke=E.assistantId===U;(0,q.useEffect)(()=>{if(!e)return;let t=Ae.current;ee(e=>{let n=e.assistantId===U?e:Jt,r=Q.machine?n.machine??t:null,i=Q.storage?n.storage??t:null;return e.assistantId===U&&e.machine===r&&e.storage===i?e:{assistantId:U,machine:r,storage:i}})},[e,Q,U]);let qe=(0,q.useMemo)(()=>{let e=Ne(G.data),t=e=>e!=null&&Ke&&Le>e;return{machine:Q.machine&&!e.machine&&t(E.machine),storage:Q.storage&&!e.storage&&t(E.storage)}},[Q,E,Ke,Le,G.data]);(0,q.useEffect)(()=>{!e||!X||F!=null&&Z||(oe(X),se(U))},[e,X,U,F,Z]);let Xe=v??g,$e=Xe==null?null:Math.max(0,ue-Xe),et=!t,{state:tt,softWaiting:nt}=Wt({planId:z?`pro`:he,targets:Y,actuals:X,initialActuals:Z?F:null,resizeOperationInFlight:ze,sawOperation:ne&&Be,msSinceWatchStart:$e,confirmExpired:u,serverVerdict:b,statusObservedSinceTargetsMet:S!=null&&Ge&&G.dataUpdatedAt>S,targetsProveNoop:et}),rt=qt.includes(tt),it=e&&z&&!rt;(0,q.useEffect)(()=>{fe(it)},[it]),(0,q.useEffect)(()=>{if(!e||!z||rt)return;let t=setInterval(()=>de(Date.now()),Kt);return()=>clearInterval(t)},[e,z,rt]);let at=!et&&(b===`started`||b===`in_progress`)&&!(ne&&Be);return(0,q.useEffect)(()=>{if(!e||!z||rt||!at)return;let t=setInterval(()=>V(`auto`),n);return()=>clearInterval(t)},[e,z,rt,at,n,V]),{state:tt,softWaiting:nt,targets:Y,actualsSnapshot:F,machineFloor:Ve,landed:qe,assistantId:U,domainStepAvailable:He,onboardingSettled:Ee,confirmError:!z&&pe.isError,targetsError:z&&H.isError&&(!J||!Te),escapeEligible:$e!=null&&$e>=6e4,retryConfirm:ve,kickProvisioning:Se,kickError:D}}var Xt=200,Zt=380;function Qt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}var $t=e=>e===`WAITING`||e===`RESIZING`||e===`STALLED`,en=e=>e===`DONE`||e===`NOT_APPLICABLE`,tn={machineSize:null,storageGib:null};function nn({open:e,onClose:t,dwellMs:n,phaseMinMs:r,mode:i=`checkout`,resizeContext:a}){let o=i===`resize`,c=s(),[l,u]=(0,q.useState)(`provisioning`),[d,f]=(0,q.useState)(`idle`),p=(0,q.useRef)([]),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(!1),S=o?a?.direction:void 0,C=We(S),w=Yt({open:e,canLowerResources:o?a?.canLowerResources===!0:!1}),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(e){D.current=!0,h(o?null:ne()),y(e=>e??Date.now());return}p.current.forEach(clearTimeout),p.current=[],u(`provisioning`),f(`idle`),_(null),y(null),x(!1),D.current&&(D.current=!1,te())},[e,o]),(0,q.useEffect)(()=>()=>{p.current.forEach(clearTimeout)},[]),(0,q.useEffect)(()=>{l===`complete`&&re()},[l]);let O=$t(w.state),k=en(g??w.state),{targets:A,assistantId:j,domainStepAvailable:M,onboardingSettled:N}=w,ie=o?a?.fromSnapshot:void 0,P=w.actualsSnapshot,F={machineSize:ie?.machineSize??P?.machineSize??null,storageGib:ie?.storageGib??P?.storageGib??null},{tintHex:ae,backdropImageUrl:oe}=xt(j),I=o&&M===!0,{domains:se,domainsError:ce,domainsFetching:le,domainsUpdatedAt:ue,domainsErrorUpdatedAt:de}=qe(e&&I,j),L=(se?.results.length??0)>0,R=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!e){R.current=null;return}!I||j==null||R.current!==j&&(R.current=j,c.invalidateQueries({queryKey:pe({path:{assistant_id:j}})}))},[e,I,j,c]);let fe=!le&&(v!=null&&ue>=v||v!=null&&!!ce&&de>=v),[z,me]=(0,q.useState)(!1),he=N&&(!I||fe);(0,q.useEffect)(()=>{if(!e){me(!1);return}he&&me(!0)},[e,he]);let ge=(0,q.useCallback)(()=>{let e=o?M===!0&&!L?`domain`:`complete`:M===!1?`complete`:`domain`;if(Qt()){u(e);return}f(`covering`),p.current.push(setTimeout(()=>{u(e),f(`revealing`),p.current.push(setTimeout(()=>f(`idle`),Zt))},Xt))},[M,o,L]),_e=(0,q.useCallback)(()=>{x(!0)},[]),ve=(0,q.useCallback)(()=>{w.kickProvisioning(),E.info(w.kickError==null?C.backgroundExitToast:C.backgroundRetryToast),x(!1),t()},[w,t,C]),ye=(0,q.useCallback)(()=>{x(!1)},[]),be=l===`provisioning`&&(w.confirmError||w.targetsError),B=l===`provisioning`&&!be,xe=B&&!k,V=`transition-[background-color] duration-300 ease-out${B?` bg-black p-0`:``}`,Se=B?`[animation:fadeIn_0.45s_ease-out_both]`:d===`revealing`?`[animation:fadeInUp_0.42s_ease-out_0.12s_both]`:`[animation:fadeIn_0.25s_ease-out_both]`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(T.Content,{size:`md`,hideCloseButton:l!==`complete`,dismissOnOverlayClick:!xe,onEscapeKeyDown:xe?e=>e.preventDefault():void 0,onInteractOutside:xe?e=>e.preventDefault():void 0,"data-theme":B?`dark`:void 0,overlayClassName:V,className:B?`overflow-y-auto inset-0 max-w-none w-screen h-screen max-h-none rounded-none border-0`:`overflow-hidden`,style:{[Ct]:ae},children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col motion-reduce:[animation:none] ${Se}`,children:H()},l),d!==`idle`&&(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":`takeover-exit-sheet`,className:`pointer-events-none fixed inset-0 z-50 ${d===`covering`?`[animation:fadeIn_200ms_ease-in_both]`:`[animation:fadeIn_380ms_ease-out_both_reverse]`}`,style:{backgroundColor:wt},children:oe&&(0,K.jsx)(mt,{imageUrl:oe,animateIn:!1})})]})}),(0,K.jsx)(ee,{open:b&&O,title:`Continue in the background?`,message:C.backgroundConfirmMessage,confirmLabel:`Continue`,cancelLabel:`Keep waiting`,onConfirm:ve,onCancel:ye})]});function H(){return l===`provisioning`?w.confirmError||w.targetsError?(0,K.jsx)(ot,{onGoToBilling:t,direction:S}):(0,K.jsx)(Ut,{state:w.state,direction:S,softWaiting:w.softWaiting,intent:m,creditsChange:o?a?.credits:void 0,targets:A??tn,fromSnapshot:F,machineFloor:w.machineFloor,landed:w.landed,celebrating:z,onCelebrationEnd:ge,assistantId:j,escapeAvailable:O&&w.escapeEligible,onEscape:_e,onPhaseChange:_,kickError:w.kickError,confirm:{onRetry:w.retryConfirm,onGoToBilling:t},dwellMs:n,phaseMinMs:r}):l===`domain`?(0,K.jsx)(at,{machineBusy:O,assistantId:j,onExit:()=>u(`complete`)}):(0,K.jsx)(Ke,{assistantId:j,direction:S})}}function rn(e){return e!=null&&!e.customized}function an(e){return rn(e)?e.name:`Custom`}var on=[`mighty`,`super`,`ultra`],sn=[`free`,...on];function cn(e){return sn.indexOf(e)}function ln(e,t){if(e===null)return`upgrade`;let n=cn(e),r=cn(t);return n===-1||r===-1?`upgrade`:r===n?`current`:r<n?`downgrade`:`upgrade`}function un(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>on.indexOf(e.key)-on.indexOf(t.key));if(!t)return n[0];let r=n.findIndex(e=>e.key===t);return r===-1?n[0]:r>=n.length-1?null:n[r+1]}var dn={free:{bodyShape:`ninja`,eyeStyle:`angry`,color:`yellow`},mighty:{bodyShape:`blob`,eyeStyle:`grumpy`,color:`green`},super:{bodyShape:`urchin`,eyeStyle:`goofy`,color:`teal`},ultra:{bodyShape:`sprout`,eyeStyle:`curious`,color:`orange`}};function fn({tier:e,size:t=40}){let n=dn[e]??dn.free,r=U();return(0,K.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex shrink-0`,children:r?(0,K.jsx)(Ee,{components:r,bodyShapeId:n.bodyShape,colorId:n.color,size:t}):(0,K.jsx)(`div`,{style:{width:t,height:t}})})}var pn=`Small`;function mn(e){return e?.machine_size?W[e.machine_size]??e.machine_size:pn}function hn(e){let t=e?.credits_usd??0,n=e?.storage_gib??4;return[{icon:Re,label:`${mn(e)} Machine`},{icon:_,label:`${st(t*100)} credits`},{icon:b,label:`${n} GB`}]}function gn(e,t=[]){let n=e?.credits_usd??0,r=e?.storage_gib??4,i=Ae[e?.machine_size??`small`];return[`${mn(e)} machine${i?` (${i})`:``}`,lt(r),ut(n),...t]}var _n={machine:`Configurable machine size`,storage:`Configurable storage`,credits:`Pay-as-you-go and bundled credits`};function vn(e,t){let n=[`${e.machineTier?G[e.machineTier]??t.machine_tiers.find(t=>t.tier===e.machineTier)?.label??e.machineTier:pn} Machine`];if(e.storageGib!=null&&n.push(`${e.storageGib} GB`),e.creditTier!=null){let r=gt(t,e.creditTier)?.credits_usd??ht(e.creditTier);n.push(r==null?`Credit bundle`:`${r} credits/mo`)}return n}function yn(e,t){let n=new Set([_n.machine]);return e.storageGib!=null&&n.add(_n.storage),e.creditTier!=null&&n.add(_n.credits),[...vn(e,t),...t.included_features.filter(e=>!n.has(e))]}var bn=`billing-portal-return-snapshot`;function xn(e){try{sessionStorage.removeItem(bn),sessionStorage.setItem(bn,JSON.stringify(e))}catch{}}function Sn(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(bn);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 Cn(){try{sessionStorage.removeItem(bn)}catch{}}function wn(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 Tn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function En(e){return e?e.cancel_at??e.current_period_end??null:null}function Dn(e){let t=s();return(0,q.useEffect)(()=>I(()=>{t.invalidateQueries(me())}),[t]),z({onSuccess:t=>{e&&xn(e),oe(t.portal_url)},onError:()=>{E.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function On(e){return e.disabled===!0}function kn({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=G[e.tier]??e.label,n=o==null?`+${$(e.price_cents)}`:e.price_cents===o?`(${$(e.price_cents)}, current)`:ct(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:On(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${$(e.price_cents)}`:e.price_cents===s?`(${$(e.price_cents)}, current)`:ct(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GB ${t}`,disabled:On(e)}}),[t,s]);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,K.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(d,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,K.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,K.jsx)(x,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,K.jsx)(D,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var An=new Set([`active`,`trialing`,`past_due`]);function jn(e){return e.plan_id!==`base`&&e.cancel_at_period_end!==!0&&!e.cancel_at&&e.status!=null&&An.has(e.status)}var Mn=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`package`,`non_field_errors`];function Nn(e,t){if(e&&typeof e==`object`){for(let t of Mn)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 Pn(e,t){let n=e.filter(e=>!On(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Fn(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function In(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Ln(){let e=s(),t=l(ve());return{changePackage:async n=>{try{let r=await t.mutateAsync({body:{package:n}});return await Promise.all([e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})]),r}catch(e){return E.error(Nn(e,`Failed to change your plan. Please try again.`)),null}},isPending:t.isPending}}function Rn({enabled:e=!0}={}){let t=s(),n=ae(),r=e&&n,i=c({...me(),enabled:r}),a=i.data,o=a!=null&&a.plan_id!==`base`,u=c({...ye(),enabled:r&&o}),d=c({...se(),enabled:r&&o}).data?.plans.find(e=>e.id===`pro`)?.machine_tiers??[],f=e=>d.find(t=>t.tier===e)?.price_cents??null,p=l(he()),m=l(fe()),h=l(be()),g={machineTier:u.data?.max_machine_tier??null,storageTier:u.data?.selected_storage_tier??null,storageGib:u.data?.selected_storage_gib??null,creditTier:a?.selected_credit_tier??null},_=a!=null&&a.plan_id!==`base`&&a.status!=null&&An.has(a.status)&&a.cancel_at_period_end!==!0&&!a.cancel_at,v=!o||!u.isPending,y=!o||u.isSuccess&&u.data!=null&&!u.isFetching&&u.dataUpdatedAt>=i.dataUpdatedAt,b=p.isPending||m.isPending||h.isPending,x=()=>Promise.all([t.invalidateQueries({queryKey:B()}),t.invalidateQueries({queryKey:L()}),t.invalidateQueries({queryKey:R()})]);return{changeTiers:async e=>{let t=e.machineTier!==g.machineTier,n=e.storageTier!==g.storageTier,r=e.creditTier!==g.creditTier,i=f(e.machineTier),a=f(g.machineTier),o=t&&i!=null&&a!=null&&i<a,s=[];if(t&&s.push(new Promise(t=>{p.mutate({body:{machine_tier:e.machineTier}},{onSuccess:()=>t({dimension:`machine`,ok:!0}),onError:e=>t({dimension:`machine`,ok:!1,error:e})})})),n&&s.push(new Promise(t=>{m.mutate({body:{storage_tier:e.storageTier}},{onSuccess:()=>t({dimension:`storage`,ok:!0}),onError:e=>t({dimension:`storage`,ok:!1,error:e})})})),r&&s.push(new Promise(t=>{h.mutate({body:{credit_tier:e.creditTier}},{onSuccess:()=>t({dimension:`credit`,ok:!0}),onError:e=>t({dimension:`credit`,ok:!1,error:e})})})),s.length===0)return{needsResize:!1,creditChanged:!1};let c=await Promise.all(s);await x();let l=c.some(e=>e.ok&&e.dimension===`machine`)&&!o,u=c.some(e=>e.ok&&e.dimension===`storage`),d=l||u,_=c.some(e=>e.ok&&e.dimension===`credit`),v=c.filter(e=>!e.ok);if(v.length>0){let e=v.map(e=>Nn(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);return E.error(e),d||_?{needsResize:d,creditChanged:_}:null}return{needsResize:d,creditChanged:_}},isPending:b,current:g,eligible:_,currentReady:v,currentKnown:y,primaryAssistantId:y?u.data?.primary_assistant_id??null:null}}var zn=`__none__`,Bn=`No extra credits`;function Vn(e){let{proPlan:t,seed:n,machineTier:r,storageTier:i,creditChoice:a}=e,o=t.machine_tiers,s=t.storage_tiers,c=t.credit_tiers??[],l=o.find(e=>e.tier===r)??null,u=s.find(e=>e.tier===i)??null,d=a&&a!==`__none__`?c.find(e=>e.tier===a)??null:null,f=n==null?null:o.find(e=>e.tier===n.machineTier)??null,p=n==null?null:s.find(e=>e.tier===n.storageTier)??null,m=n!=null&&n.creditTier!=null?c.find(e=>e.tier===n.creditTier)??null:null,h=n!=null&&n.machineTier!=null&&f==null,g=n!=null&&p==null,_=[{key:`base`,label:`Platform fee: ${$(t.base_price_cents)}`,changed:!1}];if(l!=null){let e=n!=null&&!h&&f?.tier!==l.tier;_.push({key:`machine`,label:l.description,previousLabel:e&&f!=null?f.description:void 0,changed:e})}if(u!=null){let e=n!=null&&!g&&p?.tier!==u.tier;_.push({key:`storage`,label:lt(u.storage_gib),previousLabel:e&&p!=null?lt(p.storage_gib):void 0,changed:e})}let v=a===`__none__`?Bn:d==null?null:ut(d.credits_usd);if(v!=null){let e=n!=null&&(n.creditTier??`__none__`)!==a,t=n?.creditTier==null?Bn:m==null?void 0:ut(m.credits_usd);_.push({key:`credit`,label:v,previousLabel:e?t:void 0,changed:e})}let y=t.base_price_cents+(l?.price_cents??0)+(u?.price_cents??0)+(d?.price_cents??0),b=h||g||n!=null&&n.creditTier!=null&&m==null;if(n==null||b)return{totalCents:y,previousTotalCents:null,deltaCents:null,rows:_};let x=t.base_price_cents+(f?.price_cents??0)+(p?.price_cents??0)+(m?.price_cents??0);return{totalCents:y,previousTotalCents:x,deltaCents:y-x,rows:_}}function Hn(e){return(0,K.jsxs)(`span`,{className:`text-[12px] font-medium text-[var(--content-disabled)]`,children:[`+`,$(e)]})}function Un({open:e,proPlan:t,pending:r,currentStorageGib:i,initialSelection:a,onClose:o,onContinue:s}){let c=e?a??null:null,[l,u]=(0,q.useState)(()=>c?.machineTier??``),[d,f]=(0,q.useState)(()=>c?.storageTier??``),[p,m]=(0,q.useState)(()=>c?c.creditTier??`__none__`:``),[h,v]=(0,q.useState)({open:e,initialSelection:a});(h.open!==e||h.initialSelection!==a)&&(v({open:e,initialSelection:a}),u(c?.machineTier??``),f(c?.storageTier??``),m(c?c.creditTier??`__none__`:``));let x=t.machine_tiers,S=(0,q.useMemo)(()=>t.storage_tiers.filter(e=>!e.legacy||e.tier===a?.storageTier),[t.storage_tiers,a?.storageTier]),C=t.credit_tiers??[],w=(0,q.useMemo)(()=>(t.credit_tiers??[]).filter(e=>!e.legacy),[t.credit_tiers]),E=e=>On(e)||e.legacy&&e.tier!==a?.storageTier||i!=null&&e.storage_gib<i,ee=x.map(e=>({value:e.tier,label:e.description,icon:(0,K.jsx)(Re,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:On(e)})),O=S.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(b,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents),disabled:E(e)})),k=p&&p!==`__none__`?C.find(e=>e.tier===p)??null:null,A=k?.legacy?k:null,j=[{value:zn,label:Bn,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0})},...w.map(e=>({value:e.tier,label:e.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(e.price_cents)})),...A?[{value:A.tier,label:A.label,icon:(0,K.jsx)(_,{className:`h-4 w-4`,"aria-hidden":!0}),suffix:Hn(A.price_cents),disabled:!0}]:[]],te=x.find(e=>e.tier===l)??null,M=d!==``&&d===a?.storageTier,N=S.find(e=>e.tier===d&&(M||!E(e)))??null,ne=p===`__none__`||p===a?.creditTier||w.some(e=>e.tier===p),re=p!==``&&ne?p:null,ie=te!=null&&N!=null&&re!=null,P=a!=null&&l===(a.machineTier??``)&&d===a.storageTier&&p===(a.creditTier??`__none__`),F=(0,q.useMemo)(()=>Vn({proPlan:t,seed:a??null,machineTier:l,storageTier:d,creditChoice:p}),[t,a,l,d,p]);return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{e||o()},children:(0,K.jsx)(T.Content,{size:`lg`,"data-theme":`light`,hideCloseButton:!0,overlayClassName:`backdrop-blur-[2px]`,className:`max-w-[820px] md:min-h-[min(608px,calc(100vh-4rem))]`,children:(0,K.jsx)(T.Body,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-8 md:flex-row md:gap-12`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 md:flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`flex shrink-0 items-center justify-center rounded-xl bg-[var(--surface-active)] p-[14px]`,children:(0,K.jsx)(y,{className:`h-6 w-6 text-[var(--content-emphasised)]`,"aria-hidden":!0})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Create a custom plan`}),(0,K.jsx)(T.Description,{className:`mt-0 text-[14px] font-medium leading-[18px] text-[var(--content-tertiary)]`,children:`Just better.`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select a machine size:`}),(0,K.jsx)(D,{"aria-label":`Machine size`,placeholder:`Select a machine size`,value:l,onChange:u,options:ee})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Select storage:`}),(0,K.jsx)(D,{"aria-label":`Storage`,placeholder:`Select storage`,value:d,onChange:f,options:O})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-secondary)]`,children:`Bundle some credits:`}),(0,K.jsx)(D,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,value:p,onChange:m,options:j})]})]}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-16 md:pt-[5px]`,children:[(0,K.jsx)(`span`,{className:`text-[16px] font-medium text-[var(--content-emphasised)]`,children:`Recap`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[24px] font-medium text-[var(--content-default)]`,children:$(F.totalCents)}),F.deltaCents!=null&&F.deltaCents!==0&&F.previousTotalCents!=null&&(0,K.jsxs)(`span`,{className:`text-[12px] font-medium ${F.deltaCents>0?`text-[var(--system-positive-strong)]`:`text-[var(--system-negative-strong)]`}`,children:[ct(F.deltaCents),` compared to previous (`,st(F.previousTotalCents),`)`]}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-[var(--content-tertiary)]`,children:`Total`})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(`span`,{className:`text-[12px] font-medium text-[var(--content-tertiary)]`,children:`Your selection:`}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:F.rows.map(e=>(0,K.jsxs)(`li`,{className:`flex flex-col gap-2`,children:[e.previousLabel!=null&&(0,K.jsxs)(`div`,{className:`relative flex w-fit items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`,"aria-hidden":!0}),(0,K.jsx)(`s`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-disabled)] no-underline`,children:e.previousLabel}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute -left-1 right-0 top-[9px] h-px bg-[var(--content-disabled)]`})]}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 ${e.changed?`text-[var(--system-positive-strong)]`:`text-[var(--content-secondary)]`}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`text-[14px] font-medium leading-[18px] text-[var(--content-secondary)]`,children:e.label})]})]},e.key))}),(0,K.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:!ie||P||r,onClick:()=>{!ie||P||r||s({machineTier:te.tier,storageTier:N.tier,creditTier:re===`__none__`?null:re})},children:`Continue`}),(0,K.jsx)(n,{variant:`ghost`,fullWidth:!0,disabled:r,onClick:o,children:`Cancel`})]})]})]})})})})}function Wn({className:e,"data-testid":t,children:n}){return(0,K.jsx)(`div`,{"aria-hidden":!0,"data-testid":t,className:H(`flex size-[52px] shrink-0 items-center justify-center rounded-xl`,e),children:n})}var Gn=32;function Kn(){let{ready:e,avatar:t}=xt();return(0,K.jsx)(Wn,{"data-testid":`assistant-avatar-tile`,className:`bg-[var(--surface-active)]`,children:e?(0,K.jsx)(Te,{components:t.components,traits:t.traits,customImageUrl:t.customImageUrl,size:Gn}):null})}var qn={free:{tagline:`Get to know your assistant.`,cta:`Start Free`,priceCaption:`Forever`},mighty:{tagline:`More capacity for consistent use.`,cta:`Power Up`,priceCaption:`Billed monthly`,recommended:!0},super:{tagline:`Do more, think less about the how.`,cta:`Go Super`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]},ultra:{tagline:`Your second brain, running full speed.`,cta:`Unleash Ultra`,priceCaption:`Billed monthly`,extraFeatures:[`Assistant email and subdomain`]}};function Jn(e){return qn[e]}function Yn(e){return`Downgrade to ${e}`}var Xn=`Billed monthly · prorated difference charged today`,Zn=`Billed monthly · prorated difference charged today or credited next invoice`,Qn=`Billed monthly · prorated credit on your next invoice`,$n=`Your machine downsizes now and your storage stays. No refund.`,er=`Continue`,tr=`The plan includes`,nr=`Your plan will include`;function rr(e,t,n){let r=n?Jn(n)?.tagline??``:``;switch(e){case`downgrade`:return{title:Yn(t),subtitle:``,priceCaption:Qn,checklistHeading:nr,note:$n,confirmLabel:Yn(t),destructive:!0};case`switch`:return{title:`Switch to ${t}`,subtitle:r,priceCaption:Zn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1};default:return{title:`Upgrade to ${t}`,subtitle:r,priceCaption:Xn,checklistHeading:tr,note:``,confirmLabel:er,destructive:!1}}}function ir({open:e,relation:t,packageName:r,targetPackage:i,pending:a,onCancel:o,onConfirm:s}){let c=(0,q.useRef)(null),l=(0,q.useId)(),u=rr(t,r,i?.key??null),f=i?{price:$(i.total_price_cents),highlights:gn(i,Jn(i.key)?.extraFeatures??[])}:null,p=u.subtitle,m=u.note?{"aria-describedby":l}:p?{}:{"aria-describedby":void 0};return(0,K.jsx)(T.Root,{open:e,onOpenChange:e=>{!e&&!a&&o()},children:(0,K.jsxs)(T.Content,{size:`sm`,hideCloseButton:!0,className:`gap-4 p-4 max-w-[421px]`,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus()},...m,children:[(0,K.jsxs)(T.Header,{className:`flex-row items-center gap-3 p-0 pb-2`,children:[u.destructive?(0,K.jsx)(Wn,{"data-testid":`package-switch-warning-tile`,className:`bg-[var(--system-negative-weak)]`,children:(0,K.jsx)(C,{className:`size-6 text-[var(--system-negative-strong)]`})}):(0,K.jsx)(Kn,{}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,K.jsx)(T.Title,{className:`text-title-small text-[var(--content-emphasised)] [&>span]:whitespace-normal`,children:u.title}),p?(0,K.jsx)(T.Description,{className:`mt-0 text-body-medium-default text-[var(--content-tertiary)]`,children:p}):null]})]}),f?(0,K.jsxs)(T.Body,{className:`flex flex-col gap-4 p-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(d,{as:`p`,variant:`title-large`,className:`text-[var(--content-default)]`,children:f.price}),(0,K.jsx)(d,{as:`p`,variant:`label-medium-default`,className:`leading-[15px] text-[var(--content-tertiary)]`,children:u.priceCaption})]}),(0,K.jsx)(`div`,{className:`h-px w-full bg-[var(--border-hover)]`}),(0,K.jsx)(d,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:u.checklistHeading}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.highlights.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(g,{className:`size-4 shrink-0 text-[var(--content-secondary)]`,"aria-hidden":!0}),(0,K.jsx)(d,{as:`span`,variant:`body-medium-default`,className:`text-[var(--content-default)]`,children:e})]},e))})]}):null,u.note?(0,K.jsx)(d,{id:l,as:`p`,variant:`body-medium-default`,className:`text-[var(--content-secondary)]`,children:u.note}):null,(0,K.jsxs)(T.Footer,{className:`flex-col gap-4 p-0`,children:[(0,K.jsx)(n,{fullWidth:!0,variant:u.destructive?`danger`:`primary`,onClick:s,disabled:a,"data-testid":`confirm-package-switch-button`,children:u.confirmLabel}),(0,K.jsx)(n,{ref:c,fullWidth:!0,variant:`ghost`,onClick:o,disabled:a,children:`Cancel`})]})]})})}function ar(){let e=s();(0,q.useEffect)(()=>I(()=>{e.invalidateQueries({queryKey:B()}),e.invalidateQueries({queryKey:R()}),e.invalidateQueries({queryKey:L()})}),[e])}export{ln as A,mn as C,rn as D,on as E,qe as F,Ge as I,ze as L,ct as M,st as N,un as O,$ as P,vn as S,fn as T,Tn as _,Un as a,Dn as b,An as c,In as d,Fn as f,Cn as g,wn as h,Jn as i,nn as j,an as k,Nn as l,kn as m,ir as n,Rn as o,Pn as p,Yn as r,Ln as s,ar as t,jn as u,En as v,hn as w,yn as x,Sn as y};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-wESJw6y3.js";import"./src-Da9g8qsW.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-CJh95P_q.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-DbIS4l8d.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`_vellumDebug`,F=`apps`,I=`disableIframeSandbox`,L=!1,R=new Set;function z(){return L}function B(e){let t=e===!0;if(t!==L){L=t,t?console.warn(`[vellumDebug] ${F}.${I} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Set it back to false, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${F}.${I} = false: app iframes are sandboxed again.`);for(let e of R)e()}}function V(e){return R.add(e),()=>{R.delete(e)}}function H(){return(0,N.useSyncExternalStore)(V,z,()=>!1)}function U(){if(typeof window>`u`)return;let e=window,t=e[P]??{},n=t[F]??{};Object.defineProperty(n,I,{configurable:!0,enumerable:!0,get:z,set:B}),t[F]=n,e[P]=t}function W({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(G,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function G({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var K=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function q(e){return K.some(t=>e.startsWith(t))}function J(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!q(e))}function Y(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=J([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var X=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function Z({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=H(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return Y(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(W,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:X,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Q(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,U as i,Z as n,Y as r,Q as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-BwFudwM5.js";import{l as r,u as i}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./typography-DEI9Ra9z.js";import{t as s}from"./createLucideIcon-CAM1RhH8.js";import{t as c}from"./chevron-up-DofScvyy.js";import{t as l}from"./menu-Cfi4A3sw.js";import"./src-CwGlaCIx.js";import{t as u}from"./globe-CdLn4IX7.js";import{t as d}from"./loader-circle-DWWXcfTQ.js";import{n as f,t as p}from"./minimize-2-Dj9FY4aF.js";import{t as m}from"./pencil-Cm5DdeRM.js";import{t as h}from"./x-D4O9yIS7.js";import{n as g,t as _}from"./panel-item-5YQ3jbso.js";import{n as v}from"./resolved-assistants-store-C6oDdTxB.js";import{t as y}from"./client.gen-Dq2brHDV.js";import{n as b}from"./event-bus-CbDg1VDt.js";import{d as x}from"./routes-DrfnNoYS.js";import{t as S}from"./conversation-store-CTMy9QPV.js";import{i as C}from"./viewer-store-DxLOGAkL.js";import{n as w}from"./use-is-mobile-MmHo-OM6.js";import{t as T}from"./misc-BBsGq1IU.js";import{r as E,t as D}from"./edit-chat-session-DVzLQLWl.js";import{n as O,t as k}from"./sandbox-bridge-B5H4c27m.js";var A=s(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),j=s(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),M=a(),N=e(t(),1),P=`_vellumDebug`,F=`apps`,I=`disableIframeSandbox`,L=!1,R=new Set;function z(){return L}function B(e){let t=e===!0;if(t!==L){L=t,t?console.warn(`[vellumDebug] ${F}.${I} = true: app iframes render without the sandbox attribute. App HTML runs same-origin with the host and can reach its DOM, storage, and cookies. Open apps reload to pick this up. Set it back to false, or reload the page, to restore the sandbox.`):console.info(`[vellumDebug] ${F}.${I} = false: app iframes are sandboxed again.`);for(let e of R)e()}}function V(e){return R.add(e),()=>{R.delete(e)}}function H(){return(0,N.useSyncExternalStore)(V,z,()=>!1)}function U(){if(typeof window>`u`)return;let e=window,t=e[P]??{},n=t[F]??{};Object.defineProperty(n,I,{configurable:!0,enumerable:!0,get:z,set:B}),t[F]=n,e[P]=t}function W({appName:e,onEdit:t,isEditing:r,onShare:i,isSharing:a,onDeploy:s,isDeploying:l,onToggleFullscreen:p,onClose:g}){let _=w(),v=_&&r===!0&&t!=null,y=i!=null&&s!=null;return(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-t-xl bg-[var(--surface-lift)] px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`hidden md:flex items-center min-w-[72px]`,children:t!=null&&(r?(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(A,{}),onClick:t,tooltip:`Expand app`,"aria-label":`Expand app`}):(0,M.jsx)(n,{onClick:t,children:`Edit`}))}),(0,M.jsx)(o,{variant:`body-large-default`,className:T(`flex-1 truncate text-left md:text-center text-[var(--content-emphasised)]`,v&&`cursor-pointer`),style:{lineHeight:1.4},onClick:v?t:void 0,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-[72px] justify-end`,children:[y?(0,M.jsx)(G,{onShare:i,isSharing:a,onDeploy:s,isDeploying:l,isMobile:_}):(0,M.jsxs)(M.Fragment,{children:[s!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:l?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(u,{}),onClick:s,disabled:l,tooltip:l?`Deploying…`:`Deploy`,"aria-label":l?`Deploying…`:`Deploy`}),i!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:a?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),onClick:i,disabled:a,tooltip:a?`Sharing…`:`Share`,"aria-label":a?`Sharing…`:`Share`})]}),p!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(f,{}),onClick:p,tooltip:`Fullscreen`,"aria-label":`Fullscreen`}),t!=null&&(0,M.jsx)(n,{variant:`outlined`,iconOnly:r?(0,M.jsx)(c,{}):(0,M.jsx)(m,{}),onClick:t,tooltip:r?`Open app`:`Edit`,"aria-label":r?`Open app`:`Edit`,active:r,className:`md:hidden`}),(0,M.jsx)(n,{variant:`outlined`,iconOnly:(0,M.jsx)(h,{}),onClick:g,tooltip:`Close`,"aria-label":`Close`})]})]})}function G({onShare:e,isSharing:t,onDeploy:r,isDeploying:i,isMobile:a}){let[o,s]=(0,N.useState)(!1),c=t||i,f=c?(0,M.jsx)(d,{className:`animate-spin`}):(0,M.jsx)(j,{}),p=t?`Sharing…`:i?`Deploying…`:`Share & deploy`;return a?(0,M.jsxs)(g.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(g.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(g.Content,{"aria-describedby":void 0,children:[(0,M.jsx)(g.Header,{className:`sr-only`,children:(0,M.jsx)(g.Title,{children:`Share & deploy`})}),(0,M.jsxs)(g.Body,{className:`pt-0`,children:[(0,M.jsx)(_,{icon:j,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Share`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Export as .vellum file`})]}),onSelect:()=>{s(!1),e()}}),(0,M.jsx)(_,{icon:u,label:(0,M.jsxs)(`span`,{className:`flex flex-col gap-0.5 overflow-visible whitespace-normal`,children:[(0,M.jsx)(`span`,{children:`Deploy to Vercel`}),(0,M.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Publish as a static page`})]}),onSelect:()=>{s(!1),r()}})]})]})]}):(0,M.jsxs)(l.Root,{open:o,onOpenChange:s,children:[(0,M.jsx)(l.Trigger,{asChild:!0,children:(0,M.jsx)(n,{variant:`outlined`,iconOnly:f,disabled:c,tooltip:p,"aria-label":p})}),(0,M.jsxs)(l.Content,{align:`end`,sideOffset:4,children:[(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(j,{size:14}),onSelect:()=>e(),className:`whitespace-nowrap`,children:`Share`}),(0,M.jsx)(l.Item,{leftIcon:(0,M.jsx)(u,{size:14}),onSelect:()=>r(),className:`whitespace-nowrap`,children:`Deploy to Vercel`})]})]})}var K=[`assistant:`,`conversation:`,`conversations:`,`apps:`,`plugins:`,`feature-flags:`];function q(e){return K.some(t=>e.startsWith(t))}function J(e,t){if(e.length===0)return[];let n=new Set(e);return t.filter(e=>n.has(e)&&!q(e))}function Y(e,t){let{frameId:n,assistantId:r,appId:i,enabled:a=!0,onAction:o,onOpenVellumLink:s}=t,c=(0,N.useRef)(new Map);(0,N.useEffect)(()=>{let t=c.current,l=async c=>{let l=c.data;if(!l||l.frameId!==n||c.source!==e.current?.contentWindow)return;if(l.type===`vellum_subscribe`){if(!a)return;let{subId:e,tags:n}=l;typeof e==`string`&&Array.isArray(n)&&t.set(e,new Set(n.filter(e=>typeof e==`string`)));return}if(l.type===`vellum_unsubscribe`){let{subId:e}=l;typeof e==`string`&&t.delete(e);return}if(l.type===`vellum_surface_action`){o?.(l.actionId,l.data);return}if(l.type===`vellum_open_link`){if(!navigator.userActivation?.isActive)return;s?.(l.href,l.linkText);return}if(l.type===`vellum_asset_request`){let{callId:t,path:n}=l,o=e.current,s=(e,t)=>{o?.contentWindow?.postMessage(e,`*`,t??[])};if(!a){s({type:`vellum_asset_response`,callId:t,error:`Asset proxy disabled`});return}if(!i){s({type:`vellum_asset_response`,callId:t,error:`No app context for assets`});return}if(typeof n!=`string`||n===``||n.includes(`..`)){s({type:`vellum_asset_response`,callId:t,error:`Invalid asset path`});return}try{let e=`/v1/assistants/${r}/apps/${i}/asset/${n.split(`/`).map(encodeURIComponent).join(`/`)}`,{data:a,response:o}=await y.get({url:e,parseAs:`blob`,throwOnError:!1});if(!o?.ok||!(a instanceof Blob)){s({type:`vellum_asset_response`,callId:t,error:`Asset fetch failed (${o?.status??0})`});return}let c=await a.arrayBuffer();s({type:`vellum_asset_response`,callId:t,buffer:c,contentType:a.type||`application/octet-stream`},[c])}catch(e){s({type:`vellum_asset_response`,callId:t,error:e instanceof Error?e.message:`Asset proxy error`})}return}if(!a||l.type!==`vellum_fetch_request`)return;let{callId:u,path:d,method:f,headers:p,body:m}=l,h=e.current,g=e=>{h?.contentWindow?.postMessage(e,`*`)};if(!k.test(d)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: only /v1/x/ custom routes are allowed`});return}try{let e=new URL(d,`https://placeholder`).pathname;if(!k.test(e)){g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: path traversal detected`});return}}catch{g({type:`vellum_fetch_response`,callId:u,error:`Request blocked: invalid path`});return}let _=`/v1/assistants/${r}/${d.replace(/^\/v1\//,``)}`;try{let e={url:_,throwOnError:!1,headers:p&&Object.keys(p).length>0?p:void 0,body:m?JSON.parse(m):void 0},t=await(f===`POST`?y.post:f===`PUT`?y.put:f===`PATCH`?y.patch:f===`DELETE`?y.delete:y.get)(e),n=t.response,r=t.data??t.error,i=r==null?``:typeof r==`string`?r:JSON.stringify(r);g({type:`vellum_fetch_response`,callId:u,status:n?.status??0,statusText:n?.statusText??``,body:i})}catch(e){g({type:`vellum_fetch_response`,callId:u,error:e instanceof Error?e.message:`Fetch proxy error`})}};window.addEventListener(`message`,l);let u=b(`sse.event`,r=>{let i=r.message;if(!i||i.type!==`sync_changed`||!Array.isArray(i.tags))return;let a=e.current?.contentWindow;if(!a||t.size===0)return;let o=i.tags.filter(e=>typeof e==`string`);for(let[e,r]of t){let t=J([...r],o);t.length>0&&a.postMessage({type:`vellum_event`,frameId:n,subId:e,event:{type:`sync_changed`,tags:t}},`*`)}});return()=>{window.removeEventListener(`message`,l),u()}},[n,r,i,a,o,s,e])}var X=`allow-scripts allow-popups allow-popups-to-escape-sandbox`;function Z({appId:e,appName:t,html:r,assistantId:i,onClose:a,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,route:f,enableFullscreen:m=!1,onAction:h}){let g=(0,N.useRef)(null),[_,v]=(0,N.useState)(!1),y=(0,N.useCallback)(()=>v(e=>!e),[]);(0,N.useEffect)(()=>{v(!1)},[e]),(0,N.useEffect)(()=>{if(!_)return;let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),v(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_]);let b=(0,N.useMemo)(()=>O(r,e,{fetch:!0,route:f}),[r,e,f]),x=H(),S=(0,N.useMemo)(()=>{let t=0;for(let e=0;e<r.length;e++)t=(t<<5)-t+r.charCodeAt(e)|0;return`app-${e}-${t}${x?`-nosandbox`:``}`},[r,e,x]);return Y(g,{frameId:e,assistantId:i,appId:e,onAction:h}),(0,M.jsxs)(`div`,{"data-testid":`app-viewer-root`,className:T(`flex flex-col overflow-hidden bg-[var(--surface-base)]`,_?`fixed inset-0 z-[60]`:`h-full rounded-xl`),children:[!_&&(0,M.jsx)(W,{appName:t,onEdit:o,isEditing:s,onShare:c,isSharing:l,onDeploy:u,isDeploying:d,onToggleFullscreen:m?y:void 0,onClose:a}),(0,M.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[_&&(0,M.jsx)(`div`,{className:`absolute z-10`,style:{top:`max(0.75rem, var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))`,right:`max(0.75rem, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))`},children:(0,M.jsx)(n,{variant:`primary`,iconOnly:(0,M.jsx)(p,{}),onClick:y,tooltip:`Exit fullscreen`})}),(0,M.jsx)(`iframe`,{ref:g,srcDoc:b,sandbox:x?void 0:X,referrerPolicy:`no-referrer`,title:t,className:`h-full w-full border-none`},S)]})]})}function Q(){let e=v.use.activeAssistantId(),t=w(),n=i(),{pathname:a}=r();return(0,N.useCallback)(r=>{if(!e)return;let i=D(e,r.appId)??crypto.randomUUID();E(e,r.appId,i);let o=C.getState();(o.activeAppId!==r.appId||!o.openedAppState)&&(o.openApp(r.appId),o.setLoadedApp(r)),S.getState().setEditingConversationId(i),t?o.minimizeApp():o.enterAppEditing();let s=x.conversation(i);a!==s&&n(s)},[e,t,n,a])}export{j as a,U as i,Z as n,Y as r,Q as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-Dy5001j6.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./useMutation-CXGTrp4W.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./typography-DEI9Ra9z.js";import{c,h as l,i as u,m as d,n as f,r as p,s as m,t as h}from"./use-save-twilio-credentials-yqA7lnzq.js";import{t as g}from"./check-Dt2rQhdg.js";import{B as _}from"./src-Da9g8qsW.js";import{t as v}from"./link-2-DhyrrFaE.js";import{t as y}from"./loader-circle-DWWXcfTQ.js";import{t as b}from"./input-tXUFa7Eo.js";import{t as x}from"./modal-xr_vw1ZO.js";import{i as S}from"./utils-DtVy-_pB.js";import{n as C,r as w,t as T}from"./api-errors-BRGPPSWw.js";import{Xt as E,en as D,nn as O}from"./sdk.gen-CjtCuSlS.js";import{G as k,J as A,K as j,o as M,q as ee,s as N,x as P}from"./react-query.gen-C7om930f.js";import{n as F}from"./sdk.gen-BpJ1vF7l.js";import{t as I}from"./copy-to-clipboard-DgY-nZpm.js";import{t as L}from"./mutation-error-YLfUU5XL.js";import{t as R}from"./a2a-invite-Bld7VHkJ.js";var z=e(t(),1),B=o(),V=[`no_one`,`guardian_only`,`trusted_contacts`,`any_contact`,`strangers`],H=`trusted_contacts`,U=new Set([`platform`,`a2a`]),W=new Set([`vellum`,`whatsapp`,`discord`]);function G(e){return W.has(e)}var K={no_one:`No one`,guardian_only:`Only you`,trusted_contacts:`Verified contacts`,any_contact:`Any contact`,strangers:`Strangers`};function q(e){return{no_one:`No one can message ${e} on this channel: every message is blocked, including yours.`,guardian_only:`Only you can message ${e}. Everyone else is turned away.`,trusted_contacts:`You and the people you’ve verified can message ${e}. Anyone else is asked to verify first, and you’re notified.`,any_contact:`You and any known contact can message ${e}, including contacts you haven’t verified yet. Strangers are asked to verify first.`,strangers:`Anyone can message ${e}, including complete strangers.`}}function J(e){let t=e-Date.now();if(t<=0)return`Expired`;let n=Math.ceil(t/(1e3*60*60*24));return n===1?`Expires in 1 day`:`Expires in ${n} days`}function Y({open:e,assistantId:t,onClose:r}){let[i,o]=(0,z.useState)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(!1),u=a({...k({path:{assistant_id:t}})}),d=(0,z.useRef)(u.mutate);(0,z.useLayoutEffect)(()=>{d.current=u.mutate});let f=(0,z.useRef)(u.reset);(0,z.useLayoutEffect)(()=>{f.current=u.reset}),(0,z.useEffect)(()=>{e&&!l.current&&d.current({path:{assistant_id:t}}),l.current=e},[e,t]),(0,z.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let p=(0,z.useCallback)(()=>{f.current(),o(!1),c.current&&=(clearTimeout(c.current),null),r()},[r]),m=(0,z.useCallback)(e=>{I(e,{errorMessage:`Couldn't copy the invite link.`,onCopied:()=>{o(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>o(!1),2e3)}})},[]),h=u.isSuccess&&u.data.token?R({senderAssistantId:t,token:u.data.token}):``;return(0,B.jsx)(x.Root,{open:e,onOpenChange:e=>{e||p()},children:(0,B.jsxs)(x.Content,{size:`sm`,children:[(0,B.jsx)(x.Header,{children:(0,B.jsx)(x.Title,{children:`Share Connection Link`})}),(0,B.jsx)(x.Body,{children:u.isPending?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,B.jsx)(y,{className:`h-4 w-4 animate-spin`}),`Creating invite link…`]}):u.isError?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(`p`,{role:`alert`,className:`!m-0 text-body-medium-lighter`,style:{color:`var(--system-negative-strong)`},children:`Failed to create invite link. Make sure A2A is enabled for your assistant.`}),(0,B.jsx)(n,{variant:`outlined`,onClick:()=>u.mutate({path:{assistant_id:t}}),children:`Try Again`})]}):u.isSuccess?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(s,{variant:`body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Share this link with another assistant owner to establish a connection.`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(b,{type:`text`,readOnly:!0,value:h,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>m(h),"aria-label":`Copy invite link`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-[var(--border-base)] hover:bg-[var(--surface-hover)]`,children:i?(0,B.jsx)(g,{className:`h-4 w-4`}):(0,B.jsx)(_,{className:`h-4 w-4`})})]}),u.data.expiresAt!=null&&(0,B.jsx)(s,{variant:`body-small-default`,style:{color:`var(--content-tertiary)`},children:J(u.data.expiresAt)})]}):null}),(0,B.jsx)(x.Footer,{children:(0,B.jsx)(n,{variant:`outlined`,onClick:p,children:`Done`})})]})})}function X({onClick:e}){return(0,B.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:(0,B.jsx)(v,{className:`h-3.5 w-3.5`}),onClick:e,children:`Share Connection Link`})}function Z(e){return typeof e==`string`&&V.includes(e)}function Q(e){return U.has(e)}function te(e){return(e?.policies??[]).filter(e=>!Q(e.channelType)&&!G(e.channelType)).map(e=>({...e,policy:Z(e.policy)?e.policy:`trusted_contacts`}))}async function ne(e,t,n,r){if(Q(t))throw new T(403,`Channel "${t}" is internal and is not user-configurable.`);let{data:i,error:a,response:o}=await F({path:{assistant_id:e,channel_type:t},body:{policy:n,note:r??null},throwOnError:!1});if(C(o,a,`Failed to save channel policy.`),!o.ok)throw new T(o.status,w(a,o,`Failed to save channel policy.`));if(!i?.policy)throw new T(500,`Gateway returned no policy in response.`);return i.policy}var re=`0.10.0`;function $(){return S(re)}function ie(e){let t=r(),n=$(),o=(0,z.useMemo)(()=>({path:{assistant_id:e}}),[e]),s=(0,z.useMemo)(()=>l(o),[o]),u=i({...d(o),enabled:n,select:te}),f=(0,z.useMemo)(()=>{let e={};for(let t of u.data??[])c(t.channelType)&&(e[t.channelType]=t.policy);return e},[u.data]),p=a({mutationFn:({channelKey:t,policy:n})=>ne(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:s}),onError:L(`Failed to save channel policy`)}),m=(0,z.useCallback)((e,t)=>{p.mutate({channelKey:e,policy:t})},[p]);return n?{policies:f,savingKey:p.isPending?p.variables?.channelKey??null:null,isLoading:u.isPending,isError:u.isError,onChange:m}:{policies:void 0,savingKey:null,isLoading:!1,isError:!1,onChange:void 0}}var ae={slack:`I want to reach you on Slack. Let's set it up.`,telegram:`I want to reach you on Telegram. Let's set it up.`,phone:`I want to be able to call you. Let's set you up with a phone number.`},oe=15e3;function se({assistantId:e,onStartSetupConversation:t}){let n=r(),o=(0,z.useMemo)(()=>({path:{assistant_id:e}}),[e]),s=(0,z.useMemo)(()=>N(o),[o]),c=i({...M(o),enabled:!!e,refetchInterval:oe,select:e=>e.snapshots}),l=(0,z.useMemo)(()=>ce(c.data??[]),[c.data]),d=l.some(e=>e.key===`slack`&&e.status===`ready`),m=i({...j(o),enabled:d,select:e=>e.threadMode}),g=ie(e),_=(0,z.useCallback)(()=>n.invalidateQueries({queryKey:s}),[n,s]),v=a({mutationFn:async t=>{let n={path:{assistant_id:e},throwOnError:!0};t===`slack`?await E(n):t===`telegram`?await D(n):t===`phone`&&await O(n)},onSettled:(t,r,i)=>{_(),i===`slack`&&u(n,e)}}),y=f({assistantId:e}),b=p({assistantId:e}),x=h({assistantId:e}),S=a({...A(),onSuccess:()=>{n.invalidateQueries({queryKey:ee(o)})}}),C=y.mutateAsync,w=(0,z.useCallback)(async e=>{await C(e)},[C]),T=b.mutate,k=(0,z.useCallback)((e,t)=>{T({botToken:e,appToken:t})},[T]),P=S.mutate,F=(0,z.useCallback)(t=>{P({path:{assistant_id:e},body:{threadMode:t}})},[P,e]),I=x.mutateAsync,L=(0,z.useCallback)(async(e,t)=>{await I({accountSid:e,authToken:t})},[I]),R=(0,z.useCallback)(e=>{t&&t(ae[e])},[t]),B=v.mutate,V=(0,z.useCallback)(e=>{B(e)},[B]);return{channels:l,pendingChannelKey:v.isPending?v.variables??null:null,slackThreadMode:m.data,slackThreadModePending:S.isPending,channelPolicies:g.policies,policySavingKey:g.savingKey,policiesLoading:g.isLoading,policiesError:g.isError,onChannelPolicyChange:g.onChange,onSetup:t?R:void 0,onDisconnect:V,onSaveTelegramToken:w,onSaveSlackConfig:k,slackSaveStatus:b.status,slackSaveError:b.error?.message??null,onSlackThreadModeChange:F,onSaveTwilioCredentials:L}}function ce(e){let t=new Map;for(let n of e)t.set(n.channel,n);return m.map(e=>{let n=t.get(e);return{key:e,status:le(n),address:n?.channelHandle??void 0}})}function le(e){return e?e.ready||e.setupStatus===`ready`?`ready`:e.setupStatus===`incomplete`?`incomplete`:`not_configured`:`not_configured`}function ue(e){let t=r(),[n,i]=(0,z.useState)(!1);return{isOpen:n,open:(0,z.useCallback)(()=>{i(!0)},[]),close:(0,z.useCallback)(()=>{i(!1),t.invalidateQueries({queryKey:P({path:{assistant_id:e}})})},[t,e])}}export{H as a,q as c,Y as i,se as n,V as o,X as r,K as s,ue as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-BwFudwM5.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./useMutation-CXGTrp4W.js";import{t as o}from"./jsx-runtime-D3ZM-ToX.js";import{t as s}from"./typography-DEI9Ra9z.js";import{c,h as l,i as u,m as d,n as f,r as p,s as m,t as h}from"./use-save-twilio-credentials-yqA7lnzq.js";import{t as g}from"./check-Dt2rQhdg.js";import{V as _}from"./src-CwGlaCIx.js";import{t as v}from"./link-2-DhyrrFaE.js";import{t as y}from"./loader-circle-DWWXcfTQ.js";import{t as b}from"./input-CgGeKtja.js";import{t as x}from"./modal-DagTZ8xj.js";import{i as S}from"./utils-DtVy-_pB.js";import{n as C,r as w,t as T}from"./api-errors-BRGPPSWw.js";import{Xt as E,en as D,nn as O}from"./sdk.gen-CjtCuSlS.js";import{G as k,J as A,K as j,o as M,q as ee,s as N,x as P}from"./react-query.gen-C7om930f.js";import{n as F}from"./sdk.gen-BpJ1vF7l.js";import{t as I}from"./copy-to-clipboard-Y0mxY68V.js";import{t as L}from"./mutation-error-Cp0Jaqnt.js";import{t as R}from"./a2a-invite-Bld7VHkJ.js";var z=e(t(),1),B=o(),V=[`no_one`,`guardian_only`,`trusted_contacts`,`any_contact`,`strangers`],H=`trusted_contacts`,U=new Set([`platform`,`a2a`]),W=new Set([`vellum`,`whatsapp`,`discord`]);function G(e){return W.has(e)}var K={no_one:`No one`,guardian_only:`Only you`,trusted_contacts:`Verified contacts`,any_contact:`Any contact`,strangers:`Strangers`};function q(e){return{no_one:`No one can message ${e} on this channel: every message is blocked, including yours.`,guardian_only:`Only you can message ${e}. Everyone else is turned away.`,trusted_contacts:`You and the people you’ve verified can message ${e}. Anyone else is asked to verify first, and you’re notified.`,any_contact:`You and any known contact can message ${e}, including contacts you haven’t verified yet. Strangers are asked to verify first.`,strangers:`Anyone can message ${e}, including complete strangers.`}}function J(e){let t=e-Date.now();if(t<=0)return`Expired`;let n=Math.ceil(t/(1e3*60*60*24));return n===1?`Expires in 1 day`:`Expires in ${n} days`}function Y({open:e,assistantId:t,onClose:r}){let[i,o]=(0,z.useState)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(!1),u=a({...k({path:{assistant_id:t}})}),d=(0,z.useRef)(u.mutate);(0,z.useLayoutEffect)(()=>{d.current=u.mutate});let f=(0,z.useRef)(u.reset);(0,z.useLayoutEffect)(()=>{f.current=u.reset}),(0,z.useEffect)(()=>{e&&!l.current&&d.current({path:{assistant_id:t}}),l.current=e},[e,t]),(0,z.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let p=(0,z.useCallback)(()=>{f.current(),o(!1),c.current&&=(clearTimeout(c.current),null),r()},[r]),m=(0,z.useCallback)(e=>{I(e,{errorMessage:`Couldn't copy the invite link.`,onCopied:()=>{o(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>o(!1),2e3)}})},[]),h=u.isSuccess&&u.data.token?R({senderAssistantId:t,token:u.data.token}):``;return(0,B.jsx)(x.Root,{open:e,onOpenChange:e=>{e||p()},children:(0,B.jsxs)(x.Content,{size:`sm`,children:[(0,B.jsx)(x.Header,{children:(0,B.jsx)(x.Title,{children:`Share Connection Link`})}),(0,B.jsx)(x.Body,{children:u.isPending?(0,B.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:[(0,B.jsx)(y,{className:`h-4 w-4 animate-spin`}),`Creating invite link…`]}):u.isError?(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsx)(`p`,{role:`alert`,className:`!m-0 text-body-medium-lighter`,style:{color:`var(--system-negative-strong)`},children:`Failed to create invite link. Make sure A2A is enabled for your assistant.`}),(0,B.jsx)(n,{variant:`outlined`,onClick:()=>u.mutate({path:{assistant_id:t}}),children:`Try Again`})]}):u.isSuccess?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(s,{variant:`body-medium-lighter`,style:{color:`var(--content-secondary)`},children:`Share this link with another assistant owner to establish a connection.`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(b,{type:`text`,readOnly:!0,value:h,fullWidth:!0,wrapperClassName:`flex-1`,className:`font-mono`,onFocus:e=>e.currentTarget.select()}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>m(h),"aria-label":`Copy invite link`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-[var(--border-base)] hover:bg-[var(--surface-hover)]`,children:i?(0,B.jsx)(g,{className:`h-4 w-4`}):(0,B.jsx)(_,{className:`h-4 w-4`})})]}),u.data.expiresAt!=null&&(0,B.jsx)(s,{variant:`body-small-default`,style:{color:`var(--content-tertiary)`},children:J(u.data.expiresAt)})]}):null}),(0,B.jsx)(x.Footer,{children:(0,B.jsx)(n,{variant:`outlined`,onClick:p,children:`Done`})})]})})}function X({onClick:e}){return(0,B.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:(0,B.jsx)(v,{className:`h-3.5 w-3.5`}),onClick:e,children:`Share Connection Link`})}function Z(e){return typeof e==`string`&&V.includes(e)}function Q(e){return U.has(e)}function te(e){return(e?.policies??[]).filter(e=>!Q(e.channelType)&&!G(e.channelType)).map(e=>({...e,policy:Z(e.policy)?e.policy:`trusted_contacts`}))}async function ne(e,t,n,r){if(Q(t))throw new T(403,`Channel "${t}" is internal and is not user-configurable.`);let{data:i,error:a,response:o}=await F({path:{assistant_id:e,channel_type:t},body:{policy:n,note:r??null},throwOnError:!1});if(C(o,a,`Failed to save channel policy.`),!o.ok)throw new T(o.status,w(a,o,`Failed to save channel policy.`));if(!i?.policy)throw new T(500,`Gateway returned no policy in response.`);return i.policy}var re=`0.10.0`;function $(){return S(re)}function ie(e){let t=r(),n=$(),o=(0,z.useMemo)(()=>({path:{assistant_id:e}}),[e]),s=(0,z.useMemo)(()=>l(o),[o]),u=i({...d(o),enabled:n,select:te}),f=(0,z.useMemo)(()=>{let e={};for(let t of u.data??[])c(t.channelType)&&(e[t.channelType]=t.policy);return e},[u.data]),p=a({mutationFn:({channelKey:t,policy:n})=>ne(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:s}),onError:L(`Failed to save channel policy`)}),m=(0,z.useCallback)((e,t)=>{p.mutate({channelKey:e,policy:t})},[p]);return n?{policies:f,savingKey:p.isPending?p.variables?.channelKey??null:null,isLoading:u.isPending,isError:u.isError,onChange:m}:{policies:void 0,savingKey:null,isLoading:!1,isError:!1,onChange:void 0}}var ae={slack:`I want to reach you on Slack. Let's set it up.`,telegram:`I want to reach you on Telegram. Let's set it up.`,phone:`I want to be able to call you. Let's set you up with a phone number.`},oe=15e3;function se({assistantId:e,onStartSetupConversation:t}){let n=r(),o=(0,z.useMemo)(()=>({path:{assistant_id:e}}),[e]),s=(0,z.useMemo)(()=>N(o),[o]),c=i({...M(o),enabled:!!e,refetchInterval:oe,select:e=>e.snapshots}),l=(0,z.useMemo)(()=>ce(c.data??[]),[c.data]),d=l.some(e=>e.key===`slack`&&e.status===`ready`),m=i({...j(o),enabled:d,select:e=>e.threadMode}),g=ie(e),_=(0,z.useCallback)(()=>n.invalidateQueries({queryKey:s}),[n,s]),v=a({mutationFn:async t=>{let n={path:{assistant_id:e},throwOnError:!0};t===`slack`?await E(n):t===`telegram`?await D(n):t===`phone`&&await O(n)},onSettled:(t,r,i)=>{_(),i===`slack`&&u(n,e)}}),y=f({assistantId:e}),b=p({assistantId:e}),x=h({assistantId:e}),S=a({...A(),onSuccess:()=>{n.invalidateQueries({queryKey:ee(o)})}}),C=y.mutateAsync,w=(0,z.useCallback)(async e=>{await C(e)},[C]),T=b.mutate,k=(0,z.useCallback)((e,t)=>{T({botToken:e,appToken:t})},[T]),P=S.mutate,F=(0,z.useCallback)(t=>{P({path:{assistant_id:e},body:{threadMode:t}})},[P,e]),I=x.mutateAsync,L=(0,z.useCallback)(async(e,t)=>{await I({accountSid:e,authToken:t})},[I]),R=(0,z.useCallback)(e=>{t&&t(ae[e])},[t]),B=v.mutate,V=(0,z.useCallback)(e=>{B(e)},[B]);return{channels:l,pendingChannelKey:v.isPending?v.variables??null:null,slackThreadMode:m.data,slackThreadModePending:S.isPending,channelPolicies:g.policies,policySavingKey:g.savingKey,policiesLoading:g.isLoading,policiesError:g.isError,onChannelPolicyChange:g.onChange,onSetup:t?R:void 0,onDisconnect:V,onSaveTelegramToken:w,onSaveSlackConfig:k,slackSaveStatus:b.status,slackSaveError:b.error?.message??null,onSlackThreadModeChange:F,onSaveTwilioCredentials:L}}function ce(e){let t=new Map;for(let n of e)t.set(n.channel,n);return m.map(e=>{let n=t.get(e);return{key:e,status:le(n),address:n?.channelHandle??void 0}})}function le(e){return e?e.ready||e.setupStatus===`ready`?`ready`:e.setupStatus===`incomplete`?`incomplete`:`not_configured`:`not_configured`}function ue(e){let t=r(),[n,i]=(0,z.useState)(!1);return{isOpen:n,open:(0,z.useCallback)(()=>{i(!0)},[]),close:(0,z.useCallback)(()=>{i(!1),t.invalidateQueries({queryKey:P({path:{assistant_id:e}})})},[t,e])}}export{H as a,q as c,Y as i,se as n,V as o,X as r,K as s,ue as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{c as t,r as n,s as r,t as i}from"./local-settings-Bx7FsNo5.js";import{s as a}from"./device-settings-CUIsZfaf.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-Dy5001j6.js";import{t as c}from"./jsx-runtime-D3ZM-ToX.js";import{t as l}from"./createLucideIcon-CAM1RhH8.js";import"./src-Da9g8qsW.js";import{t as u}from"./checkbox-PU47Djxg.js";import{t as d}from"./triangle-alert-D6bAGtMw.js";import{t as f}from"./notice-Dslxs3H6.js";import{t as p}from"./modal-xr_vw1ZO.js";import{i as m,t as h}from"./api-CGsj1Pig.js";import{t as g}from"./client-feature-flag-store-Cw39NfCq.js";import{a as _,i as v}from"./typed-storage-OO7emDaU.js";import{n as y,r as b,t as x}from"./theme-preferences-B2X7Xgir.js";import{t as S}from"./use-bus-subscription-DiCq1_ki.js";import{o as C}from"./funnel-events-B9hFLlxs.js";var w=l(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),T=l(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]);function ee(){return g.use.stringFlags().proactiveTips??`off`}function te(e){return e===`on`}function E(e){return e===void 0||typeof e==`number`&&Number.isFinite(e)}function D(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.shownCount==`number`&&Number.isFinite(t.shownCount)&&E(t.dismissedAt)&&E(t.lastShownAt)}function O(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n={};for(let[e,r]of Object.entries(t))D(r)&&(n[e]=r);return n}function k(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}var A=v({key:`device:tips:records`,scope:`device`,parse:O,serialize:JSON.stringify,fallback:{}}),ne=v({key:`device:tips:enabled`,scope:`device`,parse:_,serialize:String,fallback:!0}),j=v({key:`device:tips:first_seen_at`,scope:`device`,parse:k,serialize:String,fallback:0});function re(){j.load()===0&&j.save(Date.now())}function ie(e,t){let n=A.load(),r=n[e];A.save({...n,[e]:{...r,lastShownAt:t,shownCount:(r?.shownCount??0)+1}})}function ae(e,t){let n=A.load(),r=n[e];A.save({...n,[e]:{...r,dismissedAt:t,shownCount:r?.shownCount??0}})}var oe=`proactive-tips-v1`,se={impression:0,learn_more:1,dismiss:2,dont_show_again:3,click:4,completion:5};function M(e,t,n){C({stepName:t,stepIndex:se[t]},{funnelVersion:oe,screen:e,variant:n})}var N=e(o(),1);function P(){let e=g.use.velvet(),[t,n]=(0,N.useState)(()=>y({velvetEnabled:e}));return(0,N.useEffect)(()=>{n(y({velvetEnabled:e}))},[e]),(0,N.useEffect)(()=>a(`theme`,()=>{n(y({velvetEnabled:e}))}),[e]),(0,N.useEffect)(()=>{x(t)},[t]),{theme:t,setThemePreference:e=>{n(e),b(e)}}}var F=6e4;function I(e){return!!(e?.enabled&&e.effectivelyLocked)}function L(e){return I(e)?e.acknowledged&&!e.overrideActive:!1}function R(e){return!!(e&&I(e)&&!e.acknowledged&&!e.overrideActive)}function z(e){return!!(e?.enabled&&e.state===`warning`)}function B(e){return R(e)?`acknowledgement-required`:L(e)?`cleanup`:z(e)?`warning`:`inactive`}function V({monitorEnabled:e,hasResolvedStatus:t,status:n}){return!e||!t?null:R(n)?`acknowledgement-required`:null}function H(e){return`Storage cleanup mode must be acknowledged before sending messages.`}function U(e,t){return e===t?!0:!e||!t?!1:e.enabled===t.enabled&&e.state===t.state&&e.locked===t.locked&&e.acknowledged===t.acknowledged&&e.overrideActive===t.overrideActive&&e.effectivelyLocked===t.effectivelyLocked&&e.lockId===t.lockId&&e.usagePercent===t.usagePercent&&e.thresholdPercent===t.thresholdPercent&&e.path===t.path&&e.lastCheckedAt===t.lastCheckedAt&&e.error===t.error&&e.blockedCapabilities.length===t.blockedCapabilities.length&&e.blockedCapabilities.every((e,n)=>e===t.blockedCapabilities[n])}function W(e){return e?.usagePercent==null||!Number.isFinite(e.usagePercent)?`Unknown`:`${Math.round(e.usagePercent)}%`}var G={assistantId:null,status:null,hasResolvedStatus:!1};function ce(e,t){return e instanceof Error?e:Error(t)}function le({assistantId:e,enabled:t,refreshKey:n,cadenceMs:r=F}){let[i,a]=(0,N.useState)(G),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(null),u=(0,N.useRef)(e),d=(0,N.useRef)(t),f=(0,N.useRef)(0),p=(0,N.useRef)(0);(0,N.useLayoutEffect)(()=>{u.current=e,d.current=t}),(0,N.useEffect)(()=>{f.current+=1,a(G),l(null),s(!1)},[e,t]);let g=(0,N.useCallback)((e,t)=>d.current&&u.current===e&&f.current===t,[]),_=(0,N.useCallback)((e,t,n,r)=>{g(e,r)&&a(r=>r.assistantId===e&&r.hasResolvedStatus===n&&U(r.status,t)?r:{assistantId:e,status:t,hasResolvedStatus:n})},[g]),v=(0,N.useCallback)(()=>{f.current+=1,a(G)},[]),y=(0,N.useCallback)(async()=>{let n=e;if(!t||!n){v();return}let r=f.current,i=p.current+1;p.current=i;try{let e=await m(n);if(p.current!==i)return;if(!e.ok){_(n,null,!1,r);return}_(n,e.data.status,!0,r)}catch{if(p.current!==i)return;_(n,null,!1,r)}},[e,_,v,t]);(0,N.useEffect)(()=>{if(!t||!e)return;y();let n=window.setInterval(()=>{y()},r);return()=>{window.clearInterval(n)}},[e,r,t,y,n]),S(`app.resume`,()=>{y()});let b=(0,N.useCallback)(n=>{if(!t||!e){v();return}let r=f.current+1;f.current=r,s(!1),l(null),_(e,n,!0,r)},[e,_,v,t]);S(`sse.event`,e=>{let t=e.message;t.type===`disk_pressure_status_changed`&&b(t.status)});let x=(0,N.useCallback)(async()=>{let n=e;if(!t||!n){v();return}let r=f.current+1;f.current=r,s(!0),l(null);try{let e=await h(n);if(!e.ok)throw Error(`Failed to acknowledge assistant disk pressure.`);if(!g(n,r))return;let t=f.current+1;f.current=t,_(n,e.data.status,!0,t),s(!1)}catch(e){g(n,r)&&l(ce(e,`Failed to acknowledge assistant disk pressure.`))}finally{g(n,r)&&s(!1)}},[e,_,v,t,g]),C=t&&i.assistantId===e?i.status:null,w=!!(t&&e&&i.assistantId===e&&i.hasResolvedStatus);return{status:C,mode:(0,N.useMemo)(()=>B(C),[C]),hasResolvedStatus:w,isAcknowledging:o,acknowledgeError:c,acknowledge:x,applyStatusEvent:b,refresh:y}}var K=c();function ue(e){let{status:t,mode:n,isAcknowledging:r=!1,acknowledgeError:i,onAcknowledge:a,onDismissWarning:o,onReviewWorkspaceData:c,onUpgradeStorage:l}=e,[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(!1),v=W(t);if(n===`warning`){let e=t.usagePercent??0;return(0,K.jsx)(f,{tone:`warning`,title:`Your storage is almost full`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),onDismiss:o?()=>o(g):void 0,className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${e}%`,backgroundColor:`var(--system-mid-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-mid-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:l?`Free up space or add more storage to avoid interruptions.`:`Free up space to avoid interruptions.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:c,children:`Manage Storage`}),l&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Upgrade`}),o?(0,K.jsx)(u,{className:`ml-auto`,checked:g,onCheckedChange:e=>_(e===!0),label:`Don't show again`,"data-testid":`disk-pressure-banner-dont-show-again`}):null]})]})})}if(n===`cleanup`){let e=t.usagePercent??0;return(0,K.jsx)(f,{tone:`warning`,title:`Cleanup mode is active`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${e}%`,backgroundColor:`var(--system-mid-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-mid-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:`Prompt your assistant to free up space before it runs out and enters a locked state.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:c,children:`Manage Storage`}),l&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Upgrade`})]})]})})}let y=t.usagePercent??0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(f,{tone:`error`,title:`Storage is critically low`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${y}%`,backgroundColor:`var(--system-negative-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-negative-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:`Your assistant will enter a locked state if it runs out of storage.`}),i?(0,K.jsx)(`span`,{className:`text-[var(--system-negative-strong)]`,role:`alert`,children:i}):null,(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,K.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>h(!0),children:`Review`})})]})}),(0,K.jsx)(p.Root,{open:m,onOpenChange:e=>{e||h(!1)},children:(0,K.jsxs)(p.Content,{size:`sm`,children:[(0,K.jsx)(p.Header,{children:(0,K.jsx)(p.Title,{icon:d,children:`Storage is critically low`})}),(0,K.jsx)(p.Body,{children:(0,K.jsx)(p.Description,{children:`Your assistant will enter a locked state if it runs out of storage. You should either prompt your assistant to free up space or increase your storage.`})}),(0,K.jsxs)(p.Footer,{children:[l&&(0,K.jsx)(s,{variant:`outlined`,onClick:()=>{h(!1),l()},children:`Upgrade`}),(0,K.jsx)(s,{variant:`primary`,disabled:r,onClick:()=>{a(),h(!1)},children:r?`Acknowledging...`:`Acknowledge`})]})]})})]})}var de=v({key:`device:cmd_enter_to_send`,scope:`device`,parse:_,serialize:String,fallback:!1}),fe=v({key:`device:show_context_window_indicator`,scope:`device`,parse:_,serialize:String,fallback:!1}),q=`app.iosNudge.downloaded`,J=`app.iosNudge.bannerDismissed`,Y=`app.iosNudge.assistantTurnsSeen`,pe=`https://apps.apple.com/us/app/vellum-assistant/id6759934423`;function me(){return i(q,!1)}function X(){r(q,!0)}function he(){return i(J,!1)}function Z(){r(J,!0)}function Q(){return Math.max(0,n(Y,0))}function ge(e=1){e<=0||t(Y,Q()+e)}function _e(){let[e,t]=(0,N.useState)(!1),[n,r]=(0,N.useState)(!1);(0,N.useEffect)(()=>{t(me()),r(he())},[]);let i=(0,N.useCallback)(()=>{$(),X(),t(!0)},[]),a=(0,N.useCallback)(()=>{Z(),r(!0)},[]);return{bannerShouldShow:!e&&!n,handleDownload:i,handleBannerDismiss:a}}function $(){window.open(pe,`_blank`,`noopener,noreferrer`)}export{w as C,T as S,A as _,X as a,te as b,ue as c,V as d,P as f,ie as g,ae as h,_e as i,le as l,re as m,$ as n,de as o,M as p,Q as r,fe as s,ge as t,H as u,ne as v,ee as x,j as y};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{c as t,r as n,s as r,t as i}from"./local-settings-Bx7FsNo5.js";import{s as a}from"./device-settings-CUIsZfaf.js";import{t as o}from"./react-BFJW0bSv.js";import{t as s}from"./button-BwFudwM5.js";import{t as c}from"./jsx-runtime-D3ZM-ToX.js";import{t as l}from"./createLucideIcon-CAM1RhH8.js";import"./src-CwGlaCIx.js";import{t as u}from"./checkbox-fzrjTRTI.js";import{t as d}from"./triangle-alert-D6bAGtMw.js";import{t as f}from"./notice-Dslxs3H6.js";import{t as p}from"./modal-DagTZ8xj.js";import{i as m,t as h}from"./api-CGsj1Pig.js";import{t as g}from"./client-feature-flag-store-Cw39NfCq.js";import{a as _,i as v}from"./typed-storage-OO7emDaU.js";import{n as y,r as b,t as x}from"./theme-preferences-B2X7Xgir.js";import{t as S}from"./use-bus-subscription-DiCq1_ki.js";import{o as C}from"./funnel-events-B9hFLlxs.js";var w=l(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),T=l(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]);function ee(){return g.use.stringFlags().proactiveTips??`off`}function te(e){return e===`on`}function E(e){return e===void 0||typeof e==`number`&&Number.isFinite(e)}function D(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.shownCount==`number`&&Number.isFinite(t.shownCount)&&E(t.dismissedAt)&&E(t.lastShownAt)}function O(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n={};for(let[e,r]of Object.entries(t))D(r)&&(n[e]=r);return n}function k(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}var A=v({key:`device:tips:records`,scope:`device`,parse:O,serialize:JSON.stringify,fallback:{}}),ne=v({key:`device:tips:enabled`,scope:`device`,parse:_,serialize:String,fallback:!0}),j=v({key:`device:tips:first_seen_at`,scope:`device`,parse:k,serialize:String,fallback:0});function re(){j.load()===0&&j.save(Date.now())}function ie(e,t){let n=A.load(),r=n[e];A.save({...n,[e]:{...r,lastShownAt:t,shownCount:(r?.shownCount??0)+1}})}function ae(e,t){let n=A.load(),r=n[e];A.save({...n,[e]:{...r,dismissedAt:t,shownCount:r?.shownCount??0}})}var oe=`proactive-tips-v1`,se={impression:0,learn_more:1,dismiss:2,dont_show_again:3,click:4,completion:5};function M(e,t,n){C({stepName:t,stepIndex:se[t]},{funnelVersion:oe,screen:e,variant:n})}var N=e(o(),1);function P(){let e=g.use.velvet(),[t,n]=(0,N.useState)(()=>y({velvetEnabled:e}));return(0,N.useEffect)(()=>{n(y({velvetEnabled:e}))},[e]),(0,N.useEffect)(()=>a(`theme`,()=>{n(y({velvetEnabled:e}))}),[e]),(0,N.useEffect)(()=>{x(t)},[t]),{theme:t,setThemePreference:e=>{n(e),b(e)}}}var F=6e4;function I(e){return!!(e?.enabled&&e.effectivelyLocked)}function L(e){return I(e)?e.acknowledged&&!e.overrideActive:!1}function R(e){return!!(e&&I(e)&&!e.acknowledged&&!e.overrideActive)}function z(e){return!!(e?.enabled&&e.state===`warning`)}function B(e){return R(e)?`acknowledgement-required`:L(e)?`cleanup`:z(e)?`warning`:`inactive`}function V({monitorEnabled:e,hasResolvedStatus:t,status:n}){return!e||!t?null:R(n)?`acknowledgement-required`:null}function H(e){return`Storage cleanup mode must be acknowledged before sending messages.`}function U(e,t){return e===t?!0:!e||!t?!1:e.enabled===t.enabled&&e.state===t.state&&e.locked===t.locked&&e.acknowledged===t.acknowledged&&e.overrideActive===t.overrideActive&&e.effectivelyLocked===t.effectivelyLocked&&e.lockId===t.lockId&&e.usagePercent===t.usagePercent&&e.thresholdPercent===t.thresholdPercent&&e.path===t.path&&e.lastCheckedAt===t.lastCheckedAt&&e.error===t.error&&e.blockedCapabilities.length===t.blockedCapabilities.length&&e.blockedCapabilities.every((e,n)=>e===t.blockedCapabilities[n])}function W(e){return e?.usagePercent==null||!Number.isFinite(e.usagePercent)?`Unknown`:`${Math.round(e.usagePercent)}%`}var G={assistantId:null,status:null,hasResolvedStatus:!1};function ce(e,t){return e instanceof Error?e:Error(t)}function le({assistantId:e,enabled:t,refreshKey:n,cadenceMs:r=F}){let[i,a]=(0,N.useState)(G),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(null),u=(0,N.useRef)(e),d=(0,N.useRef)(t),f=(0,N.useRef)(0),p=(0,N.useRef)(0);(0,N.useLayoutEffect)(()=>{u.current=e,d.current=t}),(0,N.useEffect)(()=>{f.current+=1,a(G),l(null),s(!1)},[e,t]);let g=(0,N.useCallback)((e,t)=>d.current&&u.current===e&&f.current===t,[]),_=(0,N.useCallback)((e,t,n,r)=>{g(e,r)&&a(r=>r.assistantId===e&&r.hasResolvedStatus===n&&U(r.status,t)?r:{assistantId:e,status:t,hasResolvedStatus:n})},[g]),v=(0,N.useCallback)(()=>{f.current+=1,a(G)},[]),y=(0,N.useCallback)(async()=>{let n=e;if(!t||!n){v();return}let r=f.current,i=p.current+1;p.current=i;try{let e=await m(n);if(p.current!==i)return;if(!e.ok){_(n,null,!1,r);return}_(n,e.data.status,!0,r)}catch{if(p.current!==i)return;_(n,null,!1,r)}},[e,_,v,t]);(0,N.useEffect)(()=>{if(!t||!e)return;y();let n=window.setInterval(()=>{y()},r);return()=>{window.clearInterval(n)}},[e,r,t,y,n]),S(`app.resume`,()=>{y()});let b=(0,N.useCallback)(n=>{if(!t||!e){v();return}let r=f.current+1;f.current=r,s(!1),l(null),_(e,n,!0,r)},[e,_,v,t]);S(`sse.event`,e=>{let t=e.message;t.type===`disk_pressure_status_changed`&&b(t.status)});let x=(0,N.useCallback)(async()=>{let n=e;if(!t||!n){v();return}let r=f.current+1;f.current=r,s(!0),l(null);try{let e=await h(n);if(!e.ok)throw Error(`Failed to acknowledge assistant disk pressure.`);if(!g(n,r))return;let t=f.current+1;f.current=t,_(n,e.data.status,!0,t),s(!1)}catch(e){g(n,r)&&l(ce(e,`Failed to acknowledge assistant disk pressure.`))}finally{g(n,r)&&s(!1)}},[e,_,v,t,g]),C=t&&i.assistantId===e?i.status:null,w=!!(t&&e&&i.assistantId===e&&i.hasResolvedStatus);return{status:C,mode:(0,N.useMemo)(()=>B(C),[C]),hasResolvedStatus:w,isAcknowledging:o,acknowledgeError:c,acknowledge:x,applyStatusEvent:b,refresh:y}}var K=c();function ue(e){let{status:t,mode:n,isAcknowledging:r=!1,acknowledgeError:i,onAcknowledge:a,onDismissWarning:o,onReviewWorkspaceData:c,onUpgradeStorage:l}=e,[m,h]=(0,N.useState)(!1),[g,_]=(0,N.useState)(!1),v=W(t);if(n===`warning`){let e=t.usagePercent??0;return(0,K.jsx)(f,{tone:`warning`,title:`Your storage is almost full`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),onDismiss:o?()=>o(g):void 0,className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${e}%`,backgroundColor:`var(--system-mid-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-mid-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:l?`Free up space or add more storage to avoid interruptions.`:`Free up space to avoid interruptions.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:c,children:`Manage Storage`}),l&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Upgrade`}),o?(0,K.jsx)(u,{className:`ml-auto`,checked:g,onCheckedChange:e=>_(e===!0),label:`Don't show again`,"data-testid":`disk-pressure-banner-dont-show-again`}):null]})]})})}if(n===`cleanup`){let e=t.usagePercent??0;return(0,K.jsx)(f,{tone:`warning`,title:`Cleanup mode is active`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${e}%`,backgroundColor:`var(--system-mid-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-mid-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:`Prompt your assistant to free up space before it runs out and enters a locked state.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:c,children:`Manage Storage`}),l&&(0,K.jsx)(s,{variant:`outlined`,size:`compact`,onClick:l,children:`Upgrade`})]})]})})}let y=t.usagePercent??0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(f,{tone:`error`,title:`Storage is critically low`,icon:(0,K.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),className:`p-4`,"data-testid":`disk-pressure-banner`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-[var(--surface-active)]`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-300`,style:{width:`${y}%`,backgroundColor:`var(--system-negative-strong)`}})}),(0,K.jsx)(`span`,{className:`text-body-medium-default shrink-0 tabular-nums text-[color:var(--system-negative-strong)]`,children:v})]}),(0,K.jsx)(`p`,{className:`m-0`,children:`Your assistant will enter a locked state if it runs out of storage.`}),i?(0,K.jsx)(`span`,{className:`text-[var(--system-negative-strong)]`,role:`alert`,children:i}):null,(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,K.jsx)(s,{variant:`primary`,size:`compact`,onClick:()=>h(!0),children:`Review`})})]})}),(0,K.jsx)(p.Root,{open:m,onOpenChange:e=>{e||h(!1)},children:(0,K.jsxs)(p.Content,{size:`sm`,children:[(0,K.jsx)(p.Header,{children:(0,K.jsx)(p.Title,{icon:d,children:`Storage is critically low`})}),(0,K.jsx)(p.Body,{children:(0,K.jsx)(p.Description,{children:`Your assistant will enter a locked state if it runs out of storage. You should either prompt your assistant to free up space or increase your storage.`})}),(0,K.jsxs)(p.Footer,{children:[l&&(0,K.jsx)(s,{variant:`outlined`,onClick:()=>{h(!1),l()},children:`Upgrade`}),(0,K.jsx)(s,{variant:`primary`,disabled:r,onClick:()=>{a(),h(!1)},children:r?`Acknowledging...`:`Acknowledge`})]})]})})]})}var de=v({key:`device:cmd_enter_to_send`,scope:`device`,parse:_,serialize:String,fallback:!1}),fe=v({key:`device:show_context_window_indicator`,scope:`device`,parse:_,serialize:String,fallback:!1}),q=`app.iosNudge.downloaded`,J=`app.iosNudge.bannerDismissed`,Y=`app.iosNudge.assistantTurnsSeen`,pe=`https://apps.apple.com/us/app/vellum-assistant/id6759934423`;function me(){return i(q,!1)}function X(){r(q,!0)}function he(){return i(J,!1)}function Z(){r(J,!0)}function Q(){return Math.max(0,n(Y,0))}function ge(e=1){e<=0||t(Y,Q()+e)}function _e(){let[e,t]=(0,N.useState)(!1),[n,r]=(0,N.useState)(!1);(0,N.useEffect)(()=>{t(me()),r(he())},[]);let i=(0,N.useCallback)(()=>{$(),X(),t(!0)},[]),a=(0,N.useCallback)(()=>{Z(),r(!0)},[]);return{bannerShouldShow:!e&&!n,handleDownload:i,handleBannerDismiss:a}}function $(){window.open(pe,`_blank`,`noopener,noreferrer`)}export{w as C,T as S,A as _,X as a,te as b,ue as c,V as d,P as f,ie as g,ae as h,_e as i,le as l,re as m,$ as n,de as o,M as p,Q as r,fe as s,ge as t,H as u,ne as v,ee as x,j as y};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useMutation-CXGTrp4W.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./card-DRIctGVs.js";import{t as o}from"./createLucideIcon-CAM1RhH8.js";import{t as s}from"./brain-CN4zzNgU.js";import"./src-Da9g8qsW.js";import{t as c}from"./globe-CdLn4IX7.js";import{t as l}from"./puzzle-4NgH5snP.js";import{t as u}from"./terminal-BucMVaPU.js";import{t as d}from"./user-DHC7OLPE.js";import{t as f}from"./tag-gOOX7fbA.js";import{n as p,r as m,t as h}from"./api-errors-BRGPPSWw.js";import{hr as g}from"./sdk.gen-CjtCuSlS.js";import{ln as _}from"./react-query.gen-C7om930f.js";import{t as v}from"./skills-CbF2uKXV.js";var y=o(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),b=e(t(),1),x=i();function S({skill:e,className:t,fallback:n=`🧩`}){let[r,i]=(0,b.useState)(!1);return e.icon&&!r?(0,x.jsx)(`img`,{src:`/assistant/skills/${e.id}/${e.icon}`,alt:``,className:`${t} object-contain`,onError:()=>i(!0)}):(0,x.jsx)(`span`,{className:t,children:e.emoji??n})}var C={vellum:{label:`Vellum`,icon:y},clawhub:{label:`Clawhub`,icon:c},skillssh:{label:`skills.sh`,icon:u},custom:{label:`Custom`,icon:d},"assistant-memory":{label:`Assistant's Memory`,icon:s}};function w({origin:e}){let t=e in C?C[e]:{label:e.replace(/-/g,` `),icon:l};return(0,x.jsx)(f,{tone:`neutral`,leftIcon:(0,b.createElement)(t.icon),className:`capitalize`,children:t.label})}function T(e){return e.kind===`installed`||e.kind===`bundled`}function E(e){return e.kind===`catalog`}function D({icon:e,iconColor:t=`var(--content-tertiary)`,title:n,subtitle:r,children:i}){return(0,x.jsx)(a.Root,{children:(0,x.jsxs)(a.Body,{className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,x.jsx)(e,{className:`mb-3 h-8 w-8`,style:{color:t},"aria-hidden":!0}),(0,x.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:n}),(0,x.jsx)(`p`,{className:`mt-1 max-w-sm text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:r}),i]})})}async function O(e,t,n){let{data:r,error:i,response:a}=await g({path:{assistant_id:e},body:n?{slug:t,version:n}:{slug:t},throwOnError:!1});if(p(a,i,`Failed to install skill.`),!a.ok)throw new h(a.status,m(i,a,`Failed to install skill.`));return r??{ok:!0}}function k(e,{onRemoved:t}={}){let i=n(),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(null),d=(0,b.useCallback)(()=>{v(i,e)},[e,i]),f=r({mutationFn:t=>O(e,t),onMutate:e=>o(e),onSettled:()=>{o(null),d()}}),p=_({onMutate:e=>c(e.path.id),onSuccess:()=>{t?.()},onSettled:()=>{c(null),d()}}),m=(0,b.useCallback)(e=>{f.mutate(e.slug??e.id)},[f]),h=(0,b.useCallback)(e=>{u(e)},[]),g=(0,b.useCallback)(()=>{l&&(p.mutate({path:{assistant_id:e,id:l.id}}),u(null))},[e,l,p]),y=(0,b.useCallback)(()=>{u(null)},[]);return{handleInstall:m,handleRemove:h,isInstallingSkill:(0,b.useCallback)(e=>a===(e.slug??e.id),[a]),isRemovingSkill:(0,b.useCallback)(e=>s===e.id,[s]),skillPendingRemoval:l,confirmRemove:g,cancelRemove:y}}export{w as a,T as i,D as n,S as o,E as r,y as s,k as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{n}from"./QueryClientProvider-CMu7CkQU.js";import{t as r}from"./useMutation-CXGTrp4W.js";import{t as i}from"./jsx-runtime-D3ZM-ToX.js";import{t as a}from"./card-DRIctGVs.js";import{t as o}from"./createLucideIcon-CAM1RhH8.js";import{t as s}from"./brain-CN4zzNgU.js";import"./src-CwGlaCIx.js";import{t as c}from"./globe-CdLn4IX7.js";import{t as l}from"./puzzle-4NgH5snP.js";import{t as u}from"./terminal-BucMVaPU.js";import{t as d}from"./user-DHC7OLPE.js";import{t as f}from"./tag-G0ELn_cq.js";import{n as p,r as m,t as h}from"./api-errors-BRGPPSWw.js";import{hr as g}from"./sdk.gen-CjtCuSlS.js";import{ln as _}from"./react-query.gen-C7om930f.js";import{t as v}from"./skills-CrZ3GlyK.js";var y=o(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),b=e(t(),1),x=i();function S({skill:e,className:t,fallback:n=`🧩`}){let[r,i]=(0,b.useState)(!1);return e.icon&&!r?(0,x.jsx)(`img`,{src:`/assistant/skills/${e.id}/${e.icon}`,alt:``,className:`${t} object-contain`,onError:()=>i(!0)}):(0,x.jsx)(`span`,{className:t,children:e.emoji??n})}var C={vellum:{label:`Vellum`,icon:y},clawhub:{label:`Clawhub`,icon:c},skillssh:{label:`skills.sh`,icon:u},custom:{label:`Custom`,icon:d},"assistant-memory":{label:`Assistant's Memory`,icon:s}};function w({origin:e}){let t=e in C?C[e]:{label:e.replace(/-/g,` `),icon:l};return(0,x.jsx)(f,{tone:`neutral`,leftIcon:(0,b.createElement)(t.icon),className:`capitalize`,children:t.label})}function T(e){return e.kind===`installed`||e.kind===`bundled`}function E(e){return e.kind===`catalog`}function D({icon:e,iconColor:t=`var(--content-tertiary)`,title:n,subtitle:r,children:i}){return(0,x.jsx)(a.Root,{children:(0,x.jsxs)(a.Body,{className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,x.jsx)(e,{className:`mb-3 h-8 w-8`,style:{color:t},"aria-hidden":!0}),(0,x.jsx)(`h3`,{className:`text-title-small`,style:{color:`var(--content-default)`},children:n}),(0,x.jsx)(`p`,{className:`mt-1 max-w-sm text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:r}),i]})})}async function O(e,t,n){let{data:r,error:i,response:a}=await g({path:{assistant_id:e},body:n?{slug:t,version:n}:{slug:t},throwOnError:!1});if(p(a,i,`Failed to install skill.`),!a.ok)throw new h(a.status,m(i,a,`Failed to install skill.`));return r??{ok:!0}}function k(e,{onRemoved:t}={}){let i=n(),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(null),d=(0,b.useCallback)(()=>{v(i,e)},[e,i]),f=r({mutationFn:t=>O(e,t),onMutate:e=>o(e),onSettled:()=>{o(null),d()}}),p=_({onMutate:e=>c(e.path.id),onSuccess:()=>{t?.()},onSettled:()=>{c(null),d()}}),m=(0,b.useCallback)(e=>{f.mutate(e.slug??e.id)},[f]),h=(0,b.useCallback)(e=>{u(e)},[]),g=(0,b.useCallback)(()=>{l&&(p.mutate({path:{assistant_id:e,id:l.id}}),u(null))},[e,l,p]),y=(0,b.useCallback)(()=>{u(null)},[]);return{handleInstall:m,handleRemove:h,isInstallingSkill:(0,b.useCallback)(e=>a===(e.slug??e.id),[a]),isRemovingSkill:(0,b.useCallback)(e=>s===e.id,[s]),skillPendingRemoval:l,confirmRemove:g,cancelRemove:y}}export{w as a,T as i,D as n,S as o,E as r,y as s,k as t};