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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/assets/{account-page-BB5Phl5s.js → account-page-CCYCSy2-.js} +1 -1
  2. package/dist/assets/{advanced-page-CMAf1fno.js → advanced-page-CVnT0zH-.js} +1 -1
  3. package/dist/assets/{ai-page-DcOYf6ki.js → ai-page-kEbHR7cH.js} +1 -1
  4. package/dist/assets/{api-key-screen-A7FySG-O.js → api-key-screen-DGVn66y4.js} +1 -1
  5. package/dist/assets/{archive-page-m3yQFOvD.js → archive-page-Dl6HLIJt.js} +1 -1
  6. package/dist/assets/{billing-page-C-JoA25u.js → billing-page-Cq_yLwUC.js} +1 -1
  7. package/dist/assets/{bookmarks-page-Cl2O0te-.js → bookmarks-page-CANlE7hP.js} +1 -1
  8. package/dist/assets/{command-palette-AdQxXi8M.js → command-palette-GZu_zgQg.js} +1 -1
  9. package/dist/assets/{command-palette-window-page-9TqGuzVu.js → command-palette-window-page-CzWu42Ee.js} +1 -1
  10. package/dist/assets/{community-page-DPCIsZX3.js → community-page-Dhgypa-h.js} +1 -1
  11. package/dist/assets/{contacts-page-route-BvCp-gAp.js → contacts-page-route-C3QiOxjO.js} +1 -1
  12. package/dist/assets/{debug-page-CTD3JrfL.js → debug-page-CBozmAQQ.js} +1 -1
  13. package/dist/assets/{deploy-dialogs-C0aZYWkv.js → deploy-dialogs-jf5VL1UP.js} +1 -1
  14. package/dist/assets/{developer-page-Dx6SbGPL.js → developer-page-iEL4eJ8x.js} +1 -1
  15. package/dist/assets/{devices-page-DtqksGFR.js → devices-page-RMaPGcXe.js} +1 -1
  16. package/dist/assets/{dictation-overlay-page-B9zcq9IK.js → dictation-overlay-page-BxQCzLMY.js} +1 -1
  17. package/dist/assets/{document-viewer-page-oeRhq2Yx.js → document-viewer-page-57OuXxYw.js} +1 -1
  18. package/dist/assets/{earn-credits-modal-3vmD9Fug.js → earn-credits-modal-Nm1VymMp.js} +1 -1
  19. package/dist/assets/{emails-page-C_RKF4jL.js → emails-page-0gRZqa6y.js} +1 -1
  20. package/dist/assets/{file-editor-wIYQnMM_.js → file-editor-BNkJJbUv.js} +1 -1
  21. package/dist/assets/{general-page-Bjr3EfG_.js → general-page-aZxTpnpI.js} +1 -1
  22. package/dist/assets/{hatching-screen-OMSxOyvX.js → hatching-screen-KPinlCES.js} +1 -1
  23. package/dist/assets/{home-page-route-BDyODWxN.js → home-page-route-CudtBGg1.js} +1 -1
  24. package/dist/assets/{hosting-screen-dwUA84uS.js → hosting-screen-C14KAJ6m.js} +1 -1
  25. package/dist/assets/{identity-page-route-Ds4SXg6o.js → identity-page-route-C0BFcTAF.js} +1 -1
  26. package/dist/assets/{index-BIDC22lX.js → index-PRnvH2Y1.js} +7 -7
  27. package/dist/assets/{inspect-page-CpIdOQCU.js → inspect-page-CWasyuSO.js} +1 -1
  28. package/dist/assets/{install-b0ONV1om.js → install-C3xe8ARr.js} +1 -1
  29. package/dist/assets/{integrations-page-Dw3rJqPE.js → integrations-page-WhBpTYP2.js} +1 -1
  30. package/dist/assets/{intelligence-layout-DovsSaK4.js → intelligence-layout-CvTumtjv.js} +1 -1
  31. package/dist/assets/{keyboard-shortcuts-page-B2rDCmXw.js → keyboard-shortcuts-page-kiOEZKzE.js} +1 -1
  32. package/dist/assets/{library-detail-page-BfwLhTzc.js → library-detail-page-rPvN9G1a.js} +1 -1
  33. package/dist/assets/{library-page-CKwzimBZ.js → library-page-BHejhapZ.js} +1 -1
  34. package/dist/assets/{login-page-aWGeNMsB.js → login-page-BGLVK82t.js} +1 -1
  35. package/dist/assets/{logout-page-BgczaAe_.js → logout-page-Bl6AD21S.js} +1 -1
  36. package/dist/assets/{logs-layout-Bb4h3S2N.js → logs-layout-C9eUE1Pt.js} +1 -1
  37. package/dist/assets/{memory-router-playground-page-gcwT23uj.js → memory-router-playground-page-Dhi3uqxr.js} +1 -1
  38. package/dist/assets/{mobile-sidebar-drawer-wA5GnkLS.js → mobile-sidebar-drawer-DqXFL0Ke.js} +1 -1
  39. package/dist/assets/{notifications-page-BilxDebz.js → notifications-page-pHiDPA0p.js} +1 -1
  40. package/dist/assets/{oauth-complete-page-CzAcy6Qj.js → oauth-complete-page-DiGMWbOb.js} +1 -1
  41. package/dist/assets/{oauth-popup-complete-page-CvE_74ec.js → oauth-popup-complete-page-CwoZnzdc.js} +1 -1
  42. package/dist/assets/{pairing-page-ddUW7kSm.js → pairing-page-clFaUgzL.js} +1 -1
  43. package/dist/assets/{plugin-detail-page-B-d90SJ8.js → plugin-detail-page-IRPeI4lP.js} +1 -1
  44. package/dist/assets/{plugins-page-tUsEY9_b.js → plugins-page-BaYp2QOe.js} +1 -1
  45. package/dist/assets/{prechat-route-in5c2S6S.js → prechat-route-BaMWiiaf.js} +1 -1
  46. package/dist/assets/{privacy-page-CpYx1RMr.js → privacy-page-BUhxrIRn.js} +1 -1
  47. package/dist/assets/{privacy-screen-Cd4yErpJ.js → privacy-screen-BaHYtKEt.js} +1 -1
  48. package/dist/assets/{provider-callback-page-BCXiAoax.js → provider-callback-page-CxFC4PH1.js} +1 -1
  49. package/dist/assets/{research-mock-page-DfC4Xf4z.js → research-mock-page-ttrrPwo3.js} +1 -1
  50. package/dist/assets/{research-onboarding-route-QentSADF.js → research-onboarding-route-Cxai0fux.js} +1 -1
  51. package/dist/assets/{review-terms-screen-kUBWOFsV.js → review-terms-screen-DEiifDmK.js} +1 -1
  52. package/dist/assets/{select-assistant-screen-DDdKrCaI.js → select-assistant-screen-UoixBMN2.js} +1 -1
  53. package/dist/assets/{settings-layout-CIAca9J9.js → settings-layout-CQ3Z9Raj.js} +1 -1
  54. package/dist/assets/{share-feedback-modal-sqz1cvkl.js → share-feedback-modal-CTwByE7B.js} +1 -1
  55. package/dist/assets/{sidebar-tree-BNLVikyu.js → sidebar-tree-BJkXpCut.js} +1 -1
  56. package/dist/assets/{signup-page-DOYf5rnz.js → signup-page-CKDYl9Wb.js} +1 -1
  57. package/dist/assets/{skills-page-pXRiOYxp.js → skills-page-DVjqqfMw.js} +1 -1
  58. package/dist/assets/{sounds-page-DZjipsnL.js → sounds-page-mens6EAJ.js} +1 -1
  59. package/dist/assets/{step-indicator-dots-D1EQV6VE.js → step-indicator-dots-CEVbsP8r.js} +1 -1
  60. package/dist/assets/{subagent-detail-panel-BhMGv4KW.js → subagent-detail-panel-DVQAkMjF.js} +1 -1
  61. package/dist/assets/{system-events-page-8chSE8WO.js → system-events-page-Dro8iNrx.js} +1 -1
  62. package/dist/assets/{tiptap-document-editor-BIYDH0gu.js → tiptap-document-editor-D2t4qYzv.js} +1 -1
  63. package/dist/assets/{tool-detail-panel-CltEAL4k.js → tool-detail-panel-DRD2DIMF.js} +1 -1
  64. package/dist/assets/{trace-page-Ceqkb39z.js → trace-page-DRWPaAuQ.js} +1 -1
  65. package/dist/assets/{upgrade-cancel-page-BLYBOQhL.js → upgrade-cancel-page-Cwv5eMh9.js} +1 -1
  66. package/dist/assets/{upgrade-success-page-Besx7BnU.js → upgrade-success-page-DnJ8Kyyj.js} +1 -1
  67. package/dist/assets/{usage-page-UvJrF1jZ.js → usage-page-DJHRS0lZ.js} +1 -1
  68. package/dist/assets/{voice-page-B6ocZCAN.js → voice-page-kQZ2ya5j.js} +1 -1
  69. package/dist/assets/{weather-forecast-display-JXZ2NoLx.js → weather-forecast-display-Cu3W6OZF.js} +1 -1
  70. package/dist/assets/{welcome-screen-4_W-iOJc.js → welcome-screen-Bd7PCfAf.js} +1 -1
  71. package/dist/assets/{workflow-detail-panel-BYvRNK8S.js → workflow-detail-panel-CMmPPsuL.js} +1 -1
  72. package/dist/assets/{workspace-page-D6Ak7heg.js → workspace-page-BR4pOxs5.js} +1 -1
  73. package/dist/index.html +1 -1
  74. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/native-file-B-MK3Ngg.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-BewR0kVT.js","assets/dist-BTp54SIT.js"])))=>i.map(i=>d[i]);
