@engenty/wizards-runtime 0.11.1 → 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 (118) 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/steps.md +12 -12
  15. package/apps/runtime/dist/engine/requirements.js +7 -7
  16. package/apps/runtime/dist/engine/runner.js +8 -1
  17. package/apps/runtime/dist/engine/steps.js +3 -3
  18. package/apps/runtime/dist/files/storage.js +3 -3
  19. package/apps/runtime/dist/index.js +3 -0
  20. package/apps/runtime/dist/limits.js +16 -0
  21. package/apps/runtime/dist/manage.js +19 -0
  22. package/apps/runtime/dist/models.js +8 -8
  23. package/apps/runtime/dist/{film → motion-graphics}/project.js +54 -54
  24. package/apps/runtime/dist/{film → motion-graphics}/sounds.js +3 -3
  25. package/apps/runtime/dist/{film → motion-graphics}/step.js +37 -37
  26. package/apps/runtime/dist/{film → motion-graphics}/tools.js +1 -1
  27. package/apps/runtime/dist/render/downloads.js +2 -2
  28. package/apps/runtime/dist/render/guard.js +1 -1
  29. package/apps/runtime/dist/routes/delivery.js +1 -1
  30. package/apps/runtime/dist/routes/internal.js +1 -1
  31. package/apps/runtime/dist/routes/marketplace.js +4 -3
  32. package/apps/runtime/dist/routes/reports.js +80 -0
  33. package/apps/runtime/dist/routes/runs.js +25 -1
  34. package/apps/runtime/dist/services/brand.js +1 -1
  35. package/apps/runtime/dist/services/manage-reports.js +190 -0
  36. package/apps/runtime/dist/services/marketplace.js +33 -1
  37. package/apps/runtime/dist/services/pages.js +1 -1
  38. package/apps/runtime/dist/services/shipped-fonts.js +2 -1
  39. package/apps/runtime/dist/services/wizards.js +7 -0
  40. package/apps/runtime/dist/widgets/render.js +9 -9
  41. package/apps/runtime/dist/widgets/runtime.js +3 -3
  42. package/apps/runtime/dist/widgets/step.js +20 -20
  43. package/apps/web/dist/assets/{AboutDialog-D2r8kBfV.js → AboutDialog-Bx6j5lZO.js} +1 -1
  44. package/apps/web/dist/assets/{ChangelogDialog-j7Z1YhNv.js → ChangelogDialog-C620Sw_A.js} +1 -1
  45. package/apps/web/dist/assets/{CodeEditor-BTCMfVFJ.js → CodeEditor-DifBNaqQ.js} +1 -1
  46. package/apps/web/dist/assets/EditorPage-DWf9QG-U.js +3 -0
  47. package/apps/web/dist/assets/{FlowPreview-BtVgtW7P.js → FlowPreview-ucwQ_dTr.js} +1 -1
  48. package/apps/web/dist/assets/{Harness-H4Ue1HOd.js → Harness-Br0Z_anI.js} +2 -2
  49. package/apps/web/dist/assets/Marketplace-CFDpVMWM.js +2 -0
  50. package/apps/web/dist/assets/{NewWizardChannels-K1HOzkXf.js → NewWizardChannels-Cau6XSbl.js} +1 -1
  51. package/apps/web/dist/assets/NewWizardPage-CrFqInHR.js +7 -0
  52. package/apps/web/dist/assets/OnboardingPage-BZk42_R7.js +1 -0
  53. package/apps/web/dist/assets/PreviewPane-D9n6tylf.js +10 -0
  54. package/apps/web/dist/assets/ProjectPage-CteRfxpz.js +1 -0
  55. package/apps/web/dist/assets/PublicRunner-CNanj6-w.js +1 -0
  56. package/apps/web/dist/assets/{ReadOnly-Duk1YpNM.js → ReadOnly-DGBDtXFP.js} +1 -1
  57. package/apps/web/dist/assets/SettingsPage-ClFQewEL.js +2 -0
  58. package/apps/web/dist/assets/SetupPage-k9gyFvow.js +1 -0
  59. package/apps/web/dist/assets/{SharePage-DvAUwrOl.js → SharePage-BhWeqF3w.js} +1 -1
  60. package/apps/web/dist/assets/changelog-BrhGlZT6.js +1 -0
  61. package/apps/web/dist/assets/{coins-DSvwvqtQ.js → coins-CwURUZyt.js} +1 -1
  62. package/apps/web/dist/assets/i18n-DEmaSTJV.js +55 -0
  63. package/apps/web/dist/assets/index-ClNm5JaU.js +34 -0
  64. package/apps/web/dist/assets/index-DImS12WR.css +1 -0
  65. package/apps/web/dist/assets/{oss-credits-BLVLXRzs.js → oss-credits-C6bPkfSE.js} +1 -1
  66. package/apps/web/dist/assets/{phone-xIUU1ZFn.js → phone-DTxGRwhK.js} +1 -1
  67. package/apps/web/dist/assets/runners-BMOIT6Ze.js +1 -0
  68. package/apps/web/dist/assets/{session-CbWzkHl0.js → session-xJpGiTU_.js} +1 -1
  69. package/apps/web/dist/assets/{settings-menu-DoRItnPf.js → settings-menu-DcPFhgGA.js} +1 -1
  70. package/apps/web/dist/assets/theme-DTi1Zdw8.js +11 -0
  71. package/apps/web/dist/assets/{ui-6AgUKJhQ.js → ui-gsqxnFnT.js} +6 -6
  72. package/apps/web/dist/assets/{upload-C8WgcG1g.js → upload-BkwjFS-0.js} +1 -1
  73. package/apps/web/dist/assets/{useMutation-BdCg6qrc.js → useMutation-BS-U9g_a.js} +1 -1
  74. package/apps/web/dist/assets/{volume-2-jlgQapiz.js → volume-2-CYOgux-z.js} +1 -1
  75. package/apps/web/dist/assets/{wrench-Ca_TrBQk.js → wrench-DIfUvYPN.js} +1 -1
  76. package/apps/web/dist/index.html +9 -9
  77. package/apps/web/dist/mcp/flow.html +32 -32
  78. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +1 -1
  79. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +11 -11
  80. package/node_modules/@engenty/wizards-shared/dist/definition.js +24 -23
  81. package/node_modules/@engenty/wizards-shared/dist/engenty/data-tables/columns-value.js +1 -0
  82. package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +7 -2
  83. package/node_modules/@engenty/wizards-shared/dist/fit.js +23 -6
  84. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.d.ts +1 -1
  85. package/node_modules/@engenty/wizards-shared/dist/marketplace-entry.js +1 -1
  86. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +9 -7
  87. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +7 -23
  88. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +15 -14
  89. package/node_modules/@engenty/wizards-shared/dist/run.js +30 -28
  90. package/node_modules/@engenty/wizards-shared/dist/runners.d.ts +1 -1
  91. package/node_modules/@engenty/wizards-shared/dist/runners.js +5 -5
  92. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +1 -1
  93. package/node_modules/@engenty/wizards-shared/dist/store.js +1 -2
  94. package/node_modules/@engenty/wizards-shared/dist/theme-look.d.ts +39 -0
  95. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +112 -0
  96. package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +0 -38
  97. package/node_modules/@engenty/wizards-shared/dist/theme.js +1 -108
  98. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +1 -0
  99. package/package.json +1 -1
  100. package/plugin/.claude-plugin/plugin.json +1 -1
  101. package/plugin/plugin.json +1 -1
  102. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +0 -47
  103. package/apps/web/dist/assets/EditorPage-mx6XuEIw.js +0 -3
  104. package/apps/web/dist/assets/Marketplace-YEZDpGm9.js +0 -2
  105. package/apps/web/dist/assets/NewWizardPage-DSHVwwnU.js +0 -7
  106. package/apps/web/dist/assets/OnboardingPage-CoBNtV_1.js +0 -1
  107. package/apps/web/dist/assets/PreviewPane-z0-Glj7p.js +0 -10
  108. package/apps/web/dist/assets/ProjectPage-DFaPSeda.js +0 -1
  109. package/apps/web/dist/assets/PublicRunner-DgT4CApp.js +0 -1
  110. package/apps/web/dist/assets/SettingsPage-FimvOhQq.js +0 -2
  111. package/apps/web/dist/assets/SetupPage-BxEMrMtA.js +0 -1
  112. package/apps/web/dist/assets/changelog-CS9GmnXd.js +0 -1
  113. package/apps/web/dist/assets/i18n-UTsgNY5M.js +0 -55
  114. package/apps/web/dist/assets/index-DHIXX69l.js +0 -20
  115. package/apps/web/dist/assets/index-Mt1sNdPx.css +0 -1
  116. package/apps/web/dist/assets/runners-CrSLA6HI.js +0 -1
  117. package/apps/web/dist/assets/theme-znovbShL.js +0 -11
  118. /package/apps/runtime/dist/{film → motion-graphics}/skills.js +0 -0
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,A as a,B as o,C as s,D as c,Dn as l,E as u,En as d,G as f,Gt as p,H as m,Hn as h,Ht as g,I as _,Jn as v,Jt as y,Kn as b,Kt as x,L as S,M as C,Mn as w,N as T,O as E,On as D,Or as O,P as k,Pn as ee,Qt as A,R as j,S as te,T as ne,Tn as M,U as N,Ut as P,V as re,Vt as F,W as I,Wt as L,Xn as ie,Xt as R,Zt as ae,_ as z,_n as B,b as V,bn as oe,d as H,en as U,er as se,f as ce,fn as le,g as ue,gn as W,gt as de,h as fe,j as pe,k as G,kn as me,m as he,mn as ge,nn as _e,nr as ve,p as K,qt as q,rn as J,rr as ye,sn as be,tn as xe,tr as Se,un as Ce,v as we,w as Te,wn as Ee,x as De,y as Y,z as Oe,zn as ke}from"./ui-gsqxnFnT.js";import{b as Ae,g as je,h as Me,v as Ne,w as Pe,y as Fe}from"./Marketplace-CFDpVMWM.js";import{t as Ie}from"./useMutation-BS-U9g_a.js";import{I as Le,L as Re,P as ze,S as Be,_ as Ve,a as He,b as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,i as Ye,l as Xe,m as Ze,o as Qe,p as $e,r as et,s as tt,t as nt,u as rt,v as it,x as at,y as ot}from"./PreviewPane-D9n6tylf.js";import{b as st,f as ct}from"./theme-DTi1Zdw8.js";import{d as lt,f as ut,g as dt,p as ft,x as pt}from"./session-xJpGiTU_.js";import{t as mt}from"./phone-DTxGRwhK.js";import{n as ht,r as gt,t as _t}from"./ReadOnly-DGBDtXFP.js";import{t as vt}from"./upload-BkwjFS-0.js";import{lt as yt,n as bt,s as X}from"./i18n-DEmaSTJV.js";import{Ct as xt,Dt as St,Et as Ct,Lt as wt,Mt as Tt,Nt as Et,Pt as Dt,Vt as Ot,_t as kt,c as At,d as jt,f as Mt,h 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-ClNm5JaU.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-DcPFhgGA.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:X(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(X(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function xn({projectId:e,file:t,small:n}){let r=Oe(e,t.id);if(t.mime.startsWith(`image/`))return(0,Q.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:J(`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)(D,{className:i}):t.mime===`application/json`?(0,Q.jsx)(Ce,{className:i}):t.mime.startsWith(`model/`)?(0,Q.jsx)(nn,{className:i}):(0,Q.jsx)(l,{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:J(`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:c,onMakeMain:l,moveTo:u,onRemove:d}){let f=e=>d?d(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:u&&!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===c?(0,Q.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,Q.jsx)(P,{tone:`ember`,children:X(`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":`${X(`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)(x,{label:X(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Pe,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,Q.jsx)(x,{label:X(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,Q.jsx)(Ne,{className:`size-4`})}):null,u&&!r.readOnly?(0,Q.jsx)(ue,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,Q.jsx)(x,{label:X(`project.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,Q.jsx)(be,{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)(A,{className:`size-5`}):(0,Q.jsx)(W,{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(X(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){l(e.message)}s(!1)},h=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:X(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:X(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:J(`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:J(`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)(ke,{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)(F,{variant:`ghost`,onClick:()=>d(null),children:X(`run.back`)}),(0,Q.jsx)(F,{busy:o,disabled:!f.length,onClick:()=>void h(),children:f.length>1?X(`project.addMany`,{n:f.length}):X(`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)(y,{children:X(`project.logoUrl`)}),(0,Q.jsx)(q,{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:X(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)(F,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:o,disabled:!i.trim(),children:X(`run.next`)})]})]})})}function En(e,t,n){return ye({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>f.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?X(`project.pages`,{n:e.pages}):null,yt(e.size)].filter(Boolean).join(` · `),kn=2e5;function An({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=O(),a=N(e),o=Ze(e),s=re(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)(A,{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=Oe(e,c.id),h=(e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>d(e),className:J(`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":X(`project.openOriginal`),title:X(`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)(me,{className:`size-4`})}),n?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(x,{label:X(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:I.knowledge(e)})},children:(0,Q.jsx)(ge,{className:`size-4`})}),(0,Q.jsx)(x,{label:X(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(X(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:I.knowledge(e)}),r())},children:(0,Q.jsx)(be,{className:`size-4`})})]})]}),(0,Q.jsx)(Ke,{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)(g,{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`,X(`project.original`)):null,h(`text`,X(`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)(A,{})}):n.data?.text?(0,Q.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,Q.jsx)(de,{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:X(`project.textCut`,{shown:n.data.text.length.toLocaleString(bt),total:n.data.chars.toLocaleString(bt)})}):null]}):(0,Q.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:X(`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),yt(e.size)].filter(Boolean).join(` · `);function Pn({projectId:e,file:t,actions:n,onClose:r}){let i=Oe(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":X(`project.openOriginal`),title:X(`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)(me,{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":`${X(`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)(x,{label:X(`project.preview`),onClick:i,children:(0,Q.jsx)(Pe,{className:`size-4`})}),r&&!n.readOnly?(0,Q.jsx)(ue,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,Q.jsx)(x,{label:X(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,Q.jsx)(be,{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:X(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)(y,{children:X(`project.assetSectionName`)}),(0,Q.jsx)(q,{autoFocus:!0,value:i,maxLength:80,placeholder:X(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,Q.jsx)(F,{variant:`danger`,onClick:n,children:X(`project.sectionRemove`)}):null,(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(F,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,disabled:!i.trim(),children:X(e?`settings.save`:`project.add`)})]})]})})}function Ln({projectId:e,data:t,readOnly:n,sections:r,save:i}){let s=re(e,n),[c,l]=m(`assets`,`cards`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(r),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),w=(0,Z.useRef)(null),T=o({assetSections:h},i),E=t.files.filter(e=>e.kind===`asset`),D=new Map(E.map(e=>[e.id,e])),O=new Set(h.flatMap(e=>e.assets)),k=h.find(e=>e.id===_)??null,ee=k?k.assets.map(e=>D.get(e)).filter(e=>!!e):E.filter(e=>!O.has(e.id)),j=E.find(e=>e.id===f),te=u.trim().toLowerCase(),ne=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,M=(e,t)=>g(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),N=async e=>{let t=k?.id??null;for(let n of await s.upload(`asset`,e))M(n.id,t)},P=e=>{confirm(X(`project.removeConfirm`,{name:e.name}))&&(s.remove(e.id),M(e.id,null))},F=h.length?{options:[{value:``,label:X(`project.assetsGeneral`)},...h.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],current:e=>h.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>M(e.id,t||null)}:void 0,I=[{label:X(`project.assetUpload`),icon:(0,Q.jsx)(vt,{className:`size-4 shrink-0`}),onPick:()=>w.current?.click()},{label:X(`project.assetFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>C(!0)},...h.length<a.logoSections?[{label:X(`project.assetSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>b(`new`)}]:[]],L=h.length||E.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:[h.length?(0,Q.jsx)(xe,{value:_,onChange:e=>{v(e),d(``)},label:X(`project.assets`),options:[{id:``,label:X(`project.assetsGeneral`)},...h.map(e=>({id:e.id,label:e.title||X(`project.sectionUntitled`)}))]}):null,k&&!n?(0,Q.jsx)(x,{label:X(`project.assetSectionRename`),onClick:()=>b(`current`),children:(0,Q.jsx)(B,{className:`size-4`})}):null]}),ee.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:X(`project.assetSearch`)})}),(0,Q.jsx)(x,{label:X(c===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:c===`list`?(0,Q.jsx)(Et,{className:`size-4`}):(0,Q.jsx)(pn,{className:`size-4`})})]}):null]}):null;return(0,Q.jsxs)(Y,{title:X(`project.assets`),hint:X(`project.assetsHint`),save:T,tabs:L,action:n?null:(0,Q.jsx)(H,{entries:I}),children:[(0,Q.jsx)(`input`,{ref:w,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&&N(t)}}),ne.length?c===`cards`?(0,Q.jsx)(wn,{projectId:e,kind:`asset`,files:ne,actions:s,moveTo:F,onRemove:P,onPreview:e=>p(e.id)}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:ne.map(t=>(0,Q.jsx)(Fn,{projectId:e,file:t,actions:s,moveTo:F,onPreview:()=>p(t.id),onRemove:()=>P(t)},t.id))}):ee.length?null:n?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.staysLocal`)}):(0,Q.jsxs)(he,{accept:Mn,onFiles:e=>void N(e),className:`h-16 w-full`,children:[s.busy?(0,Q.jsx)(A,{className:`size-4`}):(0,Q.jsx)(vt,{className:`size-4`}),X(`project.drop`),` `,(0,Q.jsx)(`span`,{className:`underline`,children:X(`project.assetAdd`)})]}),s.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error}):null,j?(0,Q.jsx)(Pn,{projectId:e,file:j,actions:s,onClose:()=>p(null)}):null,y?(0,Q.jsx)(In,{section:y===`current`?k:null,onClose:()=>b(null),onSave:e=>{if(y===`current`&&k)g(t=>t.map(t=>t.id===k.id?{...t,title:e}:t));else{let t=De();g(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&k?()=>{(!k.assets.length||confirm(X(`project.assetSectionRemoveConfirm`,{name:k.title})))&&(g(e=>e.filter(e=>e.id!==k.id)),v(``),b(null))}:void 0}):null,S?(0,Q.jsx)(Tn,{kind:`asset`,onClose:()=>C(!1),fetchUrl:e=>s.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)M(t.id,k?.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:a,onClose:o}){let[s,l]=(0,Z.useState)(t),[u,d]=(0,Z.useState)(k(t)),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!n),T=e=>{l(e),d(k(e)),m(!1)},E=(e,t)=>T({...s,stops:s.stops.map((n,r)=>r===e?{...n,...t}:n)}),D=e=>{let t=[...s.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));T({...s,stops:[...s.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},O=async()=>{v(!0),S(null);try{let{gradient:t}=await f.post(`/api/studio/projects/${e}/gradients/describe`,{text:h.trim(),...C?{gradient:{name:s.name,type:s.type,angle:s.angle,stops:s.stops}}:{}});T({...s,...t,name:s.name.trim()?s.name:t.name}),g(``),w(!0)}catch(e){S(e.message)}v(!1)};return(0,Q.jsx)(L,{open:!0,onClose:o,wide:!0,title:X(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(),h.trim()&&!_&&O()},children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{"data-autofocus":n||void 0,value:h,maxLength:1e3,"aria-label":X(`project.gradientDescribe`),placeholder:X(C?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>g(e.target.value),className:`min-w-0 flex-1`}),(0,Q.jsxs)(F,{type:`submit`,variant:`secondary`,busy:_,disabled:!h.trim(),children:[(0,Q.jsx)(Ce,{className:`size-4`}),X(C?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,Q.jsx)(`p`,{className:J(`mt-1.5 text-[0.8125rem]`,b?`text-rose`:`text-ink-3`),children:b??X(`project.gradientDescribeHint`)})]}),(0,Q.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:k(s)}}),(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)(y,{children:X(`project.gradientName`)}),(0,Q.jsx)(q,{value:s.name,maxLength:80,placeholder:X(`project.gradientNamePlaceholder`),onChange:e=>l({...s,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(q,{value:s.description??``,maxLength:400,placeholder:X(`project.gradientUse`),onChange:e=>l({...s,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)(y,{children:X(`project.gradientType`)}),(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:c.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":s.type===e,onClick:()=>T({...s,type:e}),className:J(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,s.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:X(Bn[e])},e))})]}),s.type===`radial`?null:(0,Q.jsxs)(`div`,{className:`min-w-56`,children:[(0,Q.jsx)(y,{children:X(`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:s.angle,"aria-label":X(`project.gradientAngle`),onChange:e=>T({...s,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(s.angle),`°`]})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`project.gradientStops`)}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.stops.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(i,{value:Rn.test(e.color)?e.color:`#888888`,onChange:e=>E(t,{color:e.target.value})}),(0,Q.jsx)(q,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();Rn.test(n)&&E(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":X(`project.gradientAt`),onChange:e=>E(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)(x,{label:X(`project.remove`),disabled:s.stops.length<=2,onClick:()=>T({...s,stops:s.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,Q.jsx)(be,{className:`size-4`})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[s.stops.length<12?(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>D(),children:[(0,Q.jsx)(W,{className:`size-4`}),` `,X(`project.gradientStopAdd`)]}):null,r.length&&s.stops.length<12?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:X(`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:()=>D(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)(y,{children:`CSS`}),(0,Q.jsx)(q,{value:u,spellCheck:!1,onChange:e=>{d(e.target.value);let t=j(e.target.value);m(!t),t&&l({...s,...t})},className:`font-mono text-[0.8125rem]`}),(0,Q.jsx)(`p`,{className:J(`mt-1.5 text-[0.8125rem]`,p?`text-rose`:`text-ink-3`),children:X(p?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:o,children:X(`common.cancel`)}),(0,Q.jsx)(F,{onClick:()=>{a(s),o()},children:X(`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)(fe,{value:e,label:X(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,Q.jsx)(fe,{value:n??``,label:X(`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":X(`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)(x,{label:X(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:Un,children:(0,Q.jsx)(ee,{className:`size-4`})}),(0,Q.jsx)(x,{label:X(`project.download`),onClick:()=>void zn(e,e.name),className:Un,children:(0,Q.jsx)(w,{className:`size-4`})}),t?null:(0,Q.jsx)(x,{label:X(`project.remove`),onClick:i,className:J(Un,`hover:text-rose`),children:(0,Q.jsx)(be,{className:`size-4`})})]})]}),(0,Q.jsx)(Wn,{name:e.name,namePlaceholder:X(`project.gradientName`),description:e.description,usePlaceholder:X(`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=Oe(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":X(`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":X(`project.download`),title:X(`project.download`),className:J(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,Un),children:(0,Q.jsx)(w,{className:`size-4`})}),r?null:(0,Q.jsx)(x,{label:X(`project.remove`),onClick:o,className:J(Un,`hover:text-rose`),children:(0,Q.jsx)(be,{className:`size-4`})})]})]}),(0,Q.jsx)(Wn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:X(`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(/\.[^.]+$/,``)})))},h=()=>{for(let e of f)s(e);l()};return(0,Q.jsx)(L,{open:!0,onClose:h,wide:!0,title:X(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(Oe(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)(A,{className:`size-4`}):(0,Q.jsx)(M,{className:`size-4`}),X(`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)(A,{className:`size-5`}):(0,Q.jsx)(M,{className:`size-5`}),X(`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)(y,{children:X(`project.patternName`)}),(0,Q.jsx)(q,{value:u.name,maxLength:80,placeholder:u.file?r(u.file):X(`project.patternNamePlaceholder`),onChange:e=>d({...u,name:e.target.value})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`project.fillUseLabel`)}),(0,Q.jsx)(q,{value:u.description??``,maxLength:400,placeholder:X(`project.patternUse`),onChange:e=>d({...u,description:e.target.value})})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`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:J(`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:X(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)(F,{variant:`ghost`,onClick:h,children:X(`common.cancel`)}),(0,Q.jsx)(F,{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:X(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,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{colors:t}=await f.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(u(t),p([])):c(X(`project.colorsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(L,{open:!0,onClose:n,wide:l?!0:void 0,title:X(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:X(`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:()=>p(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:J(`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)(ke,{className:`size-3.5`})}):null]},e.value)})}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(F,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.value))),n()},children:d.length>1?X(`project.addMany`,{n:d.length}):X(`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)(y,{children:X(`project.logoUrl`)}),(0,Q.jsx)(q,{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:X(`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)(F,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`run.next`)})]})]})})}function Zn({projectId:e,data:t,colors:n,sections:r,gradients:s,patterns:c,rules:l,sectioned:u,ruled:d,save:f,readOnly:p}){let[m,g]=(0,Z.useState)(()=>n.map(e=>({...e,id:De()}))),[_,v]=(0,Z.useState)(r),[y,b]=(0,Z.useState)(s),[S,C]=(0,Z.useState)(c),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(null),O=re(e,p),k=te(l),[ee,A]=(0,Z.useState)(null),[j,ne]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),F=o({colors:m.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:S,colorRules:k.rules},f),I=u?_:[],L=I.filter(e=>(e.kind??`colors`)===`colors`),ie=e=>L.some(t=>t.id===e.section),R=m.filter(e=>!ie(e)),ae=(R[0]??m[0])?.id,B=(e,t)=>g(n=>n.map(n=>n.id===e?{...n,...t}:n)),oe=e=>g(t=>[...t,...e.map(e=>({...e,id:De()}))].slice(0,a.colors)),U=[{value:``,label:X(`project.sectionStandard`)},...L.map(e=>({value:e.id,label:e.title||X(`project.sectionUntitled`)}))],se=(e,t)=>{let n=De();A(n),v(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},le=e=>({id:De(),name:``,section:e,type:`linear`,angle:90,stops:[{color:m[0]?.value&&Yn.test(m[0].value)?m[0].value:`#4b73ff`,at:0},{color:m[1]?.value&&Yn.test(m[1].value)?m[1].value:`#ff6d1b`,at:100}]}),de=e=>t.files.find(t=>t.id===e)?.name??`pattern`,fe=[...m.length<a.colors?[{label:X(`project.colorNew`),icon:(0,Q.jsx)(W,{className:`size-4 shrink-0`}),onPick:()=>G()},{label:X(`project.colorsFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>N(!0)}]:[],...u&&_.length<a.logoSections?[{label:X(`project.colorSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>se(`colors`,``)},{label:X(`project.gradientSectionAdd`),icon:(0,Q.jsx)(en,{className:`size-4 shrink-0`}),onPick:()=>se(`gradients`,X(`project.gradientSectionTitle`))},{label:X(`project.patternSectionAdd`),icon:(0,Q.jsx)(ln,{className:`size-4 shrink-0`}),onPick:()=>se(`patterns`,X(`project.patternSectionTitle`))}]:[],...!d||k.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>k.add()}]],pe=e=>(0,Q.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,Q.jsx)(i,{value:Yn.test(e.value)?e.value:`#888888`,onChange:t=>B(e.id,{value:t.target.value})}),(0,Q.jsx)(q,{value:e.name,autoFocus:e.id===j,placeholder:X(`project.colorName`),maxLength:120,onChange:t=>B(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,Q.jsx)(q,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>B(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===ae?(0,Q.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,Q.jsx)(P,{tone:`ember`,children:X(`project.colorAccent`)})}):p?null:(0,Q.jsx)(x,{label:X(`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)(h,{className:`size-4`})}),p||!L.length?null:(0,Q.jsx)(ue,{options:U,value:ie(e)?e.section??``:``,onChange:t=>B(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)(x,{label:X(`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)(be,{className:`size-4`})})]})]},e.id),G=e=>{let t=De();ne(t),g(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,Q.jsxs)(Y,{title:X(`project.colors`),hint:X(`project.colorsHint`),save:F,locked:p,action:p?null:(0,Q.jsx)(H,{entries:fe}),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[R.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:R.map(pe)}),p?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.colorUse`)})]}):m.length?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:X(`project.colorsEmpty`)}),I.map(t=>{let n=t.kind??`colors`,r=m.filter(e=>e.section===t.id),i=y.filter(e=>e.section===t.id),o=S.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)(V,{title:t.title,titlePlaceholder:X(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,Q.jsx)(en,{}),label:X(`project.kindGradients`)}:n===`patterns`?{icon:(0,Q.jsx)(ln,{}),label:X(`project.kindPatterns`)}:{icon:(0,Q.jsx)(Ct,{}),label:X(`project.kindColors`)},autoFocus:ee===t.id,readOnly:p,onChange:e=>v(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!s||confirm(X(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||X(`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)O.remove(e.file);C(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:()=>T(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:()=>T(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)(W,{className:`size-5`}),X(`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:de(t.file),readOnly:p,onEdit:()=>D(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{O.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),p||S.length>=a.files.pattern?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>D({id:De(),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)(W,{className:`size-5`}),X(`project.patternAdd`)]})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(pe),p||m.length>=a.colors?null:(0,Q.jsx)(ce,{label:X(`project.colorAdd`),onClick:()=>G(t.id)})]})]},t.id)}),d?(0,Q.jsx)(z,{rules:k,placeholder:X(`project.colorRulePlaceholder`),readOnly:p}):null]}),O.error?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:O.error}):null,w?(0,Q.jsx)(Vn,{projectId:e,gradient:w,isNew:!y.some(e=>e.id===w.id),brand:m.filter(e=>Yn.test(e.value)),onClose:()=>T(null),onSave:e=>b(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,E?(0,Q.jsx)(Jn,{projectId:e,pattern:E,isNew:!S.some(e=>e.id===E.id),fileName:de,busy:O.busy,error:O.error,upload:async e=>(await O.upload(`pattern`,[e]))[0]??null,removeFile:e=>void O.remove(e),onClose:()=>D(null),onSave:e=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,M?(0,Q.jsx)(Xn,{projectId:e,onClose:()=>N(!1),onAdd:oe}):null]})}var Qn=e=>/^(ja|yes|true)$/i.test(e.trim()),$n={text:je,longtext:gt,number:Le,date:Re,url:Ee,email:Tt,phone:mt,boolean:ze};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=`${X(`project.factType`)}: ${X(`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:J(`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:J(`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)(Me,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:X(`project.factAuto`)}),(0,Q.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:X(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:J(`size-4 shrink-0`,e&&`invisible`)})]}),(0,Q.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Te.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:X(`project.type.${t}`)}),(0,Q.jsx)(ke,{className:J(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function tr({facts:e,save:t,readOnly:n}){let r=(0,Z.useRef)(0),i=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),u=o(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),d=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),f=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};l(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},m=s.filter(e=>!c.some(t=>t.key===e));return(0,Q.jsxs)(Y,{title:X(`project.facts`),hint:X(`project.factsHint`),save:u,locked:n,action:c.length<a.facts&&!n?(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`,!0),children:[(0,Q.jsx)(W,{className:`size-4`}),` `,X(`project.factAdd`)]}):null,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=pe(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)(q,{ref:p(`${e.id}:label`),value:e.label,placeholder:X(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>d(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&d(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)(U,{checked:Qn(e.value),label:e.label,onChange:t=>d(e.id,{value:X(t?`project.yes`:`project.no`)})}),(0,Q.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Qn(e.value)?X(`project.yes`):X(`project.no`)})]}):(0,Q.jsx)(_e,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:X(`project.factValue`),onChange:t=>d(e.id,{value:t.target.value}),className:`min-h-11`}),(0,Q.jsx)(er,{type:e.type,detected:t,onChange:t=>d(e.id,{type:t})}),n?null:(0,Q.jsx)(x,{label:X(`project.remove`),onClick:()=>l(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,Q.jsx)(be,{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)(F,{variant:`secondary`,size:`sm`,onClick:()=>f({},`label`),children:[(0,Q.jsx)(W,{className:`size-4`}),` `,X(`project.factAdd`)]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f({key:e,label:X(`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)(W,{className:`size-3.5`}),` `,X(`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:J(`-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:s,ruled:c,save:l}){let u=re(e,n),[d,f]=(0,Z.useState)(r),p=te(i),[m,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),b=o({logoSections:d,logoRules:p.rules},l),x=t.files.filter(e=>e.kind===`logo`),S=new Map(x.map(e=>[e.id,e])),C=s?d:[],w=new Set(C.flatMap(e=>e.logos)),T=x.filter(e=>!w.has(e.id)),E=_(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:X(`project.sectionStandard`)},...C.map(e=>({value:e.id,label:e.title||X(`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?X(`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(X(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),ne=[{label:X(`project.logoUpload`),icon:(0,Q.jsx)(vt,{className:`size-4 shrink-0`}),onPick:()=>y.current?.click()},{label:X(`project.logoFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...s&&d.length<a.logoSections?[{label:X(`project.logoSectionAdd`),icon:(0,Q.jsx)(sn,{className:`size-4 shrink-0`}),onPick:()=>{let e=De();h(e),f(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!c||p.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>p.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.logos`),hint:X(`project.logosHint`),save:b,action:n?null:(0,Q.jsx)(H,{entries:ne}),children:[(0,Q.jsx)(`input`,{ref:y,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)(V,{title:e.title,description:e.description,titlePlaceholder:X(`project.logoSectionTitle`),descriptionPlaceholder:X(`project.logoSectionUse`),autoFocus:m===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:()=>{(!e.logos.length||confirm(X(`project.logoSectionRemoveConfirm`,{name:e.title||X(`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)(z,{rules:p,placeholder:X(`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:()=>v(!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 X(`project.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return X(`project.fontSourceFile`,{name:e})}return X(`project.fontSourceUrl`,{host:ir(n.url)})}function cr({projectId:e,font:t,onSave:n,onClose:r}){let i=(N(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),a=re(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),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(t.license??``),[b,x]=(0,Z.useState)(!1),S=d.trim(),C=async()=>{g(!0),m({url:S,result:await ar(S,t.family.trim())}),g(!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:X(`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:X(`project.fontSourceHint`)}),(0,Q.jsx)(R,{value:s,options:[`file`,`url`],label:e=>X(`project.fontSourceKind.${e}`),onChange:e=>c(e)}),s===`file`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`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:J(`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)(F,{variant:`ghost`,className:`mt-2`,busy:a.busy,onClick:()=>o.current?.click(),children:[(0,Q.jsx)(vt,{className:`size-4`}),X(`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)(y,{children:X(`project.fontSourceUrlLabel`)}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{value:d,inputMode:`url`,placeholder:X(`project.fontSourceUrlPlaceholder`),onChange:e=>f(e.target.value)}),(0,Q.jsx)(F,{type:`submit`,variant:`ghost`,busy:h,disabled:!S.startsWith(`https://`),children:X(`project.fontSourceCheck`)})]}),T?(0,Q.jsx)(`p`,{className:J(`mt-1.5 text-[0.875rem]`,T===`ok`?`text-ink-3`:`text-rose`),children:X(`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:X(`project.fontPrivacy`,{host:ir(S)})}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{hint:X(`project.fontLicenseHint`),children:X(`project.fontLicense`)}),(0,Q.jsx)(q,{value:_,maxLength:200,placeholder:X(`project.fontLicensePlaceholder`),onChange:e=>v(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)}),X(`project.fontLicenseConfirm`,{family:t.family})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,Q.jsx)(F,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),r()},children:X(`project.fontSourceRemove`)}):null,(0,Q.jsx)(F,{variant:`ghost`,onClick:r,children:X(`common.cancel`)}),(0,Q.jsx)(F,{disabled:!(w&&b),onClick:()=>{w&&(n({source:w,license:_.trim()||void 0}),r())},children:X(`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)}:${u.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=N(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)(fe,{value:t.family,label:X(`project.fontFamily`),placeholder:X(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,Q.jsx)(fe,{value:t.role,label:X(`project.fontRole`),placeholder:X(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:u.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:J(`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)(fe,{value:t.license??``,label:X(`project.fontLicense`),placeholder:X(`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:X(`project.fontUses`)}),ne.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):ne.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:J(`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)(ke,{className:`size-3.5`}):null,X(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:X(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)(x,{label:X(`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)(be,{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)(fe,{value:e.name,label:X(`project.styleName`),placeholder:X(`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":X(`project.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:J(pr,`max-w-40`),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.family||X(`project.fontFamily`)},e.id))}):null,(0,Q.jsx)(`select`,{"aria-label":X(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:pr,children:[...new Set([...u,e.weight])].sort().map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))}),(0,Q.jsx)(fr,{unit:`px`,label:X(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,Q.jsx)(fr,{unit:X(`project.styleLine`),label:X(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,Q.jsx)(fr,{unit:X(`project.styleTracking`),label:X(`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:X(`project.styleUpper`),"aria-label":X(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:J(`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)(x,{label:X(`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)(be,{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,p]=(0,Z.useState)([]),m=async()=>{o(!0),c(null);try{let{fonts:t}=await f.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(u(t),p(t.slice(0,2).map(e=>e.family))):c(X(`project.fontsNoneFound`))}catch(e){c(e.message)}o(!1)};return(0,Q.jsx)(L,{open:!0,onClose:n,wide:l?!0:void 0,title:X(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:X(`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:()=>p(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)(F,{variant:`ghost`,onClick:()=>u(null),children:X(`run.back`)}),(0,Q.jsx)(F,{disabled:!d.length,onClick:()=>{t(l.filter(e=>d.includes(e.family))),n()},children:d.length>1?X(`project.addMany`,{n:d.length}):X(`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)(y,{children:X(`project.logoUrl`)}),(0,Q.jsx)(q,{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:X(`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)(F,{variant:`ghost`,onClick:n,children:X(`common.cancel`)}),(0,Q.jsx)(F,{type:`submit`,busy:a,disabled:!r.trim(),children:X(`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:J(`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(` · `):X(`project.fontWeightsUnknown`)})]}),t?(0,Q.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,Q.jsx)(ke,{className:`size-3.5`})}):null]})}function yr({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:s,save:c,readOnly:l}){let[u,d]=(0,Z.useState)(t),[f,p]=(0,Z.useState)(n),m=te(r),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),y=o({fonts:u,textStyles:f,typeRules:m.rules},c),b=(e,t=!1)=>{let n=e.map(e=>({id:De(),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=De();g(e),p(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},S=[...u.length<a.fonts?[{label:X(`project.fontNew`),icon:(0,Q.jsx)(W,{className:`size-4 shrink-0`}),onPick:()=>b([{family:``,weights:[400,700]}],!0)},{label:X(`project.fontsFromUrl`),icon:(0,Q.jsx)(dn,{className:`size-4 shrink-0`}),onPick:()=>v(!0)}]:[],...f.length<a.textStyles?[{label:X(`project.styleNew`),icon:(0,Q.jsx)(xt,{className:`size-4 shrink-0`}),onPick:x}]:[],...!i||m.full?[]:[{label:X(`project.ruleNew`),icon:(0,Q.jsx)(Ae,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,Q.jsxs)(Y,{title:X(`project.typography`),hint:X(`project.typographyHint`),save:y,action:l?null:(0,Q.jsx)(H,{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:X(`project.fontsEmpty`)}),f.length?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:X(`project.styles`)}),l?null:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:X(`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:s,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)(z,{rules:m,placeholder:X(`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??``),[i,a]=(0,Z.useState)(e.brand.about??``),s=o({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,Q.jsx)(Y,{title:X(`project.base`),hint:X(`project.baseHint`),save:s,locked:e.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`project.title`)}),(0,Q.jsx)(q,{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:X(`project.titleHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(y,{children:X(`project.about`)}),(0,Q.jsx)(_e,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:X(`project.aboutHint`)})]})]})})}function xr({project:e,group:t,top:n=!1,children:r}){let i=O(),a=N(e.id),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),u=async t=>{await f.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:I.spaces()})},d=Ie({mutationFn:()=>f.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:I.spaces()})}),p=ft(),m=ut(),h=a.data??{files:[],embeddings:!0},g=`${e.id}:${o}`,_=e.readOnly,v=t===`knowledge`,y=kt(`brandSections`),b=kt(`brandRules`),x=kt(`typography`);return Rt(_?{}:{title:X(v?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:X(v?`project.assistantHelloKnowledge`:`project.assistantHello`),about:X(v?`project.assistantAboutKnowledge`:`project.assistantAbout`),placeholder:X(v?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:v?[{label:X(`assistant.suggest.knowledgeHow`)},{label:X(`assistant.suggest.knowledgeSite`),fill:!0},{label:X(`assistant.suggest.knowledgeCategories`)}]:[{label:X(`assistant.suggest.readSite`),fill:!0},{label:X(`assistant.suggest.missing`)},{label:X(`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)(_t,{children:ht(e)}):n?(0,Q.jsx)(Ft,{}):null,t===`info`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{id:`base`,children:(0,Q.jsx)(br,{project:e,save:u},`base:${g}`)}),(0,Q.jsx)(K,{id:`facts`,children:(0,Q.jsx)(tr,{facts:e.facts,save:e=>u({facts:e}),readOnly:_},`facts:${g}`)}),(0,Q.jsx)(K,{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)(K,{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)(K,{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||X(`project.typeSample`),save:e=>u({brand:e}),readOnly:_},`typography:${g}`)}):null,(0,Q.jsx)(K,{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`&&p&&!_&&m?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{variant:`danger`,onClick:()=>l(!0),children:X(`settings.delete`)}),(0,Q.jsxs)(L,{open:c,onClose:()=>l(!1),title:X(`settings.deleteTitle`,{name:e.name}),children:[(0,Q.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:X(`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)(F,{variant:`ghost`,onClick:()=>l(!1),children:X(`common.cancel`)}),(0,Q.jsx)(F,{variant:`danger`,busy:d.isPending,onClick:()=>d.mutate(),children:X(`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=X(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,Q.jsxs)(`p`,{className:$,children:[e.map((e,t)=>e===`{brand}`?(0,Q.jsx)(v,{to:`/space/info`,className:`text-ink underline-offset-2 hover:underline`,children:X(`space.info`)},t):e===`{facts}`?(0,Q.jsx)(v,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:X(`project.facts`)},t):e),` `,X(`page.onlyShared`)]})}function Dr({host:e,value:t,onChange:n,disabled:r}){let i=G.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":X(`page.address`),maxLength:E.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:J(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Cr)})]}),(0,Q.jsx)(`p`,{className:J(`mt-1.5`,$,!i&&t&&`text-rose`),children:X(`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)(y,{children:X(`page.title`)}),(0,Q.jsx)(q,{value:t.title,disabled:r,maxLength:E.title,onChange:e=>n({title:e.target.value})}),(0,Q.jsx)(`p`,{className:J(`mt-1.5`,$),children:X(`page.titleHint`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(y,{children:X(`page.address`)}),(0,Q.jsx)(Dr,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,Q.jsx)(`p`,{className:J(`mt-1`,$),children:X(`page.addressChange`)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(y,{children:X(`page.headline`)}),(0,Q.jsx)(q,{value:t.headline??``,disabled:r,maxLength:E.headline,onChange:e=>n({headline:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,Q.jsx)(y,{children:X(`page.words`)}),(0,Q.jsx)(_e,{value:t.intro??``,disabled:r,minRows:3,maxLength:E.intro,onChange:e=>n({intro:e.target.value})})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(y,{children:X(`page.lang`)}),(0,Q.jsx)(ae,{value:t.voice,onChange:e=>n({voice:e}),options:Sr.map(e=>({value:e.value,label:X(e.label)}))}),(0,Q.jsx)(`p`,{className:J(`mt-1.5`,$),children:X(`page.langHint`)})]})]})}function kr(e,t){if(!e.published)return X(`page.draftNote`);if(!e.shareEnabled)return X(`page.notSharedNote`);let n=e.description.trim();return t?[n,X(`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:J(`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":`${X(`page.moveUp`)} / ${X(`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)(d,{className:`size-4`})}):(0,Q.jsx)(`span`,{className:`size-7 shrink-0`}),(0,Q.jsx)(pt,{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:J(`truncate`,$),children:kr(e,t)})]}),(0,Q.jsx)(U,{checked:n,disabled:r||!e.published,label:X(`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:J(`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:J(`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:X(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:J(`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":X(`page.resize`),title:X(`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[s,c]=(0,Z.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:Be(t)})),l=o(s,async e=>{if(!(G.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=ot(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:s,disabled:n,onChange:e=>c(t=>({...t,...e}))})}function Wr({project:e}){let t=O(),n=dt(),r=n.data?.tenant.pagesHost??null,i=n.data?.manageUrl??null,a=e.readOnly,o=e.page,s=!!o?.on,c=ye({queryKey:I.projectWizards(e.id),queryFn:()=>f.get(`/api/studio/projects/${e.id}/wizards`)}),[l,u]=(0,Z.useState)(1),[d,p]=(0,Z.useState)(Br),m=(0,Z.useRef)(o);m.current=o;let h=async n=>{await f.patch(`/api/studio/projects/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:I.spaces()}),u(e=>e+1)},_=Ie({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:x}=Tr(),C=c.data??[],w=(o?.wizards??[]).map(e=>C.find(t=>t.id===e)).filter(e=>e!==void 0),T=C.filter(e=>!o?.wizards.includes(e.id)),[E,D]=(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),_.mutate({wizards:n})},A=(e,t)=>_.mutate({wizards:t?[...o?.wizards??[],e]:(o?.wizards??[]).filter(t=>t!==e)}),j=e.brand.name?.trim()||e.name,te=Ie({mutationFn:()=>h({on:!0,slug:S(j)||`page`,title:j,...ot(bt===`de`?`de-du`:`en`),wizards:C.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),ne=e=>{o?_.mutate({on:e}):e&&te.mutate()},M=_.isPending||te.isPending,N=_.error??te.error;if(!r)return(0,Q.jsx)(K,{id:`page`,children:(0,Q.jsx)(Y,{title:X(`space.page`),hint:X(`page.intro`),children:(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:X(`page.cloudOnly`)})})});let P=o?.slug||S(j)||`…`,re=Ue(r,P),L=at(r,P,i),ie=(0,Q.jsxs)(`span`,{className:J(Cr,`min-w-0 truncate`),children:[(0,Q.jsxs)(`span`,{className:`text-ink-3`,children:[r,`/`]}),(0,Q.jsx)(`b`,{className:`text-ink`,children:P})]}),R=a||!o,ae=(0,Q.jsxs)(g,{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:X(`page.previewTitle`)}),s?(0,Q.jsx)(nt,{named:!0,label:X(`editor.device`),value:d,onChange:e=>{p(e),Vr(e)},options:[{id:`desktop`,label:X(`editor.deviceDesk`),icon:(0,Q.jsx)(St,{className:`size-3.5`})},{id:`tablet`,label:X(`page.deviceTablet`),icon:(0,Q.jsx)(_n,{className:`size-3.5`})},{id:`mobile`,label:X(`editor.devicePhone`),icon:(0,Q.jsx)(st,{className:`size-3.5`})}]}):null]}),s?(0,Q.jsx)(Hr,{url:L,version:l,device:d}):(0,Q.jsx)(`p`,{className:$,children:X(`page.previewOff`)}),s?(0,Q.jsx)(`p`,{className:$,children:X(`page.previewHint`)}):null]}),z=(0,Q.jsxs)(g,{className:`flex flex-col gap-3 p-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:X(`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:X(`share.onPage`,{space:o?.title||j})}),(0,Q.jsx)(`span`,{className:J(`block truncate font-mono`,$),children:re})]}),(0,Q.jsx)(U,{checked:!0,disabled:!0,label:X(`page.showOnPage`),onChange:()=>{}})]}),(0,Q.jsx)(`p`,{className:$,children:X(`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)(K,{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:X(`space.page`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:X(`page.intro`)})]}),(0,Q.jsxs)(g,{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:J(`size-2 shrink-0 rounded-full`,s?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ie]}),(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,Q.jsxs)(F,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>x(L),children:[b?(0,Q.jsx)(ke,{className:`size-3.5`}):(0,Q.jsx)(ee,{className:`size-3.5`}),X(b?`share.copied`:`share.copyMain`)]}),(0,Q.jsxs)(F,{size:`sm`,className:`max-sm:flex-1`,disabled:!s,onClick:()=>window.open(L,`_blank`,`noopener`),children:[X(`page.open`),` `,(0,Q.jsx)(Ot,{className:`size-3.5`})]})]})]}),(0,Q.jsxs)(Y,{title:X(`page.sectionPage`),locked:a,children:[(0,Q.jsxs)(`fieldset`,{"aria-label":X(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,Q.jsx)(jr,{title:X(`page.whoOff`),text:X(`page.whoOffHint`),picked:!s,disabled:a||M,onPick:()=>ne(!1)}),(0,Q.jsx)(jr,{title:X(`page.whoPublic`),text:X(`page.whoPublicHint`),picked:s,disabled:a||M,onPick:()=>ne(!0)}),(0,Q.jsx)(jr,{title:X(`page.whoMembers`),text:X(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),N?(0,Q.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:N.message}):null]})]})}),ae,(0,Q.jsx)(K,{id:`page-words`,children:(0,Q.jsx)(Y,{title:X(`page.sectionWords`),hint:o?void 0:X(`page.notYet`),save:o?v:void 0,locked:R,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:P,title:j,headline:``,intro:``,voice:bt===`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:X(`page.sectionWizards`)}),(0,Q.jsx)(`span`,{className:$,children:X(`page.wizardsHint`)})]}),(0,Q.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[w.map((e,t)=>(0,Q.jsx)(Ar,{wizard:e,first:t===0,on:!0,disabled:R,onToggle:t=>A(e.id,t),drag:{onDragStart:()=>D(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{E!==null&&k(E,t),D(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),k(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),T.map(e=>(0,Q.jsx)(Ar,{wizard:e,first:!1,on:!1,disabled:R,onToggle:t=>A(e.id,t)},e.id))]}),C.length?null:(0,Q.jsx)(`p`,{className:J(`mt-2`,$),children:X(`page.noWizards`)}),(0,Q.jsx)(`p`,{className:J(`mt-4`,$),children:X(`page.wizardsNote`)})]}),(0,Q.jsx)(Er,{})]})})})]}),z]})}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:()=>f.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:le,label:X(`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)(ae,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:X(`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)(le,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,Q.jsx)(q,{type:`search`,value:a,onChange:e=>o(e.target.value),id:Gr,placeholder:X(`space.resultsSearch`),"aria-label":X(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,Q.jsx)(ae,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:X(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,Q.jsx)(ae,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:X(`space.resultsAnyTime`)},{value:`1`,label:X(`space.resultsDay`)},{value:`7`,label:X(`space.resultsDays`,{n:7})},{value:`30`,label:X(`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??``,c=new Intl.DateTimeFormat(bt,{dateStyle:`medium`,timeStyle:`short`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Y,{title:t?s(t):X(`space.resultsAll`),hint:X(`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)(g,{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?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,Q.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,X(`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:X(`space.resultFiles`,{n:e.assets}),children:[(0,Q.jsx)(oe,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,Q.jsx)(P,{children:X(`run.testChip`)}):(0,Q.jsxs)(P,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,Q.jsx)(g,{children:(0,Q.jsx)(p,{children:r.q.trim()||r.mode||r.days?X(`space.resultsNone`):X(`space.resultsEmpty`)})})]}),a?(0,Q.jsx)(et,{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)(P,{children:X(`run.testChip`)}):(0,Q.jsxs)(P,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,Q.jsx)(ct,{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??Fe,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}=Se(),[t,n]=ve(),i=se(),a=r(),{hash:o}=a,{project:s,loading:c}=lt(),l=Bt(),u=Qt(),[d,f]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=Mt(e)?e:void 0,y=v?void 0:l.spaceParts.find(t=>t.id===e),b=v??y?.id,x=a.state?.parts===!0,S=kt(`pages`),C=Pt().filter(e=>S||e.id!==`page`),w=Nt(C,l).map(e=>({...e,to:`/space/${e.id}`})),T={id:`results`,label:X(`space.results`),icon:wt,to:`/space/results`},E=v===`results`?T:w.find(e=>e.id===b),D=t.get(`show`),O=v===`results`?2:b?D?2:1:0,k=v===`results`?1:u?Math.min(O,1):b&&g!==b&&!x?1:0,ee=Gt(k),A=Gt(O),j=(0,Z.useMemo)(()=>({slot:d,narrow:u,setDetail:h}),[d,u]),te=s?s.brand.name?.trim()||s.name:X(`nav.project`),ne=kt(`typography`)?[]:[`typography`],M=y?l.spaceMenus[y.id]??[]:[],N=y?[{plugin:null,label:null,sections:M}]:v&&v!==`results`?It(v,l,ne):[],P=v?It(v,l).filter(e=>e.plugin):[],re=Xr([...N,...v===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),F=v===`results`&&D&&D!==`all`?D:null,[I,L]=(0,Z.useState)(Kr),R=qr(v===`results`?s?.id:void 0,F,I),ae=R.data?.wizards.find(e=>e.id===F)?.title,z=v===`data`&&D&&D!==`all`||v===`knowledge`&&D&&/^[ptfcvs]:/.test(D)?D:null,B=z?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=v===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,oe=We(v===`data`?s?.id:void 0),H=Ze(v===`knowledge`?s?.id:void 0),U=it(z?.startsWith(`v:`)?z.slice(2):``),ce=H.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):U.data?.category.id)),le=v===`knowledge`?B?B.label():z?.startsWith(`v:`)?U.data&&`${U.data.category.name}: ${U.data.value}`:z?.startsWith(`c:`)?ce?.name:H.data?.items.find(e=>e.key===z)?.title:oe.data?tt(oe.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;Ht([...v===`results`?[]:[{label:X(`nav.project`),to:`/space`}],...E?[{label:E.label,to:`/space/${E.id}`}]:[],...E&&(m??ae??le)?[{label:m??ae??le}]:[]]);let ue={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Rt({...v===`data`||v===`results`?{compact:!0}:{},...v===`data`?{suggestions:[{label:X(`assistant.suggest.dataWhat`)},{label:X(`assistant.suggest.dataWho`)},{label:X(`assistant.suggest.dataEdit`)}]}:v===`results`?{suggestions:[{label:X(`assistant.suggest.resultsFailed`)},{label:X(`assistant.suggest.resultsCost`)},{label:X(`assistant.suggest.resultsShare`)}]}:{},...z&&le?{open:{kind:ue[z[0]]??`item`,id:z.slice(2),label:le}}:F&&ae?{open:{kind:`wizard`,id:F,label:ae}}:{}});let W=v===`results`||v===`data`||z?o.slice(1):D||o.slice(1),de=(0,Z.useRef)(``);(0,Z.useEffect)(()=>{let e=`${b}#${W}`;W&&de.current!==e&&document.getElementById(W)&&(de.current=e,requestAnimationFrame(()=>Qr(W,!1)))},[b,W,s?.id,l.spaceSections,M.length]),(0,Z.useEffect)(()=>{!u&&(b===`knowledge`||b===`data`)&&Vt().scrollTo({top:0})},[u,b,z]);let fe=Zr();if(!b){let t=o.slice(1),n=t?jt(t,l):null;if(n===`knowledge`&&l.spaceSections.some(e=>e.id===t))return(0,Q.jsx)(ie,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,Q.jsx)(ie,{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)(ie,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(v===`knowledge`&&!D&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,Q.jsx)(ie,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let pe=e=>{if(u){i({search:`?show=${e}`});return}de.current=`${b}#${e}`,Qr(e,!0),i({search:``,hash:e},{replace:!0})},G=e=>u?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),me=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)(K,{id:e.id,children:(0,Q.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,Q.jsx)(zt,{of:e,children:(0,Q.jsx)(e.component,{})})})},e.serial)),he=u?void 0:re,ge=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qt,{title:te,open:k===1?E??null:null,onBack:v===`results`?void 0:()=>u?i(`/space`):_(b??null),root:{icon:Dt,label:X(`nav.project`),backLabel:X(`nav.wizards`),onBack:()=>i(`/`)}}),(0,Q.jsx)(`div`,{className:J(Wt(ee)),children:k===0?(0,Q.jsx)(Yt,{entries:w,current:u?void 0:E,onPick:()=>_(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:J(`grid gap-6`,v!==`results`&&`md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[v===`results`?null:(0,Q.jsx)(`aside`,{className:J(`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&&fe?{maxHeight:fe-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:ge}),b?(0,Q.jsxs)(`div`,{className:J(`min-w-0`,u&&O<2&&`hidden`,u&&A===`deeper`&&Wt(`deeper`)),children:[u&&v!==`results`?(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Zt,{label:E?.label??te,onBack:()=>i(`/space/${b}`)})}):null,v===`data`?(0,Q.jsxs)(Xt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ut,{icon:Et,label:X(`data.all`),selected:!u&&!z,onPick:()=>G(`all`)})}),oe.data?tt(oe.data).map(e=>(0,Q.jsx)(Kt,{label:e.label,children:e.items.map(e=>(0,Q.jsx)(Ut,{icon:He[e.kind],label:e.title,selected:!u&&e.key===z,onPick:()=>G(e.key)},e.key))},e.key)):null,(0,Q.jsx)($r,{groups:P,current:he,onPick:pe})]}):v===`knowledge`?(0,Q.jsxs)(Xt,{children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,Q.jsx)(Ut,{icon:Et,label:X(`know.all`),selected:!(u||z),onPick:()=>G(`all`)})}),H.data?.categories.length?(0,Q.jsx)(Kt,{label:X(`know.categories`),children:H.data.categories.map(e=>(0,Q.jsx)(Ut,{icon:Je[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&&(z===`c:${e.id}`||U.data?.category.id===e.id),onPick:()=>G(`c:${e.id}`)},e.id))}):null,(0,Q.jsx)($r,{groups:P,current:u?void 0:B?.id,onPick:e=>G(`s:${e}`)})]}):(0,Q.jsx)(Xt,{children:(0,Q.jsx)($r,{groups:N,current:he,onPick:pe})}),s&&(v===`info`||v===`knowledge`)?(0,Q.jsxs)(xr,{project:s,group:v,top:!z||!!B,children:[v===`knowledge`?V?V.startsWith(`p:`)?(0,Q.jsx)(Xe,{pageId:V.slice(2),onGone:()=>G(`all`),onOpen:G},V):V.startsWith(`t:`)?(0,Q.jsx)(Ye,{tableId:V.slice(2),onGone:()=>G(`all`)},V):(0,Q.jsx)(An,{projectId:s.id,fileId:V.slice(2),readOnly:s.readOnly,onGone:()=>G(`all`)},V):H.data?B?(0,Q.jsx)(Y,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,Q.jsx)(zt,{of:B,children:(0,Q.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?ce?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(qe,{projectId:s.id,category:ce,readOnly:s.readOnly,onOpen:G,onGone:()=>G(`all`)}),ce.type===`choice`?null:(0,Q.jsx)(rt,{projectId:s.id,category:ce,categories:H.data.categories,onOpen:G})]},z):null:z?.startsWith(`v:`)?U.data?(0,Q.jsx)(Ve,{value:U.data,readOnly:s.readOnly,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[U.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:U.data.items.map(e=>(0,Q.jsx)(Ge,{item:e,categories:H.data.categories.filter(e=>e.id!==U.data?.category.id),onOpen:G},e.key))}):null,U.data.rows.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>G(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:X(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,Q.jsx)(K,{id:`documents`,children:(0,Q.jsx)($e,{projectId:s.id,data:H.data,readOnly:s.readOnly,onOpen:G})}):null:null,v===`info`?me(P):null]},s.id):null,s&&v===`page`&&S?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,Q.jsx)(Wr,{project:s},s.id),me(P)]}):null,s&&y?(0,Q.jsx)(zt,{of:y,children:(0,Q.jsx)(At,{part:y.id,children:(0,Q.jsx)(y.component,{})},s.id)}):null,s&&v===`data`?(0,Q.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,Q.jsx)(Ye,{tableId:z.slice(2),onGone:()=>G(`all`)},z):z?.startsWith(`p:`)?(0,Q.jsx)(Xe,{pageId:z.slice(2),onGone:()=>G(`all`)},z):(0,Q.jsxs)(Q.Fragment,{children:[oe.data?(0,Q.jsx)(Qe,{projectId:s.id,data:oe.data,readOnly:s.readOnly,onOpen:G}):null,me(P)]})}):null,s&&v===`results`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,Q.jsx)(Yr,{data:R.data,wizardId:F,onWizard:e=>G(e??`all`),filter:I,onFilter:L}):null,R.isError?(0,Q.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,me(P)]}):null,s||c?null:(0,Q.jsx)(p,{children:X(`settings.noProject`)})]}):null]})})})}export{ei as ProjectPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ft as r,G as i,Kn as a,Kt as o,Q as s,Qt as c,Un as l,Vt as u,Xn as d,ct as f,er as p,in as m,it as h,lt as ee,rn as g,rr as _,rt as v,tr as te}from"./ui-gsqxnFnT.js";import{_ as y,b,d as x,f as ne,g as S,h as C,m as w,n as re,p as ie,v as T,y as E}from"./theme-DTi1Zdw8.js";import{O as ae,S as D,b as oe,x as O}from"./session-xJpGiTU_.js";import{V as k,a as A,l as j,s as M}from"./i18n-DEmaSTJV.js";import{$ as N}from"./index-ClNm5JaU.js";var P={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`}]]};P.node;var se=a(P),F={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`]};F.node;var ce=a(F),I=e(t(),1);function le(){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 L=le(),ue=L?new URLSearchParams(window.location.search).get(`page`):null,R=new URLSearchParams(window.location.search).get(`theme`),z=R?`?theme=${encodeURIComponent(R)}`:``,B=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),de=()=>B(`close`);function fe(e){(0,I.useEffect)(()=>{if(L===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>B(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(L===`modal`||L===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&B(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var V=e(n(),1),H=`wizards.runner.translate`,U=new Set;function pe(){try{return localStorage.getItem(H)===`on`}catch{return!1}}function me(e){try{localStorage.setItem(H,e?`on`:`off`)}catch{}for(let e of U)e()}function he(){return(0,I.useSyncExternalStore)(e=>(U.add(e),()=>U.delete(e)),pe)}function ge(e){let t=he(),[n]=(0,I.useState)(()=>j()),r=e?.lang??`en`,a=e?.translatable&&n&&n!==r?n:null,o=a&&t?a:r,s=e?.token,c=_({queryKey:[`public-translation`,s,o],enabled:!!(s&&o!==r),queryFn:()=>i.post(`/api/public/wizards/${s}/translation${z}`,{lang:o}),staleTime:1/0,retry:!1}),l=_({queryKey:[`public-texts`,s,o],enabled:!(!s||k(o)),queryFn:()=>i.get(`/api/public/wizards/${s}/texts/${o}`),staleTime:1/0,retry:!1}),u=!k(o),d=o===r||c.data&&(!u||l.data),f=o!==r&&(c.isError||u&&l.isError),p=d&&!f?o:r,m=(0,I.useMemo)(()=>!k(p)&&l.data?.lang===p?{lang:l.data.lang,runner:l.data.runner,notes:l.data.notes}:null,[p,l.data]);if((0,I.useEffect)(()=>{e&&A(p,m)},[e,p,m]),(0,I.useEffect)(()=>()=>A(null),[]),!e)return null;let h=p!==r&&c.data?c.data:null;return{own:r,other:a,shown:p,wizard:h??e,translating:o!==r&&!d&&!f,failed:!!f,translated:!!h,machine:h?.translation?.machine??!1,pick:e=>me(e!==r)}}function W({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,V.jsx)(N,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function G({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,V.jsx)(`p`,{className:g(`text-ink-3`,n),children:M(`translation.failed`)}):e.translated?(0,V.jsxs)(`p`,{className:g(`text-ink-3`,n),children:[e.machine?(0,V.jsxs)(V.Fragment,{children:[M(`translation.machine`),` · `]}):null,(0,V.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:M(`translation.showOriginal`)})]}):null}function _e(e,t){let n=(0,I.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,I.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 ve(e,t){(0,I.useEffect)(()=>{if(!e||!t)return;let n=v(`/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 K=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,q=K||/Android/.test(navigator.userAgent);function ye(){let[e,t]=(0,I.useState)(()=>window.wizardInstall??null),[n,r]=(0,I.useState)(!1);if((0,I.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||q&&!e&&!K)return null;let i=/Mac/.test(navigator.platform),a=M(q?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,V.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{q&&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:[q?(0,V.jsx)(ce,{className:`size-4`}):(0,V.jsx)(se,{className:`size-4`}),M(q?`install.add`:`install.bookmark`)]}),n?(0,V.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function J({brand:e,toggle:t=!0,start:n}){return(0,V.jsx)(`header`,{className:`safe-top`,children:(0,V.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,V.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,V.jsx)(`img`,{src:v(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,V.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,V.jsx)(`div`,{className:`absolute right-3`,children:(0,V.jsx)(D,{})}):null]})})}function Y({siteKey:e,onToken:t}){let n=(0,I.useRef)(null);return(0,I.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,V.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function be({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||h||L?null:(0,V.jsxs)(`a`,{href:f(`${window.location.origin}${s}/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,V.jsx)(b,{className:`size-4`}),` `,M(`install.app`)]})}var X=e=>`wz.run.${e}`,Z=h&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=L===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=p(),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(null),d=(()=>{try{return localStorage.getItem(X(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:L!==null,origin:ue??void 0,lang:n??void 0});try{localStorage.setItem(X(e.token),a)}catch{}r(`${t}/${a}`,{replace:Z})}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:a,start:o,resume:s}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),d=Z&&e.available&&!e.turnstileSiteKey,f=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{d&&!f.current&&(f.current=!0,o())},[d]),d&&!r?(0,V.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,V.jsx)(c,{})}):(0,V.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,V.jsx)(O,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,V.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,V.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,V.jsx)(`div`,{className:`mt-3`,children:(0,V.jsx)(G,{page:t})}),e.available?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(u,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!i,onClick:o,children:[M(`run.start`),` `,(0,V.jsx)(l,{className:`size-4`})]}),e.turnstileSiteKey?(0,V.jsx)(Y,{siteKey:e.turnstileSiteKey,onToken:a}):null,s?(0,V.jsx)(`button`,{type:`button`,onClick:s,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:M(`run.resume`)}):null,(0,V.jsx)(Se,{wizard:e,current:`steps`}),L||h?null:(0,V.jsx)(ye,{}),(0,V.jsx)(be,{token:e.token})]}):(0,V.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??M(`run.unavailable`)}),r?(0,V.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,V.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,V.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:M(`run.orAs`,{label:e.label})},e.id))}):null}function Ce({wizard:e,page:t}){let n=E();return(0,V.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,V.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,V.jsx)(`span`,{className:g(n?.speaking&&`animate-breathe`),children:(0,V.jsx)(O,{kind:e.avatar,costume:e.costume,size:38})}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,V.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,V.jsx)(G,{page:t,small:!0})]}),e.brand.logoUrl&&L!==`popout`?(0,V.jsx)(`img`,{src:v(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,V.jsx)(W,{page:t,tone:`surface`}),L?null:(0,V.jsx)(D,{}),L===`popout`?(0,V.jsx)(o,{label:M(`common.close`),onClick:de,children:(0,V.jsx)(m,{className:`size-5`})}):null]})})}function we({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,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:M(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??M(`run.unavailable`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(T(`start`,(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(S,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void u(),children:[M(`run.start`),` `,(0,V.jsx)(l,{className:`size-4`})]}),d?(0,V.jsx)(S,{onClick:d,children:M(`run.resume`)}):null,t.turnstileSiteKey?(0,V.jsx)(Y,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,V.jsxs)(w,{header:r,footer:i,children:[(0,V.jsx)(y,{avatar:t.avatar,costume:t.costume,lines:f}),(0,V.jsx)(C,{})]})}function Te({className:e}){return(0,V.jsx)(`footer`,{className:g(`text-center text-ink-4`,e),children:(0,V.jsx)(`a`,{href:`${s}/`,target:L?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:M(`run.madeWith`).replace(`engenty wizards`,oe.name)})})}function Ee({chat:e=!1,steps:t=!1,talk:n=!1,video:a=!1}){let{token:o,runId:l}=te(),f=p(),m=_({queryKey:[`public`,o,z],queryFn:()=>i.get(`/api/public/wizards/${o}${z}`),retry:(e,t)=>r(t)&&e<3}),v=m.data?.runners??[],y=!m.data||v.some(e=>e.id===`talk`),b=!m.data||v.some(e=>e.id===`video`),S=!m.data||v.some(e=>e.id===`chat`)||n&&y||a&&b,C=v[0]?.id,w=e||L===`popout`||!t&&!l&&S&&(C===`chat`||C===`talk`||C===`video`),T=a&&b||!t&&!e&&!n&&C===`video`,E=!T&&(n&&y||!t&&!e&&C===`talk`),D=T?`video`:E?`talk`:`chat`,k=ge(m.data);_e(l,k),re(m.data?.brand.theme),ae(m.data?.avatar),ve(o,m.data?.title),fe(w);let A=k?.wizard.title??m.data?.title;if((0,I.useEffect)(()=>{A&&(document.title=A)},[A]),(0,I.useEffect)(()=>{o&&l&&ee(`run`,{token:o,runId:l})},[o,l]),m.isLoading)return(0,V.jsx)(`div`,{className:g(`flex items-center justify-center text-ink-4`,Q),children:(0,V.jsx)(c,{})});if(e&&m.data&&!S||n&&m.data&&!y||a&&m.data&&!b)return(0,V.jsx)(d,{to:`/w/${o}`,replace:!0});if(!m.data){let e=r(m.error);return(0,V.jsxs)(`div`,{className:g(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,V.jsx)(O,{kind:`pebble`,size:80}),(0,V.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:M(e?`common.offline`:`run.notFound`)}),e?(0,V.jsx)(u,{variant:`secondary`,onClick:()=>void m.refetch(),children:M(`common.retry`)}):null]})}let j=k?.wizard??m.data,N=k?.translating?(0,V.jsxs)(`div`,{className:g(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,V.jsx)(c,{}),(0,V.jsx)(`p`,{className:`text-[0.875rem]`,children:M(`translation.working`)})]}):null;if(w){let e=(0,V.jsx)(Ce,{wizard:j,page:k}),t=h?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(Te,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,V.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,V.jsx)(x,{effects:m.data.brand.theme.effects}),N??(l?(0,V.jsx)(ie,{runId:l,talk:E,call:T?`video`:E?`audio`:!1,onRestart:()=>f(`/w/${o}/${D}`),header:T||E?void 0:e,footer:t}):(0,V.jsx)(we,{wizard:j,page:k,header:e,footer:t,door:D}))]})}return(0,V.jsxs)(`div`,{className:g(`wizard-page flex flex-col`,Q),children:[(0,V.jsx)(x,{effects:m.data.brand.theme.effects}),L===`inline`||h?null:(0,V.jsx)(J,{brand:m.data.brand,toggle:!L,start:(0,V.jsx)(W,{page:k})}),L===`inline`||h?(0,V.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,V.jsx)(W,{page:k,tone:`surface`})}):null,l&&(k?.translated||k?.failed)?(0,V.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,V.jsx)(G,{page:k})}):null,(0,V.jsx)(`div`,{className:`flex-1`,children:N??(l?(0,V.jsx)(ne,{runId:l,onRestart:()=>f(`/w/${o}`)}):(0,V.jsx)(xe,{wizard:j,page:k}))}),h?(0,V.jsx)(`div`,{className:`safe-bottom`}):(0,V.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,V.jsx)(`a`,{href:`${s}/`,target:L?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:M(`run.madeWith`).replace(`engenty wizards`,oe.name)})})]})}export{J as BrandHeader,Ee as PublicRunner};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Hn as n}from"./ui-6AgUKJhQ.js";import{s as r}from"./i18n-UTsgNY5M.js";import{Pt as i}from"./index-DHIXX69l.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
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./jsx-runtime-BNakU3Ej.js";import{Kn as n}from"./ui-gsqxnFnT.js";import{s as r}from"./i18n-DEmaSTJV.js";import{Ft as i}from"./index-ClNm5JaU.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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-Bx6j5lZO.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-gsqxnFnT.js","assets/preload-helper-DpV6A1kQ.js","assets/i18n-DEmaSTJV.js","assets/logo-CGNoptDg.js","assets/engenty-CNjaZCVM.js","assets/index-ClNm5JaU.js","assets/Marketplace-CFDpVMWM.js","assets/useMutation-BS-U9g_a.js","assets/volume-2-CYOgux-z.js","assets/coins-CwURUZyt.js","assets/session-xJpGiTU_.js","assets/react-dom-hf6EcyAr.js","assets/media-Cej-H610.js","assets/index-DImS12WR.css","assets/settings-menu-DcPFhgGA.js","assets/ChangelogDialog-C620Sw_A.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{G as r,Gt as i,Ht as a,In as o,Jn as s,Kn as c,Kt as l,Or as u,Pn as d,Qt as f,Rn as p,Un as m,Ut as h,Vt as g,W as _,Xn as v,Yt as y,Zt as b,en as x,er as S,fn as ee,gn as C,kn as w,mn as te,nr as ne,qt as T,rn as E,rr as D,sn as re,tr as ie,wn as ae,y as oe,yn as se,zn as O}from"./ui-gsqxnFnT.js";import{E as ce,S as le,T as ue}from"./Marketplace-CFDpVMWM.js";import{t as k}from"./useMutation-BS-U9g_a.js";import{t as de}from"./preload-helper-DpV6A1kQ.js";import{n as fe,r as pe,t as me}from"./volume-2-CYOgux-z.js";import{n as he,r as ge,t as _e}from"./wrench-DIfUvYPN.js";import{t as ve}from"./coins-CwURUZyt.js";import{d as ye,g as be,n as xe,p as Se,y as Ce}from"./session-xJpGiTU_.js";import{n as we,r as Te,t as Ee}from"./ReadOnly-DGBDtXFP.js";import{E as De,O as Oe,n as A,s as j}from"./i18n-DEmaSTJV.js";import{B as ke,Dt as Ae,Ft as je,G as Me,H as Ne,J as Pe,K as Fe,M as Ie,N as Le,Q as Re,U as ze,V as Be,W as Ve,X as M,Y as N,Z as He,_ as Ue,_t as We,at as Ge,b as Ke,bt as qe,it as Je,j as Ye,jt 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 P,zt as F}from"./index-ClNm5JaU.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-DcPFhgGA.js";import{t as mt}from"./Harness-Br0Z_anI.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=c(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=c(_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=c(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=c(bt),z=e(t(),1),B=e(n(),1);function St(){let e=tt(),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(null),a=async e=>{n(e??`*`),i(null);try{await Ze(e)}catch(e){i(e.message)}finally{n(null)}};return(0,B.jsxs)(oe,{title:j(`plugins.title`),hint:e.canReload?j(`plugins.hint`):j(`plugins.hintManaged`),action:e.canReload?(0,B.jsx)(g,{variant:`secondary`,busy:t===`*`,onClick:()=>void a(),children:j(`plugins.rescan`)}):null,children:[e.plugins.length||e.problems.length?null:(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:j(`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:[j(`plugins.tools`),n.tools.map(e=>(0,B.jsx)(h,{children:e.id},e.id))]}):null,n.error?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:j(`plugins.serverFailed`,{error:n.error})}):null,r?(0,B.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:j(`plugins.studioFailed`,{error:r})}):null]}),e.canReload?(0,B.jsx)(l,{label:j(`plugins.reload`),disabled:t!==null,onClick:()=>void a(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)(h,{tone:`warn`,children:j(`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(De[A],{day:`numeric`,month:`long`});function Dt(){let e=u(),{canReload:t}=tt(),n=D({queryKey:Ct,queryFn:()=>r.get(wt),enabled:t}),i=t=>e.setQueryData(Ct,t),a=k({mutationFn:()=>r.post(`${wt}/refresh`),onSuccess:i}),o=k({mutationFn:e=>r.post(`${wt}/${e}`),onSuccess:i}),s=k({mutationFn:e=>r.del(`${wt}/${e}`),onSuccess:i}),c=n.data,l=o.isPending||s.isPending,d=o.error??s.error??a.error;return t?(0,B.jsx)(oe,{title:j(`pro.title`),hint:j(`pro.hint`),action:c?.linked?(0,B.jsx)(g,{variant:`secondary`,busy:a.isPending,onClick:()=>a.mutate(),children:j(`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:j(`pro.failed`,{error:n.error.message})}),(0,B.jsx)(g,{variant:`secondary`,onClick:()=>void n.refetch(),children:j(`pro.retry`)})]}):c?c.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:[c.plan?j(`pro.plan`,{plan:c.plan.name}):null,c.plan&&c.expiresAt?` · `:null,c.expiresAt?j(`pro.confirmedUntil`,{date:Et(c.expiresAt)}):null]}),(0,B.jsxs)(g,{variant:`ghost`,onClick:()=>P(`${c.accountUrl}/billing`),children:[j(`pro.plans`),` `,(0,B.jsx)(w,{className:`size-4`})]})]}),c.error?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c.error}):null,c.modules.length?(0,B.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:c.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)(h,{tone:`live`,children:j(`pro.on`)}):null,e.included?null:(0,B.jsx)(h,{children:j(`pro.notInPlan`)}),e.installed&&e.heldBack&&e.included?(0,B.jsx)(h,{tone:`warn`,children:j(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:l,onClick:()=>o.mutate(e.id),children:e.installed?j(`pro.update`):j(`pro.install`)}):null,e.installed?(0,B.jsx)(g,{variant:`secondary`,busy:s.isPending&&s.variables===e.id,disabled:l,onClick:()=>s.mutate(e.id),children:j(`pro.remove`)}):null]})]},e.id))}):(0,B.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:j(`pro.none`,{runtime:c.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:j(`pro.notLinked`)}):(0,B.jsx)(f,{})}):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:E(`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?j(`connectors.actions`,{n:e.actions.length,r:e.actions.filter(e=>e.group===`read`).length}):j(`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:[j(`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} (${j(`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 i=u(),[a,o]=(0,z.useState)(!1),s=()=>i.invalidateQueries({queryKey:_.connectors(e)}),c=`/api/studio/projects/${e}/connectors/${t.id}`,d=k({mutationFn:()=>r.post(`${c}/refresh`),onSuccess:s}),p=k({mutationFn:()=>r.del(c),onSuccess:s}),m=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)(fe,{className:`size-4`})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>o(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`,` ·`,` `,j(kt[t.auth]),` ·`,` `,t.toolsPending?j(`connectors.pending`):j(`connectors.actions`,{n:t.actions.length,r:m})]})]}),n?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(l,{label:j(`connectors.refresh`),onClick:()=>d.mutate(),children:d.isPending?(0,B.jsx)(f,{className:`size-4`}):(0,B.jsx)(te,{className:`size-4`})}),(0,B.jsx)(l,{label:j(`connectors.remove`),className:`hover:text-rose`,onClick:()=>confirm(j(`connectors.removeConfirm`,{name:t.name}))&&p.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:j(`connectors.needsClient`)}):null,d.error??p.error?(0,B.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:(d.error??p.error).message}):null,a&&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:E(`w-14 shrink-0 text-[0.6875rem] uppercase tracking-wide`,e.group===`read`?`text-moss`:e.group===`write`?`text-ink-3`:`text-rose`),children:j(`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:i,onDone:a}){let o=u(),[s,c]=(0,z.useState)({id:``,secret:``}),[l,d]=(0,z.useState)(!1),f=i.includes(n.suggestedId),p=k({mutationFn:()=>r.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}:{},...s.id&&s.secret?{oauthClientId:s.id,oauthClientSecret:s.secret}:{}}),onSuccess:async t=>{await o.invalidateQueries({queryKey:_.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)(h,{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:j(`connectors.ownClient`)}),(0,B.jsx)(g,{size:`sm`,busy:p.isPending,onClick:()=>p.mutate(),children:j(`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:j(`connectors.exists`)}):null,l?(0,B.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,B.jsx)(T,{placeholder:j(`connectors.clientId`),value:s.id,onChange:e=>c(t=>({...t,id:e.target.value}))}),(0,B.jsx)(T,{type:`password`,autoComplete:`off`,placeholder:j(`connectors.clientSecret`),value:s.secret,onChange:e=>c(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=We(`unsetConnectors`),[i,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(null),[d,m]=(0,z.useState)([]),h=D({queryKey:_.connectors(e),queryFn:()=>r.get(`/api/studio/projects/${e}/connectors`)}),v=k({mutationFn:()=>r.post(`/api/studio/connectors/search`,{query:i}),onSuccess:e=>{c(e),u(null),m([])}}),y=k({mutationFn:e=>r.get(`/api/studio/connectors/registry/${encodeURIComponent(e)}`),onSuccess:u}),b=h.data??[],x=b.filter(e=>e.sourceKind===`builtin`&&(n||e.usable)),S=b.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:j(`connectors.title`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:j(`connectors.hint`)}),x.length?(0,B.jsx)(`div`,{className:`mb-5 grid gap-1.5 sm:grid-cols-2`,children:x.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:j(`connectors.imported`)}),S.length?(0,B.jsx)(`div`,{className:`mb-4 flex flex-col gap-2`,children:S.map(n=>(0,B.jsx)(At,{projectId:e,connector:n,readOnly:t},n.id))}):null,t?S.length?null:(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:j(`connectors.noneImported`)}):(0,B.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),i.trim()&&v.mutate()},children:[(0,B.jsx)(T,{value:i,placeholder:j(`connectors.search`),onChange:e=>o(e.target.value)}),(0,B.jsxs)(g,{type:`submit`,variant:`secondary`,busy:v.isPending,children:[(0,B.jsx)(ee,{className:`size-4`}),` `,j(`connectors.find`)]})]}),v.error?(0,B.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:v.error.message}):null,s&&!l?(0,B.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[s.length?null:(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:j(`connectors.none`)}),s.map(e=>(0,B.jsxs)(`button`,{type:`button`,disabled:!e.kinds.length,onClick:()=>y.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)(p,{className:`-rotate-90 size-4 text-ink-4`})]},e.domain)),y.isPending?(0,B.jsx)(f,{className:`mx-auto mt-2 size-4 text-ink-4`}):null,y.error?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:y.error.message}):null]}):null,l?(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:l.domain}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>u(null),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:j(`run.back`)})]}),l.summary?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:l.summary}):null,l.sources.map(t=>(0,B.jsx)(jt,{projectId:e,domain:l.domain,source:t,taken:b.map(e=>e.id),onDone:m},`${t.sourceKind}:${t.sourceUrl}`)),l.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)),d.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:E(`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)(l,{label:j(n?`settings.copied`:`settings.copy`),onClick:async()=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)},children:n?(0,B.jsx)(O,{className:`size-4`}):(0,B.jsx)(d,{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:j(`integrate.wpIntro`)})]}),(0,B.jsxs)(a,{className:`flex flex-col gap-5 p-5`,children:[(0,B.jsxs)(Bt,{title:j(`integrate.wpInstall`),children:[(0,B.jsx)(U,{children:j(`integrate.wpInstallHint`)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(g,{variant:`secondary`,size:`sm`,onClick:()=>window.open(Vt,`_blank`),children:j(`integrate.wpDownload`)})})]}),(0,B.jsx)(Bt,{title:j(`integrate.wpConnect`),children:(0,B.jsx)(U,{children:j(e?`integrate.wpConnectHint`:`integrate.wpConnectLocal`)})}),(0,B.jsxs)(Bt,{title:j(`integrate.wpPlace`),children:[(0,B.jsx)(U,{children:j(`integrate.wpPlaceHint`)}),(0,B.jsx)(H,{text:`[engenty_wizard id="ID" mode="modal" label="${j(`integrate.wpSampleLabel`)}"]`})]}),(0,B.jsx)(Bt,{title:j(`integrate.wpPro`),children:(0,B.jsx)(U,{children:j(`integrate.wpProHint`)})}),(0,B.jsx)(Bt,{title:j(`integrate.wpLocal`),children:(0,B.jsx)(U,{children:j(`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:j(`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:j(`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:j(`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:j(`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:j(`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:j(`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:j(`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:j(`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:j(`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:j(`mcp.claudeAi`)}),(0,B.jsx)(H,{text:t})]});case`chatgpt`:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:j(`integrate.chatgpt`)}),(0,B.jsx)(H,{text:t})]});default:return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:j(`integrate.generic`)}),(0,B.jsx)(H,{text:t}),r?(0,B.jsx)(H,{text:r}):null]})}}function Gt(){let e=u(),t=D({queryKey:[`api-keys`],queryFn:()=>r.get(`/api/studio/api-keys`)}),n=k({mutationFn:e=>r.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:j(`mcp.keys`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-4 text-[0.875rem] text-ink-3`,children:j(`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?j(`settings.lastUsed`,{when:new Date(e.lastRequest).toLocaleString(A)}):j(`settings.neverUsed`)]})]}),(0,B.jsx)(l,{label:j(`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:E(`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}),j(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)(O,{className:`size-3.5 text-moss`,strokeWidth:3});return(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[n(r,j(`integrate.outRun`)),e.widgets?n(r,j(`integrate.outWidget`)):n((0,B.jsx)(Te,{className:`size-3.5 text-ink-3`}),j(`integrate.outText`)),t?n((0,B.jsx)(he,{className:`size-3.5 text-ink-3`}),j(`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)(h,{tone:`live`,icon:(0,B.jsx)(O,{className:`size-3.5`,strokeWidth:3}),children:j(`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:E(`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:E(`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)(O,{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:E(`font-medium text-[0.9375rem]`,t===`later`&&`text-ink-2`),children:n}),r?(0,B.jsx)(`div`,{className:E(`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:j(`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`}),j(`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)(O,{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,j(`integrate.checkSeen`)),n(!!t?.toolAt,j(`integrate.checkTool`)),e.widgets?n(!!t?.widgetAt,j(`integrate.checkWidget`)):null]})}function tn(){let e=be().data,{project:t}=ye(),n=D({queryKey:[`wizards`,t?.id,!!e?.account],queryFn:()=>r.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:j(`integrate.labelRun`),text:j(`integrate.askRun`,{title:n.title})},{label:j(`integrate.labelBuild`),text:j(`integrate.askBuild`)},{label:j(`integrate.labelExplain`),text:j(`integrate.askExplain`,{title:n.title})}]:[{label:j(`integrate.labelAsk`),text:j(`integrate.askTool`)},{label:j(`integrate.labelBuild`),text:j(`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:j(`integrate.next`)}),(0,B.jsx)(U,{children:j(`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)(Te,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),j(`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:i}){let a=u(),[s,c]=(0,z.useState)(!1),[l,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(!1),m=k({mutationFn:t=>r.post(`/api/studio/local/apps/${e.id}`,{connect:t}),onSuccess:e=>d(e),onError:e=>d({ok:!1,message:e.message}),onSettled:()=>a.invalidateQueries({queryKey:[`local-apps`]})}),h=!!t?.connected,_=!!n?.toolAt;if(s)return(0,B.jsx)(on,{client:e,seen:n,url:i,onBack:()=>c(!1)});let v=t=>(0,B.jsxs)(B.Fragment,{children:[t?(0,B.jsx)(`span`,{children:j(`integrate.addedIn`,{app:e.name})}):null,(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:()=>p(!f),children:[j(`integrate.details`),(0,B.jsx)(o,{className:E(`size-3.5 transition`,f&&`rotate-90`)})]}),(0,B.jsx)(`button`,{type:`button`,className:K,disabled:m.isPending,onClick:()=>m.mutate(!1),children:j(`mcp.appsDisconnect`)})]}),y=f&&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:_,children:(0,B.jsx)(Zt,{client:e})}),_?(0,B.jsx)(nn,{client:e,footer:(0,B.jsxs)(rn,{children:[v(!0),y]})}):(0,B.jsxs)(Qt,{children:[(0,B.jsxs)(G,{n:1,state:h?`done`:`now`,title:j(h?`integrate.connected`:`integrate.connect`,{app:e.name}),children:[h?(0,B.jsxs)(rn,{children:[v(!1),y]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:t?.installed===!1?j(`integrate.notInstalled`,{app:e.name}):j(`integrate.connectHint`,{app:e.name})}),(0,B.jsx)(`div`,{children:(0,B.jsxs)(g,{busy:m.isPending,onClick:()=>m.mutate(!0),children:[(0,B.jsx)(C,{className:`size-4`}),` `,j(`integrate.connect`,{app:e.name})]})})]}),l&&!l.ok?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:l.message}):null,l?.snippet?(0,B.jsx)(H,{text:l.snippet}):null]}),(0,B.jsx)(G,{n:2,state:n?`done`:h?`now`:`later`,title:j(`integrate.restart`,{app:e.name}),children:n?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:j(`integrate.restartHint`)}),h?(0,B.jsx)($t,{app:e.name}):null]})}),(0,B.jsxs)(G,{n:3,state:n?`now`:`later`,title:j(`integrate.try`),children:[(0,B.jsx)(U,{children:j(`integrate.tryHint`)}),(0,B.jsx)(H,{text:j(`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)(pe,{className:`size-4 text-ink-3`}),j(`integrate.elsewhere`,{app:e.name}),(0,B.jsx)(`button`,{type:`button`,className:K,onClick:()=>c(!0),children:j(`integrate.byAddress`)})]})]})}function on({client:e,seen:t,url:n,onBack:i}){let a=u(),[o,s]=(0,z.useState)(),c=k({mutationFn:()=>r.post(`/api/studio/api-keys`,{name:e.name.slice(0,32)}),onSuccess:async e=>{s(e.key),await a.invalidateQueries({queryKey:[`api-keys`]})}}),l=(0,B.jsx)(`p`,{className:`text-[0.875rem]`,children:(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:i,children:[(0,B.jsx)(Ae,{className:`size-4`}),j(`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:o?`done`:`now`,title:o?j(`integrate.keyReady`):j(`integrate.keyCreate`,{app:e.name}),children:o?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(U,{children:j(`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`}),` `,j(`integrate.keyCreate`,{app:e.name})]})})]})}),(0,B.jsx)(G,{n:2,state:o?t?`done`:`now`:`later`,title:j(`integrate.add`),children:o&&!t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Wt,{id:e.id,url:n,apiKey:o}),(0,B.jsx)(`p`,{className:`text-[0.75rem] text-ink-4`,children:j(`integrate.addressLocal`)}),(0,B.jsx)($t,{app:e.name})]}):null}),(0,B.jsxs)(G,{n:3,state:t?`now`:`later`,title:j(`integrate.try`),children:[(0,B.jsx)(U,{children:j(`integrate.tryHint`)}),(0,B.jsx)(H,{text:j(`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:j(`integrate.consentPreview`,{app:e})}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.6875rem] text-moss`,children:[(0,B.jsx)(he,{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:j(`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:()=>P(a.open),children:[j(`integrate.openConnectors`),(0,B.jsx)(w,{className:`size-4`})]}),(0,B.jsx)(U,{children:j(a.where)})]}):(0,B.jsx)(U,{children:j(a.where)})}),(0,B.jsx)(G,{n:2,state:`todo`,title:j(`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:j(`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:j(`integrate.address`)}),(0,B.jsx)(H,{text:t})]})]})}),(0,B.jsx)(G,{n:3,state:n?`done`:`todo`,title:j(`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:j(`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:j(`integrate.try`),children:[n?.toolAt?null:(0,B.jsx)(H,{text:j(`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:[j(`integrate.revoke`),(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:()=>P(e),children:[j(`integrate.revokeLink`),(0,B.jsx)(m,{className:`size-3.5`})]})]})}function un({client:e,me:t,onDesktop:n}){let r=t.account?.signedIn?t.account:null,i=Le(!!r),o=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:j(`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)(F,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),j(`integrate.linked`,{email:r.email,app:e.name})]}),(0,B.jsx)(cn,{client:e,url:`${r.cloudUrl}/api/mcp`,tracked:!1,accountUrl:r.url})]}):o?(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:j(`integrate.viaAccount`)}),(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[{icon:Ae,title:j(`integrate.tileHere`),text:j(`integrate.tileHereText`)},{icon:F,title:`engenty.ai`,text:j(`integrate.tileCloudText`)},{icon:Xe,title:e.name,text:j(`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)(F,{className:`size-4`}),` `,j(`integrate.linkAccount`)]}),(0,B.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:j(`integrate.linkHint`,{app:e.name})})]}),(0,B.jsx)(Ie,{...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:[j(`integrate.noAccount`),(0,B.jsxs)(`button`,{type:`button`,className:K,onClick:n,children:[j(`integrate.useDesktop`),(0,B.jsx)(m,{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:j(`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:j(`integrate.allowFirst`),children:t?null:(0,B.jsx)(U,{children:j(`integrate.allowFirstHint`,{app:e.name})})}),(0,B.jsx)(G,{n:3,state:t?`now`:`later`,title:j(`integrate.try`),children:(0,B.jsx)(H,{text:j(`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)(ce,{className:`size-5`}):(0,B.jsx)(_e,{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:E(`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)(O,{className:`size-3.5`,strokeWidth:3}):null,j(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)(ce,{className:`size-3.5`}):(0,B.jsx)(Te,{className:`size-3.5`}),j(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:j(`integrate.connectShort`)}):(0,B.jsx)(g,{size:`sm`,variant:t===`added`?`primary`:`secondary`,onClick:n,children:j(t===`works`?`integrate.view`:t===`added`?`integrate.testIt`:`integrate.connectShort`)})})]})}function pn({managed:e,here:t,web:n,standing:i,open:o}){let s=u(),c=k({mutationFn:e=>r.post(`/api/studio/local/apps/${e}`,{connect:!0}),onSettled:()=>s.invalidateQueries({queryKey:[`local-apps`]}),onSuccess:(e,t)=>o(t)}),l=(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:i(e.id),onOpen:()=>o(e.id),onConnect:t?()=>c.mutate(e.id):void 0,busy:c.isPending&&c.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:j(`integrate.title`)}),(0,B.jsx)(`p`,{className:`mt-2 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:j(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:j(`integrate.groupBrowser`)}),l(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:j(`integrate.groupDesktop`)}),l(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:j(`integrate.found`)}),l(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:j(`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)(F,{className:`size-5`})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,B.jsx)(`div`,{className:`font-medium`,children:j(`integrate.cloudTitle`)}),(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:j(`integrate.cloudText`)})]}),(0,B.jsx)(g,{variant:`secondary`,onClick:()=>o(`claude-ai`),children:j(`integrate.cloudButton`)})]})]})]})]})}function mn(){let e=be(),t=e.data?.mode===`managed`,n=D({queryKey:[`local-apps`],queryFn:()=>r.get(`/api/studio/local/apps`),enabled:e.data?.mode===`local`}),i=D({queryKey:[`integrations-seen`],queryFn:()=>r.get(`/api/studio/integrations/seen`),refetchInterval:2500}),[a,o]=ne(),{narrow:s}=at(),c=nt(e.data?.features,`wordpress`),l=c||a.get(`show`)!==`wordpress`?a.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=>i.data?.[e],p=e=>Kt(d(e),f(e)),m=e=>o({show:e},{replace:!s}),h=e=>!!(d(e.id)?.installed||d(e.id)?.connected),g=Lt.filter(e=>e.oauth),_=Lt.filter(e=>!e.oauth&&(t||h(e))),v=t?[]:Lt.filter(e=>!e.oauth&&!h(e)),y=e.data.mcpUrl??``,b=e=>(0,B.jsx)(I,{icon:e.oauth?F:e.widgets?ce:_e,label:e.name,tone:qt[p(e.id)],toneLabel:j(Jt[p(e.id)]),selected:e.id===u?.id,onPick:()=>m(e.id)},e.id),x=e.data.manageUrl?`${e.data.manageUrl}/account`:null,S;return S=l===`wordpress`?(0,B.jsx)(Ht,{managed:t}):u?t&&(u.oauth||u.connector)?zt(y)?(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:x?(0,B.jsx)(ln,{accountUrl:x}):null}):(0,B.jsx)(cn,{client:u,url:y,seen:f(u.id),tracked:!0,accountUrl:x})]}):(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(W,{client:u,works:!1}),(0,B.jsx)(U,{children:j(`integrate.needsPublic`,{app:u.name})})]}):t?(0,B.jsx)(dn,{client:u,seen:f(u.id),url:y,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:y}):(0,B.jsx)(pn,{managed:t,here:_,web:g,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:j(t?`integrate.groupBrowser`:`integrate.groupHere`),children:(t?g:_).map(b)}),(0,B.jsx)(L,{label:j(t?`integrate.groupDesktop`:`integrate.groupCloud`),children:(t?_:g).map(b)}),v.length?(0,B.jsx)(L,{label:j(`integrate.groupMore`),collapsible:!0,open:v.some(e=>e.id===u?.id),count:v.length,children:v.map(b)}):null,(0,B.jsxs)(L,{label:j(`integrate.groupShare`),children:[(0,B.jsx)(I,{icon:ae,label:j(`integrate.shareLink`),badge:(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:j(`integrate.soon`)}),selected:!1,disabled:!0}),c?(0,B.jsx)(I,{icon:pe,label:`WordPress`,selected:l===`wordpress`,onPick:()=>m(`wordpress`)}):null,(0,B.jsx)(I,{icon:pe,label:j(`integrate.shareSite`),badge:(0,B.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4`,children:j(`integrate.soon`)}),selected:!1,disabled:!0})]}),(0,B.jsx)(Xt,{})]}),(0,B.jsx)(`div`,{children:S},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:Ue(e),harnesses:n?[]:e.harnesses,canEdit:!n||e.tenant.role!==`member`,ownKeys:!n||nt(e.features,`ownKeys`)}}var gn={text:se,image:le,video:ue,speech:me,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(Pe(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?He(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 M(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&&He(i)===e.id?i:e.models[t]?.[0]?.ref;return a?{[r]:a}:{}}function bn(e){return e.version===null?{note:j(`models.noteMissing`),noteTone:`warn`}:e.auth===`none`?{note:j(`models.noteSignedOut`),noteTone:`warn`}:e.auth===`api_key`?{note:j(`models.noteShellKey`)}:{note:j(`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:M(e.by??``)?.name??e.by??``,tone:`done`};case`local`:return{text:e.by===`apple`?j(`models.optApple`):j(`models.way.local`),tone:`done`};case`credits`:return{text:t.cloud?j(`models.way.creditsOrganization`):j(`models.way.credits`),tone:`ok`};default:return{text:j(`models.way.none`),tone:`warn`}}}function Sn(){return D({queryKey:[`models`],queryFn:()=>r.get(`/api/studio/models`)})}function Y(){let e=u();return k({mutationFn:e=>r.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:E(`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)(O,{className:`size-3.5`,strokeWidth:3}):null,t===`ok`?(0,B.jsx)(ve,{className:`size-3.5`}):null,t===`warn`?(0,B.jsx)(ge,{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:E(`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)(O,{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 i=Y(),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),d=k({mutationFn:t=>r.post(`/api/studio/models/keys/${e.id}/check`,t?{key:t}:{})}),f=async()=>{u(null);let t=await d.mutateAsync(a.trim());if(!t.ok){u({ok:!1,message:t.message??j(`models.keyBad`)});return}await i.mutateAsync({keys:{[e.id]:a.trim()}}),o(``),c(!1),u({ok:!0,message:j(`models.keyOk`)})},p=!t||s;return n.ownKeys?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[p?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(T,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:e.keyPlaceholder,value:a,disabled:!n.canEdit,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a.trim()&&f()}}),(0,B.jsx)(g,{busy:d.isPending||i.isPending,disabled:!a.trim()||!n.canEdit,onClick:()=>void f(),children:j(`models.keySave`)}),s?(0,B.jsx)(g,{variant:`ghost`,onClick:()=>c(!1),children:j(`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`}),` `,j(`models.keyStored`)]}),(0,B.jsx)(g,{size:`sm`,variant:`ghost`,busy:d.isPending,onClick:async()=>{let e=await d.mutateAsync(void 0);u(e.ok?{ok:!0,message:j(`models.keyOk`)}:{ok:!1,message:e.message??j(`models.keyBad`)})},children:j(`models.keyCheck`)}),n.canEdit?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),children:j(`models.keyReplace`)}),(0,B.jsx)(g,{size:`sm`,variant:`danger`,busy:i.isPending,onClick:()=>{u(null),i.mutate({keys:{[e.id]:``}})},children:j(`models.keyRemove`)})]}):null]}),l?(0,B.jsxs)(`p`,{className:E(`flex items-center gap-1.5 text-[0.8125rem]`,l.ok?`text-moss`:`text-rose`),children:[l.ok?(0,B.jsx)(O,{className:`size-3.5`,strokeWidth:3}):null,l.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:()=>P(e.keyUrl),className:`inline-flex items-center gap-1 font-medium text-ember-strong hover:underline`,children:[j(`models.keyGet`,{name:e.name}),` `,(0,B.jsx)(w,{className:`size-3`})]}),(0,B.jsx)(`span`,{children:n.cloud?j(`models.keyWhereCloud`):j(`models.keyWhereLocal`)})]})]}):(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:j(`models.ownKeysPlan`)})}var En=`__custom__`;function Dn({provider:e,cap:t,value:n,onPick:r,disabled:i}){let a=A,o=e.models[t]??[],s=o.some(e=>e.ref===n),[c,l]=(0,z.useState)(!s&&!!n),[u,d]=(0,z.useState)(s?``:n.replace(/^[a-z]+:/,``)),f=e.id===`gateway`?``:`${e.id}:`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsx)(b,{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:j(`models.modelCustom`)}]}),c?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(T,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:u,disabled:i,placeholder:o[0]?.ref.replace(/^[a-z]+:/,``)??``,onChange:e=>d(e.target.value)}),(0,B.jsx)(g,{variant:`secondary`,disabled:!u.trim()||i,onClick:()=>r(`${f}${u.trim()}`),children:j(`settings.save`)})]}):null]})}function On({provider:e,state:t}){let n=n=>N(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:j(`models.textSimple`)}),(0,B.jsx)(`dd`,{className:`truncate font-medium`,children:n(`low`)}),(0,B.jsx)(`dt`,{className:`text-ink-3`,children:j(`models.textDemanding`)}),(0,B.jsx)(`dd`,{className:`truncate font-medium`,children:n(`standard`)})]})}function kn(e,t){return t===`context`?j(`need.context`,{tokens:`${Math.round(Be[e].context/1e3)}k`}):j(`need.${t}`)}function An({cls:e,lacks:t}){let n=[...Be[e].needs,`context`];return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`text-[0.6875rem] text-ink-4 leading-snug`,children:j(`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)(ge,{className:`mt-px size-3 shrink-0`}),j(`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)(m,{className:`size-3.5 transition group-open:rotate-90`}),j(`models.perClass`)]})}),(0,B.jsx)(`div`,{className:`flex flex-col gap-3 px-3 pt-1 pb-3`,children:Oe.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:j(`class.${i}`)}),(0,B.jsx)(`div`,{className:`text-[0.6875rem] text-ink-4 leading-snug`,children:j(`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],i=k({mutationFn:()=>r.post(`/api/studio/models/test`,{cls:n,lang:A})}),a=i.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:i.isPending,disabled:t,onClick:()=>i.mutate(),children:j(`models.try.${e}`)}),(0,B.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:e===`video`?j(`models.tryCostVideo`):J(e)?null:j(`models.tryCost`)})]}),i.isPending&&e!==`text`?(0,B.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,B.jsx)(f,{className:`size-3.5`}),` `,j(e===`video`?`models.tryWaitVideo`:`models.tryWait`)]}):null,a?.ok?(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a.media&&e===`image`?(0,B.jsx)(`img`,{src:a.media,alt:``,className:`size-48 rounded-lg object-cover ring-1 ring-border-soft`}):null,a.media&&e===`speech`?(0,B.jsx)(`audio`,{src:a.media,controls:!0,autoPlay:!0,className:`w-full max-w-sm`}):null,a.media&&e===`video`?(0,B.jsx)(`video`,{src:a.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)(O,{className:`mt-0.5 size-3.5 shrink-0 text-moss`,strokeWidth:3}),(0,B.jsx)(`span`,{children:e===`listening`?a.reply?j(`models.tryHeard`,{text:a.reply}):j(`models.tryHeardNothing`):J(e)?j(`local.testOk`,{s:(a.ms/1e3).toFixed(1),ref:N(a.ref??``),reply:a.reply??``}):j(`models.tryOk`,{s:(a.ms/1e3).toFixed(1),model:N(a.ref??``)})})]})]}):null,a&&!a.ok?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:j(`models.tryFailed`,{error:a.error??``})}):null,i.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:j(`models.tryFailed`,{error:i.error.message})}):null]})}function Nn(e){let t=e=>(e<10?Math.round(e*10)/10:Math.ceil(e)).toLocaleString(A);return e?.creditsPerImage?j(`models.notePerImage`,{n:t(e.creditsPerImage)}):e?.creditsPerSecond?j(`models.notePerSecond`,{n:t(e.creditsPerSecond)}):e?.creditsPer1kCharacters?j(`models.notePer1k`,{n:t(e.creditsPer1kCharacters)}):e?.creditsPerMinute?j(`models.notePerMinute`,{n:t(e.creditsPerMinute)}):j(`models.noteUsage`)}function Pn(e,t){let n=Fe(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=>Me(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=Fe(t.bindings[i]),o=Fn(t,e),s=t.prices?.[i]?.model,c=e=>e.source===`ai-gateway`?M(e.provider)?.name??e.provider:M(e.source)?.name??e.source;return(0,B.jsx)(b,{value:a??``,onChange:e=>r.mutate({bindings:{[i]:Qe(e||null)}}),options:[{value:``,label:s?j(`models.creditsAuto`,{model:N(s)}):j(`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=Me(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)(ve,{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:[j(`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)(O,{className:`size-3.5`,strokeWidth:3}),` `,j(`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:j(`models.useFor`)})]},e.id)})})}function Rn({cap:e,state:t,place:n,me:r,onOpen:i}){let o=Y(),s=q[e],c=t.ways[s],l=vn(t,e,n),[u,d]=(0,z.useState)(!1),f=xn(c,n),p=n.harnesses.filter(t=>(J(e)||e===`image`&&t.images)&&(t.version!==null||l?.kind===`client`&&l.id===t.id)),m=Ve.filter(t=>t.models[e]?.length),h=r=>{if(d(!1),r.kind===`credits`&&!n.credits){d(!0);return}if(_n(r,l))return;let i=ke[e],a=e=>Object.fromEntries(i.map(t=>[t,e]));switch(r.kind){case`client`:o.mutate(J(e)?{source:r.id,bindings:Ce(t.bindings)}:{bindings:{[s]:`${r.id}/image`}});return;case`key`:{let i=M(r.provider);o.mutate({...J(e)&&!n.cloud?{source:`own`}:{},bindings:yn(i,e,t)});return}case`local`:o.mutate(r.by===`apple`?{bindings:J(e)?zn(t):{audio:`apple:transcribe`}}:{source:`own`,bindings:a(`ollama:qwen3`)});return;case`credits`:o.mutate(J(e)&&!n.cloud?{source:`account`,bindings:Ce(t.bindings)}:{bindings:a(Ne)});return}},g=l?.kind===`key`?M(l.provider):null,_=g?!t.keys[g.id]:!1,v=l?.kind===`client`?n.harnesses.find(e=>e.id===l.id):null,b=c.kind!==`none`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:gn[e],title:j(`models.cap.${e}`),lead:j(`models.cap.${e}.hint`),status:(0,B.jsx)(Cn,{...f})}),(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:j(`models.who`),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p.length?(0,B.jsx)(Q,{label:j(`models.optSubscription`),children:p.map(e=>(0,B.jsx)($,{title:e.name,...bn(e),selected:l?.kind===`client`&&l.id===e.id,disabled:!n.canEdit,onPick:()=>h({kind:`client`,id:e.id})},e.id))}):null,(0,B.jsx)(Q,{label:j(`models.optKey`),children:m.map(e=>(0,B.jsx)($,{title:e.name,note:t.keys[e.id]?j(`models.noteKey`):j(`models.noteNoKey`),noteTone:t.keys[e.id]?`done`:void 0,selected:l?.kind===`key`&&l.provider===e.id,disabled:!n.canEdit,onPick:()=>h({kind:`key`,provider:e.id})},e.id))}),(0,B.jsxs)(Q,{label:J(e)&&!n.cloud?j(`models.optOther`):j(`models.optCreditsGroup`),children:[(J(e)||e===`listening`)&&!n.cloud&&t.apple?.supported?(0,B.jsx)($,{title:j(`models.optApple`),note:J(e)?Bn(t.apple):j(`models.optAppleNote`),noteTone:J(e)&&!t.apple.available?void 0:`done`,selected:l?.kind===`local`&&l.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:j(`models.optLocal`),note:j(`models.optLocalNote`),selected:l?.kind===`local`&&l.by===`ollama`,disabled:!n.canEdit,onPick:()=>h({kind:`local`,by:`ollama`})}):null,(0,B.jsx)($,{title:n.cloud?j(`models.creditsOrganization`):j(`models.creditsName`),note:n.credits?Pn(e,t):j(`models.noteNeedsAccount`),noteTone:n.credits?`done`:void 0,selected:l?.kind===`credits`,disabled:!n.canEdit,onPick:()=>h({kind:`credits`})})]})]}),u?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:[j(`local.sourceNeedsAccount`),` `,(0,B.jsx)(Yn,{})]}):null,o.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o.error.message}):null]}),g?(0,B.jsxs)(B.Fragment,{children:[_?(0,B.jsxs)(X,{title:j(`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)(ve,{className:`mr-1 inline size-3.5 align-[-2px]`}),j(`models.keyFallback`)]}):null]}):null,_&&n.credits&&Fn(t,e,g.id).length?(0,B.jsx)(X,{title:j(`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:j(`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:j(`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)=>o.mutate({bindings:{[e]:t}})})]}):(0,B.jsx)(Dn,{provider:g,cap:e,value:t.bindings[s]??g.models[e]?.[0]?.ref??``,disabled:!n.canEdit,onPick:e=>o.mutate({bindings:{[s]:e}})},`${g.id}:${t.bindings[s]??``}`)})]}):null,l?.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:j(`models.clientImages`,{name:v.name,sub:j(`harness.sub.${v.id}`)})})}):null,l?.kind===`local`?l.by===`apple`?(0,B.jsx)(Vn,{cap:e,state:t,place:n}):(0,B.jsx)(Hn,{state:t,disabled:!n.canEdit}):null,l?.kind===`credits`&&n.credits?J(e)?(0,B.jsx)(X,{title:j(`models.creditsName`),children:(0,B.jsxs)(Z,{children:[j(`models.creditsPicks`),c.kind===`credits`&&c.ref?` ${j(`models.creditsModel`,{model:N(c.ref)})}`:``]})}):(0,B.jsxs)(X,{title:j(`models.model`),children:[(0,B.jsx)(In,{cap:e,state:t,disabled:!n.canEdit}),(0,B.jsx)(Z,{children:j(`models.creditsPickHint`)})]}):null,c.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)(ge,{className:`mt-0.5 size-3.5 shrink-0 text-ink-3`}),(0,B.jsx)(`span`,{children:(0,B.jsx)(y,{text:c.problem})})]}):null,l?.kind===`client`&&J(e)?null:(0,B.jsx)(X,{title:j(`models.try`),children:(0,B.jsx)(Mn,{cap:e,disabled:!b||!n.canEdit},`${e}:${c.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 j(`models.optAppleNote`);switch(e.reason){case`off`:return j(`models.appleOff`);case`loading`:return j(`models.appleLoading`);default:return j(`models.appleDevice`)}}function Vn({cap:e,state:t,place:n}){return(0,B.jsx)(X,{title:j(`models.optApple`),children:(0,B.jsx)(Z,{children:J(e)?j(`models.appleHint`,{way:xn(t.ways.standard,n).text}):j(`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:j(`models.optLocal`),children:[(0,B.jsx)(Z,{children:j(`models.ollamaHint`)}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_12rem_auto]`,children:[(0,B.jsx)(T,{className:`font-mono text-[0.8125rem]`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,B.jsx)(T,{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(Oe.map(e=>[e,`ollama:${a.trim()}`]))}),children:j(`settings.save`)})]})]})}var Un=[`claude`,`codex`,`cursor`],Wn=[`openai`,`anthropic`,`google`,`gateway`];function Gn(e,t,n){return e===`models`?j(`models.chatModels`):e===`account`?n.cloud?j(`models.creditsOrganization`):j(`models.creditsName`):t.harnesses.find(t=>t.id===e)?.name??M(e)?.name??e}function Kn({me:e,state:t,place:n,onOpen:i}){let o=u(),s=k({mutationFn:e=>r.put(`/api/studio/local/chat`,{engine:e}),onSuccess:()=>o.invalidateQueries({queryKey:[`me`]})}),[c,l]=(0,z.useState)(!1),d=t=>e.chatWays.includes(t),f=e=>{if(l(!1),e===`account`&&!d(e)){l(!0);return}if(Wn.includes(e)&&!d(e)){i({type:`provider`,id:e});return}s.mutate(e)},p=n.harnesses.filter(e=>Un.includes(e.id)&&e.version!==null),m=(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:()=>f(t)},t);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:Xe,title:j(`models.cap.chat`),lead:j(`models.cap.chat.hint`),status:(0,B.jsx)(Cn,{text:Gn(e.chatEngine,e,n),tone:d(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:j(`models.who`),children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p.length?(0,B.jsx)(Q,{label:j(`models.optSubscription`),children:p.map(e=>m(e.id,e.name,bn(e).note,d(e.id),!d(e.id)))}):null,(0,B.jsx)(Q,{label:j(`models.optKey`),children:Wn.map(e=>m(e,M(e)?.name??e,t.keys[e]?j(`models.noteKey`):j(`models.noteNoKey`),!!t.keys[e]))}),(0,B.jsxs)(Q,{label:j(`models.optOther`),children:[m(`models`,j(`models.chatModels`),xn(t.ways.high,n).text,d(`models`)),m(`account`,Gn(`account`,e,n),d(`account`)?j(`models.noteUsage`):j(`models.noteNeedsAccount`),d(`account`))]})]}),c?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:[j(`local.sourceNeedsAccount`),` `,(0,B.jsx)(Yn,{})]}):null,s.isError?(0,B.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:s.error.message}):null,(0,B.jsx)(Z,{children:j(`models.chatHint`)})]})})]})}function qn({provider:e,state:t,place:n,onOpen:r}){let i=Y(),o=ze.filter(t=>e.models[t]?.length),s=t.keys[e.id],c=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,A),status:(0,B.jsx)(Cn,{text:j(s?`models.keyStored`:`models.keyNone`),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:j(`models.key`),children:(0,B.jsx)(Tn,{provider:e,stored:s,place:n})}),(0,B.jsx)(X,{title:j(`models.uses`),children:(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:o.map(a=>{let o=gn[a],s=vn(t,a,n),c=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:j(`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(` · `)})]}),c?(0,B.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-[0.75rem] text-moss`,children:[(0,B.jsx)(O,{className:`size-3.5`,strokeWidth:3}),` `,j(`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:j(`models.useFor`)})]},a)})})}),c.length?(0,B.jsxs)(X,{title:j(`models.viaCredits`,{name:e.name}),children:[(0,B.jsx)(Z,{children:n.credits?j(`models.viaCreditsHint`):j(`models.viaCreditsNeedsAccount`)}),(0,B.jsx)(Ln,{models:c,state:t,place:n})]}):null]})]})}function Jn({me:e,id:t,state:n,place:r}){let i=Y(),o=r.harnesses.find(e=>e.id===t);if(!o)return null;let s=n.source===t,c=o.version!==null&&o.auth!==`none`;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:je,title:o.name,lead:j(`harness.desc.${t}`),status:(0,B.jsx)(Cn,{text:bn(o).note,tone:c?`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:j(`models.clientSignIn`),children:(0,B.jsx)(mt,{me:e,id:t})}),(0,B.jsxs)(X,{title:j(`models.uses`),children:[(0,B.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:[`text`,...o.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:j(`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)(O,{className:`size-3.5`,strokeWidth:3}),` `,j(`models.inUse`)]}):(0,B.jsx)(g,{size:`sm`,variant:`secondary`,busy:i.isPending,onClick:()=>i.mutate(e===`text`?{source:t,bindings:Ce(n.bindings)}:{bindings:{image:`${t}/image`}}),children:j(`models.useFor`)})]},e)})}),s?null:(0,B.jsx)(Z,{children:j(`models.clientNotChosen`,{name:o.name})})]})]})]})}function Yn(){return(0,B.jsx)(s,{to:`/settings/account`,className:`font-medium text-ember-strong underline-offset-2 hover:underline`,children:j(`local.toAccount`)})}function Xn({state:e,place:t,onOpen:n}){let r=Y(),i=ze.filter(t=>e.ways[q[t]].kind===`credits`),o=t.cloud?j(`models.creditsOrganization`):j(`models.creditsName`);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,B.jsx)(wn,{icon:ve,title:o,lead:t.cloud?j(`models.creditsCloudHint`):j(`models.creditsLocalLead`),status:t.balance===null?void 0:(0,B.jsx)(`span`,{className:`font-display font-semibold text-[1.25rem] tabular-nums`,children:j(`nav.credits`,{n:Math.floor(t.balance).toLocaleString(A)})})}),(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:j(`models.creditsConnectTitle`),children:[(0,B.jsx)(Z,{children:j(`models.creditsLocalHint`)}),(0,B.jsx)(`div`,{children:(0,B.jsx)(s,{to:`/settings/account`,children:(0,B.jsx)(g,{children:j(`models.creditsConnect`)})})})]}):null,t.account&&!t.account.signedIn?(0,B.jsxs)(`p`,{className:`text-[0.8125rem] text-rose`,children:[j(`local.accountExpired`),` `,(0,B.jsx)(Yn,{})]}):null,t.account?(0,B.jsx)(X,{title:j(`models.creditsFallback`),children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(x,{checked:e.creditFallback,disabled:!t.canEdit,onChange:e=>r.mutate({creditFallback:e}),label:j(`models.creditsFallback`)}),(0,B.jsx)(Z,{children:e.creditFallback?j(`models.creditsFallbackOn`):j(`models.creditsFallbackOff`)})]})}):null,t.credits?(0,B.jsx)(X,{title:j(`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:[j(`models.creditsTopUp`),` `,(0,B.jsx)(w,{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:j(`models.cap.${t}`)}),(0,B.jsxs)(`span`,{className:`truncate text-[0.75rem] text-ink-3`,children:[i.ref?N(i.ref):``,` · `,Pn(t,e)]})]})},t)})}):(0,B.jsx)(Z,{children:j(`models.creditsNone`)})}):null]})]})}function Zn(e){return e?e===`credits`?{type:`credits`}:e===`chat`?{type:`chat`}:ze.includes(e)?{type:`cap`,id:e}:M(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 j(`models.cap.chat`);case`cap`:return j(`models.cap.${e.id}`);case`provider`:return M(e.id)?.name??e.id;case`client`:return t?.harnesses.find(t=>t.id===e.id)?.name??e.id;default:return t?.mode===`managed`?j(`models.creditsOrganization`):j(`models.creditsName`)}}function nr(){let e=be(),t=Sn(),[n,r]=ne(),[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=Ve.filter(e=>l.keys[e.id]),h=Ve.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:j(`models.groupStudio`),children:(0,B.jsx)(I,{icon:Xe,label:j(`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:j(`models.groupRuns`),children:ze.map(e=>{let t=l.ways[q[e]];return(0,B.jsx)(I,{icon:gn[e],label:j(`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:j(`models.groupAccess`),children:[(0,B.jsx)(I,{icon:ve,label:u.cloud?j(`models.creditsOrganization`):j(`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(A)}),tone:u.credits?void 0:`off`,toneLabel:u.credits?void 0:j(`models.noteNeedsAccount`),selected:f({type:`credits`}),onPick:()=>d({type:`credits`})}),p.map(e=>(0,B.jsx)(I,{icon:je,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:j(`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:j(`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:j(`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`&&M(c.id)?(0,B.jsx)(qn,{provider:M(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:xe(e)})}function ir({me:e}){let t=D({queryKey:[`organization`,e.tenant.id],queryFn:()=>r.get(`/api/studio/organization`)}),n=t.data,i=n?.plan??e.tenant.plan,a=n?.seats;return(0,B.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,B.jsxs)(oe,{title:j(`organization.title`),hint:j(`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:j(`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:i?.name??j(`organization.planFree`)}),a?(0,B.jsx)(h,{children:a.limit===null?j(`organization.seatsUnlimited`):j(`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:()=>P(`${e.manageUrl}/billing`),children:[j(`organization.changePlan`),` `,(0,B.jsx)(w,{className:`size-4`})]}),n?.canManage?(0,B.jsxs)(g,{onClick:()=>P(`${e.manageUrl}/`),children:[j(`organization.manage`),` `,(0,B.jsx)(w,{className:`size-4`})]}):null]})]}),(0,B.jsx)(`p`,{className:`mt-4 text-[0.8125rem] text-ink-3 leading-relaxed`,children:e.tenant.role===`member`?j(`organization.memberNote`):j(`organization.roles`)})]}),(0,B.jsx)(oe,{title:j(`organization.members`),children:t.isPending?(0,B.jsx)(f,{}):t.isError||!n?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:j(`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:[` · `,j(`organization.you`)]}):null]}),(0,B.jsx)(`div`,{className:`truncate text-[0.8125rem] text-ink-3`,children:t.email})]}),(0,B.jsx)(h,{tone:t.role===`member`?void 0:`live`,children:j(`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)(h,{tone:`warn`,children:[j(`organization.invited`),` · `,j(`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)(qe,{className:`size-4`}),` –`]}):null]})})]})}var ar=(0,z.lazy)(()=>de(()=>import(`./AboutDialog-Bx6j5lZO.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,18]))),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=u(),[n,i]=(0,z.useState)(e.mcpServers.map(e=>({...e,auth:e.headers?.Authorization??e.headers?.authorization??``}))),[o,s]=(0,z.useState)(!1),c=e.readOnly,d=k({mutationFn:()=>r.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:_.spaces()}),s(!0),setTimeout(()=>s(!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:j(`settings.mcp`)}),(0,B.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:j(`settings.mcpHint`)}),(0,B.jsxs)(`fieldset`,{disabled:c,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)(T,{placeholder:j(`settings.serverName`),value:e.name,onChange:e=>i(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)(T,{placeholder:`${j(`settings.serverUrl`)} (https://…/mcp)`,value:e.url,onChange:e=>i(n=>n.map((n,r)=>r===t?{...n,url:e.target.value}:n))}),c?(0,B.jsx)(`span`,{}):(0,B.jsx)(l,{label:j(`common.remove`),onClick:()=>i(e=>e.filter((e,n)=>n!==t)),className:`hover:text-rose`,children:(0,B.jsx)(re,{className:`size-4`})}),(0,B.jsx)(T,{className:`sm:col-span-2`,placeholder:j(`settings.serverHeader`),value:e.auth??``,onChange:e=>i(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)),c?null:(0,B.jsxs)(g,{variant:`secondary`,className:`self-start`,onClick:()=>i(e=>[...e,{id:``,name:``,url:``,auth:``}]),children:[(0,B.jsx)(C,{className:`size-4`}),` `,j(`settings.addServer`)]})]}),c?null:(0,B.jsxs)(`div`,{className:`mt-5 flex items-center justify-end gap-3`,children:[d.error?(0,B.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,B.jsx)(g,{busy:d.isPending,onClick:()=>d.mutate(),children:j(o?`settings.saved`:`settings.save`)})]})]})}var lr=new Set([`models`,`integrate`]);function ur(){let{section:e}=ie(),[t]=ne(),n=S(),r=be(),{project:a,loading:o}=ye(),s=Se(),[c,l]=(0,z.useState)(a?.id);(0,z.useEffect)(()=>l(a?.id),[a?.id]);let u=tt(),d=pt(),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(null),y=Je(r.data,u),b=y.find(t=>t.id===e),x=y.map(e=>({...e,to:`/settings/${e.id}`})),ee=x.find(t=>t.id===e),C=b?lr.has(b.id):!1,w=b?C&&!t.get(`show`)?1:2:0,te=d?Math.min(w,1):C&&g!==e?1:0,T=ot(te),D=ot(w),re=(0,z.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]);if($e(b?.id===`models`?{suggestions:[{label:j(`assistant.suggest.modelsNow`)},{label:j(`assistant.suggest.modelsMissing`)},{label:j(`assistant.suggest.modelsCost`)}]}:b?.id===`account`?{suggestions:[{label:j(`assistant.suggest.credits`)},{label:j(`assistant.suggest.accountWhy`)},{label:j(`assistant.suggest.plans`)}]}:b?.id===`integrate`?{suggestions:[{label:j(`assistant.suggest.integrateWhat`)},{label:j(`assistant.suggest.integrateClaude`)},{label:j(`assistant.suggest.what`)}]}:b?.id===`connectors`?{suggestions:[{label:j(`assistant.suggest.connectorsWhat`)},{label:j(`assistant.suggest.connectorsAdd`),fill:!0},{label:j(`assistant.suggest.what`)}]}:{}),rt([{label:j(`settings.title`),to:`/settings`},...b?[{label:b.label,to:`/settings/${b.id}`}]:[],...b&&m?[{label:m}]:[]]),!b){if(e===`build`)return(0,B.jsx)(v,{to:`/settings/integrate`,replace:!0});if(e===`project`)return(0,B.jsx)(v,{to:`/space`,replace:!0});if(e!==void 0||!d)return u.status===`ready`||e===void 0?(0,B.jsx)(v,{to:`/settings/account`,replace:!0}):null}let ae=b?.id===`connectors`&&s,oe=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ct,{title:j(`settings.title`),open:te===1?ee??null:null,onBack:()=>d?n(`/settings`):_(e??null)}),(0,B.jsx)(`div`,{className:E(it(T)),children:te===0?(0,B.jsx)(ut,{entries:x,current:d?void 0:ee,onPick:()=>_(null)}):(0,B.jsx)(`div`,{ref:p})},te)]});return(0,B.jsx)(lt.Provider,{value:re,children:(0,B.jsx)(`div`,{className:`animate-rise`,children:(0,B.jsxs)(`div`,{className:E(`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:E(`min-w-0 md:sticky md:top-6 md:self-start`,d&&w===2&&`hidden`,d&&D===`back`&&it(`back`)),children:oe}),b?(0,B.jsxs)(`div`,{className:E(`min-w-0`,![`integrate`,`models`].includes(b.id)&&`max-w-2xl`,d&&w<2&&`hidden`,d&&D===`deeper`&&it(`deeper`)),children:[d?(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(ft,{label:C?b.label:j(`settings.title`),onBack:()=>n(C?`/settings/${b.id}`:`/settings`)})}):null,ae?(0,B.jsx)(`div`,{className:`mb-6`,children:(0,B.jsx)(Ke,{})}):null,b.id===`connectors`&&a?(0,B.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.readOnly?(0,B.jsx)(Ee,{children:we(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)(i,{children:j(`settings.noProject`)}):null,b.id===`models`?(0,B.jsx)(nr,{}):null,b.id===`integrate`?(0,B.jsx)(mn,{}):null,b.id===`account`&&r.data?(0,B.jsx)(Ye,{me:r.data}):null,b.id===`cloud`?(0,B.jsx)(Ge,{}):null,b.id===`about`?(0,B.jsx)(z.Suspense,{fallback:null,children:(0,B.jsx)(ar,{me:r.data,active:!0,initialTab:or(t.get(`tab`))})}):null,b.id===`organization`&&r.data?(0,B.jsx)(ir,{me:r.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};
@@ -0,0 +1 @@
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,Or as i,Un as a,Vt as o,Wn as ee,er as te,mn as ne,rn as s,zn as c}from"./ui-gsqxnFnT.js";import{t as l}from"./useMutation-BS-U9g_a.js";import{D as re,d as u,g as d,w as ie,x as f,y as ae}from"./session-xJpGiTU_.js";import{t as p}from"./logo-CGNoptDg.js";import{n as m,s as h}from"./i18n-DEmaSTJV.js";import{L as oe,M as se,N as ce,R as le,_t as g,et as ue,gt as de,z as _,zt as fe}from"./index-ClNm5JaU.js";import{n as v,t as pe}from"./Harness-Br0Z_anI.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 h(`models.optAppleNote`);switch(e.reason){case`off`:return h(`models.appleOff`);case`loading`:return h(`models.appleLoading`);default:return h(`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)(p,{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:i,onPick:o}){return(0,b.jsxs)(`button`,{type:`button`,onClick:o,"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)(c,{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})]}),i?(0,b.jsx)(`span`,{className:s(`shrink-0 text-[0.75rem]`,e?`opacity-70`:`text-(color:--on)/65`),children:i}):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=[h(`setup.stage.connect`),h(`setup.stage.test`),h(`setup.stage.done`)],i=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 i=n||r<t;return(0,b.jsxs)(`li`,{"aria-current":!i&&r===t?`step`:void 0,className:`flex items-center gap-1 transition-colors duration-500`,style:{color:i?w:r===t?T:E},children:[i?(0,b.jsx)(c,{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<i?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=re()===`dark`;ie(t?x:null);let n=d(),a=i(),p=te(),_=de(),C=g(`account`),{project:T}=u(),E=ce(!!n.data?.account?.signedIn),[M,I]=(0,y.useState)(N),[L,R]=(0,y.useState)(!1),z=l({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:ae(n.data?.models?.bindings??{})}),onSuccess:async(e,t)=>{await a.invalidateQueries({queryKey:[`me`]}),I(!0),R(!1),j(),P(t===`own`)}}),B=l({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`?h(`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?h(`setup.h.done`):K?K.version===null?h(`setup.h.install`,{name:K.name}):K.auth===`none`?h(`setup.h.signIn`,{name:K.name}):h(`setup.h.test`):h(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)(oe,{tone:t?`ground`:`surface`}),(0,b.jsx)(ue,{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)(f,{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:h(`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:h(`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:h(`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)(fe,{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:h(`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:h(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(m)})].filter(Boolean).join(` · `)})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.9375rem]`,children:h(`setup.account`)}),(0,b.jsx)(`p`,{className:`text-(color:--on)/75 text-[0.8125rem] leading-snug`,children:h(`setup.accountText`)}),(0,b.jsx)(se,{...E})]})}),n.data.account?.signedIn?null:(0,b.jsx)(o,{variant:`secondary`,size:`sm`,busy:E.link.isPending,onClick:()=>E.link.mutate({}),children:h(`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:h(`setup.creditsChoice`),description:h(`setup.creditsDesc`),note:n.data.account.credits===null?void 0:h(`setup.accountCredits`,{credits:n.data.account.credits.toLocaleString(m)}),onPick:()=>z.mutate(`account`)}):null,U.map((e,t)=>(0,b.jsx)(F,{selected:$===e.id,title:e.name,description:h(`harness.desc.${e.id}`),badge:t===0?h(`setup.recommended`):void 0,note:e.version===null?h(`harness.notInstalled`):e.auth===`subscription`?h(`harness.ready`):void 0,onPick:()=>z.mutate(e.id)},e.id)),W?.supported?(0,b.jsx)(F,{selected:$===`apple`,title:h(`models.optApple`),description:h(`setup.appleDesc`),note:ve(W),onPick:()=>z.mutate(`apple`)}):null,(0,b.jsx)(F,{selected:$===`own`,title:h(`local.sourceOwn`),description:h(`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:h(`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`}),` `,h(`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`}),` `,h(`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)(f,{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??h(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?h(`setup.appleHintKeeps`,{way:q}):h(`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:h(`setup.creditsDesc`)}),(0,b.jsx)(v,{auto:!J})]}):(0,b.jsx)(le,{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)(c,{className:`size-4`,strokeWidth:3}),h(`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:()=>p(`/`,{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:[h(`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:h(`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?h(`setup.thisComputer`,{space:T?.name??``,organization:n.data.account.organization??n.data.account.name}):h(`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 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,G as i,Mt as a,Rt as o,Y as s,Yt as c,Zn as l,mt as u,ut as d,zn as f,zt as p}from"./ui-6AgUKJhQ.js";import{d as m,n as h}from"./theme-znovbShL.js";import{O as g,b as _,x as v}from"./session-CbWzkHl0.js";import{n as y,s as b}from"./i18n-UTsgNY5M.js";import{BrandHeader as x}from"./PublicRunner-DgT4CApp.js";var S=e(t(),1),C=e(n(),1);function w(){let{token:e}=l(),t=r({queryKey:[`share`,e],queryFn:()=>i.get(`/api/shares/${e}`),retry:(e,t)=>a(t)&&e<3});if(h(t.data?.brand.theme),g(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)(v,{kind:`pebble`,size:80}),(0,C.jsx)(`p`,{className:`max-w-sm text-ink-3`,children:b(a(t.error)?`common.offline`:`sharePage.gone`)}),a(t.error)?(0,C.jsx)(o,{variant:`secondary`,onClick:()=>void t.refetch(),children:b(`common.retry`)}):null]});let w=`/api/shares/${n.token}`,T=e=>new Intl.DateTimeFormat(y,{dateStyle:`long`}).format(new Date(e));return(0,C.jsxs)(`div`,{className:`wizard-page flex min-h-dvh flex-col`,children:[(0,C.jsx)(m,{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)(v,{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?b(`sharePage.until`,{date:T(n.expiresAt)}):b(`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)(p,{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)(d,{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)(v,{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:[b(`sharePage.own`),` `,(0,C.jsx)(f,{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:b(`run.madeWith`).replace(`engenty wizards`,_.name)})})]})}export{w as SharePage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ft as r,G as i,Ht as a,Q as o,Qt as s,Un as c,Vt as l,_t as u,pt as d,rr as f,tr as p}from"./ui-gsqxnFnT.js";import{d as m,n as h}from"./theme-DTi1Zdw8.js";import{O as g,b as _,x as v}from"./session-xJpGiTU_.js";import{n as y,s as b}from"./i18n-DEmaSTJV.js";import{BrandHeader as x}from"./PublicRunner-CNanj6-w.js";var S=e(t(),1),C=e(n(),1);function w(){let{token:e}=p(),t=f({queryKey:[`share`,e],queryFn:()=>i.get(`/api/shares/${e}`),retry:(e,t)=>r(t)&&e<3});if(h(t.data?.brand.theme),g(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)(s,{})});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)(v,{kind:`pebble`,size:80}),(0,C.jsx)(`p`,{className:`max-w-sm text-ink-3`,children:b(r(t.error)?`common.offline`:`sharePage.gone`)}),r(t.error)?(0,C.jsx)(l,{variant:`secondary`,onClick:()=>void t.refetch(),children:b(`common.retry`)}):null]});let w=`/api/shares/${n.token}`,T=e=>new Intl.DateTimeFormat(y,{dateStyle:`long`}).format(new Date(e));return(0,C.jsxs)(`div`,{className:`wizard-page flex min-h-dvh flex-col`,children:[(0,C.jsx)(m,{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)(v,{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?b(`sharePage.until`,{date:T(n.expiresAt)}):b(`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)(a,{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)(d,{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)(v,{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:[b(`sharePage.own`),` `,(0,C.jsx)(c,{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:`${o}/`,className:`inline-block py-3.5 hover:text-ink-2`,children:b(`run.madeWith`).replace(`engenty wizards`,_.name)})})]})}export{w as SharePage};