@engenty/wizards-runtime 0.16.2 → 0.17.1

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 (156) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +13 -6
  2. package/apps/runtime/dist/app.js +2 -0
  3. package/apps/runtime/dist/assistant/knows.js +15 -2
  4. package/apps/runtime/dist/broker/account.js +20 -1
  5. package/apps/runtime/dist/broker/call.js +131 -22
  6. package/apps/runtime/dist/broker/grant.js +25 -1
  7. package/apps/runtime/dist/broker/host.js +8 -2
  8. package/apps/runtime/dist/broker/index.js +5 -4
  9. package/apps/runtime/dist/broker/log.js +178 -24
  10. package/apps/runtime/dist/broker/over.js +38 -0
  11. package/apps/runtime/dist/broker/rights.js +192 -0
  12. package/apps/runtime/dist/broker/rwx.js +309 -53
  13. package/apps/runtime/dist/broker/send.js +109 -44
  14. package/apps/runtime/dist/bundles/fetch.js +119 -0
  15. package/apps/runtime/dist/bundles/index.js +621 -0
  16. package/apps/runtime/dist/bundles/read.js +607 -0
  17. package/apps/runtime/dist/connectors/external.js +532 -61
  18. package/apps/runtime/dist/connectors/person-sign-ins.js +1 -0
  19. package/apps/runtime/dist/connectors/reload.js +73 -0
  20. package/apps/runtime/dist/connectors/space-connections.js +118 -6
  21. package/apps/runtime/dist/db/migrations/tenant/0058_mcp_state_across_roles.sql +26 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0059_space_connection_paused.sql +2 -0
  23. package/apps/runtime/dist/db/migrations/tenant/0060_space_bundle.sql +21 -0
  24. package/apps/runtime/dist/db/migrations/tenant/0061_space_connection_limits.sql +2 -0
  25. package/apps/runtime/dist/db/migrations/tenant/meta/0058_snapshot.json +6696 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/0059_snapshot.json +6710 -0
  27. package/apps/runtime/dist/db/migrations/tenant/meta/0060_snapshot.json +6857 -0
  28. package/apps/runtime/dist/db/migrations/tenant/meta/0061_snapshot.json +6871 -0
  29. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +28 -0
  30. package/apps/runtime/dist/db/schema.js +81 -3
  31. package/apps/runtime/dist/docs/dev/broker.md +316 -50
  32. package/apps/runtime/dist/docs/dev/plugins/space.md +13 -2
  33. package/apps/runtime/dist/docs/user-guide/capabilities.md +172 -10
  34. package/apps/runtime/dist/docs/user-guide/connectors.md +57 -7
  35. package/apps/runtime/dist/docs/user-guide/protocol.md +44 -7
  36. package/apps/runtime/dist/docs/user-guide/test-and-share.md +1 -1
  37. package/apps/runtime/dist/docs/user-guide/together.md +4 -4
  38. package/apps/runtime/dist/elements/caller.js +2 -2
  39. package/apps/runtime/dist/elements/knowledge.js +16 -12
  40. package/apps/runtime/dist/engenty/connections-external/build-connector.js +23 -8
  41. package/apps/runtime/dist/engenty/connections-external/import-service.js +18 -9
  42. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +12 -0
  43. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +1 -0
  44. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +6 -3
  45. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +2 -2
  46. package/apps/runtime/dist/engenty/shims/web-ingest.js +64 -0
  47. package/apps/runtime/dist/engine/resources.js +15 -6
  48. package/apps/runtime/dist/engine/runner.js +2 -1
  49. package/apps/runtime/dist/engine/steps.js +3 -2
  50. package/apps/runtime/dist/env.js +2 -0
  51. package/apps/runtime/dist/index.js +19 -2
  52. package/apps/runtime/dist/live/hub.js +17 -3
  53. package/apps/runtime/dist/live/origin.js +6 -4
  54. package/apps/runtime/dist/live/views.js +38 -7
  55. package/apps/runtime/dist/mcp/handler.js +2 -2
  56. package/apps/runtime/dist/mcp/seen.js +71 -51
  57. package/apps/runtime/dist/mcp/tools.js +5 -1
  58. package/apps/runtime/dist/models.js +18 -0
  59. package/apps/runtime/dist/prompts/mcp.md +1 -1
  60. package/apps/runtime/dist/prompts/tools.md +17 -1
  61. package/apps/runtime/dist/routes/api.js +2 -2
  62. package/apps/runtime/dist/routes/broker.js +59 -20
  63. package/apps/runtime/dist/routes/bundles.js +91 -0
  64. package/apps/runtime/dist/routes/connections.js +14 -3
  65. package/apps/runtime/dist/routes/live.js +4 -2
  66. package/apps/runtime/dist/routes/rules.js +53 -9
  67. package/apps/runtime/dist/routes/studio.js +36 -20
  68. package/apps/runtime/dist/services/api.js +4 -2
  69. package/apps/runtime/dist/services/cloud.js +2 -0
  70. package/apps/runtime/dist/services/draft-events.js +79 -6
  71. package/apps/runtime/dist/services/errors.js +1 -0
  72. package/apps/runtime/dist/services/files.js +2 -2
  73. package/apps/runtime/dist/services/knowledge.js +93 -27
  74. package/apps/runtime/dist/services/members-studio.js +22 -2
  75. package/apps/runtime/dist/services/skills.js +61 -5
  76. package/apps/runtime/dist/services/space-categories.js +83 -5
  77. package/apps/runtime/dist/services/space-index.js +173 -25
  78. package/apps/runtime/dist/services/space-origin.js +28 -11
  79. package/apps/runtime/dist/services/synced-spaces.js +5 -1
  80. package/apps/runtime/dist/services/wizards.js +48 -2
  81. package/apps/runtime/dist/services/work-ai.js +15 -5
  82. package/apps/runtime/dist/sharing/jobs.js +8 -2
  83. package/apps/runtime/dist/sync/hub.js +17 -3
  84. package/apps/runtime/dist/sync/records.js +6 -1
  85. package/apps/runtime/dist/texts.js +42 -5
  86. package/apps/runtime/dist/tools/connections.js +8 -0
  87. package/apps/runtime/dist/tools/connector.js +13 -1
  88. package/apps/runtime/dist/tools/index.js +21 -10
  89. package/apps/runtime/dist/tools/skills.js +11 -1
  90. package/apps/runtime/dist/tools/web-search.js +36 -0
  91. package/apps/web/dist/assets/{AboutDialog-BCcD8hKm.js → AboutDialog-mZCBU7KF.js} +1 -1
  92. package/apps/web/dist/assets/{BlockEditor-DgaUm2pR.js → BlockEditor-Dk0QwLSU.js} +1 -1
  93. package/apps/web/dist/assets/CapabilitiesPage-GkpgF-wZ.js +2 -0
  94. package/apps/web/dist/assets/{ChangelogDialog-B08elwyr.js → ChangelogDialog-BhyilZWA.js} +1 -1
  95. package/apps/web/dist/assets/{CodeEditor-BiyOk_SC.js → CodeEditor-DULYZbuE.js} +1 -1
  96. package/apps/web/dist/assets/EditorPage-D_mCdYdZ.js +3 -0
  97. package/apps/web/dist/assets/{FlowPreview-DF_6TvZ0.js → FlowPreview-ykxZxWnk.js} +1 -1
  98. package/apps/web/dist/assets/{LangSwitch-Ba4OWLzJ.js → LangSwitch-iO54w9AP.js} +1 -1
  99. package/apps/web/dist/assets/{Marketplace-DqziLf66.js → Marketplace-C97fH7UC.js} +2 -2
  100. package/apps/web/dist/assets/{NewWizardChannels-CsIGp0nZ.js → NewWizardChannels-CsSV7sm2.js} +1 -1
  101. package/apps/web/dist/assets/{NewWizardPage-CzQAkKMy.js → NewWizardPage-Ebgw-Vf_.js} +1 -1
  102. package/apps/web/dist/assets/{OnboardingPage-B9gr2OX5.js → OnboardingPage-BZlloT7v.js} +1 -1
  103. package/apps/web/dist/assets/PreviewPane-CJuqY5uA.js +7 -0
  104. package/apps/web/dist/assets/ProtocolSection-CPaDKVpZ.js +1 -0
  105. package/apps/web/dist/assets/{PublicRunner-BVs8-Vu3.js → PublicRunner-4Lf4SnwB.js} +1 -1
  106. package/apps/web/dist/assets/{ReadOnly--4CIJCDD.js → ReadOnly-CXQ41R9Q.js} +1 -1
  107. package/apps/web/dist/assets/SettingsPage-C-8BgK9O.js +2 -0
  108. package/apps/web/dist/assets/{SetupPage-9Zk-KUGA.js → SetupPage-4_K083Wl.js} +1 -1
  109. package/apps/web/dist/assets/{SharePage-D_Ab0gjr.js → SharePage-CQjgMcDI.js} +1 -1
  110. package/apps/web/dist/assets/{SkillEditor-DvtameHg.js → SkillEditor-DT5hQwbg.js} +1 -1
  111. package/apps/web/dist/assets/{Skills-Cf1Kl4Fy.js → Skills-D7V_9_xo.js} +1 -1
  112. package/apps/web/dist/assets/SpacePage-D3rYS1bA.js +2 -0
  113. package/apps/web/dist/assets/{UpdateCheck-DweZBVP6.js → UpdateCheck-DVgAJmy8.js} +2 -2
  114. package/apps/web/dist/assets/changelog-DzQCUSsx.js +1 -0
  115. package/apps/web/dist/assets/{code-editor-B1RbFTAZ.js → code-editor-5T7ilBjd.js} +2 -2
  116. package/apps/web/dist/assets/{host-CKS5U5Vg.js → host-CCijW1hj.js} +6 -6
  117. package/apps/web/dist/assets/i18n-DCPDesT-.js +55 -0
  118. package/apps/web/dist/assets/{index-Ckcn5vy7.js → index-C_iWl8iS.js} +3 -3
  119. package/apps/web/dist/assets/index-zcPlodHx.css +1 -0
  120. package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
  121. package/apps/web/dist/assets/{read-aloud-Bq88XUHC.js → read-aloud-Qb719not.js} +1 -1
  122. package/apps/web/dist/assets/{runners-DvYVe9Dt.js → runners-BeZ84YH_.js} +1 -1
  123. package/apps/web/dist/assets/{session-D2bjiA3P.js → session-CEJRkSP5.js} +1 -1
  124. package/apps/web/dist/assets/{theme-CNJIC2be.js → theme-y_owNosi.js} +1 -1
  125. package/apps/web/dist/assets/{ui-Mplfhz_Z.js → ui-BacfkQ7Q.js} +1 -1
  126. package/apps/web/dist/assets/{useMutation-8QRM-z4M.js → useMutation-CgzFr4qH.js} +1 -1
  127. package/apps/web/dist/assets/{viewers-CEocUV_2.js → viewers-CkyHAjnk.js} +2 -2
  128. package/apps/web/dist/index.html +12 -12
  129. package/apps/web/dist/mcp/flow.html +2 -2
  130. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +7 -2
  131. package/node_modules/@engenty/wizards-shared/dist/bundles.d.ts +219 -0
  132. package/node_modules/@engenty/wizards-shared/dist/bundles.js +19 -0
  133. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +117 -4
  134. package/node_modules/@engenty/wizards-shared/dist/connectors.js +14 -0
  135. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +12 -0
  136. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +12 -0
  137. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +11 -0
  138. package/node_modules/@engenty/wizards-shared/dist/run.js +22 -0
  139. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +84 -1
  140. package/node_modules/@engenty/wizards-shared/dist/rwx.js +69 -1
  141. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +20 -3
  142. package/node_modules/@engenty/wizards-shared/dist/skills.js +5 -2
  143. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +3 -2
  144. package/node_modules/@engenty/wizards-shared/dist/spaces.js +12 -3
  145. package/package.json +1 -1
  146. package/plugin/.claude-plugin/plugin.json +1 -1
  147. package/plugin/plugin.json +1 -1
  148. package/apps/web/dist/assets/CapabilitiesPage-DuJJV1ll.js +0 -2
  149. package/apps/web/dist/assets/EditorPage-EMFTHEYD.js +0 -3
  150. package/apps/web/dist/assets/PreviewPane-DSOV3o-1.js +0 -7
  151. package/apps/web/dist/assets/SettingsPage-z2u8lSe2.js +0 -2
  152. package/apps/web/dist/assets/SpacePage-CyqVzX9b.js +0 -2
  153. package/apps/web/dist/assets/changelog-C85v9OWg.js +0 -1
  154. package/apps/web/dist/assets/connection-sign-in-CaVvh5GQ.js +0 -1
  155. package/apps/web/dist/assets/i18n-Bymk5Ev-.js +0 -55
  156. package/apps/web/dist/assets/index-w-3J3ZJ9.css +0 -1
