@engenty/wizards-runtime 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +25 -6
  2. package/apps/runtime/dist/app.js +5 -0
  3. package/apps/runtime/dist/authoring/guide.js +19 -19
  4. package/apps/runtime/dist/docs/dev/index.md +1 -0
  5. package/apps/runtime/dist/docs/dev/licensing.md +60 -0
  6. package/apps/runtime/dist/docs/dev/meta.json +2 -1
  7. package/apps/runtime/dist/docs/dev/plugins/runners.md +2 -2
  8. package/apps/runtime/dist/docs/dev/wizard-format/index.md +4 -4
  9. package/apps/runtime/dist/docs/dev/wizard-format/meta.json +1 -1
  10. package/apps/runtime/dist/docs/dev/wizard-format/motion-graphics-steps.md +47 -0
  11. package/apps/runtime/dist/docs/dev/wizard-format/review-and-result.md +2 -2
  12. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +2 -2
  13. package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +4 -4
  14. package/apps/runtime/dist/docs/user-guide/space.md +5 -1
  15. package/apps/runtime/dist/docs/user-guide/steps.md +12 -12
  16. package/apps/runtime/dist/engine/requirements.js +7 -7
  17. package/apps/runtime/dist/engine/runner.js +8 -1
  18. package/apps/runtime/dist/engine/steps.js +3 -3
  19. package/apps/runtime/dist/files/storage.js +3 -3
  20. package/apps/runtime/dist/index.js +3 -0
  21. package/apps/runtime/dist/limits.js +16 -0
  22. package/apps/runtime/dist/manage.js +19 -0
  23. package/apps/runtime/dist/models.js +8 -8
  24. package/apps/runtime/dist/{film → motion-graphics}/project.js +54 -54
  25. package/apps/runtime/dist/{film → motion-graphics}/sounds.js +3 -3
  26. package/apps/runtime/dist/{film → motion-graphics}/step.js +37 -37
  27. package/apps/runtime/dist/{film → motion-graphics}/tools.js +1 -1
  28. package/apps/runtime/dist/render/downloads.js +2 -2
  29. package/apps/runtime/dist/render/guard.js +1 -1
  30. package/apps/runtime/dist/routes/delivery.js +1 -1
  31. package/apps/runtime/dist/routes/internal.js +1 -1
  32. package/apps/runtime/dist/routes/marketplace.js +4 -3
  33. package/apps/runtime/dist/routes/reports.js +80 -0
  34. package/apps/runtime/dist/routes/runs.js +25 -1
  35. package/apps/runtime/dist/services/brand.js +1 -1
  36. package/apps/runtime/dist/services/manage-reports.js +190 -0
  37. package/apps/runtime/dist/services/marketplace.js +33 -1
  38. package/apps/runtime/dist/services/pages.js +1 -1
  39. package/apps/runtime/dist/services/shipped-fonts.js +2 -1
  40. package/apps/runtime/dist/services/wizards.js +7 -0
  41. package/apps/runtime/dist/widgets/render.js +9 -9
  42. package/apps/runtime/dist/widgets/runtime.js +3 -3
  43. package/apps/runtime/dist/widgets/step.js +20 -20
  44. package/apps/web/dist/assets/AboutDialog-Bx6j5lZO.js +1 -0
  45. package/apps/web/dist/assets/ChangelogDialog-C620Sw_A.js +1 -0
  46. package/apps/web/dist/assets/CodeEditor-DifBNaqQ.js +2 -0
  47. package/apps/web/dist/assets/EditorPage-DWf9QG-U.js +3 -0
  48. package/apps/web/dist/assets/{FlowPreview-BV1NJ0rF.js → FlowPreview-ucwQ_dTr.js} +1 -1
  49. package/apps/web/dist/assets/{Harness-DYviBlHB.js → Harness-Br0Z_anI.js} +2 -2
  50. package/apps/web/dist/assets/Marketplace-CFDpVMWM.js +2 -0
  51. package/apps/web/dist/assets/NewWizardChannels-Cau6XSbl.js +1 -0
  52. package/apps/web/dist/assets/NewWizardPage-CrFqInHR.js +7 -0
  53. package/apps/web/dist/assets/OnboardingPage-BZk42_R7.js +1 -0
  54. package/apps/web/dist/assets/PreviewPane-D9n6tylf.js +10 -0
  55. package/apps/web/dist/assets/ProjectPage-CteRfxpz.js +1 -0
  56. package/apps/web/dist/assets/PublicRunner-CNanj6-w.js +1 -0
  57. package/apps/web/dist/assets/ReadOnly-DGBDtXFP.js +1 -0
  58. package/apps/web/dist/assets/SettingsPage-ClFQewEL.js +2 -0
  59. package/apps/web/dist/assets/SetupPage-k9gyFvow.js +1 -0
  60. package/apps/web/dist/assets/SharePage-BhWeqF3w.js +1 -0
  61. package/apps/web/dist/assets/changelog-BrhGlZT6.js +1 -0
  62. package/apps/web/dist/assets/{coins-DQ91VJAB.js → coins-CwURUZyt.js} +1 -1
  63. package/apps/web/dist/assets/dist-BwhPmMDu.js +1 -0
  64. package/apps/web/dist/assets/dist-DVpDdhG9.js +1 -0
  65. package/apps/web/dist/assets/dist-DzdNG7Sf.js +10 -0
  66. package/apps/web/dist/assets/i18n-DEmaSTJV.js +55 -0
  67. package/apps/web/dist/assets/index-ClNm5JaU.js +34 -0
  68. package/apps/web/dist/assets/index-DImS12WR.css +1 -0
  69. package/apps/web/dist/assets/json-D2GVvTXK.js +1 -0
  70. package/apps/web/dist/assets/markdown-DwdMW7q0.js +29 -0
  71. package/apps/web/dist/assets/{oss-credits-C2JUsf2d.js → oss-credits-C6bPkfSE.js} +1 -1
  72. package/apps/web/dist/assets/{phone-jIuRIwyg.js → phone-DTxGRwhK.js} +1 -1
  73. package/apps/web/dist/assets/runners-BMOIT6Ze.js +1 -0
  74. package/apps/web/dist/assets/session-xJpGiTU_.js +2 -0
  75. package/apps/web/dist/assets/{settings-menu-CoLUNJGQ.js → settings-menu-DcPFhgGA.js} +1 -1
  76. package/apps/web/dist/assets/theme-DTi1Zdw8.js +11 -0
  77. package/apps/web/dist/assets/ui-gsqxnFnT.js +83 -0
  78. package/apps/web/dist/assets/{upload-BcOvBWHS.js → upload-BkwjFS-0.js} +1 -1
  79. package/apps/web/dist/assets/{useMutation-CD7HmAxR.js → useMutation-BS-U9g_a.js} +1 -1
  80. package/apps/web/dist/assets/{volume-2-D2To9w5D.js → volume-2-CYOgux-z.js} +1 -1
  81. package/apps/web/dist/assets/{wrench-B98ubRvB.js → wrench-DIfUvYPN.js} +1 -1
  82. package/apps/web/dist/index.html +9 -8
  83. package/apps/web/dist/mcp/flow.html +32 -32
  84. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1 -1
  85. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +11 -11
  86. package/node_modules/@engenty/wizards-shared/dist/definition.js +24 -23
  87. package/node_modules/@engenty/wizards-shared/dist/engenty/data-tables/columns-value.js +1 -0
  88. package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +7 -2
  89. package/node_modules/@engenty/wizards-shared/dist/fit.js +23 -6
  90. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.d.ts +1 -1
  91. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.js +1 -1
  92. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -7
  93. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +7 -23
  94. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +15 -14
  95. package/node_modules/@engenty/wizards-shared/dist/run.js +30 -28
  96. package/node_modules/@engenty/wizards-shared/dist/runners.d.ts +1 -1
  97. package/node_modules/@engenty/wizards-shared/dist/runners.js +5 -5
  98. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +1 -1
  99. package/node_modules/@engenty/wizards-shared/dist/store.js +1 -2
  100. package/node_modules/@engenty/wizards-shared/dist/theme-look.d.ts +39 -0
  101. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +112 -0
  102. package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +0 -38
  103. package/node_modules/@engenty/wizards-shared/dist/theme.js +1 -108
  104. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +1 -0
  105. package/package.json +1 -1
  106. package/plugin/.claude-plugin/plugin.json +1 -1
  107. package/plugin/plugin.json +1 -1
  108. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +0 -47
  109. package/apps/web/dist/assets/AboutDialog-9VcgySrQ.js +0 -1
  110. package/apps/web/dist/assets/ChangelogDialog-BXvT2VMU.js +0 -1
  111. package/apps/web/dist/assets/EditorPage-Cvzd0nah.js +0 -4
  112. package/apps/web/dist/assets/Marketplace-DTSg7_U7.js +0 -2
  113. package/apps/web/dist/assets/NewWizardChannels-DiujJzOR.js +0 -1
  114. package/apps/web/dist/assets/NewWizardPage-CngUh9g-.js +0 -7
  115. package/apps/web/dist/assets/OnboardingPage-DFKJnWtw.js +0 -1
  116. package/apps/web/dist/assets/PreviewPane-C0E9OLzB.js +0 -9
  117. package/apps/web/dist/assets/ProjectPage-CYDX-JYc.js +0 -1
  118. package/apps/web/dist/assets/PublicRunner-CkRO_Pw-.js +0 -1
  119. package/apps/web/dist/assets/ReadOnly-E-h9y_QO.js +0 -1
  120. package/apps/web/dist/assets/SettingsPage-BMgP3aRV.js +0 -2
  121. package/apps/web/dist/assets/SetupPage-DBO_rzj7.js +0 -1
  122. package/apps/web/dist/assets/SharePage-BvvmYB5N.js +0 -1
  123. package/apps/web/dist/assets/changelog-zllICQ4q.js +0 -1
  124. package/apps/web/dist/assets/index-Bjn557f1.js +0 -20
  125. package/apps/web/dist/assets/index-DN0VMwsS.css +0 -1
  126. package/apps/web/dist/assets/runners-DloOxEbh.js +0 -1
  127. package/apps/web/dist/assets/session-BpsCkDv6.js +0 -2
  128. package/apps/web/dist/assets/theme-2XjIQXH3.js +0 -11
  129. package/apps/web/dist/assets/ui-BIWmkPh6.js +0 -137
  130. /package/apps/runtime/dist/{film → motion-graphics}/skills.js +0 -0
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,$t as i,A as a,Ar as o,B as s,Bt as c,C as l,D as u,E as d,Fr as f,G as p,Gr as m,Gt as h,H as g,Hr as _,Ht as v,I as y,Jt as b,L as x,Lr as S,M as C,Mr as w,N as T,Nr as E,O as D,Or as O,P as k,Qt as ee,R as A,Rt as j,S as M,T as N,U as P,Ut as F,V as I,Vt as L,W as R,Wt as z,Xt as te,Yr as B,Yt as V,Zn as H,Zr as U,Zt as W,_ as ne,ai as re,b as ie,br as G,d as ae,dr as K,en as q,f as oe,g as se,gr as ce,h as le,ii as ue,j as de,ji as J,jr as fe,k as pe,kr as me,m as he,mr as ge,ni as _e,nn as ve,oi as ye,p as be,pt as xe,qt as Se,ri as Ce,sn as Y,v as we,vr as Te,w as Ee,wr as De,x as Oe,xr as ke,y as X,z as Ae,zt as je}from"./ui-BIWmkPh6.js";import{S as Me,_ as Ne,g as Pe,m as Fe,p as Ie,v as Le}from"./Marketplace-DTSg7_U7.js";import{t as Re}from"./useMutation-CD7HmAxR.js";import{F as ze,I as Be,N as Ve,S as He,_ as Ue,a as We,b as Ge,c as Ke,d as qe,f as Je,g as Ye,h as Xe,i as Ze,l as Qe,m as $e,o as et,p as tt,r as nt,s as rt,t as it,u as at,v as ot,x as st,y as ct}from"./PreviewPane-C0E9OLzB.js";import{b as lt,f as ut}from"./theme-2XjIQXH3.js";import{d as dt,f as ft,g as pt,p as mt,x as ht}from"./session-BpsCkDv6.js";import{t as gt}from"./phone-jIuRIwyg.js";import{n as _t,r as vt,t as yt}from"./ReadOnly-E-h9y_QO.js";import{t as bt}from"./upload-BcOvBWHS.js";import{Bt as xt,Et as St,It as Ct,Mt as wt,Nt as Tt,St as Et,Tt as Dt,_t as Ot,c as kt,d as At,f as jt,h as Mt,jt as Nt,m as Pt,nt as Ft,p as It,pt as Lt,rt as Rt,s as zt,u as Bt,v as Vt,y as Ht}from"./index-Bjn557f1.js";import{a as Ut,c as Wt,f as Gt,i as Kt,n as qt,o as Jt,r as Yt,s as Xt,t as Zt,u as Qt}from"./settings-menu-CoLUNJGQ.js";var $t={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};$t.node;var en=B($t),tn={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};tn.node;var nn=B(tn),rn={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};rn.node;var an=B(rn),on={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};on.node;var sn=B(on),cn={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};cn.node;var ln=B(cn),un={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};un.node;var dn=B(un),fn={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};fn.node;var pn=B(fn),mn={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};mn.node;var hn=B(mn),gn={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};gn.node;var _n=B(gn),Z=e(t(),1),Q=e(n(),1),vn={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function yn({file:e,actions:t}){let[n,r]=(0,Z.useState)(e.description),i=(0,Z.useRef)(e.description),a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Z.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,Q.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:Y(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function bn(e,t){confirm(Y(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function xn({projectId:e,file:t,small:n}){let r=Ae(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:q(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,Q.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,Q.jsx)(Sn,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,Q.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,Q.jsx)(hn,{className:i}):t.mime===`application/pdf`?(0,Q.jsx)(w,{className:i}):t.mime===`application/json`?(0,Q.jsx)(ge,{className:i}):t.mime.startsWith(`model/`)?(0,Q.jsx)(nn,{className:i}):(0,Q.jsx)(fe,{className:i}),n?null:(0,Q.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function Sn({src:e,small:t}){let[n,r]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,Q.jsx)(`div`,{className:q(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Cn=`application/x-wizards-logo`;function wn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:l,onMakeMain:u,moveTo:d,onRemove:f}){let p=e=>f?f(e):bn(e,r);return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,Q.jsxs)(`div`,{draggable:d&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Cn,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===l?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(c,{tone:`ember`,children:Y(`project.logoMain`)})}):null,(0,Q.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?vn:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${Y(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,Q.jsx)(xn,{projectId:e,file:n})}):(0,Q.jsx)(xn,{projectId:e,file:n}),(0,Q.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[s?(0,Q.jsx)(F,{label:Y(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Me,{className:`size-4`})}):null,u&&n.id!==l&&!r.readOnly?(0,Q.jsx)(F,{label:Y(`project.logoMakeMain`),onClick:()=>u(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Pe,{className:`size-4`})}):null,d&&!r.readOnly?(0,Q.jsx)(se,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]})]}),t===`asset`?(0,Q.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,Q.jsx)(yn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,Q.jsxs)(he,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,Q.jsx)(V,{className:`size-5`}):(0,Q.jsx)(G,{className:`size-5`}),a]}):null]})}function Tn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)([]),m=async()=>{s(!0),l(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(d(a.candidates),p([a.candidates[0].url])):l(Y(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},g=async()=>{s(!0),l(null);let e=[];try{for(let n of f){let r=await t(n);r.file&&e.push(r.file)}}catch(e){l(e.message)}s(!1),e.length&&n(e),e.length===f.length&&r()};return(0,Q.jsx)(L,{open:!0,onClose:r,wide:u?!0:void 0,title:Y(u?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:u?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Y(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:u.map(t=>{let n=f.includes(t.url);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>p(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:q(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:vn,children:[(0,Q.jsx)(`img`,{src:t.url,alt:``,className:q(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(_,{className:`size-3.5`})}):null]},t.url)})}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>d(null),children:Y(`run.back`)}),(0,Q.jsx)(j,{busy:o,disabled:!f.length,onClick:()=>void g(),children:f.length>1?Y(`project.addMany`,{n:f.length}):Y(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),c?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:r,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,busy:o,disabled:!i.trim(),children:Y(`run.next`)})]})]})})}function En(e,t,n){return ye({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>p.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function Dn(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var On=e=>[Dn(e),e.pages?Y(`project.pages`,{n:e.pages}):null,H(e.size)].filter(Boolean).join(` · `),kn=2e5;function An({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=J(),a=P(e),o=$e(e),s=I(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[u,d]=(0,Z.useState)(null);if(!c)return a.isLoading?(0,Q.jsx)(V,{className:`mx-auto text-ink-3`}):null;let f=u??(l?`original`:`text`),p=o.data?.items.find(e=>e.key===`f:${c.id}`),m=Ae(e,c.id),h=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>d(e),className:q(`rounded-full px-3 py-1 text-[0.8125rem] transition`,f===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,Q.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:c.name}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:On(c)}),(0,Q.jsx)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,"aria-label":Y(`project.openOriginal`),title:Y(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(E,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{label:Y(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:R.knowledge(e)})},children:(0,Q.jsx)(Te,{className:`size-4`})}),(0,Q.jsx)(F,{label:Y(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(Y(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:R.knowledge(e)}),r())},children:(0,Q.jsx)(K,{className:`size-4`})})]})]}),(0,Q.jsx)(Je,{projectId:e,itemKey:`f:${c.id}`,has:p?.categories??[],originLabel:p?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,Q.jsx)(`div`,{className:`px-1`,children:(0,Q.jsx)(yn,{file:c,actions:s})}),c.status===`failed`?(0,Q.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,Q.jsxs)(je,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[l?h(`original`,Y(`project.original`)):null,h(`text`,Y(`project.readText`))]}),f===`original`?c.mime===`application/pdf`?(0,Q.jsx)(`iframe`,{src:m,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,Q.jsx)(`img`,{src:m,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,Q.jsx)(jn,{projectId:e,file:c})]})]})}function jn({projectId:e,file:t}){let n=En(e,t,kn);return n.isLoading||t.status===`pending`?(0,Q.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,Q.jsx)(V,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(xe,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:Y(`project.textCut`,{shown:n.data.text.length.toLocaleString(ve),total:n.data.chars.toLocaleString(ve)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:Y(`project.noText`)})}var Mn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,Nn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),H(e.size)].filter(Boolean).join(` · `);function Pn({projectId:e,file:t,actions:n,onClose:r}){let i=Ae(e,t.id);return(0,Q.jsxs)(L,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,Q.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:Nn(t)}),(0,Q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":Y(`project.openOriginal`),title:Y(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,Q.jsx)(E,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:vn,children:(0,Q.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,Q.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,Q.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(yn,{file:t,actions:n})})]})}function Fn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,Q.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${Y(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,Q.jsx)(xn,{projectId:e,file:t,small:!0})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:Nn(t)})]}),(0,Q.jsx)(yn,{file:t,actions:n})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,Q.jsx)(F,{label:Y(`project.preview`),onClick:i,children:(0,Q.jsx)(Me,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(se,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]})]})}function In({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Z.useState)(e?.title??``);return(0,Q.jsx)(L,{open:!0,onClose:r,title:Y(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.assetSectionName`)}),(0,Q.jsx)(z,{autoFocus:!0,value:i,maxLength:80,placeholder:Y(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(j,{variant:`danger`,onClick:n,children:Y(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(j,{variant:`ghost`,onClick:r,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,disabled:!i.trim(),children:Y(e?`settings.save`:`project.add`)})]})]})})}function Ln({projectId:e,data:t,readOnly:n,sections:r,save:i}){let o=I(e,n),[c,l]=g(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=s({assetSections:m},i),T=t.files.filter(e=>e.kind===`asset`),E=new Map(T.map(e=>[e.id,e])),D=new Set(m.flatMap(e=>e.assets)),O=m.find(e=>e.id===_)??null,k=O?O.assets.map(e=>E.get(e)).filter(e=>!!e):T.filter(e=>!D.has(e.id)),A=T.find(e=>e.id===f),j=u.trim().toLowerCase(),M=j?k.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(j)):k,N=(e,t)=>h(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),P=async e=>{let t=O?.id??null;for(let n of await o.upload(`asset`,e))N(n.id,t)},L=e=>{confirm(Y(`project.removeConfirm`,{name:e.name}))&&(o.remove(e.id),N(e.id,null))},R=m.length?{options:[{value:``,label:Y(`project.assetsGeneral`)},...m.map(e=>({value:e.id,label:e.title||Y(`project.sectionUntitled`)}))],current:e=>m.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>N(e.id,t||null)}:void 0,z=[{label:Y(`project.assetUpload`),icon:(0,Q.jsx)(bt,{className:`size-4 shrink-0`}),onPick:()=>C.current?.click()},{label:Y(`project.assetFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>S(!0)},...m.length<a.logoSections?[{label:Y(`project.assetSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>b(`new`)}]:[]],te=m.length||T.length?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[m.length?(0,Q.jsx)(ee,{value:_,onChange:e=>{v(e),d(``)},label:Y(`project.assets`),options:[{id:``,label:Y(`project.assetsGeneral`)},...m.map(e=>({id:e.id,label:e.title||Y(`project.sectionUntitled`)}))]}):null,O&&!n?(0,Q.jsx)(F,{label:Y(`project.assetSectionRename`),onClick:()=>b(`current`),children:(0,Q.jsx)(ke,{className:`size-4`})}):null]}),k.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,Q.jsx)(we,{value:u,onChange:d,placeholder:Y(`project.assetSearch`)})}),(0,Q.jsx)(F,{label:Y(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(wt,{className:`size-4`}):(0,Q.jsx)(pn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(X,{title:Y(`project.assets`),hint:Y(`project.assetsHint`),save:w,tabs:te,action:n?null:(0,Q.jsx)(ae,{entries:z}),children:[(0,Q.jsx)(`input`,{ref:C,type:`file`,multiple:!0,accept:Mn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&P(t)}}),M.length?c===`cards`?(0,Q.jsx)(wn,{projectId:e,kind:`asset`,files:M,actions:o,moveTo:R,onRemove:L,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:M.map(t=>(0,Q.jsx)(Fn,{projectId:e,file:t,actions:o,moveTo:R,onPreview:()=>p(t.id),onRemove:()=>L(t)},t.id))}):k.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Y(`project.staysLocal`)}):(0,Q.jsxs)(he,{accept:Mn,onFiles:e=>void P(e),className:`h-16 w-full`,children:[o.busy?(0,Q.jsx)(V,{className:`size-4`}):(0,Q.jsx)(bt,{className:`size-4`}),Y(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:Y(`project.assetAdd`)})]}),o.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error}):null,A?(0,Q.jsx)(Pn,{projectId:e,file:A,actions:o,onClose:()=>p(null)}):null,y?(0,Q.jsx)(In,{section:y===`current`?O:null,onClose:()=>b(null),onSave:e=>{if(y===`current`&&O)h(t=>t.map(t=>t.id===O.id?{...t,title:e}:t));else{let t=Oe();h(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&O?()=>{(!O.assets.length||confirm(Y(`project.assetSectionRemoveConfirm`,{name:O.title})))&&(h(e=>e.filter(e=>e.id!==O.id)),v(``),b(null))}:void 0}):null,x?(0,Q.jsx)(Tn,{kind:`asset`,onClose:()=>S(!1),fetchUrl:e=>o.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)N(t.id,O?.id??null)}}):null]})}var Rn=/^#[0-9a-fA-F]{6}$/;async function zn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var Bn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function Vn({projectId:e,gradient:t,isNew:n,brand:r,onSave:i,onClose:a}){let[o,s]=(0,Z.useState)(t),[c,l]=(0,Z.useState)(k(t)),[d,f]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!n),C=e=>{s(e),l(k(e)),f(!1)},w=(e,t)=>C({...o,stops:o.stops.map((n,r)=>r===e?{...n,...t}:n)}),T=e=>{let t=[...o.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));C({...o,stops:[...o.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},E=async()=>{v(!0),b(null);try{let{gradient:t}=await p.post(`/api/studio/projects/${e}/gradients/describe`,{text:m.trim(),...x?{gradient:{name:o.name,type:o.type,angle:o.angle,stops:o.stops}}:{}});C({...o,...t,name:o.name.trim()?o.name:t.name}),g(``),S(!0)}catch(e){b(e.message)}v(!1)};return(0,Q.jsx)(L,{open:!0,onClose:a,wide:!0,title:Y(n?`project.gradientNew`:`project.gradientEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!_&&E()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(z,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":Y(`project.gradientDescribe`),placeholder:Y(x?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>g(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(j,{type:`submit`,variant:`secondary`,busy:_,disabled:!m.trim(),children:[(0,Q.jsx)(ge,{className:`size-4`}),Y(x?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.8125rem]`,y?`text-rose`:`text-ink-3`),children:y??Y(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:k(o)}}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.gradientName`)}),(0,Q.jsx)(z,{value:o.name,maxLength:80,placeholder:Y(`project.gradientNamePlaceholder`),onChange:e=>s({...o,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.fillUseLabel`)}),(0,Q.jsx)(z,{value:o.description??``,maxLength:400,placeholder:Y(`project.gradientUse`),onChange:e=>s({...o,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":o.type===e,onClick:()=>C({...o,type:e}),className:q(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,o.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:Y(Bn[e])},e))})]}),o.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(h,{children:Y(`project.gradientAngle`)}),(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:360,value:o.angle,"aria-label":Y(`project.gradientAngle`),onChange:e=>C({...o,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(o.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(te,{value:Rn.test(e.color)?e.color:`#888888`,onChange:e=>w(t,{color:e.target.value})}),(0,Q.jsx)(z,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Rn.test(n)&&w(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":Y(`project.gradientAt`),onChange:e=>w(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,Q.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,Q.jsx)(F,{label:Y(`project.remove`),disabled:o.stops.length<=2,onClick:()=>C({...o,stops:o.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[o.stops.length<12?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>T(),children:[(0,Q.jsx)(G,{className:`size-4`}),` `,Y(`project.gradientStopAdd`)]}):null,r.length&&o.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:Y(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>T(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:`CSS`}),(0,Q.jsx)(z,{value:c,spellCheck:!1,onChange:e=>{l(e.target.value);let t=A(e.target.value);f(!t),t&&s({...o,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.8125rem]`,d?`text-rose`:`text-ink-3`),children:Y(d?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:a,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{onClick:()=>{i(o),a()},children:Y(`settings.save`)})]})]})})}var Hn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,Un=`size-8 bg-card shadow-soft hover:bg-card`;function Wn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,Q.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,Q.jsx)(le,{value:e,label:Y(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(le,{value:n??``,label:Y(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function Gn({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=k(e),[o,s]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:t,"aria-label":Y(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,Q.jsxs)(`div`,{className:Hn,children:[(0,Q.jsx)(F,{label:Y(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Un,children:(0,Q.jsx)(S,{className:`size-4`})}),(0,Q.jsx)(F,{label:Y(`project.download`),onClick:()=>void zn(e,e.name),className:Un,children:(0,Q.jsx)(f,{className:`size-4`})}),t?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:i,className:q(Un,`hover:text-rose`),children:(0,Q.jsx)(K,{className:`size-4`})})]})]}),(0,Q.jsx)(Wn,{name:e.name,namePlaceholder:Y(`project.gradientName`),description:e.description,usePlaceholder:Y(`project.gradientUse`),readOnly:t,onChange:r})]})}function Kn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function qn({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=Ae(e,t.file);return(0,Q.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-label":Y(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:Kn(s,t.tile)}),(0,Q.jsxs)(`div`,{className:Hn,children:[(0,Q.jsx)(`a`,{href:s,download:n,"aria-label":Y(`project.download`),title:Y(`project.download`),className:q(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Un),children:(0,Q.jsx)(f,{className:`size-4`})}),r?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:o,className:q(Un,`hover:text-rose`),children:(0,Q.jsx)(K,{className:`size-4`})})]})]}),(0,Q.jsx)(Wn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:Y(`project.patternUse`),readOnly:r,onChange:a})]})}function Jn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:a,upload:o,removeFile:s,onSave:c,onClose:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)([]),m=async e=>{let t=e[0];if(!t)return;let n=await o(t);n&&(p(e=>[...e,n.id]),d(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},g=()=>{for(let e of f)s(e);l()};return(0,Q.jsx)(L,{open:!0,onClose:g,wide:!0,title:Y(n?`project.patternNew`:`project.patternEdit`),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u.file?(0,Q.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:Kn(Ae(e,u.file),u.tile),children:(0,Q.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,Q.jsx)(V,{className:`size-4`}):(0,Q.jsx)(me,{className:`size-4`}),Y(`project.patternReplace`)]})}):(0,Q.jsxs)(he,{accept:`image/*`,multiple:!1,onFiles:e=>void m(e),className:`h-40 flex-col`,children:[i?(0,Q.jsx)(V,{className:`size-5`}):(0,Q.jsx)(me,{className:`size-5`}),Y(`project.patternPick`)]}),(0,Q.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.patternName`)}),(0,Q.jsx)(z,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):Y(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.fillUseLabel`)}),(0,Q.jsx)(z,{value:u.description??``,maxLength:400,placeholder:Y(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.patternShow`)}),(0,Q.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!u.tile===e,onClick:()=>d({...u,tile:e||void 0}),className:q(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!u.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:Y(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[a?(0,Q.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:a}):null,(0,Q.jsx)(j,{variant:`ghost`,onClick:g,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{disabled:!u.file||i,onClick:()=>{for(let e of f.filter(e=>e!==u.file))s(e);t.file&&t.file!==u.file&&s(t.file),c({...u,name:u.name.trim(),description:u.description?.trim()||void 0}),l()},children:Y(n?`project.add`:`settings.save`)})]})]})})}var Yn=/^#[0-9a-fA-F]{6}$/;function Xn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{colors:t}=await p.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),f([])):c(Y(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(L,{open:!0,onClose:n,wide:l?!0:void 0,title:Y(l?`project.colorsFound`:`project.colorsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Y(`project.colorsFoundHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:l.map(e=>{let t=d.includes(e.value);return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>f(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:q(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,Q.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,Q.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,Q.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(_,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>u(null),children:Y(`run.back`)}),(0,Q.jsx)(j,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?Y(`project.addMany`,{n:d.length}):Y(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(`project.colorsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:n,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,busy:a,disabled:!r.trim(),children:Y(`run.next`)})]})]})})}function Zn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:o,rules:l,sectioned:u,ruled:d,save:f,readOnly:p}){let[h,g]=(0,Z.useState)(()=>n.map(e=>({...e,id:Oe()}))),[_,v]=(0,Z.useState)(r),[y,b]=(0,Z.useState)(i),[x,S]=(0,Z.useState)(o),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),D=I(e,p),O=M(l),[k,ee]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(!1),L=s({colors:h.filter(e=>Yn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:_,gradients:y,patterns:x,colorRules:O.rules},f),R=u?_:[],B=R.filter(e=>(e.kind??`colors`)===`colors`),V=e=>B.some(t=>t.id===e.section),H=h.filter(e=>!V(e)),U=(H[0]??h[0])?.id,W=(e,t)=>g(n=>n.map(n=>n.id===e?{...n,...t}:n)),re=e=>g(t=>[...t,...e.map(e=>({...e,id:Oe()}))].slice(0,a.colors)),q=[{value:``,label:Y(`project.sectionStandard`)},...B.map(e=>({value:e.id,label:e.title||Y(`project.sectionUntitled`)}))],ce=(e,t)=>{let n=Oe();ee(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},le=e=>({id:Oe(),name:``,section:e,type:`linear`,angle:90,stops:[{color:h[0]?.value&&Yn.test(h[0].value)?h[0].value:`#4b73ff`,at:0},{color:h[1]?.value&&Yn.test(h[1].value)?h[1].value:`#ff6d1b`,at:100}]}),ue=e=>t.files.find(t=>t.id===e)?.name??`pattern`,de=[...h.length<a.colors?[{label:Y(`project.colorNew`),icon:(0,Q.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>fe()},{label:Y(`project.colorsFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>P(!0)}]:[],...u&&_.length<a.logoSections?[{label:Y(`project.colorSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>ce(`colors`,``)},{label:Y(`project.gradientSectionAdd`),icon:(0,Q.jsx)(en,{className:`size-4 shrink-0`}),onPick:()=>ce(`gradients`,Y(`project.gradientSectionTitle`))},{label:Y(`project.patternSectionAdd`),icon:(0,Q.jsx)(ln,{className:`size-4 shrink-0`}),onPick:()=>ce(`patterns`,Y(`project.patternSectionTitle`))}]:[],...!d||O.full?[]:[{label:Y(`project.ruleNew`),icon:(0,Q.jsx)(Le,{className:`size-4 shrink-0`}),onPick:()=>O.add()}]],J=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(te,{value:Yn.test(e.value)?e.value:`#888888`,onChange:t=>W(e.id,{value:t.target.value})}),(0,Q.jsx)(z,{value:e.name,autoFocus:e.id===A,placeholder:Y(`project.colorName`),maxLength:120,onChange:t=>W(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(z,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>W(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,Q.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===U?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(c,{tone:`ember`,children:Y(`project.colorAccent`)})}):p?null:(0,Q.jsx)(F,{label:Y(`project.colorFirst`),onClick:()=>g(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,Q.jsx)(m,{className:`size-4`})}),p||!B.length?null:(0,Q.jsx)(se,{options:q,value:V(e)?e.section??``:``,onChange:t=>W(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),p?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:()=>g(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]})]},e.id),fe=e=>{let t=Oe();j(t),g(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(X,{title:Y(`project.colors`),hint:Y(`project.colorsHint`),save:L,locked:p,action:p?null:(0,Q.jsx)(ae,{entries:de}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[H.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:H.map(J)}),p?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(`project.colorUse`)})]}):h.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Y(`project.colorsEmpty`)}),R.map(t=>{let n=t.kind??`colors`,r=h.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),o=x.filter(e=>e.section===t.id),s=n===`gradients`?i.length:n===`patterns`?o.length:r.length;return(0,Q.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,Q.jsx)(ie,{title:t.title,titlePlaceholder:Y(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)(en,{}),label:Y(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(ln,{}),label:Y(`project.kindPatterns`)}:{icon:(0,Q.jsx)(Dt,{}),label:Y(`project.kindColors`)},autoFocus:k===t.id,readOnly:p,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(Y(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||Y(`project.sectionUntitled`)}))){v(e=>e.filter(e=>e.id!==t.id)),g(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),b(e=>e.filter(e=>e.section!==t.id));for(let e of o)D.remove(e.file);S(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,Q.jsx)(Gn,{gradient:e,readOnly:p,onEdit:()=>w(e),onChange:t=>b(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>b(t=>t.filter(t=>t.id!==e.id))},e.id)),p||y.length>=a.gradients?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(le(t.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(G,{className:`size-5`}),Y(`project.gradientAdd`)]})]}):n===`patterns`?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[o.map(t=>(0,Q.jsx)(qn,{projectId:e,pattern:t,fileName:ue(t.file),readOnly:p,onEdit:()=>E(t),onChange:e=>S(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{D.remove(t.file),S(e=>e.filter(e=>e.id!==t.id))}},t.id)),p||x.length>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E({id:Oe(),name:``,section:t.id,file:``}),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,Q.jsx)(G,{className:`size-5`}),Y(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(J),p||h.length>=a.colors?null:(0,Q.jsx)(oe,{label:Y(`project.colorAdd`),onClick:()=>fe(t.id)})]})]},t.id)}),d?(0,Q.jsx)(ne,{rules:O,placeholder:Y(`project.colorRulePlaceholder`),readOnly:p}):null]}),D.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:D.error}):null,C?(0,Q.jsx)(Vn,{projectId:e,gradient:C,isNew:!y.some(e=>e.id===C.id),brand:h.filter(e=>Yn.test(e.value)),onClose:()=>w(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,T?(0,Q.jsx)(Jn,{projectId:e,pattern:T,isNew:!x.some(e=>e.id===T.id),fileName:ue,busy:D.busy,error:D.error,upload:async e=>(await D.upload(`pattern`,[e]))[0]??null,removeFile:e=>void D.remove(e),onClose:()=>E(null),onSave:e=>S(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,N?(0,Q.jsx)(Xn,{projectId:e,onClose:()=>P(!1),onAdd:re}):null]})}var Qn=e=>/^(ja|yes|true)$/i.test(e.trim()),$n={text:Fe,longtext:vt,number:ze,date:Be,url:O,email:Nt,phone:gt,boolean:Ve};function er({type:e,detected:t,onChange:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=$n[e??t],l=`${Y(`project.factType`)}: ${Y(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:q(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,Q.jsx)(c,{className:`size-4`})}),r?(0,Q.jsxs)(`div`,{role:`menu`,className:q(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,Q.jsx)(Ie,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Y(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:Y(`project.type.${t}`)}),(0,Q.jsx)(_,{className:q(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=$n[t];return(0,Q.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Y(`project.type.${t}`)}),(0,Q.jsx)(_,{className:q(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function tr({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),o=(0,Z.useRef)(null),[c,u]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),d=s(c.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),f=(e,t)=>u(n=>n.map(n=>n.id===e?{...n,...t}:n)),p=(e,t,n=!1)=>{let i=`f${r.current++}`;o.current=`${i}:${t}`;let a={id:i,key:``,label:``,value:``,...e};u(e=>n?[a,...e]:[...e,a])},m=e=>t=>{t&&o.current===e&&(o.current=null,t.focus())},h=l.filter(e=>!c.some(t=>t.key===e));return(0,Q.jsxs)(X,{title:Y(`project.facts`),hint:Y(`project.factsHint`),save:d,locked:n,action:c.length<a.facts&&!n?(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>p({},`label`,!0),children:[(0,Q.jsx)(G,{className:`size-4`}),` `,Y(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=de(e.value),r=e.type??t;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,Q.jsx)(z,{ref:m(`${e.id}:label`),value:e.label,placeholder:Y(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>f(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&f(e.id,{key:C(e.label,c.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,Q.jsx)(W,{checked:Qn(e.value),label:e.label,onChange:t=>f(e.id,{value:Y(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Qn(e.value)?Y(`project.yes`):Y(`project.no`)})]}):(0,Q.jsx)(i,{ref:m(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:Y(`project.factValue`),onChange:t=>f(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(er,{type:e.type,detected:t,onChange:t=>f(e.id,{type:t})}),n?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:()=>u(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]},e.id)})}),c.length<a.facts&&!n?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${c.length?`mt-4`:``}`,children:[(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>p({},`label`),children:[(0,Q.jsx)(G,{className:`size-4`}),` `,Y(`project.factAdd`)]}),h.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p({key:e,label:Y(`fact.${e}`)},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,Q.jsx)(G,{className:`size-3.5`}),` `,Y(`fact.${e}`)]},e))]}):null]})}function nr({onLogo:e,children:t,className:n}){let[r,i]=(0,Z.useState)(!1);return e?(0,Q.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(Cn);i(!1),n&&(t.preventDefault(),e(n))},className:q(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,Q.jsx)(`div`,{className:n,children:t})}function rr({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:o,ruled:c,save:l}){let u=I(e,n),[d,f]=(0,Z.useState)(r),p=M(i),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(null),b=s({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=o?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=y(x,d)?.id,D=(e,t)=>f(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),k=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)D(e.id,t)},ee=C.length?{options:[{value:``,label:Y(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||Y(`project.sectionUntitled`)}))],current:e=>C.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,A=(t,n,r)=>(0,Q.jsx)(wn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?Y(`project.logoAdd`):void 0,onUpload:e=>void k(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),u.order(`logo`,[e.id,...x.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:e=>{confirm(Y(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),N=[{label:Y(`project.logoUpload`),icon:(0,Q.jsx)(bt,{className:`size-4 shrink-0`}),onPick:()=>v.current?.click()},{label:Y(`project.logoFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>_(!0)},...o&&d.length<a.logoSections?[{label:Y(`project.logoSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>{let e=Oe();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:Y(`project.ruleNew`),icon:(0,Q.jsx)(Le,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(X,{title:Y(`project.logos`),hint:Y(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(ae,{entries:N}),children:[(0,Q.jsx)(`input`,{ref:v,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&k(t,null)}}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Q.jsx)(nr,{onLogo:j?.(null),children:A(T,null,!0)}),C.map(e=>(0,Q.jsx)(`div`,{className:`group/section`,children:(0,Q.jsxs)(nr,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,Q.jsx)(ie,{title:e.title,description:e.description,titlePlaceholder:Y(`project.logoSectionTitle`),descriptionPlaceholder:Y(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(Y(`project.logoSectionRemoveConfirm`,{name:e.title||Y(`project.sectionUntitled`)})))&&f(t=>t.filter(t=>t.id!==e.id))}}),A(e.logos.map(e=>S.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),c?(0,Q.jsx)(ne,{rules:p,placeholder:Y(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,g?(0,Q.jsx)(Tn,{kind:`logo`,onClose:()=>_(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var ir=e=>URL.canParse(e)?new URL(e).host:e;async function ar(e,t){let n=T({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await or(e,t);let r=await fetch(e,{mode:`cors`}).catch(()=>null);return r?r.ok?await new FontFace(`engenty-check-${Date.now()}`,await r.arrayBuffer()).load().then(()=>`ok`,()=>`noFont`):`down`:await fetch(e,{mode:`no-cors`}).then(()=>!0,()=>!1)?`cors`:`down`}function or(e,t){let n=new Set(document.fonts),r=document.createElement(`link`);return r.rel=`stylesheet`,r.href=e,new Promise(e=>{r.onerror=()=>e(`down`),r.onload=async()=>{let r=[...document.fonts].filter(e=>!n.has(e)&&e.family.replace(/^["']|["']$/g,``)===t),i=await Promise.allSettled(r.map(e=>e.load()));e(r.length===0?`missing`:i.some(e=>e.status===`fulfilled`)?`ok`:`cors`)},document.head.append(r)}).finally(()=>r.remove())}function sr(e,t){let n=e.source;if(!n)return Y(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return Y(`project.fontSourceFile`,{name:e})}return Y(`project.fontSourceUrl`,{host:ir(n.url)})}function cr({projectId:e,font:t,onSave:n,onClose:r}){let i=(P(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=I(e),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(t.source&&`url`in t.source?`url`:`file`),[l,u]=(0,Z.useState)(t.source&&`file`in t.source?t.source.file:``),[d,f]=(0,Z.useState)(t.source&&`url`in t.source?t.source.url:``),[p,m]=(0,Z.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(t.license??``),[b,x]=(0,Z.useState)(!1),S=d.trim(),C=async()=>{_(!0),m({url:S,result:await ar(S,t.family.trim())}),_(!1)},w=s===`file`?l?{file:l}:null:p?.url===S&&p.result===`ok`?{url:S}:null,T=p?.url===S?p.result:null;return(0,Q.jsx)(L,{open:!0,onClose:r,title:Y(`project.fontSourceTitle`,{family:t.family}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Y(`project.fontSourceHint`)}),(0,Q.jsx)(Se,{value:s,options:[`file`,`url`],label:e=>Y(`project.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.fontSourceFiles`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>u(e.id),className:q(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,l===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,Q.jsx)(`input`,{ref:o,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await a.upload(`asset`,t);n&&u(n.id)}}),(0,Q.jsxs)(j,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,Q.jsx)(bt,{className:`size-4`}),Y(`project.fontSourceUpload`)]}),a.error?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:a.error}):null]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),C()},children:[(0,Q.jsx)(h,{children:Y(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(z,{value:d,inputMode:`url`,placeholder:Y(`project.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,Q.jsx)(j,{type:`submit`,variant:`ghost`,busy:g,disabled:!S.startsWith(`https://`),children:Y(`project.fontSourceCheck`)})]}),T?(0,Q.jsx)(`p`,{className:q(`mt-1.5 text-[0.875rem]`,T===`ok`?`text-ink-3`:`text-rose`),children:Y(`project.fontCheck.${T}`,{host:ir(S),family:t.family})}):null,T===`ok`?(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:Y(`project.fontPrivacy`,{host:ir(S)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{hint:Y(`project.fontLicenseHint`),children:Y(`project.fontLicense`)}),(0,Q.jsx)(z,{value:v,maxLength:200,placeholder:Y(`project.fontLicensePlaceholder`),onChange:e=>y(e.target.value)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:b,onChange:e=>x(e.target.checked)}),Y(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(j,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:Y(`project.fontSourceRemove`)}):null,(0,Q.jsx)(j,{variant:`ghost`,onClick:r,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{disabled:!(w&&b),onClick:()=>{w&&(n({source:w,license:v.trim()||void 0}),r())},children:Y(`project.fontSourceSave`)})]})]})})}var lr=new Set;function ur(e){(0,Z.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||lr.has(t))return;lr.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${d.join(`,`)}&display=swap`,document.head.append(n)},[e])}var dr=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function fr({unit:e,label:t,...n}){return(0,Q.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,Q.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var pr=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,mr={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function hr({projectId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){ur(t.family);let s=P(e).data?.files??[],[c,l]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,Q.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:dr(t.family)},children:[(0,Q.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,Q.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(le,{value:t.family,label:Y(`project.fontFamily`),placeholder:Y(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(le,{value:t.role,label:Y(`project.fontRole`),placeholder:Y(n?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>{let n=t.weights.includes(e);return(0,Q.jsx)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>a({weights:n?t.weights.filter(t=>t!==e):[...t.weights,e].sort((e,t)=>e-t)}),style:{fontFamily:dr(t.family),fontWeight:e},className:q(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,n?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:e},e)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,Q.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,Q.jsx)(le,{value:t.license??``,label:Y(`project.fontLicense`),placeholder:Y(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:Y(`project.fontUses`)}),N.map(e=>{let n=!!t.uses?.includes(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):N.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:q(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,n?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,r&&!n&&`hidden`),children:[n?(0,Q.jsx)(_,{className:`size-3.5`}):null,Y(mr[e])]},e)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:sr(t,s)}),r||!t.family.trim()?null:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:Y(t.source?`project.fontSourceChange`:`project.fontSourceSet`)})]}),c?(0,Q.jsx)(cr,{projectId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:o,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]})}function gr({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){let s=t.find(t=>t.id===e.font)??t[0],c={fontFamily:dr(s?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,Q.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,Q.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,Q.jsx)(`div`,{className:`w-40`,children:(0,Q.jsx)(le,{value:e.name,label:Y(`project.styleName`),placeholder:Y(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,Q.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,Q.jsx)(`select`,{"aria-label":Y(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:q(pr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||Y(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":Y(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:pr,children:[...new Set([...d,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(fr,{unit:`px`,label:Y(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,Q.jsx)(fr,{unit:Y(`project.styleLine`),label:Y(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(fr,{unit:Y(`project.styleTracking`),label:Y(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:Y(`project.styleUpper`),"aria-label":Y(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:q(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,Q.jsx)(an,{className:`size-4`})})]}),r?null:(0,Q.jsx)(F,{label:Y(`project.remove`),onClick:o,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,Q.jsx)(K,{className:`size-4`})})]})]})}function _r({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{fonts:t}=await p.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),f(t.slice(0,2).map(e=>e.family))):c(Y(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(L,{open:!0,onClose:n,wide:l?!0:void 0,title:Y(l?`project.fontsFound`:`project.fontsFromUrl`),children:l?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Y(`project.fontsFoundHint`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,Q.jsx)(vr,{font:e,on:d.includes(e.family),onToggle:()=>f(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>u(null),children:Y(`run.back`)}),(0,Q.jsx)(j,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?Y(`project.addMany`,{n:d.length}):Y(`project.add`)})]})]}):(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.logoUrl`)}),(0,Q.jsx)(z,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(`project.fontsUrlHint`)})]}),s?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:n,children:Y(`common.cancel`)}),(0,Q.jsx)(j,{type:`submit`,busy:a,disabled:!r.trim(),children:Y(`run.next`)})]})]})})}function vr({font:e,on:t,onToggle:n}){return ur(e.family),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:q(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,Q.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:dr(e.family)},children:`Aa`}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,Q.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):Y(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(_,{className:`size-3.5`})}):null]})}function yr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:o,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=M(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=s({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:Oe(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&g(n[0].id),d(e=>[...e,...n].slice(0,a.fonts))},x=()=>{let e=Oe();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:Y(`project.fontNew`),icon:(0,Q.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:Y(`project.fontsFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:Y(`project.styleNew`),icon:(0,Q.jsx)(Et,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:Y(`project.ruleNew`),icon:(0,Q.jsx)(Le,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(X,{title:Y(`project.typography`),hint:Y(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(ae,{entries:S}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,Q.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((t,n)=>(0,Q.jsx)(hr,{projectId:e,font:t,first:n===0,readOnly:l,autoFocus:h===t.id,onChange:e=>d(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>d(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Y(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:Y(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:Y(`project.stylesHint`)}),(0,Q.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:f.map(e=>(0,Q.jsx)(gr,{style:e,fonts:u,sample:o,readOnly:l,autoFocus:h===e.id,onChange:t=>p(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>p(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,Q.jsx)(ne,{rules:m,placeholder:Y(`project.typeRulePlaceholder`),readOnly:l}):null]}),_?(0,Q.jsx)(_r,{projectId:e,onClose:()=>v(!1),onAdd:e=>b(e)}):null]})}function br({project:e,save:t}){let[n,r]=(0,Z.useState)(e.brand.name??``),[a,o]=(0,Z.useState)(e.brand.about??``),c=s({name:n.trim(),about:a.trim()},e=>t({brand:e}));return(0,Q.jsx)(X,{title:Y(`project.base`),hint:Y(`project.baseHint`),save:c,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.title`)}),(0,Q.jsx)(z,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(h,{children:Y(`project.about`)}),(0,Q.jsx)(i,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Y(`project.aboutHint`)})]})]})})}function xr({project:e,group:t,top:n=!1,children:r}){let i=J(),a=P(e.id),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),u=async t=>{await p.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:R.spaces()})},d=Re({mutationFn:()=>p.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:R.spaces()})}),f=mt(),m=ft(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${o}`,_=e.readOnly,v=t===`knowledge`,y=Ot(`brandSections`),b=Ot(`brandRules`),x=Ot(`typography`);return Rt(_?{}:{title:Y(v?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:Y(v?`project.assistantHelloKnowledge`:`project.assistantHello`),about:Y(v?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:Y(v?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:v?[{label:Y(`assistant.suggest.knowledgeHow`)},{label:Y(`assistant.suggest.knowledgeSite`),fill:!0},{label:Y(`assistant.suggest.knowledgeCategories`)}]:[{label:Y(`assistant.suggest.readSite`),fill:!0},{label:Y(`assistant.suggest.missing`)},{label:Y(`assistant.suggest.facts`)}],summary:v?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${h.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,Q.jsx)(yt,{children:_t(e)}):n?(0,Q.jsx)(Ft,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(be,{id:`base`,children:(0,Q.jsx)(br,{project:e,save:u},`base:${g}`)}),(0,Q.jsx)(be,{id:`facts`,children:(0,Q.jsx)(tr,{facts:e.facts,save:e=>u({facts:e}),readOnly:_},`facts:${g}`)}),(0,Q.jsx)(be,{id:`logos`,children:(0,Q.jsx)(rr,{projectId:e.id,data:h,readOnly:_,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:y,ruled:b,save:e=>u({brand:e})},`logos:${g}`)}),(0,Q.jsx)(be,{id:`colors`,children:(0,Q.jsx)(Zn,{projectId:e.id,data:h,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:y,ruled:b,save:e=>u({brand:e}),readOnly:_},`colors:${g}`)}),x?(0,Q.jsx)(be,{id:`typography`,children:(0,Q.jsx)(yr,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:b,sample:e.brand.name||Y(`project.typeSample`),save:e=>u({brand:e}),readOnly:_},`typography:${g}`)}):null,(0,Q.jsx)(be,{id:`assets`,children:(0,Q.jsx)(Ln,{projectId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${g}`)})]}):null,r,t===`info`&&f&&!_&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(j,{variant:`danger`,onClick:()=>l(!0),children:Y(`settings.delete`)}),(0,Q.jsxs)(L,{open:c,onClose:()=>l(!1),title:Y(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:Y(`settings.deleteBody`)}),d.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:d.error.message}):null,(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(j,{variant:`ghost`,onClick:()=>l(!1),children:Y(`common.cancel`)}),(0,Q.jsx)(j,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:Y(`common.delete`)})]})]})]}):null]})}var Sr=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],$=`text-[0.8125rem] text-ink-3 leading-snug`,Cr=`font-mono text-[0.875rem]`,wr=e=>e.slice(e.indexOf(`.`)+1);function Tr(){let[e,t]=(0,Z.useState)(!1),n=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>()=>clearTimeout(n.current),[]),{copied:e,copy:e=>navigator.clipboard.writeText(e).then(()=>{t(!0),clearTimeout(n.current),n.current=setTimeout(()=>t(!1),1500)}).catch(()=>t(!1))}}function Er(){let e=Y(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(U,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:Y(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(U,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:Y(`project.facts`)},t):e),` `,Y(`page.onlyShared`)]})}function Dr({host:e,value:t,onChange:n,disabled:r}){let i=pe.test(t);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-stretch overflow-hidden rounded-lg border border-input bg-card focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,children:[(0,Q.jsxs)(`span`,{title:`${e}/`,className:`flex max-w-[55%] items-center truncate bg-paper-2 px-3 font-mono text-[0.75rem] text-ink-3`,children:[`…`,wr(e),`/`]}),(0,Q.jsx)(`input`,{value:t,disabled:r,"aria-label":Y(`page.address`),maxLength:D.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:q(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Cr)})]}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$,!i&&t&&`text-rose`),children:Y(`page.addressRules`)})]})}function Or({host:e,words:t,onChange:n,disabled:r}){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(h,{children:Y(`page.title`)}),(0,Q.jsx)(z,{value:t.title,disabled:r,maxLength:D.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$),children:Y(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(h,{children:Y(`page.address`)}),(0,Q.jsx)(Dr,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:q(`mt-1`,$),children:Y(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(h,{children:Y(`page.headline`)}),(0,Q.jsx)(z,{value:t.headline??``,disabled:r,maxLength:D.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(h,{children:Y(`page.words`)}),(0,Q.jsx)(i,{value:t.intro??``,disabled:r,minRows:3,maxLength:D.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(h,{children:Y(`page.lang`)}),(0,Q.jsx)(b,{value:t.voice,onChange:e=>n({voice:e}),options:Sr.map(e=>({value:e.value,label:Y(e.label)}))}),(0,Q.jsx)(`p`,{className:q(`mt-1.5`,$),children:Y(`page.langHint`)})]})]})}function kr(e,t){if(!e.published)return Y(`page.draftNote`);if(!e.shareEnabled)return Y(`page.notSharedNote`);let n=e.description.trim();return t?[n,Y(`page.first`)].filter(Boolean).join(` · `):n}function Ar({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:a}){return(0,Q.jsxs)(`li`,{draggable:a?!0:void 0,onDragStart:a?.onDragStart,onDragOver:a?.onDragOver,onDrop:a?.onDrop,className:q(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[a?(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${Y(`page.moveUp`)} / ${Y(`page.moveDown`)}`,onKeyDown:a.onKeyDown,className:`grid size-7 shrink-0 cursor-grab place-items-center rounded-md text-ink-4 hover:text-ink focus:text-ink`,children:(0,Q.jsx)(o,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(ht,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,Q.jsx)(`p`,{className:q(`truncate`,$),children:kr(e,t)})]}),(0,Q.jsx)(W,{checked:n,disabled:r||!e.published,label:Y(`page.showOnPage`),onChange:i})]})}function jr({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:q(`flex min-h-20 flex-col items-start gap-1 rounded-xl px-4 py-3 text-left transition`,n?`bg-accent ring-2 ring-primary`:i?`border border-border border-dashed opacity-60`:`ring-1 ring-border-soft hover:bg-paper-2`,(r||i)&&`cursor-not-allowed`),children:[(0,Q.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,Q.jsx)(`span`,{className:$,children:t})]})}var Mr={desktop:1280,tablet:768,mobile:390},Nr=`wizards.pagePreviewDevice`,Pr=`wizards.pagePreviewHeight`,Fr=360,Ir=e=>e?640:480,Lr=()=>Math.max(Fr,window.innerHeight-140);function Rr(){try{let e=Number(localStorage.getItem(Pr));return e>=Fr?e:null}catch{return null}}function zr(e){try{e===null?localStorage.removeItem(Pr):localStorage.setItem(Pr,String(Math.round(e)))}catch{}}function Br(){try{let e=localStorage.getItem(Nr);return e&&e in Mr?e:`desktop`}catch{return`desktop`}}function Vr(e){try{localStorage.setItem(Nr,e)}catch{}}function Hr({url:e,version:t,device:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)({width:0,tall:!0});(0,Z.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a({width:e.clientWidth,tall:e.clientWidth>=640});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o=Mr[n],[s,c]=(0,Z.useState)(Rr),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=Math.min(s??Ir(i.tall),i.width?Lr():9999),p=e=>{let t=Math.round(Math.min(Lr(),Math.max(Fr,e)));return c(t),t},m=n===`mobile`,h=m?12:0,g=i.width?Math.min(1,(i.width-2*h)/o):1,_=(0,Q.jsxs)(`div`,{className:q(`relative overflow-hidden bg-paper-2`,m?`rounded-[1.5rem]`:`rounded-lg ring-1 ring-border-soft`),style:{width:Math.round(o*g),height:f},children:[i.width?(0,Q.jsx)(`iframe`,{title:Y(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:q(`absolute top-0 left-0 border-0`,l&&`pointer-events-none`),style:{width:o,height:Math.ceil(f/g),transform:`scale(${g})`,transformOrigin:`top left`}},t):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":Y(`page.resize`),title:Y(`page.resize`),onPointerDown:e=>{e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}d.current={y:e.clientY,height:f},u(!0)},onPointerMove:e=>{d.current&&p(d.current.height+e.clientY-d.current.y)},onPointerUp:e=>{d.current&&=(zr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),zr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),zr(p(f+(e.key===`ArrowDown`?24:-24))))},className:`absolute right-1 bottom-1 z-10 grid size-7 cursor-ns-resize touch-none place-items-center rounded-md bg-card/90 text-ink-3 shadow-soft ring-1 ring-border-soft hover:text-ink coarse:size-9`,children:(0,Q.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,Q.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:m?(0,Q.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function Ur({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Z.useRef)(t);a.current=t;let[o,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:He(t)})),l=s(o,async e=>{if(!(pe.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=ct(e.voice);await r({...a.current,slug:e.slug,title:e.title.trim(),headline:e.headline?.trim()||void 0,intro:e.intro?.trim()||void 0,lang:t,form:n})}),{state:u,error:d}=l;return(0,Z.useEffect)(()=>i(l),[u,d]),(0,Q.jsx)(Or,{host:e,words:o,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Wr({project:e}){let t=J(),n=pt(),r=n.data?.tenant.pagesHost??null,i=n.data?.manageUrl??null,a=e.readOnly,o=e.page,s=!!o?.on,c=ye({queryKey:R.projectWizards(e.id),queryFn:()=>p.get(`/api/studio/projects/${e.id}/wizards`)}),[l,u]=(0,Z.useState)(1),[d,f]=(0,Z.useState)(Br),m=(0,Z.useRef)(o);m.current=o;let h=async n=>{await p.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:R.spaces()}),u(e=>e+1)},g=Re({mutationFn:e=>{let t=m.current;return t?h({...t,...e}):Promise.resolve()}}),[v,y]=(0,Z.useState)({state:`idle`,error:null}),{copied:b,copy:C}=Tr(),w=c.data??[],T=(o?.wizards??[]).map(e=>w.find(t=>t.id===e)).filter(e=>e!==void 0),E=w.filter(e=>!o?.wizards.includes(e.id)),[D,O]=(0,Z.useState)(null),k=(e,t)=>{let n=[...o?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),g.mutate({wizards:n})},ee=(e,t)=>g.mutate({wizards:t?[...o?.wizards??[],e]:(o?.wizards??[]).filter(t=>t!==e)}),A=e.brand.name?.trim()||e.name,M=Re({mutationFn:()=>h({on:!0,slug:x(A)||`page`,title:A,...ct(ve===`de`?`de-du`:`en`),wizards:w.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),N=e=>{o?g.mutate({on:e}):e&&M.mutate()},P=g.isPending||M.isPending,F=g.error??M.error;if(!r)return(0,Q.jsx)(be,{id:`page`,children:(0,Q.jsx)(X,{title:Y(`space.page`),hint:Y(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:Y(`page.cloudOnly`)})})});let I=o?.slug||x(A)||`…`,L=Ge(r,I),z=st(r,I,i),te=(0,Q.jsxs)(`span`,{className:q(Cr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:I})]}),B=a||!o,V=(0,Q.jsxs)(je,{className:`flex flex-col gap-2.5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:Y(`page.previewTitle`)}),s?(0,Q.jsx)(it,{named:!0,label:Y(`editor.device`),value:d,onChange:e=>{f(e),Vr(e)},options:[{id:`desktop`,label:Y(`editor.deviceDesk`),icon:(0,Q.jsx)(St,{className:`size-3.5`})},{id:`tablet`,label:Y(`page.deviceTablet`),icon:(0,Q.jsx)(_n,{className:`size-3.5`})},{id:`mobile`,label:Y(`editor.devicePhone`),icon:(0,Q.jsx)(lt,{className:`size-3.5`})}]}):null]}),s?(0,Q.jsx)(Hr,{url:z,version:l,device:d}):(0,Q.jsx)(`p`,{className:$,children:Y(`page.previewOff`)}),s?(0,Q.jsx)(`p`,{className:$,children:Y(`page.previewHint`)}):null]}),H=(0,Q.jsxs)(je,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:Y(`page.inShare`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:Y(`share.onPage`,{space:o?.title||A})}),(0,Q.jsx)(`span`,{className:q(`block truncate font-mono`,$),children:L})]}),(0,Q.jsx)(W,{checked:!0,disabled:!0,label:Y(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:Y(`page.inShareHint`)})]});return(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(be,{id:`page`,children:(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`px-1`,children:[(0,Q.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:Y(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:Y(`page.intro`)})]}),(0,Q.jsxs)(je,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:q(`size-2 shrink-0 rounded-full`,s?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),te]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(j,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>C(z),children:[b?(0,Q.jsx)(_,{className:`size-3.5`}):(0,Q.jsx)(S,{className:`size-3.5`}),Y(b?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(j,{size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>window.open(z,`_blank`,`noopener`),children:[Y(`page.open`),` `,(0,Q.jsx)(xt,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(X,{title:Y(`page.sectionPage`),locked:a,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":Y(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(jr,{title:Y(`page.whoOff`),text:Y(`page.whoOffHint`),picked:!s,disabled:a||P,onPick:()=>N(!1)}),(0,Q.jsx)(jr,{title:Y(`page.whoPublic`),text:Y(`page.whoPublicHint`),picked:s,disabled:a||P,onPick:()=>N(!0)}),(0,Q.jsx)(jr,{title:Y(`page.whoMembers`),text:Y(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),F?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:F.message}):null]})]})}),V,(0,Q.jsx)(be,{id:`page-words`,children:(0,Q.jsx)(X,{title:Y(`page.sectionWords`),hint:o?void 0:Y(`page.notYet`),save:o?v:void 0,locked:B,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[o?(0,Q.jsx)(Ur,{host:r,page:o,disabled:a,save:h,onState:y},`${e.id}:${o.slug}`):(0,Q.jsx)(Or,{host:r,disabled:!0,words:{slug:I,title:A,headline:``,intro:``,voice:ve===`de`?`de-du`:`en`},onChange:()=>{}}),(0,Q.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:Y(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:Y(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[T.map((e,t)=>(0,Q.jsx)(Ar,{wizard:e,first:t===0,on:!0,disabled:B,onToggle:t=>ee(e.id,t),drag:{onDragStart:()=>O(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{D!==null&&k(D,t),O(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),E.map(e=>(0,Q.jsx)(Ar,{wizard:e,first:!1,on:!1,disabled:B,onToggle:t=>ee(e.id,t)},e.id))]}),w.length?null:(0,Q.jsx)(`p`,{className:q(`mt-2`,$),children:Y(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:q(`mt-4`,$),children:Y(`page.wizardsNote`)})]}),(0,Q.jsx)(Er,{})]})})})]}),H]})}var Gr=`results-search`,Kr={q:``,mode:``,days:0};function qr(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return ye({queryKey:[`results`,e,i],queryFn:()=>p.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Jr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(r.q);return Lt({icon:ce,label:Y(`space.resultsSearch`),run:()=>{let e=document.getElementById(Gr);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Z.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(b,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:Y(`space.resultsAllWizards`)},...e.wizards.filter(e=>e.results||e.id===t).map(e=>({value:e.id,label:`${e.title} (${e.results})`}))],className:`w-56 max-sm:w-full`}),(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,Q.jsx)(ce,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(z,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Gr,placeholder:Y(`space.resultsSearch`),"aria-label":Y(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(b,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:Y(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(b,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:Y(`space.resultsAnyTime`)},{value:`1`,label:Y(`space.resultsDay`)},{value:`7`,label:Y(`space.resultsDays`,{n:7})},{value:`30`,label:Y(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Yr({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Z.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,l=new Intl.DateTimeFormat(ve,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(X,{title:t?s(t):Y(`space.resultsAll`),hint:Y(`space.resultsHint`),plain:!0,children:[(0,Q.jsx)(Jr,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,Q.jsx)(je,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?l.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${l.format(new Date(e.doneAt))} · `,Y(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:Y(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(De,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(c,{children:Y(`run.testChip`)}):(0,Q.jsxs)(c,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(je,{children:(0,Q.jsx)(v,{children:r.q.trim()||r.mode||r.days?Y(`space.resultsNone`):Y(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(nt,{header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,Q.jsx)(c,{children:Y(`run.testChip`)}):(0,Q.jsxs)(c,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(ut,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}function Xr(e){let t=e.join(` `),[n,r]=(0,Z.useState)(e[0]);return(0,Z.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Vt(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Zr(){let[e,t]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let e=Vt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Qr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function $r({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,Q.jsx)(Ut,{icon:e.icon??Ne,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,Q.jsx)(Kt,{label:e.label,children:r},e.plugin):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function ei(){let{group:e}=ue(),[t,n]=re(),i=Ce(),a=_e(),{hash:o}=a,{project:s,loading:c}=dt(),l=Bt(),u=Qt(),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),_=jt(e)?e:void 0,y=_?void 0:l.spaceParts.find(t=>t.id===e),b=_??y?.id,x=a.state?.parts===!0,S=Ot(`pages`),C=Pt().filter(e=>S||e.id!==`page`),w=Mt(C,l).map(e=>({...e,to:`/space/${e.id}`})),T={id:`results`,label:Y(`space.results`),icon:Ct,to:`/space/results`},E=_===`results`?T:w.find(e=>e.id===b),D=t.get(`show`),O=_===`results`?2:b?D?2:1:0,k=_===`results`?1:u?Math.min(O,1):b&&h!==b&&!x?1:0,ee=Gt(k),A=Gt(O),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:m}),[d,u]),M=s?s.brand.name?.trim()||s.name:Y(`nav.project`),N=Ot(`typography`)?[]:[`typography`],P=y?l.spaceMenus[y.id]??[]:[],F=y?[{plugin:null,label:null,sections:P}]:_&&_!==`results`?It(_,l,N):[],I=_?It(_,l).filter(e=>e.plugin):[],L=Xr([...F,..._===`results`?I:[]].flatMap(e=>e.sections.map(e=>e.id))),R=_===`results`&&D&&D!==`all`?D:null,[z,te]=(0,Z.useState)(Kr),B=qr(_===`results`?s?.id:void 0,R,z),V=B.data?.wizards.find(e=>e.id===R)?.title,H=_===`data`&&D&&D!==`all`||_===`knowledge`&&D&&/^[ptfcvs]:/.test(D)?D:null,U=H?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===H.slice(2)):void 0,W=_===`knowledge`&&H&&/^[ptf]:/.test(H)?H:null,ne=Ke(_===`data`?s?.id:void 0),ie=$e(_===`knowledge`?s?.id:void 0),G=ot(H?.startsWith(`v:`)?H.slice(2):``),ae=ie.data?.categories.find(e=>e.id===(H?.startsWith(`c:`)?H.slice(2):G.data?.category.id)),K=_===`knowledge`?U?U.label():H?.startsWith(`v:`)?G.data&&`${G.data.category.name}: ${G.data.value}`:H?.startsWith(`c:`)?ae?.name:ie.data?.items.find(e=>e.key===H)?.title:ne.data?rt(ne.data).flatMap(e=>e.items).find(e=>e.key===H)?.title:void 0;Ht([..._===`results`?[]:[{label:Y(`nav.project`),to:`/space`}],...E?[{label:E.label,to:`/space/${E.id}`}]:[],...E&&(p??V??K)?[{label:p??V??K}]:[]]);let oe={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Rt({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:Y(`assistant.suggest.dataWhat`)},{label:Y(`assistant.suggest.dataWho`)},{label:Y(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:Y(`assistant.suggest.resultsFailed`)},{label:Y(`assistant.suggest.resultsCost`)},{label:Y(`assistant.suggest.resultsShare`)}]}:{},...H&&K?{open:{kind:oe[H[0]]??`item`,id:H.slice(2),label:K}}:R&&V?{open:{kind:`wizard`,id:R,label:V}}:{}});let se=_===`results`||_===`data`||H?o.slice(1):D||o.slice(1),ce=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${b}#${se}`;se&&ce.current!==e&&document.getElementById(se)&&(ce.current=e,requestAnimationFrame(()=>Qr(se,!1)))},[b,se,s?.id,l.spaceSections,P.length]),(0,Z.useEffect)(()=>{!u&&(b===`knowledge`||b===`data`)&&Vt().scrollTo({top:0})},[u,b,H]);let le=Zr();if(!b){let t=o.slice(1),n=t?At(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(r,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(r,{to:u?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&l.status!==`ready`)return null;if(e!==void 0||!u)return(0,Q.jsx)(r,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(_===`knowledge`&&!D&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(r,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let de=e=>{if(u){i({search:`?show=${e}`});return}ce.current=`${b}#${e}`,Qr(e,!0),i({search:``,hash:e},{replace:!0})},J=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),fe=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,Q.jsx)(be,{id:e.id,children:(0,Q.jsx)(X,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(zt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),pe=u?void 0:L,me=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qt,{title:M,open:k===1?E??null:null,onBack:_===`results`?void 0:()=>u?i(`/space`):g(b??null),root:{icon:Tt,label:Y(`nav.project`),backLabel:Y(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:q(Wt(ee)),children:k===0?(0,Q.jsx)(Yt,{entries:w,current:u?void 0:E,onPick:()=>g(null)}):(0,Q.jsx)(`div`,{ref:f})},k)]});return(0,Q.jsx)(Jt.Provider,{value:j,children:(0,Q.jsx)(`div`,{className:`animate-rise`,children:(0,Q.jsxs)(`div`,{className:q(`grid gap-6`,_!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[_===`results`?null:(0,Q.jsx)(`aside`,{className:q(`min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&O===2&&`hidden`,u&&A===`back`&&Wt(`back`)),style:!u&&le?{maxHeight:le-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:me}),b?(0,Q.jsxs)(`div`,{className:q(`min-w-0`,u&&O<2&&`hidden`,u&&A===`deeper`&&Wt(`deeper`)),children:[u&&_!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Zt,{label:E?.label??M,onBack:()=>i(`/space/${b}`)})}):null,_===`data`?(0,Q.jsxs)(Xt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ut,{icon:wt,label:Y(`data.all`),selected:!u&&!H,onPick:()=>J(`all`)})}),ne.data?rt(ne.data).map(e=>(0,Q.jsx)(Kt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ut,{icon:We[e.kind],label:e.title,selected:!u&&e.key===H,onPick:()=>J(e.key)},e.key))},e.key)):null,(0,Q.jsx)($r,{groups:I,current:pe,onPick:de})]}):_===`knowledge`?(0,Q.jsxs)(Xt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ut,{icon:wt,label:Y(`know.all`),selected:!(u||H),onPick:()=>J(`all`)})}),ie.data?.categories.length?(0,Q.jsx)(Kt,{label:Y(`know.categories`),children:ie.data.categories.map(e=>(0,Q.jsx)(Ut,{icon:Xe[e.type],label:e.name,badge:(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(H===`c:${e.id}`||G.data?.category.id===e.id),onPick:()=>J(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($r,{groups:I,current:u?void 0:U?.id,onPick:e=>J(`s:${e}`)})]}):(0,Q.jsx)(Xt,{children:(0,Q.jsx)($r,{groups:F,current:pe,onPick:de})}),s&&(_===`info`||_===`knowledge`)?(0,Q.jsxs)(xr,{project:s,group:_,top:!H||!!U,children:[_===`knowledge`?W?W.startsWith(`p:`)?(0,Q.jsx)(Qe,{pageId:W.slice(2),onGone:()=>J(`all`),onOpen:J},W):W.startsWith(`t:`)?(0,Q.jsx)(Ze,{tableId:W.slice(2),onGone:()=>J(`all`)},W):(0,Q.jsx)(An,{projectId:s.id,fileId:W.slice(2),readOnly:s.readOnly,onGone:()=>J(`all`)},W):ie.data?U?(0,Q.jsx)(X,{title:U.label(),hint:U.hint?.(),plain:!0,children:(0,Q.jsx)(zt,{of:U,children:(0,Q.jsx)(U.component,{})})},H):H?.startsWith(`c:`)?ae?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(Ye,{projectId:s.id,category:ae,readOnly:s.readOnly,onOpen:J,onGone:()=>J(`all`)}),ae.type===`choice`?null:(0,Q.jsx)(at,{projectId:s.id,category:ae,categories:ie.data.categories,onOpen:J})]},H):null:H?.startsWith(`v:`)?G.data?(0,Q.jsx)(Ue,{value:G.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[G.data.items.length?(0,Q.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:G.data.items.map(e=>(0,Q.jsx)(qe,{item:e,categories:ie.data.categories.filter(e=>e.id!==G.data?.category.id),onOpen:J},e.key))}):null,G.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>J(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:Y(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},H):null:(0,Q.jsx)(be,{id:`documents`,children:(0,Q.jsx)(tt,{projectId:s.id,data:ie.data,readOnly:s.readOnly,onOpen:J})}):null:null,_===`info`?fe(I):null]},s.id):null,s&&_===`page`&&S?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Wr,{project:s},s.id),fe(I)]}):null,s&&y?(0,Q.jsx)(zt,{of:y,children:(0,Q.jsx)(kt,{part:y.id,children:(0,Q.jsx)(y.component,{})},s.id)}):null,s&&_===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:H?.startsWith(`t:`)?(0,Q.jsx)(Ze,{tableId:H.slice(2),onGone:()=>J(`all`)},H):H?.startsWith(`p:`)?(0,Q.jsx)(Qe,{pageId:H.slice(2),onGone:()=>J(`all`)},H):(0,Q.jsxs)(Q.Fragment,{children:[ne.data?(0,Q.jsx)(et,{projectId:s.id,data:ne.data,readOnly:s.readOnly,onOpen:J}):null,fe(I)]})}):null,s&&_===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[B.data?(0,Q.jsx)(Yr,{data:B.data,wizardId:R,onWizard:e=>J(e??`all`),filter:z,onFilter:te}):null,B.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:B.error.message}):null,fe(I)]}):null,s||c?null:(0,Q.jsx)(v,{children:Y(`settings.noProject`)})]}):null]})})})}export{ei as ProjectPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,G as i,Kr as a,Ln as o,Mt as s,Rt as c,Ut as l,Y as u,Yr as d,Yt as f,an as p,at as m,cr as h,en as g,et as _,ii as ee,ln as v,oi as y,ot as te,ri as b,sn as x,tt as S}from"./ui-BIWmkPh6.js";import{_ as C,b as w,d as T,f as ne,g as E,h as D,m as O,n as re,p as ie,v as k,y as A}from"./theme-2XjIQXH3.js";import{O as ae,S as j,b as M,x as N}from"./session-BpsCkDv6.js";import{$ as P}from"./index-Bjn557f1.js";var F={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};F.node;var oe=d(F),I={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};I.node;var se=d(I),L=e(t(),1);function ce(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var R=ce(),le=R?new URLSearchParams(window.location.search).get(`page`):null,z=new URLSearchParams(window.location.search).get(`theme`),B=z?`?theme=${encodeURIComponent(z)}`:``,V=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),ue=()=>V(`close`);function de(e){(0,L.useEffect)(()=>{if(R===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>V(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(R===`modal`||R===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&V(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var H=e(n(),1),U=`wizards.runner.translate`,W=new Set;function fe(){try{return localStorage.getItem(U)===`on`}catch{return!1}}function pe(e){try{localStorage.setItem(U,e?`on`:`off`)}catch{}for(let e of W)e()}function me(){return(0,L.useSyncExternalStore)(e=>(W.add(e),()=>W.delete(e)),fe)}function he(e){let t=me(),[n]=(0,L.useState)(()=>v()),r=e?.lang??`en`,a=e?.translatable&&n&&n!==r?n:null,s=a&&t?a:r,c=e?.token,l=y({queryKey:[`public-translation`,c,s],enabled:!!(c&&s!==r),queryFn:()=>i.post(`/api/public/wizards/${c}/translation${B}`,{lang:s}),staleTime:1/0,retry:!1}),u=y({queryKey:[`public-texts`,c,s],enabled:!(!c||o(s)),queryFn:()=>i.get(`/api/public/wizards/${c}/texts/${s}`),staleTime:1/0,retry:!1}),d=!o(s),f=s===r||l.data&&(!d||u.data),m=s!==r&&(l.isError||d&&u.isError),h=f&&!m?s:r,g=(0,L.useMemo)(()=>!o(h)&&u.data?.lang===h?{lang:u.data.lang,runner:u.data.runner,notes:u.data.notes}:null,[h,u.data]);if((0,L.useEffect)(()=>{e&&p(h,g)},[e,h,g]),(0,L.useEffect)(()=>()=>p(null),[]),!e)return null;let _=h!==r&&l.data?l.data:null;return{own:r,other:a,shown:h,wizard:_??e,translating:s!==r&&!f&&!m,failed:!!m,translated:!!_,machine:_?.translation?.machine??!1,pick:e=>pe(e!==r)}}function G({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,H.jsx)(P,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function K({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,H.jsx)(`p`,{className:g(`text-ink-3`,n),children:x(`translation.failed`)}):e.translated?(0,H.jsxs)(`p`,{className:g(`text-ink-3`,n),children:[e.machine?(0,H.jsxs)(H.Fragment,{children:[x(`translation.machine`),` · `]}):null,(0,H.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:x(`translation.showOriginal`)})]}):null}function ge(e,t){let n=(0,L.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,L.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,i.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function _e(e,t){(0,L.useEffect)(()=>{if(!e||!t)return;let n=_(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var q=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,J=q||/Android/.test(navigator.userAgent);function ve(){let[e,t]=(0,L.useState)(()=>window.wizardInstall??null),[n,r]=(0,L.useState)(!1);if((0,L.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||J&&!e&&!q)return null;let i=/Mac/.test(navigator.platform),a=x(J?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,H.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{J&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[J?(0,H.jsx)(se,{className:`size-4`}):(0,H.jsx)(oe,{className:`size-4`}),x(J?`install.add`:`install.bookmark`)]}),n?(0,H.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function Y({brand:e,toggle:t=!0,start:n}){return(0,H.jsx)(`header`,{className:`safe-top`,children:(0,H.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,H.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,H.jsx)(`img`,{src:_(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,H.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,H.jsx)(`div`,{className:`absolute right-3`,children:(0,H.jsx)(j,{})}):null]})})}function X({siteKey:e,onToken:t}){let n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,H.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function ye({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||S||R?null:(0,H.jsxs)(`a`,{href:m(`${window.location.origin}${u}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,H.jsx)(w,{className:`size-4`}),` `,x(`install.app`)]})}var Z=e=>`wz.run.${e}`,be=S&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=R===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=b(),[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(null),d=(()=>{try{return localStorage.getItem(Z(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:u,start:async()=>{o(!0),c(null);try{let{runId:a}=await i.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:R!==null,origin:le??void 0,lang:n??void 0});try{localStorage.setItem(Z(e.token),a)}catch{}r(`${t}/${a}`,{replace:be})}catch(e){c(e.message),o(!1)}},resume:d?()=>r(`${t}/${d}`):null}}function xe({wizard:e,page:t}){let{busy:n,error:r,captcha:i,setCaptcha:o,start:s,resume:l}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),u=be&&e.available&&!e.turnstileSiteKey,d=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{u&&!d.current&&(d.current=!0,s())},[u]),u&&!r?(0,H.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,H.jsx)(f,{})}):(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,H.jsx)(N,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,H.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,H.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(K,{page:t})}),e.available?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(c,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:s,children:[x(`run.start`),` `,(0,H.jsx)(a,{className:`size-4`})]}),e.turnstileSiteKey?(0,H.jsx)(X,{siteKey:e.turnstileSiteKey,onToken:o}):null,l?(0,H.jsx)(`button`,{type:`button`,onClick:l,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:x(`run.resume`)}):null,(0,H.jsx)(Se,{wizard:e,current:`steps`}),R||S?null:(0,H.jsx)(ve,{}),(0,H.jsx)(ye,{token:e.token})]}):(0,H.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??x(`run.unavailable`)}),r?(0,H.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:r}):null]})}function Se({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,H.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,H.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:x(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=A();return(0,H.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,H.jsx)(`span`,{className:g(n?.speaking&&`animate-breathe`),children:(0,H.jsx)(N,{kind:e.avatar,costume:e.costume,size:38})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,H.jsx)(K,{page:t,small:!0})]}),e.brand.logoUrl&&R!==`popout`?(0,H.jsx)(`img`,{src:_(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,H.jsx)(G,{page:t,tone:`surface`}),R?null:(0,H.jsx)(j,{}),R===`popout`?(0,H.jsx)(l,{label:x(`common.close`),onClick:ue,children:(0,H.jsx)(h,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:o,error:s,captcha:c,setCaptcha:l,start:u,resume:d}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),f=[{key:`hello`,who:`bot`,node:t.description||t.title}];return e!==`chat`&&f.push({key:e,who:`bot`,node:x(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??x(`run.unavailable`)}),s&&f.push({key:`error`,who:`bot`,node:s,tone:`error`}),t.available&&f.push(k(`start`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(E,{primary:!0,busy:o,disabled:!!t.turnstileSiteKey&&!c,onClick:()=>void u(),children:[x(`run.start`),` `,(0,H.jsx)(a,{className:`size-4`})]}),d?(0,H.jsx)(E,{onClick:d,children:x(`run.resume`)}):null,t.turnstileSiteKey?(0,H.jsx)(X,{siteKey:t.turnstileSiteKey,onToken:l}):null]}))),(0,H.jsxs)(O,{header:r,footer:i,children:[(0,H.jsx)(C,{avatar:t.avatar,costume:t.costume,lines:f}),(0,H.jsx)(D,{})]})}function Te({className:e}){return(0,H.jsx)(`footer`,{className:g(`text-center text-ink-4`,e),children:(0,H.jsx)(`a`,{href:`${u}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:x(`run.madeWith`).replace(`engenty wizards`,M.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:a=!1}){let{token:o,runId:l}=ee(),d=b(),p=y({queryKey:[`public`,o,B],queryFn:()=>i.get(`/api/public/wizards/${o}${B}`),retry:(e,t)=>s(t)&&e<3}),m=p.data?.runners??[],h=!p.data||m.some(e=>e.id===`talk`),_=!p.data||m.some(e=>e.id===`video`),v=!p.data||m.some(e=>e.id===`chat`)||n&&h||a&&_,C=m[0]?.id,w=e||R===`popout`||!t&&!l&&v&&(C===`chat`||C===`talk`||C===`video`),E=a&&_||!t&&!e&&!n&&C===`video`,D=!E&&(n&&h||!t&&!e&&C===`talk`),O=E?`video`:D?`talk`:`chat`,k=he(p.data);ge(l,k),re(p.data?.brand.theme),ae(p.data?.avatar),_e(o,p.data?.title),de(w);let A=k?.wizard.title??p.data?.title;if((0,L.useEffect)(()=>{A&&(document.title=A)},[A]),(0,L.useEffect)(()=>{o&&l&&te(`run`,{token:o,runId:l})},[o,l]),p.isLoading)return(0,H.jsx)(`div`,{className:g(`flex items-center justify-center text-ink-4`,Q),children:(0,H.jsx)(f,{})});if(e&&p.data&&!v||n&&p.data&&!h||a&&p.data&&!_)return(0,H.jsx)(r,{to:`/w/${o}`,replace:!0});if(!p.data){let e=s(p.error);return(0,H.jsxs)(`div`,{className:g(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,H.jsx)(N,{kind:`pebble`,size:80}),(0,H.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:x(e?`common.offline`:`run.notFound`)}),e?(0,H.jsx)(c,{variant:`secondary`,onClick:()=>void p.refetch(),children:x(`common.retry`)}):null]})}let j=k?.wizard??p.data,P=k?.translating?(0,H.jsxs)(`div`,{className:g(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,H.jsx)(f,{}),(0,H.jsx)(`p`,{className:`text-[0.875rem]`,children:x(`translation.working`)})]}):null;if(w){let e=(0,H.jsx)(Ce,{wizard:j,page:k}),t=S?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,H.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,H.jsx)(T,{effects:p.data.brand.theme.effects}),P??(l?(0,H.jsx)(ie,{runId:l,talk:D,call:E?`video`:D?`audio`:!1,onRestart:()=>d(`/w/${o}/${O}`),header:E||D?void 0:e,footer:t}):(0,H.jsx)(we,{wizard:j,page:k,header:e,footer:t,door:O}))]})}return(0,H.jsxs)(`div`,{className:g(`wizard-page flex flex-col`,Q),children:[(0,H.jsx)(T,{effects:p.data.brand.theme.effects}),R===`inline`||S?null:(0,H.jsx)(Y,{brand:p.data.brand,toggle:!R,start:(0,H.jsx)(G,{page:k})}),R===`inline`||S?(0,H.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,H.jsx)(G,{page:k,tone:`surface`})}):null,l&&(k?.translated||k?.failed)?(0,H.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,H.jsx)(K,{page:k})}):null,(0,H.jsx)(`div`,{className:`flex-1`,children:P??(l?(0,H.jsx)(ne,{runId:l,onRestart:()=>d(`/w/${o}`)}):(0,H.jsx)(xe,{wizard:j,page:k}))}),S?(0,H.jsx)(`div`,{className:`safe-bottom`}):(0,H.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,H.jsx)(`a`,{href:`${u}/`,target:R?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:x(`run.madeWith`).replace(`engenty wizards`,M.name)})})]})}export{Y as BrandHeader,Ee as PublicRunner};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Yr as n,sn as r}from"./ui-BIWmkPh6.js";import{Pt as i}from"./index-Bjn557f1.js";var a={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};a.node;var o=n(a),s=e(t(),1);function c(e){return r(e.origin===`local`?`readonly.project`:`readonly.server`)}function l({children:e}){return(0,s.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-amber-tint px-4 py-3 font-medium text-[0.875rem] text-ink leading-relaxed`,children:[(0,s.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-amber`}),(0,s.jsx)(`p`,{className:`min-w-0`,children:e})]})}export{c as n,o as r,l as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-9VcgySrQ.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BIWmkPh6.js","assets/preload-helper-DpV6A1kQ.js","assets/logo-CGNoptDg.js","assets/engenty-CNjaZCVM.js","assets/index-Bjn557f1.js","assets/Marketplace-DTSg7_U7.js","assets/useMutation-CD7HmAxR.js","assets/volume-2-D2To9w5D.js","assets/coins-DQ91VJAB.js","assets/session-BpsCkDv6.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/index-DN0VMwsS.css","assets/settings-menu-CoLUNJGQ.js","assets/ChangelogDialog-BXvT2VMU.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$r as r,Bt as i,Cn as a,Cr as o,G as s,Hr as c,Ht as l,Jt as u,Kr as d,Kt as f,Lr as p,Nr as m,Or as h,Rt as g,Tn as _,Ut as v,Vr as y,W as b,Wt as x,Yr as S,Yt as C,Zr as w,Zt as ee,ai as te,br as ne,dr as re,en as T,gr as ie,ii as ae,ji as E,nn as D,oi as O,ri as oe,sn as k,vr as se,y as ce,zr as le,zt as A}from"./ui-BIWmkPh6.js";import{C as ue,b as de,w as fe}from"./Marketplace-DTSg7_U7.js";import{t as j}from"./useMutation-CD7HmAxR.js";import{t as pe}from"./preload-helper-DpV6A1kQ.js";import{n as me,r as he,t as ge}from"./volume-2-D2To9w5D.js";import{n as _e,r as ve,t as ye}from"./wrench-B98ubRvB.js";import{t as M}from"./coins-DQ91VJAB.js";import{d as be,g as xe,n as Se,p as Ce,y as we}from"./session-BpsCkDv6.js";import{n as Te,r as Ee,t as De}from"./ReadOnly-E-h9y_QO.js";import{At as Oe,B as ke,Et as Ae,G as je,H as Me,J as Ne,K as Pe,M as Fe,N as Ie,Pt as Le,Q as Re,Rt as ze,U as Be,V as Ve,W as He,X as N,Y as P,Z as Ue,_ as We,_t as Ge,at as Ke,b as qe,bt as Je,it as Ye,j as Xe,l as Ze,q as Qe,rt as $e,s as et,u as tt,vt as nt,y as rt,z as F}from"./index-Bjn557f1.js";import{a as I,c as it,d as at,f as ot,i as L,l as st,n as ct,o as lt,r as ut,s as dt,t as ft,u as pt}from"./settings-menu-CoLUNJGQ.js";import{t as mt}from"./Harness-DYviBlHB.js";var ht={name:`ear`,size:24,node:[[`path`,{d:`M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0`,key:`1dfaln`}],[`path`,{d:`M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4`,key:`1qnva7`}]]};ht.node;var gt=S(ht),_t={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};_t.node;var R=S(_t),vt={name:`mail-plus`,size:24,node:[[`path`,{d:`M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8`,key:`12jkf8`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}],[`path`,{d:`M19 16v6`,key:`tddt3s`}],[`path`,{d:`M16 19h6`,key:`xwg31i`}]]};vt.node;var yt=S(vt),bt={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};bt.node;var xt=S(bt),z=e(t(),1),B=e(n(),1);function St(){let e=tt(),[t,n]=(0,z.useState)(null),[r,a]=(0,z.useState)(null),o=async e=>{n(e??`*`),a(null);try{await Ze(e)}catch(e){a(e.message)}finally{n(null)}};return(0,B.jsxs)(ce,{title:k(`plugins.title`),hint:e.canReload?k(`plugins.hint`):k(`plugins.hintManaged`),action:e.canReload?(0,B.jsx)(g,{variant:`secondary`,busy:t===`*`,onClick:()=>void o(),children:k(`plugins.rescan`)}):null,children:[e.plugins.length||e.problems.length?null:(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:k(`plugins.none`)}),(0,B.jsxs)(`ul`,{className:`divide-y divide-border-soft`,children:[e.plugins.map(n=>{let r=e.failed[n.id];return(0,B.jsxs)(`li`,{className:`flex items-start gap-4 py-4 first:pt-0 last:pb-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,B.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:n.name}),n.name===n.id?null:(0,B.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-4`,children:[n.id,` · `,n.version]})]}),n.description?(0,B.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:n.description}):null,n.tools.length?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[k(`plugins.tools`),n.tools.map(e=>(0,B.jsx)(i,{children:e.id},e.id))]}):null,n.error?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:k(`plugins.serverFailed`,{error:n.error})}):null,r?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:k(`plugins.studioFailed`,{error:r})}):null]}),e.canReload?(0,B.jsx)(v,{label:k(`plugins.reload`),disabled:t!==null,onClick:()=>void o(n.id),children:(0,B.jsx)(xt,{className:t===n.id?`size-4 animate-spin`:`size-4`})}):null]},n.id)}),e.problems.map(e=>(0,B.jsxs)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,B.jsx)(i,{tone:`warn`,children:k(`plugins.problems`)}),(0,B.jsx)(`span`,{className:`break-all font-mono text-[0.75rem] text-ink-3`,children:e.path})]}),(0,B.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:e.message})]},e.path))]}),r?(0,B.jsx)(`p`,{className:`mt-4 text-[0.8125rem] text-rose`,children:r}):null]})}var Ct=[`pro-modules`],wt=`/api/studio/plugins/-/pro`,Tt={managed:`pro.held.plan`,not_installed:`pro.held.release`,release:`pro.held.release`,unconfirmed:`pro.held.unconfirmed`,plan:`pro.held.plan`},Et=e=>new Date(e).toLocaleDateString(a[D],{day:`numeric`,month:`long`});function Dt(){let e=E(),{canReload:t}=tt(),n=O({queryKey:Ct,queryFn:()=>s.get(wt),enabled:t}),r=t=>e.setQueryData(Ct,t),a=j({mutationFn:()=>s.post(`${wt}/refresh`),onSuccess:r}),o=j({mutationFn:e=>s.post(`${wt}/${e}`),onSuccess:r}),c=j({mutationFn:e=>s.del(`${wt}/${e}`),onSuccess:r}),l=n.data,u=o.isPending||c.isPending,d=o.error??c.error??a.error;return t?(0,B.jsx)(ce,{title:k(`pro.title`),hint:k(`pro.hint`),action:l?.linked?(0,B.jsx)(g,{variant:`secondary`,busy:a.isPending,onClick:()=>a.mutate(),children:k(`pro.check`)}):null,children:n.isError?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:k(`pro.failed`,{error:n.error.message})}),(0,B.jsx)(g,{variant:`secondary`,onClick:()=>void n.refetch(),children:k(`pro.retry`)})]}):l?l.linked?(0,B.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,B.jsxs)(`span`,{children:[l.plan?k(`pro.plan`,{plan:l.plan.name}):null,l.plan&&l.expiresAt?` · `:null,l.expiresAt?k(`pro.confirmedUntil`,{date:Et(l.expiresAt)}):null]}),(0,B.jsxs)(g,{variant:`ghost`,onClick:()=>F(`${l.accountUrl}/billing`),children:[k(`pro.plans`),` `,(0,B.jsx)(m,{className:`size-4`})]})]}),l.error?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:l.error}):null,l.modules.length?(0,B.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:l.modules.map(e=>(0,B.jsxs)(`li`,{className:`flex items-start gap-4 py-4 first:pt-0 last:pb-0`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,B.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.name}),(0,B.jsxs)(`span`,{className:`font-mono text-[0.75rem] text-ink-4`,children:[e.id,` · `,e.installed?.version??e.version]}),e.loaded?(0,B.jsx)(i,{tone:`live`,children:k(`pro.on`)}):null,e.included?null:(0,B.jsx)(i,{children:k(`pro.notInPlan`)}),e.installed&&e.heldBack&&e.included?(0,B.jsx)(i,{tone:`warn`,children:k(Tt[e.heldBack])}):null]}),e.description?(0,B.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:e.description}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.included&&(!e.installed||e.update)?(0,B.jsx)(g,{busy:o.isPending&&o.variables===e.id,disabled:u,onClick:()=>o.mutate(e.id),children:e.installed?k(`pro.update`):k(`pro.install`)}):null,e.installed?(0,B.jsx)(g,{variant:`secondary`,busy:c.isPending&&c.variables===e.id,disabled:u,onClick:()=>c.mutate(e.id),children:k(`pro.remove`)}):null]})]},e.id))}):(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:k(`pro.none`,{runtime:l.runtime})}),d?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:d.message}):null]}):(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:k(`pro.notLinked`)}):(0,B.jsx)(C,{})}):null}function Ot({connector:e}){let[t,n]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-3 px-3 py-2 text-left`,children:[(0,B.jsx)(`span`,{className:T(`size-2 shrink-0 rounded-full`,e.usable?`bg-moss`:`bg-ink-4`)}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem]`,children:[e.name,` `,(0,B.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:e.id})]}),(0,B.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:e.usable?k(`connectors.actions`,{n:e.actions.length,r:e.actions.filter(e=>e.group===`read`).length}):k(`connectors.notSetUp`)})]}),t?(0,B.jsxs)(`div`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem]`,children:[e.missingSetup?(0,B.jsxs)(`p`,{className:`mb-1 text-ink-3`,children:[k(`connectors.setup`),` `,(0,B.jsx)(`span`,{className:`font-mono text-ink-2`,children:e.missingSetup})]}):null,(0,B.jsx)(`p`,{className:`text-ink-4`,children:e.actions.map(e=>e.group===`read`?e.id:`${e.id} (${k(`connectors.group.${e.group}`)})`).join(` · `)})]}):null]})}var kt={none:`connectors.authNone`,oauth2:`connectors.authOauth`,api_key:`connectors.authKey`};function At({projectId:e,connector:t,readOnly:n}){let r=E(),[i,a]=(0,z.useState)(!1),o=()=>r.invalidateQueries({queryKey:b.connectors(e)}),c=`/api/studio/projects/${e}/connectors/${t.id}`,l=j({mutationFn:()=>s.post(`${c}/refresh`),onSuccess:o}),u=j({mutationFn:()=>s.del(c),onSuccess:o}),d=t.actions.filter(e=>e.group===`read`).length;return(0,B.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,B.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-paper-2 text-ink-2`,children:(0,B.jsx)(me,{className:`size-4`})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`min-w-0 flex-1 text-left`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:t.name}),(0,B.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:t.id})]}),(0,B.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t.domain,` · `,t.sourceKind===`mcp`?`MCP`:`OpenAPI`,` ·`,` `,k(kt[t.auth]),` ·`,` `,t.toolsPending?k(`connectors.pending`):k(`connectors.actions`,{n:t.actions.length,r:d})]})]}),n?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(v,{label:k(`connectors.refresh`),onClick:()=>l.mutate(),children:l.isPending?(0,B.jsx)(C,{className:`size-4`}):(0,B.jsx)(se,{className:`size-4`})}),(0,B.jsx)(v,{label:k(`connectors.remove`),className:`hover:text-rose`,onClick:()=>confirm(k(`connectors.removeConfirm`,{name:t.name}))&&u.mutate(),children:(0,B.jsx)(re,{className:`size-4`})})]})]}),t.needsOAuthClient?(0,B.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:k(`connectors.needsClient`)}):null,l.error??u.error?(0,B.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:(l.error??u.error).message}):null,i&&t.actions.length?(0,B.jsx)(`ul`,{className:`max-h-64 overflow-y-auto border-border-soft border-t px-3 py-2`,children:t.actions.map(e=>(0,B.jsxs)(`li`,{className:`flex items-baseline gap-2 py-1 text-[0.75rem]`,children:[(0,B.jsx)(`span`,{className:T(`w-14 shrink-0 text-[0.6875rem] uppercase tracking-wide`,e.group===`read`?`text-moss`:e.group===`write`?`text-ink-3`:`text-rose`),children:k(`connectors.group.${e.group}`)}),(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-ink-2`,children:e.id}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-ink-4`,children:e.summary})]},e.id))}):null]})}function jt({projectId:e,domain:t,source:n,taken:r,onDone:a}){let o=E(),[c,l]=(0,z.useState)({id:``,secret:``}),[u,d]=(0,z.useState)(!1),f=r.includes(n.suggestedId),p=j({mutationFn:()=>s.post(`/api/studio/projects/${e}/connectors`,{domain:t,sourceKind:n.sourceKind,sourceUrl:n.sourceUrl,id:n.suggestedId,toolPrefix:n.suggestedToolPrefix,...n.name?{name:n.name}:{},...c.id&&c.secret?{oauthClientId:c.id,oauthClientSecret:c.secret}:{}}),onSuccess:async t=>{await o.invalidateQueries({queryKey:b.connectors(e)}),a(t.warnings)}});return(0,B.jsxs)(`div`,{className:`rounded-lg bg-card p-3 ring-1 ring-border-soft`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(i,{tone:n.sourceKind===`mcp`?`ember`:`neutral`,children:n.sourceKind===`mcp`?`MCP`:`OpenAPI`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-[0.8125rem]`,children:n.name??n.suggestedId}),(0,B.jsx)(`div`,{className:`truncate font-mono text-[0.6875rem] text-ink-4`,children:n.sourceUrl})]}),n.blocked||f?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:k(`connectors.ownClient`)}),(0,B.jsx)(g,{size:`sm`,busy:p.isPending,onClick:()=>p.mutate(),children:k(`connectors.import`)})]})]}),n.blocked?(0,B.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:n.blocked}):null,f?(0,B.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:k(`connectors.exists`)}):null,u?(0,B.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,B.jsx)(x,{placeholder:k(`connectors.clientId`),value:c.id,onChange:e=>l(t=>({...t,id:e.target.value}))}),(0,B.jsx)(x,{type:`password`,autoComplete:`off`,placeholder:k(`connectors.clientSecret`),value:c.secret,onChange:e=>l(t=>({...t,secret:e.target.value}))})]}):null,p.error?(0,B.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-rose`,children:p.error.message}):null]})}function Mt({projectId:e,readOnly:t}){let n=Ge(`unsetConnectors`),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(null),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)([]),f=O({queryKey:b.connectors(e),queryFn:()=>s.get(`/api/studio/projects/${e}/connectors`)}),p=j({mutationFn:()=>s.post(`/api/studio/connectors/search`,{query:r}),onSuccess:e=>{o(e),l(null),d([])}}),m=j({mutationFn:e=>s.get(`/api/studio/connectors/registry/${encodeURIComponent(e)}`),onSuccess:l}),h=f.data??[],_=h.filter(e=>e.sourceKind===`builtin`&&(n||e.usable)),v=h.filter(e=>e.sourceKind!==`builtin`);return(0,B.jsxs)(A,{className:`p-4 sm:p-6`,children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:k(`connectors.title`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:k(`connectors.hint`)}),_.length?(0,B.jsx)(`div`,{className:`mb-5 grid gap-1.5 sm:grid-cols-2`,children:_.map(e=>(0,B.jsx)(Ot,{connector:e},e.id))}):null,(0,B.jsx)(`h3`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.07em]`,children:k(`connectors.imported`)}),v.length?(0,B.jsx)(`div`,{className:`mb-4 flex flex-col gap-2`,children:v.map(n=>(0,B.jsx)(At,{projectId:e,connector:n,readOnly:t},n.id))}):null,t?v.length?null:(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:k(`connectors.noneImported`)}):(0,B.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),r.trim()&&p.mutate()},children:[(0,B.jsx)(x,{value:r,placeholder:k(`connectors.search`),onChange:e=>i(e.target.value)}),(0,B.jsxs)(g,{type:`submit`,variant:`secondary`,busy:p.isPending,children:[(0,B.jsx)(ie,{className:`size-4`}),` `,k(`connectors.find`)]})]}),p.error?(0,B.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:p.error.message}):null,a&&!c?(0,B.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[a.length?null:(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:k(`connectors.none`)}),a.map(e=>(0,B.jsxs)(`button`,{type:`button`,disabled:!e.kinds.length,onClick:()=>m.mutate(e.domain),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-paper-2 disabled:opacity-50`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:e.domain}),(0,B.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.description})]}),(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4 uppercase`,children:e.kinds.join(` · `)}),(0,B.jsx)(y,{className:`-rotate-90 size-4 text-ink-4`})]},e.domain)),m.isPending?(0,B.jsx)(C,{className:`mx-auto mt-2 size-4 text-ink-4`}):null,m.error?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:m.error.message}):null]}):null,c?(0,B.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,B.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:c.domain}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:k(`run.back`)})]}),c.summary?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:c.summary}):null,c.sources.map(t=>(0,B.jsx)(jt,{projectId:e,domain:c.domain,source:t,taken:h.map(e=>e.id),onDone:d},`${t.sourceKind}:${t.sourceUrl}`)),c.credentials.filter(e=>e.setup||e.url).map(e=>(0,B.jsxs)(`p`,{className:`text-[0.75rem] text-ink-3`,children:[(0,B.jsxs)(`span`,{className:`text-ink-2`,children:[e.label,`:`]}),` `,e.setup,` `,e.url?(0,B.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-ember underline`,children:e.url}):null]},e.label)),u.map(e=>(0,B.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:e},e))]}):null]})}var Nt=e=>new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),V=`engenty-wizards`,Pt=`wizards`,Ft=`engenty wizards`,It=`ENGENTY_WIZARDS_KEY`,Lt=[{id:`claude-desktop`,name:`Claude Desktop`,widgets:!0,connector:!0},{id:`claude-code`,name:`Claude Code`,widgets:!1},{id:`codex`,name:`Codex · ChatGPT app`,widgets:!1},{id:`cursor`,name:`Cursor`,widgets:!0},{id:`vscode`,name:`VS Code (Copilot)`,widgets:!0},{id:`windsurf`,name:`Windsurf`,widgets:!1},{id:`antigravity`,name:`Antigravity`,widgets:!1},{id:`goose`,name:`Goose`,widgets:!0},{id:`openclaw`,name:`OpenClaw`,widgets:!1},{id:`lm-studio`,name:`LM Studio`,widgets:!1},{id:`claude-ai`,name:`claude.ai`,widgets:!0,oauth:!0},{id:`chatgpt`,name:`ChatGPT`,widgets:!0,oauth:!0}],Rt={"claude-ai":{open:`https://claude.ai/settings/connectors`,where:`integrate.claudeAiWhere`,host:`claude.ai`},"claude-desktop":{where:`integrate.desktopWhere`,host:`claude.ai`},chatgpt:{where:`integrate.chatgptWhere`,host:`chatgpt.com`}};function H({text:e,muted:t}){let[n,r]=(0,z.useState)(!1);return(0,B.jsxs)(`div`,{className:T(`flex items-start gap-2 rounded-lg bg-paper-2 p-3`,t&&`text-ink-3 opacity-80`),children:[(0,B.jsx)(`code`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-[0.75rem] leading-relaxed`,children:e}),(0,B.jsx)(v,{label:k(n?`settings.copied`:`settings.copy`),onClick:async()=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)},children:n?(0,B.jsx)(c,{className:`size-4`}):(0,B.jsx)(p,{className:`size-4`})})]})}function zt(e){try{let t=new URL(e);return t.protocol===`https:`&&!/(^|\.)localhost$/.test(t.hostname)&&!/^(127\.|10\.|192\.168\.|\[::1\])/.test(t.hostname)}catch{return!1}}function U({children:e}){return(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-relaxed`,children:e})}function Bt({title:e,children:t}){return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2.5 border-border-soft border-t pt-5 first:border-t-0 first:pt-0`,children:[(0,B.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:e}),t]})}var Vt=`https://github.com/engenty/engenty-wizards-wp-plugin/releases/latest/download/engenty-wizards.zip`;function Ht({managed:e}){return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:`WordPress`}),(0,B.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-2`,children:k(`integrate.wpIntro`)})]}),(0,B.jsxs)(A,{className:`flex flex-col gap-5 p-5`,children:[(0,B.jsxs)(Bt,{title:k(`integrate.wpInstall`),children:[(0,B.jsx)(U,{children:k(`integrate.wpInstallHint`)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(g,{variant:`secondary`,size:`sm`,onClick:()=>window.open(Vt,`_blank`),children:k(`integrate.wpDownload`)})})]}),(0,B.jsx)(Bt,{title:k(`integrate.wpConnect`),children:(0,B.jsx)(U,{children:k(e?`integrate.wpConnectHint`:`integrate.wpConnectLocal`)})}),(0,B.jsxs)(Bt,{title:k(`integrate.wpPlace`),children:[(0,B.jsx)(U,{children:k(`integrate.wpPlaceHint`)}),(0,B.jsx)(H,{text:`[engenty_wizard id="ID" mode="modal" label="${k(`integrate.wpSampleLabel`)}"]`})]}),(0,B.jsx)(Bt,{title:k(`integrate.wpPro`),children:(0,B.jsx)(U,{children:k(`integrate.wpProHint`)})}),(0,B.jsx)(Bt,{title:k(`integrate.wpLocal`),children:(0,B.jsx)(U,{children:k(`integrate.wpLocalHint`)})})]})]})}function Ut(e,t){return JSON.stringify({[e]:{[V]:t}},null,2)}function Wt({id:e,url:t,apiKey:n}){let r=n?`Authorization: Bearer ${n}`:null,i=n?{headers:{Authorization:`Bearer ${n}`}}:{};switch(e){case`claude-code`:{let e=t.replace(/\/api\/mcp$/,`/api/claude-plugin`);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.terminal`)}),(0,B.jsx)(H,{text:`claude mcp add --transport http --scope user ${V} ${t}${r?` --header "${r}"`:``}`}),!n&&zt(t)?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.ccPlugin`)}),(0,B.jsx)(H,{text:`claude plugin marketplace add ${e}/marketplace.json`}),(0,B.jsx)(H,{text:`claude plugin install ${Pt}@${Nt(t)}`})]}):null]})}case`codex`:return n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.codexKey`)}),(0,B.jsx)(H,{text:`echo 'export ${It}=${n}' >> ~/.zshrc && source ~/.zshrc`}),(0,B.jsx)(H,{text:`codex mcp add ${V} --url ${t} --bearer-token-env-var ${It}`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.terminal`)}),(0,B.jsx)(H,{text:`codex mcp add ${V} --url ${t}`}),(0,B.jsx)(H,{text:`codex mcp login ${V}`})]});case`antigravity`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.terminal`)}),(0,B.jsx)(H,{text:`agy mcp add${r?` -H "${r}"`:``} ${V} ${t}`})]});case`cursor`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.file`,{file:`~/.cursor/mcp.json`})}),(0,B.jsx)(H,{text:Ut(`mcpServers`,{url:t,...i})})]});case`vscode`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.vscode`)}),(0,B.jsx)(H,{text:Ut(`servers`,{type:`http`,url:t,...i})})]});case`windsurf`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.file`,{file:`~/.codeium/windsurf/mcp_config.json`})}),(0,B.jsx)(H,{text:Ut(`mcpServers`,{serverUrl:t,...i})})]});case`lm-studio`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.file`,{file:`~/.lmstudio/mcp.json`})}),(0,B.jsx)(H,{text:Ut(`mcpServers`,{url:t,...i})})]});case`claude-desktop`:case`claude-ai`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`mcp.claudeAi`)}),(0,B.jsx)(H,{text:t})]});case`chatgpt`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.chatgpt`)}),(0,B.jsx)(H,{text:t})]});default:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.generic`)}),(0,B.jsx)(H,{text:t}),r?(0,B.jsx)(H,{text:r}):null]})}}function Gt(){let e=E(),t=O({queryKey:[`api-keys`],queryFn:()=>s.get(`/api/studio/api-keys`)}),n=j({mutationFn:e=>s.del(`/api/studio/api-keys/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:[`api-keys`]})});return t.data?.length?(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:k(`mcp.keys`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-4 text-[0.875rem] text-ink-3`,children:k(`mcp.keysHint`)}),(0,B.jsx)(A,{className:`flex flex-col gap-2 p-3`,children:t.data.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg px-3 py-2`,children:[(0,B.jsx)(R,{className:`size-4 shrink-0 text-ink-4`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:e.name}),(0,B.jsxs)(`div`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:[e.start,`… ·`,` `,e.lastRequest?k(`settings.lastUsed`,{when:new Date(e.lastRequest).toLocaleString(D)}):k(`settings.neverUsed`)]})]}),(0,B.jsx)(v,{label:k(`settings.revoke`),onClick:()=>n.mutate(e.id),className:`hover:text-rose`,children:(0,B.jsx)(re,{className:`size-4`})})]},e.id))})]}):null}function Kt(e,t){return t?.toolAt?`works`:e?.connected||t?`added`:`none`}var qt={works:`done`,added:`on`,none:void 0},Jt={works:`integrate.stateWorks`,added:`integrate.stateAdded`,none:`integrate.stateNone`};function Yt({standing:e}){return e===`none`?(0,B.jsx)(`span`,{className:`w-2 text-center text-ink-4 leading-none`,children:`–`}):(0,B.jsx)(`span`,{className:T(`size-2 shrink-0 rounded-full`,e===`works`?`bg-moss`:`bg-ember`)})}function Xt(){return(0,B.jsx)(`div`,{className:`mt-5 flex flex-col gap-1.5 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.75rem] text-ink-3`,children:[`works`,`added`,`none`].map(e=>(0,B.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,B.jsx)(Yt,{standing:e}),k(Jt[e])]},e))})}function Zt({client:e,signIn:t}){let n=(e,t)=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-card px-2.5 py-1 text-[0.8125rem] text-ink-2 ring-1 ring-border-soft`,children:[e,t]}),r=(0,B.jsx)(c,{className:`size-3.5 text-moss`,strokeWidth:3});return(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[n(r,k(`integrate.outRun`)),e.widgets?n(r,k(`integrate.outWidget`)):n((0,B.jsx)(Ee,{className:`size-3.5 text-ink-3`}),k(`integrate.outText`)),t?n((0,B.jsx)(_e,{className:`size-3.5 text-ink-3`}),k(`integrate.outSignIn`)):null]})}function W({client:e,works:t,children:n}){return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:e.name}),t?(0,B.jsx)(i,{tone:`live`,icon:(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}),children:k(`integrate.works`)}):null]}),n]})}function G({n:e,state:t,title:n,children:r}){return(0,B.jsxs)(`li`,{"aria-current":t===`now`?`step`:void 0,className:T(`grid grid-cols-[28px_minmax(0,1fr)] gap-x-3.5 rounded-xl px-3 py-3`,t===`now`&&`bg-ember-tint/40 ring-1 ring-ember-strong/25`),children:[(0,B.jsx)(`span`,{className:T(`grid size-7 place-items-center rounded-full font-semibold text-[0.8125rem]`,t===`done`&&`bg-moss text-white`,(t===`now`||t===`todo`)&&`bg-primary text-primary-foreground`,t===`later`&&`bg-paper text-ink-3 ring-1 ring-border`),children:t===`done`?(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}):e}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 pt-1`,children:[(0,B.jsx)(`span`,{className:T(`font-medium text-[0.9375rem]`,t===`later`&&`text-ink-2`),children:n}),r?(0,B.jsx)(`div`,{className:T(`flex flex-col gap-2`,t===`later`&&`opacity-70`),children:r}):null]})]})}function Qt({children:e}){return(0,B.jsxs)(A,{className:`p-3 sm:p-4`,children:[(0,B.jsx)(`h3`,{className:`px-3 pt-2 pb-2 font-medium text-[0.9375rem]`,children:k(`integrate.steps`)}),(0,B.jsx)(`ol`,{className:`flex flex-col gap-1`,children:e})]})}function $t({app:e}){return(0,B.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ember-strong`,children:[(0,B.jsx)(`span`,{className:`size-2 rounded-full bg-ember`}),k(`integrate.waiting`,{app:e})]})}function en({client:e,seen:t}){let n=(e,t)=>(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e?(0,B.jsx)(c,{className:`size-3.5 text-moss`,strokeWidth:3}):(0,B.jsx)(`span`,{className:`size-2.5 rounded-full ring-2 ring-ink-4 ring-inset`}),t]});return(0,B.jsxs)(`p`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[0.8125rem] text-ink-2`,children:[n(!!t,k(`integrate.checkSeen`)),n(!!t?.toolAt,k(`integrate.checkTool`)),e.widgets?n(!!t?.widgetAt,k(`integrate.checkWidget`)):null]})}function tn(){let e=xe().data,{project:t}=be(),n=O({queryKey:[`wizards`,t?.id,!!e?.account],queryFn:()=>s.get(`/api/studio/projects/${t.id}/wizards`),enabled:!!t}).data??[];return n.find(e=>e.published)??n[0]??null}function nn({client:e,footer:t}){let n=tn(),r=n?[{label:k(`integrate.labelRun`),text:k(`integrate.askRun`,{title:n.title})},{label:k(`integrate.labelBuild`),text:k(`integrate.askBuild`)},{label:k(`integrate.labelExplain`),text:k(`integrate.askExplain`,{title:n.title})}]:[{label:k(`integrate.labelAsk`),text:k(`integrate.askTool`)},{label:k(`integrate.labelBuild`),text:k(`integrate.askBuild`)}];return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(A,{className:`flex flex-col gap-4 p-5 sm:p-6`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:k(`integrate.next`)}),(0,B.jsx)(U,{children:k(`integrate.nextHint`,{app:e.name})})]}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,B.jsxs)(`li`,{className:`grid items-start gap-1 sm:grid-cols-[5.5rem_minmax(0,1fr)] sm:gap-3`,children:[(0,B.jsx)(`span`,{className:`pt-3 text-[0.75rem] text-ink-3`,children:e.label}),(0,B.jsx)(H,{text:e.text})]},e.label))})]}),e.widgets?null:(0,B.jsxs)(`p`,{className:`flex items-start gap-3 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2 leading-relaxed`,children:[(0,B.jsx)(Ee,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),k(`integrate.textOnly`,{app:e.name})]}),t]})}function rn({children:e}){return(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-[0.8125rem] text-ink-3`,children:e})}var K=`inline-flex items-center gap-1 text-ember-strong underline-offset-2 transition hover:underline`;function an({client:e,local:t,seen:n,url:r}){let i=E(),[a,o]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(!1),f=j({mutationFn:t=>s.post(`/api/studio/local/apps/${e.id}`,{connect:t}),onSuccess:e=>l(e),onError:e=>l({ok:!1,message:e.message}),onSettled:()=>i.invalidateQueries({queryKey:[`local-apps`]})}),p=!!t?.connected,m=!!n?.toolAt;if(a)return(0,B.jsx)(on,{client:e,seen:n,url:r,onBack:()=>o(!1)});let h=t=>(0,B.jsxs)(B.Fragment,{children:[t?(0,B.jsx)(`span`,{children:k(`integrate.addedIn`,{app:e.name})}):null,(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:()=>d(!u),children:[k(`integrate.details`),(0,B.jsx)(le,{className:T(`size-3.5 transition`,u&&`rotate-90`)})]}),(0,B.jsx)(`button`,{type:`button`,className:K,disabled:f.isPending,onClick:()=>f.mutate(!1),children:k(`mcp.appsDisconnect`)})]}),_=u&&t?.where?(0,B.jsx)(`p`,{className:`w-full font-mono text-[0.6875rem] text-ink-4`,children:t.where}):null;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:e,works:m,children:(0,B.jsx)(Zt,{client:e})}),m?(0,B.jsx)(nn,{client:e,footer:(0,B.jsxs)(rn,{children:[h(!0),_]})}):(0,B.jsxs)(Qt,{children:[(0,B.jsxs)(G,{n:1,state:p?`done`:`now`,title:k(p?`integrate.connected`:`integrate.connect`,{app:e.name}),children:[p?(0,B.jsxs)(rn,{children:[h(!1),_]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:t?.installed===!1?k(`integrate.notInstalled`,{app:e.name}):k(`integrate.connectHint`,{app:e.name})}),(0,B.jsx)(`div`,{children:(0,B.jsxs)(g,{busy:f.isPending,onClick:()=>f.mutate(!0),children:[(0,B.jsx)(ne,{className:`size-4`}),` `,k(`integrate.connect`,{app:e.name})]})})]}),c&&!c.ok?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c.message}):null,c?.snippet?(0,B.jsx)(H,{text:c.snippet}):null]}),(0,B.jsx)(G,{n:2,state:n?`done`:p?`now`:`later`,title:k(`integrate.restart`,{app:e.name}),children:n?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.restartHint`)}),p?(0,B.jsx)($t,{app:e.name}):null]})}),(0,B.jsxs)(G,{n:3,state:n?`now`:`later`,title:k(`integrate.try`),children:[(0,B.jsx)(U,{children:k(`integrate.tryHint`)}),(0,B.jsx)(H,{text:k(`integrate.askTool`),muted:!n})]})]}),(0,B.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.875rem] text-ink-2`,children:[(0,B.jsx)(he,{className:`size-4 text-ink-3`}),k(`integrate.elsewhere`,{app:e.name}),(0,B.jsx)(`button`,{type:`button`,className:K,onClick:()=>o(!0),children:k(`integrate.byAddress`)})]})]})}function on({client:e,seen:t,url:n,onBack:r}){let i=E(),[a,o]=(0,z.useState)(),c=j({mutationFn:()=>s.post(`/api/studio/api-keys`,{name:e.name.slice(0,32)}),onSuccess:async e=>{o(e.key),await i.invalidateQueries({queryKey:[`api-keys`]})}}),l=(0,B.jsx)(`p`,{className:`text-[0.875rem]`,children:(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:r,children:[(0,B.jsx)(Ae,{className:`size-4`}),k(`integrate.backHere`)]})});return t?.toolAt?(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:e,works:!0,children:(0,B.jsx)(Zt,{client:e})}),(0,B.jsx)(nn,{client:e,footer:l})]}):(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:e,works:!1,children:(0,B.jsx)(Zt,{client:e})}),(0,B.jsxs)(Qt,{children:[(0,B.jsx)(G,{n:1,state:a?`done`:`now`,title:a?k(`integrate.keyReady`):k(`integrate.keyCreate`,{app:e.name}),children:a?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:k(`integrate.keyHint`,{app:e.name})}),(0,B.jsx)(`div`,{children:(0,B.jsxs)(g,{variant:`secondary`,busy:c.isPending,onClick:()=>c.mutate(),children:[(0,B.jsx)(R,{className:`size-4`}),` `,k(`integrate.keyCreate`,{app:e.name})]})})]})}),(0,B.jsx)(G,{n:2,state:a?t?`done`:`now`:`later`,title:k(`integrate.add`),children:a&&!t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Wt,{id:e.id,url:n,apiKey:a}),(0,B.jsx)(`p`,{className:`text-[0.75rem] text-ink-4`,children:k(`integrate.addressLocal`)}),(0,B.jsx)($t,{app:e.name})]}):null}),(0,B.jsxs)(G,{n:3,state:t?`now`:`later`,title:k(`integrate.try`),children:[(0,B.jsx)(U,{children:k(`integrate.tryHint`)}),(0,B.jsx)(H,{text:k(`integrate.askTool`),muted:!t})]})]}),l]})}function sn({app:e,host:t}){return(0,B.jsxs)(`div`,{"aria-hidden":`true`,className:`flex w-56 shrink-0 flex-col items-center gap-2 rounded-xl bg-paper px-4 py-3.5 text-center ring-1 ring-border-soft`,children:[(0,B.jsx)(`span`,{className:`font-display font-semibold text-[0.8125rem] leading-snug`,children:k(`integrate.consentPreview`,{app:e})}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.6875rem] text-moss`,children:[(0,B.jsx)(_e,{className:`size-3`}),t]}),(0,B.jsxs)(`span`,{className:`flex w-full gap-1.5`,children:[(0,B.jsx)(`span`,{className:`h-5 flex-1 rounded-full bg-card ring-1 ring-border`}),(0,B.jsx)(`span`,{className:`h-5 flex-1 rounded-full bg-primary`})]})]})}function cn({client:e,url:t,seen:n,tracked:r,accountUrl:i}){let a=Rt[e.id]??Rt[`claude-desktop`],o=e.id===`chatgpt`?`ChatGPT`:`Claude`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Qt,{children:[(0,B.jsx)(G,{n:1,state:`todo`,title:k(`integrate.open`,{app:e.name}),children:a.open?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsxs)(g,{onClick:()=>F(a.open),children:[k(`integrate.openConnectors`),(0,B.jsx)(m,{className:`size-4`})]}),(0,B.jsx)(U,{children:k(a.where)})]}):(0,B.jsx)(U,{children:k(a.where)})}),(0,B.jsx)(G,{n:2,state:`todo`,title:k(`integrate.nameAddress`),children:(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:k(`integrate.name`)}),(0,B.jsx)(H,{text:Ft})]}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:k(`integrate.address`)}),(0,B.jsx)(H,{text:t})]})]})}),(0,B.jsx)(G,{n:3,state:n?`done`:`todo`,title:k(`integrate.allow`),children:n?null:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,B.jsx)(`p`,{className:`min-w-0 flex-[1_1_16rem] text-[0.875rem] text-ink-3 leading-relaxed`,children:k(`integrate.allowHint`)}),(0,B.jsx)(sn,{app:o,host:a.host})]})}),(0,B.jsxs)(G,{n:4,state:n?.toolAt?`done`:n?`now`:`later`,title:k(`integrate.try`),children:[n?.toolAt?null:(0,B.jsx)(H,{text:k(`integrate.askTool`),muted:!n}),r?(0,B.jsx)(en,{client:e,seen:n}):null]})]}),i?(0,B.jsx)(ln,{accountUrl:i}):null]})}function ln({accountUrl:e}){return(0,B.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-[0.8125rem] text-ink-3`,children:[k(`integrate.revoke`),(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:()=>F(e),children:[k(`integrate.revokeLink`),(0,B.jsx)(d,{className:`size-3.5`})]})]})}function un({client:e,me:t,onDesktop:n}){let r=t.account?.signedIn?t.account:null,i=Ie(!!r),a=nt(t.features,`account`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:e,works:!1,children:(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:k(`integrate.remoteWhy`,{app:e.name})})}),r?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2 text-[0.875rem] text-ink-2`,children:[(0,B.jsx)(ze,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),k(`integrate.linked`,{email:r.email,app:e.name})]}),(0,B.jsx)(cn,{client:e,url:`${r.cloudUrl}/api/mcp`,tracked:!1,accountUrl:r.url})]}):a?(0,B.jsxs)(A,{className:`flex flex-col gap-5 p-5 sm:p-6`,children:[(0,B.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:k(`integrate.viaAccount`)}),(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{icon:Ae,title:k(`integrate.tileHere`),text:k(`integrate.tileHereText`)},{icon:ze,title:`engenty.ai`,text:k(`integrate.tileCloudText`)},{icon:Oe,title:e.name,text:k(`integrate.tileAppText`)}].map(e=>(0,B.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-paper px-4 py-3.5`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[(0,B.jsx)(e.icon,{className:`size-4 text-ink-2`}),e.title]}),(0,B.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:e.text})]},e.title))}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsxs)(g,{busy:i.link.isPending,onClick:()=>i.link.mutate({}),children:[(0,B.jsx)(ze,{className:`size-4`}),` `,k(`integrate.linkAccount`)]}),(0,B.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:k(`integrate.linkHint`,{app:e.name})})]}),(0,B.jsx)(Fe,{...i})]}):null,r?null:(0,B.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-xl bg-paper-2 px-4 py-3 text-[0.875rem] text-ink-2`,children:[k(`integrate.noAccount`),(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:n,children:[k(`integrate.useDesktop`),(0,B.jsx)(d,{className:`size-3.5`})]})]})]})}function dn({client:e,seen:t,url:n,me:r}){let i=!!t?.toolAt,a=r.manageUrl?`${r.manageUrl}/account`:null;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:e,works:i,children:(0,B.jsx)(Zt,{client:e,signIn:!0})}),i?(0,B.jsx)(nn,{client:e}):(0,B.jsxs)(Qt,{children:[(0,B.jsx)(G,{n:1,state:t?`done`:`now`,title:k(`integrate.add`),children:t?null:(0,B.jsx)(Wt,{id:e.id,url:n})}),(0,B.jsx)(G,{n:2,state:t?`done`:`later`,title:k(`integrate.allowFirst`),children:t?null:(0,B.jsx)(U,{children:k(`integrate.allowFirstHint`,{app:e.name})})}),(0,B.jsx)(G,{n:3,state:t?`now`:`later`,title:k(`integrate.try`),children:(0,B.jsx)(H,{text:k(`integrate.askTool`),muted:!t})})]}),a?(0,B.jsx)(ln,{accountUrl:a}):null]})}function fn({client:e,standing:t,onOpen:n,onConnect:r,busy:i}){return(0,B.jsxs)(A,{className:`flex flex-col gap-3 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-[10px] bg-paper-2 text-ink-2`,children:e.widgets?(0,B.jsx)(fe,{className:`size-5`}):(0,B.jsx)(ye,{className:`size-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),(0,B.jsxs)(`div`,{className:T(`flex items-center gap-1.5 text-[0.8125rem]`,t===`works`&&`font-medium text-moss`,t===`added`&&`text-ember-strong`,t===`none`&&`text-ink-3`),children:[t===`works`?(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}):null,k(Jt[t])]})]})]}),(0,B.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[e.widgets?(0,B.jsx)(fe,{className:`size-3.5`}):(0,B.jsx)(Ee,{className:`size-3.5`}),k(e.widgets?`integrate.outWidget`:`integrate.outText`)]}),(0,B.jsx)(`div`,{children:t===`none`&&r?(0,B.jsx)(g,{size:`sm`,variant:`secondary`,busy:i,onClick:r,children:k(`integrate.connectShort`)}):(0,B.jsx)(g,{size:`sm`,variant:t===`added`?`primary`:`secondary`,onClick:n,children:k(t===`works`?`integrate.view`:t===`added`?`integrate.testIt`:`integrate.connectShort`)})})]})}function pn({managed:e,here:t,web:n,standing:r,open:i}){let a=E(),o=j({mutationFn:e=>s.post(`/api/studio/local/apps/${e}`,{connect:!0}),onSettled:()=>a.invalidateQueries({queryKey:[`local-apps`]}),onSuccess:(e,t)=>i(t)}),c=(e,t)=>(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]`,children:e.map(e=>(0,B.jsx)(fn,{client:e,standing:r(e.id),onOpen:()=>i(e.id),onConnect:t?()=>o.mutate(e.id):void 0,busy:o.isPending&&o.variables===e.id},e.id))});return(0,B.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-[1.625rem] leading-tight tracking-tight`,children:k(`integrate.title`)}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:k(e?`integrate.introManaged`:`integrate.intro`)})]}),e?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:k(`integrate.groupBrowser`)}),c(n,!1)]}),(0,B.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:k(`integrate.groupDesktop`)}),c(t,!1)]})]}):(0,B.jsxs)(B.Fragment,{children:[t.length?(0,B.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:k(`integrate.found`)}),c(t,!0)]}):null,(0,B.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,B.jsx)(`h3`,{className:`font-display font-semibold text-lg`,children:k(`integrate.groupCloud`)}),(0,B.jsxs)(A,{className:`flex flex-wrap items-center gap-4 p-5`,children:[(0,B.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-[10px] bg-paper-2 text-ink-2`,children:(0,B.jsx)(ze,{className:`size-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:k(`integrate.cloudTitle`)}),(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:k(`integrate.cloudText`)})]}),(0,B.jsx)(g,{variant:`secondary`,onClick:()=>i(`claude-ai`),children:k(`integrate.cloudButton`)})]})]})]})]})}function mn(){let e=xe(),t=e.data?.mode===`managed`,n=O({queryKey:[`local-apps`],queryFn:()=>s.get(`/api/studio/local/apps`),enabled:e.data?.mode===`local`}),r=O({queryKey:[`integrations-seen`],queryFn:()=>s.get(`/api/studio/integrations/seen`),refetchInterval:2500}),[i,a]=te(),{narrow:o}=at(),c=nt(e.data?.features,`wordpress`),l=c||i.get(`show`)!==`wordpress`?i.get(`show`):null,u=Lt.find(e=>e.id===l)??null;if(st(l===`wordpress`?`WordPress`:u?.name??null),!e.data||!t&&!n.data)return null;let d=e=>n.data?.find(t=>t.id===e),f=e=>r.data?.[e],p=e=>Kt(d(e),f(e)),m=e=>a({show:e},{replace:!o}),g=e=>!!(d(e.id)?.installed||d(e.id)?.connected),_=Lt.filter(e=>e.oauth),v=Lt.filter(e=>!e.oauth&&(t||g(e))),y=t?[]:Lt.filter(e=>!e.oauth&&!g(e)),b=e.data.mcpUrl??``,x=e=>(0,B.jsx)(I,{icon:e.oauth?ze:e.widgets?fe:ye,label:e.name,tone:qt[p(e.id)],toneLabel:k(Jt[p(e.id)]),selected:e.id===u?.id,onPick:()=>m(e.id)},e.id),S=e.data.manageUrl?`${e.data.manageUrl}/account`:null,C;return C=l===`wordpress`?(0,B.jsx)(Ht,{managed:t}):u?t&&(u.oauth||u.connector)?zt(b)?(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:u,works:!!f(u.id)?.toolAt,children:(0,B.jsx)(Zt,{client:u,signIn:!0})}),f(u.id)?.toolAt?(0,B.jsx)(nn,{client:u,footer:S?(0,B.jsx)(ln,{accountUrl:S}):null}):(0,B.jsx)(cn,{client:u,url:b,seen:f(u.id),tracked:!0,accountUrl:S})]}):(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:u,works:!1}),(0,B.jsx)(U,{children:k(`integrate.needsPublic`,{app:u.name})})]}):t?(0,B.jsx)(dn,{client:u,seen:f(u.id),url:b,me:e.data}):u.oauth?(0,B.jsx)(un,{client:u,me:e.data,onDesktop:()=>m(`claude-desktop`)}):(0,B.jsx)(an,{client:u,local:d(u.id),seen:f(u.id),url:b}):(0,B.jsx)(pn,{managed:t,here:v,web:_,standing:p,open:m}),(0,B.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,B.jsxs)(dt,{children:[(0,B.jsx)(L,{label:k(t?`integrate.groupBrowser`:`integrate.groupHere`),children:(t?_:v).map(x)}),(0,B.jsx)(L,{label:k(t?`integrate.groupDesktop`:`integrate.groupCloud`),children:(t?v:_).map(x)}),y.length?(0,B.jsx)(L,{label:k(`integrate.groupMore`),collapsible:!0,open:y.some(e=>e.id===u?.id),count:y.length,children:y.map(x)}):null,(0,B.jsxs)(L,{label:k(`integrate.groupShare`),children:[(0,B.jsx)(I,{icon:h,label:k(`integrate.shareLink`),badge:(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:k(`integrate.soon`)}),selected:!1,disabled:!0}),c?(0,B.jsx)(I,{icon:he,label:`WordPress`,selected:l===`wordpress`,onPick:()=>m(`wordpress`)}):null,(0,B.jsx)(I,{icon:he,label:k(`integrate.shareSite`),badge:(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:k(`integrate.soon`)}),selected:!1,disabled:!0})]}),(0,B.jsx)(Xt,{})]}),(0,B.jsx)(`div`,{children:C},u?.id??`start`),t||l===`wordpress`?null:(0,B.jsx)(Gt,{})]})}function hn(e,t){let n=t===`auto`?e.mode===`managed`:t===`cloud`,r=t===`auto`||t===`linked`?e.account??(t===`linked`?{name:e.user.name,email:e.user.email,organization:null,credits:1250,expiring:[],url:``,cloudUrl:``,signedIn:!0}:null):null;return{cloud:n,account:n?null:r,credits:n||!!r?.signedIn,balance:n?e.credits??(t===`cloud`?1250:null):r?.credits??null,topUp:We(e),harnesses:n?[]:e.harnesses,canEdit:!n||e.tenant.role!==`member`,ownKeys:!n||nt(e.features,`ownKeys`)}}var gn={text:o,image:de,video:ue,speech:ge,listening:gt},q={text:`low`,image:`image`,video:`video`,speech:`speech`,listening:`audio`},J=e=>e===`text`;function _n(e,t){return JSON.stringify(e)===JSON.stringify(t)}function vn(e,t,n){let r=q[t];if(J(t)&&!n.cloud){if(e.bindings.low?.startsWith(`apple:`))return{kind:`local`,by:`apple`};if(e.source===`account`)return{kind:`credits`};if(e.source!==`own`)return{kind:`client`,id:e.source}}let i=e.bindings[r];if(Ne(i))return{kind:`credits`};if(i?.startsWith(`ollama:`))return{kind:`local`,by:`ollama`};if(i?.startsWith(`apple:`))return{kind:`local`,by:`apple`};let a=i?Ue(i):null;if(a)return{kind:`key`,provider:a};if(i&&/^(claude|codex|antigravity|cursor)\//.test(i))return{kind:`client`,id:i.split(`/`)[0]};let o=e.ways[r];switch(o.kind){case`client`:return{kind:`client`,id:o.by};case`key`:return N(o.by??``)?{kind:`key`,provider:o.by}:null;case`local`:return{kind:`local`,by:o.by===`apple`?`apple`:`ollama`};case`credits`:return{kind:`credits`};default:return null}}function yn(e,t,n){if(J(t)&&e.text)return e.text;let r=q[t],i=n.bindings[r],a=i&&Ue(i)===e.id?i:e.models[t]?.[0]?.ref;return a?{[r]:a}:{}}function bn(e){return e.version===null?{note:k(`models.noteMissing`),noteTone:`warn`}:e.auth===`none`?{note:k(`models.noteSignedOut`),noteTone:`warn`}:e.auth===`api_key`?{note:k(`models.noteShellKey`)}:{note:k(`models.noteIncluded`),noteTone:`done`}}function xn(e,t){switch(e.kind){case`client`:return{text:t.harnesses.find(t=>t.id===e.by)?.name??e.by??``,tone:`done`};case`key`:return{text:N(e.by??``)?.name??e.by??``,tone:`done`};case`local`:return{text:e.by===`apple`?k(`models.optApple`):k(`models.way.local`),tone:`done`};case`credits`:return{text:t.cloud?k(`models.way.creditsOrganization`):k(`models.way.credits`),tone:`ok`};default:return{text:k(`models.way.none`),tone:`warn`}}}function Sn(){return O({queryKey:[`models`],queryFn:()=>s.get(`/api/studio/models`)})}function Y(){let e=E();return j({mutationFn:e=>s.put(`/api/studio/models`,e),onSuccess:async t=>{e.setQueryData([`models`],t),await e.invalidateQueries({queryKey:[`me`]})}})}function X({title:e,aside:t,children:n}){return(0,B.jsxs)(`section`,{className:`flex flex-col gap-3 border-border-soft border-t pt-5 first:border-t-0 first:pt-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:e}),t]}),n]})}function Z({children:e}){return(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e})}function Cn({text:e,tone:t}){return(0,B.jsxs)(`span`,{className:T(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full px-3 font-medium text-[0.75rem]`,t===`done`&&`bg-moss-tint text-moss`,t===`ok`&&`bg-amber-tint text-ink-2`,t===`warn`&&`bg-paper-2 text-ink-3`),children:[t===`done`?(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}):null,t===`ok`?(0,B.jsx)(M,{className:`size-3.5`}):null,t===`warn`?(0,B.jsx)(ve,{className:`size-3.5`}):null,e]})}function wn({icon:e,title:t,lead:n,status:r}){return(0,B.jsxs)(`div`,{className:`flex items-start gap-3 sm:gap-4`,children:[(0,B.jsx)(`span`,{className:`grid size-10 shrink-0 place-items-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,B.jsx)(e,{className:`size-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight`,children:t}),r]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-[0.875rem] text-ink-3`,children:n})]})]})}function Q({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`grid items-start gap-x-4 gap-y-1.5 sm:grid-cols-[7.5rem_minmax(0,1fr)]`,children:[(0,B.jsx)(`span`,{className:`pt-2 text-[0.75rem] text-ink-3`,children:e}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t})]})}function $({selected:e,title:t,note:n,noteTone:r,disabled:i,onPick:a}){return(0,B.jsxs)(`button`,{type:`button`,onClick:a,disabled:i,"aria-pressed":e,title:n,className:T(`inline-flex h-9 items-center gap-1.5 rounded-full border px-3.5 text-[0.8125rem] transition coarse:h-11`,e?`border-ember bg-ember-tint font-medium text-ink`:r===`done`?`border-input bg-card text-ink hover:border-ink-4`:`border-border-soft border-dashed text-ink-3 hover:border-ink-4 hover:text-ink`,i&&`cursor-not-allowed opacity-50`),children:[r===`done`?(0,B.jsx)(c,{className:`size-3.5 text-moss`,strokeWidth:3}):null,t,(0,B.jsxs)(`span`,{className:`sr-only`,children:[`: `,n]})]})}function Tn({provider:e,stored:t,place:n}){let r=Y(),[i,a]=(0,z.useState)(``),[o,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(null),f=j({mutationFn:t=>s.post(`/api/studio/models/keys/${e.id}/check`,t?{key:t}:{})}),p=async()=>{d(null);let t=await f.mutateAsync(i.trim());if(!t.ok){d({ok:!1,message:t.message??k(`models.keyBad`)});return}await r.mutateAsync({keys:{[e.id]:i.trim()}}),a(``),l(!1),d({ok:!0,message:k(`models.keyOk`)})},h=!t||o;return n.ownKeys?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[h?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:e.keyPlaceholder,value:i,disabled:!n.canEdit,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&p()}}),(0,B.jsx)(g,{busy:f.isPending||r.isPending,disabled:!i.trim()||!n.canEdit,onClick:()=>void p(),children:k(`models.keySave`)}),o?(0,B.jsx)(g,{variant:`ghost`,onClick:()=>l(!1),children:k(`common.cancel`)}):null]}):(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-2 text-[0.875rem] text-ink-2`,children:[(0,B.jsx)(R,{className:`size-4 text-moss`}),` `,k(`models.keyStored`)]}),(0,B.jsx)(g,{size:`sm`,variant:`ghost`,busy:f.isPending,onClick:async()=>{let e=await f.mutateAsync(void 0);d(e.ok?{ok:!0,message:k(`models.keyOk`)}:{ok:!1,message:e.message??k(`models.keyBad`)})},children:k(`models.keyCheck`)}),n.canEdit?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>l(!0),children:k(`models.keyReplace`)}),(0,B.jsx)(g,{size:`sm`,variant:`danger`,busy:r.isPending,onClick:()=>{d(null),r.mutate({keys:{[e.id]:``}})},children:k(`models.keyRemove`)})]}):null]}),u?(0,B.jsxs)(`p`,{className:T(`flex items-center gap-1.5 text-[0.8125rem]`,u.ok?`text-moss`:`text-rose`),children:[u.ok?(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}):null,u.message]}):null,(0,B.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.75rem] text-ink-4`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>F(e.keyUrl),className:`inline-flex items-center gap-1 font-medium text-ember-strong hover:underline`,children:[k(`models.keyGet`,{name:e.name}),` `,(0,B.jsx)(m,{className:`size-3`})]}),(0,B.jsx)(`span`,{children:n.cloud?k(`models.keyWhereCloud`):k(`models.keyWhereLocal`)})]})]}):(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:k(`models.ownKeysPlan`)})}var En=`__custom__`;function Dn({provider:e,cap:t,value:n,onPick:r,disabled:i}){let a=D,o=e.models[t]??[],s=o.some(e=>e.ref===n),[c,l]=(0,z.useState)(!s&&!!n),[d,f]=(0,z.useState)(s?``:n.replace(/^[a-z]+:/,``)),p=e.id===`gateway`?``:`${e.id}:`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(u,{value:c?En:n,onChange:e=>{if(e===En){l(!0);return}l(!1),r(e)},options:[...o.map(e=>({value:e.ref,label:e.note?`${e.label} – ${Re(e.note,a)}`:e.label})),{value:En,label:k(`models.modelCustom`)}]}),c?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(x,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:d,disabled:i,placeholder:o[0]?.ref.replace(/^[a-z]+:/,``)??``,onChange:e=>f(e.target.value)}),(0,B.jsx)(g,{variant:`secondary`,disabled:!d.trim()||i,onClick:()=>r(`${p}${d.trim()}`),children:k(`settings.save`)})]}):null]})}function On({provider:e,state:t}){let n=n=>P(t.bindings[n]??e.text?.[n]??``);return(0,B.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-[0.875rem]`,children:[(0,B.jsx)(`dt`,{className:`text-ink-3`,children:k(`models.textSimple`)}),(0,B.jsx)(`dd`,{className:`truncate font-medium`,children:n(`low`)}),(0,B.jsx)(`dt`,{className:`text-ink-3`,children:k(`models.textDemanding`)}),(0,B.jsx)(`dd`,{className:`truncate font-medium`,children:n(`standard`)})]})}function kn(e,t){return t===`context`?k(`need.context`,{tokens:`${Math.round(Ve[e].context/1e3)}k`}):k(`need.${t}`)}function An({cls:e,lacks:t}){let n=[...Ve[e].needs,`context`];return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-[0.6875rem] text-ink-4 leading-snug`,children:k(`class.needs`,{needs:n.map(t=>kn(e,t)).join(`, `)})}),t?.length?(0,B.jsxs)(`div`,{className:`flex items-start gap-1 text-[0.6875rem] text-amber leading-snug`,children:[(0,B.jsx)(ve,{className:`mt-px size-3 shrink-0`}),k(`class.lacks`,{needs:t.map(t=>kn(e,t)).join(`, `)})]}):null]})}function jn({provider:e,state:t,onPick:n,disabled:r}){return(0,B.jsxs)(`details`,{className:`group rounded-lg ring-1 ring-border-soft`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer list-none px-3 py-2.5 text-[0.8125rem] text-ink-2 hover:text-ink`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(d,{className:`size-3.5 transition group-open:rotate-90`}),k(`models.perClass`)]})}),(0,B.jsx)(`div`,{className:`flex flex-col gap-3 px-3 pt-1 pb-3`,children:_.map(i=>(0,B.jsxs)(`div`,{className:`grid items-center gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[0.8125rem] text-ink-2`,children:k(`class.${i}`)}),(0,B.jsx)(`div`,{className:`text-[0.6875rem] text-ink-4 leading-snug`,children:k(`class.${i}.hint`)})]}),(0,B.jsx)(Dn,{provider:e,cap:`text`,value:t.bindings[i]??e.text?.[i]??``,disabled:r,onPick:e=>n(i,e)}),(0,B.jsx)(`div`,{className:`flex flex-col gap-0.5 sm:col-start-2`,children:(0,B.jsx)(An,{cls:i,lacks:t.fit[i]})})]},i))})]})}function Mn({cap:e,disabled:t}){let n=q[e],r=j({mutationFn:()=>s.post(`/api/studio/models/test`,{cls:n,lang:D})}),i=r.data;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(g,{variant:`secondary`,busy:r.isPending,disabled:t,onClick:()=>r.mutate(),children:k(`models.try.${e}`)}),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e===`video`?k(`models.tryCostVideo`):J(e)?null:k(`models.tryCost`)})]}),r.isPending&&e!==`text`?(0,B.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,B.jsx)(C,{className:`size-3.5`}),` `,k(e===`video`?`models.tryWaitVideo`:`models.tryWait`)]}):null,i?.ok?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.media&&e===`image`?(0,B.jsx)(`img`,{src:i.media,alt:``,className:`size-48 rounded-lg object-cover ring-1 ring-border-soft`}):null,i.media&&e===`speech`?(0,B.jsx)(`audio`,{src:i.media,controls:!0,autoPlay:!0,className:`w-full max-w-sm`}):null,i.media&&e===`video`?(0,B.jsx)(`video`,{src:i.media,controls:!0,autoPlay:!0,muted:!0,className:`w-full max-w-md rounded-lg`}):null,(0,B.jsxs)(`p`,{className:`flex items-start gap-2 text-[0.8125rem] text-ink-2`,children:[(0,B.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-moss`,strokeWidth:3}),(0,B.jsx)(`span`,{children:e===`listening`?i.reply?k(`models.tryHeard`,{text:i.reply}):k(`models.tryHeardNothing`):J(e)?k(`local.testOk`,{s:(i.ms/1e3).toFixed(1),ref:P(i.ref??``),reply:i.reply??``}):k(`models.tryOk`,{s:(i.ms/1e3).toFixed(1),model:P(i.ref??``)})})]})]}):null,i&&!i.ok?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:k(`models.tryFailed`,{error:i.error??``})}):null,r.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:k(`models.tryFailed`,{error:r.error.message})}):null]})}function Nn(e){let t=e=>(e<10?Math.round(e*10)/10:Math.ceil(e)).toLocaleString(D);return e?.creditsPerImage?k(`models.notePerImage`,{n:t(e.creditsPerImage)}):e?.creditsPerSecond?k(`models.notePerSecond`,{n:t(e.creditsPerSecond)}):e?.creditsPer1kCharacters?k(`models.notePer1k`,{n:t(e.creditsPer1kCharacters)}):e?.creditsPerMinute?k(`models.notePerMinute`,{n:t(e.creditsPerMinute)}):k(`models.noteUsage`)}function Pn(e,t){let n=Pe(t.bindings[q[e]]);return Nn((n?t.creditModels.find(e=>e.id===n):null)??t.prices?.[q[e]])}function Fn(e,t,n){return e.creditModels.filter(e=>je(e.kind)===t&&(!n||e.source===n||e.provider===n))}function In({cap:e,state:t,disabled:n}){let r=Y(),i=q[e],a=Pe(t.bindings[i]),o=Fn(t,e),s=t.prices?.[i]?.model,c=e=>e.source===`ai-gateway`?N(e.provider)?.name??e.provider:N(e.source)?.name??e.source;return(0,B.jsx)(u,{value:a??``,onChange:e=>r.mutate({bindings:{[i]:Qe(e||null)}}),options:[{value:``,label:s?k(`models.creditsAuto`,{model:P(s)}):k(`models.creditsAutoNone`)},...o.map(e=>({value:e.id,label:`${e.name} · ${c(e)} – ${Nn(e)}`,disabled:n}))]})}function Ln({models:e,state:t,place:n}){let r=Y();return(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>{let i=je(e.kind),a=q[i],o=t.bindings[a]===Qe(e.id);return(0,B.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 py-2.5`,children:[(0,B.jsx)(M,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:e.name}),(0,B.jsxs)(`span`,{className:`block text-[0.75rem] text-ink-3`,children:[k(`models.cap.${i}`),` · `,Nn(e)]})]}),o?(0,B.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}),` `,k(`models.inUse`)]}):(0,B.jsx)(g,{size:`sm`,variant:`secondary`,disabled:!n.canEdit||!n.credits,busy:r.isPending&&r.variables?.bindings?.[a]===Qe(e.id),onClick:()=>r.mutate({bindings:{[a]:Qe(e.id)}}),children:k(`models.useFor`)})]},e.id)})})}function Rn({cap:e,state:t,place:n,me:r,onOpen:i}){let a=Y(),o=q[e],s=t.ways[o],c=vn(t,e,n),[l,u]=(0,z.useState)(!1),d=xn(s,n),p=n.harnesses.filter(t=>(J(e)||e===`image`&&t.images)&&(t.version!==null||c?.kind===`client`&&c.id===t.id)),m=He.filter(t=>t.models[e]?.length),h=r=>{if(u(!1),r.kind===`credits`&&!n.credits){u(!0);return}if(_n(r,c))return;let i=ke[e],s=e=>Object.fromEntries(i.map(t=>[t,e]));switch(r.kind){case`client`:a.mutate(J(e)?{source:r.id,bindings:we(t.bindings)}:{bindings:{[o]:`${r.id}/image`}});return;case`key`:{let i=N(r.provider);a.mutate({...J(e)&&!n.cloud?{source:`own`}:{},bindings:yn(i,e,t)});return}case`local`:a.mutate(r.by===`apple`?{bindings:J(e)?zn(t):{audio:`apple:transcribe`}}:{source:`own`,bindings:s(`ollama:qwen3`)});return;case`credits`:a.mutate(J(e)&&!n.cloud?{source:`account`,bindings:we(t.bindings)}:{bindings:s(Me)});return}},g=c?.kind===`key`?N(c.provider):null,_=g?!t.keys[g.id]:!1,v=c?.kind===`client`?n.harnesses.find(e=>e.id===c.id):null,y=s.kind!==`none`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:gn[e],title:k(`models.cap.${e}`),lead:k(`models.cap.${e}.hint`),status:(0,B.jsx)(Cn,{...d})}),(0,B.jsxs)(A,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,B.jsxs)(X,{title:k(`models.who`),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p.length?(0,B.jsx)(Q,{label:k(`models.optSubscription`),children:p.map(e=>(0,B.jsx)($,{title:e.name,...bn(e),selected:c?.kind===`client`&&c.id===e.id,disabled:!n.canEdit,onPick:()=>h({kind:`client`,id:e.id})},e.id))}):null,(0,B.jsx)(Q,{label:k(`models.optKey`),children:m.map(e=>(0,B.jsx)($,{title:e.name,note:t.keys[e.id]?k(`models.noteKey`):k(`models.noteNoKey`),noteTone:t.keys[e.id]?`done`:void 0,selected:c?.kind===`key`&&c.provider===e.id,disabled:!n.canEdit,onPick:()=>h({kind:`key`,provider:e.id})},e.id))}),(0,B.jsxs)(Q,{label:J(e)&&!n.cloud?k(`models.optOther`):k(`models.optCreditsGroup`),children:[(J(e)||e===`listening`)&&!n.cloud&&t.apple?.supported?(0,B.jsx)($,{title:k(`models.optApple`),note:J(e)?Bn(t.apple):k(`models.optAppleNote`),noteTone:J(e)&&!t.apple.available?void 0:`done`,selected:c?.kind===`local`&&c.by===`apple`,disabled:!n.canEdit||J(e)&&!t.apple.available,onPick:()=>h({kind:`local`,by:`apple`})}):null,J(e)&&!n.cloud?(0,B.jsx)($,{title:k(`models.optLocal`),note:k(`models.optLocalNote`),selected:c?.kind===`local`&&c.by===`ollama`,disabled:!n.canEdit,onPick:()=>h({kind:`local`,by:`ollama`})}):null,(0,B.jsx)($,{title:n.cloud?k(`models.creditsOrganization`):k(`models.creditsName`),note:n.credits?Pn(e,t):k(`models.noteNeedsAccount`),noteTone:n.credits?`done`:void 0,selected:c?.kind===`credits`,disabled:!n.canEdit,onPick:()=>h({kind:`credits`})})]})]}),l?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:[k(`local.sourceNeedsAccount`),` `,(0,B.jsx)(Yn,{})]}):null,a.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:a.error.message}):null]}),g?(0,B.jsxs)(B.Fragment,{children:[_?(0,B.jsxs)(X,{title:k(`models.keyFor`,{name:g.name}),children:[(0,B.jsx)(Tn,{provider:g,stored:!1,place:n}),n.credits?(0,B.jsxs)(Z,{children:[(0,B.jsx)(M,{className:`mr-1 inline size-3.5 align-[-2px]`}),k(`models.keyFallback`)]}):null]}):null,_&&n.credits&&Fn(t,e,g.id).length?(0,B.jsx)(X,{title:k(`models.viaCredits`,{name:g.name}),children:(0,B.jsx)(Ln,{models:Fn(t,e,g.id),state:t,place:n})}):null,(0,B.jsx)(X,{title:k(`models.model`),aside:_?null:(0,B.jsx)(`button`,{type:`button`,onClick:()=>i({type:`provider`,id:g.id}),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:k(`models.manageKey`,{name:g.name})}),children:J(e)&&g.text?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(On,{provider:g,state:t}),(0,B.jsx)(jn,{provider:g,state:t,disabled:!n.canEdit,onPick:(e,t)=>a.mutate({bindings:{[e]:t}})})]}):(0,B.jsx)(Dn,{provider:g,cap:e,value:t.bindings[o]??g.models[e]?.[0]?.ref??``,disabled:!n.canEdit,onPick:e=>a.mutate({bindings:{[o]:e}})},`${g.id}:${t.bindings[o]??``}`)})]}):null,c?.kind===`client`&&v?J(e)?(0,B.jsx)(X,{title:v.name,children:(0,B.jsx)(mt,{me:r,id:v.id})}):(0,B.jsx)(X,{title:v.name,children:(0,B.jsx)(Z,{children:k(`models.clientImages`,{name:v.name,sub:k(`harness.sub.${v.id}`)})})}):null,c?.kind===`local`?c.by===`apple`?(0,B.jsx)(Vn,{cap:e,state:t,place:n}):(0,B.jsx)(Hn,{state:t,disabled:!n.canEdit}):null,c?.kind===`credits`&&n.credits?J(e)?(0,B.jsx)(X,{title:k(`models.creditsName`),children:(0,B.jsxs)(Z,{children:[k(`models.creditsPicks`),s.kind===`credits`&&s.ref?` ${k(`models.creditsModel`,{model:P(s.ref)})}`:``]})}):(0,B.jsxs)(X,{title:k(`models.model`),children:[(0,B.jsx)(In,{cap:e,state:t,disabled:!n.canEdit}),(0,B.jsx)(Z,{children:k(`models.creditsPickHint`)})]}):null,s.problem?(0,B.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg bg-paper-2 px-3 py-2.5 text-[0.8125rem] text-ink-2`,children:[(0,B.jsx)(ve,{className:`mt-0.5 size-3.5 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{children:(0,B.jsx)(f,{text:s.problem})})]}):null,c?.kind===`client`&&J(e)?null:(0,B.jsx)(X,{title:k(`models.try`),children:(0,B.jsx)(Mn,{cap:e,disabled:!y||!n.canEdit},`${e}:${s.ref}`)})]})]})}function zn(e){let t=t=>{let n=e.bindings[t]??``;return/^(ollama|apple):/.test(n)?``:n};return{classifier:`apple:default`,low:`apple:default`,standard:t(`standard`),high:t(`high`)}}function Bn(e){if(e.available)return k(`models.optAppleNote`);switch(e.reason){case`off`:return k(`models.appleOff`);case`loading`:return k(`models.appleLoading`);default:return k(`models.appleDevice`)}}function Vn({cap:e,state:t,place:n}){return(0,B.jsx)(X,{title:k(`models.optApple`),children:(0,B.jsx)(Z,{children:J(e)?k(`models.appleHint`,{way:xn(t.ways.standard,n).text}):k(`models.appleListenHint`)})})}function Hn({state:e,disabled:t}){let n=Y(),[r,i]=(0,z.useState)(e.ollamaUrl),[a,o]=(0,z.useState)((e.bindings.low??`ollama:qwen3`).replace(/^ollama:/,``));return(0,B.jsxs)(X,{title:k(`models.optLocal`),children:[(0,B.jsx)(Z,{children:k(`models.ollamaHint`)}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_12rem_auto]`,children:[(0,B.jsx)(x,{className:`font-mono text-[0.8125rem]`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,B.jsx)(x,{className:`font-mono text-[0.8125rem]`,value:a,disabled:t,onChange:e=>o(e.target.value)}),(0,B.jsx)(g,{variant:`secondary`,busy:n.isPending,disabled:t||!a.trim(),onClick:()=>n.mutate({ollamaUrl:r,bindings:Object.fromEntries(_.map(e=>[e,`ollama:${a.trim()}`]))}),children:k(`settings.save`)})]})]})}var Un=[`claude`,`codex`,`cursor`],Wn=[`openai`,`anthropic`,`google`,`gateway`];function Gn(e,t,n){return e===`models`?k(`models.chatModels`):e===`account`?n.cloud?k(`models.creditsOrganization`):k(`models.creditsName`):t.harnesses.find(t=>t.id===e)?.name??N(e)?.name??e}function Kn({me:e,state:t,place:n,onOpen:r}){let i=E(),a=j({mutationFn:e=>s.put(`/api/studio/local/chat`,{engine:e}),onSuccess:()=>i.invalidateQueries({queryKey:[`me`]})}),[o,c]=(0,z.useState)(!1),l=t=>e.chatWays.includes(t),u=e=>{if(c(!1),e===`account`&&!l(e)){c(!0);return}if(Wn.includes(e)&&!l(e)){r({type:`provider`,id:e});return}a.mutate(e)},d=n.harnesses.filter(e=>Un.includes(e.id)&&e.version!==null),f=(t,r,i,a,o=!1)=>(0,B.jsx)($,{title:r,note:i,noteTone:a?`done`:void 0,selected:e.chatEngine===t,disabled:!n.canEdit||o,onPick:()=>u(t)},t);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:Oe,title:k(`models.cap.chat`),lead:k(`models.cap.chat.hint`),status:(0,B.jsx)(Cn,{text:Gn(e.chatEngine,e,n),tone:l(e.chatEngine)?`done`:`warn`})}),(0,B.jsx)(A,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:(0,B.jsxs)(X,{title:k(`models.who`),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d.length?(0,B.jsx)(Q,{label:k(`models.optSubscription`),children:d.map(e=>f(e.id,e.name,bn(e).note,l(e.id),!l(e.id)))}):null,(0,B.jsx)(Q,{label:k(`models.optKey`),children:Wn.map(e=>f(e,N(e)?.name??e,t.keys[e]?k(`models.noteKey`):k(`models.noteNoKey`),!!t.keys[e]))}),(0,B.jsxs)(Q,{label:k(`models.optOther`),children:[f(`models`,k(`models.chatModels`),xn(t.ways.high,n).text,l(`models`)),f(`account`,Gn(`account`,e,n),l(`account`)?k(`models.noteUsage`):k(`models.noteNeedsAccount`),l(`account`))]})]}),o?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:[k(`local.sourceNeedsAccount`),` `,(0,B.jsx)(Yn,{})]}):null,a.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:a.error.message}):null,(0,B.jsx)(Z,{children:k(`models.chatHint`)})]})})]})}function qn({provider:e,state:t,place:n,onOpen:r}){let i=Y(),a=Be.filter(t=>e.models[t]?.length),o=t.keys[e.id],s=e.id===`gateway`?[]:t.creditModels.filter(t=>t.source===e.id||t.provider===e.id);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:R,title:e.name,lead:Re(e.about,D),status:(0,B.jsx)(Cn,{text:k(o?`models.keyStored`:`models.keyNone`),tone:o?`done`:`warn`})}),(0,B.jsxs)(A,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,B.jsx)(X,{title:k(`models.key`),children:(0,B.jsx)(Tn,{provider:e,stored:o,place:n})}),(0,B.jsx)(X,{title:k(`models.uses`),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(a=>{let o=gn[a],s=vn(t,a,n),l=s?.kind===`key`&&s.provider===e.id;return(0,B.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3 py-2.5`,children:[(0,B.jsx)(o,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r({type:`cap`,id:a}),className:`min-w-0 flex-1 text-left`,children:[(0,B.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:k(`models.cap.${a}`)}),(0,B.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:(e.models[a]??[]).map(e=>e.label).join(` · `)})]}),l?(0,B.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}),` `,k(`models.inUse`)]}):(0,B.jsx)(g,{size:`sm`,variant:`secondary`,disabled:!n.canEdit,busy:i.isPending&&i.variables?.bindings!==void 0,onClick:()=>i.mutate({...J(a)&&!n.cloud?{source:`own`}:{},bindings:yn(e,a,t)}),children:k(`models.useFor`)})]},a)})})}),s.length?(0,B.jsxs)(X,{title:k(`models.viaCredits`,{name:e.name}),children:[(0,B.jsx)(Z,{children:n.credits?k(`models.viaCreditsHint`):k(`models.viaCreditsNeedsAccount`)}),(0,B.jsx)(Ln,{models:s,state:t,place:n})]}):null]})]})}function Jn({me:e,id:t,state:n,place:r}){let i=Y(),a=r.harnesses.find(e=>e.id===t);if(!a)return null;let o=n.source===t,s=a.version!==null&&a.auth!==`none`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:Le,title:a.name,lead:k(`harness.desc.${t}`),status:(0,B.jsx)(Cn,{text:bn(a).note,tone:s?`done`:`warn`})}),(0,B.jsxs)(A,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[(0,B.jsx)(X,{title:k(`models.clientSignIn`),children:(0,B.jsx)(mt,{me:e,id:t})}),(0,B.jsxs)(X,{title:k(`models.uses`),children:[(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:[`text`,...a.images?[`image`]:[]].map(e=>{let a=gn[e],o=vn(n,e,r),s=o?.kind===`client`&&o.id===t;return(0,B.jsxs)(`li`,{className:`flex items-center gap-3 py-2.5`,children:[(0,B.jsx)(a,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 font-medium text-[0.875rem]`,children:k(`models.cap.${e}`)}),s?(0,B.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,B.jsx)(c,{className:`size-3.5`,strokeWidth:3}),` `,k(`models.inUse`)]}):(0,B.jsx)(g,{size:`sm`,variant:`secondary`,busy:i.isPending,onClick:()=>i.mutate(e===`text`?{source:t,bindings:we(n.bindings)}:{bindings:{image:`${t}/image`}}),children:k(`models.useFor`)})]},e)})}),o?null:(0,B.jsx)(Z,{children:k(`models.clientNotChosen`,{name:a.name})})]})]})]})}function Yn(){return(0,B.jsx)(w,{to:`/settings/account`,className:`font-medium text-ember-strong underline-offset-2 hover:underline`,children:k(`local.toAccount`)})}function Xn({state:e,place:t,onOpen:n}){let r=Y(),i=Be.filter(t=>e.ways[q[t]].kind===`credits`),a=t.cloud?k(`models.creditsOrganization`):k(`models.creditsName`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:M,title:a,lead:t.cloud?k(`models.creditsCloudHint`):k(`models.creditsLocalLead`),status:t.balance===null?void 0:(0,B.jsx)(`span`,{className:`font-display font-semibold text-[1.25rem] tabular-nums`,children:k(`nav.credits`,{n:Math.floor(t.balance).toLocaleString(D)})})}),(0,B.jsxs)(A,{className:`flex flex-col gap-6 p-3.5 sm:p-5 sm:p-6`,children:[!t.cloud&&!t.account?(0,B.jsxs)(X,{title:k(`models.creditsConnectTitle`),children:[(0,B.jsx)(Z,{children:k(`models.creditsLocalHint`)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(w,{to:`/settings/account`,children:(0,B.jsx)(g,{children:k(`models.creditsConnect`)})})})]}):null,t.account&&!t.account.signedIn?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[k(`local.accountExpired`),` `,(0,B.jsx)(Yn,{})]}):null,t.account?(0,B.jsx)(X,{title:k(`models.creditsFallback`),children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(ee,{checked:e.creditFallback,disabled:!t.canEdit,onChange:e=>r.mutate({creditFallback:e}),label:k(`models.creditsFallback`)}),(0,B.jsx)(Z,{children:e.creditFallback?k(`models.creditsFallbackOn`):k(`models.creditsFallbackOff`)})]})}):null,t.credits?(0,B.jsx)(X,{title:k(`models.creditsOn`),aside:t.topUp?(0,B.jsxs)(`a`,{href:t.topUp,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.8125rem] text-ember-strong hover:underline`,children:[k(`models.creditsTopUp`),` `,(0,B.jsx)(m,{className:`size-3`})]}):null,children:i.length?(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:i.map(t=>{let r=gn[t],i=e.ways[q[t]];return(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n({type:`cap`,id:t}),className:`flex w-full items-center gap-3 py-2.5 text-left`,children:[(0,B.jsx)(r,{className:`size-4 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 font-medium text-[0.875rem]`,children:k(`models.cap.${t}`)}),(0,B.jsxs)(`span`,{className:`truncate text-[0.75rem] text-ink-3`,children:[i.ref?P(i.ref):``,` · `,Pn(t,e)]})]})},t)})}):(0,B.jsx)(Z,{children:k(`models.creditsNone`)})}):null]})]})}function Zn(e){return e?e===`credits`?{type:`credits`}:e===`chat`?{type:`chat`}:Be.includes(e)?{type:`cap`,id:e}:N(e)?{type:`provider`,id:e}:{type:`client`,id:e}:{type:`cap`,id:`text`}}var Qn=e=>e.type===`credits`||e.type===`chat`?e.type:e.id;function $n({view:e,onView:t}){return null}function er(e){return e.kind===`none`?`off`:e.kind===`credits`?`credits`:`done`}function tr(e,t){switch(e.type){case`chat`:return k(`models.cap.chat`);case`cap`:return k(`models.cap.${e.id}`);case`provider`:return N(e.id)?.name??e.id;case`client`:return t?.harnesses.find(t=>t.id===e.id)?.name??e.id;default:return t?.mode===`managed`?k(`models.creditsOrganization`):k(`models.creditsName`)}}function nr(){let e=xe(),t=Sn(),[n,r]=te(),[i,a]=(0,z.useState)(`auto`),{narrow:o}=at(),s=n.get(`show`),c=Zn(s);if(st(s||!o?tr(c,e.data):null),!e.data||!t.data)return t.isError?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:t.error.message}):null;let l=t.data,u=hn(e.data,i),d=e=>r({show:Qn(e)},{replace:!o}),f=e=>!(!s&&o)&&Qn(e)===Qn(c),p=u.harnesses.filter(e=>e.version!==null||l.source===e.id),m=He.filter(e=>l.keys[e.id]),h=He.filter(e=>!l.keys[e.id]);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(dt,{children:[u.cloud?null:(0,B.jsx)(L,{label:k(`models.groupStudio`),children:(0,B.jsx)(I,{icon:Oe,label:k(`models.cap.chat`),tone:e.data.chatWays.includes(e.data.chatEngine)?`done`:`off`,toneLabel:Gn(e.data.chatEngine,e.data,u),selected:f({type:`chat`}),onPick:()=>d({type:`chat`})})}),(0,B.jsx)(L,{label:k(`models.groupRuns`),children:Be.map(e=>{let t=l.ways[q[e]];return(0,B.jsx)(I,{icon:gn[e],label:k(`models.cap.${e}`),tone:er(t),toneLabel:xn(t,u).text,selected:f({type:`cap`,id:e}),onPick:()=>d({type:`cap`,id:e})},e)})}),(0,B.jsxs)(L,{label:k(`models.groupAccess`),children:[(0,B.jsx)(I,{icon:M,label:u.cloud?k(`models.creditsOrganization`):k(`models.creditsName`),badge:u.balance===null?null:(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:Math.floor(u.balance).toLocaleString(D)}),tone:u.credits?void 0:`off`,toneLabel:u.credits?void 0:k(`models.noteNeedsAccount`),selected:f({type:`credits`}),onPick:()=>d({type:`credits`})}),p.map(e=>(0,B.jsx)(I,{icon:Le,label:e.name,tone:e.version!==null&&e.auth===`subscription`?`done`:e.auth===`api_key`?`on`:`off`,toneLabel:bn(e).note,selected:f({type:`client`,id:e.id}),onPick:()=>d({type:`client`,id:e.id})},e.id)),m.map(e=>(0,B.jsx)(I,{icon:R,label:e.name,tone:`done`,toneLabel:k(`models.noteKey`),selected:f({type:`provider`,id:e.id}),onPick:()=>d({type:`provider`,id:e.id})},e.id))]}),h.length?(0,B.jsx)(L,{label:k(`models.groupMore`),collapsible:!0,open:h.some(e=>f({type:`provider`,id:e.id})),count:h.length,children:h.map(e=>(0,B.jsx)(I,{icon:R,label:e.name,selected:f({type:`provider`,id:e.id}),onPick:()=>d({type:`provider`,id:e.id})},e.id))}):null,(0,B.jsx)($n,{view:i,onView:a})]}),u.canEdit?null:(0,B.jsx)(`p`,{className:`mb-4 rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem] text-ink-2`,children:k(`models.readOnly`)}),c.type===`chat`?(0,B.jsx)(Kn,{me:e.data,state:l,place:u,onOpen:d}):c.type===`cap`?(0,B.jsx)(Rn,{cap:c.id,state:l,place:u,me:e.data,onOpen:d},c.id):c.type===`provider`&&N(c.id)?(0,B.jsx)(qn,{provider:N(c.id),state:l,place:u,onOpen:d},c.id):c.type===`client`?(0,B.jsx)(Jn,{me:e.data,id:c.id,state:l,place:u},c.id):(0,B.jsx)(Xn,{state:l,place:u,onOpen:d})]})}function rr({name:e,image:t}){return t?(0,B.jsx)(`img`,{src:t,alt:``,className:`size-9 shrink-0 rounded-full object-cover`}):(0,B.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.75rem] text-ink-2`,children:Se(e)})}function ir({me:e}){let t=O({queryKey:[`organization`,e.tenant.id],queryFn:()=>s.get(`/api/studio/organization`)}),n=t.data,r=n?.plan??e.tenant.plan,a=n?.seats;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,B.jsxs)(ce,{title:k(`organization.title`),hint:k(`organization.hint`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:k(`organization.plan`)}),(0,B.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:r?.name??k(`organization.planFree`)}),a?(0,B.jsx)(i,{children:a.limit===null?k(`organization.seatsUnlimited`):k(`organization.seats`,{taken:a.taken,limit:a.limit})}):null]})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(g,{variant:`secondary`,onClick:()=>F(`${e.manageUrl}/billing`),children:[k(`organization.changePlan`),` `,(0,B.jsx)(m,{className:`size-4`})]}),n?.canManage?(0,B.jsxs)(g,{onClick:()=>F(`${e.manageUrl}/`),children:[k(`organization.manage`),` `,(0,B.jsx)(m,{className:`size-4`})]}):null]})]}),(0,B.jsx)(`p`,{className:`mt-4 text-[0.8125rem] text-ink-3 leading-relaxed`,children:e.tenant.role===`member`?k(`organization.memberNote`):k(`organization.roles`)})]}),(0,B.jsx)(ce,{title:k(`organization.members`),children:t.isPending?(0,B.jsx)(C,{}):t.isError||!n?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:k(`organization.failed`)}):(0,B.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[n.members.map(t=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,B.jsx)(rr,{name:t.name,image:t.image}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`truncate text-[0.9375rem]`,children:[t.name,t.userId===e.user.id?(0,B.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,k(`organization.you`)]}):null]}),(0,B.jsx)(`div`,{className:`truncate text-[0.8125rem] text-ink-3`,children:t.email})]}),(0,B.jsx)(i,{tone:t.role===`member`?void 0:`live`,children:k(`organization.role.${t.role}`)})]},t.userId)),n.invitations.map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3 py-3 first:pt-0 last:pb-0`,children:[(0,B.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-3`,children:(0,B.jsx)(yt,{className:`size-4`})}),(0,B.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.email}),(0,B.jsxs)(i,{tone:`warn`,children:[k(`organization.invited`),` · `,k(`organization.role.${e.role}`)]})]},e.id)),n.members.length===0&&n.invitations.length===0?(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-[0.875rem] text-ink-3`,children:[(0,B.jsx)(Je,{className:`size-4`}),` –`]}):null]})})]})}var ar=(0,z.lazy)(()=>pe(()=>import(`./AboutDialog-9VcgySrQ.js`).then(e=>({default:e.AboutPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),or=e=>e===`earlier`||e===`credits`?e:`new`;function sr(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,24)||`system`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}function cr({project:e}){let t=E(),[n,r]=(0,z.useState)(e.mcpServers.map(e=>({...e,auth:e.headers?.Authorization??e.headers?.authorization??``}))),[i,a]=(0,z.useState)(!1),o=e.readOnly,c=j({mutationFn:()=>s.patch(`/api/studio/projects/${e.id}`,{mcpServers:n.filter(e=>e.name&&e.url).map(({auth:e,headers:t,...n})=>({...n,headers:e?{...t,Authorization:e}:void 0}))}),onSuccess:async()=>{await t.invalidateQueries({queryKey:b.spaces()}),a(!0),setTimeout(()=>a(!1),1800)}});return(0,B.jsxs)(A,{className:`p-4 sm:p-6`,children:[(0,B.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:k(`settings.mcp`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:k(`settings.mcpHint`)}),(0,B.jsxs)(`fieldset`,{disabled:o,className:`flex min-w-0 flex-col gap-3`,children:[n.map((e,t)=>(0,B.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft sm:grid-cols-[1fr_2fr_auto]`,children:[(0,B.jsx)(x,{placeholder:k(`settings.serverName`),value:e.name,onChange:e=>r(n=>n.map((r,i)=>i===t?{...r,name:e.target.value,id:r.id||sr(e.target.value,n.map(e=>e.id))}:r))}),(0,B.jsx)(x,{placeholder:`${k(`settings.serverUrl`)} (https://…/mcp)`,value:e.url,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,url:e.target.value}:n))}),o?(0,B.jsx)(`span`,{}):(0,B.jsx)(v,{label:k(`common.remove`),onClick:()=>r(e=>e.filter((e,n)=>n!==t)),className:`hover:text-rose`,children:(0,B.jsx)(re,{className:`size-4`})}),(0,B.jsx)(x,{className:`sm:col-span-2`,placeholder:k(`settings.serverHeader`),value:e.auth??``,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,auth:e.target.value}:n))}),e.id?(0,B.jsx)(`span`,{className:`self-center font-mono text-[0.6875rem] text-ink-4`,children:e.id}):null]},t)),o?null:(0,B.jsxs)(g,{variant:`secondary`,className:`self-start`,onClick:()=>r(e=>[...e,{id:``,name:``,url:``,auth:``}]),children:[(0,B.jsx)(ne,{className:`size-4`}),` `,k(`settings.addServer`)]})]}),o?null:(0,B.jsxs)(`div`,{className:`mt-5 flex items-center justify-end gap-3`,children:[c.error?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error.message}):null,(0,B.jsx)(g,{busy:c.isPending,onClick:()=>c.mutate(),children:k(i?`settings.saved`:`settings.save`)})]})]})}var lr=new Set([`models`,`integrate`]);function ur(){let{section:e}=ae(),[t]=te(),n=oe(),i=xe(),{project:a,loading:o}=be(),s=Ce(),[c,u]=(0,z.useState)(a?.id);(0,z.useEffect)(()=>u(a?.id),[a?.id]);let d=tt(),f=pt(),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(null),y=Ye(i.data,d),b=y.find(t=>t.id===e),x=y.map(e=>({...e,to:`/settings/${e.id}`})),S=x.find(t=>t.id===e),C=b?lr.has(b.id):!1,w=b?C&&!t.get(`show`)?1:2:0,ee=f?Math.min(w,1):C&&_!==e?1:0,ne=ot(ee),re=ot(w),ie=(0,z.useMemo)(()=>({slot:p,narrow:f,setDetail:g}),[p,f]);if($e(b?.id===`models`?{suggestions:[{label:k(`assistant.suggest.modelsNow`)},{label:k(`assistant.suggest.modelsMissing`)},{label:k(`assistant.suggest.modelsCost`)}]}:b?.id===`account`?{suggestions:[{label:k(`assistant.suggest.credits`)},{label:k(`assistant.suggest.accountWhy`)},{label:k(`assistant.suggest.plans`)}]}:b?.id===`integrate`?{suggestions:[{label:k(`assistant.suggest.integrateWhat`)},{label:k(`assistant.suggest.integrateClaude`)},{label:k(`assistant.suggest.what`)}]}:b?.id===`connectors`?{suggestions:[{label:k(`assistant.suggest.connectorsWhat`)},{label:k(`assistant.suggest.connectorsAdd`),fill:!0},{label:k(`assistant.suggest.what`)}]}:{}),rt([{label:k(`settings.title`),to:`/settings`},...b?[{label:b.label,to:`/settings/${b.id}`}]:[],...b&&h?[{label:h}]:[]]),!b){if(e===`build`)return(0,B.jsx)(r,{to:`/settings/integrate`,replace:!0});if(e===`project`)return(0,B.jsx)(r,{to:`/space`,replace:!0});if(e!==void 0||!f)return d.status===`ready`||e===void 0?(0,B.jsx)(r,{to:`/settings/account`,replace:!0}):null}let E=b?.id===`connectors`&&s,D=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ct,{title:k(`settings.title`),open:ee===1?S??null:null,onBack:()=>f?n(`/settings`):v(e??null)}),(0,B.jsx)(`div`,{className:T(it(ne)),children:ee===0?(0,B.jsx)(ut,{entries:x,current:f?void 0:S,onPick:()=>v(null)}):(0,B.jsx)(`div`,{ref:m})},ee)]});return(0,B.jsx)(lt.Provider,{value:ie,children:(0,B.jsx)(`div`,{className:`animate-rise`,children:(0,B.jsxs)(`div`,{className:T(`grid gap-6`,`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[(0,B.jsx)(`aside`,{className:T(`min-w-0 md:sticky md:top-6 md:self-start`,f&&w===2&&`hidden`,f&&re===`back`&&it(`back`)),children:D}),b?(0,B.jsxs)(`div`,{className:T(`min-w-0`,![`integrate`,`models`].includes(b.id)&&`max-w-2xl`,f&&w<2&&`hidden`,f&&re===`deeper`&&it(`deeper`)),children:[f?(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(ft,{label:C?b.label:k(`settings.title`),onBack:()=>n(C?`/settings/${b.id}`:`/settings`)})}):null,E?(0,B.jsx)(`div`,{className:`mb-6`,children:(0,B.jsx)(qe,{})}):null,b.id===`connectors`&&a?(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.readOnly?(0,B.jsx)(De,{children:Te(a)}):null,(0,B.jsx)(Mt,{projectId:a.id,readOnly:a.readOnly},c),(0,B.jsx)(cr,{project:a},c)]}):null,b.id===`connectors`&&!a&&!o?(0,B.jsx)(l,{children:k(`settings.noProject`)}):null,b.id===`models`?(0,B.jsx)(nr,{}):null,b.id===`integrate`?(0,B.jsx)(mn,{}):null,b.id===`account`&&i.data?(0,B.jsx)(Xe,{me:i.data}):null,b.id===`cloud`?(0,B.jsx)(Ke,{}):null,b.id===`about`?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(ar,{me:i.data,active:!0,initialTab:or(t.get(`tab`))})}):null,b.id===`organization`&&i.data?(0,B.jsx)(ir,{me:i.data}):null,b.id===`plugins`?(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,B.jsx)(St,{}),(0,B.jsx)(Dt,{})]}):null,b.plugin?(0,B.jsx)(et,{of:b.plugin,children:(0,B.jsx)(b.plugin.component,{})}):null]}):null]})})})}export{ur as SettingsPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{G as r,Hr as i,Kr as a,Rt as o,en as s,ji as c,nn as l,qr as ee,ri as te,sn as u,vr as ne}from"./ui-BIWmkPh6.js";import{t as d}from"./useMutation-CD7HmAxR.js";import{D as f,d as re,g as ie,w as ae,x as p,y as oe}from"./session-BpsCkDv6.js";import{t as m}from"./logo-CGNoptDg.js";import{L as se,M as ce,N as le,R as ue,Rt as h,_t as g,et as de,gt as fe,z as _}from"./index-Bjn557f1.js";import{n as v,t as pe}from"./Harness-DYviBlHB.js";var y=e(t(),1),b=e(n(),1),x=`oklch(50% 0.2 262)`,S=`oklch(32% 0.15 262)`,C=`oklch(90% 0.1 80)`,w=`var(--step-done)`,T=`var(--step-now)`,E=`color-mix(in oklab, var(--on) 38%, transparent)`,me={"--on":`white`,"--tile":`rgb(255 255 255 / 0.1)`,"--tile-hover":`rgb(255 255 255 / 0.15)`,"--tile-ring":`rgb(255 255 255 / 0.15)`,"--panel":`rgb(255 255 255 / 0.07)`,"--panel-ring":`rgb(255 255 255 / 0.12)`,"--pick":`white`,"--pick-ink":S,"--pick-mark":S,"--dot":C,"--step-done":`oklch(88% 0.17 150)`,"--step-now":`oklch(88% 0.14 80)`,"--ready-ink":`oklch(27% 0.09 150)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--ink-4":`oklch(82% 0.05 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},he={"--on":`var(--ink)`,"--tile":`var(--card)`,"--tile-hover":`var(--paper-2)`,"--tile-ring":`var(--border-soft)`,"--panel":`var(--card)`,"--panel-ring":`var(--border-soft)`,"--pick":x,"--pick-ink":`white`,"--pick-mark":`white`,"--dot":x,"--step-done":`oklch(52% 0.15 150)`,"--step-now":`oklch(60% 0.15 65)`,"--ready-ink":`white`},D=`ease-[cubic-bezier(0.3,0.7,0.2,1)]`,ge=220,_e={codex:`dome`,claude:`oval`,antigravity:`wedge`,cursor:`sprout`,own:`bean`,account:`drop`,apple:`pebble`};function ve(e){if(e.available)return u(`models.optAppleNote`);switch(e.reason){case`off`:return u(`models.appleOff`);case`loading`:return u(`models.appleLoading`);default:return u(`models.appleDevice`)}}var O=`relative w-fit max-w-full transition-[left,translate] duration-700 ease-[cubic-bezier(0.3,0.7,0.2,1)] motion-reduce:transition-none`,k=`left-1/2 -translate-x-1/2 text-center`,A=`max-lg:left-1/2 max-lg:-translate-x-1/2 max-lg:text-center lg:left-0 lg:translate-x-0 lg:text-left`;function j(){window.matchMedia(`(max-width: 1023px)`).matches&&window.scrollTo({top:0})}var M=`wizards.setup.own`;function N(){try{return sessionStorage.getItem(M)===`1`}catch{return!1}}function P(e){try{e?sessionStorage.setItem(M,`1`):sessionStorage.removeItem(M)}catch{}}function ye(){return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,b.jsx)(m,{size:28}),(0,b.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,b.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,b.jsx)(`span`,{className:`font-normal text-(color:--on)/70`,children:`wizards`})]})]})}function F({selected:e,title:t,description:n,badge:r,note:o,onPick:c}){return(0,b.jsxs)(`button`,{type:`button`,onClick:c,"aria-pressed":e,className:s(`group relative flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left transition-[background-color,color,box-shadow] duration-300`,e?`bg-(color:--pick) text-(color:--pick-ink) shadow-elevated`:`bg-(color:--tile) ring-(color:--tile-ring) ring-1 hover:bg-(color:--tile-hover)`),children:[r?(0,b.jsx)(`span`,{className:`absolute -top-2.5 right-4 rounded-full px-2.5 py-[3px] font-semibold text-[0.6875rem] leading-none tracking-wide shadow-[0_2px_8px_oklch(0%_0_0/0.22)]`,style:{background:C,color:S},children:r}):null,(0,b.jsx)(`span`,{className:s(`flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors duration-300`,e?`border-transparent bg-(color:--pick-mark)`:`border-(color:--on)/40`),children:e?(0,b.jsx)(i,{className:`size-3.5 text-(color:--pick)`}):null}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`span`,{className:`block font-medium text-[0.9375rem]`,children:t}),(0,b.jsx)(`span`,{className:s(`mt-0.5 block truncate text-[0.8125rem]`,e?`opacity-70`:`text-(color:--on)/65`),children:n})]}),o?(0,b.jsx)(`span`,{className:s(`shrink-0 text-[0.75rem]`,e?`opacity-70`:`text-(color:--on)/65`),children:o}):null,(0,b.jsx)(a,{className:s(`size-4 shrink-0 transition`,e?`opacity-70`:`text-(color:--on)/40 group-hover:translate-x-0.5 group-hover:text-(color:--on)/80`)})]})}function be({name:e,at:t,done:n}){let r=[u(`setup.stage.connect`),u(`setup.stage.test`),u(`setup.stage.done`)],a=n?r.length:t+1;return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-medium text-[0.75rem] uppercase tracking-[0.14em]`,children:[(0,b.jsx)(`span`,{className:`text-(color:--on)/70`,children:e}),(0,b.jsx)(`ol`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:r.map((e,r)=>{let a=n||r<t;return(0,b.jsxs)(`li`,{"aria-current":!a&&r===t?`step`:void 0,className:`flex items-center gap-1 transition-colors duration-500`,style:{color:a?w:r===t?T:E},children:[a?(0,b.jsx)(i,{className:`size-3.5`,strokeWidth:3}):null,e]},e)})}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1.5`,children:r.map((e,t)=>(0,b.jsx)(`span`,{className:`h-[3px] w-5 rounded-full transition-colors duration-500`,style:{background:t<a?n?w:T:`color-mix(in oklab, var(--on) 22%, transparent)`}},e))})]})}function xe({href:e,children:t}){return(0,b.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`transition hover:text-(color:--on)`,onClick:t=>{t.preventDefault(),_(e)},children:t})}function I(){let e=g(`site`),t=f()===`dark`;ae(t?x:null);let n=ie(),a=c(),m=te(),_=fe(),C=g(`account`),{project:T}=re(),E=le(!!n.data?.account?.signedIn),[M,I]=(0,y.useState)(N),[L,R]=(0,y.useState)(!1),z=d({mutationFn:e=>r.put(`/api/studio/local/models`,e===`apple`?{bindings:{classifier:`apple:default`,low:`apple:default`}}:e===`own`?{source:`own`,bindings:{classifier:``,low:``}}:{source:e,bindings:oe(n.data?.models?.bindings??{})}),onSuccess:async(e,t)=>{await a.invalidateQueries({queryKey:[`me`]}),I(!0),R(!1),j(),P(t===`own`)}}),B=d({mutationFn:()=>Promise.all((n.data?.harnesses??[]).map(e=>r.post(`/api/studio/local/harness/${e.id}/detect`))),onSuccess:()=>a.invalidateQueries({queryKey:[`me`]})});if(!n.data?.models)return null;let V=n.data.models,H=e=>(e.version===null?2:0)+ +!e.app,U=[...n.data.harnesses].sort((e,t)=>H(e)-H(t)),Se=U.filter(e=>e.version!==null),W=n.data.apple,G=V.bindings.low?.startsWith(`apple:`)?`apple`:M||n.data.setupDone||V.source!==`own`?V.source:null,K=n.data.harnesses.find(e=>e.id===G),q=V.source===`account`?u(`models.creditsName`):n.data.harnesses.find(e=>e.id===V.source)?.name??null,J=n.data.setupDone,Y=Object.values(V.keys).some(Boolean),Ce=J?2:K?K.auth===`none`?0:1:G===`apple`||G===`account`||Y?1:0,X=J?u(`setup.h.done`):K?K.version===null?u(`setup.h.install`,{name:K.name}):K.auth===`none`?u(`setup.h.signIn`,{name:K.name}):u(`setup.h.test`):u(G===`apple`||G===`account`||Y?`setup.h.test`:`setup.h.keys`),Z=e?_.data?.site:null,Q=G!==null&&!L,$=z.isPending?z.variables??G:G;return(0,b.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-(color:--on) sm:px-10`,style:t?me:he,children:[(0,b.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,b.jsx)(ye,{}),(0,b.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(se,{tone:t?`ground`:`surface`}),(0,b.jsx)(de,{tone:t?`ground`:`surface`,ink:S})]})]}),(0,b.jsxs)(`main`,{className:`relative mx-auto flex w-full max-w-6xl flex-1 flex-col pt-6 pb-10 lg:pt-[6vh]`,children:[(0,b.jsx)(`div`,{"aria-hidden":`true`,className:s(`absolute top-6 left-1/2 z-10 origin-top -translate-x-1/2 transition-[opacity,scale,left] duration-500 motion-reduce:transition-none lg:top-[calc(6vh+5.25rem)] lg:origin-center lg:translate-x-0`,D,G?`lg:pointer-events-none lg:left-[calc(50%-560px)] lg:scale-75 lg:opacity-0`:`lg:left-[calc(50%-508px)] lg:scale-100 lg:opacity-100`,Q?`max-lg:pointer-events-none max-lg:scale-[0.4] max-lg:opacity-0`:`max-lg:scale-[0.6] max-lg:opacity-100`),children:(0,b.jsx)(`div`,{className:`animate-rise`,children:(0,b.jsx)(p,{kind:`drop`,size:ge,fluffy:!0,coat:`fur`})})}),(0,b.jsx)(`div`,{"aria-hidden":`true`,className:s(`shrink-0 transition-[height] duration-500 motion-reduce:transition-none lg:h-0`,D,Q?`max-lg:h-0`:`max-lg:h-[148px]`)}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-10 lg:flex-row lg:items-start lg:gap-14`,children:[(0,b.jsxs)(`section`,{className:s(`flex w-full shrink-0 animate-rise flex-col lg:w-[32rem] lg:transition-[margin] lg:duration-700 motion-reduce:transition-none`,D,G?`lg:ml-0`:`lg:ml-[calc(50%-16rem)]`,Q?`max-lg:hidden`:``),children:[(0,b.jsxs)(`div`,{className:`flex flex-col lg:min-h-[6.5rem]`,children:[(0,b.jsx)(`p`,{className:s(O,`font-medium text-(color:--on)/70 text-[0.75rem] uppercase tracking-[0.16em]`,G?A:k),children:u(`setup.title`)}),(0,b.jsx)(`h1`,{className:s(O,`mt-2 font-display font-semibold text-[1.625rem] leading-[1.08] tracking-[-0.02em] sm:text-[1.75rem]`,G?A:k),children:u(`setup.source`)}),(0,b.jsx)(`p`,{className:s(O,`mt-2.5 text-(color:--on)/75 text-[0.9375rem] leading-relaxed`,G?A:k),children:u(`setup.sub`)})]}),C?(0,b.jsxs)(`div`,{className:`mt-5 flex items-center gap-3.5 rounded-2xl bg-(color:--panel) px-4 py-3.5 ring-(color:--panel-ring) ring-1`,children:[(0,b.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-(color:--pick) font-semibold text-(color:--pick-ink) text-[0.9375rem]`,children:n.data.account?.signedIn?(n.data.account.name||n.data.account.email).slice(0,1).toUpperCase():(0,b.jsx)(h,{className:`size-4.5`})}),(0,b.jsx)(`div`,{className:`min-w-0 flex-1`,children:n.data.account?.signedIn?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:u(`setup.accountLinked`,{name:n.data.account.name||n.data.account.email})}),(0,b.jsx)(`p`,{className:`text-(color:--on)/75 text-[0.8125rem]`,children:[n.data.account.organization,n.data.account.credits===null?null:u(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(l)})].filter(Boolean).join(` · `)})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:u(`setup.account`)}),(0,b.jsx)(`p`,{className:`text-(color:--on)/75 text-[0.8125rem] leading-snug`,children:u(`setup.accountText`)}),(0,b.jsx)(ce,{...E})]})}),n.data.account?.signedIn?null:(0,b.jsx)(o,{variant:`secondary`,size:`sm`,busy:E.link.isPending,onClick:()=>E.link.mutate({}),children:u(`account.signIn`)})]}):null,(0,b.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[n.data.account?.signedIn?(0,b.jsx)(F,{selected:$===`account`,title:u(`setup.creditsChoice`),description:u(`setup.creditsDesc`),note:n.data.account.credits===null?void 0:u(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(l)}),onPick:()=>z.mutate(`account`)}):null,U.map((e,t)=>(0,b.jsx)(F,{selected:$===e.id,title:e.name,description:u(`harness.desc.${e.id}`),badge:t===0?u(`setup.recommended`):void 0,note:e.version===null?u(`harness.notInstalled`):e.auth===`subscription`?u(`harness.ready`):void 0,onPick:()=>z.mutate(e.id)},e.id)),W?.supported?(0,b.jsx)(F,{selected:$===`apple`,title:u(`models.optApple`),description:u(`setup.appleDesc`),note:ve(W),onPick:()=>z.mutate(`apple`)}):null,(0,b.jsx)(F,{selected:$===`own`,title:u(`local.sourceOwn`),description:u(`setup.ownDesc`),onPick:()=>z.mutate(`own`)})]}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-(color:--on)/60 text-[0.8125rem]`,children:[(0,b.jsx)(`span`,{children:Se.length?null:u(`setup.noHarness`)}),(0,b.jsxs)(o,{variant:`ghost`,size:`sm`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,b.jsx)(ne,{className:`size-3.5`}),` `,u(`local.recheck`)]})]})]}),G?(0,b.jsxs)(`section`,{className:s(`min-w-0 flex-1 animate-settle`,L?`max-lg:hidden`:``),children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>{R(!0),j()},className:`-ml-1.5 mb-5 inline-flex items-center gap-1.5 rounded-full px-1.5 py-1 text-(color:--on)/80 text-[0.875rem] transition hover:text-(color:--on) lg:hidden`,children:[(0,b.jsx)(ee,{className:`size-4`}),` `,u(`run.back`)]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-6 right-2 z-10`,children:(0,b.jsx)(p,{kind:_e[G],size:120,fluffy:!0,coat:`fur`})}),(0,b.jsxs)(`div`,{className:`min-h-[6.5rem]`,children:[(0,b.jsx)(be,{name:K?.name??u(G===`apple`?`models.optApple`:G===`account`?`setup.creditsChoice`:`local.sourceOwn`),at:Ce,done:J}),(0,b.jsx)(`h2`,{className:`mt-2 animate-rise pr-32 font-display font-semibold text-[clamp(28px,3vw,40px)] leading-[1.06] tracking-[-0.03em]`,children:X},X)]}),(0,b.jsx)(`div`,{className:`mt-5 rounded-2xl bg-(color:--panel) p-5 ring-(color:--panel-ring) ring-1 sm:p-6`,children:K?(0,b.jsx)(pe,{me:n.data,id:K.id,autoTest:!J}):G===`apple`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,b.jsx)(`p`,{className:`text-[0.875rem] text-ink-2 leading-relaxed`,children:q?u(`setup.appleHintKeeps`,{way:q}):u(`setup.appleHint`)}),(0,b.jsx)(v,{auto:!J&&W?.available===!0})]}):G===`account`?(0,b.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,b.jsx)(`p`,{className:`text-[0.875rem] text-ink-2 leading-relaxed`,children:u(`setup.creditsDesc`)}),(0,b.jsx)(v,{auto:!J})]}):(0,b.jsx)(ue,{models:V})}),(0,b.jsxs)(`div`,{className:`mt-9`,children:[J?(0,b.jsxs)(`p`,{className:`mb-3 flex animate-rise items-center gap-2 font-medium text-[0.9375rem]`,style:{color:w},children:[(0,b.jsx)(i,{className:`size-4`,strokeWidth:3}),u(`setup.ready`)]}):null,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,b.jsxs)(`button`,{type:`button`,disabled:!J,onClick:()=>m(`/`,{replace:!0}),className:s(`group inline-flex h-12 items-center gap-2.5 rounded-full px-6 font-semibold text-[1rem] transition-[background-color,color,box-shadow,filter] duration-300`,J?`shadow-[0_6px_24px_oklch(88%_0.17_150/0.35)] hover:brightness-105`:`cursor-not-allowed bg-(color:--on)/20 text-(color:--on)/65`),style:J?{background:w,color:`var(--ready-ink)`}:void 0,children:[u(`setup.done`),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`transition-transform group-enabled:group-hover:translate-x-0.5`,children:`→`})]}),J?null:(0,b.jsx)(`span`,{className:`text-(color:--on)/65 text-[0.8125rem]`,children:u(`setup.untilWorks`)})]})]})]})]},G):null]})]}),(0,b.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between gap-4 pb-6 text-(color:--on)/55 text-[0.75rem] sm:pb-8`,children:[(0,b.jsxs)(`span`,{children:[`engenty ·`,` `,n.data.account?.signedIn?u(`setup.thisComputer`,{space:T?.name??``,organization:n.data.account.organization??n.data.account.name}):u(`setup.local`)]}),(0,b.jsxs)(`span`,{className:`flex items-center gap-5`,children:[Z?(0,b.jsx)(xe,{href:Z,children:new URL(Z).host}):null,(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})]})}export{I as SetupPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{G as r,Kr as i,Mt as a,Rt as o,Y as s,Yt as c,ii as l,mt as u,nn as d,oi as f,sn as p,ut as m,zt as h}from"./ui-BIWmkPh6.js";import{d as g,n as _}from"./theme-2XjIQXH3.js";import{O as v,b as y,x as b}from"./session-BpsCkDv6.js";import{BrandHeader as x}from"./PublicRunner-CkRO_Pw-.js";var S=e(t(),1),C=e(n(),1);function w(){let{token:e}=l(),t=f({queryKey:[`share`,e],queryFn:()=>r.get(`/api/shares/${e}`),retry:(e,t)=>a(t)&&e<3});if(_(t.data?.brand.theme),v(t.data?.wizard.avatar),(0,S.useEffect)(()=>{t.data&&(document.title=`${t.data.title} · ${t.data.wizard.title}`)},[t.data]),t.isLoading)return(0,C.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center text-ink-4`,children:(0,C.jsx)(c,{})});let n=t.data;if(!n)return(0,C.jsxs)(`div`,{className:`flex min-h-dvh flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,C.jsx)(b,{kind:`pebble`,size:80}),(0,C.jsx)(`p`,{className:`max-w-sm text-ink-3`,children:p(a(t.error)?`common.offline`:`sharePage.gone`)}),a(t.error)?(0,C.jsx)(o,{variant:`secondary`,onClick:()=>void t.refetch(),children:p(`common.retry`)}):null]});let w=`/api/shares/${n.token}`,T=e=>new Intl.DateTimeFormat(d,{dateStyle:`long`}).format(new Date(e));return(0,C.jsxs)(`div`,{className:`wizard-page flex min-h-dvh flex-col`,children:[(0,C.jsx)(g,{effects:n.brand.theme.effects}),(0,C.jsx)(x,{brand:n.brand}),(0,C.jsxs)(`main`,{className:`mx-auto w-full max-w-3xl flex-1 animate-rise px-4 pt-6 pb-12 sm:px-6`,children:[(0,C.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-4`,children:[(0,C.jsx)(b,{kind:n.wizard.avatar,costume:n.wizard.costume,size:64}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`p`,{className:`text-[0.8125rem] text-ink-4`,children:n.expiresAt?p(`sharePage.until`,{date:T(n.expiresAt)}):p(`sharePage.shared`,{date:T(n.createdAt)})}),(0,C.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] leading-tight tracking-tight sm:text-[2rem]`,children:n.title}),n.message?(0,C.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]})]}),(0,C.jsx)(`div`,{className:`flex flex-col gap-6`,children:n.shown.map(({step:e,output:t,formats:n,label:r})=>(0,C.jsxs)(h,{className:`p-4 sm:p-5`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,C.jsx)(`h2`,{className:`font-display font-semibold text-[1.0625rem]`,children:r??e.title}),(0,C.jsx)(m,{base:w,stepId:e.id,formats:n,title:r??e.title})]}),(0,C.jsx)(u,{base:w,step:e,output:t})]},e.id))}),n.wizardUrl?(0,C.jsxs)(`a`,{href:n.wizardUrl,className:`mt-10 flex items-center gap-4 rounded-2xl bg-card p-5 shadow-soft ring-1 ring-border-soft transition hover:shadow-elevated`,children:[(0,C.jsx)(b,{kind:n.wizard.avatar,costume:n.wizard.costume,size:44,interactive:!1}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`font-display font-semibold text-[1rem]`,children:n.wizard.title}),n.wizard.description?(0,C.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:n.wizard.description}):null]}),(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-[0.875rem] text-ember-strong`,children:[p(`sharePage.own`),` `,(0,C.jsx)(i,{className:`size-4`})]})]}):null]}),(0,C.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,C.jsx)(`a`,{href:`${s}/`,className:`inline-block py-3.5 hover:text-ink-2`,children:p(`run.madeWith`).replace(`engenty wizards`,y.name)})})]})}export{w as SharePage};