2
- import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Hr1Yo2kx.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D7s2Q_uG.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./typography-BscuIPxA.js";import{t as m}from"./card-BibIM9x3.js";import{t as h}from"./dropdown-CL8VmqrY.js";import{t as g}from"./confirm-dialog-CfOXCE1N.js";import{t as _}from"./notice-CqRgVmeL.js";import{t as v}from"./tag-B_-QAvJF.js";import{t as y}from"./input-C8kfrq9r.js";import{t as b}from"./toggle-X_kQW5my.js";import{n as x,t as S}from"./stat-square-B0S3fO7O.js";import{t as C}from"./modal-D0Q3UWD0.js";import{n as w}from"./toast-2TW5tj1Y.js";import{t as T}from"./createLucideIcon-BlMXrA59.js";import{t as E}from"./arrow-left-CP-EhDNF.js";import{t as D}from"./check-D6WkI0gF.js";import{t as O}from"./circle-alert-DvNg50UK.js";import{t as k}from"./circle-check-DzlJxj_M.js";import{t as A}from"./cpu-CiHv3fhs.js";import{t as j}from"./credit-card-BKRB1ZIi.js";import{n as M,t as N}from"./domain-field-DYwuCpup.js";import{t as P}from"./external-link-DPAtkBJ2.js";import{t as F}from"./file-text-CmK9LY1p.js";import{t as I}from"./hard-drive-D7_5VMhi.js";import{t as L}from"./info-_OtUK1cX.js";import{t as R}from"./loader-circle-IIzBGiwm.js";import{a as ee,c as te,i as ne,n as z,r as B,t as V}from"./resize-errors-DnJEbHn4.js";import{t as re}from"./triangle-alert-DKOyShqD.js";import{ot as ie,st as H}from"./sdk.gen-D-_js_oC.js";import{a as U}from"./routes-DVqkwUEe.js";import{n as ae}from"./use-is-mobile-Cy10kl9u.js";import{$ as oe,B as se,Ct as ce,G as le,H as ue,J as de,K as fe,O as pe,Q as me,R as he,St as ge,U as _e,V as ve,W as ye,X as be,Y as xe,Z as Se,bt as Ce,c as we,et as W,ht as Te,it as Ee,nt as De,ot as Oe,q as ke,r as G,rt as K,st as Ae,tt as je,y as Me,z as Ne}from"./react-query.gen-rp6Krcco.js";import{t as Pe}from"./effective-timezone-DrYGH2Lb.js";import{n as Fe,t as Ie}from"./browser-CKX_K5ev.js";import{Fi as Le,Ir as Re,Li as ze,Nr as Be,Ri as Ve,an as He,in as Ue,on as We,pi as Ge,ra as Ke,rn as qe,x as Je}from"./index-BIDC22lX.js";import{t as Ye}from"./add-credits-modal-Dy3I3Har.js";import{t as Xe}from"./format-date-CLlHK5gl.js";import{a as Ze,n as Qe,t as $e}from"./llm-dimension-CQdmYu05.js";import{r as et,t as tt}from"./usage-window-Wgtgd-cv.js";import{t as nt}from"./environment-store-CvH3J6fT.js";var rt=T(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),it=T(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),at=T(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),ot=T(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),st=T(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),q=e(r(),1),J=f();function ct({onBack:e}){let t=o(),{data:n}=u(G()),r=n?.name||`your assistant`;return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(at,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(U.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,J.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`})})]})}function lt({current:e,total:t=2}){return(0,J.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function ut({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,J.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,J.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var dt=1e3,ft=1e4;function pt(e){return ne[e]??ne.medium}var mt=[`machine_size`,`subdomain`,`non_field_errors`],ht={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`};function gt(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=ht[t.error];if(e)return e}for(let e of mt){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}function _t({onBack:e,onExit:t}){let n=l(),r=nt.use.emailRootDomain(),{data:a}=u(G()),o=a?.id,{data:s}=u({...we({path:{assistant_id:o??``}}),enabled:!!o}),c=s?.results?.[0],[f,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(`hi`),[v,y]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!v){if(c){m(c.subdomain),y(!0);return}!a?.handle||f||(m(a.handle),y(!0))}},[a?.handle,c,v,f]);let[b,x]=(0,q.useState)(null),[S,w]=(0,q.useState)(!1),T=d(Se()),D=!!c||S,O=T.isPending||S;return(0,q.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:Ge}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,J.jsx)(N,{subdomain:f,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:O,error:b,locked:D,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{value:h,onChange:e=>g(e.target.value.toLowerCase().trim()),disabled:O||D,readOnly:D,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(h.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(h.length,2)+1.5}ch`}}),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!D&&(0,J.jsxs)(_,{tone:`info`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:f||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,J.jsx)(_,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:O,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:0})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:D?(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:O,onClick:()=>{O||T.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||O,onClick:()=>{O||!f||T.mutate({body:{subdomain:f,...h?{email_username:h}:{}}},{onSuccess:()=>{x(null),w(!0),n.invalidateQueries({queryKey:Me()})},onError:e=>{x(gt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function vt({onGoToBilling:e}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:O,tone:`negative`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function yt({message:e,onRetry:t,onGoToBilling:n}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:O,tone:`warning`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,J.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function bt({title:e,body:t}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,J.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,J.jsx)(R,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:e}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function xt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,J.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function St({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=u(G()),c=s?.machine_size||`small`,l=s?.provisioned_storage_gib??null,f=pt(t),m=f.length>0?f[f.length-1]:c,h=m!==c,g=e!=null&&(l==null||l<e),[v,y]=(0,q.useState)(null),b=d(pe());return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:A}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h&&(0,J.jsx)(xt,{icon:A,label:`Machine`,from:B[c],fromDetail:z[c],to:B[m],toDetail:z[m]}),g&&(0,J.jsx)(xt,{icon:I,label:`Storage`,from:l==null?`—`:`${l} GiB`,to:`${e} GiB`}),!h&&!g&&(0,J.jsx)(_,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,J.jsx)(_,{tone:`error`,children:v}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:a,total:o})}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(gt(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Ct({onContinue:e,continueDisabled:t=!1}){return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(M,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,J.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function wt({open:e,onClose:t}){let n=l(),[r,i]=(0,q.useState)(`confirm-pro`),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(0);(0,q.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:je()}),n.invalidateQueries({queryKey:oe()}))},[e,n]);let d=(0,q.useCallback)(()=>{o(!1),c(e=>e+1),n.invalidateQueries({queryKey:je()})},[n]),f=u({...W(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:dt,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,q.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),ft);return()=>clearTimeout(t)},[e,r,s]),(0,q.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=u({...me(),enabled:e&&r!==`confirm-pro`});u({...G(),enabled:e});let m=p.data?.domain_setup_available,h=(0,q.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,q.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsx)(C.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,J.jsx)(vt,{onGoToBilling:t}):a?(0,J.jsx)(yt,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,J.jsx)(bt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,J.jsx)(vt,{onGoToBilling:t}):(0,J.jsx)(Ct,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,J.jsx)(_t,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,J.jsx)(vt,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,J.jsx)(St,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,J.jsx)(ct,{onBack:()=>i(`setup`)}):null}}var Tt=`billing-portal-return-snapshot`;function Et(e){try{sessionStorage.removeItem(Tt),sessionStorage.setItem(Tt,JSON.stringify(e))}catch{}}function Dt(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(Tt);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 Ot(){try{sessionStorage.removeItem(Tt)}catch{}}function kt(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 At(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function jt(e){return e?e.cancel_at??e.current_period_end??null:null}function Mt(e){let t=l();return(0,q.useEffect)(()=>Fe(()=>{t.invalidateQueries(W())}),[t]),ge({onSuccess:t=>{e&&Et(e),Ie(t.portal_url)},onError:()=>{w.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Nt(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Nt(e)}/mo`}function Pt(e){return`${e>0?`+`:`−`}${Nt(Math.abs(e))}/mo`}var Ft={medium:`Medium`,large:`Large`,xl:`XL`};function It(e){return e.disabled===!0}function Lt({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=Ft[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:It(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:It(e)}}),[t,s]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,J.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,J.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Rt=new Set([`active`,`trialing`,`past_due`]),zt=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function Bt(e,t){if(e&&typeof e==`object`){for(let t of zt)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 Vt(e,t){let n=e.filter(e=>!It(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Ht(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function Ut(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Wt({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,J.jsxs)(C.Content,{size:`md`,hideCloseButton:!0,children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:re,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,J.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Gt=`__none__`;function Kt(e){return`${e.label} — ${Y(e.price_cents)}`}function qt({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,q.useMemo)(()=>[{value:Gt,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:Kt(e)}))],[e]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,J.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Gt,onChange:e=>n(e===Gt?null:e),options:i})]})}function Jt({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,J.jsx)(J.Fragment,{children:e.slice(0,r).join(`, `)}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(k,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function Yt({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:f,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,machineTiersForPicker:x,storageTiersForPicker:S,currentMachinePrice:C,currentStoragePrice:w,currentCreditPriceUnknown:T,proCurrentTotalCents:E,proLiveTotalCents:D,proTotalDelta:O,onboardingLoading:k,tierChangePending:A,machineChanged:j,storageChanged:N,creditChanged:P,tierChangeError:F,upgradePending:I,portalPending:ee,onUpgrade:te,onApplyTierChange:ne,onDowngradeClick:z,onKeepPlan:B}){let V=e.id===`pro`,re=e.id===`base`,ie=V&&n&&r&&!a,H=V&&(!t||t&&c),U=V&&t&&c;return(0,J.jsxs)(m,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:V?(0,J.jsx)(M,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,J.jsx)(st,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,J.jsx)(p,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,J.jsx)(v,{tone:`positive`,children:`Current`})]}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:re?`All you need for a capable assistant`:`More features, more compute, more storage`}),ie&&o&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:re?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Free`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(H&&D!=null)&&(E==null||T)?k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:H&&D!=null?(0,J.jsxs)(J.Fragment,{children:[Y(D),O!=null&&O!==0&&(0,J.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Pt(O),`)`]})]}):E==null?e.id===`pro`?`From ${Y(e.base_price_cents+Ut(e.machine_tiers)+Ut(e.storage_tiers))}`:null:`Currently ${Y(E)}`}),H&&O!=null&&O!==0&&(0,J.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(E)} to ${Y(D)}.`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Nt(e.base_price_cents),` base fee`]})]})}),(0,J.jsx)(Jt,{features:e.included_features,variant:`checklist`}),V&&!l&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&V&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:I}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:te,disabled:I||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),U&&(k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:A}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,currentMachinePriceCents:C,currentStoragePriceCents:w}),F&&(0,J.jsx)(_,{tone:`error`,children:F}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:ne,disabled:A||!j&&!N&&!P,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&re&&n&&!r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:z,disabled:ee,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),ie&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:B,disabled:ee,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function Xt({open:e,onClose:t,onTierUpgraded:n}){let r=l(),a=u(fe()),o=u(W()),s=d(De()),c=d(xe()),f=d(be()),m=d(de()),h=Mt(kt(o.data)),[g,v]=(0,q.useState)(`plans`),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[T,D]=(0,q.useState)(null),[O,k]=(0,q.useState)(void 0);(0,q.useEffect)(()=>Fe(()=>{r.invalidateQueries({queryKey:je()}),r.invalidateQueries({queryKey:ke()}),r.invalidateQueries({queryKey:oe()}),t()}),[r,t]);let A=o.data?.plan_id,j=A===`pro`,M=u({...me(),enabled:j}),N=M.data?.max_machine_tier??null,P=M.data?.selected_storage_tier??null,F=M.data?.selected_storage_gib??null,I=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,L=o.data?.status===`canceled`,ee=jt(o.data),te=o.data?.status,ne=te!=null&&Rt.has(te),z=j&&ne&&!I&&!L,B=a.data?.plans.find(e=>e.id===`pro`),V=B?.credit_tiers??[],ie=V.length>0,H=o.data?.selected_credit_tier??null,U=e=>V.find(t=>t.tier===e)?.price_cents??0,ae=U(H),se=H!=null&&!V.some(e=>e.tier===H),ce=O===void 0?H:O,le=U(ce),ue=B?.machine_tiers??[],pe=z&&F!=null?(B?.storage_tiers??[]).map(e=>e.storage_gib<F?{...e,disabled:!0}:e):B?.storage_tiers??[];(0,q.useEffect)(()=>{if(!e){S(null),D(null),k(void 0);return}if(B){if(z){if(N==null||P==null)return;S(e=>Vt(ue,e??N)),D(e=>Vt(pe,e??P)),k(e=>Ht(V,e,H));return}S(e=>Vt(B.machine_tiers,e)),D(e=>Vt(B.storage_tiers,e)),k(e=>Ht(V,e,null))}},[e,B,z,N,P,H]);let he=a.data?.plans.find(e=>e.id===`base`),ge=new Set(he?.included_features??[]),_e=(B?.included_features??[]).filter(e=>!ge.has(e)),ve=()=>{if(!s.isPending){if(!x||!T){w.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:T,credit_tier:ce}},{onSuccess:e=>{if(e.checkout_url){Ie(e.checkout_url);return}if(e.status===`no_op`){w.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}w.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{w.error(Bt(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ye=()=>{h.isPending||(v(`plans`),h.mutate({}))},Se=()=>{r.invalidateQueries({queryKey:je()}),r.invalidateQueries({queryKey:oe()}),r.invalidateQueries({queryKey:ke()})},Ce=c.isPending||f.isPending||m.isPending,we=x!=null&&x!==N,Te=T!=null&&T!==P,Ee=ie&&O!==void 0&&O!==H,Oe=e=>ue.find(t=>t.tier===e)?.price_cents??null,G=e=>pe.find(t=>t.tier===e)?.price_cents??null,K=Oe(x),Ae=G(T),Me=Oe(N),Ne=G(P),Pe=we&&K!=null&&Me!=null&&K<Me,Le=()=>{if(Ce)return;let e=[];we&&x&&e.push(new Promise(e=>{c.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),Te&&T&&e.push(new Promise(e=>{f.mutate({body:{storage_tier:T}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),Ee&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:ce}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{Se();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Pe,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>Bt(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);w.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):w.success(Ee&&!we&&!Te?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Re=()=>{if(!Ce){if(Pe){b(!0);return}Le()}},ze=()=>{b(!1),Le()},Be=e=>K!=null&&Ae!=null?e.base_price_cents+K+Ae+le:null,Ve=e=>Me!=null&&Ne!=null?e.base_price_cents+Me+Ne+ae:null,He=c.isError||f.isError||m.isError?Bt(c.error??f.error??m.error,`Failed to update plan. Please try again.`):null,Ue=a.isLoading||o.isLoading,We=a.isError||o.isError||!a.data||!o.data;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,J.jsx)(C.Content,{size:g===`plans`?`lg`:`md`,children:g===`downgrade-confirm`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:re,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:_e.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:h.isPending,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(i,{variant:`danger`,onClick:ye,disabled:h.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,J.jsx)(C.Body,{children:Ue?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):We?(0,J.jsx)(_,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===A,n=e.id===`pro`&&B?Be(B):null,r=e.id===`pro`&&B?Ve(B):null;return(0,J.jsx)(Yt,{plan:e,isCurrent:t,onPro:j,cancelAtPeriodEnd:I,isCanceled:L,cancelDate:ee,formatGraceDate:At,proTierChangeMode:z,creditTiersEnabled:ie,creditTiers:V,displayCreditTier:ce,onCreditTierChange:k,selectedMachineTier:x,selectedStorageTier:T,onMachineTierChange:S,onStorageTierChange:D,machineTiersForPicker:ue,storageTiersForPicker:pe,currentMachinePrice:Me,currentStoragePrice:Ne,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:M.isLoading,tierChangePending:Ce,machineChanged:we,storageChanged:Te,creditChanged:Ee,tierChangeError:He,upgradePending:s.isPending,portalPending:h.isPending,onUpgrade:ve,onApplyTierChange:Re,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>h.mutate({})},e.id)})})]})}),(0,J.jsxs)(C.Footer,{className:`relative items-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,J.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,J.jsx)(Wt,{open:y,onCancel:()=>b(!1),onConfirm:ze,confirming:Ce,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var Zt={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function Qt(e){return Zt[e.toLowerCase()]??e}function $t(e,t){return`${Qt(e??`card`)} •••• ${t??`????`}`}function en({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,J.jsx)(g,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var tn={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function nn(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function rn(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function an(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function on({initialValues:e=tn,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,q.useState)(e),[c,l]=(0,q.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=rn(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:nn(t[e])}))},p=e=>an(e,u,n,c[e]);return(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,J.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:nn(o.threshold_usd),amount_usd:nn(o.amount_usd),monthly_cap_usd:nn(o.monthly_cap_usd)};s(e);let t=rn(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function sn(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function cn(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var ln={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function un(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function dn(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${$t(t,n)}`:`Charged to ${Qt(t??`card`)}`}function fn(){let e=l(),t=u(se()),n=d(ye()),r=d(he()),[a,o]=(0,q.useState)(`view`),[s,c]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,v=g.enabled===!0,y=g.disabled_due_to_repeated_failures===!0&&!v,x=()=>{n.reset(),r.reset(),o(`form`)},S=()=>{o(`view`),c(!1)},C=()=>{r.reset(),p(!1)},w=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{ue(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:ve()}),S()}})},T=()=>{r.mutate({},{onSuccess:()=>{ue(e,void 0,e=>({...ln,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),c(!1)}})},E=e=>{if(e&&!v){if(!g.has_payment_method||y){h(!0);return}h(!1),c(!0),x();return}if(!e&&!v&&s){S();return}!e&&v&&p(!0)},D=a===`form`,O=un(n.error),k=n.isError&&Object.keys(O).length===0,A=v||s,j=dn({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,J.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsx)(b,{checked:A,onChange:E,label:`Enable Auto-Reload`}),v&&!D&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`text-right`,children:[(0,J.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,cn(g.amount_usd),` when the balance falls under `,cn(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,J.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[cn(g.current_month_credits_purchased_usd),` of`,` `,cn(g.monthly_cap_usd),` this month`]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:x,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),y&&(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,J.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!y?`1fr`:`0fr`},children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),k&&(0,J.jsx)(_,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,J.jsx)(_,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),D&&(0,J.jsx)(on,{initialValues:v?{threshold_usd:sn(g.threshold_usd),amount_usd:sn(g.amount_usd),monthly_cap_usd:sn(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:O,onCancel:S,onSave:w}),v&&!g.has_payment_method&&(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),v&&g.has_payment_method&&(0,J.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:j??`Charged to a saved card`}),(v||D)&&(0,J.jsx)(_,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,J.jsx)(en,{open:f,confirming:r.isPending,onCancel:C,onConfirm:T})]})}var pn=2e3;function mn(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function hn(){let e=l(),{data:t,isLoading:n,isError:r}=u(K()),a=t??null,[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(0),d=(0,q.useRef)(null),f=ce({onSuccess:()=>{e.invalidateQueries({queryKey:Ee()})},onError:()=>{c.current<3&&(d.current=setTimeout(()=>{f.reset()},pn))}});(0,q.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=f.mutate;(0,q.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&c.current<3&&!f.isPending&&!f.isError&&!f.isSuccess&&(c.current+=1,h({}))},[a,f.isPending,f.isError,f.isSuccess,h]);let g=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(m,{padding:`md`,children:[g,n?(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Ve,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`effective-balance`,children:mn(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(rt,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`settled-balance`,children:mn(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(it,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`pending-charges`,children:mn(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,J.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(fn,{})})]}),(0,J.jsx)(Ye,{open:o,onOpenChange:s})]})}var gn=1e3,_n=15e3,vn=3e3,yn=45e3,bn=`billing-portal-return`;function xn(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?At(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function Sn(){let[e]=s(),t=o(),n=l(),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,q.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=Dt(),o=W(),s=je(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<_n&&(await new Promise(e=>setTimeout(e,gn)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=xn(a,e);t===`success`?w.success(n,{id:bn}):w.info(n,{id:bn})}catch{if(i.current)return;w.info(`Subscription updated.`,{id:bn})}finally{if(!i.current){Ot(),t(U.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=yn){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},vn)}}})(),()=>{i.current=!0}},[e,t,n]),null}var Cn=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function wn(e,t=Pe()){let{fromDate:n,toDate:r}=tt(e,t);return{from:n,to:r}}function Tn(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function En({from:e,to:t}){let n=Tn(e,t);return n===7?7:n===90?90:30}function Dn({value:e,onChange:t}){let n=We(),r=(0,q.useMemo)(()=>`${En(e)}`,[e]);return(0,J.jsx)(h,{options:Cn,value:r,onChange:e=>{let r=Number(e);t(wn(r,n),r)},"aria-label":`Date range`})}var On={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},kn={fontSize:12,fill:`var(--content-tertiary)`},An={stroke:`var(--border-subtle)`,strokeOpacity:.4},jn=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function Mn({item:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Nn({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,J.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??et)(String(r))}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Mn,{item:u}),d.length>0&&(0,J.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,J.jsx)(Mn,{item:e},e.key)),s&&(0,J.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,J.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Pn(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Fn(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function In(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Ln(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Fn(n/r)*r}function Rn(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function zn(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function Bn(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Vn=40,Hn={fontSize:11,fill:`var(--content-tertiary)`},Un={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function Wn(e,t){return Un[e]??jn[t%jn.length]??`#6b7280`}function Gn(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function Kn({stackKeys:e,labelMap:t}){return(0,J.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:Wn(e,n)}}),(0,J.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var qn=350,Jn={top:8,right:4,bottom:32,left:0},Yn=.2,Xn=5,Zn=12,Qn=200;function $n({buckets:e,metric:t,onBarClick:n}){let r=ae(),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,q.useMemo)(()=>Gn(e,t),[e,t]),u=(0,q.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=Wn(c[t],t);return e},[c]),d=(0,q.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,q.useState)(null),m=r?Vn:56,h=r?Hn:kn,g=Jn.left+m,_=Math.max(0,a-g-Jn.right),v=Jn.top,y=qn-Jn.top-Jn.bottom,b=(0,q.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,q.useMemo)(()=>Ln(b,{integerOnly:x,tickCount:Xn}),[b,x]),C=(0,q.useMemo)(()=>Rn(S,Xn),[S]),w=(0,q.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/Xn,n=Math.max(t<1?2:0,In(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,q.useMemo)(()=>Pn([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-Yn),k=(D-O)/2,A=(0,q.useMemo)(()=>Bn(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:Wn(t,i),isLast:u}})}}),N=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},P=()=>p(null),F=e=>{n&&n(e)},I=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],L={left:f?Math.max(0,Math.min(f.x+Zn,a-Qn)):0,top:f?f.y-Zn:0,visibility:f?`visible`:`hidden`};return(0,J.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:qn},children:j?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{width:a,height:qn,className:`block`,children:[C.map(e=>(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:On.stroke,strokeOpacity:On.strokeOpacity,strokeDasharray:On.strokeDasharray},e)),(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:An.stroke,strokeOpacity:An.strokeOpacity}),C.map(e=>(0,J.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,J.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:et(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>N(n,e,t.key),onMouseLeave:P,onClick:()=>F(t.key)};return t.isLast?(0,J.jsx)(`path`,{...i,d:zn(t.x,t.y,O,t.h,3)}):(0,J.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:L,children:(0,J.jsx)(Nn,{active:!!f,payload:I,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,J.jsx)(Kn,{stackKeys:c,labelMap:l})]})}function er(e=Pe()){return wn(30,e)}function tr(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:Ze(e.llmDimension??`model`)}function nr(e,t=Pe()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:tr(e.drilldown)}:{}}}function rr(e,t=Pe()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function ir(e){let t=We(),n=u(Oe({query:nr(e,t)})),r=u(Ae({query:rr(e,t)}));return{series:n.data,totals:r.data,isLoading:n.isLoading||r.isLoading,isError:n.isError||r.isError}}var ar=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function or(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function sr(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function cr(){let e=We(),[t,n]=(0,q.useState)(30),[r,i]=(0,q.useState)(()=>er(e)),a=(0,q.useMemo)(()=>t===null?r:wn(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`spend`),{series:d,totals:f,isLoading:h,isError:g}=ir({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),_=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:$e}:{}})};return(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,J.jsx)(Dn,{value:a,onChange:o}),(0,J.jsx)(`div`,{className:`w-44`,children:(0,J.jsx)(x,{items:ar,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Ve,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):or(f?.total_usd),label:`Spend`}),(0,J.jsx)(S,{icon:(0,J.jsx)(ot,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):sr(f?.event_count),label:`Events`})]}),s&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,J.jsx)(E,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Back to all usage`}),(0,J.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,J.jsx)(`div`,{className:`w-56`,children:(0,J.jsx)(x,{items:Qe,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),h?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,J.jsx)(R,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):g?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,J.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,J.jsx)($n,{buckets:d.buckets,metric:l,onBarClick:_})}):null]})})}function lr(){let{data:e}=u(W()),t=Mt((0,q.useMemo)(()=>kt(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=jt(e);return n?(0,J.jsx)(_,{tone:`info`,title:`Your Pro plan will end on ${At(n)}.`,actions:(0,J.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,J.jsx)(R,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var ur=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),dr=t(((e,t)=>{var n=ur();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=dr()()}))(),1);function fr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fr(Object(n),!0).forEach(function(t){hr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mr(e){"@babel/helpers - typeof";return mr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},mr(e)}function hr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function _r(e,t){if(e==null)return{};var n=gr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function vr(e,t){return yr(e)||br(e,t)||xr(e,t)||Cr()}function yr(e){if(Array.isArray(e))return e}function br(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function xr(e,t){if(e){if(typeof e==`string`)return Sr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sr(e,t)}}function Sr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Cr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ import{o as e,t}from"./chunk-jRWAZmH_.js";import{t as n}from"./capture-error-Hr1Yo2kx.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./button-D7s2Q_uG.js";import{t as a}from"./preload-helper-BewR0kVT.js";import{d as o,h as s,r as c}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as l}from"./QueryClientProvider-DKhXIxGb.js";import{t as u}from"./useQuery-B45lW1Kk.js";import{t as d}from"./useMutation-Lj4VunQV.js";import{t as f}from"./jsx-runtime-CVSDxk6A.js";import{t as p}from"./typography-BscuIPxA.js";import{t as m}from"./card-BibIM9x3.js";import{t as h}from"./dropdown-CL8VmqrY.js";import{t as g}from"./confirm-dialog-CfOXCE1N.js";import{t as _}from"./notice-CqRgVmeL.js";import{t as v}from"./tag-B_-QAvJF.js";import{t as y}from"./input-C8kfrq9r.js";import{t as b}from"./toggle-X_kQW5my.js";import{n as x,t as S}from"./stat-square-B0S3fO7O.js";import{t as C}from"./modal-D0Q3UWD0.js";import{n as w}from"./toast-2TW5tj1Y.js";import{t as T}from"./createLucideIcon-BlMXrA59.js";import{t as E}from"./arrow-left-CP-EhDNF.js";import{t as D}from"./check-D6WkI0gF.js";import{t as O}from"./circle-alert-DvNg50UK.js";import{t as k}from"./circle-check-DzlJxj_M.js";import{t as A}from"./cpu-CiHv3fhs.js";import{t as j}from"./credit-card-BKRB1ZIi.js";import{n as M,t as N}from"./domain-field-DYwuCpup.js";import{t as P}from"./external-link-DPAtkBJ2.js";import{t as F}from"./file-text-CmK9LY1p.js";import{t as I}from"./hard-drive-D7_5VMhi.js";import{t as L}from"./info-_OtUK1cX.js";import{t as R}from"./loader-circle-IIzBGiwm.js";import{a as ee,c as te,i as ne,n as z,r as B,t as V}from"./resize-errors-DnJEbHn4.js";import{t as re}from"./triangle-alert-DKOyShqD.js";import{ot as ie,st as H}from"./sdk.gen-D-_js_oC.js";import{a as U}from"./routes-DVqkwUEe.js";import{n as ae}from"./use-is-mobile-Cy10kl9u.js";import{$ as oe,B as se,Ct as ce,G as le,H as ue,J as de,K as fe,O as pe,Q as me,R as he,St as ge,U as _e,V as ve,W as ye,X as be,Y as xe,Z as Se,bt as Ce,c as we,et as W,ht as Te,it as Ee,nt as De,ot as Oe,q as ke,r as G,rt as K,st as Ae,tt as je,y as Me,z as Ne}from"./react-query.gen-rp6Krcco.js";import{t as Pe}from"./effective-timezone-DrYGH2Lb.js";import{n as Fe,t as Ie}from"./browser-CKX_K5ev.js";import{Fi as Le,Ir as Re,Li as ze,Nr as Be,Ri as Ve,an as He,in as Ue,on as We,pi as Ge,ra as Ke,rn as qe,x as Je}from"./index-PRnvH2Y1.js";import{t as Ye}from"./add-credits-modal-Dy3I3Har.js";import{t as Xe}from"./format-date-CLlHK5gl.js";import{a as Ze,n as Qe,t as $e}from"./llm-dimension-CQdmYu05.js";import{r as et,t as tt}from"./usage-window-Wgtgd-cv.js";import{t as nt}from"./environment-store-CvH3J6fT.js";var rt=T(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),it=T(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),at=T(`party-popper`,[[`path`,{d:`M5.8 11.3 2 22l10.7-3.79`,key:`gwxi1d`}],[`path`,{d:`M4 3h.01`,key:`1vcuye`}],[`path`,{d:`M22 8h.01`,key:`1mrtc2`}],[`path`,{d:`M15 2h.01`,key:`1cjtqr`}],[`path`,{d:`M22 20h.01`,key:`1mrys2`}],[`path`,{d:`m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10`,key:`hbicv8`}],[`path`,{d:`m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17`,key:`1i94pl`}],[`path`,{d:`m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7`,key:`1cofks`}],[`path`,{d:`M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z`,key:`4kbmks`}]]),ot=T(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),st=T(`tree-palm`,[[`path`,{d:`M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4`,key:`foxbe7`}],[`path`,{d:`M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3`,key:`18arnh`}],[`path`,{d:`M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35`,key:`ywahnh`}],[`path`,{d:`M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14`,key:`ft0feo`}]]),q=e(r(),1),J=f();function ct({onBack:e}){let t=o(),{data:n}=u(G()),r=n?.name||`your assistant`;return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(at,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`You're all set`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`Your assistant just got a serious upgrade.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsxs)(i,{variant:`primary`,"data-testid":`onboarding-complete-return`,onClick:()=>t(U.assistant,{replace:!0}),children:[`Return to `,r]})}),(0,J.jsx)(`div`,{className:`absolute bottom-4 left-4`,children:(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-complete-back`,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`})})]})}function lt({current:e,total:t=2}){return(0,J.jsx)(`div`,{className:`flex items-center justify-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,J.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300`,style:{width:n===e?20:6,backgroundColor:n<=e?`var(--content-default)`:`var(--border-element)`}},n))})}function ut({icon:e,tone:t=`positive`}){let n=t===`positive`?`--system-positive-strong`:t===`warning`?`--system-mid-strong`:`--system-negative-strong`;return(0,J.jsx)(`span`,{className:`flex h-11 w-11 items-center justify-center rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(${n}) 12%, transparent)`},children:(0,J.jsx)(e,{className:`h-5 w-5`,style:{color:`var(${n})`},"aria-hidden":`true`})})}var dt=1e3,ft=1e4;function pt(e){return ne[e]??ne.medium}var mt=[`machine_size`,`subdomain`,`non_field_errors`],ht={subdomain_taken:`That subdomain is already taken. Try another.`,assistant_already_has_domain:`Your assistant already has a custom domain.`,no_assistant_to_attach_domain:`We couldn't find an assistant to attach this domain to.`,exceeds_machine_tier:`That machine size isn't available on your plan.`};function gt(e,t){if(e&&typeof e==`object`){let t=e;if(typeof t.error==`string`){let e=ht[t.error];if(e)return e}for(let e of mt){let n=t[e];if(Array.isArray(n)&&typeof n[0]==`string`)return n[0]}if(typeof t.detail==`string`)return t.detail}return t}function _t({onBack:e,onExit:t}){let n=l(),r=nt.use.emailRootDomain(),{data:a}=u(G()),o=a?.id,{data:s}=u({...we({path:{assistant_id:o??``}}),enabled:!!o}),c=s?.results?.[0],[f,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(`hi`),[v,y]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!v){if(c){m(c.subdomain),y(!0);return}!a?.handle||f||(m(a.handle),y(!0))}},[a?.handle,c,v,f]);let[b,x]=(0,q.useState)(null),[S,w]=(0,q.useState)(!1),T=d(Se()),D=!!c||S,O=T.isPending||S;return(0,q.useEffect)(()=>{if(!S)return;let e=setTimeout(t,800);return()=>clearTimeout(e)},[S,t]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:Ge}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Assistant email`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Set up an email address for your assistant.`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`body-small-default`,as:`label`,className:`text-[var(--content-secondary)]`,children:`Email address`}),(0,J.jsx)(N,{subdomain:f,autoFocus:!0,onSubdomainChange:e=>{m(e),b&&x(null)},domainSuffix:r,disabled:O,error:b,locked:D,lockedMessage:`This domain has been set and cannot be changed.`,prefix:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{value:h,onChange:e=>g(e.target.value.toLowerCase().trim()),disabled:O||D,readOnly:D,placeholder:`hi`,"aria-label":`Email username`,size:Math.max(h.length,2),className:`h-full w-0 min-w-[2ch] flex-none bg-transparent pl-3 pr-1.5 text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none disabled:cursor-not-allowed disabled:opacity-60`,style:{width:`${Math.max(h.length,2)+1.5}ch`}}),(0,J.jsx)(`span`,{className:`shrink-0 font-mono text-[var(--content-secondary)]`,children:`@`})]})})]}),!D&&(0,J.jsxs)(_,{tone:`info`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:f||`<subdomain>`}),` will also become your assistant's public handle. You won't be able to change it once set.`]}),S?(0,J.jsx)(_,{tone:`success`,children:`Domain set — redirecting…`}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-back`,disabled:O,onClick:e,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:0})}),(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:D?(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-continue`,onClick:t,children:`Continue`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-domain-skip`,disabled:O,onClick:()=>{O||T.mutate({body:{skipped:!0}},{onSuccess:t,onError:()=>t()})},children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-domain-set`,disabled:!f||O,onClick:()=>{O||!f||T.mutate({body:{subdomain:f,...h?{email_username:h}:{}}},{onSuccess:()=>{x(null),w(!0),n.invalidateQueries({queryKey:Me()})},onError:e=>{x(gt(e,`Couldn't register that subdomain. Try a different one.`))}})},children:`Set domain`})]})})]})]})}function vt({onGoToBilling:e}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:O,tone:`negative`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Couldn't reach billing`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`We hit a problem checking your subscription. Your upgrade may still be processing — return to billing to refresh.`})]}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-go-to-billing`,onClick:e,children:`Go to billing`})]})}function yt({message:e,onRetry:t,onGoToBilling:n}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsx)(ut,{icon:O,tone:`warning`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Taking longer than expected`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:e})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,J.jsx)(i,{variant:`outlined`,"data-testid":`onboarding-go-to-billing`,onClick:n,children:`Go to billing`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-retry`,onClick:t,children:`Try again`})]})]})}function bt({title:e,body:t}){return(0,J.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center gap-4 px-6 py-10 text-center`,children:[(0,J.jsxs)(`div`,{className:`relative flex h-11 w-11 items-center justify-center`,children:[(0,J.jsx)(`div`,{className:`absolute h-14 w-14 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-9 w-9 rounded-full`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 8%, transparent)`,animation:`onboarding-glow 2.4s ease-in-out infinite 0.4s`},"aria-hidden":`true`}),(0,J.jsx)(R,{className:`relative h-5 w-5 animate-spin text-[var(--system-positive-strong)]`,"aria-hidden":`true`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:e}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:t})]})]})}function xt({icon:e,label:t,from:n,fromDetail:r,to:i,toDetail:a}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),r&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)] line-through`,children:r})]}),(0,J.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:i}),a&&(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:a})]})]})]})]})}function St({storageGib:e,maxTier:t,onBack:n,onAdvance:r,dotIndex:a,dotTotal:o}){let{data:s}=u(G()),c=s?.machine_size||`small`,l=s?.provisioned_storage_gib??null,f=pt(t),m=f.length>0?f[f.length-1]:c,h=m!==c,g=e!=null&&(l==null||l<e),[v,y]=(0,q.useState)(null),b=d(pe());return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C.Body,{className:`min-h-[320px] space-y-5 pt-10 pb-4`,style:{animation:`onboarding-step-in 350ms ease-out`},children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 pb-2 text-center`,children:[(0,J.jsx)(ut,{icon:A}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{variant:`title-small`,as:`h1`,children:`Your assistant's new resources`}),(0,J.jsx)(p,{variant:`body-medium-lighter`,as:`p`,className:`text-[var(--content-secondary)]`,children:`Your assistant will go offline briefly while it resizes.`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[h&&(0,J.jsx)(xt,{icon:A,label:`Machine`,from:B[c],fromDetail:z[c],to:B[m],toDetail:z[m]}),g&&(0,J.jsx)(xt,{icon:I,label:`Storage`,from:l==null?`—`:`${l} GiB`,to:`${e} GiB`}),!h&&!g&&(0,J.jsx)(_,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`})]}),v?(0,J.jsx)(_,{tone:`error`,children:v}):null]}),(0,J.jsxs)(C.Footer,{className:`relative items-center justify-between`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-back`,disabled:b.isPending,onClick:n,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 flex justify-center`,children:(0,J.jsx)(lt,{current:a,total:o})}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(i,{variant:`ghost`,"data-testid":`onboarding-setup-skip`,disabled:b.isPending,onClick:r,children:`Do later`}),(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-setup-continue`,disabled:b.isPending||!s?.id,onClick:()=>{b.isPending||!s?.id||b.mutate({path:{id:s.id},body:{machine_size:m,...e==null?{}:{storage_gib:e}}},{onSuccess:()=>{y(null),r()},onError:e=>{y(gt(e,`Couldn't apply changes. Please try again.`))}})},children:`Apply & Restart`})]})]})]})}function Ct({onContinue:e,continueDisabled:t=!1}){return(0,J.jsxs)(`div`,{className:`relative flex min-h-[320px] flex-col items-center justify-center overflow-hidden px-8 text-center`,children:[(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,style:{background:`radial-gradient(ellipse 60% 50% at 50% 38%, color-mix(in oklab, var(--system-positive-strong) 14%, transparent), transparent)`},"aria-hidden":`true`}),(0,J.jsxs)(`div`,{className:`relative mb-5 flex items-center justify-center`,style:{animation:`welcome-reveal 600ms ease-out both`},children:[(0,J.jsx)(`div`,{className:`absolute h-24 w-24 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 18%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite`},"aria-hidden":`true`}),(0,J.jsx)(`div`,{className:`absolute h-16 w-16 rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--system-positive-strong) 12%, transparent), transparent 70%)`,animation:`welcome-crown-glow 3s ease-in-out infinite 0.5s`},"aria-hidden":`true`}),(0,J.jsx)(M,{className:`relative h-8 w-8 text-[var(--system-positive-strong)]`,strokeWidth:1.5,"aria-hidden":`true`})]}),(0,J.jsx)(`h1`,{className:`relative mb-2 text-[var(--content-emphasised)]`,style:{fontFamily:`var(--font-serif)`,fontSize:`28px`,lineHeight:1,fontWeight:400,animation:`welcome-reveal 600ms ease-out 150ms both`},children:`Welcome to Pro`}),(0,J.jsx)(`p`,{className:`relative mb-6 max-w-[320px] text-body-medium-lighter text-[var(--content-secondary)]`,style:{animation:`welcome-reveal 600ms ease-out 300ms both`},children:`More compute, more storage, and more features. Let's set everything up.`}),(0,J.jsx)(`div`,{style:{animation:`welcome-reveal 600ms ease-out 450ms both`},children:(0,J.jsx)(i,{variant:`primary`,"data-testid":`onboarding-welcome-continue`,disabled:t,onClick:e,children:`Get started`})}),(0,J.jsx)(`p`,{className:`relative mt-6 max-w-[320px] text-body-small-default text-[var(--content-tertiary)]`,style:{animation:`welcome-reveal 600ms ease-out 600ms both`},children:`This quick setup gets your Pro features ready to go. You can close it anytime and turn these features on later from Settings.`})]})}function wt({open:e,onClose:t}){let n=l(),[r,i]=(0,q.useState)(`confirm-pro`),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(0);(0,q.useEffect)(()=>{e&&(n.invalidateQueries({queryKey:je()}),n.invalidateQueries({queryKey:oe()}))},[e,n]);let d=(0,q.useCallback)(()=>{o(!1),c(e=>e+1),n.invalidateQueries({queryKey:je()})},[n]),f=u({...W(),refetchInterval:e=>e.state.data?.plan_id===`pro`||a?!1:dt,refetchIntervalInBackground:!1,enabled:e&&r===`confirm-pro`});(0,q.useEffect)(()=>{if(!e||r!==`confirm-pro`)return;let t=setTimeout(()=>o(!0),ft);return()=>clearTimeout(t)},[e,r,s]),(0,q.useEffect)(()=>{r===`confirm-pro`&&f.data?.plan_id===`pro`&&i(`welcome`)},[r,f.data?.plan_id]);let p=u({...me(),enabled:e&&r!==`confirm-pro`});u({...G(),enabled:e});let m=p.data?.domain_setup_available,h=(0,q.useCallback)(()=>{i(m===!1?`setup`:`domain`)},[m]),g=(0,q.useCallback)(()=>{i(m===!1?`welcome`:`domain`)},[m]),_=r===`welcome`;return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsx)(C.Content,{size:`md`,hideCloseButton:!_,dismissOnOverlayClick:!_,onEscapeKeyDown:_?e=>e.preventDefault():void 0,onInteractOutside:_?e=>e.preventDefault():void 0,className:`overflow-hidden`,children:v()})});function v(){if(r===`confirm-pro`)return f.isError?(0,J.jsx)(vt,{onGoToBilling:t}):a?(0,J.jsx)(yt,{message:`We're still confirming your upgrade.`,onRetry:d,onGoToBilling:t}):(0,J.jsx)(bt,{title:`Finalizing your upgrade…`,body:`This usually takes a few seconds.`});if(r===`welcome`)return p.isError?(0,J.jsx)(vt,{onGoToBilling:t}):(0,J.jsx)(Ct,{onContinue:h,continueDisabled:p.isPending||p.isFetching});if(r===`domain`)return(0,J.jsx)(_t,{onBack:()=>i(`welcome`),onExit:()=>i(`setup`)});if(r===`setup`){if(p.isError)return(0,J.jsx)(vt,{onGoToBilling:t});let e=p.data?.max_machine_tier??null,n=m!==!1;return(0,J.jsx)(St,{storageGib:p.data?.selected_storage_gib??null,maxTier:e,onBack:g,onAdvance:()=>i(`complete`),dotIndex:+!!n,dotTotal:n?2:1})}return r===`complete`?(0,J.jsx)(ct,{onBack:()=>i(`setup`)}):null}}var Tt=`billing-portal-return-snapshot`;function Et(e){try{sessionStorage.removeItem(Tt),sessionStorage.setItem(Tt,JSON.stringify(e))}catch{}}function Dt(){if(typeof sessionStorage>`u`)return null;try{let e=sessionStorage.getItem(Tt);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 Ot(){try{sessionStorage.removeItem(Tt)}catch{}}function kt(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 At(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:`numeric`,month:`long`,day:`numeric`})}function jt(e){return e?e.cancel_at??e.current_period_end??null:null}function Mt(e){let t=l();return(0,q.useEffect)(()=>Fe(()=>{t.invalidateQueries(W())}),[t]),ge({onSuccess:t=>{e&&Et(e),Ie(t.portal_url)},onError:()=>{w.error(`Couldn't open the billing portal. Please try again.`,{id:`billing-portal-session-error`})}})}function Nt(e){let t=e/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}function Y(e){return`${Nt(e)}/mo`}function Pt(e){return`${e>0?`+`:`−`}${Nt(Math.abs(e))}/mo`}var Ft={medium:`Medium`,large:`Large`,xl:`XL`};function It(e){return e.disabled===!0}function Lt({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=Ft[e.tier]??e.label,n=o==null?`+${Y(e.price_cents)}`:e.price_cents===o?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-o);return{value:e.tier,label:`${t} ${n}`,disabled:It(e)}}),[e,o]),l=(0,q.useMemo)(()=>t.map(e=>{let t=s==null?`+${Y(e.price_cents)}`:e.price_cents===s?`(${Y(e.price_cents)}, current)`:Pt(e.price_cents-s);return{value:e.tier,label:`${e.storage_gib} GiB ${t}`,disabled:It(e)}}),[t,s]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Machine`}),(0,J.jsx)(`span`,{title:`Determines the CPU and memory allocated to your assistant`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Machine tier`,placeholder:`Select a machine tier`,value:n??``,onChange:i,options:c})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Storage`}),(0,J.jsx)(`span`,{title:`Persistent disk space for your assistant's files and data`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Storage tier`,placeholder:`Select a storage tier`,value:r??``,onChange:a,options:l})]})]})}var Rt=new Set([`active`,`trialing`,`past_due`]),zt=[`target_plan_id`,`confirm`,`machine_tier`,`storage_tier`,`credit_tier`,`non_field_errors`];function Bt(e,t){if(e&&typeof e==`object`){for(let t of zt)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 Vt(e,t){let n=e.filter(e=>!It(e));return t!==null&&n.some(e=>e.tier===t)?t:n[0]?.tier??null}function Ht(e,t,n){return t===void 0?n:t!==null&&(t===n||e.some(e=>e.tier===t))?t:null}function Ut(e){return e.length?Math.min(...e.map(e=>e.price_cents)):0}function Wt({open:e,onCancel:t,onConfirm:n,confirming:r,lostFeatures:a}){return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{!e&&!r&&t()},children:(0,J.jsxs)(C.Content,{size:`md`,hideCloseButton:!0,children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:re,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:a.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`outlined`,onClick:t,disabled:r,children:`Keep Pro`}),(0,J.jsx)(i,{variant:`danger`,onClick:n,disabled:r,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]})})}var Gt=`__none__`;function Kt(e){return`${e.label} — ${Y(e.price_cents)}`}function qt({creditTiers:e,selectedCreditTier:t,onCreditTierChange:n,disabled:r=!1}){let i=(0,q.useMemo)(()=>[{value:Gt,label:`No credit bundle — ${Y(0)}`},...e.map(e=>({value:e.tier,label:Kt(e)}))],[e]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`label-small-default`,className:`text-[var(--content-secondary)]`,children:`Credit bundle`}),(0,J.jsx)(`span`,{title:`A monthly allotment of credits added to your Pro Plan subscription`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),(0,J.jsx)(h,{"aria-label":`Credit bundle`,placeholder:`Select a credit bundle`,disabled:r,value:t??Gt,onChange:e=>n(e===Gt?null:e),options:i})]})}function Jt({features:e,variant:t,header:n,maxInline:r=3}){return t===`inline`?(0,J.jsx)(J.Fragment,{children:e.slice(0,r).join(`, `)}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-secondary)]`,children:n}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(k,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})]},e))})]})}function Yt({plan:e,isCurrent:t,onPro:n,cancelAtPeriodEnd:r,isCanceled:a,cancelDate:o,formatGraceDate:s,proTierChangeMode:c,creditTiersEnabled:l,creditTiers:u,displayCreditTier:d,onCreditTierChange:f,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,machineTiersForPicker:x,storageTiersForPicker:S,currentMachinePrice:C,currentStoragePrice:w,currentCreditPriceUnknown:T,proCurrentTotalCents:E,proLiveTotalCents:D,proTotalDelta:O,onboardingLoading:k,tierChangePending:A,machineChanged:j,storageChanged:N,creditChanged:P,tierChangeError:F,upgradePending:I,portalPending:ee,onUpgrade:te,onApplyTierChange:ne,onDowngradeClick:z,onKeepPlan:B}){let V=e.id===`pro`,re=e.id===`base`,ie=V&&n&&r&&!a,H=V&&(!t||t&&c),U=V&&t&&c;return(0,J.jsxs)(m,{padding:`lg`,className:`flex flex-col bg-[var(--surface-base)]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)]`,children:V?(0,J.jsx)(M,{className:`h-5 w-5 text-[var(--content-default)]`}):(0,J.jsx)(st,{className:`h-5 w-5 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`flex min-h-6 items-center gap-2`,children:[(0,J.jsx)(p,{as:`h3`,variant:`title-small`,children:e.name}),t&&(0,J.jsx)(v,{tone:`positive`,children:`Current`})]}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`-mt-2 text-[var(--content-tertiary)]`,children:re?`All you need for a capable assistant`:`More features, more compute, more storage`}),ie&&o&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`modal-cancels-on`,children:[`Your plan ends on `,s(o)]}),(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:re?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Free`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,children:`Forever`})]}):t&&!(H&&D!=null)&&(E==null||T)?k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-price-unavailable`,children:`Current plan pricing unavailable`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,"data-testid":`modal-pro-price`,children:H&&D!=null?(0,J.jsxs)(J.Fragment,{children:[Y(D),O!=null&&O!==0&&(0,J.jsxs)(`span`,{className:`ml-1 text-[var(--content-tertiary)]`,children:[`(`,Pt(O),`)`]})]}):E==null?e.id===`pro`?`From ${Y(e.base_price_cents+Ut(e.machine_tiers)+Ut(e.storage_tiers))}`:null:`Currently ${Y(E)}`}),H&&O!=null&&O!==0&&(0,J.jsx)(`span`,{title:`Your Pro Plan subscription will change from ${Y(E)} to ${Y(D)}.`,children:(0,J.jsx)(L,{className:`h-3 w-3 text-[var(--content-tertiary)]`})})]}),e.id===`pro`&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-pro-base-fee`,children:[Nt(e.base_price_cents),` base fee`]})]})}),(0,J.jsx)(Jt,{features:e.included_features,variant:`checklist`}),V&&!l&&(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`modal-credits-not-included`,children:`*Credits not included`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex flex-1 flex-col justify-end gap-4`,children:[!t&&V&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:I}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:te,disabled:I||!h||!g,"data-testid":`modal-upgrade-to-pro-button`,children:`Upgrade to Pro`})]}),U&&(k?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading your plan...`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),l&&(0,J.jsx)(qt,{creditTiers:u,selectedCreditTier:d,onCreditTierChange:f,disabled:A}),(0,J.jsx)(Lt,{machineTiers:x,storageTiers:S,selectedMachineTier:h,selectedStorageTier:g,onMachineTierChange:y,onStorageTierChange:b,currentMachinePriceCents:C,currentStoragePriceCents:w}),F&&(0,J.jsx)(_,{tone:`error`,children:F}),(0,J.jsx)(i,{variant:`primary`,className:`w-full`,onClick:ne,disabled:A||!j&&!N&&!P,"data-testid":`modal-change-tier-button`,children:`Update Plan`})]})),!t&&re&&n&&!r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:z,disabled:ee,"data-testid":`modal-downgrade-to-base-button`,children:`Downgrade to Base`})]}),ie&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`hr`,{className:`border-t border-[var(--border-base)]`}),(0,J.jsx)(i,{variant:`outlined`,className:`w-full`,onClick:B,disabled:ee,"data-testid":`modal-keep-plan-button`,children:`Keep your Plan`})]})]})]})}function Xt({open:e,onClose:t,onTierUpgraded:n}){let r=l(),a=u(fe()),o=u(W()),s=d(De()),c=d(xe()),f=d(be()),m=d(de()),h=Mt(kt(o.data)),[g,v]=(0,q.useState)(`plans`),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(null),[T,D]=(0,q.useState)(null),[O,k]=(0,q.useState)(void 0);(0,q.useEffect)(()=>Fe(()=>{r.invalidateQueries({queryKey:je()}),r.invalidateQueries({queryKey:ke()}),r.invalidateQueries({queryKey:oe()}),t()}),[r,t]);let A=o.data?.plan_id,j=A===`pro`,M=u({...me(),enabled:j}),N=M.data?.max_machine_tier??null,P=M.data?.selected_storage_tier??null,F=M.data?.selected_storage_gib??null,I=o.data?.cancel_at_period_end===!0||!!o.data?.cancel_at,L=o.data?.status===`canceled`,ee=jt(o.data),te=o.data?.status,ne=te!=null&&Rt.has(te),z=j&&ne&&!I&&!L,B=a.data?.plans.find(e=>e.id===`pro`),V=B?.credit_tiers??[],ie=V.length>0,H=o.data?.selected_credit_tier??null,U=e=>V.find(t=>t.tier===e)?.price_cents??0,ae=U(H),se=H!=null&&!V.some(e=>e.tier===H),ce=O===void 0?H:O,le=U(ce),ue=B?.machine_tiers??[],pe=z&&F!=null?(B?.storage_tiers??[]).map(e=>e.storage_gib<F?{...e,disabled:!0}:e):B?.storage_tiers??[];(0,q.useEffect)(()=>{if(!e){S(null),D(null),k(void 0);return}if(B){if(z){if(N==null||P==null)return;S(e=>Vt(ue,e??N)),D(e=>Vt(pe,e??P)),k(e=>Ht(V,e,H));return}S(e=>Vt(B.machine_tiers,e)),D(e=>Vt(B.storage_tiers,e)),k(e=>Ht(V,e,null))}},[e,B,z,N,P,H]);let he=a.data?.plans.find(e=>e.id===`base`),ge=new Set(he?.included_features??[]),_e=(B?.included_features??[]).filter(e=>!ge.has(e)),ve=()=>{if(!s.isPending){if(!x||!T){w.error(`Pick a machine and storage tier to continue.`,{id:`pro-upgrade-error`});return}s.mutate({body:{target_plan_id:`pro`,confirm:!0,machine_tier:x,storage_tier:T,credit_tier:ce}},{onSuccess:e=>{if(e.checkout_url){Ie(e.checkout_url);return}if(e.status===`no_op`){w.info(`You're already on Pro.`,{id:`pro-upgrade`}),t();return}w.error(e.message??`Failed to start upgrade. Please try again.`,{id:`pro-upgrade-error`})},onError:e=>{w.error(Bt(e,`Failed to start upgrade. Please try again.`),{id:`pro-upgrade-error`})}})}},ye=()=>{h.isPending||(v(`plans`),h.mutate({}))},Se=()=>{r.invalidateQueries({queryKey:je()}),r.invalidateQueries({queryKey:oe()}),r.invalidateQueries({queryKey:ke()})},Ce=c.isPending||f.isPending||m.isPending,we=x!=null&&x!==N,Te=T!=null&&T!==P,Ee=ie&&O!==void 0&&O!==H,Oe=e=>ue.find(t=>t.tier===e)?.price_cents??null,G=e=>pe.find(t=>t.tier===e)?.price_cents??null,K=Oe(x),Ae=G(T),Me=Oe(N),Ne=G(P),Pe=we&&K!=null&&Me!=null&&K<Me,Le=()=>{if(Ce)return;let e=[];we&&x&&e.push(new Promise(e=>{c.mutate({body:{machine_tier:x}},{onSuccess:()=>e({dimension:`machine`,ok:!0}),onError:t=>e({dimension:`machine`,ok:!1,error:t})})})),Te&&T&&e.push(new Promise(e=>{f.mutate({body:{storage_tier:T}},{onSuccess:()=>e({dimension:`storage`,ok:!0}),onError:t=>e({dimension:`storage`,ok:!1,error:t})})})),Ee&&e.push(new Promise(e=>{m.mutate({body:{credit_tier:ce}},{onSuccess:()=>e({dimension:`credit`,ok:!0}),onError:t=>e({dimension:`credit`,ok:!1,error:t})})})),Promise.all(e).then(e=>{Se();let r=e.some(e=>e.ok&&e.dimension===`storage`),i=e.some(e=>e.ok&&e.dimension===`machine`)&&!Pe,a=(r||i)&&!!n,o=e.filter(e=>!e.ok);if(o.length>0){let e=o.map(e=>Bt(e.error,`Failed to update ${e.dimension} tier.`)).join(` `);w.error(e,{id:`pro-tier-change-error`}),a&&(t(),n());return}a?(t(),n()):w.success(Ee&&!we&&!Te?`Credit bundle updated.`:`Plan updated.`,{id:`pro-tier-change`})})},Re=()=>{if(!Ce){if(Pe){b(!0);return}Le()}},ze=()=>{b(!1),Le()},Be=e=>K!=null&&Ae!=null?e.base_price_cents+K+Ae+le:null,Ve=e=>Me!=null&&Ne!=null?e.base_price_cents+Me+Ne+ae:null,He=c.isError||f.isError||m.isError?Bt(c.error??f.error??m.error,`Failed to update plan. Please try again.`):null,Ue=a.isLoading||o.isLoading,We=a.isError||o.isError||!a.data||!o.data;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||(v(`plans`),t())},children:(0,J.jsx)(C.Content,{size:g===`plans`?`lg`:`md`,children:g===`downgrade-confirm`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{icon:re,children:`Downgrade to Base?`})}),(0,J.jsxs)(C.Body,{children:[(0,J.jsx)(p,{as:`p`,variant:`body-medium-default`,className:`text-(--content-secondary)`,children:`Downgrading removes the following Pro features:`}),(0,J.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5`,children:_e.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(p,{as:`span`,variant:`body-medium-default`,children:e})},e))})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>v(`plans`),disabled:h.isPending,leftIcon:(0,J.jsx)(E,{className:`h-4 w-4`}),children:`Back`}),(0,J.jsx)(i,{variant:`danger`,onClick:ye,disabled:h.isPending,"data-testid":`confirm-downgrade-button`,children:`Confirm Downgrade`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{className:`sr-only`,children:`Upgrade Plan`})}),(0,J.jsx)(C.Body,{children:Ue?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-medium-lighter`,children:`Loading plans...`})]}):We?(0,J.jsx)(_,{tone:`error`,children:`Failed to load plans. Please try again later.`}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-2 pb-2 pt-4 text-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`title-medium`,children:`Your Assistant, Your Way`}),(0,J.jsx)(p,{as:`p`,variant:`body-medium-lighter`,className:`text-[var(--content-secondary)]`,children:`Choose the plan that works best for you and your assistant.`})]}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:a.data.plans.map(e=>{let t=e.id===A,n=e.id===`pro`&&B?Be(B):null,r=e.id===`pro`&&B?Ve(B):null;return(0,J.jsx)(Yt,{plan:e,isCurrent:t,onPro:j,cancelAtPeriodEnd:I,isCanceled:L,cancelDate:ee,formatGraceDate:At,proTierChangeMode:z,creditTiersEnabled:ie,creditTiers:V,displayCreditTier:ce,onCreditTierChange:k,selectedMachineTier:x,selectedStorageTier:T,onMachineTierChange:S,onStorageTierChange:D,machineTiersForPicker:ue,storageTiersForPicker:pe,currentMachinePrice:Me,currentStoragePrice:Ne,currentCreditPriceUnknown:se,proCurrentTotalCents:r,proLiveTotalCents:n,proTotalDelta:n!=null&&r!=null?n-r:null,onboardingLoading:M.isLoading,tierChangePending:Ce,machineChanged:we,storageChanged:Te,creditChanged:Ee,tierChangeError:He,upgradePending:s.isPending,portalPending:h.isPending,onUpgrade:ve,onApplyTierChange:Re,onDowngradeClick:()=>v(`downgrade-confirm`),onKeepPlan:()=>h.mutate({})},e.id)})})]})}),(0,J.jsxs)(C.Footer,{className:`relative items-center`,children:[(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`pointer-events-none absolute inset-x-0 text-center text-[var(--content-tertiary)]`,children:(0,J.jsx)(`span`,{className:`pointer-events-auto`,children:`You can change or cancel your plan at any time from billing settings.`})}),(0,J.jsx)(`div`,{className:`ml-auto`,children:(0,J.jsx)(i,{variant:`outlined`,onClick:t,"data-testid":`modal-cancel-button`,children:`Cancel`})})]})]})})}),(0,J.jsx)(Wt,{open:y,onCancel:()=>b(!1),onConfirm:ze,confirming:Ce,lostFeatures:[`Reduced CPU and memory for your assistant — it will resize to the smaller compute profile.`]})]})}var Zt={visa:`Visa`,mastercard:`Mastercard`,amex:`Amex`,discover:`Discover`,diners:`Diners Club`,jcb:`JCB`,unionpay:`UnionPay`};function Qt(e){return Zt[e.toLowerCase()]??e}function $t(e,t){return`${Qt(e??`card`)} •••• ${t??`????`}`}function en({open:e,confirming:t,onCancel:n,onConfirm:r}){return(0,J.jsx)(g,{open:e,title:`Disable automatic top-ups?`,message:`Auto top-ups will stop. Any saved payment method stays on file.`,confirmLabel:t?`Disabling…`:`Disable`,cancelLabel:`Keep enabled`,destructive:!0,onConfirm:r,onCancel:n})}var tn={threshold_usd:`100`,amount_usd:`10`,monthly_cap_usd:``};function nn(e){if(e===``||e===`-`)return e;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function rn(e){let t={},n=parseFloat(e.threshold_usd),r=parseFloat(e.amount_usd);if((!Number.isFinite(r)||r<10||r>500)&&(t.amount_usd=`Must be between $10 and $500`),(!Number.isFinite(n)||n<1||n>100)&&(t.threshold_usd=`Must be between $1 and $100`),e.monthly_cap_usd!==``){let n=parseFloat(e.monthly_cap_usd);!Number.isFinite(n)||n<25||n>1e4?t.monthly_cap_usd=`Must be between $25 and $10,000`:Number.isFinite(r)&&n<r&&(t.monthly_cap_usd=`Must be at least the top-up amount`)}return t}function an(e,t,n,r){if(n[e])return n[e];if(r)return t[e]}function on({initialValues:e=tn,submitting:t,serverErrors:n,onSave:r,onCancel:a}){let[o,s]=(0,q.useState)(e),[c,l]=(0,q.useState)({threshold_usd:!1,amount_usd:!1,monthly_cap_usd:!1}),u=rn(o),d=e=>t=>{s(n=>({...n,[e]:t.target.value}))},f=e=>()=>{l(t=>({...t,[e]:!0})),s(t=>({...t,[e]:nn(t[e])}))},p=e=>an(e,u,n,c[e]);return(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Auto-Reload when balance below`,value:o.threshold_usd,onChange:d(`threshold_usd`),onBlur:f(`threshold_usd`),errorText:p(`threshold_usd`),"data-testid":`auto-top-up-threshold-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Add amount when auto reloading`,value:o.amount_usd,onChange:d(`amount_usd`),onBlur:f(`amount_usd`),errorText:p(`amount_usd`),"data-testid":`auto-top-up-amount-input`,fullWidth:!0})}),(0,J.jsx)(`div`,{className:`min-w-[10rem] flex-1`,children:(0,J.jsx)(y,{type:`number`,step:`1`,label:`Monthly spending cap`,helperText:`Pauses auto top-ups for the rest of the month once spending reaches this amount. Manual purchases also count toward the total. Leave empty for no limit.`,value:o.monthly_cap_usd,onChange:d(`monthly_cap_usd`),onBlur:f(`monthly_cap_usd`),errorText:p(`monthly_cap_usd`),"data-testid":`auto-top-up-cap-input`,fullWidth:!0})}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-[18px]`,children:[(0,J.jsx)(i,{variant:`outlined`,onClick:a,disabled:t,children:`Cancel`}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>{l({threshold_usd:!0,amount_usd:!0,monthly_cap_usd:!0});let e={threshold_usd:nn(o.threshold_usd),amount_usd:nn(o.amount_usd),monthly_cap_usd:nn(o.monthly_cap_usd)};s(e);let t=rn(e);if(Object.keys(t).length!==0)return;let n=e=>e===``?``:`${parseInt(e,10)}.00`;r({threshold_usd:n(e.threshold_usd),amount_usd:n(e.amount_usd),monthly_cap_usd:e.monthly_cap_usd===``?``:n(e.monthly_cap_usd)})},disabled:t,"data-testid":`auto-top-up-save-button`,children:`Save`})]})]})})}function sn(e){if(!e)return``;let t=parseFloat(e);return Number.isFinite(t)?String(Math.trunc(t)):``}function cn(e){if(!e)return`$0`;let t=parseFloat(e);if(!Number.isFinite(t))return`$0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-$${r}`:`$${r}`}var ln={enabled:!1,threshold_usd:null,amount_usd:null,monthly_cap_usd:null,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null,stripe_payment_method_updated_at:null,last_charge_at:null,last_failure_at:null,last_failure_reason:null,disabled_due_to_repeated_failures:!1,paused_until:null,current_month_credits_purchased_usd:`0.00`,current_month_charged_usd:`0.00`,next_trigger_amount_usd:null,stubbed:!1};function un(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&typeof r[0]==`string`&&(t[n]=r[0]);return t}function dn(e){let{brand:t,last4:n}=e;return!t&&!n?null:n?`Charged to ${$t(t,n)}`:`Charged to ${Qt(t??`card`)}`}function fn(){let e=l(),t=u(se()),n=d(ye()),r=d(he()),[a,o]=(0,q.useState)(`view`),[s,c]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{m&&t.data?.has_payment_method&&h(!1)},[m,t.data?.has_payment_method]),t.isLoading)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Loading…`})});if(t.isError||!t.data)return(0,J.jsx)(`div`,{"data-testid":`auto-top-up-card`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load auto top-up configuration.`})});let g=t.data,v=g.enabled===!0,y=g.disabled_due_to_repeated_failures===!0&&!v,x=()=>{n.reset(),r.reset(),o(`form`)},S=()=>{o(`view`),c(!1)},C=()=>{r.reset(),p(!1)},w=t=>{n.mutate({body:{enabled:!0,threshold_usd:t.threshold_usd,amount_usd:t.amount_usd,monthly_cap_usd:t.monthly_cap_usd===``?null:t.monthly_cap_usd}},{onSuccess:t=>{ue(e,void 0,e=>({...t,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null})),e.invalidateQueries({queryKey:ve()}),S()}})},T=()=>{r.mutate({},{onSuccess:()=>{ue(e,void 0,e=>({...ln,has_payment_method:e?.has_payment_method??!1,payment_method_brand:e?.payment_method_brand??null,payment_method_last4:e?.payment_method_last4??null,stripe_payment_method_updated_at:e?.stripe_payment_method_updated_at??null})),p(!1),o(`view`),c(!1)}})},E=e=>{if(e&&!v){if(!g.has_payment_method||y){h(!0);return}h(!1),c(!0),x();return}if(!e&&!v&&s){S();return}!e&&v&&p(!0)},D=a===`form`,O=un(n.error),k=n.isError&&Object.keys(O).length===0,A=v||s,j=dn({brand:g.payment_method_brand,last4:g.payment_method_last4});return(0,J.jsxs)(`div`,{"data-testid":`auto-top-up-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsx)(b,{checked:A,onChange:E,label:`Enable Auto-Reload`}),v&&!D&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`text-right`,children:[(0,J.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-summary`,children:[`Add `,cn(g.amount_usd),` when the balance falls under `,cn(g.threshold_usd)]}),g.monthly_cap_usd!=null&&(0,J.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-cap-progress`,children:[cn(g.current_month_credits_purchased_usd),` of`,` `,cn(g.monthly_cap_usd),` this month`]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:x,"data-testid":`auto-top-up-edit-button`,children:`Adjust`})]})]}),y&&(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-declined-cutoff`,children:`We paused automatic reloads after several declined payments. Add a new payment method below to turn auto-reload back on.`}),(0,J.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-in-out`,style:{gridTemplateRows:m&&!y?`1fr`:`0fr`},children:(0,J.jsx)(`div`,{className:`overflow-hidden`,children:(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,children:`You must first add a Payment Method before you can enable automatic credit reloads.`})})}),k&&(0,J.jsx)(_,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-update-error`,children:`Failed to save automatic top-ups. Please try again.`}),r.isError&&(0,J.jsx)(_,{tone:`error`,className:`mt-4`,"data-testid":`auto-top-up-disable-error`,children:`Failed to disable automatic top-ups. Please try again.`}),D&&(0,J.jsx)(on,{initialValues:v?{threshold_usd:sn(g.threshold_usd),amount_usd:sn(g.amount_usd),monthly_cap_usd:sn(g.monthly_cap_usd)}:void 0,submitting:n.isPending,serverErrors:O,onCancel:S,onSave:w}),v&&!g.has_payment_method&&(0,J.jsx)(_,{tone:`warning`,className:`mt-3`,"data-testid":`auto-top-up-no-pm`,children:`You must add a Payment Method.`}),v&&g.has_payment_method&&(0,J.jsx)(`p`,{className:`mt-3 text-body-small-default text-[var(--content-tertiary)]`,"data-testid":`auto-top-up-saved-pm`,children:j??`Charged to a saved card`}),(v||D)&&(0,J.jsx)(_,{tone:`info`,className:`mt-4`,children:`If you're too close to your monthly limit, the auto-reload will only top up to that limit.`}),(0,J.jsx)(en,{open:f,confirming:r.isPending,onCancel:C,onConfirm:T})]})}var pn=2e3;function mn(e){let t=parseFloat(e);if(Number.isNaN(t))return`0`;let n=Math.abs(t).toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2}),r=n.endsWith(`.00`)?n.slice(0,-3):n;return t<0?`-${r}`:r}function hn(){let e=l(),{data:t,isLoading:n,isError:r}=u(K()),a=t??null,[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(0),d=(0,q.useRef)(null),f=ce({onSuccess:()=>{e.invalidateQueries({queryKey:Ee()})},onError:()=>{c.current<3&&(d.current=setTimeout(()=>{f.reset()},pn))}});(0,q.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let h=f.mutate;(0,q.useEffect)(()=>{a&&a.settled_balance===`0.00`&&a.pending_compute===`0.00`&&a.effective_balance===`0.00`&&c.current<3&&!f.isPending&&!f.isError&&!f.isSuccess&&(c.current+=1,h({}))},[a,f.isPending,f.isError,f.isSuccess,h]);let g=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Balance`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`An overview of your credit balance and pending charges.`})]}),(0,J.jsx)(i,{variant:`primary`,onClick:()=>s(!0),disabled:n||!a,"data-testid":`add-credits-button`,children:`Add Credits`})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(m,{padding:`md`,children:[g,n?(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading billing summary...`]}):r?(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load billing summary. Please try again later.`})}):a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mt-4`,children:(()=>{if(!a)return null;let e=parseFloat(a.effective_balance)<0,t=parseFloat(a.settled_balance)<0,n=parseFloat(a.pending_compute)<0;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Ve,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`effective-balance`,children:mn(a.effective_balance)}),label:`Balance`,tone:e?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(rt,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`settled-balance`,children:mn(a.settled_balance)}),label:`Settled Balance`,tone:t?`negative`:`default`}),(0,J.jsx)(S,{icon:(0,J.jsx)(it,{className:`h-4 w-4`,"aria-hidden":!0}),value:(0,J.jsx)(`span`,{"data-testid":`pending-charges`,children:mn(a.pending_compute)}),label:a.is_degraded?`Pending Usage (estimated)`:`Pending Usage`,tone:a.is_degraded?`muted`:n?`negative`:`default`})]})})()}),a.is_degraded&&(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`warning`,children:`Pending charges could not be calculated. The balance shown may be incomplete.`})})]}):(0,J.jsx)(`p`,{className:`mt-4 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`No billing information available.`}),(0,J.jsx)(`div`,{className:`mt-6 border-t border-[var(--border-base)] pt-6`,children:(0,J.jsx)(fn,{})})]}),(0,J.jsx)(Ye,{open:o,onOpenChange:s})]})}var gn=1e3,_n=15e3,vn=3e3,yn=45e3,bn=`billing-portal-return`;function xn(e,t){if(!e)return{kind:`info`,message:`Subscription updated.`};let n=e.cancel_at_period_end||!!e.cancel_at,r=t.cancel_at_period_end||!!t.cancel_at;return!n&&r?{kind:`info`,message:`Pro plan canceled. You'll have access until ${t.cancel_at?At(t.cancel_at):`the end of your billing period`}.`}:n&&!r?{kind:`success`,message:`Pro plan reactivated.`}:{kind:`info`,message:`Subscription updated.`}}function Sn(){let[e]=s(),t=o(),n=l(),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&(clearInterval(r.current),r.current=null)},[]),(0,q.useEffect)(()=>{if(e.get(`portal_return`)!==`true`)return;let i={current:!1},a=Dt(),o=W(),s=je(),c=Date.now();async function l(){await n.invalidateQueries({queryKey:s});let e=await n.fetchQuery(o);return{cancel_at_period_end:e.cancel_at_period_end,cancel_at:e.cancel_at}}async function u(){let e=await l();for(;!i.current&&a&&e.cancel_at_period_end===a.cancel_at_period_end&&e.cancel_at===a.cancel_at&&Date.now()-c<_n&&(await new Promise(e=>setTimeout(e,gn)),!i.current);)e=await l();return e}return(async()=>{try{let e=await u();if(i.current)return;let{kind:t,message:n}=xn(a,e);t===`success`?w.success(n,{id:bn}):w.info(n,{id:bn})}catch{if(i.current)return;w.info(`Subscription updated.`,{id:bn})}finally{if(!i.current){Ot(),t(U.settings.billing,{replace:!0});let e=Date.now();r.current!==null&&clearInterval(r.current),r.current=setInterval(()=>{if(Date.now()-e>=yn){r.current!==null&&(clearInterval(r.current),r.current=null);return}l().catch(e=>{console.error(`billing poll error:`,e)})},vn)}}})(),()=>{i.current=!0}},[e,t,n]),null}var Cn=[7,30,90].map(e=>({value:`${e}`,label:`Last ${e} days`}));function wn(e,t=Pe()){let{fromDate:n,toDate:r}=tt(e,t);return{from:n,to:r}}function Tn(e,t){let n=new Date(e),r=new Date(t);return Math.round((r.getTime()-n.getTime())/864e5)+1}function En({from:e,to:t}){let n=Tn(e,t);return n===7?7:n===90?90:30}function Dn({value:e,onChange:t}){let n=We(),r=(0,q.useMemo)(()=>`${En(e)}`,[e]);return(0,J.jsx)(h,{options:Cn,value:r,onChange:e=>{let r=Number(e);t(wn(r,n),r)},"aria-label":`Date range`})}var On={strokeDasharray:`3 3`,stroke:`var(--border-subtle)`,strokeOpacity:.4},kn={fontSize:12,fill:`var(--content-tertiary)`},An={stroke:`var(--border-subtle)`,strokeOpacity:.4},jn=[`#3b82f6`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#06b6d4`,`#ec4899`,`#84cc16`];function Mn({item:e}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5 text-[13px] text-[var(--content-default)]`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`span`,{className:`ml-auto tabular-nums`,children:e.value})]})}function Nn({active:e,payload:t,hoveredKey:n,label:r,labelMap:i,colorMap:a,formatValue:o,showTotal:s,formatLabel:c}){if(!e||!t?.length)return null;let l=t.filter(e=>e.value!=null&&e.dataKey!=null).map(e=>({key:String(e.dataKey),label:i[String(e.dataKey)]??String(e.dataKey),value:o(Number(e.value)),color:a[String(e.dataKey)]??`#6b7280`,numericValue:Number(e.value)})).sort((e,t)=>e.numericValue===t.numericValue?e.label.localeCompare(t.label):t.numericValue-e.numericValue),u=n?l.find(e=>e.key===n):null,d=u?l.filter(e=>e.key!==n):l,f=l.reduce((e,t)=>e+t.numericValue,0);return(0,J.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-overlay)] px-3.5 py-2.5 shadow-[var(--shadow-popover)]`,children:[(0,J.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-[var(--content-secondary)]`,children:(c??et)(String(r))}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Mn,{item:u}),d.length>0&&(0,J.jsx)(`div`,{className:`my-1.5 border-t border-[var(--border-subtle)]`})]}),d.map(e=>(0,J.jsx)(Mn,{item:e},e.key)),s&&(0,J.jsx)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-[var(--border-subtle)] pt-1.5 text-[13px] font-semibold text-[var(--content-default)]`,children:(0,J.jsxs)(`span`,{children:[`Total: `,o(f)]})})]})}function Pn(e,t){let[n,r]=e,[i,a]=t,o=r-n||1;return e=>i+(e-n)/o*(a-i)}function Fn(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t,r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*t}function In(e){if(e>=1)return+!Number.isInteger(e);let t=e/10**Math.floor(Math.log10(e)),n=Math.abs(t-2.5)<.01;return Math.ceil(-Math.log10(e))+ +!!n}function Ln(e,t){let n=Math.max(0,...e),r=t?.tickCount??5;return n===0?t?.integerOnly?r:1:t?.integerOnly?Math.max(1,Math.ceil(n/r))*r:Fn(n/r)*r}function Rn(e,t){if(e===0)return[0];let n=e/t,r=10**(n>=1?0:Math.ceil(-Math.log10(n))+2),i=[];for(let e=0;e<=t;e++)i.push(Math.round(n*e*r)/r);return i}function zn(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return[`M${e},${t+a}`,`A${a},${a} 0 0 1 ${e+a},${t}`,`H${e+n-a}`,`A${a},${a} 0 0 1 ${e+n},${t+a}`,`V${t+r}`,`H${e}`,`Z`].join(``)}function Bn(e,t){if(e<=0)return[];if(t)return e<=3?Array.from({length:e},(e,t)=>t):[0,Math.floor(e/2),e-1];let n=Math.max(1,Math.ceil(e/Math.min(e,12))),r=[];for(let t=0;t<e;t+=n)r.push(t);return r[r.length-1]!==e-1&&r.push(e-1),r}var Vn=40,Hn={fontSize:11,fill:`var(--content-tertiary)`},Un={runtime_proxy_api:`#3b82f6`,oauth_proxy:`#f59e0b`};function Wn(e,t){return Un[e]??jn[t%jn.length]??`#6b7280`}function Gn(e,t){let n=new Set,r={};for(let t of e)for(let e of t.groups)n.add(e.group_key),r[e.group_key]=e.group_label;return{data:e.map(e=>{let n={date:e.date};for(let r of e.groups)n[r.group_key]=t===`spend`?parseFloat(r.total_usd):r.event_count;return n}),stackKeys:Array.from(n),labelMap:r}}function Kn({stackKeys:e,labelMap:t}){return(0,J.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-5 gap-y-1 pt-3 text-body-small-default`,children:e.map((e,n)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-sm`,style:{backgroundColor:Wn(e,n)}}),(0,J.jsx)(`span`,{className:`text-[var(--content-quiet)]`,children:t[e]??e})]},e))})}var qn=350,Jn={top:8,right:4,bottom:32,left:0},Yn=.2,Xn=5,Zn=12,Qn=200;function $n({buckets:e,metric:t,onBarClick:n}){let r=ae(),i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&o(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let{data:s,stackKeys:c,labelMap:l}=(0,q.useMemo)(()=>Gn(e,t),[e,t]),u=(0,q.useMemo)(()=>{let e={};for(let t=0;t<c.length;t++)e[c[t]]=Wn(c[t],t);return e},[c]),d=(0,q.useCallback)(e=>t===`spend`?`$${e.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`:e.toLocaleString(`en-US`),[t]),[f,p]=(0,q.useState)(null),m=r?Vn:56,h=r?Hn:kn,g=Jn.left+m,_=Math.max(0,a-g-Jn.right),v=Jn.top,y=qn-Jn.top-Jn.bottom,b=(0,q.useMemo)(()=>s.map(e=>c.reduce((t,n)=>t+(Number(e[n])||0),0)),[s,c]),x=t===`events`,S=(0,q.useMemo)(()=>Ln(b,{integerOnly:x,tickCount:Xn}),[b,x]),C=(0,q.useMemo)(()=>Rn(S,Xn),[S]),w=(0,q.useCallback)(e=>{if(t===`spend`){if(e===0)return`$0`;let t=S/Xn,n=Math.max(t<1?2:0,In(t));return`$${e.toLocaleString(`en-US`,{minimumFractionDigits:n,maximumFractionDigits:n})}`}return e.toLocaleString(`en-US`)},[t,S]),T=(0,q.useMemo)(()=>Pn([0,S],[v+y,v]),[S,v,y]),E=s.length,D=E>0?_/E:0,O=D*(1-Yn),k=(D-O)/2,A=(0,q.useMemo)(()=>Bn(E,r),[E,r]),j=c.length===0,M=j?[]:s.map((e,t)=>{let n=g+t*D+k,r=0;return{di:t,x:n,segments:c.map((t,i)=>{let a=Number(e[t])||0,o=r;r+=a;let s=T(r),l=T(o)-s,u=i===c.length-1;return{key:t,val:a,x:n,y:s,h:l,color:Wn(t,i),isLast:u}})}}),N=(e,t,n)=>{let r=i.current?.getBoundingClientRect();r&&p({x:e.clientX-r.left,y:e.clientY-r.top,datumIndex:t,hoveredKey:n})},P=()=>p(null),F=e=>{n&&n(e)},I=f?c.filter(e=>(Number(s[f.datumIndex]?.[e])||0)>0).map(e=>({dataKey:e,value:Number(s[f.datumIndex]?.[e])||0})):[],L={left:f?Math.max(0,Math.min(f.x+Zn,a-Qn)):0,top:f?f.y-Zn:0,visibility:f?`visible`:`hidden`};return(0,J.jsxs)(`div`,{onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`div`,{ref:i,className:`relative w-full`,style:{height:qn},children:j?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center text-body-medium-lighter text-[var(--content-faint)]`,children:`No usage data for this period`}):a>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{width:a,height:qn,className:`block`,children:[C.map(e=>(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:T(e),y2:T(e),stroke:On.stroke,strokeOpacity:On.strokeOpacity,strokeDasharray:On.strokeDasharray},e)),(0,J.jsx)(`line`,{x1:g,x2:g+_,y1:v+y,y2:v+y,stroke:An.stroke,strokeOpacity:An.strokeOpacity}),C.map(e=>(0,J.jsx)(`text`,{x:g-8,y:T(e),textAnchor:`end`,dominantBaseline:`middle`,fontSize:h.fontSize,fill:h.fill,children:w(e)},e)),A.map(e=>{let t=s[e];return t?(0,J.jsx)(`text`,{x:g+e*D+D/2,y:v+y+20,textAnchor:`middle`,fontSize:h.fontSize,fill:h.fill,children:et(String(t.date))},e):null}),M.map(({di:e,segments:t})=>t.map(t=>{if(t.h<=0)return null;let r=f?.hoveredKey&&f.hoveredKey!==t.key?.4:1,i={key:`${e}-${t.key}`,fill:t.color,opacity:r,cursor:n?`pointer`:void 0,onMouseMove:n=>N(n,e,t.key),onMouseLeave:P,onClick:()=>F(t.key)};return t.isLast?(0,J.jsx)(`path`,{...i,d:zn(t.x,t.y,O,t.h,3)}):(0,J.jsx)(`rect`,{...i,x:t.x,y:t.y,width:O,height:t.h})}))]}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute z-[1] max-w-[calc(100vw-32px)] -translate-y-full`,style:L,children:(0,J.jsx)(Nn,{active:!!f,payload:I,hoveredKey:f?.hoveredKey??void 0,label:f?String(s[f.datumIndex]?.date):``,labelMap:l,colorMap:u,formatValue:d})})]}):null}),!j&&(0,J.jsx)(Kn,{stackKeys:c,labelMap:l})]})}function er(e=Pe()){return wn(30,e)}function tr(e){if(e)return e.usageSource===`oauth_proxy`?`oauth_provider`:Ze(e.llmDimension??`model`)}function nr(e,t=Pe()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource,group_by:tr(e.drilldown)}:{}}}function rr(e,t=Pe()){return{from:e.dateRange.from,to:e.dateRange.to,tz:t,...e.drilldown?{usage_source:e.drilldown.usageSource}:{}}}function ir(e){let t=We(),n=u(Oe({query:nr(e,t)})),r=u(Ae({query:rr(e,t)}));return{series:n.data,totals:r.data,isLoading:n.isLoading||r.isLoading,isError:n.isError||r.isError}}var ar=[{value:`spend`,label:`Spend ($)`},{value:`events`,label:`Events`}];function or(e){if(e===void 0)return`—`;let t=parseFloat(e);return Number.isNaN(t)?`$0.00`:`$${t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function sr(e){return e===void 0?`—`:e.toLocaleString(`en-US`)}function cr(){let e=We(),[t,n]=(0,q.useState)(30),[r,i]=(0,q.useState)(()=>er(e)),a=(0,q.useMemo)(()=>t===null?r:wn(t,e),[t,r,e]),o=(e,t)=>{n(t),i(e)},[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(`spend`),{series:d,totals:f,isLoading:h,isError:g}=ir({dateRange:a,setDateRange:e=>{n(null),i(e)},drilldown:s,setDrilldown:c}),_=s?void 0:e=>{let t={runtime_proxy_api:`runtime_proxy`,oauth_proxy:`oauth_proxy`}[e];t&&c({usageSource:t,...t===`runtime_proxy`?{llmDimension:$e}:{}})};return(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Credit Usage`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Overview of your spending habits.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 [&_[role=combobox]]:h-8 [&_[role=radio]]:h-7`,children:[(0,J.jsx)(Dn,{value:a,onChange:o}),(0,J.jsx)(`div`,{className:`w-44`,children:(0,J.jsx)(x,{items:ar,value:l,onChange:u,ariaLabel:`Chart metric`})})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[(0,J.jsx)(S,{icon:(0,J.jsx)(Ve,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):or(f?.total_usd),label:`Spend`}),(0,J.jsx)(S,{icon:(0,J.jsx)(ot,{className:`h-4 w-4`,"aria-hidden":!0}),value:h?(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`,"aria-hidden":!0}):sr(f?.event_count),label:`Events`})]}),s&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsxs)(`button`,{className:`flex items-center gap-1.5 text-body-medium-lighter text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,onClick:()=>c(null),children:[(0,J.jsx)(E,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Back to all usage`}),(0,J.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:`/`}),(0,J.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:s.usageSource===`runtime_proxy`?`LLM Spend`:`OAuth Spend`})]})}),s.usageSource===`runtime_proxy`&&(0,J.jsx)(`div`,{className:`w-56`,children:(0,J.jsx)(x,{items:Qe,value:s.llmDimension??`model`,onChange:e=>c({usageSource:`runtime_proxy`,llmDimension:e}),ariaLabel:`LLM spend dimension`})})]}),h?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)]`,children:(0,J.jsx)(R,{className:`h-6 w-6 animate-spin text-[var(--content-tertiary)]`})}):g?(0,J.jsx)(`div`,{className:`flex h-[345px] items-center justify-center rounded-xl bg-[var(--surface-base)] text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Failed to load usage data.`}):d?(0,J.jsx)(`div`,{className:`rounded-xl bg-[var(--surface-base)] p-3`,children:(0,J.jsx)($n,{buckets:d.buckets,metric:l,onBarClick:_})}):null]})})}function lr(){let{data:e}=u(W()),t=Mt((0,q.useMemo)(()=>kt(e),[e]));if(!e||e.plan_id!==`pro`||e.status===`canceled`||!e.cancel_at_period_end&&!e.cancel_at)return null;let n=jt(e);return n?(0,J.jsx)(_,{tone:`info`,title:`Your Pro plan will end on ${At(n)}.`,actions:(0,J.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>t.mutate({}),disabled:t.isPending,leftIcon:t.isPending?(0,J.jsx)(R,{className:`animate-spin`}):void 0,"data-testid":`grace-period-reactivate-button`,children:`Reactivate`}),"data-testid":`grace-period-banner`,children:`You'll keep Pro features until then.`}):null}var ur=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),dr=t(((e,t)=>{var n=ur();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),X=e(t(((e,t)=>{t.exports=dr()()}))(),1);function fr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fr(Object(n),!0).forEach(function(t){hr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mr(e){"@babel/helpers - typeof";return mr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},mr(e)}function hr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function _r(e,t){if(e==null)return{};var n=gr(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function vr(e,t){return yr(e)||br(e,t)||xr(e,t)||Cr()}function yr(e){if(Array.isArray(e))return e}function br(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function xr(e,t){if(e){if(typeof e==`string`)return Sr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sr(e,t)}}function Sr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Cr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Z=function(e,t,n){var r=!!n,i=q.useRef(n);q.useEffect(function(){i.current=n},[n]),q.useEffect(function(){if(!r||!e)return function(){};var n=function(){i.current&&i.current.apply(i,arguments)};return e.on(t,n),function(){e.off(t,n)}},[r,t,e,i])},wr=function(e){var t=q.useRef(e);return q.useEffect(function(){t.current=e},[e]),t.current},Tr=function(e){return e!==null&&mr(e)===`object`},Er=function(e){return Tr(e)&&typeof e.then==`function`},Dr=function(e){return Tr(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Or=`[object Object]`,kr=function e(t,n){if(!Tr(t)||!Tr(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Or;if(i!==(Object.prototype.toString.call(n)===Or))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Ar=function(e,t,n){return Tr(e)?Object.keys(e).reduce(function(r,i){var a=!Tr(t)||!kr(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?pr(pr({},r||{}),{},hr({},i,e[i])):r},null):null},jr="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",Mr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jr;if(e===null||Dr(e))return e;throw Error(t)},Nr=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jr;if(Er(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return Mr(e,t)})};var n=Mr(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Pr=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Fr=q.createContext(null);Fr.displayName=`ElementsContext`;var Ir=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e},Lr=function(e){var t=e.stripe,n=e.options,r=e.children,i=q.useMemo(function(){return Nr(t)},[t]),a=vr(q.useState(function(){return{stripe:i.tag===`sync`?i.stripe:null,elements:i.tag===`sync`?i.stripe.elements(n):null}}),2),o=a[0],s=a[1];q.useEffect(function(){var e=!0,t=function(e){s(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return i.tag===`async`&&!o.stripe?i.stripePromise.then(function(n){n&&e&&t(n)}):i.tag===`sync`&&!o.stripe&&t(i.stripe),function(){e=!1}},[i,o,n]);var c=wr(t);q.useEffect(function(){c!==null&&c!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[c,t]);var l=wr(n);return q.useEffect(function(){if(o.elements){var e=Ar(n,l,[`clientSecret`,`fonts`]);e&&o.elements.update(e)}},[n,l,o.elements]),q.useEffect(function(){Pr(o.stripe)},[o.stripe]),q.createElement(Fr.Provider,{value:o},r)};Lr.propTypes={stripe:X.default.any,options:X.default.object};var Rr=function(e){return Ir(q.useContext(Fr),e)},zr=function(e){var t=e.children;return t(Rr(`mounts <ElementsConsumer>`))};zr.propTypes={children:X.default.func.isRequired};var Br=q.createContext(null);Br.displayName=`CheckoutContext`;var Vr=function(e){var t=q.useContext(Br),n=q.useContext(Fr);if(t){if(n)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return t}else return Ir(n,e)},Hr=[`mode`],Ur=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,t,n){var r=`${Ur(e)}Element`,i=t?function(e){Vr(`mounts <${r}>`);var t=e.id,n=e.className;return q.createElement(`div`,{id:t,className:n})}:function(t){var n=t.id,i=t.className,a=t.options,o=a===void 0?{}:a,s=t.onBlur,c=t.onFocus,l=t.onReady,u=t.onChange,d=t.onEscape,f=t.onClick,p=t.onLoadError,m=t.onLoaderStart,h=t.onNetworksChange,g=t.onConfirm,_=t.onCancel,v=t.onShippingAddressChange,y=t.onShippingRateChange,b=t.onSavedPaymentMethodRemove,x=t.onSavedPaymentMethodUpdate,S=t.onAvailablePaymentMethodsChange,C=Vr(`mounts <${r}>`),w=`elements`in C?C.elements:null,T=`checkoutState`in C?C.checkoutState:null,E=T?.type===`success`||T?.type===`loading`?T.sdk:null,D=vr(q.useState(null),2),O=D[0],k=D[1],A=q.useRef(null),j=q.useRef(null);Z(O,`blur`,s),Z(O,`focus`,c),Z(O,`escape`,d),Z(O,`click`,f),Z(O,`loaderror`,p),Z(O,`loaderstart`,m),Z(O,`networkschange`,h),Z(O,`confirm`,g),Z(O,`cancel`,_),Z(O,`shippingaddresschange`,v),Z(O,`shippingratechange`,y),Z(O,`savedpaymentmethodremove`,b),Z(O,`savedpaymentmethodupdate`,x),Z(O,`availablepaymentmethodschange`,S),Z(O,`change`,u);var M;l&&(M=e===`expressCheckout`?l:function(){l(O)}),Z(O,`ready`,M),q.useLayoutEffect(function(){if(A.current===null&&j.current!==null&&(w||E)){var t=null;if(E){var n=E,i=E;switch(e){case`paymentForm`:t=i.createForm(o);break;case`payment`:t=n.createPaymentElement(o);break;case`address`:if(`mode`in o){var a=o.mode,s=_r(o,Hr);if(a===`shipping`)t=n.createShippingAddressElement(s);else if(a===`billing`)t=n.createBillingAddressElement(s);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(o);break;case`currencySelector`:t=E.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(o);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${r}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else w&&(t=w.create(e,o));A.current=t,k(t),t&&t.mount(j.current)}},[w,E,o]);var N=wr(o);return q.useEffect(function(){if(A.current){var e=Ar(o,N,[`paymentRequest`]);e&&`update`in A.current&&A.current.update(e)}},[o,N]),q.useLayoutEffect(function(){return function(){if(A.current&&typeof A.current.destroy==`function`)try{A.current.destroy(),A.current=null}catch{}}},[]),q.createElement(`div`,{id:n,className:i,ref:j})};return i.propTypes={id:X.default.string,className:X.default.string,onChange:X.default.func,onBlur:X.default.func,onFocus:X.default.func,onReady:X.default.func,onEscape:X.default.func,onClick:X.default.func,onLoadError:X.default.func,onLoaderStart:X.default.func,onNetworksChange:X.default.func,onConfirm:X.default.func,onCancel:X.default.func,onShippingAddressChange:X.default.func,onShippingRateChange:X.default.func,onSavedPaymentMethodRemove:X.default.func,onSavedPaymentMethodUpdate:X.default.func,onAvailablePaymentMethodsChange:X.default.func,options:X.default.object},i.displayName=r,i.__elementType=e,i},$=typeof window>`u`,Wr=q.createContext(null);Wr.displayName=`EmbeddedCheckoutProviderContext`,Q(`auBankAccount`,$),Q(`card`,$),Q(`cardNumber`,$),Q(`cardExpiry`,$),Q(`cardCvc`,$),Q(`iban`,$),Q(`payment`,$),Q(`expressCheckout`,$),Q(`paymentRequestButton`,$),Q(`linkAuthentication`,$),Q(`contactDetails`,$),Q(`address`,$),Q(`shippingAddress`,$),Q(`paymentMethodMessaging`,$),Q(`taxId`,$),Q(`issuingCardNumberDisplay`,$),Q(`issuingCardCvcDisplay`,$),Q(`issuingCardExpiryDisplay`,$),Q(`issuingCardPinDisplay`,$),Q(`issuingCardCopyButton`,$);var Gr=`dahlia`,Kr=`https://js.stripe.com`,qr=`${Kr}/${Gr}/stripe.js`,Jr=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Yr=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Xr=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,Zr=function(e){return Jr.test(e)||Yr.test(e)},Qr=function(){for(var e=document.querySelectorAll(`script[src^="${Kr}"]`),t=0;t<e.length;t++){var n=e[t];if(Zr(n.src))return n}return null},$r=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${qr}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},ei=null,ti=null,ni=null,ri=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},ii=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},ai=function(e){return ei===null?(ei=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Xr),window.Stripe){t(window.Stripe);return}try{var r=Qr();if(r&&e)console.warn(Xr);else if(!r)r=$r(e);else if(r&&ni!==null&&ti!==null){var i;r.removeEventListener(`load`,ni),r.removeEventListener(`error`,ti),(i=r.parentNode)==null||i.removeChild(r),r=$r(e)}ni=ii(t,n),ti=ri(n),r.addEventListener(`load`,ni),r.addEventListener(`error`,ti)}catch(e){n(e);return}}),ei.catch(function(e){return ei=null,Promise.reject(e)})):ei},oi,si=!1,ci=function(){return oi||(oi=ai(null).catch(function(e){return oi=null,Promise.reject(e)}),oi)};Promise.resolve().then(function(){return ci()}).catch(function(e){si||console.warn(e)});function li(){return typeof document<`u`&&document.documentElement.classList.contains(`dark`)?{theme:`night`}:{theme:`stripe`}}function ui({open:e,onClose:t,onSavedOptimistic:n}){let r=d(_e()),{mutate:i,reset:a}=r;return(0,q.useEffect)(()=>{e||a()},[e,i,a]),(0,q.useMemo)(()=>li(),[r.data?.client_secret??null]),(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||t()},children:(0,J.jsxs)(C.Content,{size:`sm`,children:[(0,J.jsx)(C.Header,{children:(0,J.jsx)(C.Title,{children:`Save Payment Method`})}),(0,J.jsx)(C.Body,{className:`min-h-[260px]`,children:(0,J.jsx)(di,{})})]})})}function di(){return(0,q.useEffect)(()=>{console.warn(`[AutoTopUpPaymentMethodModal] VITE_STRIPE_PUBLISHABLE_KEY is not set; the payment-method modal cannot mount Stripe Elements.`)},[]),(0,J.jsx)(_,{tone:`error`,children:`Payment method setup is currently unavailable. Please try again later.`})}function fi(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Payment Method`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`This is the payment method that will be used for automated credit reloads.`})]})}function pi(){let e=l(),t=u(se()),[n,r]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=d(Ne()),c=async()=>{let t=Date.now(),n=e=>e?.stripe_payment_method_updated_at??null,r=n(e.getQueryData(ve()));try{await e.invalidateQueries({queryKey:ve()})}catch{}for(;Date.now()-t<2e4;){try{let t=await e.fetchQuery(se());if(t.has_payment_method&&n(t)!==r)return}catch{}await new Promise(e=>setTimeout(e,1500))}};if(t.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(fi,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading…`]})]});if(t.isError||!t.data)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(fi,{}),(0,J.jsx)(`div`,{className:`mt-4`,children:(0,J.jsx)(_,{tone:`error`,children:`Failed to load payment method.`})})]});let f=t.data,h=Qt(f.payment_method_brand??`card`),v=f.payment_method_last4;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{padding:`md`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(fi,{}),f.has_payment_method?(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(j,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,children:h}),v?(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[`Ending in `,v]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>r(!0),children:`Change`}),(0,J.jsx)(i,{variant:`ghost`,onClick:()=>o(!0),disabled:a||s.isPending,leftIcon:(0,J.jsx)(Re,{className:`h-3.5 w-3.5`}),children:`Remove`})]})]}):(0,J.jsx)(i,{className:`self-start`,onClick:()=>r(!0),children:`Add Card`})]})}),(0,J.jsx)(g,{open:a,title:`Remove payment method?`,message:`Removing your payment method will disable automatic top-ups. You can re-enable them after adding a new payment method.`,confirmLabel:s.isPending?`Removing…`:`Remove`,cancelLabel:`Keep`,destructive:!0,onConfirm:()=>{s.isPending||s.mutate({},{onSuccess:()=>{ue(e,void 0,e=>e?{...e,enabled:!1,has_payment_method:!1,payment_method_brand:null,payment_method_last4:null}:ln),o(!1)},onError:()=>{w.error(`Failed to remove payment method. Please try again.`),o(!1)}})},onCancel:()=>{s.isPending||o(!1)}}),(0,J.jsx)(ui,{open:n,onClose:()=>r(!1),onSavedOptimistic:c})]})}var mi={invoices:[]};function hi(e){switch(e){case`paid`:return`positive`;case`open`:return`warning`;case`uncollectible`:return`negative`;default:return`neutral`}}function gi(e,t){let n=t.toUpperCase();try{let t=new Intl.NumberFormat(void 0,{style:`currency`,currency:n}),r=t.resolvedOptions().maximumFractionDigits??2;return t.format(e/10**r)}catch{return`${(e/100).toFixed(2)} ${n}`}}function _i(e){return Xe(new Date(e*1e3),{alwaysShowYear:!0})}function vi(e){let t=document.createElement(`a`);t.href=e,t.target=`_blank`,t.rel=`noopener noreferrer`,document.body.appendChild(t),t.click(),t.remove()}function yi({open:e,onOpenChange:t}){let[r,o]=(0,q.useState)(!1),s=u({queryKey:le(),enabled:e,queryFn:async({signal:e})=>{let{data:t,response:n}=await H({throwOnError:!1,signal:e});if(n?.status===404)return mi;if(!n?.ok||!t)throw Error(`Failed to load invoices (${n?.status??`network error`})`);return t}}),c=s.data?.invoices??[],l=c.some(e=>e.invoice_pdf!=null);async function d(){o(!0);try{let{data:e,response:t}=await ie({throwOnError:!1,parseAs:`blob`});if(!t?.ok||!(e instanceof Blob))throw Error(`Failed to download invoices (${t?.status??`network error`})`);let{saveFile:n}=await a(async()=>{let{saveFile:e}=await import(`./native-file-B-MK3Ngg.js`).then(e=>e.t);return{saveFile:e}},__vite__mapDeps([0,1,2,3]));await n(e,`invoices.zip`)}catch(e){n(e,{context:`download_all_invoices`}),w.error(`Failed to download invoices.`)}finally{o(!1)}}return(0,J.jsx)(C.Root,{open:e,onOpenChange:t,children:(0,J.jsxs)(C.Content,{size:`lg`,children:[(0,J.jsxs)(C.Header,{children:[(0,J.jsx)(C.Title,{icon:F,children:`Invoices`}),(0,J.jsx)(C.Description,{children:`Your billing history. Open an invoice for full details or download it as a PDF.`})]}),(0,J.jsx)(C.Body,{children:s.isLoading?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading invoices...`})]}):s.isError?(0,J.jsx)(_,{tone:`error`,children:`Failed to load invoices.`}):c.length===0?(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`py-6 text-center text-[var(--content-tertiary)]`,"data-testid":`invoices-empty`,children:`No Invoices Found`}):(0,J.jsx)(`ul`,{className:`flex flex-col divide-y divide-[var(--border-base)]`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-3 py-3`,"data-testid":`invoice-row`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`span`,className:`text-[var(--content-default)]`,children:e.number??`Invoice`}),e.status&&(0,J.jsx)(v,{tone:hi(e.status),children:e.status})]}),(0,J.jsxs)(p,{variant:`body-small-default`,as:`div`,className:`text-[var(--content-tertiary)]`,children:[_i(e.created),` ·`,` `,gi(e.amount_due,e.currency)]})]}),e.hosted_invoice_url&&(0,J.jsx)(i,{asChild:!0,variant:`ghost`,size:`compact`,leftIcon:(0,J.jsx)(P,{}),children:(0,J.jsx)(`a`,{href:e.hosted_invoice_url,target:`_blank`,rel:`noopener noreferrer`,children:`View`})}),e.invoice_pdf&&(0,J.jsx)(i,{variant:`ghost`,size:`compact`,iconOnly:(0,J.jsx)(Le,{}),"aria-label":`Download invoice PDF`,onClick:()=>vi(e.invoice_pdf)})]},e.id))})}),(0,J.jsxs)(C.Footer,{children:[l&&(0,J.jsx)(i,{variant:`outlined`,leftIcon:r?(0,J.jsx)(R,{className:`animate-spin`}):(0,J.jsx)(Le,{}),disabled:r,onClick:d,children:`Download all`}),(0,J.jsx)(C.Close,{asChild:!0,children:(0,J.jsx)(i,{variant:`primary`,children:`Done`})})]})]})})}var bi={pro:{icon:M,actionLabel:`Manage`,actionVariant:`outlined`,actionTestId:`plan-card-manage-button`,showsRenewal:!0},base:{icon:st,actionLabel:`Upgrade to Pro`,actionVariant:`primary`,actionTestId:`plan-card-upgrade-button`,showsRenewal:!1}},xi=bi.base;function Si(){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Plan`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:`Manage which Vellum plan you're on.`})]})}function Ci({onManage:e}){let[t,n]=(0,q.useState)(!1),r=u(W()),a=u(fe());if(r.isLoading||a.isLoading)return(0,J.jsxs)(m,{padding:`md`,children:[(0,J.jsx)(Si,{}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(p,{as:`span`,variant:`body-small-default`,children:`Loading plan...`})]})]});let o=r.data,s=a.data?.plans,c=s?.find(e=>e.id===o?.plan_id);if(r.isError||a.isError||!o||!s||!c)return(0,J.jsx)(_,{tone:`error`,children:`Failed to load plan.`});let l=bi[c.id]??xi,d=l.icon,f=c.name??c.id,h=l.showsRenewal&&(o.cancel_at_period_end===!0||!!o.cancel_at),g=o.status===`canceled`,v=jt(o),y=l.showsRenewal&&!h&&!g&&o.current_period_end,b=l.showsRenewal&&h&&!g&&v,x=c.id===`pro`?c:void 0,S=o.selected_credit_tier??null,C=S==null?void 0:x?.credit_tiers,w=C?.find(e=>e.tier===S),T=w?`${w.label} (${Y(w.price_cents)})`:C?.length?S:null;return(0,J.jsxs)(m,{padding:`lg`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsx)(Si,{}),(0,J.jsx)(i,{variant:`outlined`,leftIcon:(0,J.jsx)(F,{}),onClick:()=>n(!0),"data-testid":`plan-card-invoices-button`,children:`Invoices`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)]`,children:(0,J.jsx)(d,{className:`h-4 w-4 text-[var(--content-default)]`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,J.jsx)(p,{variant:`body-medium-default`,as:`div`,"data-testid":`plan-card-name`,children:f}),(0,J.jsx)(p,{variant:`body-small-default`,as:`div`,className:`leading-snug text-[var(--content-tertiary)]`,children:(0,J.jsx)(Jt,{features:c.included_features,variant:`inline`})})]}),(0,J.jsx)(i,{variant:l.actionVariant,onClick:e,"data-testid":l.actionTestId,children:l.actionLabel})]}),T&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-credit-bundle`,children:[`Monthly credits: `,T]}),y&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--content-tertiary)]`,"data-testid":`plan-card-renews`,children:[`Renews on `,At(o.current_period_end),`.`]}),b&&(0,J.jsxs)(p,{as:`p`,variant:`body-small-default`,className:`text-[var(--system-mid-strong)]`,"data-testid":`plan-card-cancels`,children:[`Your plan ends on `,At(v),`.`]})]}),(0,J.jsx)(yi,{open:t,onOpenChange:n})]})}var wi=`settings-referral-panel`;function Ti(e){return e.replace(/\.00$/,``)}function Ei(){let{data:e,isLoading:t,isError:n}=u(Te()),[r,a]=(0,q.useState)(!1),o=(0,q.useCallback)(e=>{navigator.clipboard.writeText(e).then(()=>{a(!0),w.success(`Copied to clipboard!`),setTimeout(()=>a(!1),2e3)})},[]),s=e?`Share Vellum with friends - you'll each earn ${Ti(e.referrer_credit_amount)} credits when they sign up, up to ${Ti(e.earning_cap)} total.`:`Share Vellum with friends and earn credits for every signup.`;return(0,J.jsx)(m,{padding:`md`,id:wi,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(p,{as:`h2`,variant:`title-medium`,className:`text-[var(--content-default)]`,children:`Earn Free Credits`}),(0,J.jsx)(p,{as:`p`,variant:`body-small-default`,className:`mt-2 text-[var(--content-tertiary)]`,children:s})]}),t?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-body-medium-lighter text-[var(--content-tertiary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading...`]}):n||!e?(0,J.jsx)(_,{tone:`error`,children:`Failed to load referral information.`}):(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Ve,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:Ti(e.total_earned)}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Credits Earned`})]})]}),(0,J.jsxs)(`div`,{className:`flex min-w-[200px] flex-1 items-center gap-1.5 rounded-lg bg-[var(--surface-base)] px-2 py-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`flex h-6 w-6 shrink-0 items-center justify-center text-[var(--content-emphasised)]`,children:(0,J.jsx)(Be,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`span`,{className:`flex items-baseline gap-1 text-body-medium-default`,children:[(0,J.jsx)(`span`,{children:e.referred_count}),(0,J.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Friends Referred`})]})]}),(0,J.jsx)(i,{variant:`outlined`,onClick:()=>o(e.referral_url),leftIcon:r?(0,J.jsx)(D,{className:`h-3.5 w-3.5`}):(0,J.jsx)(ze,{className:`h-3.5 w-3.5`}),"data-testid":`referral-copy-button`,children:r?`Copied!`:`Copy Share Link`})]})]})})}function Di({icon:e,label:t,from:n,to:r}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-[var(--surface-base)] p-3`,children:[(0,J.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,style:{backgroundColor:`color-mix(in oklab, var(--system-positive-strong) 10%, transparent)`},children:(0,J.jsx)(e,{className:`h-4 w-4 text-[var(--system-positive-strong)]`})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:t}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-tertiary)] line-through`,children:n}),(0,J.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-[var(--content-tertiary)]`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:r})]})]})]})}function Oi({open:e,onClose:t}){let n=u({...G(),enabled:e}),r=u({...me(),enabled:e}),a=n.data,o=a?.machine_size||`small`,s=a?.provisioned_storage_gib??null,c=r.data?.max_machine_tier??null,l=r.data?.selected_storage_gib??null,d=ee(c),f=d.length>0?d[d.length-1]:o,p=f!==o,m=l!=null&&(s==null||s<l),h=p||m,[g,v]=(0,q.useState)(null),y=Ce({onSuccess:()=>{w.success(`Resize started. Changes will apply shortly.`,{id:`assistant-resize`}),v(null),t()},onError:e=>{v(V(e,`Failed to resize assistant. Please try again.`))}}),b=y.isPending,x=n.isLoading||r.isLoading;return(0,J.jsx)(C.Root,{open:e,onOpenChange:e=>{e||(v(null),t())},children:(0,J.jsxs)(C.Content,{size:`sm`,children:[(0,J.jsxs)(C.Header,{children:[(0,J.jsx)(C.Title,{icon:te,children:`Plan Updated`}),(0,J.jsx)(C.Description,{children:`Your new resources are ready. Apply them now to resize your assistant — it will briefly restart.`})]}),(0,J.jsxs)(C.Body,{children:[x?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,J.jsx)(R,{className:`h-5 w-5 animate-spin text-[var(--content-tertiary)]`})}):h?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Di,{icon:A,label:`Machine`,from:B[o],to:B[f]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`CPU`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:z[f].split(`,`)[0].trim()})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-lg bg-[var(--surface-base)] px-3 py-2.5`,children:[(0,J.jsx)(`span`,{className:`text-label-small-default text-[var(--content-tertiary)]`,children:`Memory`}),(0,J.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-default)]`,children:z[f].split(`,`)[1].trim()})]})]})]}),m&&(0,J.jsx)(Di,{icon:I,label:`Storage`,from:s==null?`—`:`${s} GiB`,to:`${l} GiB`})]}):(0,J.jsx)(_,{tone:`neutral`,children:`Your assistant is already running at the maximum size for your plan.`}),g&&(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(_,{tone:`error`,children:g})})]}),(0,J.jsxs)(C.Footer,{children:[(0,J.jsx)(i,{variant:`ghost`,onClick:()=>{v(null),t()},children:`Do Later`}),(0,J.jsx)(i,{disabled:x||!h||b||!a?.id,leftIcon:b?(0,J.jsx)(R,{className:`animate-spin`}):void 0,onClick:()=>{if(!a?.id)return;v(null);let e={};p&&(e.machine_size=f),m&&l!=null&&(e.storage_gib=l),y.mutate({path:{id:a.id},body:e})},children:g?`Retry`:`Apply & Restart`})]})]})})}function ki(){let[e]=s(),t=o(),n=l();return(0,q.useEffect)(()=>{let r=e.get(`billing_status`);r&&(r===`success`?(w.success(`Payment received! Your credit balance will update shortly.`,{id:`billing-status`}),n.invalidateQueries({queryKey:K().queryKey})):r===`cancel`&&w.info(`Checkout was cancelled. No credits were added.`,{id:`billing-status`}),t(U.settings.billing,{replace:!0}))},[e,t,n]),null}function Ai(){let e=He({platformHostedOnly:!0}),t=He(),n=qe(),r=Ue(),[i,a]=s(),[o,l]=(0,q.useState)(!1),u=(0,q.useCallback)(()=>l(!0),[]),d=(0,q.useCallback)(()=>l(!1),[]),[f,p]=(0,q.useState)(!1),m=(0,q.useCallback)(()=>p(!0),[]);(0,q.useEffect)(()=>{i.has(`adjust_plan`)&&(l(!0),a(e=>{let t=new URLSearchParams(e);return t.delete(`adjust_plan`),t},{replace:!0}))},[i,a]);let h=i.has(`session_id`),g=(0,q.useCallback)(()=>{a(e=>{let t=new URLSearchParams(e);return t.delete(`session_id`),t},{replace:!0})},[a]);if(t===`gated`)return(0,J.jsx)(c,{replace:!0,to:U.settings.general});if(t===`disabled`)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(Je,{children:`Log in to the Vellum platform to manage billing and usage.`})});if(r)return(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-body-medium-lighter text-[var(--content-secondary)]`,children:[(0,J.jsx)(R,{className:`h-4 w-4 animate-spin`}),`Loading billing…`]})});let v=n;return!n&&e!==`gated`?(0,J.jsx)(`div`,{className:`space-y-4`,children:(0,J.jsx)(_,{tone:`warning`,children:`Billing isn't available for the current assistant state.`})}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(q.Suspense,{fallback:null,children:[(0,J.jsx)(ki,{}),(0,J.jsx)(Sn,{})]}),v&&(0,J.jsx)(lr,{}),v&&(0,J.jsx)(Ci,{onManage:u}),v&&(0,J.jsx)(Xt,{open:o,onClose:d,onTierUpgraded:m}),(0,J.jsx)(pi,{}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(hn,{})}),(0,J.jsx)(Ei,{}),(0,J.jsx)(cr,{}),v&&(0,J.jsx)(wt,{open:h,onClose:g}),v&&(0,J.jsx)(Oi,{open:f,onClose:()=>p(!1)})]})}export{Ai as BillingPage};
@@ -1 +1 @@
1
- import{t as e}from"./button-D7s2Q_uG.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-BibIM9x3.js";import{t as i}from"./bookmark-C3S-p0MQ.js";import{t as a}from"./loader-circle-IIzBGiwm.js";import{t as o}from"./triangle-alert-DKOyShqD.js";import{t as s}from"./x-KVxA2ZL0.js";import{a as c}from"./routes-DVqkwUEe.js";import{F as l,I as u,Zr as d}from"./index-BIDC22lX.js";var f=n();function p(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function m(){return(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,f.jsx)(i,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Hover any message and click the bookmark icon to save it here.`})]})})}function h({bookmark:t,isFirst:n,onOpen:r,onRemove:i}){let a=t.conversationTitle&&t.conversationTitle.trim().length>0?t.conversationTitle:`Untitled conversation`,o=t.messageRole!==`user`,c=p(t.createdAt);return(0,f.jsxs)(`div`,{className:`flex items-start gap-3 py-3 ${n?``:`border-t border-[var(--border-base)]`}`,children:[(0,f.jsx)(`span`,{"aria-hidden":!0,className:`mt-1 h-8 w-1 shrink-0 rounded-full`,style:{backgroundColor:o?`var(--content-default)`:`var(--content-tertiary)`}}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,f.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),c?(0,f.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:c}):null]}),t.messagePreview?(0,f.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-small-default text-[var(--content-tertiary)]`,children:t.messagePreview}):null]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,f.jsx)(e,{variant:`outlined`,onClick:r,children:`Open`}),(0,f.jsx)(`button`,{type:`button`,onClick:i,title:`Remove bookmark`,"aria-label":`Remove bookmark`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-active)] hover:text-[var(--content-default)]`,children:(0,f.jsx)(s,{className:`h-4 w-4`})})]})]})}function g(){let n=t(),{bookmarks:i,isLoading:s,isError:p,refetch:g}=u(),_=l();return s?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,f.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):p?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,f.jsx)(o,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,f.jsxs)(e,{variant:`outlined`,onClick:g,className:`mt-4`,children:[(0,f.jsx)(d,{className:`h-4 w-4`}),`Retry`]})]})})}):i.length===0?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(m,{})}):(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{noPadding:!0,className:`px-4`,children:i.map((e,t)=>(0,f.jsx)(h,{bookmark:e,isFirst:t===0,onOpen:()=>{n(c.conversationAtMessage(e.conversationId,e.messageId))},onRemove:()=>{_(e.messageId,e.conversationId,!0)}},e.id))})})}export{g as BookmarksPage};
1
+ import{t as e}from"./button-D7s2Q_uG.js";import{d as t}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{t as r}from"./card-BibIM9x3.js";import{t as i}from"./bookmark-C3S-p0MQ.js";import{t as a}from"./loader-circle-IIzBGiwm.js";import{t as o}from"./triangle-alert-DKOyShqD.js";import{t as s}from"./x-KVxA2ZL0.js";import{a as c}from"./routes-DVqkwUEe.js";import{F as l,I as u,Zr as d}from"./index-PRnvH2Y1.js";var f=n();function p(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function m(){return(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--surface-base)]`,children:(0,f.jsx)(i,{className:`h-6 w-6 text-[var(--content-disabled)] dark:text-[var(--content-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`No bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Hover any message and click the bookmark icon to save it here.`})]})})}function h({bookmark:t,isFirst:n,onOpen:r,onRemove:i}){let a=t.conversationTitle&&t.conversationTitle.trim().length>0?t.conversationTitle:`Untitled conversation`,o=t.messageRole!==`user`,c=p(t.createdAt);return(0,f.jsxs)(`div`,{className:`flex items-start gap-3 py-3 ${n?``:`border-t border-[var(--border-base)]`}`,children:[(0,f.jsx)(`span`,{"aria-hidden":!0,className:`mt-1 h-8 w-1 shrink-0 rounded-full`,style:{backgroundColor:o?`var(--content-default)`:`var(--content-tertiary)`}}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,f.jsx)(`div`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:a}),c?(0,f.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:c}):null]}),t.messagePreview?(0,f.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-body-small-default text-[var(--content-tertiary)]`,children:t.messagePreview}):null]}),(0,f.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,f.jsx)(e,{variant:`outlined`,onClick:r,children:`Open`}),(0,f.jsx)(`button`,{type:`button`,onClick:i,title:`Remove bookmark`,"aria-label":`Remove bookmark`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-active)] hover:text-[var(--content-default)]`,children:(0,f.jsx)(s,{className:`h-4 w-4`})})]})]})}function g(){let n=t(),{bookmarks:i,isLoading:s,isError:p,refetch:g}=u(),_=l();return s?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(`div`,{className:`flex min-h-[400px] items-center justify-center`,children:(0,f.jsx)(a,{className:`h-6 w-6 animate-spin text-[var(--content-disabled)]`})})}):p?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex min-h-[400px] flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,f.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--system-error-lighter)]`,children:(0,f.jsx)(o,{className:`h-6 w-6 text-[var(--system-error-default)]`})}),(0,f.jsx)(`h2`,{className:`mt-4 text-title-small text-[var(--content-default)]`,children:`Failed to load bookmarks`}),(0,f.jsx)(`p`,{className:`mt-1 text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Something went wrong. Please try again.`}),(0,f.jsxs)(e,{variant:`outlined`,onClick:g,className:`mt-4`,children:[(0,f.jsx)(d,{className:`h-4 w-4`}),`Retry`]})]})})}):i.length===0?(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(m,{})}):(0,f.jsx)(`div`,{className:`w-full`,children:(0,f.jsx)(r,{noPadding:!0,className:`px-4`,children:i.map((e,t)=>(0,f.jsx)(h,{bookmark:e,isFirst:t===0,onOpen:()=>{n(c.conversationAtMessage(e.conversationId,e.messageId))},onRemove:()=>{_(e.messageId,e.conversationId,!0)}},e.id))})})}export{g as BookmarksPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{O as n,t as r}from"./button-D7s2Q_uG.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import{t as o}from"./panel-item-nGTDevWP.js";import"./src-CK6bncSg.js";import{t as s}from"./loader-circle-IIzBGiwm.js";import{t as c}from"./x-KVxA2ZL0.js";import{n as l}from"./use-is-mobile-Cy10kl9u.js";import{Jr as u}from"./index-BIDC22lX.js";var d=e(t(),1),f=e(n(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:s=`overlay`}){let c=e;return s===`window`?(0,p.jsxs)(`button`,{type:`button`,role:`option`,"aria-current":i?`page`:void 0,"aria-selected":i,onClick:a,className:[`flex h-10 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none transition-colors`,i?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`].join(` `),children:[c?(0,p.jsx)(c,{size:16,"aria-hidden":!0,className:i?`shrink-0 text-[var(--content-default)]`:`shrink-0 text-[var(--content-tertiary)]`}):null,(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-xs text-[var(--content-tertiary)]`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[var(--content-tertiary)]`,children:r}):null]})]}):(0,p.jsx)(o,{icon:e,label:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-[var(--content-tertiary)] text-body-small-default`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-[var(--content-tertiary)] text-body-small-default`,children:r}):null]}),active:i,onSelect:a,className:`px-3 py-2`})}var h=({isOpen:e,onClose:t,query:n,onQueryChange:i,selectedIndex:o,sections:h,isSearching:g=!1,onItemSelect:_,onKeyDown:v,surface:y=`overlay`})=>{let b=l(),x=(0,d.useRef)(null),S=(0,d.useRef)(null),C=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{S.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,d.useEffect)(()=>{if(!e||!C.current)return;let t=C.current.querySelector(`[aria-current='page']`);t&&t.scrollIntoView({block:`nearest`})},[e,o]);let w=(0,d.useCallback)(e=>{e.target===x.current&&t()},[t]);if(!e)return null;let T=0,E=y===`window`,D=b&&!E,O=(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-base)] px-4 py-3`,children:[g?(0,p.jsx)(s,{size:16,"aria-hidden":!0,className:`shrink-0 animate-spin text-[var(--content-tertiary)]`}):(0,p.jsx)(u,{size:16,"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)]`}),(0,p.jsx)(`input`,{ref:S,type:`text`,value:n,onChange:e=>i(e.target.value),placeholder:`Search conversations, memories…`,className:E?`min-w-0 flex-1 bg-transparent text-sm font-medium text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`:`min-w-0 flex-1 bg-transparent text-body-medium-lighter text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`,"aria-label":`Search`}),n?D?(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 text-body-medium-lighter text-[var(--content-tertiary)]`,onClick:()=>i(``),"aria-label":`Clear search`,children:`Clear`}):E?(0,p.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`,"aria-label":`Clear search`,onClick:()=>i(``),children:(0,p.jsx)(c,{size:16,"aria-hidden":!0})}):(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),"aria-label":`Clear search`,onClick:()=>i(``),tintColor:`var(--content-tertiary)`}):D?null:(0,p.jsx)(`kbd`,{className:E?`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-xs font-medium text-[var(--content-secondary)]`:`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-label-small-default text-[var(--content-tertiary)]`,children:`⌘K`}),D?(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),expandOnMobile:!1,"aria-label":`Close search`,onClick:t,tintColor:`var(--content-tertiary)`}):null]}),k=(0,p.jsx)(`div`,{ref:C,className:D?`flex-1 overflow-y-auto overscroll-contain p-2`:`max-h-[360px] overflow-y-auto overscroll-contain p-2`,role:`listbox`,children:h.length===0?(0,p.jsx)(`div`,{className:`px-3 py-6 text-center`,children:(0,p.jsx)(a,{variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,children:g?`Searching…`:`No results`})}):h.map(e=>(0,p.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,p.jsx)(a,{variant:`label-small-default`,as:`div`,className:E?`px-3 pb-1 pt-2 text-xs font-semibold text-[var(--content-tertiary)]`:`px-3 pb-1 pt-2 text-[var(--content-tertiary)]`,children:e.label}),e.items.map(e=>{let t=T++;return(0,p.jsx)(m,{icon:e.icon,title:e.title,subtitle:e.subtitle,shortcutHint:D?void 0:e.shortcutHint,isSelected:t===o,onClick:()=>_?.(e,t),surface:y},e.id)})]},e.id))});if(D)return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-[var(--surface-lift)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,onKeyDown:v,style:{paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`,paddingBottom:`var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))`,paddingLeft:`var(--safe-area-inset-left, env(safe-area-inset-left, 0px))`,paddingRight:`var(--safe-area-inset-right, env(safe-area-inset-right, 0px))`},children:[O,k]});let A=(0,p.jsx)(`div`,{ref:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:y===`window`?`flex h-full w-full items-start justify-center bg-transparent p-3`:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-[15vh]`,onClick:w,onKeyDown:v,children:(0,p.jsxs)(`div`,{className:`flex w-full max-w-[560px] flex-col overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)] shadow-xl`,children:[O,k]})});return y===`window`?A:(0,f.createPortal)(A,document.body)};export{h as CommandPalette};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{O as n,t as r}from"./button-D7s2Q_uG.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{t as a}from"./typography-BscuIPxA.js";import{t as o}from"./panel-item-nGTDevWP.js";import"./src-CK6bncSg.js";import{t as s}from"./loader-circle-IIzBGiwm.js";import{t as c}from"./x-KVxA2ZL0.js";import{n as l}from"./use-is-mobile-Cy10kl9u.js";import{Jr as u}from"./index-PRnvH2Y1.js";var d=e(t(),1),f=e(n(),1),p=i();function m({icon:e,title:t,subtitle:n,shortcutHint:r,isSelected:i,onClick:a,surface:s=`overlay`}){let c=e;return s===`window`?(0,p.jsxs)(`button`,{type:`button`,role:`option`,"aria-current":i?`page`:void 0,"aria-selected":i,onClick:a,className:[`flex h-10 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium outline-none transition-colors`,i?`bg-[var(--surface-active)] text-[var(--content-default)]`:`text-[var(--content-secondary)] hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`].join(` `),children:[c?(0,p.jsx)(c,{size:16,"aria-hidden":!0,className:i?`shrink-0 text-[var(--content-default)]`:`shrink-0 text-[var(--content-tertiary)]`}):null,(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-xs text-[var(--content-tertiary)]`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-[var(--content-tertiary)]`,children:r}):null]})]}):(0,p.jsx)(o,{icon:e,label:(0,p.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:t}),n?(0,p.jsx)(`span`,{className:`shrink-0 truncate text-[var(--content-tertiary)] text-body-small-default`,children:n}):null,r?(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-[var(--content-tertiary)] text-body-small-default`,children:r}):null]}),active:i,onSelect:a,className:`px-3 py-2`})}var h=({isOpen:e,onClose:t,query:n,onQueryChange:i,selectedIndex:o,sections:h,isSearching:g=!1,onItemSelect:_,onKeyDown:v,surface:y=`overlay`})=>{let b=l(),x=(0,d.useRef)(null),S=(0,d.useRef)(null),C=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{S.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,d.useEffect)(()=>{if(!e||!C.current)return;let t=C.current.querySelector(`[aria-current='page']`);t&&t.scrollIntoView({block:`nearest`})},[e,o]);let w=(0,d.useCallback)(e=>{e.target===x.current&&t()},[t]);if(!e)return null;let T=0,E=y===`window`,D=b&&!E,O=(0,p.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-base)] px-4 py-3`,children:[g?(0,p.jsx)(s,{size:16,"aria-hidden":!0,className:`shrink-0 animate-spin text-[var(--content-tertiary)]`}):(0,p.jsx)(u,{size:16,"aria-hidden":!0,className:`shrink-0 text-[var(--content-tertiary)]`}),(0,p.jsx)(`input`,{ref:S,type:`text`,value:n,onChange:e=>i(e.target.value),placeholder:`Search conversations, memories…`,className:E?`min-w-0 flex-1 bg-transparent text-sm font-medium text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`:`min-w-0 flex-1 bg-transparent text-body-medium-lighter text-[var(--content-default)] placeholder:text-[var(--content-tertiary)] outline-none`,"aria-label":`Search`}),n?D?(0,p.jsx)(`button`,{type:`button`,className:`shrink-0 text-body-medium-lighter text-[var(--content-tertiary)]`,onClick:()=>i(``),"aria-label":`Clear search`,children:`Clear`}):E?(0,p.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--content-tertiary)] transition-colors hover:bg-[var(--surface-overlay)] hover:text-[var(--content-default)]`,"aria-label":`Clear search`,onClick:()=>i(``),children:(0,p.jsx)(c,{size:16,"aria-hidden":!0})}):(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),"aria-label":`Clear search`,onClick:()=>i(``),tintColor:`var(--content-tertiary)`}):D?null:(0,p.jsx)(`kbd`,{className:E?`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-xs font-medium text-[var(--content-secondary)]`:`shrink-0 rounded-md border border-[var(--border-base)] bg-[var(--surface-active)] px-1.5 py-0.5 text-label-small-default text-[var(--content-tertiary)]`,children:`⌘K`}),D?(0,p.jsx)(r,{variant:`ghost`,size:`compact`,iconOnly:(0,p.jsx)(c,{}),expandOnMobile:!1,"aria-label":`Close search`,onClick:t,tintColor:`var(--content-tertiary)`}):null]}),k=(0,p.jsx)(`div`,{ref:C,className:D?`flex-1 overflow-y-auto overscroll-contain p-2`:`max-h-[360px] overflow-y-auto overscroll-contain p-2`,role:`listbox`,children:h.length===0?(0,p.jsx)(`div`,{className:`px-3 py-6 text-center`,children:(0,p.jsx)(a,{variant:`body-medium-lighter`,className:`text-[var(--content-tertiary)]`,children:g?`Searching…`:`No results`})}):h.map(e=>(0,p.jsxs)(`div`,{role:`group`,"aria-label":e.label,children:[(0,p.jsx)(a,{variant:`label-small-default`,as:`div`,className:E?`px-3 pb-1 pt-2 text-xs font-semibold text-[var(--content-tertiary)]`:`px-3 pb-1 pt-2 text-[var(--content-tertiary)]`,children:e.label}),e.items.map(e=>{let t=T++;return(0,p.jsx)(m,{icon:e.icon,title:e.title,subtitle:e.subtitle,shortcutHint:D?void 0:e.shortcutHint,isSelected:t===o,onClick:()=>_?.(e,t),surface:y},e.id)})]},e.id))});if(D)return(0,p.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-[var(--surface-lift)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Search`,onKeyDown:v,style:{paddingTop:`var(--safe-area-inset-top, env(safe-area-inset-top, 0px))`,paddingBottom:`var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))`,paddingLeft:`var(--safe-area-inset-left, env(safe-area-inset-left, 0px))`,paddingRight:`var(--safe-area-inset-right, env(safe-area-inset-right, 0px))`},children:[O,k]});let A=(0,p.jsx)(`div`,{ref:x,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:y===`window`?`flex h-full w-full items-start justify-center bg-transparent p-3`:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-[15vh]`,onClick:w,onKeyDown:v,children:(0,p.jsxs)(`div`,{className:`flex w-full max-w-[560px] flex-col overflow-hidden rounded-xl border border-[var(--border-base)] bg-[var(--surface-base)] shadow-xl`,children:[O,k]})});return y===`window`?A:(0,f.createPortal)(A,document.body)};export{h as CommandPalette};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{at as r}from"./local-mode-CvrNMtPF.js";import{n as i}from"./resolved-assistants-store-Cp4J43BK.js";import{V as a,X as o,i as s,n as c,o as l}from"./auth-store-Kfxhs2oI.js";import{t as u}from"./client-feature-flag-store-C1kdd1EO.js";import{Gn as d,Gt as f,Jt as p,On as m,Pt as h,Wt as g,zn as _}from"./index-BIDC22lX.js";import{CommandPalette as v}from"./command-palette-AdQxXi8M.js";var y=e(t(),1),b=n(),x=()=>void 0,S=e=>void 0,C=e=>{switch(e.id){case`action-new-conversation`:return{kind:`newConversation`};case`action-current-conversation`:return{kind:`currentConversation`};case`action-settings`:return{kind:`openSettings`};case`action-library`:return{kind:`openLibrary`};case`action-intelligence`:return{kind:`openIdentity`};case`action-back`:return{kind:`navigateBack`};case`action-forward`:return{kind:`navigateForward`};case`action-zoom-in`:return{kind:`zoomIn`};case`action-zoom-out`:return{kind:`zoomOut`};case`action-actual-size`:return{kind:`actualSize`};default:return e.id.startsWith(`conv-`)?{kind:`openConversation`,conversationId:e.id.slice(5)}:e.id.startsWith(`search-conv-`)?{kind:`openConversation`,conversationId:e.id.slice(12)}:e.id.startsWith(`search-schedule-`)||e.id.startsWith(`search-contact-`)?{kind:`openIdentity`}:null}};function w(){let e=c.use.sessionStatus(),t=l(),n=s();d(),m(!t),_({sessionStatus:e,hasPlatformSession:n});let w=i.use.assistants(),T=i.use.activeAssistantId(),E=i.use.selectedAssistantId(),D=a.use.currentOrganizationId(),O=u.use.multiPlatformAssistant(),k=(0,y.useMemo)(()=>{let e=O&&!r()&&D?o(D):T;if(!e)return null;let t=w.find(t=>t.id===e);return t?{id:t.id,name:t.name}:null},[O,T,w,D,E]),A=k?.id??null,{conversations:j}=p(A,!0),M=(0,y.useCallback)(e=>{let t=C(e);t&&f(t)},[]),{commandPalette:N,mergedSections:P,handleItemSelect:F}=h({assistantId:A,assistantName:k?.name,conversations:j,activeConversationId:void 0,startNewConversation:x,switchConversation:x,navigate:S,navigateToSettings:x,isOpen:!0,onClose:()=>{g()},onItemSelect:M});return(0,b.jsx)(`div`,{className:`h-screen w-screen bg-transparent`,children:(0,b.jsx)(v,{isOpen:!0,surface:`window`,onClose:N.close,query:N.query,onQueryChange:N.setQuery,selectedIndex:N.selectedIndex,sections:P,isSearching:N.isSearching,onItemSelect:F,onKeyDown:N.handleKeyDown})})}export{w as CommandPaletteWindowPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./jsx-runtime-CVSDxk6A.js";import{at as r}from"./local-mode-CvrNMtPF.js";import{n as i}from"./resolved-assistants-store-Cp4J43BK.js";import{V as a,X as o,i as s,n as c,o as l}from"./auth-store-Kfxhs2oI.js";import{t as u}from"./client-feature-flag-store-C1kdd1EO.js";import{Gn as d,Gt as f,Jt as p,On as m,Pt as h,Wt as g,zn as _}from"./index-PRnvH2Y1.js";import{CommandPalette as v}from"./command-palette-GZu_zgQg.js";var y=e(t(),1),b=n(),x=()=>void 0,S=e=>void 0,C=e=>{switch(e.id){case`action-new-conversation`:return{kind:`newConversation`};case`action-current-conversation`:return{kind:`currentConversation`};case`action-settings`:return{kind:`openSettings`};case`action-library`:return{kind:`openLibrary`};case`action-intelligence`:return{kind:`openIdentity`};case`action-back`:return{kind:`navigateBack`};case`action-forward`:return{kind:`navigateForward`};case`action-zoom-in`:return{kind:`zoomIn`};case`action-zoom-out`:return{kind:`zoomOut`};case`action-actual-size`:return{kind:`actualSize`};default:return e.id.startsWith(`conv-`)?{kind:`openConversation`,conversationId:e.id.slice(5)}:e.id.startsWith(`search-conv-`)?{kind:`openConversation`,conversationId:e.id.slice(12)}:e.id.startsWith(`search-schedule-`)||e.id.startsWith(`search-contact-`)?{kind:`openIdentity`}:null}};function w(){let e=c.use.sessionStatus(),t=l(),n=s();d(),m(!t),_({sessionStatus:e,hasPlatformSession:n});let w=i.use.assistants(),T=i.use.activeAssistantId(),E=i.use.selectedAssistantId(),D=a.use.currentOrganizationId(),O=u.use.multiPlatformAssistant(),k=(0,y.useMemo)(()=>{let e=O&&!r()&&D?o(D):T;if(!e)return null;let t=w.find(t=>t.id===e);return t?{id:t.id,name:t.name}:null},[O,T,w,D,E]),A=k?.id??null,{conversations:j}=p(A,!0),M=(0,y.useCallback)(e=>{let t=C(e);t&&f(t)},[]),{commandPalette:N,mergedSections:P,handleItemSelect:F}=h({assistantId:A,assistantName:k?.name,conversations:j,activeConversationId:void 0,startNewConversation:x,switchConversation:x,navigate:S,navigateToSettings:x,isOpen:!0,onClose:()=>{g()},onItemSelect:M});return(0,b.jsx)(`div`,{className:`h-screen w-screen bg-transparent`,children:(0,b.jsx)(v,{isOpen:!0,surface:`window`,onClose:N.close,query:N.query,onQueryChange:N.setQuery,selectedIndex:N.selectedIndex,sections:P,isSearching:N.isSearching,onItemSelect:F,onKeyDown:N.handleKeyDown})})}export{w as CommandPaletteWindowPage};
@@ -1 +1 @@
1
- import{t as e}from"./button-D7s2Q_uG.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-BibIM9x3.js";import{t as r}from"./tag-B_-QAvJF.js";import{t as i}from"./createLucideIcon-BlMXrA59.js";import{t as a}from"./bug-DDcuQ3au.js";import{t as o}from"./external-link-DPAtkBJ2.js";import{t as s}from"./globe-DYF_lSGm.js";import{t as c}from"./sparkles-BICoewVE.js";import{Nr as l,a as u,i as d,n as f,na as p,ni as m,o as h,ot as g,wi as _,zr as v}from"./index-BIDC22lX.js";var y=i(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),b=t();function x({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function S({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})})}function C({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814ZM9.545 15.568V8.432L15.818 12l-6.273 3.568Z`})})}function w(){return(0,b.jsx)(n,{padding:`lg`,className:`bg-[var(--surface-lift)]`,children:(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`pointer-events-none absolute -right-16 -top-16 h-64 w-64 rounded-full opacity-30 blur-3xl`,style:{background:`radial-gradient(circle, var(--system-mid-weak) 0%, transparent 70%)`},"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`relative flex flex-col items-start gap-3`,children:[(0,b.jsxs)(r,{tone:`neutral`,children:[(0,b.jsx)(m,{className:`h-3.5 w-3.5`}),`Community`]}),(0,b.jsx)(`h1`,{className:`text-[28px] font-semibold leading-tight tracking-tight text-[var(--content-emphasised)]`,children:`Build with us, in the open.`}),(0,b.jsx)(`p`,{className:`max-w-xl text-body-medium-default text-[color:var(--content-tertiary)]`,children:`Vellum is built in the open with a growing community of developers, designers, and tinkerers. Here's how to get involved.`})]})]})})}function T({icon:e,text:t}){return(0,b.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,children:(0,b.jsx)(e,{size:14,className:`text-[var(--content-secondary)]`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]})}function E({accentColor:t,iconColor:r=`var(--aux-white)`,label:i,icon:a,title:o,subtitle:s,benefits:c,primaryAction:l,secondaryAction:u}){return(0,b.jsx)(n,{padding:`lg`,className:`flex-1`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:a}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:i})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:o}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:s})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:c.map(({icon:e,text:t})=>(0,b.jsx)(T,{icon:e,text:t},t))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(e,{onClick:l.onClick,children:[l.icon,l.label]}),u&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(u.href,`_blank`,`noopener,noreferrer`),children:[u.label,(0,b.jsx)(p,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:a,href:s}){return(0,b.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`flex flex-1 cursor-pointer`,children:(0,b.jsx)(n,{className:`flex-1 transition-shadow hover:shadow-md`,padding:`lg`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:e}),(0,b.jsx)(o,{size:14,className:`text-[var(--content-tertiary)]`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`span`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:i}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:a})]})]})})})}function O(){let{handleStar:e}=h();return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(w,{}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,b.jsx)(E,{accentColor:`var(--content-emphasised)`,iconColor:`var(--surface-base)`,label:`Open Source`,icon:(0,b.jsx)(x,{size:20}),title:`Vellum is open source`,subtitle:`Read the source, star the repo, and contribute fixes and features on GitHub.`,benefits:[{icon:v,text:`Star the repo to follow updates`},{icon:a,text:`Open issues and report bugs`},{icon:y,text:`Contribute fixes and new features`}],primaryAction:{label:`Star on GitHub`,icon:(0,b.jsx)(v,{size:16}),onClick:e},secondaryAction:{label:`View source`,href:u}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(g,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:_,text:`Talk directly with the team`},{icon:c,text:`Share feedback and request features`},{icon:l,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(g,{size:16,style:{color:`currentColor`}}),onClick:d}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:`More from Vellum`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,b.jsx)(D,{icon:(0,b.jsx)(s,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:f}),(0,b.jsx)(D,{icon:(0,b.jsx)(S,{size:20}),iconBg:`var(--content-default)`,iconColor:`var(--surface-base)`,title:`Follow on X`,description:`Product updates, releases, and behind-the-scenes.`,href:`https://x.com/vellum_ai`}),(0,b.jsx)(D,{icon:(0,b.jsx)(C,{size:20}),iconBg:`#ef4444`,title:`YouTube channel`,description:`Walkthroughs, tutorials, and product deep-dives.`,href:`https://www.youtube.com/@Vellum_AI`})]})]})]})}export{O as CommunityPage};
1
+ import{t as e}from"./button-D7s2Q_uG.js";import{t}from"./jsx-runtime-CVSDxk6A.js";import{t as n}from"./card-BibIM9x3.js";import{t as r}from"./tag-B_-QAvJF.js";import{t as i}from"./createLucideIcon-BlMXrA59.js";import{t as a}from"./bug-DDcuQ3au.js";import{t as o}from"./external-link-DPAtkBJ2.js";import{t as s}from"./globe-DYF_lSGm.js";import{t as c}from"./sparkles-BICoewVE.js";import{Nr as l,a as u,i as d,n as f,na as p,ni as m,o as h,ot as g,wi as _,zr as v}from"./index-PRnvH2Y1.js";var y=i(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),b=t();function x({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function S({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})})}function C({size:e=24,className:t,style:n}){return(0,b.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:e,height:e,fill:`currentColor`,className:t,style:n,"aria-hidden":!0,children:(0,b.jsx)(`path`,{d:`M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814ZM9.545 15.568V8.432L15.818 12l-6.273 3.568Z`})})}function w(){return(0,b.jsx)(n,{padding:`lg`,className:`bg-[var(--surface-lift)]`,children:(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`pointer-events-none absolute -right-16 -top-16 h-64 w-64 rounded-full opacity-30 blur-3xl`,style:{background:`radial-gradient(circle, var(--system-mid-weak) 0%, transparent 70%)`},"aria-hidden":!0}),(0,b.jsxs)(`div`,{className:`relative flex flex-col items-start gap-3`,children:[(0,b.jsxs)(r,{tone:`neutral`,children:[(0,b.jsx)(m,{className:`h-3.5 w-3.5`}),`Community`]}),(0,b.jsx)(`h1`,{className:`text-[28px] font-semibold leading-tight tracking-tight text-[var(--content-emphasised)]`,children:`Build with us, in the open.`}),(0,b.jsx)(`p`,{className:`max-w-xl text-body-medium-default text-[color:var(--content-tertiary)]`,children:`Vellum is built in the open with a growing community of developers, designers, and tinkerers. Here's how to get involved.`})]})]})})}function T({icon:e,text:t}){return(0,b.jsxs)(`li`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-base)]`,children:(0,b.jsx)(e,{size:14,className:`text-[var(--content-secondary)]`,"aria-hidden":!0})}),(0,b.jsx)(`span`,{className:`text-body-medium-lighter text-[color:var(--content-secondary)]`,children:t})]})}function E({accentColor:t,iconColor:r=`var(--aux-white)`,label:i,icon:a,title:o,subtitle:s,benefits:c,primaryAction:l,secondaryAction:u}){return(0,b.jsx)(n,{padding:`lg`,className:`flex-1`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:a}),(0,b.jsx)(`span`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:i})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`h2`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:o}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:s})]}),(0,b.jsx)(`ul`,{className:`flex flex-col gap-3`,children:c.map(({icon:e,text:t})=>(0,b.jsx)(T,{icon:e,text:t},t))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(e,{onClick:l.onClick,children:[l.icon,l.label]}),u&&(0,b.jsxs)(e,{variant:`ghost`,onClick:()=>window.open(u.href,`_blank`,`noopener,noreferrer`),children:[u.label,(0,b.jsx)(p,{className:`h-3.5 w-3.5`})]})]})]})})}function D({icon:e,iconBg:t,iconColor:r=`white`,title:i,description:a,href:s}){return(0,b.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`flex flex-1 cursor-pointer`,children:(0,b.jsx)(n,{className:`flex-1 transition-shadow hover:shadow-md`,padding:`lg`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg`,style:{backgroundColor:t,color:r},children:e}),(0,b.jsx)(o,{size:14,className:`text-[var(--content-tertiary)]`,"aria-hidden":!0})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsx)(`span`,{className:`text-title-medium text-[var(--content-emphasised)]`,children:i}),(0,b.jsx)(`p`,{className:`text-body-medium-lighter text-[color:var(--content-tertiary)]`,children:a})]})]})})})}function O(){let{handleStar:e}=h();return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(w,{}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,b.jsx)(E,{accentColor:`var(--content-emphasised)`,iconColor:`var(--surface-base)`,label:`Open Source`,icon:(0,b.jsx)(x,{size:20}),title:`Vellum is open source`,subtitle:`Read the source, star the repo, and contribute fixes and features on GitHub.`,benefits:[{icon:v,text:`Star the repo to follow updates`},{icon:a,text:`Open issues and report bugs`},{icon:y,text:`Contribute fixes and new features`}],primaryAction:{label:`Star on GitHub`,icon:(0,b.jsx)(v,{size:16}),onClick:e},secondaryAction:{label:`View source`,href:u}}),(0,b.jsx)(E,{accentColor:`#5865F2`,label:`Discord`,icon:(0,b.jsx)(g,{size:20}),title:`Join our community`,subtitle:`Talk to the team, share feedback, request features, and get answers faster.`,benefits:[{icon:_,text:`Talk directly with the team`},{icon:c,text:`Share feedback and request features`},{icon:l,text:`Get answers faster from the community`}],primaryAction:{label:`Join Discord`,icon:(0,b.jsx)(g,{size:16,style:{color:`currentColor`}}),onClick:d}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,b.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wider text-[color:var(--content-tertiary)]`,children:`More from Vellum`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,b.jsx)(D,{icon:(0,b.jsx)(s,{size:20}),iconBg:`#22c55e`,title:`Community Hub`,description:`Showcases, guides, and projects shared by the community.`,href:f}),(0,b.jsx)(D,{icon:(0,b.jsx)(S,{size:20}),iconBg:`var(--content-default)`,iconColor:`var(--surface-base)`,title:`Follow on X`,description:`Product updates, releases, and behind-the-scenes.`,href:`https://x.com/vellum_ai`}),(0,b.jsx)(D,{icon:(0,b.jsx)(C,{size:20}),iconBg:`#ef4444`,title:`YouTube channel`,description:`Walkthroughs, tutorials, and product deep-dives.`,href:`https://www.youtube.com/@Vellum_AI`})]})]})]})}export{O as CommunityPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{d as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-BscuIPxA.js";import{t as l}from"./card-BibIM9x3.js";import{t as u}from"./dropdown-CL8VmqrY.js";import{t as d}from"./panel-item-nGTDevWP.js";import{c as f,s as p}from"./src-CK6bncSg.js";import{t as m}from"./confirm-dialog-CfOXCE1N.js";import{t as h}from"./tag-B_-QAvJF.js";import{t as g}from"./input-C8kfrq9r.js";import{t as _}from"./modal-D0Q3UWD0.js";import{n as v}from"./toast-2TW5tj1Y.js";import{t as y}from"./createLucideIcon-BlMXrA59.js";import{t as b}from"./arrow-left-CP-EhDNF.js";import{t as x}from"./check-D6WkI0gF.js";import{t as S}from"./chevron-right-B6vEpVY0.js";import{t as C}from"./link-2-CaszbD7P.js";import{t as w}from"./loader-circle-IIzBGiwm.js";import{t as T}from"./pencil-DbB9rxpY.js";import{t as E}from"./user-plus-C0OyQU83.js";import{Bt as D,Ht as O,It as ee,Ut as k,Vt as te,x as ne,zt as re}from"./sdk.gen-1aYqVbMj.js";import{B as ie,H as ae,Mt as oe,U as se,V as ce,_ as le,a as ue,jt as de,o as fe,s as pe,v as me,y as A}from"./react-query.gen-CQLyoqYk.js";import{n as j,r as M,t as N}from"./api-errors-CveHbhgb.js";import{t as P}from"./client.gen-Cs6pCK0s.js";import{a as he}from"./routes-DVqkwUEe.js";import{t as ge}from"./assistant-identity-store-CKjnoLSp.js";import{n as _e}from"./viewer-store-Dead64xY.js";import{t as ve}from"./conversation-store-DK-7gFAt.js";import{t as ye}from"./assistant-feature-flag-store-Dl92XRsM.js";import{t as be}from"./conversation-selection-CtKjA5Ni.js";import{$i as xe,Jr as F,Li as I,Ti as L,Zi as R,ai as z,li as B,pi as V,qr as H,ta as U,ti as Se}from"./index-BIDC22lX.js";import{t as W}from"./use-active-assistant-id-C-RHQ9f6.js";import{n as Ce,t as we}from"./mobile-sidebar-drawer-wA5GnkLS.js";import{t as G}from"./detail-card-BIwpXT5F.js";import{a as Te,i as Ee,r as De,t as Oe}from"./contacts-gateway-dxw1KMN2.js";import{t as K}from"./mutation-error-CsyN8rYH.js";var ke=y(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ae=y(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),q=y(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),J=e(t(),1),Y=s();function X({role:e,contactType:t}){let{label:n,tone:r}=je(e,t);return(0,Y.jsx)(h,{tone:r,children:n})}function je(e,t){switch(e){case`guardian`:return{label:`Guardian`,tone:`positive`};case`assistant`:return{label:`Assistant`,tone:`negative`};default:return t===`assistant`?{label:`Assistant`,tone:`negative`}:{label:`Human`,tone:`warning`}}}function Me({onClick:e}){return(0,Y.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`}),onClick:e,children:`Share Connection Link`})}var Ne=[`no_one`,`guardian_only`,`trusted_contacts`,`any_contact`,`strangers`],Pe=new Set([`platform`,`a2a`]),Fe=new Set([`vellum`,`whatsapp`]);function Ie(e){return Fe.has(e)}var Le={no_one:`No one`,guardian_only:`Only you`,trusted_contacts:`Verified contacts`,any_contact:`Any contact`,strangers:`Strangers`},Re={no_one:`Hard-deny every inbound message on this channel.`,guardian_only:`Only messages sent by you are admitted.`,trusted_contacts:`Admit verified contacts and the guardian; deny everyone else.`,any_contact:`Admit any matched contact (verified or pending) and the guardian.`,strangers:`Admit everyone, including unrecognised senders.`},ze=Ne.map(e=>({value:e,label:Le[e],tooltip:Re[e]})),Be={no_one:{title:`Block all messages?`,message:`Setting this channel to “No one” hard-denies every inbound message — including messages from you.
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-D7s2Q_uG.js";import{d as r}from"./chunk-5KNZJZUH-DdS6bb-3.js";import{n as i}from"./QueryClientProvider-DKhXIxGb.js";import{t as a}from"./useQuery-B45lW1Kk.js";import{t as o}from"./useMutation-Lj4VunQV.js";import{t as s}from"./jsx-runtime-CVSDxk6A.js";import{t as c}from"./typography-BscuIPxA.js";import{t as l}from"./card-BibIM9x3.js";import{t as u}from"./dropdown-CL8VmqrY.js";import{t as d}from"./panel-item-nGTDevWP.js";import{c as f,s as p}from"./src-CK6bncSg.js";import{t as m}from"./confirm-dialog-CfOXCE1N.js";import{t as h}from"./tag-B_-QAvJF.js";import{t as g}from"./input-C8kfrq9r.js";import{t as _}from"./modal-D0Q3UWD0.js";import{n as v}from"./toast-2TW5tj1Y.js";import{t as y}from"./createLucideIcon-BlMXrA59.js";import{t as b}from"./arrow-left-CP-EhDNF.js";import{t as x}from"./check-D6WkI0gF.js";import{t as S}from"./chevron-right-B6vEpVY0.js";import{t as C}from"./link-2-CaszbD7P.js";import{t as w}from"./loader-circle-IIzBGiwm.js";import{t as T}from"./pencil-DbB9rxpY.js";import{t as E}from"./user-plus-C0OyQU83.js";import{Bt as D,Ht as O,It as ee,Ut as k,Vt as te,x as ne,zt as re}from"./sdk.gen-1aYqVbMj.js";import{B as ie,H as ae,Mt as oe,U as se,V as ce,_ as le,a as ue,jt as de,o as fe,s as pe,v as me,y as A}from"./react-query.gen-CQLyoqYk.js";import{n as j,r as M,t as N}from"./api-errors-CveHbhgb.js";import{t as P}from"./client.gen-Cs6pCK0s.js";import{a as he}from"./routes-DVqkwUEe.js";import{t as ge}from"./assistant-identity-store-CKjnoLSp.js";import{n as _e}from"./viewer-store-Dead64xY.js";import{t as ve}from"./conversation-store-DK-7gFAt.js";import{t as ye}from"./assistant-feature-flag-store-Dl92XRsM.js";import{t as be}from"./conversation-selection-CtKjA5Ni.js";import{$i as xe,Jr as F,Li as I,Ti as L,Zi as R,ai as z,li as B,pi as V,qr as H,ta as U,ti as Se}from"./index-PRnvH2Y1.js";import{t as W}from"./use-active-assistant-id-C-RHQ9f6.js";import{n as Ce,t as we}from"./mobile-sidebar-drawer-DqXFL0Ke.js";import{t as G}from"./detail-card-BIwpXT5F.js";import{a as Te,i as Ee,r as De,t as Oe}from"./contacts-gateway-dxw1KMN2.js";import{t as K}from"./mutation-error-CsyN8rYH.js";var ke=y(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ae=y(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),q=y(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),J=e(t(),1),Y=s();function X({role:e,contactType:t}){let{label:n,tone:r}=je(e,t);return(0,Y.jsx)(h,{tone:r,children:n})}function je(e,t){switch(e){case`guardian`:return{label:`Guardian`,tone:`positive`};case`assistant`:return{label:`Assistant`,tone:`negative`};default:return t===`assistant`?{label:`Assistant`,tone:`negative`}:{label:`Human`,tone:`warning`}}}function Me({onClick:e}){return(0,Y.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:(0,Y.jsx)(C,{className:`h-3.5 w-3.5`}),onClick:e,children:`Share Connection Link`})}var Ne=[`no_one`,`guardian_only`,`trusted_contacts`,`any_contact`,`strangers`],Pe=new Set([`platform`,`a2a`]),Fe=new Set([`vellum`,`whatsapp`]);function Ie(e){return Fe.has(e)}var Le={no_one:`No one`,guardian_only:`Only you`,trusted_contacts:`Verified contacts`,any_contact:`Any contact`,strangers:`Strangers`},Re={no_one:`Hard-deny every inbound message on this channel.`,guardian_only:`Only messages sent by you are admitted.`,trusted_contacts:`Admit verified contacts and the guardian; deny everyone else.`,any_contact:`Admit any matched contact (verified or pending) and the guardian.`,strangers:`Admit everyone, including unrecognised senders.`},ze=Ne.map(e=>({value:e,label:Le[e],tooltip:Re[e]})),Be={no_one:{title:`Block all messages?`,message:`Setting this channel to “No one” hard-denies every inbound message — including messages from you.
2
2
 
3
3
  You can reverse this at any time.`,confirmLabel:`Block all`,destructive:!0},any_contact:{title:`Allow any contact?`,message:`“Any contact” admits every matched contact in this channel — including pending, unverified ones — not just your verified contacts.
4
4