@@ -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{$t as r,Dn as i,Dt as a,Gn as o,K as s,Q as c,Vr as l,X as u,an as d,en as f,fn as p,gr as m,hn as h,i as ee,in as g,nn as _,on as v,pt as te,un as y,v as b}from"./ui-Mplfhz_Z.js";import{t as x}from"./useMutation-8QRM-z4M.js";import{d as S,i as C,l as ne,r as w,s as T}from"./marked.esm-DQ7XA7AC.js";import{c as E,d as D,i as O,l as re,n as k,o as ie,t as A,u as ae}from"./Skills-Cf1Kl4Fy.js";import{t as j}from"./code-xml-S4IFi5Jc.js";import{n as M,t as oe}from"./scroll-text-BEnPzQEi.js";import{t as N}from"./eye-TJSuiHHO.js";import{n as P,s as F}from"./i18n-Bymk5Ev-.js";import{t as I}from"./code-editor-B1RbFTAZ.js";import{N as L,a as R,r as z,t as B}from"./dist-CQpLJoQZ.js";var V={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};V.node;var se=S(V),H=e(t(),1),U=B.line({class:`cm-frontmatter`});function W(e){let t=new L,n=e.state.doc;if(n.lines>1&&n.line(1).text.trim()===`---`){for(let e=2;e<=Math.min(n.lines,80);e++)if(n.line(e).text.trim()===`---`){for(let r=1;r<=e;r++)t.add(n.line(r).from,n.line(r).from,U);break}}return t.finish()}function G(){return[R.fromClass(class{decorations;constructor(e){this.decorations=W(e)}update(e){e.docChanged&&(this.decorations=W(e.view))}},{decorations:e=>e.decorations}),z.theme({".cm-frontmatter, .cm-frontmatter *":{fontFamily:`var(--f-mono)`,fontSize:`0.8125rem !important`,fontWeight:`400 !important`,color:`var(--ink-3) !important`,textDecoration:`none !important`}})]}var K=e(n(),1),q=[`always`,`demand`,`off`],ce=G();function J(e){return m({queryKey:u.skill(e),queryFn:()=>c.get(`/api/studio/skills/${e}`)})}function le({value:e,onChange:t,disabled:n}){return(0,K.jsx)(`fieldset`,{"aria-label":F(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 flex flex-col gap-2`,children:q.map(r=>{let i=r===e,a=k[r];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:h(`flex items-start gap-3 rounded-xl bg-card p-3 text-left ring-1 transition disabled:pointer-events-none`,i?`ring-ember shadow-[0_0_0_3px] shadow-ember-tint`:`ring-border-soft hover:ring-ink-4`,n&&!i&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:h(`flex size-8 shrink-0 items-center justify-center rounded-lg`,i?`bg-ember-tint text-ember-strong`:`bg-paper-2 text-ink-3`),children:(0,K.jsx)(a,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:F(`skills.mode.${r}`)}),(0,K.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.modeHint.${r}`)})]})]},r)})})}function ue({skill:e}){let t=l(),n=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{runScripts:t}),onSuccess:async()=>{await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),r=e.source!==`own`&&!e.official;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.scriptsTitle`)}),(0,K.jsxs)(f,{className:`flex flex-col gap-2 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 font-medium text-[0.8125rem]`,children:F(`skills.runScripts`)}),(0,K.jsx)(p,{checked:e.runScripts,label:F(`skills.runScripts`),disabled:e.readOnly||n.isPending,onChange:e=>n.mutate(e)})]}),(0,K.jsx)(`p`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.runScriptsHint`)}),r?(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.75rem] text-ink-2 leading-snug`,children:F(`skills.runScriptsWarn`)}):null,n.error?(0,K.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:n.error.message}):null]})]})}function Y({code:e,onChange:t}){return(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,"aria-pressed":e,onClick:()=>t(!e),children:[e?(0,K.jsx)(N,{className:`size-4`}):(0,K.jsx)(j,{className:`size-4`}),F(e?`skills.rendered`:`skills.code`)]})}var X=e=>`${(e/1e3).toLocaleString(P,{maximumFractionDigits:1})} KB`,Z=e=>X(new TextEncoder().encode(e).length),Q=e=>/\.(md|markdown|mdx)$/i.test(e);function $({file:e,readOnly:t,onChange:n,onDelete:i,onClose:o}){let[s,c]=(0,H.useState)(!1),l=e?Q(e.path):!1,u=s||!l;return(0,K.jsx)(_,{open:e!==null,onClose:o,wide:!0,height:`tall`,title:e?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.path})]}):null,children:e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:Z(e.text)}),l?(0,K.jsx)(Y,{code:s,onChange:c}):null]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:u?(0,K.jsx)(I,{value:e.text,onChange:n,readOnly:t,language:`markdown`,ariaLabel:e.path,className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh]`}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)(a,{text:e.text})})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?null:(0,K.jsxs)(r,{variant:`danger`,size:`sm`,onClick:i,children:[(0,K.jsx)(w,{className:`size-4`}),` `,F(`skills.deleteFile`)]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(r,{size:`sm`,onClick:o,children:F(`skills.done`)})]})]}):null})}function de({open:e,taken:t,onClose:n,onMade:i}){let[a,o]=(0,H.useState)(``),s=a.trim().replace(/^\.?\//,``),c=D(s)&&s!==`SKILL.md`&&!t.includes(s);return(0,K.jsx)(_,{open:e,onClose:n,title:F(`skills.newFile`),children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c&&(i(s),o(``))},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{children:F(`skills.filePath`)}),(0,K.jsx)(d,{"data-autofocus":!0,value:a,placeholder:F(`skills.filePathHint`),onChange:e=>o(e.target.value),className:`font-mono`})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(r,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,K.jsx)(r,{type:`submit`,disabled:!c,children:F(`skills.create`)})]})]})})}function fe({items:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]),(0,K.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,K.jsx)(g,{label:F(`skills.more`),"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`ring-1 ring-border`,children:(0,K.jsx)(M,{className:`size-4`})}),t?(0,K.jsx)(`div`,{role:`menu`,className:`absolute top-11 right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{n(!1),e.onPick()},className:h(`w-full rounded-lg px-2.5 py-2 text-left text-[0.8125rem] transition hover:bg-accent`,e.danger&&`text-rose`),children:e.label},e.label))}):null]})}function pe({skill:e}){let t=l(),[n,o]=(0,H.useState)(!1),s=m({queryKey:[`skill-update`,e.id,e.originHash],queryFn:()=>c.get(`/api/studio/skills/${e.id}/update`),staleTime:6e5,retry:!1}),d=x({mutationFn:t=>c.post(`/api/studio/skills/${e.id}/update`,{hash:t}),onSuccess:async()=>{o(!1),await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),p=s.data?.update;return!p||e.readOnly?null:(0,K.jsxs)(f,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-ember`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-[0.8125rem]`,children:F(`skills.updateAvailable`)}),(0,K.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:F(`skills.showChanges`)}),(0,K.jsx)(_,{open:n,onClose:()=>o(!1),wide:!0,height:`tall`,title:F(`skills.updateTitle`,{name:e.name}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:p.description}),(0,K.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,K.jsx)(a,{text:p.body})}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[0.8125rem]`,children:p.fileList.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e.path},e.path))}),(0,K.jsx)(A,{files:p.fileList,skipped:p.skipped}),d.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(r,{busy:d.isPending,onClick:()=>d.mutate(p.hash),children:F(`skills.takeUpdate`)})})]})})]})}function me({skillId:e,onGone:t,onOpen:n,filesFirst:r}){let i=J(e);return i.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:i.error.message}):i.data?(0,K.jsx)(he,{skill:i.data,onGone:t,onOpen:n,filesFirst:r},i.data.id):(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(y,{className:`size-5`})})}function he({skill:e,onGone:t,onOpen:n,filesFirst:i}){let d=l(),p=e.source===`skills.sh`,m=e.readOnly||p,[h,g]=(0,H.useState)({name:e.name,description:e.description,body:e.body,meta:e.meta,files:e.fileList}),[_,v]=(0,H.useState)(!1),[S,w]=(0,H.useState)(null),[D,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(!1),L=s(h,async t=>{m||(await c.patch(`/api/studio/skills/${e.id}`,t),await d.invalidateQueries({queryKey:u.skills(e.spaceId)}))}),R=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{mode:t}),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skill(e.id)}),await d.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),z=x({mutationFn:()=>c.del(`/api/studio/skills/${e.id}`),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),t()}}),B=x({mutationFn:()=>c.post(`/api/studio/skills/${e.id}/copy`),onSuccess:async({id:t})=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),n(`k:${t}`)}}),V=h.files.find(e=>e.path===A)??null,U=S??ae(h),W=e=>g(t=>({...t,...e})),G=async()=>{await ee(F(p?`skills.removeConfirm`:`skills.deleteConfirm`,{name:e.name}))&&z.mutate()},q=L.error??R.error?.message??null,J=typeof e.meta.license==`string`?e.meta.license:null,Q=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.filesTitle`),children:m?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>N(!0),children:[(0,K.jsx)(C,{className:`size-4`}),` `,F(`skills.addFile`)]})}),h.files.length||e.blobList.length?(0,K.jsxs)(f,{className:`flex flex-col divide-y divide-border-soft overflow-hidden`,children:[h.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>j(e.path),className:`flex items-center gap-2.5 px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:Z(e.text)})]},e.path)),e.blobList.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2.5`,children:[(0,K.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:[F(`skills.forScripts`),` · `,X(e.bytes)]})]},e.path))]}):(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.noFiles`)}),(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.filesHint`)}),e.blobList.length?(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.blobHint`)}):null]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 pb-20`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-start gap-4`,children:[(0,K.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,K.jsx)(oe,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[m?(0,K.jsx)(`h1`,{className:`font-medium font-mono text-2xl`,children:h.name}):(0,K.jsx)(b,{fit:!0,value:h.name,label:F(`skills.name`),placeholder:F(`skills.namePlaceholder`),maxLength:E.name,onChange:e=>{w(null),W({name:e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)})},className:`font-medium font-mono text-2xl`}),(0,K.jsx)(ie,{skill:e}),L.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(y,{className:`size-3`}),` `,F(`space.saving`)]}):L.state===`saved`?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`settings.saved`)}):null]}),m?(0,K.jsx)(`p`,{className:`mt-1 max-w-3xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:h.description}):(0,K.jsx)(`textarea`,{value:h.description,"aria-label":F(`skills.description`),placeholder:F(`skills.descPlaceholder`),maxLength:E.description,rows:2,onChange:e=>{w(null),W({description:e.target.value})},className:`-mx-1 mt-1 block w-full max-w-3xl resize-none rounded-md bg-transparent px-1 py-0.5 text-[0.9375rem] text-ink-2 leading-relaxed outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`}),(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.75rem] text-ink-3`,children:F(`skills.descHint`)})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-1`,children:[(0,K.jsxs)(`a`,{href:te(`/api/studio/skills/${e.id}/zip`),download:!0,className:`inline-flex h-8 items-center gap-2 rounded-full bg-card px-3 font-medium text-[0.8125rem] ring-1 ring-border transition hover:bg-accent`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,F(`skills.download`)]}),e.readOnly?null:(0,K.jsx)(fe,{items:[...p?[]:[{label:F(`skills.copy`),onPick:()=>B.mutate()}],{label:F(p?`skills.remove`:`skills.delete`),danger:!0,onPick:G}]})]})]}),p?(0,K.jsx)(pe,{skill:e}):null,q?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:q}):null,(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,K.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(O,{title:F(`skills.instructions`),children:[(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`skills.chars`,{n:h.body.length.toLocaleString(P)})}),(0,K.jsx)(Y,{code:_,onChange:v})]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:_?(0,K.jsx)(I,{value:U,readOnly:m,onChange:e=>{w(e);try{let t=re(e);k(!1),W({...t,files:h.files})}catch{k(!0)}},language:`markdown`,ariaLabel:`SKILL.md`,extensions:ce,className:`min-h-[55vh] [&_.cm-editor]:min-h-[55vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,K.jsx)(`div`,{className:`min-h-40 p-5 sm:px-8 sm:py-6`,children:h.body.trim()?(0,K.jsx)(a,{text:h.body}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`skills.emptyBody`)})})}),_&&D?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:F(`skills.mdError`)}):null,p?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.readOnlyNote`)}):null]}),(0,K.jsxs)(`aside`,{className:`flex flex-col gap-6`,children:[i?Q:null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.when`)}),(0,K.jsx)(le,{value:e.mode,onChange:e=>R.mutate(e),disabled:e.readOnly||R.isPending})]}),(0,K.jsx)(ue,{skill:e}),p?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.origin`)}),(0,K.jsx)(f,{className:`p-4`,children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] gap-y-2 text-[0.8125rem]`,children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.source`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`a`,{href:`https://skills.sh/${e.origin}`,target:`_blank`,rel:`noreferrer`,className:`break-all underline hover:text-ink`,children:e.origin})}),J?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.license`)}),(0,K.jsx)(`dd`,{className:`break-words`,children:J})]}):null,e.originHash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.version`)}),(0,K.jsx)(`dd`,{className:`font-mono text-[0.75rem]`,children:e.originHash.slice(0,12)})]}):null]})}),e.readOnly?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,className:`self-start`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,F(`skills.copy`)]})]}):null,i?null:Q]})]}),(0,K.jsx)($,{file:V,readOnly:m,onClose:()=>j(null),onChange:e=>W({files:h.files.map(t=>t.path===A?{...t,text:e}:t)}),onDelete:()=>{W({files:h.files.filter(e=>e.path!==A)}),j(null)}}),(0,K.jsx)(de,{open:M,taken:h.files.map(e=>e.path),onClose:()=>N(!1),onMade:e=>{W({files:[...h.files,{path:e,text:``}].sort((e,t)=>e.path.localeCompare(t.path))}),N(!1),j(e)}})]})}export{me as SkillEditor};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dn as i,Dt as a,Gn as o,K as s,Q as c,Vr as l,X as u,an as d,en as f,fn as p,gr as m,hn as h,i as ee,in as g,nn as _,on as v,pt as te,un as y,v as b}from"./ui-BacfkQ7Q.js";import{t as x}from"./useMutation-CgzFr4qH.js";import{d as S,i as C,l as ne,r as w,s as T}from"./marked.esm-DQ7XA7AC.js";import{c as E,d as D,i as O,l as re,n as k,o as ie,t as A,u as ae}from"./Skills-D7V_9_xo.js";import{t as j}from"./code-xml-S4IFi5Jc.js";import{n as M,t as oe}from"./scroll-text-BEnPzQEi.js";import{t as N}from"./eye-TJSuiHHO.js";import{n as P,s as F}from"./i18n-DCPDesT-.js";import{t as I}from"./code-editor-5T7ilBjd.js";import{N as L,a as R,r as z,t as B}from"./dist-CQpLJoQZ.js";var V={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};V.node;var se=S(V),H=e(t(),1),U=B.line({class:`cm-frontmatter`});function W(e){let t=new L,n=e.state.doc;if(n.lines>1&&n.line(1).text.trim()===`---`){for(let e=2;e<=Math.min(n.lines,80);e++)if(n.line(e).text.trim()===`---`){for(let r=1;r<=e;r++)t.add(n.line(r).from,n.line(r).from,U);break}}return t.finish()}function G(){return[R.fromClass(class{decorations;constructor(e){this.decorations=W(e)}update(e){e.docChanged&&(this.decorations=W(e.view))}},{decorations:e=>e.decorations}),z.theme({".cm-frontmatter, .cm-frontmatter *":{fontFamily:`var(--f-mono)`,fontSize:`0.8125rem !important`,fontWeight:`400 !important`,color:`var(--ink-3) !important`,textDecoration:`none !important`}})]}var K=e(n(),1),q=[`always`,`demand`,`off`],ce=G();function J(e){return m({queryKey:u.skill(e),queryFn:()=>c.get(`/api/studio/skills/${e}`)})}function le({value:e,onChange:t,disabled:n}){return(0,K.jsx)(`fieldset`,{"aria-label":F(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 flex flex-col gap-2`,children:q.map(r=>{let i=r===e,a=k[r];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:h(`flex items-start gap-3 rounded-xl bg-card p-3 text-left ring-1 transition disabled:pointer-events-none`,i?`ring-ember shadow-[0_0_0_3px] shadow-ember-tint`:`ring-border-soft hover:ring-ink-4`,n&&!i&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:h(`flex size-8 shrink-0 items-center justify-center rounded-lg`,i?`bg-ember-tint text-ember-strong`:`bg-paper-2 text-ink-3`),children:(0,K.jsx)(a,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:F(`skills.mode.${r}`)}),(0,K.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.modeHint.${r}`)})]})]},r)})})}function ue({skill:e}){let t=l(),n=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{runScripts:t}),onSuccess:async()=>{await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),r=e.source!==`own`&&!e.official;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.scriptsTitle`)}),(0,K.jsxs)(f,{className:`flex flex-col gap-2 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 font-medium text-[0.8125rem]`,children:F(`skills.runScripts`)}),(0,K.jsx)(p,{checked:e.runScripts,label:F(`skills.runScripts`),disabled:e.readOnly||n.isPending,onChange:e=>n.mutate(e)})]}),(0,K.jsx)(`p`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.runScriptsHint`)}),r?(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.75rem] text-ink-2 leading-snug`,children:F(`skills.runScriptsWarn`)}):null,n.error?(0,K.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:n.error.message}):null]})]})}function Y({code:e,onChange:t}){return(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,"aria-pressed":e,onClick:()=>t(!e),children:[e?(0,K.jsx)(N,{className:`size-4`}):(0,K.jsx)(j,{className:`size-4`}),F(e?`skills.rendered`:`skills.code`)]})}var X=e=>`${(e/1e3).toLocaleString(P,{maximumFractionDigits:1})} KB`,Z=e=>X(new TextEncoder().encode(e).length),Q=e=>/\.(md|markdown|mdx)$/i.test(e);function $({file:e,readOnly:t,onChange:n,onDelete:i,onClose:o}){let[s,c]=(0,H.useState)(!1),l=e?Q(e.path):!1,u=s||!l;return(0,K.jsx)(_,{open:e!==null,onClose:o,wide:!0,height:`tall`,title:e?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.path})]}):null,children:e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:Z(e.text)}),l?(0,K.jsx)(Y,{code:s,onChange:c}):null]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:u?(0,K.jsx)(I,{value:e.text,onChange:n,readOnly:t,language:`markdown`,ariaLabel:e.path,className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh]`}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)(a,{text:e.text})})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?null:(0,K.jsxs)(r,{variant:`danger`,size:`sm`,onClick:i,children:[(0,K.jsx)(w,{className:`size-4`}),` `,F(`skills.deleteFile`)]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(r,{size:`sm`,onClick:o,children:F(`skills.done`)})]})]}):null})}function de({open:e,taken:t,onClose:n,onMade:i}){let[a,o]=(0,H.useState)(``),s=a.trim().replace(/^\.?\//,``),c=D(s)&&s!==`SKILL.md`&&!t.includes(s);return(0,K.jsx)(_,{open:e,onClose:n,title:F(`skills.newFile`),children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c&&(i(s),o(``))},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{children:F(`skills.filePath`)}),(0,K.jsx)(d,{"data-autofocus":!0,value:a,placeholder:F(`skills.filePathHint`),onChange:e=>o(e.target.value),className:`font-mono`})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(r,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,K.jsx)(r,{type:`submit`,disabled:!c,children:F(`skills.create`)})]})]})})}function fe({items:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]),(0,K.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,K.jsx)(g,{label:F(`skills.more`),"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`ring-1 ring-border`,children:(0,K.jsx)(M,{className:`size-4`})}),t?(0,K.jsx)(`div`,{role:`menu`,className:`absolute top-11 right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{n(!1),e.onPick()},className:h(`w-full rounded-lg px-2.5 py-2 text-left text-[0.8125rem] transition hover:bg-accent`,e.danger&&`text-rose`),children:e.label},e.label))}):null]})}function pe({skill:e}){let t=l(),[n,o]=(0,H.useState)(!1),s=m({queryKey:[`skill-update`,e.id,e.originHash],queryFn:()=>c.get(`/api/studio/skills/${e.id}/update`),staleTime:6e5,retry:!1}),d=x({mutationFn:t=>c.post(`/api/studio/skills/${e.id}/update`,{hash:t}),onSuccess:async()=>{o(!1),await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),p=s.data?.update;return!p||e.readOnly?null:(0,K.jsxs)(f,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-ember`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-[0.8125rem]`,children:F(`skills.updateAvailable`)}),(0,K.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:F(`skills.showChanges`)}),(0,K.jsx)(_,{open:n,onClose:()=>o(!1),wide:!0,height:`tall`,title:F(`skills.updateTitle`,{name:e.name}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:p.description}),(0,K.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,K.jsx)(a,{text:p.body})}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[0.8125rem]`,children:p.fileList.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e.path},e.path))}),(0,K.jsx)(A,{files:p.fileList,skipped:p.skipped}),d.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(r,{busy:d.isPending,onClick:()=>d.mutate(p.hash),children:F(`skills.takeUpdate`)})})]})})]})}function me({skillId:e,onGone:t,onOpen:n,filesFirst:r}){let i=J(e);return i.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:i.error.message}):i.data?(0,K.jsx)(he,{skill:i.data,onGone:t,onOpen:n,filesFirst:r},i.data.id):(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(y,{className:`size-5`})})}function he({skill:e,onGone:t,onOpen:n,filesFirst:i}){let d=l(),p=e.source===`skills.sh`,m=e.readOnly||p,[h,g]=(0,H.useState)({name:e.name,description:e.description,body:e.body,meta:e.meta,files:e.fileList}),[_,v]=(0,H.useState)(!1),[S,w]=(0,H.useState)(null),[D,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(!1),L=s(h,async t=>{m||(await c.patch(`/api/studio/skills/${e.id}`,t),await d.invalidateQueries({queryKey:u.skills(e.spaceId)}))}),R=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{mode:t}),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skill(e.id)}),await d.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),z=x({mutationFn:()=>c.del(`/api/studio/skills/${e.id}`),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),t()}}),B=x({mutationFn:()=>c.post(`/api/studio/skills/${e.id}/copy`),onSuccess:async({id:t})=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),n(`k:${t}`)}}),V=h.files.find(e=>e.path===A)??null,U=S??ae(h),W=e=>g(t=>({...t,...e})),G=async()=>{await ee(F(p?`skills.removeConfirm`:`skills.deleteConfirm`,{name:e.name}))&&z.mutate()},q=L.error??R.error?.message??null,J=typeof e.meta.license==`string`?e.meta.license:null,Q=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.filesTitle`),children:m?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>N(!0),children:[(0,K.jsx)(C,{className:`size-4`}),` `,F(`skills.addFile`)]})}),h.files.length||e.blobList.length?(0,K.jsxs)(f,{className:`flex flex-col divide-y divide-border-soft overflow-hidden`,children:[h.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>j(e.path),className:`flex items-center gap-2.5 px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:Z(e.text)})]},e.path)),e.blobList.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2.5`,children:[(0,K.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:[F(`skills.forScripts`),` · `,X(e.bytes)]})]},e.path))]}):(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.noFiles`)}),(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.filesHint`)}),e.blobList.length?(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.blobHint`)}):null]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 pb-20`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-start gap-4`,children:[(0,K.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,K.jsx)(oe,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[m?(0,K.jsx)(`h1`,{className:`font-medium font-mono text-2xl`,children:h.name}):(0,K.jsx)(b,{fit:!0,value:h.name,label:F(`skills.name`),placeholder:F(`skills.namePlaceholder`),maxLength:E.name,onChange:e=>{w(null),W({name:e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)})},className:`font-medium font-mono text-2xl`}),(0,K.jsx)(ie,{skill:e}),L.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(y,{className:`size-3`}),` `,F(`space.saving`)]}):L.state===`saved`?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`settings.saved`)}):null]}),m?(0,K.jsx)(`p`,{className:`mt-1 max-w-3xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:h.description}):(0,K.jsx)(`textarea`,{value:h.description,"aria-label":F(`skills.description`),placeholder:F(`skills.descPlaceholder`),maxLength:E.description,rows:2,onChange:e=>{w(null),W({description:e.target.value})},className:`-mx-1 mt-1 block w-full max-w-3xl resize-none rounded-md bg-transparent px-1 py-0.5 text-[0.9375rem] text-ink-2 leading-relaxed outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`}),(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.75rem] text-ink-3`,children:F(`skills.descHint`)})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-1`,children:[(0,K.jsxs)(`a`,{href:te(`/api/studio/skills/${e.id}/zip`),download:!0,className:`inline-flex h-8 items-center gap-2 rounded-full bg-card px-3 font-medium text-[0.8125rem] ring-1 ring-border transition hover:bg-accent`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,F(`skills.download`)]}),e.readOnly?null:(0,K.jsx)(fe,{items:[...p?[]:[{label:F(`skills.copy`),onPick:()=>B.mutate()}],{label:F(p?`skills.remove`:`skills.delete`),danger:!0,onPick:G}]})]})]}),p?(0,K.jsx)(pe,{skill:e}):null,q?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:q}):null,(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,K.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(O,{title:F(`skills.instructions`),children:[(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`skills.chars`,{n:h.body.length.toLocaleString(P)})}),(0,K.jsx)(Y,{code:_,onChange:v})]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:_?(0,K.jsx)(I,{value:U,readOnly:m,onChange:e=>{w(e);try{let t=re(e);k(!1),W({...t,files:h.files})}catch{k(!0)}},language:`markdown`,ariaLabel:`SKILL.md`,extensions:ce,className:`min-h-[55vh] [&_.cm-editor]:min-h-[55vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,K.jsx)(`div`,{className:`min-h-40 p-5 sm:px-8 sm:py-6`,children:h.body.trim()?(0,K.jsx)(a,{text:h.body}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`skills.emptyBody`)})})}),_&&D?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:F(`skills.mdError`)}):null,p?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.readOnlyNote`)}):null]}),(0,K.jsxs)(`aside`,{className:`flex flex-col gap-6`,children:[i?Q:null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.when`)}),(0,K.jsx)(le,{value:e.mode,onChange:e=>R.mutate(e),disabled:e.readOnly||R.isPending})]}),(0,K.jsx)(ue,{skill:e}),p?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.origin`)}),(0,K.jsx)(f,{className:`p-4`,children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] gap-y-2 text-[0.8125rem]`,children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.source`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`a`,{href:`https://skills.sh/${e.origin}`,target:`_blank`,rel:`noreferrer`,className:`break-all underline hover:text-ink`,children:e.origin})}),J?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.license`)}),(0,K.jsx)(`dd`,{className:`break-words`,children:J})]}):null,e.originHash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.version`)}),(0,K.jsx)(`dd`,{className:`font-mono text-[0.75rem]`,children:e.originHash.slice(0,12)})]}):null]})}),e.readOnly?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,className:`self-start`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,F(`skills.copy`)]})]}):null,i?null:Q]})]}),(0,K.jsx)($,{file:V,readOnly:m,onClose:()=>j(null),onChange:e=>W({files:h.files.map(t=>t.path===A?{...t,text:e}:t)}),onDelete:()=>{W({files:h.files.filter(e=>e.path!==A)}),j(null)}}),(0,K.jsx)(de,{open:M,taken:h.files.map(e=>e.path),onClose:()=>N(!1),onMade:e=>{W({files:[...h.files,{path:e,text:``}].sort((e,t)=>e.path.localeCompare(t.path))}),N(!1),j(e)}})]})}export{me as SkillEditor};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dt as i,Q as a,S as o,Sn as s,Tn as c,Vr as l,X as u,Zn as d,an as f,en as p,fn as m,gr as h,hn as g,kn as _,nn as v,on as y,rn as b,rr as x,tn as S,un as C}from"./ui-Mplfhz_Z.js";import{t as w}from"./useMutation-8QRM-z4M.js";import{d as T,i as E}from"./marked.esm-DQ7XA7AC.js";import{t as D}from"./circle-check-DDLzlcXP.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-Bymk5Ev-.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=T(j),N={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};N.node;var P=T(N),F={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function I(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function V(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dt as i,Q as a,S as o,Sn as s,Tn as c,Vr as l,X as u,Zn as d,an as f,en as p,fn as m,gr as h,hn as g,kn as _,nn as v,on as y,rn as b,rr as x,tn as S,un as C}from"./ui-BacfkQ7Q.js";import{t as w}from"./useMutation-CgzFr4qH.js";import{d as T,i as E}from"./marked.esm-DQ7XA7AC.js";import{t as D}from"./circle-check-DDLzlcXP.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-DCPDesT-.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=T(j),N={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};N.node;var P=T(N),F={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function I(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function V(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
2
2
  `):r.join(`
3
3
  `).replace(/([^\n])\n(?!\n)/g,`$1 `).replace(/\n\n/g,`
4
4
  `),e.includes(`-`)?i.replace(/\s+$/,``):`${i.replace(/\n*$/,``)}\n`}function H(e){let t={},n=e.replace(/\r\n?/g,`
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/viewers-CkyHAjnk.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BacfkQ7Q.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-DCPDesT-.js","assets/code-editor-5T7ilBjd.js","assets/dist-CQpLJoQZ.js","assets/w3c-keyname-BOAvb0qz.js","assets/SkillEditor-DT5hQwbg.js","assets/useMutation-CgzFr4qH.js","assets/Skills-D7V_9_xo.js","assets/circle-check-DDLzlcXP.js","assets/upload-CAlHC232.js","assets/code-xml-S4IFi5Jc.js","assets/scroll-text-BEnPzQEi.js","assets/eye-TJSuiHHO.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{$t as r,A as i,B as a,Bn as o,C as s,D as c,Dn as l,Dt as u,E as d,F as f,G as p,Gn as m,H as h,Hn as g,I as _,J as v,K as y,L as b,M as x,Mn as S,N as C,Nn as w,O as T,P as E,Q as D,Rn as O,S as k,Sn as ee,T as A,Tn as te,V as ne,Vr as j,X as M,Y as N,Yn as P,_ as re,an as F,b as ie,cn as ae,cr as oe,dn as se,en as ce,fn as le,g as I,gn as ue,gr as de,h as fe,hn as L,hr as pe,i as me,in as R,j as he,k as ge,kn as _e,ln as ve,lr as ye,m as be,mn as xe,mr as Se,nn as z,on as B,or as Ce,pn as V,pr as we,q as H,rn as Te,tn as U,tr as Ee,un as De,v as W,w as G,x as Oe,y as ke,yn as Ae,z as K,zn as q}from"./ui-BacfkQ7Q.js";import{_ as je,v as Me,y as Ne}from"./Marketplace-C97fH7UC.js";import{t as Pe}from"./useMutation-CgzFr4qH.js";import{t as Fe}from"./preload-helper-DpV6A1kQ.js";import{a as Ie,c as Le,d as Re,i as J,l as ze,o as Be,r as Y,s as Ve,u as He}from"./marked.esm-DQ7XA7AC.js";import{$ as Ue,An as We,Ct as Ge,Dn as Ke,Ft as qe,Hn as Je,Kn as Ye,Ln as Xe,M as Ze,Q as Qe,Qn as $e,Rn as et,Sn as tt,St as nt,Tt as rt,Un as it,Y as at,Z as ot,_n as st,_t as ct,a as lt,at as ut,bn as dt,bt as ft,c as pt,ct as mt,dt as ht,et as gt,ft as X,gt as _t,h as vt,ht as yt,it as bt,jn as xt,l as St,lt as Ct,m as wt,mt as Tt,n as Et,nt as Dt,o as Ot,on as kt,ot as At,p as jt,pn as Mt,pt as Nt,rt as Pt,s as Ft,sn as It,st as Lt,t as Rt,tr as zt,tt as Bt,u as Vt,ut as Ht,vt as Ut,wt as Wt,xn as Gt,xt as Kt,yt as qt}from"./host-CCijW1hj.js";import{a as Jt,n as Yt,s as Xt}from"./Skills-D7V_9_xo.js";import{r as Zt}from"./volume-2-BqlBtCIJ.js";import{n as Qt,t as $t}from"./scroll-text-BEnPzQEi.js";import{t as en}from"./eye-TJSuiHHO.js";import{b as tn,f as nn}from"./theme-y_owNosi.js";import{t as rn}from"./list-checks-DaxmUPqK.js";import{t as an}from"./link-CPL8pB1P.js";import{A as on}from"./floating-ui.dom-pwdNGv4b.js";import{a as sn,c as cn,d as ln,f as un,i as dn,l as fn,o as pn,p as mn,r as hn,s as gn,t as _n,u as vn}from"./PreviewPane-CJuqY5uA.js";import{S as yn,d as bn,f as xn,h as Sn,u as Cn}from"./session-CEJRkSP5.js";import{t as wn}from"./phone-B4uKDBFq.js";import{n as Tn,r as En,t as Dn}from"./ReadOnly-CXQ41R9Q.js";import{t as On}from"./upload-CAlHC232.js";import{_t as kn,n as An,s as Z}from"./i18n-DCPDesT-.js";import{a as jn,c as Mn,f as Nn,i as Pn,l as Fn,m as In,o as Ln,p as Rn,r as zn,s as Bn,u as Vn}from"./UpdateCheck-DVgAJmy8.js";import{c as Hn}from"./index-C_iWl8iS.js";var Un={name:`at-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]};Un.node;var Wn=Re(Un),Gn={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Gn.node;var Kn=Re(Gn),qn={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`}]]};qn.node;var Jn=Re(qn),Yn={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`}]]};Yn.node;var Xn=Re(Yn),Zn={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`]};Zn.node;var Qn=Re(Zn),$n={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`}]]};$n.node;var er=Re($n),Q=e(t(),1),$=e(n(),1);function tr({spaceId:e,onDone:t}){let[n,i]=(0,Q.useState)(``),a=Pe({mutationFn:t=>D.post(`/api/studio/spaces/${e}/invite`,{email:t,lang:An}),onSuccess:()=>{i(``),t()}});return(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&a.mutate(n.trim())},className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{id:`invite-${e}`,type:`email`,value:n,maxLength:254,placeholder:Z(`clients.invitePlaceholder`),onChange:e=>i(e.target.value)}),(0,$.jsx)(r,{type:`submit`,variant:`secondary`,disabled:!n.trim()||a.isPending,children:Z(`clients.invite`)})]}),a.error?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:a.error.message}):null]})}var nr=e=>[`client-spaces`,e],rr=e=>[`open-to-clients`,e];function ir({space:e}){let t=j(),n=de({queryKey:nr(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/clients`)}),[i,a]=(0,Q.useState)(``),o=Pe({mutationFn:t=>D.post(`/api/studio/spaces/${e.id}/clients`,{name:t}),onSuccess:()=>{a(``),t.invalidateQueries({queryKey:nr(e.id)})}}),s=e=>{e.preventDefault(),i.trim()&&o.mutate(i.trim())},c=n.data?.clients??[];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(k,{title:Z(`clients.title`),hint:Z(`clients.hint`),locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`form`,{onSubmit:s,className:`flex gap-2`,children:[(0,$.jsx)(F,{id:`client-space-name`,value:i,maxLength:200,placeholder:Z(`clients.newPlaceholder`),onChange:e=>a(e.target.value)}),(0,$.jsx)(r,{type:`submit`,disabled:!i.trim()||o.isPending,children:Z(`clients.new`)})]}),o.error?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-danger`,children:o.error.message}):null,n.isSuccess&&!c.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`clients.empty`)}):(0,$.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:c.map(t=>(0,$.jsx)(ar,{spaceId:e.id,client:t},t.id))})]})}),(0,$.jsx)(or,{space:e})]})}function ar({spaceId:e,client:t}){let n=j(),[r,i]=(0,Q.useState)(!1),a=de({queryKey:[`space-members`,t.id],queryFn:()=>D.get(`/api/studio/spaces/${t.id}/members`),enabled:r}),o=Pe({mutationFn:()=>D.del(`/api/studio/spaces/${t.id}/client`),onSuccess:()=>n.invalidateQueries({queryKey:nr(e)})});return(0,$.jsxs)(`li`,{className:`py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),"aria-expanded":r,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,$.jsx)(P,{className:L(`size-4 shrink-0 text-ink-4 transition-transform`,r&&`rotate-90`)}),(0,$.jsx)(st,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:t.name}),(0,$.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-4`,children:Z(`clients.counts`,{clients:t.clients,members:t.members})})]}),(0,$.jsx)(R,{label:Z(`clients.close`,{name:t.name}),onClick:async()=>{await me(Z(`clients.closeConfirm`,{name:t.name}))&&o.mutate()},children:(0,$.jsx)(Y,{className:`size-4`})})]}),r?(0,$.jsxs)(`div`,{className:`mt-2 ml-8 flex flex-col gap-2 text-[0.875rem]`,children:[a.data?.members.length?a.data.members.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-ink-2`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.email??e.userId}),(0,$.jsxs)(`span`,{className:`text-ink-4`,children:[e.role===`client`?Z(`clients.roleClient`):Z(`clients.roleMember`),e.userId?null:` · ${Z(`clients.invited`)}`]})]},e.userId??e.email)):(0,$.jsx)(`p`,{className:`text-ink-3`,children:Z(`clients.noPeople`)}),(0,$.jsx)(tr,{spaceId:t.id,onDone:()=>a.refetch()})]}):null]})}function or({space:e}){let t=j(),n=de({queryKey:[`space-wizards`,e.id],queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),r=de({queryKey:rr(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/open-to-clients`)}),i=Pe({mutationFn:t=>D.put(`/api/studio/spaces/${e.id}/open-to-clients`,{kind:`wizard`,...t}),onSettled:()=>t.invalidateQueries({queryKey:rr(e.id)})}),a=(n.data??[]).filter(e=>e.published),o=new Set(r.data?.open.wizard??[]);return(0,$.jsx)(k,{title:Z(`clients.wizards`),hint:Z(`clients.wizardsHint`),locked:e.readOnly,children:n.isSuccess&&!a.length?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`clients.noWizards`)}):(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:a.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.9375rem]`,children:e.title}),(0,$.jsx)(le,{checked:o.has(e.id),onChange:t=>i.mutate({id:e.id,open:t}),label:e.title})]},e.id))})})}function sr({spaceId:e,kind:t,id:n}){let r=j(),i=de({queryKey:rr(e),queryFn:()=>D.get(`/api/studio/spaces/${e}/open-to-clients`)}),a=Pe({mutationFn:r=>D.put(`/api/studio/spaces/${e}/open-to-clients`,{kind:t,id:n,open:r}),onSettled:()=>r.invalidateQueries({queryKey:rr(e)})}),o=i.data?.open[t].includes(n)??!1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-ink/5 px-4 py-2.5`,children:[(0,$.jsx)(st,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:Z(`clients.openTitle`)}),(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:Z(o?`clients.openOn`:`clients.openOff`)})]}),(0,$.jsx)(le,{checked:o,disabled:!i.isSuccess||a.isPending,onChange:e=>a.mutate(e),label:Z(`clients.openTitle`)})]})}var cr={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function lr({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.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,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:Z(o?`space.describing`:`space.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`})}async function ur(e,t){await me(Z(`space.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function dr({spaceId:e,file:t,small:n}){let r=h(e,t.id);if(t.thumb&&(t.kind===`asset`||t.kind===`document`))return(0,$.jsx)(`img`,{src:p(e,t.id),alt:``,loading:`lazy`,className:`size-full object-cover object-top`});if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:L(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(fr,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(w,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(Ve,{className:i}):t.mime===`application/json`?(0,$.jsx)(ee,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Jn,{className:i}):(0,$.jsx)(g,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function fr({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.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,$.jsx)(`div`,{className:L(`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 pr=`application/x-wizards-logo`;function mr({spaceId: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):ur(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:u&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(pr,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,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(U,{tone:`ember`,children:Z(`space.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?cr:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${Z(`space.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(dr,{spaceId:e,file:n})}):(0,$.jsx)(dr,{spaceId:e,file:n}),(0,$.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,$.jsx)(R,{label:Z(`space.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(en,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(R,{label:Z(`space.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Me,{className:`size-4`})}):null,u&&!r.readOnly?(0,$.jsx)(ke,{options:u.options,value:u.current(n),onChange:e=>u.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:()=>f(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(lr,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(re,{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,$.jsx)(De,{className:`size-5`}):(0,$.jsx)(J,{className:`size-5`}),a]}):null]})}function hr({kind:e,fetchUrl:t,onAdded:n,onClose:i}){let[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{c(!0),u(null);try{let r=await t(a.trim());r.file?(n([r.file]),i()):r.candidates?.length?(f(r.candidates),m([r.candidates[0].url])):u(Z(e===`logo`?`space.logoNoneFound`:`space.assetNoneFound`))}catch(e){u(e.message)}c(!1)},g=async()=>{c(!0),u(null);let e=[];try{for(let n of p){let r=await t(n);r.file&&e.push(r.file)}}catch(e){u(e.message)}c(!1),e.length&&n(e),e.length===p.length&&i()};return(0,$.jsx)(z,{open:!0,onClose:i,wide:d?!0:void 0,title:Z(d?e===`logo`?`space.logoFound`:`space.assetFound`:e===`logo`?`space.logoFromUrl`:`space.assetFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Z(e===`logo`?`space.logoFoundHint`:`space.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:d.map(t=>{let n=p.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>m(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:L(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:cr,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:L(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(He,{className:`size-3.5`})}):null]},t.url)})}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:()=>f(null),children:Z(`run.back`)}),(0,$.jsx)(r,{busy:s,disabled:!p.length,onClick:()=>void g(),children:p.length>1?Z(`space.addMany`,{n:p.length}):Z(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.logoUrl`)}),(0,$.jsx)(F,{autoFocus:!0,value:a,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(e===`logo`?`space.logoUrlHint`:`space.assetUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:i,children:Z(`common.cancel`)}),(0,$.jsx)(r,{type:`submit`,busy:s,disabled:!a.trim(),children:Z(`run.next`)})]})]})})}var gr=(0,Q.lazy)(()=>Fe(()=>import(`./viewers-CkyHAjnk.js`).then(e=>({default:e.Viewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function _r(e,t,n){return de({queryKey:[`space-file-text`,t.id,t.chars,n],queryFn:()=>D.get(`/api/studio/spaces/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function vr(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var yr=e=>[vr(e),e.pages?Z(`space.pages`,{n:e.pages}):null,kn(e.size)].filter(Boolean).join(` · `),br=2e5;function xr({spaceId:e,fileId:t,readOnly:n,onGone:r,page:i}){let a=j(),o=N(e),s=ht(e),c=H(e,n),u=o.data?.files.find(e=>e.id===t),d=Mt(`knowledgeTree`),f=u?ut(u.mime,u.name):null,p=u?d?f!==null:u.mime===`application/pdf`||u.mime.startsWith(`image/`):!1,[m,g]=(0,Q.useState)(null);if(!u)return o.isLoading?(0,$.jsx)(De,{className:`mx-auto text-ink-3`}):null;let _=m??(p?`original`:`text`),v=s.data?.items.find(e=>e.key===`f:${u.id}`),y=h(e,u.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":_===e,onClick:()=>g(e),className:L(`rounded-full px-3 py-1 text-[0.8125rem] transition`,_===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:u.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:yr(u)}),(0,$.jsx)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,"aria-label":Z(`space.openOriginal`),title:Z(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(Le,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{label:Z(`space.reindex`),onClick:async()=>{await c.reindex(u.id),await a.invalidateQueries({queryKey:M.knowledge(e)})},children:(0,$.jsx)(l,{className:`size-4`})}),(0,$.jsx)(R,{label:Z(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{await me(Z(`data.confirmDelete`,{title:u.name}))&&(await c.remove(u.id),await a.invalidateQueries({queryKey:M.knowledge(e)}),r())},children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(mt,{spaceId:e,itemKey:`f:${u.id}`,has:v?.categories??[],originLabel:v?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(lr,{file:u,actions:c})}),u.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:u.error}):null,(0,$.jsxs)(ce,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[p?b(`original`,Z(`space.original`)):null,b(`text`,Z(`space.readText`))]}),_===`original`&&d&&f?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(De,{})}),children:(0,$.jsx)(gr,{kind:f,url:y,name:u.name,page:i})}):_===`original`?u.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:y,title:u.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:y,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(Sr,{spaceId:e,file:u})]})]})}function Sr({spaceId:e,file:t}){let n=_r(e,t,br);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(De,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(u,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:Z(`space.textCut`,{shown:n.data.text.length.toLocaleString(An),total:n.data.chars.toLocaleString(An)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:Z(`space.noText`)})}var Cr=8;function wr({tab:e,onTab:t}){let n=(n,r)=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:L(`flex-1 rounded-md px-2 py-1 text-[0.8125rem] transition`,e===n?`bg-card font-medium text-ink shadow-soft`:`text-ink-2 hover:text-ink`),children:r});return(0,$.jsxs)(`div`,{role:`tablist`,className:`mb-2 flex gap-0.5 rounded-lg bg-paper-2 p-0.5`,children:[n(`folders`,Z(`know.tabFolders`)),n(`categories`,Z(`know.tabCategories`))]})}function Tr({categories:e,picked:t,pickedCategory:n,readOnly:i,onPick:a,onNew:o}){let{filter:s}=Rn(),[c,l]=(0,Q.useState)(()=>new Set);(0,Q.useEffect)(()=>{n&&l(e=>e.has(n)?e:new Set([...e,n]))},[n]);let u=e=>l(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});if(!e.length)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-1`,children:[(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:Z(`know.categoriesEmpty`)}),i?null:(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,className:`self-start`,onClick:o,children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`know.category`)]})]});let d=e=>L(`flex min-w-0 flex-1 items-center gap-2 py-1.5 pr-2 text-left text-[0.875rem]`,e?`font-medium text-ink`:`text-ink-2 group-hover/row:text-ink`),f=s?e.filter(e=>e.name.toLowerCase().includes(s)||e.values.some(e=>e.value.toLowerCase().includes(s))):e;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:f.map(e=>{let r=ft[e.type],i=s?e.values.filter(e=>e.value.toLowerCase().includes(s)):e.values,o=c.has(e.id)||!!(s&&i.length),l=t===`c:${e.id}`||!o&&n===e.id&&t!==null;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:L(`group/row flex items-center rounded-lg transition`,l?`bg-paper-2`:`hover:bg-accent`),children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:i.length?0:-1,"aria-label":Z(o?`know.collapse`:`know.expand`),"aria-expanded":i.length?o:void 0,onClick:()=>i.length&&u(e.id),className:L(`grid size-6 shrink-0 place-items-center rounded-md text-ink-4`,i.length?`hover:text-ink`:`invisible`),children:(0,$.jsx)(P,{className:L(`size-3.5 transition-transform`,o&&`rotate-90`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`c:${e.id}`),"aria-current":l?`page`:void 0,className:d(l),children:[(0,$.jsx)(r,{className:L(`size-4 shrink-0`,l?`text-ember-strong`:`text-ink-3`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.proposed?(0,$.jsx)(U,{tone:`ember`,children:Z(`know.proposed`)}):(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})]}),o&&i.length?(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5 pt-0.5`,children:[i.slice(0,s?void 0:Cr).map(e=>{let n=t===`v:${e.id}`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),"aria-current":n?`page`:void 0,className:L(`flex w-full items-center gap-2 rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.875rem] transition`,n?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.value}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]})},e.id)}),!s&&i.length>Cr?(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(`c:${e.id}`),className:`w-full rounded-lg py-1.5 pr-2 pl-9 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:Z(`know.moreValues`,{n:i.length-Cr})})}):null]}):null]},e.id)})}),i?null:(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`mt-2 flex items-center gap-2 rounded-lg px-1 py-1.5 text-left text-[0.8125rem] text-ink-3 transition hover:bg-accent hover:text-ink`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center`,children:(0,$.jsx)(J,{className:`size-4`})}),Z(`know.category`)]})]})}function Er({onEdit:e,onDelete:t}){let[n,r]=(0,Q.useState)(!1),i=(0,Q.useRef)(null);vt(i,n,()=>r(!1));let a=`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink`,o=e=>()=>{r(!1),e()};return(0,$.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,$.jsx)(R,{label:Z(`know.more`),"aria-haspopup":`menu`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`size-8`,children:(0,$.jsx)(Qt,{className:`size-4`})}),n?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute top-full right-0 z-50 mt-1 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:a,onClick:o(e),children:[(0,$.jsx)(_e,{className:`size-4 shrink-0`}),` `,Z(`know.edit`)]}),(0,$.jsx)(`div`,{className:`mx-2 my-1.5 h-px bg-border-soft`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:L(a,`text-rose hover:bg-rose-tint hover:text-rose`),onClick:o(t),children:[(0,$.jsx)(Y,{className:`size-4 shrink-0`}),` `,Z(`know.deleteCategory`)]})]}):null]})}function Dr({eyebrow:e,title:t,line:n,action:r}){return(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(tt,{className:`size-3.5`}),` `,e]}),(0,$.jsx)(`h2`,{className:`mt-0.5 font-display font-semibold text-lg leading-tight`,children:t}),n?(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3`,children:n}):null]}),r?(0,$.jsx)(`div`,{className:`shrink-0`,children:r}):null]})}function Or({spaceId:e,data:t,category:n,readOnly:i,onOpen:a,onGone:o}){let s=j(),[c,l]=(0,Q.useState)(!1),u=Pe({mutationFn:e=>e(),onSuccess:()=>s.invalidateQueries({queryKey:M.knowledge(e)})}),d=ft[n.type];return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(Dr,{eyebrow:Z(`know.type.${n.type}`),title:n.name,line:[Wt(n.count),n.unit,n.hint].filter(Boolean).join(` · `),action:i?null:(0,$.jsx)(Er,{onEdit:()=>l(!0),onDelete:async()=>await me(Z(`know.confirmCategory`,{name:n.name}))&&u.mutate(async()=>{await D.del(`/api/studio/categories/${n.id}`),o()})})}),n.proposed&&!i?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl bg-ember-tint px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:Z(`know.proposedHint`)}),(0,$.jsx)(r,{size:`sm`,variant:`secondary`,onClick:()=>u.mutate(()=>D.del(`/api/studio/categories/${n.id}`)),children:Z(`know.dismiss`)}),(0,$.jsx)(r,{size:`sm`,onClick:()=>u.mutate(()=>D.patch(`/api/studio/categories/${n.id}`,{proposed:!1})),children:Z(`know.accept`)})]}):null,n.type===`choice`?(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:n.values.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(`v:${e.id}`),className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3.5 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(d,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e.value})]}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:[Wt(e.count),e.summary?Z(`know.summary`):``].filter(Boolean).join(` · `)})]},e.id))}):(0,$.jsx)(At,{spaceId:e,category:n,categories:t.categories,onOpen:a}),u.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:u.error.message}):null,(0,$.jsx)(z,{open:c,onClose:()=>l(!1),wide:!0,children:(0,$.jsx)(Kt,{spaceId:e,category:n,readOnly:i,onOpen:e=>{l(!1),a(e)},onGone:()=>{l(!1),o()}})})]})}function kr({data:e,value:t,readOnly:n,onOpen:r}){let i=t.rows.reduce((e,t)=>e+t.count,0);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(Dr,{eyebrow:t.category.name,title:t.value,line:[Wt(t.items.length),...t.rows.map(e=>Z(`know.tocRows`,{n:e.count,table:e.title}))].filter(Boolean).join(` · `)}),(0,$.jsx)(Ge,{value:t,readOnly:n,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[t.items.length?(0,$.jsx)(X,{items:t.items,categories:e.categories.filter(e=>e.id!==t.category.id),onOpen:r}):null,i?t.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:Z(`know.tocRows`,{n:e.count,table:e.title})},e.tableId)):null]})})]})}var Ar=[{value:`de-du`,label:`page.lang.deDu`},{value:`de-sie`,label:`page.lang.deSie`},{value:`en`,label:`page.lang.en`}],jr=`text-[0.8125rem] text-ink-3 leading-snug`,Mr=`font-mono text-[0.875rem]`,Nr=e=>e.slice(e.indexOf(`.`)+1);function Pr(){let[e,t]=(0,Q.useState)(!1),n=(0,Q.useRef)(void 0);return(0,Q.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 Fr(){let e=Z(`page.sources`).split(/(\{brand\}|\{facts\})/);return(0,$.jsxs)(`p`,{className:jr,children:[e.map((e,t)=>e===`{brand}`?(0,$.jsx)(Ce,{to:`/space/brand`,className:`text-ink underline-offset-2 hover:underline`,children:Z(`space.brand`)},t):e===`{facts}`?(0,$.jsx)(Ce,{to:`/space/info#facts`,className:`text-ink underline-offset-2 hover:underline`,children:Z(`space.facts`)},t):e),` `,Z(`page.onlyShared`)]})}function Ir({host:e,value:t,onChange:n,disabled:r}){let i=x.test(t);return(0,$.jsxs)(`div`,{children:[(0,$.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,$.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:[`…`,Nr(e),`/`]}),(0,$.jsx)(`input`,{value:t,disabled:r,"aria-label":Z(`page.address`),maxLength:he.slug,onChange:e=>n(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,`-`)),className:L(`min-w-0 flex-1 bg-transparent px-3 outline-none`,Mr)})]}),(0,$.jsx)(`p`,{className:L(`mt-1.5`,jr,!i&&t&&`text-rose`),children:Z(`page.addressRules`)})]})}function Lr({host:e,words:t,onChange:n,disabled:r}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-5 sm:grid-cols-[repeat(2,minmax(0,1fr))]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(B,{children:Z(`page.title`)}),(0,$.jsx)(F,{value:t.title,disabled:r,maxLength:he.title,onChange:e=>n({title:e.target.value})}),(0,$.jsx)(`p`,{className:L(`mt-1.5`,jr),children:Z(`page.titleHint`)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(B,{children:Z(`page.address`)}),(0,$.jsx)(Ir,{host:e,value:t.slug,disabled:r,onChange:e=>n({slug:e})}),(0,$.jsx)(`p`,{className:L(`mt-1`,jr),children:Z(`page.addressChange`)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,$.jsx)(B,{children:Z(`page.headline`)}),(0,$.jsx)(F,{value:t.headline??``,disabled:r,maxLength:he.headline,onChange:e=>n({headline:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,$.jsx)(B,{children:Z(`page.words`)}),(0,$.jsx)(xe,{value:t.intro??``,disabled:r,minRows:3,maxLength:he.intro,onChange:e=>n({intro:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(B,{children:Z(`page.lang`)}),(0,$.jsx)(ve,{value:t.voice,onChange:e=>n({voice:e}),options:Ar.map(e=>({value:e.value,label:Z(e.label)}))}),(0,$.jsx)(`p`,{className:L(`mt-1.5`,jr),children:Z(`page.langHint`)})]})]})}function Rr(e,t){if(!e.published)return Z(`page.draftNote`);if(!e.shareEnabled)return Z(`page.notSharedNote`);let n=e.description.trim();return t?[n,Z(`page.first`)].filter(Boolean).join(` · `):n}function zr({wizard:e,first:t,on:n,disabled:r,onToggle:i,drag:a}){return(0,$.jsxs)(`li`,{draggable:a?!0:void 0,onDragStart:a?.onDragStart,onDragOver:a?.onDragOver,onDrop:a?.onDrop,className:L(`flex items-center gap-3 border-border-soft border-t py-2.5 first:border-t-0`,!e.published&&`opacity-60`),children:[a?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${Z(`page.moveUp`)} / ${Z(`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,$.jsx)(o,{className:`size-4`})}):(0,$.jsx)(`span`,{className:`size-7 shrink-0`}),(0,$.jsx)(yn,{kind:e.avatar,costume:e.costume,size:36,interactive:!1}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),(0,$.jsx)(`p`,{className:L(`truncate`,jr),children:Rr(e,t)})]}),(0,$.jsx)(le,{checked:n,disabled:r||!e.published,label:Z(`page.showOnPage`),onChange:i})]})}function Br({title:e,text:t,picked:n,disabled:r,later:i,onPick:a}){return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:r||i,onClick:a,className:L(`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,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e}),(0,$.jsx)(`span`,{className:jr,children:t})]})}var Vr={desktop:1280,tablet:768,mobile:390},Hr=`wizards.pagePreviewDevice`,Ur=`wizards.pagePreviewHeight`,Wr=360,Gr=e=>e?640:480,Kr=()=>Math.max(Wr,window.innerHeight-140);function qr(){try{let e=Number(localStorage.getItem(Ur));return e>=Wr?e:null}catch{return null}}function Jr(e){try{e===null?localStorage.removeItem(Ur):localStorage.setItem(Ur,String(Math.round(e)))}catch{}}function Yr(){try{let e=localStorage.getItem(Hr);return e&&e in Vr?e:`desktop`}catch{return`desktop`}}function Xr(e){try{localStorage.setItem(Hr,e)}catch{}}function Zr({url:e,version:t,device:n}){let r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)({width:0,tall:!0});(0,Q.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=Vr[n],[s,c]=(0,Q.useState)(qr),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=Math.min(s??Gr(i.tall),i.width?Kr():9999),p=e=>{let t=Math.round(Math.min(Kr(),Math.max(Wr,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,$.jsxs)(`div`,{className:L(`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,$.jsx)(`iframe`,{title:Z(`page.previewTitle`),src:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`,tabIndex:-1,className:L(`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,$.jsx)(`button`,{type:`button`,"aria-label":Z(`page.resize`),title:Z(`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&&=(Jr(p(d.current.height+e.clientY-d.current.y)),null),u(!1)},onPointerCancel:()=>{d.current=null,u(!1)},onDoubleClick:()=>{c(null),Jr(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),Jr(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,$.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,$.jsx)(`path`,{d:`M11 1 1 11M11 5 5 11M11 9 9 11`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]});return(0,$.jsx)(`div`,{ref:r,className:`flex w-full justify-center`,children:m?(0,$.jsx)(`div`,{className:`rounded-[2.25rem] bg-ink p-3 shadow-soft`,children:_}):_})}function Qr({host:e,page:t,disabled:n,save:r,onState:i}){let a=(0,Q.useRef)(t);a.current=t;let[o,s]=(0,Q.useState)(()=>({slug:t.slug,title:t.title,headline:t.headline??``,intro:t.intro??``,voice:mn(t)})),c=y(o,async e=>{if(!(x.test(e.slug)&&e.title.trim()))return;let{lang:t,form:n}=vn(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:l,error:u}=c;return(0,Q.useEffect)(()=>i(c),[l,u]),(0,$.jsx)(Lr,{host:e,words:o,disabled:n,onChange:e=>s(t=>({...t,...e}))})}function $r({space:e}){let t=j(),n=Sn(),i=n.data?.tenant.pagesHost??null,o=n.data?.manageUrl??null,s=e.readOnly,c=e.page,l=!!c?.on,u=de({queryKey:M.spaceWizards(e.id),queryFn:()=>D.get(`/api/studio/spaces/${e.id}/wizards`)}),[d,f]=(0,Q.useState)(1),[p,m]=(0,Q.useState)(Yr),h=(0,Q.useRef)(c);h.current=c;let g=async n=>{await D.patch(`/api/studio/spaces/${e.id}`,{page:n}),await t.invalidateQueries({queryKey:M.spaces()}),f(e=>e+1)},_=Pe({mutationFn:e=>{let t=h.current;return t?g({...t,...e}):Promise.resolve()}}),[v,y]=(0,Q.useState)({state:`idle`,error:null}),{copied:b,copy:x}=Pr(),S=u.data??[],C=(c?.wizards??[]).map(e=>S.find(t=>t.id===e)).filter(e=>e!==void 0),w=S.filter(e=>!c?.wizards.includes(e.id)),[T,E]=(0,Q.useState)(null),O=(e,t)=>{let n=[...c?.wizards??[]];if(t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),_.mutate({wizards:n})},ee=(e,t)=>_.mutate({wizards:t?[...c?.wizards??[],e]:(c?.wizards??[]).filter(t=>t!==e)}),A=e.brand.name?.trim()||e.name,te=Pe({mutationFn:()=>g({on:!0,slug:a(A)||`page`,title:A,...vn(An===`de`?`de-du`:`en`),wizards:S.filter(e=>e.published&&e.shareEnabled).map(e=>e.id),examples:{}})}),ne=e=>{c?_.mutate({on:e}):e&&te.mutate()},N=_.isPending||te.isPending,P=_.error??te.error;if(!i)return(0,$.jsx)(I,{id:`page`,children:(0,$.jsx)(k,{title:Z(`space.page`),hint:Z(`page.intro`),children:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:Z(`page.cloudOnly`)})})});let re=c?.slug||a(A)||`…`,F=ln(i,re),ie=un(i,re,o),ae=(0,$.jsxs)(`span`,{className:L(Mr,`min-w-0 truncate`),children:[(0,$.jsxs)(`span`,{className:`text-ink-3`,children:[i,`/`]}),(0,$.jsx)(`b`,{className:`text-ink`,children:re})]}),oe=s||!c,se=(0,$.jsxs)(ce,{className:`flex flex-col gap-2.5 p-4`,children:[(0,$.jsxs)(`div`,{className:`@container flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:Z(`page.previewTitle`)}),l?(0,$.jsx)(_n,{named:!0,label:Z(`editor.device`),value:p,onChange:e=>{m(e),Xr(e)},options:[{id:`desktop`,label:Z(`editor.deviceDesk`),icon:(0,$.jsx)(xt,{className:`size-3.5`})},{id:`tablet`,label:Z(`page.deviceTablet`),icon:(0,$.jsx)(er,{className:`size-3.5`})},{id:`mobile`,label:Z(`editor.devicePhone`),icon:(0,$.jsx)(tn,{className:`size-3.5`})}]}):null]}),l?(0,$.jsx)(Zr,{url:ie,version:d,device:p}):(0,$.jsx)(`p`,{className:jr,children:Z(`page.previewOff`)}),l?(0,$.jsx)(`p`,{className:jr,children:Z(`page.previewHint`)}):null]}),ue=(0,$.jsxs)(ce,{className:`flex flex-col gap-3 p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.875rem]`,children:Z(`page.inShare`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-paper-2 px-3 py-2.5`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:Z(`share.onPage`,{space:c?.title||A})}),(0,$.jsx)(`span`,{className:L(`block truncate font-mono`,jr),children:F})]}),(0,$.jsx)(le,{checked:!0,disabled:!0,label:Z(`page.showOnPage`),onChange:()=>{}})]}),(0,$.jsx)(`p`,{className:jr,children:Z(`page.inShareHint`)})]});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-9`,children:[(0,$.jsxs)(`div`,{className:`contents`,children:[(0,$.jsx)(I,{id:`page`,children:(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`px-1`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:Z(`space.page`)}),(0,$.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:Z(`page.intro`)})]}),(0,$.jsxs)(ce,{className:`flex flex-wrap items-center gap-3 p-3 sm:pl-4`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:L(`size-2 shrink-0 rounded-full`,l?`bg-moss`:`bg-ink-4`),"aria-hidden":!0}),ae]}),(0,$.jsxs)(`span`,{className:`flex w-full items-center gap-2 sm:w-auto sm:shrink-0`,children:[(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>x(ie),children:[b?(0,$.jsx)(He,{className:`size-3.5`}):(0,$.jsx)(ze,{className:`size-3.5`}),Z(b?`share.copied`:`share.copyMain`)]}),(0,$.jsxs)(r,{size:`sm`,className:`max-sm:flex-1`,disabled:!l,onClick:()=>window.open(ie,`_blank`,`noopener`),children:[Z(`page.open`),` `,(0,$.jsx)(zt,{className:`size-3.5`})]})]})]}),(0,$.jsxs)(k,{title:Z(`page.sectionPage`),locked:s,children:[(0,$.jsxs)(`fieldset`,{"aria-label":Z(`page.sectionPage`),className:`grid min-w-0 gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))]`,children:[(0,$.jsx)(Br,{title:Z(`page.whoOff`),text:Z(`page.whoOffHint`),picked:!l,disabled:s||N,onPick:()=>ne(!1)}),(0,$.jsx)(Br,{title:Z(`page.whoPublic`),text:Z(`page.whoPublicHint`),picked:l,disabled:s||N,onPick:()=>ne(!0)}),(0,$.jsx)(Br,{title:Z(`page.whoMembers`),text:Z(`page.whoMembersHint`),picked:!1,later:!0,onPick:()=>{}})]}),P?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:P.message}):null]})]})}),se,(0,$.jsx)(I,{id:`page-words`,children:(0,$.jsx)(k,{title:Z(`page.sectionWords`),hint:c?void 0:Z(`page.notYet`),save:c?v:void 0,locked:oe,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[c?(0,$.jsx)(Qr,{host:i,page:c,disabled:s,save:g,onState:y},`${e.id}:${c.slug}`):(0,$.jsx)(Lr,{host:i,disabled:!0,words:{slug:re,title:A,headline:``,intro:``,voice:An===`de`?`de-du`:`en`},onChange:()=>{}}),(0,$.jsxs)(`div`,{id:`page-wizards`,className:`scroll-mt-6 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:Z(`page.sectionWizards`)}),(0,$.jsx)(`span`,{className:jr,children:Z(`page.wizardsHint`)})]}),(0,$.jsxs)(`ul`,{className:`mt-2 flex flex-col`,children:[C.map((e,t)=>(0,$.jsx)(zr,{wizard:e,first:t===0,on:!0,disabled:oe,onToggle:t=>ee(e.id,t),drag:{onDragStart:()=>E(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{T!==null&&O(T,t),E(null)},onKeyDown:e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),O(t,e.key===`ArrowUp`?t-1:t+1))}}},e.id)),w.map(e=>(0,$.jsx)(zr,{wizard:e,first:!1,on:!1,disabled:oe,onToggle:t=>ee(e.id,t)},e.id))]}),S.length?null:(0,$.jsx)(`p`,{className:L(`mt-2`,jr),children:Z(`page.noWizards`)}),(0,$.jsx)(`p`,{className:L(`mt-4`,jr),children:Z(`page.wizardsNote`)})]}),(0,$.jsx)(Fr,{})]})})})]}),ue]})}var ei=`results-search`,ti={q:``,mode:``,days:0};function ni(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 de({queryKey:[`results`,e,i],queryFn:()=>D.get(`/api/studio/spaces/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function ri({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Q.useState)(r.q);return It({icon:te,label:Z(`space.resultsSearch`),run:()=>{let e=document.getElementById(ei);e?.scrollIntoView({block:`center`,behavior:`smooth`}),e?.focus()}}),(0,Q.useEffect)(()=>{if(a===r.q)return;let e=setTimeout(()=>i({...r,q:a}),250);return()=>clearTimeout(e)},[a,r,i]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(ve,{value:t??``,onChange:e=>n(e||null),options:[{value:``,label:Z(`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,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(te,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(F,{type:`search`,value:a,onChange:e=>o(e.target.value),id:ei,placeholder:Z(`space.resultsSearch`),"aria-label":Z(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(ve,{value:r.mode,onChange:e=>i({...r,mode:e}),options:[{value:``,label:Z(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(ve,{value:String(r.days),onChange:e=>i({...r,days:Number(e)}),options:[{value:`0`,label:Z(`space.resultsAnyTime`)},{value:`1`,label:Z(`space.resultsDay`)},{value:`7`,label:Z(`space.resultsDays`,{n:7})},{value:`30`,label:Z(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function ii({data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}){let[a,o]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(An,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{title:t?s(t):Z(`space.resultsAll`),hint:Z(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(ri,{data:e,wizardId:t,onWizard:n,filter:r,onFilter:i}),e.runs.length?(0,$.jsx)(ce,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.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,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,Z(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:Z(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(S,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(U,{children:Z(`run.testChip`)}):(0,$.jsxs)(U,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(ce,{children:(0,$.jsx)(Te,{children:r.q.trim()||r.mode||r.days?Z(`space.resultsNone`):Z(`space.resultsEmpty`)})})]}),a?(0,$.jsx)(hn,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(a.wizardId)}),a.mode===`test`?(0,$.jsx)(U,{children:Z(`run.testChip`)}):(0,$.jsxs)(U,{tone:`live`,children:[`Live v`,a.version]})]}),onClose:()=>o(null),children:(0,$.jsx)(nn,{runId:a.id,compact:!0,studio:!0},a.id)}):null]})}var ai={info:`space.teaser.info`,brand:`space.teaser.brand`,knowledge:`space.teaser.knowledge`,data:`space.teaser.data`,page:`space.teaser.page`};function oi({space:e,parts:t}){let n=Se(),r=N(e.id),i=ht(e.id),a=cn(e.id);kt({title:Z(`space.overviewAssistantTitle`),hello:Z(`space.overviewAssistantHello`),suggestions:[{label:Z(`assistant.suggest.missing`)},{label:Z(`assistant.suggest.readSite`),fill:!0}]});let o=r.data?.files.filter(e=>e.kind===`logo`)??[],s=o.length,c=e.brand.colors?.length??0,l=i.data?.items.length??0,u=i.data?.categories.length??0,d=a.data?.tables.length??0,f=a.data?.pages.length??0,p=t=>{let n=(...e)=>e.filter(Boolean).join(` · `);switch(t){case`info`:{let t=!!e.brand.name?.trim();return{text:n(!t&&Z(`space.status.noTitle`),e.facts.length>0&&Z(`space.status.facts`,{n:e.facts.length}))||Z(`space.status.empty`),filled:t}}case`brand`:return r.isPending?null:{text:n(s>0&&Z(`space.status.logos`,{n:s}),c>0&&Z(`space.status.colors`,{n:c}))||Z(`space.status.empty`),filled:s+c>0};case`knowledge`:return i.isPending?null:{text:n(l>0&&Z(`space.status.entries`,{n:l}),u>0&&Z(`space.status.categories`,{n:u}))||Z(`space.status.empty`),filled:l>0};case`data`:return a.isPending?null:{text:n(d>0&&Z(`space.status.tables`,{n:d}),f>0&&Z(`space.pages`,{n:f}))||Z(`space.status.empty`),filled:d+f>0};default:return null}},m=t=>{let n=`flex min-w-0 items-center gap-2 text-[0.8125rem] text-ink-2`;switch(t){case`info`:return e.brand.name?.trim()||e.facts.length?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.brand.name?.trim()?(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.name}):null,e.facts.slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-ink-3`,children:e.label}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.value})]},e.key))]}):null;case`brand`:return s+c||e.brand.tagline?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.brand.brandName||e.brand.tagline?(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-[0.875rem] text-ink`,children:e.brand.brandName||e.brand.name}),e.brand.tagline?(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-3 italic`,children:e.brand.tagline}):null]}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o.slice(0,3).map(t=>(0,$.jsx)(`span`,{className:`grid size-12 shrink-0 place-items-center overflow-hidden rounded-lg bg-paper ring-1 ring-border-soft`,children:(0,$.jsx)(dr,{spaceId:e.id,file:t,small:!0})},t.id)),(0,$.jsx)(`span`,{className:`flex flex-wrap gap-1`,children:(e.brand.colors??[]).slice(0,8).map(e=>(0,$.jsx)(`span`,{title:`${e.name} ${e.value}`,className:`size-5 rounded-full ring-1 ring-border-soft`,style:{background:e.value}},`${e.name}${e.value}`))})]})]}):null;case`knowledge`:return l?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i.data?.items.slice(0,3).map(e=>{let t=e.kind===`page`?Ve:e.kind===`table`?Ae:Be;return(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(t,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.key)}),u?(0,$.jsx)(`span`,{className:`mt-1 flex flex-wrap gap-1`,children:i.data?.categories.slice(0,4).map(e=>(0,$.jsx)(`span`,{className:`rounded-full bg-paper-2 px-2 py-0.5 text-[0.75rem] text-ink-3`,children:e.name},e.id))}):null]}):null;case`data`:return d+f?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:[...(a.data?.tables??[]).map(e=>({key:`t:${e.id}`,title:e.title,rows:e.rows,Icon:Ae})),...(a.data?.pages??[]).map(e=>({key:`p:${e.id}`,title:e.title,rows:null,Icon:Ve}))].slice(0,3).map(e=>(0,$.jsxs)(`span`,{className:n,children:[(0,$.jsx)(e.Icon,{className:`size-3.5 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.rows===null?null:(0,$.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:e.rows})]},e.key))}):null;default:return null}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)(Ze,{}),(0,$.jsx)(k,{title:Z(`nav.sources`),hint:Z(`space.overviewHint`),plain:!0,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:t.map(e=>{let t=p(e.id),r=ai[e.id];return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.to),className:`group flex min-w-0 flex-col gap-2 rounded-xl bg-card p-4 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-paper-2 text-ember-strong`,children:(0,$.jsx)(e.icon,{className:`size-4`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-semibold text-[0.9375rem]`,children:e.label}),(0,$.jsx)(P,{className:`size-4 text-ink-4 transition group-hover:translate-x-0.5 group-hover:text-ink-3`})]}),r?(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-relaxed`,children:Z(r)}):null,m(e.id)?(0,$.jsx)(`span`,{className:`block rounded-lg bg-paper-2/50 p-3`,children:m(e.id)}):null,t?(0,$.jsx)(`span`,{className:`mt-auto pt-1`,children:(0,$.jsx)(U,{tone:t.filled?`live`:`warn`,children:t.text})}):null]},e.id)})})})]})}var si=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,ci=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),kn(e.size)].filter(Boolean).join(` · `);function li({spaceId:e,file:t,actions:n,onClose:r}){let i=h(e,t.id);return(0,$.jsxs)(z,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:ci(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":Z(`space.openOriginal`),title:Z(`space.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(Le,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:cr,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(lr,{file:t,actions:n})})]})}function ui({spaceId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${Z(`space.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(dr,{spaceId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.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,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:ci(t)})]}),(0,$.jsx)(lr,{file:t,actions:n})]}),(0,$.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,$.jsx)(R,{label:Z(`space.preview`),onClick:i,children:(0,$.jsx)(en,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(ke,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]})]})}function di({section:e,onSave:t,onRemove:n,onClose:i}){let[a,o]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(z,{open:!0,onClose:i,title:Z(e?`space.assetSectionRename`:`space.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.trim()&&(t(a.trim()),i())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.assetSectionName`)}),(0,$.jsx)(F,{autoFocus:!0,value:a,maxLength:80,placeholder:Z(`space.assetSectionTitle`),onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(r,{variant:`danger`,onClick:n,children:Z(`space.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(r,{variant:`ghost`,onClick:i,children:Z(`common.cancel`)}),(0,$.jsx)(r,{type:`submit`,disabled:!a.trim(),children:Z(e?`settings.save`:`space.add`)})]})]})})}function fi({spaceId:e,data:t,readOnly:n,sections:r,save:i}){let a=H(e,n),[o,s]=v(`assets`,`cards`),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(r),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null),w=y({assetSections:f},i),T=t.files.filter(e=>e.kind===`asset`),E=new Map(T.map(e=>[e.id,e])),D=new Set(f.flatMap(e=>e.assets)),O=f.find(e=>e.id===m)??null,ee=O?O.assets.map(e=>E.get(e)).filter(e=>!!e):T.filter(e=>!D.has(e.id)),A=T.find(e=>e.id===u),te=c.trim().toLowerCase(),ne=te?ee.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(te)):ee,j=(e,t)=>p(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),M=async e=>{let t=O?.id??null;for(let n of await a.upload(`asset`,e))j(n.id,t)},N=async e=>{await me(Z(`space.removeConfirm`,{name:e.name}))&&(a.remove(e.id),j(e.id,null))},P=f.length?{options:[{value:``,label:Z(`space.assetsGeneral`)},...f.map(e=>({value:e.id,label:e.title||Z(`space.sectionUntitled`)}))],current:e=>f.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>j(e.id,t||null)}:void 0,F=[{label:Z(`space.assetUpload`),icon:(0,$.jsx)(On,{className:`size-4 shrink-0`}),onPick:()=>S.current?.click()},{label:Z(`space.assetFromUrl`),icon:(0,$.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>x(!0)},...f.length<C.logoSections?[{label:Z(`space.assetSectionAdd`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>_(`new`)}]:[]],ie=f.length||T.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[f.length?(0,$.jsx)(V,{value:m,onChange:e=>{h(e),l(``)},label:Z(`space.assets`),options:[{id:``,label:Z(`space.assetsGeneral`)},...f.map(e=>({id:e.id,label:e.title||Z(`space.sectionUntitled`)}))]}):null,O&&!n?(0,$.jsx)(R,{label:Z(`space.assetSectionRename`),onClick:()=>_(`current`),children:(0,$.jsx)(_e,{className:`size-4`})}):null]}),ee.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(Oe,{value:c,onChange:l,placeholder:Z(`space.assetSearch`)})}),(0,$.jsx)(R,{label:Z(o===`list`?`space.viewCards`:`space.viewList`),onClick:s,children:o===`list`?(0,$.jsx)(Xe,{className:`size-4`}):(0,$.jsx)(on,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(k,{title:Z(`space.assets`),hint:Z(`space.assetsHint`),save:w,tabs:ie,action:n?null:(0,$.jsx)(be,{entries:F}),children:[(0,$.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:si,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&M(t)}}),ne.length?o===`cards`?(0,$.jsx)(mr,{spaceId:e,kind:`asset`,files:ne,actions:a,moveTo:P,onRemove:N,onPreview:e=>d(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:ne.map(t=>(0,$.jsx)(ui,{spaceId:e,file:t,actions:a,moveTo:P,onPreview:()=>d(t.id),onRemove:()=>N(t)},t.id))}):ee.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`space.staysLocal`)}):(0,$.jsxs)(re,{accept:si,onFiles:e=>void M(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(De,{className:`size-4`}):(0,$.jsx)(On,{className:`size-4`}),Z(`space.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:Z(`space.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,A?(0,$.jsx)(li,{spaceId:e,file:A,actions:a,onClose:()=>d(null)}):null,g?(0,$.jsx)(di,{section:g===`current`?O:null,onClose:()=>_(null),onSave:e=>{if(g===`current`&&O)p(t=>t.map(t=>t.id===O.id?{...t,title:e}:t));else{let t=G();p(n=>[...n,{id:t,title:e,assets:[]}]),h(t)}},onRemove:g===`current`&&O?async()=>{(!O.assets.length||await me(Z(`space.assetSectionRemoveConfirm`,{name:O.title})))&&(p(e=>e.filter(e=>e.id!==O.id)),h(``),_(null))}:void 0}):null,b?(0,$.jsx)(hr,{kind:`asset`,onClose:()=>x(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)j(t.id,O?.id??null)}}):null]})}var pi=/^#[0-9a-fA-F]{6}$/;async function mi(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 hi={linear:`space.gradientLinear`,radial:`space.gradientRadial`,conic:`space.gradientConic`};function gi({spaceId:e,gradient:t,isNew:n,brand:a,onSave:o,onClose:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(b(t)),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(!n),C=e=>{l(e),d(b(e)),p(!1)},w=(e,t)=>C({...c,stops:c.stops.map((n,r)=>r===e?{...n,...t}:n)}),T=e=>{let t=[...c.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));C({...c,stops:[...c.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},E=async()=>{_(!0),y(null);try{let{gradient:t}=await D.post(`/api/studio/spaces/${e}/gradients/describe`,{text:m.trim(),...x?{gradient:{name:c.name,type:c.type,angle:c.angle,stops:c.stops}}:{}});C({...c,...t,name:c.name.trim()?c.name:t.name}),h(``),S(!0)}catch(e){y(e.message)}_(!1)};return(0,$.jsx)(z,{open:!0,onClose:s,wide:!0,title:Z(n?`space.gradientNew`:`space.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&!g&&E()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{"data-autofocus":n||void 0,value:m,maxLength:1e3,"aria-label":Z(`space.gradientDescribe`),placeholder:Z(x?`space.gradientDescribeChange`:`space.gradientDescribeNew`),onChange:e=>h(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(r,{type:`submit`,variant:`secondary`,busy:g,disabled:!m.trim(),children:[(0,$.jsx)(ee,{className:`size-4`}),Z(x?`space.gradientDescribeApply`:`space.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.8125rem]`,v?`text-rose`:`text-ink-3`),children:v??Z(`space.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:b(c)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.gradientName`)}),(0,$.jsx)(F,{value:c.name,maxLength:80,placeholder:Z(`space.gradientNamePlaceholder`),onChange:e=>l({...c,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.fillUseLabel`)}),(0,$.jsx)(F,{value:c.description??``,maxLength:400,placeholder:Z(`space.gradientUse`),onChange:e=>l({...c,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:i.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":c.type===e,onClick:()=>C({...c,type:e}),className:L(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,c.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:Z(hi[e])},e))})]}),c.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(B,{children:Z(`space.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:c.angle,"aria-label":Z(`space.gradientAngle`),onChange:e=>C({...c,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(c.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(se,{value:pi.test(e.color)?e.color:`#888888`,onChange:e=>w(t,{color:e.target.value})}),(0,$.jsx)(F,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();pi.test(n)&&w(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":Z(`space.gradientAt`),onChange:e=>w(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(R,{label:Z(`space.remove`),disabled:c.stops.length<=2,onClick:()=>C({...c,stops:c.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[c.stops.length<12?(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>T(),children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`space.gradientStopAdd`)]}):null,a.length&&c.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:Z(`space.gradientFromBrand`)}),a.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>T(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:`CSS`}),(0,$.jsx)(F,{value:u,spellCheck:!1,onChange:e=>{d(e.target.value);let t=ne(e.target.value);p(!t),t&&l({...c,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.8125rem]`,f?`text-rose`:`text-ink-3`),children:Z(f?`space.gradientCssError`:`space.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:s,children:Z(`common.cancel`)}),(0,$.jsx)(r,{onClick:()=>{o(c),s()},children:Z(`settings.save`)})]})]})})}var _i=`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`,vi=`size-8 bg-card shadow-soft hover:bg-card`;function yi({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(W,{value:e,label:Z(`space.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(W,{value:n??``,label:Z(`space.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function bi({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=b(e),[o,s]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":Z(`space.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,$.jsxs)(`div`,{className:_i,children:[(0,$.jsx)(R,{label:Z(o?`space.gradientCopied`:`space.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:vi,children:(0,$.jsx)(ze,{className:`size-4`})}),(0,$.jsx)(R,{label:Z(`space.download`),onClick:()=>void mi(e,e.name),className:vi,children:(0,$.jsx)(m,{className:`size-4`})}),t?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:i,className:L(vi,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(yi,{name:e.name,namePlaceholder:Z(`space.gradientName`),description:e.description,usePlaceholder:Z(`space.gradientUse`),readOnly:t,onChange:r})]})}function xi(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function Si({spaceId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=h(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":Z(`space.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:xi(s,t.tile)}),(0,$.jsxs)(`div`,{className:_i,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":Z(`space.download`),title:Z(`space.download`),className:L(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,vi),children:(0,$.jsx)(m,{className:`size-4`})}),r?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:o,className:L(vi,`hover:text-rose`),children:(0,$.jsx)(Y,{className:`size-4`})})]})]}),(0,$.jsx)(yi,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:Z(`space.patternUse`),readOnly:r,onChange:a})]})}function Ci({spaceId:e,pattern:t,isNew:n,fileName:i,busy:a,error:o,upload:s,removeFile:c,onSave:l,onClose:u}){let[d,f]=(0,Q.useState)(t),[p,m]=(0,Q.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(m(e=>[...e,n.id]),f(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of p)c(e);u()};return(0,$.jsx)(z,{open:!0,onClose:_,wide:!0,title:Z(n?`space.patternNew`:`space.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[d.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:xi(h(e,d.file),d.tile),children:(0,$.jsxs)(re,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[a?(0,$.jsx)(De,{className:`size-4`}):(0,$.jsx)(Ie,{className:`size-4`}),Z(`space.patternReplace`)]})}):(0,$.jsxs)(re,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[a?(0,$.jsx)(De,{className:`size-5`}):(0,$.jsx)(Ie,{className:`size-5`}),Z(`space.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.patternName`)}),(0,$.jsx)(F,{value:d.name,maxLength:80,placeholder:d.file?i(d.file):Z(`space.patternNamePlaceholder`),onChange:e=>f({...d,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.fillUseLabel`)}),(0,$.jsx)(F,{value:d.description??``,maxLength:400,placeholder:Z(`space.patternUse`),onChange:e=>f({...d,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.patternShow`)}),(0,$.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,$.jsx)(`button`,{type:`button`,"aria-pressed":!!d.tile===e,onClick:()=>f({...d,tile:e||void 0}),className:L(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!d.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:Z(e?`space.patternTile`:`space.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,$.jsx)(r,{variant:`ghost`,onClick:_,children:Z(`common.cancel`)}),(0,$.jsx)(r,{disabled:!d.file||a,onClick:()=>{for(let e of p.filter(e=>e!==d.file))c(e);t.file&&t.file!==d.file&&c(t.file),l({...d,name:d.name.trim(),description:d.description?.trim()||void 0}),u()},children:Z(n?`space.add`:`settings.save`)})]})]})})}var wi=/^#[0-9a-fA-F]{6}$/;function Ti({spaceId:e,onAdd:t,onClose:n}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{colors:t}=await D.post(`/api/studio/spaces/${e}/colors/scan`,{url:i.trim()});t.length?(d(t),p([])):l(Z(`space.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(z,{open:!0,onClose:n,wide:u?!0:void 0,title:Z(u?`space.colorsFound`:`space.colorsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Z(`space.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:u.map(e=>{let t=f.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>p(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:L(`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,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(He,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:()=>d(null),children:Z(`run.back`)}),(0,$.jsx)(r,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.value))),n()},children:f.length>1?Z(`space.addMany`,{n:f.length}):Z(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.logoUrl`)}),(0,$.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(`space.colorsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:n,children:Z(`common.cancel`)}),(0,$.jsx)(r,{type:`submit`,busy:o,disabled:!i.trim(),children:Z(`run.next`)})]})]})})}function Ei({spaceId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:o,sectioned:c,ruled:l,save:u,readOnly:d}){let[f,p]=(0,Q.useState)(()=>n.map(e=>({...e,id:G()}))),[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(i),[v,b]=(0,Q.useState)(a),[x,S]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),E=H(e,d),D=A(o),[O,ee]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),N=y({colors:f.filter(e=>wi.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:m,gradients:g,patterns:v,colorRules:D.rules},u),P=c?m:[],re=P.filter(e=>(e.kind??`colors`)===`colors`),ae=e=>re.some(t=>t.id===e.section),oe=f.filter(e=>!ae(e)),ce=(oe[0]??f[0])?.id,le=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),I=e=>p(t=>[...t,...e.map(e=>({...e,id:G()}))].slice(0,C.colors)),ue=[{value:``,label:Z(`space.sectionStandard`)},...re.map(e=>({value:e.id,label:e.title||Z(`space.sectionUntitled`)}))],de=(e,t)=>{let n=G();ee(n),h(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},L=e=>({id:G(),name:``,section:e,type:`linear`,angle:90,stops:[{color:f[0]?.value&&wi.test(f[0].value)?f[0].value:`#4b73ff`,at:0},{color:f[1]?.value&&wi.test(f[1].value)?f[1].value:`#ff6d1b`,at:100}]}),pe=e=>t.files.find(t=>t.id===e)?.name??`pattern`,he=[...f.length<C.colors?[{label:Z(`space.colorNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>_e()},{label:Z(`space.colorsFromUrl`),icon:(0,$.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...c&&m.length<C.logoSections?[{label:Z(`space.colorSectionAdd`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>de(`colors`,``)},{label:Z(`space.gradientSectionAdd`),icon:(0,$.jsx)(Kn,{className:`size-4 shrink-0`}),onPick:()=>de(`gradients`,Z(`space.gradientSectionTitle`))},{label:Z(`space.patternSectionAdd`),icon:(0,$.jsx)(Qn,{className:`size-4 shrink-0`}),onPick:()=>de(`patterns`,Z(`space.patternSectionTitle`))}]:[],...!l||D.full?[]:[{label:Z(`space.ruleNew`),icon:(0,$.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>D.add()}]],ge=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(se,{value:wi.test(e.value)?e.value:`#888888`,onChange:t=>le(e.id,{value:t.target.value})}),(0,$.jsx)(F,{value:e.name,autoFocus:e.id===te,placeholder:Z(`space.colorName`),maxLength:120,onChange:t=>le(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(F,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>le(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===ce?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(U,{tone:`ember`,children:Z(`space.colorAccent`)})}):d?null:(0,$.jsx)(R,{label:Z(`space.colorFirst`),onClick:()=>p(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,$.jsx)(Ee,{className:`size-4`})}),d||!re.length?null:(0,$.jsx)(ke,{options:ue,value:ae(e)?e.section??``:``,onChange:t=>le(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),d?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:()=>p(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,$.jsx)(Y,{className:`size-4`})})]})]},e.id),_e=e=>{let t=G();ne(t),p(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(k,{title:Z(`space.colors`),hint:Z(`space.colorsHint`),save:N,locked:d,action:d?null:(0,$.jsx)(be,{entries:he}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[oe.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:oe.map(ge)}),d?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(`space.colorUse`)})]}):f.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`space.colorsEmpty`)}),P.map(t=>{let n=t.kind??`colors`,r=f.filter(e=>e.section===t.id),i=g.filter(e=>e.section===t.id),a=v.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(s,{title:t.title,titlePlaceholder:Z(n===`gradients`?`space.gradientSectionTitlePlaceholder`:n===`patterns`?`space.patternSectionTitlePlaceholder`:`space.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Kn,{}),label:Z(`space.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Qn,{}),label:Z(`space.kindPatterns`)}:{icon:(0,$.jsx)(We,{}),label:Z(`space.kindColors`)},autoFocus:O===t.id,readOnly:d,onChange:e=>h(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:async()=>{if(!o||await me(Z(n===`colors`?`space.colorSectionRemoveConfirm`:`space.fillSectionRemoveConfirm`,{name:t.title||Z(`space.sectionUntitled`)}))){h(e=>e.filter(e=>e.id!==t.id)),p(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),_(e=>e.filter(e=>e.section!==t.id));for(let e of a)E.remove(e.file);b(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(bi,{gradient:e,readOnly:d,onEdit:()=>S(e),onChange:t=>_(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>_(t=>t.filter(t=>t.id!==e.id))},e.id)),d||g.length>=C.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(L(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,$.jsx)(J,{className:`size-5`}),Z(`space.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(Si,{spaceId:e,pattern:t,fileName:pe(t.file),readOnly:d,onEdit:()=>T(t),onChange:e=>b(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{E.remove(t.file),b(e=>e.filter(e=>e.id!==t.id))}},t.id)),d||v.length>=C.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T({id:G(),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,$.jsx)(J,{className:`size-5`}),Z(`space.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ge),d||f.length>=C.colors?null:(0,$.jsx)(fe,{label:Z(`space.colorAdd`),onClick:()=>_e(t.id)})]})]},t.id)}),l?(0,$.jsx)(ie,{rules:D,placeholder:Z(`space.colorRulePlaceholder`),readOnly:d}):null]}),E.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:E.error}):null,x?(0,$.jsx)(gi,{spaceId:e,gradient:x,isNew:!g.some(e=>e.id===x.id),brand:f.filter(e=>wi.test(e.value)),onClose:()=>S(null),onSave:e=>_(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,w?(0,$.jsx)(Ci,{spaceId:e,pattern:w,isNew:!v.some(e=>e.id===w.id),fileName:pe,busy:E.busy,error:E.error,upload:async e=>(await E.upload(`pattern`,[e]))[0]??null,removeFile:e=>void E.remove(e),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,j?(0,$.jsx)(Ti,{spaceId:e,onClose:()=>M(!1),onAdd:I}):null]})}var Di=e=>/^(ja|yes|true)$/i.test(e.trim()),Oi={text:je,longtext:En,number:it,date:$e,url:O,email:Hn,phone:wn,boolean:dt};function ki({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.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 l=Oi[e??t],u=`${Z(`space.factType`)}: ${Z(`space.type.${e??t}`)}`,d=`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`,f=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":u,title:u,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:L(`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,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:L(`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,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:d,onClick:()=>f(void 0),children:[(0,$.jsx)(ue,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:Z(`space.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:Z(`space.type.${t}`)}),(0,$.jsx)(He,{className:L(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),c.map(t=>{let n=Oi[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:d,onClick:()=>f(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:Z(`space.type.${t}`)}),(0,$.jsx)(He,{className:L(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Ai({facts:e,save:t,readOnly:n}){let i=(0,Q.useRef)(0),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${i.current++}`}))),c=y(o.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),l=(e,t)=>s(n=>n.map(n=>n.id===e?{...n,...t}:n)),u=(e,t,n=!1)=>{let r=`f${i.current++}`;a.current=`${r}:${t}`;let o={id:r,key:``,label:``,value:``,...e};s(e=>n?[o,...e]:[...e,o])},p=e=>t=>{t&&a.current===e&&(a.current=null,t.focus())},m=d.filter(e=>!o.some(t=>t.key===e));return(0,$.jsxs)(k,{title:Z(`space.facts`),hint:Z(`space.factsHint`),save:c,locked:n,action:o.length<C.facts&&!n?(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`,!0),children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`space.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>{let t=E(e.value),r=e.type??t;return(0,$.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,$.jsx)(F,{ref:p(`${e.id}:label`),value:e.label,placeholder:Z(`space.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>l(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&l(e.id,{key:f(e.label,o.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(le,{checked:Di(e.value),label:e.label,onChange:t=>l(e.id,{value:Z(t?`space.yes`:`space.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Di(e.value)?Z(`space.yes`):Z(`space.no`)})]}):(0,$.jsx)(xe,{ref:p(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:Z(`space.factValue`),onChange:t=>l(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(ki,{type:e.type,detected:t,onChange:t=>l(e.id,{type:t})}),n?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:()=>s(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),o.length<C.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${o.length?`mt-4`:``}`,children:[(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>u({},`label`),children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`space.factAdd`)]}),m.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u({key:e,label:Z(`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,$.jsx)(J,{className:`size-3.5`}),` `,Z(`fact.${e}`)]},e))]}):null]})}var ji=[{label:`Website`,placeholder:`https://…`},{label:`LinkedIn`,placeholder:`linkedin.com/company/…`},{label:`Instagram`,placeholder:`instagram.com/…`},{label:`Facebook`,placeholder:`facebook.com/…`},{label:`YouTube`,placeholder:`youtube.com/@…`},{label:`TikTok`,placeholder:`tiktok.com/@…`},{label:`X`,placeholder:`x.com/…`}],Mi=e=>e===`Website`?Zt:ji.some(t=>t.label===e)?Wn:O;function Ni({links:e,readOnly:t,save:n}){let[i,a]=(0,Q.useState)(e),o=(0,Q.useRef)(null),s=y(i.map(e=>({...e,label:e.label.trim(),url:e.url.trim()})).filter(e=>e.url),n),c=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=e=>{let t=G();o.current=`${t}:${e?`url`:`label`}`,a(n=>[...n,{id:t,label:e,url:``}])},u=e=>t=>{t&&o.current===e&&(o.current=null,t.focus())},d=ji.filter(e=>!i.some(t=>t.label===e.label)),f=i.length>=C.links,p=[...d.map(e=>{let t=Mi(e.label);return{label:e.label,icon:(0,$.jsx)(t,{className:`size-4 shrink-0`}),onPick:()=>l(e.label)}}),{label:Z(`space.links.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>l(``)}];return(0,$.jsxs)(k,{title:Z(`space.links`),hint:Z(`space.linksHint`),save:s,locked:t,action:t||f?null:(0,$.jsx)(be,{entries:p}),children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>{let n=Mi(e.label);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:grid-cols-[auto_minmax(0,2fr)_minmax(0,3fr)_auto]`,children:[(0,$.jsx)(`span`,{className:`grid size-11 place-items-center text-ink-3`,children:(0,$.jsx)(n,{className:`size-4`})}),(0,$.jsx)(F,{ref:u(`${e.id}:label`),value:e.label,maxLength:80,readOnly:t,placeholder:Z(`space.links.label`),onChange:t=>c(e.id,{label:t.target.value}),className:`max-sm:col-span-1 max-sm:font-medium`}),(0,$.jsx)(F,{ref:u(`${e.id}:url`),value:e.url,maxLength:600,readOnly:t,inputMode:`url`,placeholder:ji.find(t=>t.label===e.label)?.placeholder??`https://…`,onChange:t=>c(e.id,{url:t.target.value}),className:`max-sm:col-span-2 max-sm:col-start-2 max-sm:row-start-2`}),t?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose max-sm:col-start-3 max-sm:row-start-1`,children:(0,$.jsx)(Y,{className:`size-4`})})]},e.id)})}),t||f?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${i.length?`mt-4`:``}`,children:[(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>l(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`space.links.own`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(e.label),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,$.jsx)(J,{className:`size-3.5`}),` `,e.label]},e.label))]})]})}function Pi({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.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(pr);i(!1),n&&(t.preventDefault(),e(n))},className:L(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function Fi({spaceId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:o,save:c}){let l=H(e,n),[u,d]=(0,Q.useState)(r),f=A(i),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(null),v=y({logoSections:u,logoRules:f.rules},c),b=t.files.filter(e=>e.kind===`logo`),x=new Map(b.map(e=>[e.id,e])),S=a?u:[],w=new Set(S.flatMap(e=>e.logos)),T=b.filter(e=>!w.has(e.id)),E=K(b,u)?.id,D=(e,t)=>d(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),O=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,...t}:n)),ee=async(e,t)=>{let n=await l.upload(`logo`,e);for(let e of n)D(e.id,t)},te=S.length?{options:[{value:``,label:Z(`space.sectionStandard`)},...S.map(e=>({value:e.id,label:e.title||Z(`space.sectionUntitled`)}))],current:e=>S.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>D(e.id,t||null)}:void 0,ne=(t,n,r)=>(0,$.jsx)(mr,{spaceId:e,kind:`logo`,files:t,actions:l,accept:`image/*`,addLabel:r?Z(`space.logoAdd`):void 0,onUpload:e=>void ee(e,n),mainId:E,onMakeMain:e=>{D(e.id,null),l.order(`logo`,[e.id,...b.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:te,onRemove:async e=>{await me(Z(`space.removeConfirm`,{name:e.name}))&&(l.remove(e.id),D(e.id,null))}}),j=n?void 0:e=>t=>D(t,e),M=[{label:Z(`space.logoUpload`),icon:(0,$.jsx)(On,{className:`size-4 shrink-0`}),onPick:()=>_.current?.click()},{label:Z(`space.logoFromUrl`),icon:(0,$.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>g(!0)},...a&&u.length<C.logoSections?[{label:Z(`space.logoSectionAdd`),icon:(0,$.jsx)(Ye,{className:`size-4 shrink-0`}),onPick:()=>{let e=G();m(e),d(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!o||f.full?[]:[{label:Z(`space.ruleNew`),icon:(0,$.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(k,{title:Z(`space.logos`),hint:Z(`space.logosHint`),save:v,action:n?null:(0,$.jsx)(be,{entries:M}),children:[(0,$.jsx)(`input`,{ref:_,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&&ee(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(Pi,{onLogo:j?.(null),children:ne(T,null,!0)}),S.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Pi,{onLogo:j?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(s,{title:e.title,description:e.description,titlePlaceholder:Z(`space.logoSectionTitle`),descriptionPlaceholder:Z(`space.logoSectionUse`),autoFocus:p===e.id,readOnly:n,onChange:t=>O(e.id,t),onRemove:async()=>{(!e.logos.length||await me(Z(`space.logoSectionRemoveConfirm`,{name:e.title||Z(`space.sectionUntitled`)})))&&d(t=>t.filter(t=>t.id!==e.id))}}),ne(e.logos.map(e=>x.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),o?(0,$.jsx)(ie,{rules:f,placeholder:Z(`space.logoRulePlaceholder`),readOnly:n}):null]}),l.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:l.error}):null,h?(0,$.jsx)(hr,{kind:`logo`,onClose:()=>g(!1),fetchUrl:e=>l.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)D(t.id,null)}}):null]})}var Ii=e=>URL.canParse(e)?new URL(e).host:e;async function Li(e,t){let n=_({family:t,source:{url:e}});if(!n)return`down`;if(n.stylesheet)return await Ri(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 Ri(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 zi(e,t){let n=e.source;if(!n)return Z(`space.fontSourceNone`);if(`file`in n){let e=t.find(e=>e.id===n.file)?.name??``;return Z(`space.fontSourceFile`,{name:e})}return Z(`space.fontSourceUrl`,{host:Ii(n.url)})}function Bi({spaceId:e,font:t,onSave:n,onClose:i}){let a=(N(e).data?.files??[]).filter(e=>e.mime.startsWith(`font/`)),o=H(e),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(t.source&&`url`in t.source?`url`:`file`),[u,d]=(0,Q.useState)(t.source&&`file`in t.source?t.source.file:``),[f,p]=(0,Q.useState)(t.source&&`url`in t.source?t.source.url:``),[m,h]=(0,Q.useState)(t.source&&`url`in t.source?{url:t.source.url,result:`ok`}:null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(t.license??``),[b,x]=(0,Q.useState)(!1),S=f.trim(),C=async()=>{_(!0),h({url:S,result:await Li(S,t.family.trim())}),_(!1)},w=c===`file`?u?{file:u}:null:m?.url===S&&m.result===`ok`?{url:S}:null,T=m?.url===S?m.result:null;return(0,$.jsx)(z,{open:!0,onClose:i,title:Z(`space.fontSourceTitle`,{family:t.family}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Z(`space.fontSourceHint`)}),(0,$.jsx)(ae,{value:c,options:[`file`,`url`],label:e=>Z(`space.fontSourceKind.${e}`),onChange:e=>l(e)}),c===`file`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.fontSourceFiles`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>d(e.id),className:L(`rounded-lg px-3 py-2 text-left text-[0.875rem] ring-1 transition`,u===e.id?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:e.name},e.id))}),(0,$.jsx)(`input`,{ref:s,type:`file`,accept:`.woff2,.woff,.ttf,.otf`,className:`hidden`,onChange:async e=>{let t=[...e.target.files??[]];e.target.value=``;let[n]=await o.upload(`asset`,t);n&&d(n.id)}}),(0,$.jsxs)(r,{variant:`ghost`,className:`mt-2`,busy:o.busy,onClick:()=>s.current?.click(),children:[(0,$.jsx)(On,{className:`size-4`}),Z(`space.fontSourceUpload`)]}),o.error?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-rose`,children:o.error}):null]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),C()},children:[(0,$.jsx)(B,{children:Z(`space.fontSourceUrlLabel`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{value:f,inputMode:`url`,placeholder:Z(`space.fontSourceUrlPlaceholder`),onChange:e=>p(e.target.value)}),(0,$.jsx)(r,{type:`submit`,variant:`ghost`,busy:g,disabled:!S.startsWith(`https://`),children:Z(`space.fontSourceCheck`)})]}),T?(0,$.jsx)(`p`,{className:L(`mt-1.5 text-[0.875rem]`,T===`ok`?`text-ink-3`:`text-rose`),children:Z(`space.fontCheck.${T}`,{host:Ii(S),family:t.family})}):null,T===`ok`?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.875rem] text-ink-3`,children:Z(`space.fontPrivacy`,{host:Ii(S)})}):null]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{hint:Z(`space.fontLicenseHint`),children:Z(`space.fontLicense`)}),(0,$.jsx)(F,{value:v,maxLength:200,placeholder:Z(`space.fontLicensePlaceholder`),onChange:e=>y(e.target.value)}),(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-[0.875rem]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-ember`,checked:b,onChange:e=>x(e.target.checked)}),Z(`space.fontLicenseConfirm`,{family:t.family})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[t.source?(0,$.jsx)(r,{variant:`ghost`,className:`mr-auto`,onClick:()=>{n({source:void 0,license:t.license}),i()},children:Z(`space.fontSourceRemove`)}):null,(0,$.jsx)(r,{variant:`ghost`,onClick:i,children:Z(`common.cancel`)}),(0,$.jsx)(r,{disabled:!(w&&b),onClick:()=>{w&&(n({source:w,license:v.trim()||void 0}),i())},children:Z(`space.fontSourceSave`)})]})]})})}var Vi=new Set;function Hi(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Vi.has(t))return;Vi.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${ge.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Ui=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Wi({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.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 Gi=`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`,Ki={web:`space.fontUseWeb`,documents:`space.fontUseDocuments`,print:`space.fontUsePrint`,images:`space.fontUseImages`,video:`space.fontUseVideo`};function qi({spaceId:e,font:t,first:n,readOnly:r,autoFocus:i,onChange:a,onRemove:o}){Hi(t.family);let s=N(e).data?.files??[],[c,l]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.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:Ui(t.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:t.family}),t.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:t.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(W,{value:t.family,label:Z(`space.fontFamily`),placeholder:Z(`space.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(W,{value:t.role,label:Z(`space.fontRole`),placeholder:Z(n?`space.fontRoleFirst`:`space.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ge.map(e=>{let n=t.weights.includes(e);return(0,$.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:Ui(t.family),fontWeight:e},className:L(`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,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[r?t.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:t.license}):null:(0,$.jsx)(W,{value:t.license??``,label:Z(`space.fontLicense`),placeholder:Z(`space.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),r&&!t.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:Z(`space.fontUses`)}),T.map(e=>{let n=!!t.uses?.includes(e);return(0,$.jsxs)(`button`,{type:`button`,disabled:r,"aria-pressed":n,onClick:()=>{let r=n?(t.uses??[]).filter(t=>t!==e):T.filter(n=>n===e||t.uses?.includes(n));a({uses:r.length?r:void 0})},className:L(`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,$.jsx)(He,{className:`size-3.5`}):null,Z(Ki[e])]},e)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[0.8125rem] text-ink-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:zi(t,s)}),r||!t.family.trim()?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-ink underline decoration-border underline-offset-2 hover:decoration-ink`,children:Z(t.source?`space.fontSourceChange`:`space.fontSourceSet`)})]}),c?(0,$.jsx)(Bi,{spaceId:e,font:t,onSave:a,onClose:()=>l(!1)}):null,r?null:(0,$.jsx)(R,{label:Z(`space.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,$.jsx)(Y,{className:`size-4`})})]})}function Ji({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:Ui(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,$.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,$.jsx)(`div`,{className:`truncate text-ink`,style:c,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(W,{value:e.name,label:Z(`space.styleName`),placeholder:Z(`space.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":Z(`space.styleFont`),value:s?.id??``,onChange:e=>a({font:e.target.value}),className:L(Gi,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||Z(`space.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":Z(`space.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:Gi,children:[...new Set([...ge,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Wi,{unit:`px`,label:Z(`space.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(Wi,{unit:Z(`space.styleLine`),label:Z(`space.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Wi,{unit:Z(`space.styleTracking`),label:Z(`space.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:Z(`space.styleUpper`),"aria-label":Z(`space.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:L(`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,$.jsx)(Xn,{className:`size-4`})})]}),r?null:(0,$.jsx)(R,{label:Z(`space.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,$.jsx)(Y,{className:`size-4`})})]})]})}function Yi({spaceId:e,onAdd:t,onClose:n}){let[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{fonts:t}=await D.post(`/api/studio/spaces/${e}/fonts/scan`,{url:i.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(Z(`space.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(z,{open:!0,onClose:n,wide:u?!0:void 0,title:Z(u?`space.fontsFound`:`space.fontsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:Z(`space.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(Xi,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:()=>d(null),children:Z(`run.back`)}),(0,$.jsx)(r,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?Z(`space.addMany`,{n:f.length}):Z(`space.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.logoUrl`)}),(0,$.jsx)(F,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(`space.fontsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:n,children:Z(`common.cancel`)}),(0,$.jsx)(r,{type:`submit`,busy:o,disabled:!i.trim(),children:Z(`run.next`)})]})]})})}function Xi({font:e,on:t,onToggle:n}){return Hi(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:L(`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,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:Ui(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):Z(`space.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(He,{className:`size-3.5`})}):null]})}function Zi({spaceId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:o,readOnly:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=A(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=y({fonts:c,textStyles:u,typeRules:f.rules},o),v=(e,t=!1)=>{let n=e.map(e=>({id:G(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,C.fonts))},b=()=>{let e=G();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...c.length<C.fonts?[{label:Z(`space.fontNew`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:Z(`space.fontsFromUrl`),icon:(0,$.jsx)(an,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<C.textStyles?[{label:Z(`space.styleNew`),icon:(0,$.jsx)(Ke,{className:`size-4 shrink-0`}),onPick:b}]:[],...!i||f.full?[]:[{label:Z(`space.ruleNew`),icon:(0,$.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(k,{title:Z(`space.typography`),hint:Z(`space.typographyHint`),save:_,action:s?null:(0,$.jsx)(be,{entries:x}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((t,n)=>(0,$.jsx)(qi,{spaceId:e,font:t,first:n===0,readOnly:s,autoFocus:p===t.id,onChange:e=>l(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>l(e=>e.filter(e=>e.id!==t.id))},t.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:Z(`space.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:Z(`space.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:Z(`space.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(Ji,{style:e,fonts:c,sample:a,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(ie,{rules:f,placeholder:Z(`space.typeRulePlaceholder`),readOnly:s}):null]}),h?(0,$.jsx)(Yi,{spaceId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}var Qi=[{title:`space.voice.tone`,hint:`space.voice.toneHint`},{title:`space.voice.audience`,hint:`space.voice.audienceHint`},{title:`space.voice.positioning`,hint:`space.voice.positioningHint`},{title:`space.voice.values`,hint:`space.voice.valuesHint`}];function $i({blocks:e,rules:t,ruled:n,readOnly:i,save:a}){let[o,s]=(0,Q.useState)(e),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),f=A(t),p=y({voice:o,voiceRules:f.rules},a),m=(e,t)=>s(n=>n.map(n=>n.id===e?{...n,...t}:n)),h=o.length>=C.voiceBlocks,g=e=>{let t=G();(e?d:l)(t),s(n=>[...n,{id:t,title:e,text:``}])},_=Qi.filter(e=>!o.some(t=>t.title===Z(e.title))),v=e=>Qi.find(t=>Z(t.title)===e)?.hint,b=[...h?[]:[..._.map(e=>({label:Z(e.title),icon:(0,$.jsx)(Gt,{className:`size-4 shrink-0`}),onPick:()=>g(Z(e.title))})),{label:Z(`space.voice.own`),icon:(0,$.jsx)(J,{className:`size-4 shrink-0`}),onPick:()=>g(``)}],...!n||f.full?[]:[{label:Z(`space.ruleNew`),icon:(0,$.jsx)(rn,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsx)(k,{title:Z(`space.voice`),hint:Z(`space.voiceHint`),save:p,locked:i,action:i||!b.length?null:(0,$.jsx)(be,{entries:b}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[o.length?(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:o.map(e=>{let t=v(e.title);return(0,$.jsxs)(`div`,{className:`group/row grid gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[i?(0,$.jsx)(`p`,{className:`min-w-0 flex-1 font-medium text-[0.9375rem]`,children:e.title}):(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(W,{value:e.title,label:Z(`space.voice.title`),placeholder:Z(`space.voice.title`),maxLength:80,autoFocus:c===e.id,onChange:t=>m(e.id,{title:t}),className:`font-medium text-[0.9375rem]`})}),i?null:(0,$.jsx)(R,{label:Z(`space.remove`),onClick:async()=>{(!e.text.trim()||await me(Z(`space.voice.removeConfirm`,{name:e.title||Z(`space.sectionUntitled`)})))&&s(t=>t.filter(t=>t.id!==e.id))},className:`-mt-1 size-8 shrink-0 rounded-lg opacity-0 transition hover:text-rose focus-visible:opacity-100 group-hover/row:opacity-100 max-sm:opacity-100`,children:(0,$.jsx)(Y,{className:`size-4`})})]}),i?(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[0.9375rem] text-ink-2 leading-relaxed sm:pt-2`,children:e.text}):(0,$.jsx)(xe,{ref:t=>{t&&u===e.id&&(d(null),t.focus())},rows:2,minRows:2,maxRows:14,maxLength:C.voiceText,value:e.text,placeholder:Z(t||`space.voice.textPlaceholder`),onChange:t=>m(e.id,{text:t.target.value})})]},e.id)})}):null,i||h?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>g(``),children:[(0,$.jsx)(J,{className:`size-4`}),` `,Z(`space.voice.own`)]}),_.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g(Z(e.title)),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,$.jsx)(J,{className:`size-3.5`}),` `,Z(e.title)]},e.title))]}),n?(0,$.jsx)(ie,{rules:f,placeholder:Z(`space.voice.rulePlaceholder`),readOnly:i}):null]})})}function ea({spaceId:e,logo:t}){let n=Z(t?`space.logoPeek`:`space.logoPeekAdd`);return(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(B,{children:Z(`space.logo`)}),(0,$.jsx)(Ce,{to:{pathname:`/space/brand`,hash:`logos`},title:n,"aria-label":n,className:L(`grid size-[4.5rem] place-items-center overflow-hidden rounded-xl transition`,t?`bg-card ring-1 ring-border-soft hover:ring-border`:`text-ink-4 ring-1 ring-border ring-dashed hover:text-ink-2`),children:t?(0,$.jsx)(dr,{spaceId:e,file:t,small:!0}):(0,$.jsx)(q,{className:`size-5`})})]})}function ta({space:e,save:t}){let n=Sn().data,r=bn(),i=Mt(`capabilities`)&&r&&n?.mode===`managed`,[a,o]=(0,Q.useState)(e.membersStudio);return i?(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-border-soft border-t pt-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:Z(`space.membersStudio`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:Z(`space.membersStudioHint`)})]}),(0,$.jsx)(le,{checked:a,disabled:e.readOnly,label:Z(`space.membersStudio`),onChange:e=>{o(e),t({membersStudio:e}).catch(()=>o(!e))}})]}):null}function na({space:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.brandName??``),[i,a]=(0,Q.useState)(e.brand.tagline??``),o=y({brandName:n.trim(),tagline:i.trim()},e=>t({brand:e}));return(0,$.jsx)(k,{title:Z(`space.identity`),hint:Z(`space.identityHint`),save:o,locked:e.readOnly,children:(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[{id:`brand-name`,label:Z(`space.brandName`),hint:Z(`space.brandNameHint`),field:(0,$.jsx)(F,{id:`brand-name`,value:n,maxLength:120,placeholder:e.brand.name??``,onChange:e=>r(e.target.value)})},{id:`brand-tagline`,label:Z(`space.tagline`),hint:Z(`space.taglineHint`),field:(0,$.jsx)(F,{id:`brand-tagline`,value:i,maxLength:200,onChange:e=>a(e.target.value)})}].map(e=>(0,$.jsxs)(`div`,{className:`grid items-start gap-x-6 gap-y-2 py-4 first:pt-0 last:pb-0 sm:grid-cols-[15rem_minmax(0,1fr)]`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:e.id,className:`font-medium text-[0.9375rem]`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.hint})]}),e.field]},e.id))})})}function ra({space:e,logo:t,save:n}){let[r,i]=(0,Q.useState)(e.brand.name??``),[a,o]=(0,Q.useState)(e.brand.about??``),s=y({name:r.trim(),about:a.trim()},e=>n({brand:e}));return(0,$.jsx)(k,{title:Z(`space.base`),hint:Z(`space.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(B,{children:Z(`space.title`)}),(0,$.jsx)(F,{value:r,maxLength:120,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(`space.titleHint`)})]}),(0,$.jsx)(ea,{spaceId:e.id,logo:t})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{children:Z(`space.about`)}),(0,$.jsx)(xe,{minRows:4,value:a,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:Z(`space.aboutHint`)})]}),(0,$.jsx)(ta,{space:e,save:n})]})})}function ia({space:e,group:t,top:n=!1,children:i}){let a=j(),o=N(e.id),[s,c]=(0,Q.useState)(0),[l,u]=(0,Q.useState)(!1),d=async t=>{await D.patch(`/api/studio/spaces/${e.id}`,t),await a.invalidateQueries({queryKey:M.spaces()})},f=Pe({mutationFn:()=>D.del(`/api/studio/spaces/${e.id}`),onSuccess:()=>a.invalidateQueries({queryKey:M.spaces()})}),p=xn(),m=bn(),h=o.data??{files:[],embeddings:!0},g=`${e.id}:${s}`,_=e.readOnly,v=t===`knowledge`,y=Mt(`brandSections`),b=Mt(`brandRules`),x=Mt(`typography`);return kt(_?{}:{title:Z(v?`space.assistantTitleKnowledge`:`space.assistantTitle`),hello:Z(v?`space.assistantHelloKnowledge`:`space.assistantHello`),about:Z(v?`space.assistantAboutKnowledge`:`space.assistantAbout`),placeholder:Z(v?`space.assistantComposerKnowledge`:`space.assistantComposer`),suggestions:v?[{label:Z(`assistant.suggest.knowledgeHow`)},{label:Z(`assistant.suggest.knowledgeSite`),fill:!0},{label:Z(`assistant.suggest.knowledgeCategories`)}]:[{label:Z(`assistant.suggest.readSite`),fill:!0},{label:Z(`assistant.suggest.missing`)},...t===`info`?[{label:Z(`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:()=>c(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[_?(0,$.jsx)(Dn,{children:Tn(e)}):n?(0,$.jsx)(Ze,{}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{id:`base`,children:(0,$.jsx)(ra,{space:e,logo:K(h.files.filter(e=>e.kind===`logo`),e.brand.logoSections),save:d},`base:${g}`)}),(0,$.jsx)(I,{id:`facts`,children:(0,$.jsx)(Ai,{facts:e.facts,save:e=>d({facts:e}),readOnly:_},`facts:${g}`)}),(0,$.jsx)(I,{id:`links`,children:(0,$.jsx)(Ni,{links:e.brand.links??[],save:e=>d({brand:{links:e}}),readOnly:_},`links:${g}`)})]}):null,t===`brand`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{id:`identity`,children:(0,$.jsx)(na,{space:e,save:d},`identity:${g}`)}),(0,$.jsx)(I,{id:`logos`,children:(0,$.jsx)(Fi,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:y,ruled:b,save:e=>d({brand:e})},`logos:${g}`)}),(0,$.jsx)(I,{id:`colors`,children:(0,$.jsx)(Ei,{spaceId: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=>d({brand:e}),readOnly:_},`colors:${g}`)}),x?(0,$.jsx)(I,{id:`typography`,children:(0,$.jsx)(Zi,{spaceId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:b,sample:e.brand.name||Z(`space.typeSample`),save:e=>d({brand:e}),readOnly:_},`typography:${g}`)}):null,(0,$.jsx)(I,{id:`assets`,children:(0,$.jsx)(fi,{spaceId:e.id,data:h,readOnly:_,sections:e.brand.assetSections??[],save:e=>d({brand:e})},`assets:${g}`)}),(0,$.jsx)(I,{id:`voice`,children:(0,$.jsx)($i,{blocks:e.brand.voice??[],rules:e.brand.voiceRules??[],ruled:b,save:e=>d({brand:e}),readOnly:_},`voice:${g}`)})]}):null,i,t===`info`&&p&&!_&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(r,{variant:`danger`,onClick:()=>u(!0),children:Z(`settings.delete`)}),(0,$.jsxs)(z,{open:l,onClose:()=>u(!1),title:Z(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:Z(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(r,{variant:`ghost`,onClick:()=>u(!1),children:Z(`common.cancel`)}),(0,$.jsx)(r,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:Z(`common.delete`)})]})]})]}):null]})}var aa=/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function oa(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=jt(),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 sa(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=jt(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function ca(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function la({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Bn,{icon:e.icon??Ne,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Ln,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},e.plugin??`own`)})}var ua=(0,Q.lazy)(()=>Fe(()=>import(`./SkillEditor-DT5hQwbg.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([10,1,2,3,4,5,6,11,12,13,14,15,16,17,7,8,9])));function da({place:e}){let{group:t}=pe(),[n,r]=oe(),i=Se(),a=we(),{hash:o}=a,{space:s,loading:c}=Cn(),l=lt(),u=Nn(),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),_=e??(Ft(t)&&t!==`skills`?t:void 0),v=_?void 0:l.spaceParts.find(e=>e.id===t),y=_??v?.id,b=a.state?.parts===!0,x=Mt(`pages`),S=Mt(`skills`),C=bn(),w=Mt(`clientSpaces`)&&C,T=Mt(`knowledgeTree`),E=Sn().data?.mode===`local`,D=Mt(`dateien`)&&(E||l.mountKinds.length>0),O=pt().filter(e=>(x||e.id!==`page`)&&(w||e.id!==`clients`)&&(D||e.id!==`files`)),ee=Vt(O,l).map(e=>({...e,to:`/space/${e.id}`})),A=ee,ne={id:`results`,label:Z(`space.results`),icon:Je,to:`/space/results`},j={id:`skills`,label:Z(`space.skills`),icon:$t,to:`/skills`},M=_===`results`||_===`skills`,N=_===`results`?ne:_===`skills`?j:A.find(e=>e.id===y),P=n.get(`show`),[re,F]=(0,Q.useState)(``),ie=(0,Q.useRef)(null),ae=re.trim().toLowerCase(),se=(0,Q.useMemo)(()=>({slot:d,narrow:u,setDetail:m,filter:ae}),[d,u,ae]),ce=s?s.brand.name?.trim()||s.name:Z(`nav.space`),le=Mt(`typography`)?[]:[`typography`],ue=v?l.spaceMenus[v.id]??[]:[],de=v?[{plugin:null,label:null,sections:ue}]:_&&_!==`results`?St(_,l,le):[],fe=_?St(_,l).filter(e=>e.plugin):[],me=oa([...de,..._===`results`?fe:[]].flatMap(e=>e.sections.map(e=>e.id))),R=(0,Q.useRef)(null),[he,ge]=ha(),_e=_===`results`&&P&&P!==`all`?P:null,[ve,be]=(0,Q.useState)(ti),xe=ni(_===`results`?s?.id:void 0,_e,ve),z=xe.data?.wizards.find(e=>e.id===_e)?.title,[B,Ce]=(P??``).split(`#`),V=_===`data`&&B&&B!==`all`||_===`knowledge`&&B&&/^[ptfcvsq]:/.test(B)?B:null,H=V?.startsWith(`s:`)?l.spaceSections.find(e=>e.id===V.slice(2)):void 0,U=_===`knowledge`&&V&&/^[ptf]:/.test(V)?V:null,Ee=_===`skills`&&P?.startsWith(`k:`)?P:null,De=Xt(_===`skills`&&S?s?.id:void 0),W=cn(_===`data`?s?.id:void 0),G=ht(_===`knowledge`?s?.id:void 0),Oe=Ue(_===`knowledge`&&T?s?.id:void 0),[ke,Ae]=(0,Q.useState)(null);_t.clear(),ct.clear();for(let e of Oe.sources)e.folderId&&(_t.set(e.folderId,Oe.iconOf(e)),ct.set(e.folderId,e.id));let K=rt(V?.startsWith(`v:`)?V.slice(2):``),q=G.data?.items.find(e=>e.key===U),[je,Me]=(0,Q.useState)(null),[Ne,Pe]=(0,Q.useState)(null),[Fe,Ie]=(0,Q.useState)(void 0),Le=qt(s?.id),Re=G.data?.categories.find(e=>e.id===(V?.startsWith(`c:`)?V.slice(2):K.data?.category.id)),[J,ze]=(0,Q.useState)(`folders`),[Be,Y]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{V&&/^[cv]:/.test(V)?ze(`categories`):V&&/^[ptf]:/.test(V)&&ze(`folders`)},[V]);let Ve=fe.length>0||_===`files`||_===`knowledge`&&!!(G.data?.categories.length||T&&G.data?.items.length)||_===`data`&&!!(W.data&&gn(W.data).some(e=>e.items.length)),He=!!_&&!M&&(_!==`data`&&_!==`knowledge`&&_!==`files`||!Ve),We=_===`results`?2:y?P||He?2:1:P===`overview`?2:0,Ke=M?1:u?Math.min(We,1):y&&!He&&h!==y&&!b?1:0,Ye=In(Ke),Ze=In(We);(0,Q.useEffect)(()=>{g(null),F(``)},[y]),(0,Q.useEffect)(()=>{if(u||Ke!==1)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`f`&&ie.current&&(e.preventDefault(),ie.current.focus(),ie.current.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,Ke]);let $e=_===`skills`?De.data?.skills.find(e=>`k:${e.id}`===Ee)?.name:_===`knowledge`?H?H.label():V?.startsWith(`v:`)?K.data&&`${K.data.category.name}: ${K.data.value}`:V?.startsWith(`c:`)?Re?.name:G.data?.items.find(e=>e.key===V)?.title:W.data?gn(W.data).flatMap(e=>e.items).find(e=>e.key===V)?.title:void 0;wt([...M?[]:[{label:Z(`nav.sources`),to:`/space`}],...y?[]:[{label:Z(`space.overview`)}],...N?[{label:N.label,to:N.to}]:[],...T&&q&&G.data?yt(G.data.items,q).map(e=>({label:e.title,to:`/space/knowledge?show=${e.key}`})):[],...N&&(p??z??$e)?[{label:p??z??$e}]:[]]);let tt={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};kt({..._===`data`||_===`results`?{compact:!0}:{},..._===`data`?{suggestions:[{label:Z(`assistant.suggest.dataWhat`)},{label:Z(`assistant.suggest.dataWho`)},{label:Z(`assistant.suggest.dataEdit`)}]}:_===`results`?{suggestions:[{label:Z(`assistant.suggest.resultsFailed`)},{label:Z(`assistant.suggest.resultsCost`)},{label:Z(`assistant.suggest.resultsShare`)}]}:{},...V&&$e?{open:{kind:tt[V[0]]??`item`,id:V.slice(2),label:$e}}:_e&&z?{open:{kind:`wizard`,id:_e,label:z}}:{}});let it=_===`results`||_===`data`||V?o.slice(1):P||o.slice(1),st=(0,Q.useRef)(``);(0,Q.useEffect)(()=>{let e=`${y}#${it}`;it&&st.current!==e&&document.getElementById(it)&&(st.current=e,requestAnimationFrame(()=>ca(it,!1)))},[y,it,s?.id,l.spaceSections,ue.length]),(0,Q.useEffect)(()=>{!u&&(y===`knowledge`||y===`data`||y===`skills`)&&jt().scrollTo({top:0})},[u,y,V,Ee]);let ut=sa();if(t===`skills`)return(0,$.jsx)(ye,{to:{pathname:`/skills`,search:a.search,hash:o},replace:!0});if(!y){let e=o.slice(1),n=e?Ot(e,l):null;if(n===`knowledge`&&l.spaceSections.some(t=>t.id===e))return(0,$.jsx)(ye,{to:`/space/knowledge?show=s:${e}`,replace:!0});if(n)return(0,$.jsx)(ye,{to:u?`/space/${n}?show=${e}`:{pathname:`/space/${n}`,hash:e},replace:!0});if((e||t)&&l.status!==`ready`)return null;if(t!==void 0)return(0,$.jsx)(ye,{to:`/space`,replace:!0})}let dt=_===`info`?P??o.slice(1):``;if(dt&&Ot(dt,l)===`brand`)return(0,$.jsx)(ye,{to:u?`/space/brand?show=${dt}`:{pathname:`/space/brand`,hash:dt},replace:!0});if(_===`skills`&&!S)return(0,$.jsx)(ye,{to:`/`,replace:!0});if(_===`knowledge`&&!P&&l.spaceSections.some(e=>e.id===o.slice(1)))return(0,$.jsx)(ye,{to:`/space/knowledge?show=s:${o.slice(1)}`,replace:!0});let mt=e=>{if(u){i({search:`?show=${e}`});return}st.current=`${y}#${e}`,ca(e,!0),i({search:``,hash:e},{replace:!0})},X=e=>{e!==P&&(u?r({show:e}):r(e===`all`?{}:{show:e},{replace:_!==`knowledge`}))},vt=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(I,{id:e.id,children:(0,$.jsx)(k,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Rt,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),xt=e=>e.flatMap(e=>e.sections).map(e=>l.spaceSections.find(t=>t.id===e.id)).map(e=>e?.status?(0,$.jsx)(Rt,{of:e,children:(0,$.jsx)(e.status,{})},e.serial):null),It=u?void 0:me,zt=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{title:ce,open:Ke===1?N??null:null,onBack:M?void 0:()=>u?i(`/space`):g(y??null),root:{icon:et,label:Z(`nav.sources`),onOpen:()=>i(u?`/space?show=overview`:`/space`),current:!y}}),u||M?(0,$.jsx)(`div`,{className:L(Vn(Ye)),children:Ke===0?(0,$.jsx)(jn,{entries:A,current:void 0,onPick:()=>g(null)}):(0,$.jsx)(`div`,{ref:f})},Ke):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jn,{entries:A,current:Ke===0?N:void 0,hide:Ke===1?N?.id:void 0,onPick:()=>{g(null),He&&N&&(i(N.to),jt().scrollTo({top:0,behavior:`smooth`}))}}),Ke===1?(0,$.jsxs)(`div`,{className:`fade-in-0 slide-in-from-top-1 animate-in duration-200`,children:[(0,$.jsx)(`div`,{className:`mx-2 my-3 h-px bg-border-soft`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(te,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,$.jsx)(`input`,{ref:ie,type:`search`,value:re,onChange:e=>F(e.target.value),onKeyDown:e=>e.key===`Escape`&&F(``),"aria-label":Z(`space.menuSearch`),placeholder:Z(`space.menuSearch`),className:`h-8 w-full rounded-lg border border-input bg-card pr-14 pl-9 text-[0.8125rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),(0,$.jsx)(`kbd`,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 rounded border border-border-soft px-1 font-sans text-[0.6875rem] text-ink-4`,children:aa?`⌘F`:`Ctrl F`})]}),(0,$.jsx)(`div`,{ref:f})]},y):null]})]});return(0,$.jsx)(Mn.Provider,{value:se,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{ref:R,className:L(`grid gap-6`,_!==`results`&&`md:grid-cols-[var(--menu-w,10.5rem)_minmax(0,1fr)] md:gap-5 lg:grid-cols-[var(--menu-w,15rem)_minmax(0,1fr)] lg:gap-10`),style:he?{"--menu-w":`${he}px`}:void 0,children:[_===`results`?null:(0,$.jsxs)(`div`,{className:`relative min-w-0`,style:!u&&ut?{minHeight:ut-48}:void 0,children:[(0,$.jsx)(`aside`,{className:L(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,u&&We===2&&`hidden`,u&&Ze===`back`&&Vn(`back`)),style:!u&&ut?{maxHeight:ut-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:zt}),u?null:(0,$.jsx)(ga,{grid:R,onWidth:ge})]}),y?(0,$.jsxs)(`div`,{className:L(`min-w-0`,u&&We<2&&`hidden`,u&&Ze===`deeper`&&Vn(`deeper`)),children:[u&&_!==`results`?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(zn,{label:N?.label??ce,onBack:()=>i(N?.to??`/space/${y}`)})}):null,_===`data`?(0,$.jsxs)(Fn,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Bn,{icon:Xe,label:Z(`data.all`),selected:!u&&!V,onPick:()=>X(`all`)})}),W.data?gn(W.data).map(e=>(0,$.jsx)(Ln,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Bn,{icon:sn[e.kind],label:e.title,selected:!u&&e.key===V,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(la,{groups:fe,current:It,onPick:mt})]}):_===`knowledge`?(0,$.jsxs)(Fn,{children:[T&&G.data?(0,$.jsx)(wr,{tab:J,onTab:ze}):null,T&&G.data&&J===`categories`?(0,$.jsx)(Tr,{categories:G.data.categories,picked:u?null:V,pickedCategory:K.data?.category.id??null,readOnly:!!s?.readOnly,onPick:X,onNew:()=>Y(!0)}):T&&G.data?(0,$.jsx)(Nt,{spaceId:s.id,items:G.data.items,picked:u?null:U,all:!(u||V),readOnly:!!s?.readOnly,onPick:X,onMove:Le,onNewFolder:Ie,onMoveTo:Pe}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Bn,{icon:Xe,label:Z(`know.all`),selected:!(u||V),onPick:()=>X(`all`)})}),G.data?.categories.length&&!T?(0,$.jsx)(Ln,{label:Z(`know.categories`),children:G.data.categories.map(e=>(0,$.jsx)(Bn,{icon:ft[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!u&&(V===`c:${e.id}`||K.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(la,{groups:fe,current:u?void 0:H?.id,onPick:e=>X(`s:${e}`)})]}):_===`files`&&s?(0,$.jsx)(Fn,{children:(0,$.jsx)(Pt,{spaceId:s.id,admin:C})}):_===`skills`?(0,$.jsxs)(Fn,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Bn,{icon:Xe,label:Z(`skills.all`),selected:!(u||Ee),onPick:()=>X(`all`)}),De.data?.skills.map(e=>(0,$.jsx)(Bn,{icon:Yt[e.mode],label:e.name,selected:!u&&Ee===`k:${e.id}`,onPick:()=>X(`k:${e.id}`)},e.id))]}),(0,$.jsx)(la,{groups:fe,current:It,onPick:mt})]}):(0,$.jsx)(Fn,{children:(0,$.jsx)(la,{groups:de,current:It,onPick:mt})}),s&&(_===`info`||_===`brand`||_===`knowledge`)?(0,$.jsxs)(ia,{space:s,group:_,top:!V||!!H,children:[_===`knowledge`&&C?(0,$.jsx)(qe,{spaceId:s.id,folder:n.has(`audience`)&&q?.kind===`page`?{id:q.id,title:q.title}:null,onClose:()=>r(P?{show:P}:{},{replace:!0})}):null,_===`knowledge`&&U&&w?(0,$.jsx)(sr,{spaceId:s.id,kind:U.startsWith(`p:`)?`page`:U.startsWith(`t:`)?`table`:`document`,id:U.slice(2)}):null,_===`knowledge`?U?T&&G.data&&q&&Ut(q)&&je!==U?(0,$.jsx)(gt,{spaceId:s.id,data:G.data,folder:q,readOnly:s.readOnly,onOpen:X,onWrite:e=>{Me(e),X(e)},onGone:()=>X(q.parentId?`p:${q.parentId}`:`all`),kinds:Oe.kinds,source:Oe.ofFolder(q.id)??(q.kept?void 0:Oe.sources.find(e=>q.origin===`source:${e.id}`)),status:Oe.ofFolder(q.id)?(0,$.jsx)(Qe,{spaceId:s.id,sources:Oe.sources,only:Oe.ofFolder(q.id)?.id}):null},U):U.startsWith(`p:`)?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(fn,{pageId:U.slice(2),onGone:()=>X(`all`),onOpen:X}),T&&G.data&&q?(0,$.jsx)(Dt,{data:G.data,page:q,onOpen:X}):null]},U):U.startsWith(`t:`)?(0,$.jsx)(dn,{tableId:U.slice(2),onGone:()=>X(`all`)},U):(0,$.jsx)(xr,{spaceId:s.id,fileId:U.slice(2),page:Number(Ce)||void 0,readOnly:s.readOnly,onGone:()=>X(`all`)},U):T&&V?.startsWith(`q:`)?(0,$.jsx)(ot,{spaceId:s.id,sourceId:V.slice(2),readOnly:s.readOnly,onOpen:X,onGone:()=>X(`all`)},V):G.data?H?(0,$.jsx)(k,{title:H.label(),hint:H.hint?.(),plain:!0,children:(0,$.jsx)(Rt,{of:H,children:(0,$.jsx)(H.component,{})})},V):T&&V?.startsWith(`c:`)?Re?(0,$.jsx)(Or,{spaceId:s.id,data:G.data,category:Re,readOnly:s.readOnly,onOpen:X,onGone:()=>X(`all`)},V):null:T&&V?.startsWith(`v:`)?K.data?(0,$.jsx)(kr,{data:G.data,value:K.data,readOnly:s.readOnly,onOpen:X},V):null:V?.startsWith(`c:`)?Re?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(Kt,{spaceId:s.id,category:Re,readOnly:s.readOnly,onOpen:X,onGone:()=>X(`all`)}),Re.type===`choice`?null:(0,$.jsx)(At,{spaceId:s.id,category:Re,categories:G.data.categories,onOpen:X})]},V):null:V?.startsWith(`v:`)?K.data?(0,$.jsx)(Ge,{value:K.data,readOnly:s.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[K.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:K.data.items.map(e=>(0,$.jsx)(Lt,{item:e,categories:G.data.categories.filter(e=>e.id!==K.data?.category.id),onOpen:X},e.key))}):null,K.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:Z(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},V):null:(0,$.jsx)(I,{id:`documents`,children:T?(0,$.jsx)(Bt,{spaceId:s.id,data:G.data,readOnly:s.readOnly,onOpen:X,onWrite:e=>{Me(e),X(e)},status:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qe,{spaceId:s.id,sources:Oe.sources,onOpen:X}),xt(fe)]}),kinds:Oe.kinds,adds:l.spaceSections.filter(e=>(e.group??`knowledge`)===`knowledge`&&e.add).map(e=>({id:e.id,label:e.add?.label()??e.label(),hint:e.add?.hint?.(),icon:e.add?.icon??e.icon}))}):(0,$.jsx)(Ct,{spaceId:s.id,data:G.data,readOnly:s.readOnly,onOpen:X,status:xt(fe)})}):null:null,_===`info`||_===`brand`?vt(fe):null]},s.id):null,s&&_===`knowledge`&&T&&G.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(at,{spaceId:s.id,kind:ke?.kind??null,parentId:ke?.parentId??null,onClose:()=>Ae(null),onOpen:X}),(0,$.jsx)(Tt,{item:Ne,items:G.data.items,onClose:()=>Pe(null),onMove:Le}),(0,$.jsx)(nt,{spaceId:s.id,open:Be,onClose:()=>Y(!1),onMade:e=>{Y(!1),X(`c:${e}`)}}),(0,$.jsx)(Ht,{kind:Fe===void 0?null:`folder`,spaceId:s.id,parentId:Fe,onClose:()=>Ie(void 0),onMade:e=>{Ie(void 0),X(e)}})]}):null,s&&_===`clients`&&w?(0,$.jsx)(I,{id:`clients`,children:(0,$.jsx)(ir,{space:s})}):null,s&&_===`skills`&&S?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:Ee?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(ua,{skillId:Ee.slice(2),onGone:()=>X(`all`),onOpen:X},Ee)}):De.data?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jt,{spaceId:s.id,data:De.data,onOpen:X}),vt(fe)]}):De.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:De.error.message}):null}):null,s&&_===`page`&&x?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,$.jsx)($r,{space:s},s.id),vt(fe)]}):null,s&&v?(0,$.jsx)(Rt,{of:v,children:(0,$.jsx)(Et,{part:v.id,children:(0,$.jsx)(v.component,{})},s.id)}):null,s&&_===`files`&&D?(0,$.jsx)(bt,{spaceId:s.id,admin:C},s.id):null,s&&_===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:V?.startsWith(`t:`)?(0,$.jsx)(dn,{tableId:V.slice(2),onGone:()=>X(`all`)},V):V?.startsWith(`p:`)?(0,$.jsx)(fn,{pageId:V.slice(2),onGone:()=>X(`all`)},V):(0,$.jsxs)($.Fragment,{children:[W.data?(0,$.jsx)(pn,{spaceId:s.id,data:W.data,readOnly:s.readOnly,onOpen:X}):null,vt(fe)]})}):null,s&&_===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[xe.data?(0,$.jsx)(ii,{data:xe.data,wizardId:_e,onWizard:e=>X(e??`all`),filter:ve,onFilter:be}):null,xe.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:xe.error.message}):null,vt(fe)]}):null,s||c?null:(0,$.jsx)(Te,{children:Z(`settings.noSpace`)})]}):s&&(!u||P===`overview`)?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[u?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(zn,{label:Z(`nav.sources`),onBack:()=>i(`/space`)})}):null,(0,$.jsx)(oi,{space:s,parts:ee})]}):null]})})})}var fa=`space.menuWidth`,pa=160,ma=480;function ha(){let[e,t]=(0,Q.useState)(()=>{try{let e=Number(localStorage.getItem(fa));return e>=pa&&e<=ma?e:null}catch{return null}});return[e,e=>{t(e);try{e===null?localStorage.removeItem(fa):localStorage.setItem(fa,String(e))}catch{}}]}function ga({grid:e,onWidth:t}){let[n,r]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{"aria-hidden":!0,onDoubleClick:()=>{e.current?.style.removeProperty(`--menu-w`),t(null)},onPointerDown:n=>{let i=n.currentTarget.parentElement,a=e.current;if(!(i&&a)||n.button!==0)return;n.preventDefault();let o=n.clientX,s=i.getBoundingClientRect().width,c=s;r(!0);let l=e=>{c=Math.round(Math.min(ma,Math.max(pa,s+e.clientX-o))),a.style.setProperty(`--menu-w`,`${c}px`)},u=()=>{window.removeEventListener(`pointermove`,l),window.removeEventListener(`pointerup`,u),r(!1),c!==s&&t(c)};window.addEventListener(`pointermove`,l),window.addEventListener(`pointerup`,u)},className:`group/resize -right-4 lg:-right-6 absolute inset-y-0 z-10 hidden w-3 cursor-col-resize touch-none md:block`,children:[(0,$.jsx)(`span`,{className:L(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`)}),(0,$.jsxs)(`span`,{className:L(`group/grip sticky top-[calc(50vh-1.5rem)] mx-auto flex h-12 w-3 items-center justify-center transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/resize:opacity-100`),children:[(0,$.jsx)(`span`,{className:L(`block h-10 w-1 rounded-full transition-colors`,n?`bg-ink-2`:`bg-ink-4 group-hover/grip:bg-ink-2`)}),(0,$.jsx)(`span`,{className:L(`pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[0.75rem] text-paper opacity-0 shadow-overlay transition-opacity`,!n&&`group-hover/grip:opacity-100 group-hover/grip:delay-300`),children:Z(`space.menuWidth`)})]})]})}export{da as SpacePage};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-BCcD8hKm.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-Mplfhz_Z.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-Bymk5Ev-.js","assets/logo-BpnjXTRy.js","assets/engenty-CNjaZCVM.js","assets/ChangelogDialog-B08elwyr.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{$t as r,Dn as i,Gn as a,Q as o,Vr as s,Xn as c,Yn as l,Zn as u,gr as d,hn as f,in as p,or as m,rr as h,un as g}from"./ui-Mplfhz_Z.js";import{t as _}from"./useMutation-8QRM-z4M.js";import{t as v}from"./react-dom-hf6EcyAr.js";import{t as y}from"./preload-helper-DpV6A1kQ.js";import{n as b,s as x}from"./i18n-Bymk5Ev-.js";import{t as S}from"./media-Cej-H610.js";var C=e(v(),1),w=e(t(),1),T=e(n(),1),E=(0,w.lazy)(()=>y(()=>import(`./AboutDialog-BCcD8hKm.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),D=`0.16.2`;function O({me:e}){let[t,n]=(0,w.useState)(!1);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:x(`about.version`,{v:D})}),t?(0,T.jsx)(w.Suspense,{fallback:null,children:(0,T.jsx)(E,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var k=[`update`],A=36e5;function j(e=!0){let t=s(),[n,r]=(0,w.useState)(null),i=d({queryKey:k,queryFn:()=>o.get(`/api/studio/update`),staleTime:A,refetchInterval:A,retry:!1,enabled:e}),a=_({mutationFn:()=>o.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(k,e)}),c=_({mutationFn:()=>o.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(k,e)}),l=i.data,u=l?.latest??null,f=l?.restarts&&(l.applying===`running`||l.applying===`done`),p=l?.current;return(0,w.useEffect)(()=>{if(!(f||l?.applying===`running`)||!u)return;let e=setInterval(async()=>{try{let e=await o.get(`/api/studio/update`);if(e.current!==p){window.location.reload();return}t.setQueryData(k,e),e.applying===`done`&&e.restarts&&r(u)}catch{r(u)}},2e3);return()=>clearInterval(e)},[f,l?.applying,u,p,t]),{status:i,data:l,latest:u,check:a,apply:c,busy:l?.applying===`running`||n!==null,progress:!l||!u?null:n===null?l.applying===`running`?x(`about.update.installing`,{v:u}):l.applying===`done`?x(`about.update.done`,{v:u}):l.applying===`failed`?x(`about.update.failed`):null:x(`about.update.restarting`,{v:u})}}var M=(0,w.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function N(){return(0,w.useContext)(M)}function P({children:e}){let{slot:t}=N();return t?(0,C.createPortal)(e,t):null}function F(e){let{setDetail:t}=N();(0,w.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function I(){return S(`(max-width: 767px)`)}function L(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function R({title:e,open:t,onBack:n,root:r}){let i=t??r??null,a=t?n:void 0;return(0,T.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,T.jsx)(`div`,{className:f(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&a?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,T.jsx)(`button`,{type:`button`,onClick:a,"aria-hidden":!(i&&a),tabIndex:i&&a?void 0:-1,"aria-label":e,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,T.jsx)(h,{className:`size-4`})})}),!t&&r?.onOpen?(0,T.jsxs)(`button`,{type:`button`,onClick:r.onOpen,"aria-current":r.current?`page`:void 0,className:f(`-mx-1 flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1 text-left font-medium text-[0.875rem] transition`,r.current?`bg-paper-2 text-ink`:`hover:bg-accent`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(r.icon,{className:`size-4 text-ember-strong`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label})]}):i?(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,T.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,T.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,T.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function z({entries:e,current:t,hide:n,onPick:r}){let[i,a]=(0,w.useState)(!1);return(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,onPointerMove:()=>i&&a(!1),children:e.map((o,s)=>(0,T.jsx)(`li`,{"aria-hidden":o.id===n||void 0,className:f(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,o.id===n?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr]`),children:(0,T.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[o.group===e[s-1]?.group?null:o.group?(0,T.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:o.group}):(0,T.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,T.jsxs)(m,{to:o.to,onClick:e=>{a(!0),o.id===t?.id&&(e.preventDefault(),r(o))},"aria-current":o.id===t?.id?`page`:void 0,className:f(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,o.id===t?.id?`bg-paper-2 font-medium text-ink`:i?`text-ink-2`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(o.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.label}),o.count===void 0?null:(0,T.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:o.count}),(0,T.jsx)(l,{className:`size-4 text-ink-4 md:hidden`})]})]})},o.id))})}function B({label:e,onBack:t}){return(0,T.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,T.jsx)(c,{className:`size-4`}),e]})}function V(e){let t=(0,w.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function H({label:e,collapsible:t,open:n=!0,count:r,children:i}){let[a,o]=(0,w.useState)(n),s=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,T.jsxs)(`div`,{className:`mt-5 first:mt-0 [&:not(:has(li))]:hidden`,children:[t?(0,T.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,className:f(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,s),children:[(0,T.jsx)(`span`,{className:`flex-1`,children:e}),a?null:(0,T.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,T.jsx)(u,{className:f(`size-3.5 transition-transform`,a?null:`-rotate-90`)})]}):(0,T.jsx)(`p`,{className:f(`mb-1 px-2`,s),children:e}),a?(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:i}):null]})}function U({icon:e,label:t,badge:n,tone:r,toneLabel:i,selected:a,disabled:o,onPick:s}){let{filter:c}=N();return c&&!t.toLowerCase().includes(c)?null:(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,onClick:s,disabled:o,"aria-current":a?`page`:void 0,className:f(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,a?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,o&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(e,{className:f(`size-4 transition-transform duration-200 ease-out`,!o&&`group-hover:scale-110`,a?`text-ember-strong`:`text-ink-3`)})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,r?(0,T.jsx)(`span`,{role:`img`,title:i,"aria-label":i,className:f(`size-2 shrink-0 rounded-full`,r===`done`&&`bg-moss`,r===`credits`&&`bg-amber`,r===`on`&&`bg-ember`,r===`miss`&&`bg-amber`,r===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,o?null:(0,T.jsx)(l,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}function W({enabled:e=!0,align:t=`center`}){let{status:n,data:o,latest:s,check:c,apply:l,busy:u,progress:d}=j(e),p=o?.checkedAt?new Date(o.checkedAt).toLocaleTimeString(b,{hour:`2-digit`,minute:`2-digit`}):null,m=t===`center`;return(0,T.jsxs)(`div`,{className:f(`flex flex-col gap-3 text-[0.875rem] text-ink-2`,m?`items-center text-center`:`items-start`),children:[n.isPending||c.isPending?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,T.jsx)(g,{className:`size-4 text-ember-strong`}),x(`about.update.checking`)]}):d?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,T.jsx)(g,{className:`size-4 text-ember-strong`}):null,d]}):o?.newer&&s?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5 font-medium text-ink`,children:[(0,T.jsx)(a,{className:`size-4 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:s})]}),o.canApply?null:(0,T.jsx)(`p`,{className:`text-ink-3`,children:x(`about.update.manual`)})]}):o?.enabled?o.latest===null?(0,T.jsx)(`p`,{children:x(`about.update.unknown`)}):(0,T.jsxs)(`p`,{children:[x(`about.update.upToDate`),p?(0,T.jsxs)(`span`,{className:`text-ink-4`,children:[` `,`· `,x(`about.update.checkedAt`,{when:p})]}):null]}):(0,T.jsx)(`p`,{children:x(`about.update.off`)}),u||n.isPending?null:(0,T.jsxs)(`div`,{className:f(`flex flex-wrap gap-2`,m&&`justify-center`),children:[o?.newer&&o.canApply&&o.applying!==`running`?(0,T.jsxs)(r,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(a,{className:`size-4`}),` `,x(`about.update.install`)]}):null,o?.enabled===!1?null:(0,T.jsxs)(r,{size:`sm`,variant:`secondary`,disabled:c.isPending,onClick:()=>c.mutate(),children:[(0,T.jsx)(i,{className:f(`size-4`,c.isPending&&`animate-spin`)}),` `,x(`about.update.check`)]})]})]})}function G({me:e}){let t=e.mode===`local`,{status:n,data:o,latest:s,check:c,apply:l,busy:u,progress:d}=j(t),f=n.isPending||c.isPending;return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 text-[0.8125rem] text-ink-3`,children:[(0,T.jsx)(O,{me:e}),(0,T.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?f?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(g,{className:`size-3.5 text-ember-strong`}),` `,x(`about.update.checking`)]}):d?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[u?(0,T.jsx)(g,{className:`size-3.5 text-ember-strong`}):null,d]}):o?.newer&&s?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-ink`,children:[(0,T.jsx)(a,{className:`size-3.5 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:s})]}):o?.enabled?o.latest===null?(0,T.jsx)(`span`,{children:x(`about.update.unknown`)}):(0,T.jsx)(`span`,{children:x(`about.update.upToDate`)}):(0,T.jsx)(`span`,{children:x(`about.update.off`)}):(0,T.jsx)(`span`,{children:x(`about.kind.cloud`)}),!t||f||u?null:o?.newer&&o.canApply?(0,T.jsxs)(r,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(a,{className:`size-4`}),` `,x(`about.update.install`)]}):o?.enabled?(0,T.jsx)(p,{label:x(`about.update.check`),className:`size-7 coarse:size-9`,onClick:()=>c.mutate(),children:(0,T.jsx)(i,{className:`size-3.5`})}):null]})}export{z as a,M as c,F as d,I as f,D as g,j as h,R as i,P as l,V as m,G as n,H as o,N as p,B as r,U as s,W as t,L as u};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AboutDialog-mZCBU7KF.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-BacfkQ7Q.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-DCPDesT-.js","assets/logo-BpnjXTRy.js","assets/engenty-CNjaZCVM.js","assets/ChangelogDialog-BhyilZWA.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{$t as r,Dn as i,Gn as a,Q as o,Vr as s,Xn as c,Yn as l,Zn as u,gr as d,hn as f,in as p,or as m,rr as h,un as g}from"./ui-BacfkQ7Q.js";import{t as _}from"./useMutation-CgzFr4qH.js";import{t as v}from"./react-dom-hf6EcyAr.js";import{t as y}from"./preload-helper-DpV6A1kQ.js";import{n as b,s as x}from"./i18n-DCPDesT-.js";import{t as S}from"./media-Cej-H610.js";var C=e(v(),1),w=e(t(),1),T=e(n(),1),E=(0,w.lazy)(()=>y(()=>import(`./AboutDialog-mZCBU7KF.js`).then(e=>({default:e.AboutDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),D=`0.17.1`;function O({me:e}){let[t,n]=(0,w.useState)(!1);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{type:`button`,className:`tabular-nums transition hover:text-ink-2`,onClick:()=>n(!0),children:x(`about.version`,{v:D})}),t?(0,T.jsx)(w.Suspense,{fallback:null,children:(0,T.jsx)(E,{open:!0,me:e,onClose:()=>n(!1)})}):null]})}var k=[`update`],A=36e5;function j(e=!0){let t=s(),[n,r]=(0,w.useState)(null),i=d({queryKey:k,queryFn:()=>o.get(`/api/studio/update`),staleTime:A,refetchInterval:A,retry:!1,enabled:e}),a=_({mutationFn:()=>o.get(`/api/studio/update?fresh=1`),onSuccess:e=>t.setQueryData(k,e)}),c=_({mutationFn:()=>o.post(`/api/studio/update`),onSuccess:e=>t.setQueryData(k,e)}),l=i.data,u=l?.latest??null,f=l?.restarts&&(l.applying===`running`||l.applying===`done`),p=l?.current;return(0,w.useEffect)(()=>{if(!(f||l?.applying===`running`)||!u)return;let e=setInterval(async()=>{try{let e=await o.get(`/api/studio/update`);if(e.current!==p){window.location.reload();return}t.setQueryData(k,e),e.applying===`done`&&e.restarts&&r(u)}catch{r(u)}},2e3);return()=>clearInterval(e)},[f,l?.applying,u,p,t]),{status:i,data:l,latest:u,check:a,apply:c,busy:l?.applying===`running`||n!==null,progress:!l||!u?null:n===null?l.applying===`running`?x(`about.update.installing`,{v:u}):l.applying===`done`?x(`about.update.done`,{v:u}):l.applying===`failed`?x(`about.update.failed`):null:x(`about.update.restarting`,{v:u})}}var M=(0,w.createContext)({slot:null,narrow:!1,setDetail:()=>void 0});function N(){return(0,w.useContext)(M)}function P({children:e}){let{slot:t}=N();return t?(0,C.createPortal)(e,t):null}function F(e){let{setDetail:t}=N();(0,w.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function I(){return S(`(max-width: 767px)`)}function L(e){return e===`deeper`?`animate-step-deeper`:e===`back`&&`animate-step-back`}function R({title:e,open:t,onBack:n,root:r}){let i=t??r??null,a=t?n:void 0;return(0,T.jsxs)(`div`,{className:`mb-2 flex h-9 min-w-0 items-center px-1`,children:[(0,T.jsx)(`div`,{className:f(`shrink-0 overflow-hidden transition-[width,margin,opacity] duration-200 ease-out`,i&&a?`-ml-1.5 mr-0.5 w-8 opacity-100`:`w-0 opacity-0`),children:(0,T.jsx)(`button`,{type:`button`,onClick:a,"aria-hidden":!(i&&a),tabIndex:i&&a?void 0:-1,"aria-label":e,className:`grid size-8 place-items-center rounded-lg text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,T.jsx)(h,{className:`size-4`})})}),!t&&r?.onOpen?(0,T.jsxs)(`button`,{type:`button`,onClick:r.onOpen,"aria-current":r.current?`page`:void 0,className:f(`-mx-1 flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-1 text-left font-medium text-[0.875rem] transition`,r.current?`bg-paper-2 text-ink`:`hover:bg-accent`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(r.icon,{className:`size-4 text-ember-strong`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label})]}):i?(0,T.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-medium text-[0.875rem]`,children:[(0,T.jsx)(i.icon,{className:`size-4 shrink-0 text-ember-strong`}),(0,T.jsx)(`span`,{className:`truncate`,children:i.label})]}):(0,T.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:e})]})}function z({entries:e,current:t,hide:n,onPick:r}){let[i,a]=(0,w.useState)(!1);return(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,onPointerMove:()=>i&&a(!1),children:e.map((o,s)=>(0,T.jsx)(`li`,{"aria-hidden":o.id===n||void 0,className:f(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,o.id===n?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr]`),children:(0,T.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[o.group===e[s-1]?.group?null:o.group?(0,T.jsx)(`div`,{className:`px-2 pt-4 pb-1 font-medium text-[0.75rem] text-ink-3 first:pt-1`,children:o.group}):(0,T.jsx)(`div`,{className:`h-3`,"aria-hidden":!0}),(0,T.jsxs)(m,{to:o.to,onClick:e=>{a(!0),o.id===t?.id&&(e.preventDefault(),r(o))},"aria-current":o.id===t?.id?`page`:void 0,className:f(`group flex items-center gap-2 rounded-lg px-2 py-1 text-[0.875rem] transition max-md:py-2`,o.id===t?.id?`bg-paper-2 font-medium text-ink`:i?`text-ink-2`:`text-ink-2 hover:bg-accent hover:text-ink`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(o.icon,{className:`size-4 transition-transform duration-200 ease-out group-hover:scale-110`})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.label}),o.count===void 0?null:(0,T.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:o.count}),(0,T.jsx)(l,{className:`size-4 text-ink-4 md:hidden`})]})]})},o.id))})}function B({label:e,onBack:t}){return(0,T.jsxs)(`button`,{type:`button`,onClick:t,className:`-ml-1 flex items-center gap-1 rounded-lg py-1.5 pr-3 pl-1 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[(0,T.jsx)(c,{className:`size-4`}),e]})}function V(e){let t=(0,w.useRef)({level:e,direction:null});return e!==t.current.level&&(t.current={level:e,direction:e>t.current.level?`deeper`:`back`}),t.current.direction}function H({label:e,collapsible:t,open:n=!0,count:r,children:i}){let[a,o]=(0,w.useState)(n),s=`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`;return(0,T.jsxs)(`div`,{className:`mt-5 first:mt-0 [&:not(:has(li))]:hidden`,children:[t?(0,T.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),"aria-expanded":a,className:f(`mb-1 flex w-full items-center gap-1 px-2 text-left hover:text-ink-2`,s),children:[(0,T.jsx)(`span`,{className:`flex-1`,children:e}),a?null:(0,T.jsx)(`span`,{className:`tabular-nums tracking-normal`,children:r}),(0,T.jsx)(u,{className:f(`size-3.5 transition-transform`,a?null:`-rotate-90`)})]}):(0,T.jsx)(`p`,{className:f(`mb-1 px-2`,s),children:e}),a?(0,T.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:i}):null]})}function U({icon:e,label:t,badge:n,tone:r,toneLabel:i,selected:a,disabled:o,onPick:s}){let{filter:c}=N();return c&&!t.toLowerCase().includes(c)?null:(0,T.jsx)(`li`,{children:(0,T.jsxs)(`button`,{type:`button`,onClick:s,disabled:o,"aria-current":a?`page`:void 0,className:f(`group flex w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-[0.875rem] transition max-md:py-2`,a?`bg-paper-2 font-medium text-ink`:`text-ink-2 hover:bg-accent hover:text-ink`,o&&`cursor-default opacity-50 hover:bg-transparent hover:text-ink-2`),children:[(0,T.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center`,children:(0,T.jsx)(e,{className:f(`size-4 transition-transform duration-200 ease-out`,!o&&`group-hover:scale-110`,a?`text-ember-strong`:`text-ink-3`)})}),(0,T.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),n,r?(0,T.jsx)(`span`,{role:`img`,title:i,"aria-label":i,className:f(`size-2 shrink-0 rounded-full`,r===`done`&&`bg-moss`,r===`credits`&&`bg-amber`,r===`on`&&`bg-ember`,r===`miss`&&`bg-amber`,r===`off`&&`ring-1 ring-ink-4 ring-inset`)}):null,o?null:(0,T.jsx)(l,{className:`size-4 shrink-0 text-ink-4 md:hidden`})]})})}function W({enabled:e=!0,align:t=`center`}){let{status:n,data:o,latest:s,check:c,apply:l,busy:u,progress:d}=j(e),p=o?.checkedAt?new Date(o.checkedAt).toLocaleTimeString(b,{hour:`2-digit`,minute:`2-digit`}):null,m=t===`center`;return(0,T.jsxs)(`div`,{className:f(`flex flex-col gap-3 text-[0.875rem] text-ink-2`,m?`items-center text-center`:`items-start`),children:[n.isPending||c.isPending?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,T.jsx)(g,{className:`size-4 text-ember-strong`}),x(`about.update.checking`)]}):d?(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,T.jsx)(g,{className:`size-4 text-ember-strong`}):null,d]}):o?.newer&&s?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5 font-medium text-ink`,children:[(0,T.jsx)(a,{className:`size-4 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:s})]}),o.canApply?null:(0,T.jsx)(`p`,{className:`text-ink-3`,children:x(`about.update.manual`)})]}):o?.enabled?o.latest===null?(0,T.jsx)(`p`,{children:x(`about.update.unknown`)}):(0,T.jsxs)(`p`,{children:[x(`about.update.upToDate`),p?(0,T.jsxs)(`span`,{className:`text-ink-4`,children:[` `,`· `,x(`about.update.checkedAt`,{when:p})]}):null]}):(0,T.jsx)(`p`,{children:x(`about.update.off`)}),u||n.isPending?null:(0,T.jsxs)(`div`,{className:f(`flex flex-wrap gap-2`,m&&`justify-center`),children:[o?.newer&&o.canApply&&o.applying!==`running`?(0,T.jsxs)(r,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(a,{className:`size-4`}),` `,x(`about.update.install`)]}):null,o?.enabled===!1?null:(0,T.jsxs)(r,{size:`sm`,variant:`secondary`,disabled:c.isPending,onClick:()=>c.mutate(),children:[(0,T.jsx)(i,{className:f(`size-4`,c.isPending&&`animate-spin`)}),` `,x(`about.update.check`)]})]})]})}function G({me:e}){let t=e.mode===`local`,{status:n,data:o,latest:s,check:c,apply:l,busy:u,progress:d}=j(t),f=n.isPending||c.isPending;return(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-2 text-[0.8125rem] text-ink-3`,children:[(0,T.jsx)(O,{me:e}),(0,T.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?f?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,T.jsx)(g,{className:`size-3.5 text-ember-strong`}),` `,x(`about.update.checking`)]}):d?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[u?(0,T.jsx)(g,{className:`size-3.5 text-ember-strong`}):null,d]}):o?.newer&&s?(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium text-ink`,children:[(0,T.jsx)(a,{className:`size-3.5 shrink-0 text-ember-strong`}),x(`about.update.available`,{v:s})]}):o?.enabled?o.latest===null?(0,T.jsx)(`span`,{children:x(`about.update.unknown`)}):(0,T.jsx)(`span`,{children:x(`about.update.upToDate`)}):(0,T.jsx)(`span`,{children:x(`about.update.off`)}):(0,T.jsx)(`span`,{children:x(`about.kind.cloud`)}),!t||f||u?null:o?.newer&&o.canApply?(0,T.jsxs)(r,{size:`sm`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,T.jsx)(a,{className:`size-4`}),` `,x(`about.update.install`)]}):o?.enabled?(0,T.jsx)(p,{label:x(`about.update.check`),className:`size-7 coarse:size-9`,onClick:()=>c.mutate(),children:(0,T.jsx)(i,{className:`size-3.5`})}):null]})}export{z as a,M as c,F as d,I as f,D as g,j as h,R as i,P as l,V as m,G as n,H as o,N as p,B as r,U as s,W as t,L as u};