@engenty/wizards-runtime 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/apps/runtime/dist/bundles/discover.js +133 -0
  2. package/apps/runtime/dist/connectors/external.js +8 -0
  3. package/apps/runtime/dist/docs/dev/broker.md +62 -2
  4. package/apps/runtime/dist/docs/dev/skills.md +8 -1
  5. package/apps/runtime/dist/docs/user-guide/capabilities.md +5 -1
  6. package/apps/runtime/dist/docs/user-guide/connectors.md +53 -2
  7. package/apps/runtime/dist/docs/user-guide/skills.md +11 -1
  8. package/apps/runtime/dist/routes/discover.js +1 -0
  9. package/apps/runtime/dist/services/discover.js +9 -3
  10. package/apps/runtime/dist/services/space-index.js +15 -5
  11. package/apps/web/dist/assets/{AboutDialog-mZCBU7KF.js → AboutDialog-NzB-GEj_.js} +1 -1
  12. package/apps/web/dist/assets/{BlockEditor-Dk0QwLSU.js → BlockEditor-HyDf8fOb.js} +1 -1
  13. package/apps/web/dist/assets/Bundle-B0Bhs0By.js +1 -0
  14. package/apps/web/dist/assets/CapabilitiesPage-CQSaMsWK.js +2 -0
  15. package/apps/web/dist/assets/{ChangelogDialog-BhyilZWA.js → ChangelogDialog-Ngxuqubx.js} +1 -1
  16. package/apps/web/dist/assets/{CodeEditor-DULYZbuE.js → CodeEditor-C2LBf4pS.js} +1 -1
  17. package/apps/web/dist/assets/EditorPage-Dysvvadu.js +3 -0
  18. package/apps/web/dist/assets/{FlowPreview-ykxZxWnk.js → FlowPreview-CGfSaeYu.js} +1 -1
  19. package/apps/web/dist/assets/LangSwitch-B7UQlGh5.js +1 -0
  20. package/apps/web/dist/assets/Marketplace-BkIxd1PW.js +2 -0
  21. package/apps/web/dist/assets/{NewWizardChannels-CsSV7sm2.js → NewWizardChannels-BWLaVFld.js} +1 -1
  22. package/apps/web/dist/assets/NewWizardPage-BpRd8tDF.js +7 -0
  23. package/apps/web/dist/assets/OnboardingPage-ScEcQcR0.js +1 -0
  24. package/apps/web/dist/assets/{PreviewPane-CJuqY5uA.js → PreviewPane-CaC1FYxZ.js} +4 -4
  25. package/apps/web/dist/assets/ProtocolSection-CILRCYLD.js +1 -0
  26. package/apps/web/dist/assets/PublicRunner-DHX431Pr.js +1 -0
  27. package/apps/web/dist/assets/{ReadOnly-CXQ41R9Q.js → ReadOnly-DqS1UDQs.js} +1 -1
  28. package/apps/web/dist/assets/SettingsPage-Dp2-rHXu.js +2 -0
  29. package/apps/web/dist/assets/SetupPage-mzMLQcD5.js +1 -0
  30. package/apps/web/dist/assets/SharePage-CBDgqEH7.js +1 -0
  31. package/apps/web/dist/assets/SkillEditor-Cf6FqkkU.js +1 -0
  32. package/apps/web/dist/assets/{Skills-D7V_9_xo.js → Skills-DqV5Oqqu.js} +5 -5
  33. package/apps/web/dist/assets/SpacePage-C3SXe2hs.js +2 -0
  34. package/apps/web/dist/assets/{UpdateCheck-DVgAJmy8.js → UpdateCheck-B51jMIhp.js} +2 -2
  35. package/apps/web/dist/assets/brand-CG35IRgr.js +2 -0
  36. package/apps/web/dist/assets/changelog-DN6sziTl.js +1 -0
  37. package/apps/web/dist/assets/{code-editor-5T7ilBjd.js → code-editor-Bsyy7cuT.js} +2 -2
  38. package/apps/web/dist/assets/{host-CCijW1hj.js → host-DaDyLfqT.js} +16 -16
  39. package/apps/web/dist/assets/{i18n-DCPDesT-.js → i18n-CyrHWeGk.js} +1 -1
  40. package/apps/web/dist/assets/{index-zcPlodHx.css → index-Db9JthZr.css} +1 -1
  41. package/apps/web/dist/assets/index-LjwVRoki.js +10 -0
  42. package/apps/web/dist/assets/plug-De3mHDFV.js +1 -0
  43. package/apps/web/dist/assets/{read-aloud-Qb719not.js → read-aloud-DCTouK7J.js} +1 -1
  44. package/apps/web/dist/assets/{runners-BeZ84YH_.js → runners-DtiBHvG7.js} +1 -1
  45. package/apps/web/dist/assets/session-DKGZUy6h.js +1 -0
  46. package/apps/web/dist/assets/{theme-y_owNosi.js → theme-Bcj8TXQr.js} +2 -2
  47. package/apps/web/dist/assets/{ui-BacfkQ7Q.js → ui-C6vSmisV.js} +1 -1
  48. package/apps/web/dist/assets/{useMutation-CgzFr4qH.js → useMutation-B8hJ5Z6N.js} +1 -1
  49. package/apps/web/dist/assets/{viewers-CkyHAjnk.js → viewers-b9FdC42r.js} +2 -2
  50. package/apps/web/dist/assets/{volume-2-BqlBtCIJ.js → volume-2-B1roRk6x.js} +1 -1
  51. package/apps/web/dist/index.html +15 -13
  52. package/apps/web/dist/mcp/flow.html +2 -2
  53. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +28 -1
  54. package/package.json +1 -1
  55. package/plugin/.claude-plugin/plugin.json +1 -1
  56. package/plugin/plugin.json +1 -1
  57. package/apps/web/dist/assets/CapabilitiesPage-GkpgF-wZ.js +0 -2
  58. package/apps/web/dist/assets/EditorPage-D_mCdYdZ.js +0 -3
  59. package/apps/web/dist/assets/LangSwitch-iO54w9AP.js +0 -1
  60. package/apps/web/dist/assets/Marketplace-C97fH7UC.js +0 -2
  61. package/apps/web/dist/assets/NewWizardPage-Ebgw-Vf_.js +0 -7
  62. package/apps/web/dist/assets/OnboardingPage-BZlloT7v.js +0 -1
  63. package/apps/web/dist/assets/ProtocolSection-CPaDKVpZ.js +0 -1
  64. package/apps/web/dist/assets/PublicRunner-4Lf4SnwB.js +0 -1
  65. package/apps/web/dist/assets/SettingsPage-C-8BgK9O.js +0 -2
  66. package/apps/web/dist/assets/SetupPage-4_K083Wl.js +0 -1
  67. package/apps/web/dist/assets/SharePage-CQjgMcDI.js +0 -1
  68. package/apps/web/dist/assets/SkillEditor-DT5hQwbg.js +0 -1
  69. package/apps/web/dist/assets/SpacePage-D3rYS1bA.js +0 -2
  70. package/apps/web/dist/assets/changelog-DzQCUSsx.js +0 -1
  71. package/apps/web/dist/assets/index-C_iWl8iS.js +0 -10
  72. package/apps/web/dist/assets/session-CEJRkSP5.js +0 -2
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-ykxZxWnk.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/esm-Xwn4GtqG.js","assets/react-dom-hf6EcyAr.js","assets/with-selector-CoMyWBAX.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{n,t as r}from"./jsx-runtime-BNakU3Ej.js";import{$t as i,Fn as a,Jn as o,Pn as s,Q as c,Tn as l,Vr as u,X as d,Zn as f,_n as p,_r as m,br as h,en as g,er as _,gn as v,gr as y,hn as b,jn as x,jr as ee,mr as S,nn as te,tn as C,un as w,vr as ne,xr as re,yn as ie}from"./ui-BacfkQ7Q.js";import{t as T}from"./useMutation-CgzFr4qH.js";import{t as ae}from"./preload-helper-DpV6A1kQ.js";import{d as E,n as D,s as O,u as k}from"./marked.esm-DQ7XA7AC.js";import{i as oe,n as se,r as ce,t as le}from"./volume-2-BqlBtCIJ.js";import{t as ue}from"./eye-TJSuiHHO.js";import{n as A,t as de}from"./list-checks-DaxmUPqK.js";import{A as fe,S as pe,m as me,u as he}from"./session-CEJRkSP5.js";import{c as ge,s as _e}from"./engenty-CNjaZCVM.js";import{H as j,V as ve,X as ye,b as be,et as M,lt as xe,n as N,nt as Se,rt as Ce,s as P}from"./i18n-DCPDesT-.js";var we=class extends ne{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:h(t,n.data),hasPreviousPage:re(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Te(e,t){return m(e,we,t)}var Ee={name:`app-window`,size:24,node:[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]};Ee.node;var F=E(Ee),De={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};De.node;var I=E(De),Oe={name:`circle-dollar-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]};Oe.node;var ke=E(Oe),Ae={name:`circle-euro`,size:24,node:[[`path`,{d:`M15 9.4a4 4 0 1 0 0 5.2`,key:`1makmb`}],[`path`,{d:`M7 12h5`,key:`gblrwe`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ae.node;var je=E(Ae),Me={name:`clapperboard`,size:24,node:[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]};Me.node;var L=E(Me),Ne={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ne.node;var Pe=E(Ne),Fe={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};Fe.node;var Ie=E(Fe),Le={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};Le.node;var R=E(Le),Re={name:`hourglass`,size:24,node:[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]};Re.node;var z=E(Re),ze={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};ze.node;var Be=E(ze),Ve={name:`layout-template`,size:24,node:[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]};Ve.node;var He=E(Ve),Ue={name:`puzzle`,size:24,node:[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]};Ue.node;var We=E(Ue),Ge={name:`scan-text`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`path`,{d:`M7 8h8`,key:`1jbsf9`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h6`,key:`1vyc9m`}]]};Ge.node;var Ke=E(Ge),qe={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};qe.node;var B=E(qe),Je={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Je.node;var Ye=E(Je),Xe={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Xe.node;var Ze=E(Xe),Qe=[`text`,`web`,`browser`,`documents`,`image`,`video`,`speech`,`listening`,`code`,`connectors`,`motion-graphics`],$e=new Set([`html`,`md`,`txt`,`csv`,`json`]),et=new Set([`code`]),tt=new Set([`web_search`,`browser`,`sandbox`,`image`]),nt=new Set([`web_fetch`,`http`]),rt=/\{\{\s*memory\b/;function it(e){switch(e.type){case`agent`:return[e.instructions,e.call?JSON.stringify(e.call.input):``];case`generate`:return[e.prompt,e.options?.style??``];case`motion-graphics`:return[e.brief];case`widget`:case`surface`:return Object.values(e.data).map(e=>`{{${j(e)}}}`);default:return[]}}function at(e,t){return e.steps.slice(t+1).some(e=>e.type===`agent`&&!e.call||e.type===`generate`||e.type===`motion-graphics`)}function ot(e,t){let n=[],r=(t,r)=>{let i=n.find(e=>e.need===t);i?i.hard||=r:n.push({stepId:e.id,need:t,hard:r})},i=t.steps.indexOf(e);for(let t of it(e))rt.test(t)&&r(`memory`,!0),xe(t).some(e=>e.startsWith(`lists.`))&&r(`lists`,!0);switch(e.type){case`page`:for(let n of e.fields){switch(n.kind){case`audio`:r(`field:audio`,!!n.required);break;case`connection`:r(`field:connection`,!0);break;case`slot`:r(`field:slot`,!0);break;case`list`:r(`lists`,!0);break;case`location`:r(`field:location`,!1);break;case`image`:r(`field:image`,!1);break;case`file`:at(t,i)?r(`field:file-read`,!0):r(`field:file`,!1)}n.optionsFrom&&M(j(n.optionsFrom).split(`.`).slice(0,2).join(`.`))&&r(`lists`,!0)}break;case`agent`:{let t=e.call&&`tool`in e.call?[...e.tools,e.call.tool]:e.tools;for(let e of t){let t=Se(e);t?r(`plugin:${t.plugin}`,!0):nt.has(e)||et.has(e)||(tt.has(e)?r(`tool:${e}`,!0):r(`tool:${e}`,!1))}e.connections?.length&&r(`connections`,!0),e.each&&(M(j(e.each))?r(`lists`,!0):r(`each`,!1));break}case`generate`:e.asset!==`document`&&e.asset!==`dashboard`&&r(`asset:${e.asset}`,!0);break;case`motion-graphics`:r(`motion-graphics`,!0);break;case`widget`:r(e.video?`widget:video`:`widget`,!0);break;case`surface`:Object.values(e.data).some(e=>M(j(e)))&&r(`lists`,!0);break;case`wait`:r(`wait`,!0);break;case`review`:e.show.some(e=>M(e))&&r(`lists`,!0);break;case`result`:for(let n of e.deliverables){if(M(n.from)){r(`lists`,!0);continue}let e=t.steps.find(e=>e.id===n.from);if(e?.type!==`agent`&&(e?.type!==`generate`||e.asset!==`document`&&e.asset!==`dashboard`))continue;let i=n.formats.some(e=>$e.has(e));for(let t of n.formats)$e.has(t)||(t!==`pdf`||e?.type!==`agent`)&&r(`format:${t}`,t!==`pdf`&&!i)}}return n}function st(e){let t=e.steps.flatMap(t=>ot(t,e));e.lists?.length&&!t.some(e=>e.need===`lists`)&&t.push({stepId:e.steps[0]?.id??``,need:`lists`,hard:!0}),e.connections?.length&&!t.some(e=>e.need===`connections`)&&t.push({stepId:e.steps[0]?.id??``,need:`connections`,hard:!0});let n=ut(e);return{fit:t.some(e=>e.hard&&n.has(e.stepId))?`no`:t.length?`less`:`full`,notes:t}}function ct(e){switch(e){case`tool:web_search`:case`tool:web_fetch`:return`web`;case`tool:browser`:return`browser`;case`tool:sandbox`:return`code`;case`tool:image`:case`asset:image`:return`image`;case`asset:video`:case`motion-graphics`:case`widget:video`:return`video`;case`asset:voice`:return`speech`;case`field:audio`:return`listening`;case`tool:http`:case`connections`:case`field:connection`:return`connectors`;case`field:image`:case`field:file`:case`field:file-read`:return`documents`;default:return null}}function lt(e){let t=st(e),n=ut(e),r=new Set,i=new Set,a=new Set,o=new Set;for(let e of t.notes){if(e.need.startsWith(`plugin:`)){a.add(e.need.slice(7));continue}if(e.need.startsWith(`format:`)){o.add(e.need.slice(7));continue}let t=ct(e.need);t&&(e.hard&&n.has(e.stepId)?r.add(t):i.add(t))}for(let e of r)i.delete(e);return{...t,missing:[...r],optional:[...i],needs:[...a].sort(),without:[...o]}}function ut(e){return e.steps.length?dt(e,e.steps[0].id,{}):new Set}function dt(e,t,n){let r=new Map(e.steps.map((e,t)=>[e.id,t])),i=r.get(t)??0,a=t=>{let i=[];for(let a of e.steps[t].next??[]){if(ye(a))continue;let t=a.goto===`end`?e.steps.length:r.get(a.goto)??-1;if(a.ask||!ve(a.when).every(e=>e.field in n)){t>=0&&i.push(t);continue}if(Ce(a,n))return t>=0?[...i,t]:i}return i.push(ft(e,t,r)),i},o=t=>{if(t===i)return!1;let n=new Set([i]),r=[i];for(;r.length;){let i=r.shift();if(i>=e.steps.length)return!0;for(let e of a(i))e!==t&&!n.has(e)&&(n.add(e),r.push(e))}return!1};return new Set(e.steps.filter((e,t)=>!o(t)).map(e=>e.id))}function ft(e,t,n){let r=e.steps[t].next?.find(ye)?.goto;return r===void 0?t+1:r===`end`?e.steps.length:n.get(r)??t+1}var pt=[`text`,`document`,`table`,`image`,`video`,`audio`,`dashboard`],mt=[`any`,`trades`,`gastronomy`,`hospitality`,`realEstate`,`retail`,`health`,`professional`,`agency`,`events`,`publicSector`],ht=[`marketing`,`sales`,`accounting`,`service`,`research`,`hr`,`operations`,`website`,`visuals`,`inquiries`,`advice`],gt=[`free`,`pro`],_t={"format.text":`Text`,"format.document":`Document (PDF, Word)`,"format.table":`Table`,"format.image":`Image`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Any industry`,"industry.trades":`Trades`,"industry.gastronomy":`Food service`,"industry.hospitality":`Hotels & tourism`,"industry.realEstate":`Real estate`,"industry.retail":`Retail`,"industry.health":`Health`,"industry.professional":`Professional services`,"industry.agency":`Agency & marketing`,"industry.events":`Events`,"industry.publicSector":`Associations & public sector`,"useCase.marketing":`Marketing & social media`,"useCase.sales":`Offers & sales`,"useCase.accounting":`Accounting & receipts`,"useCase.service":`Customer service`,"useCase.research":`Research & analysis`,"useCase.hr":`HR & applications`,"useCase.operations":`Planning & operations`,"useCase.website":`Website helpers`,"useCase.visuals":`Images & video`,"useCase.inquiries":`Inquiries & bookings`,"useCase.advice":`Advice & pricing`,"capability.text":`Writes text`,"capability.web":`Web search`,"capability.browser":`Drives a browser`,"capability.documents":`Reads documents & photos`,"capability.image":`Makes images`,"capability.video":`Makes video`,"capability.speech":`Speech output`,"capability.listening":`Understands voice notes`,"capability.code":`Runs code`,"capability.connectors":`Connected accounts & systems`,"capability.motion-graphics":`Motion graphics with Claude Code (on your subscription)`,"cost.low":`low cost`,"cost.medium":`medium cost`,"cost.high":`high cost`,"plan.free":`Free`,"plan.pro":`Pro`,"outline.otherwise":`otherwise`,"outline.and":`{first} and {second}`,"outline.with":`with {name}`,"outline.without":`without {name}`,"outline.contains":`{name} contains {value}`},vt={en:_t,de:{"format.text":`Text`,"format.document":`Dokument (PDF, Word)`,"format.table":`Tabelle`,"format.image":`Bild`,"format.video":`Video`,"format.audio":`Audio`,"format.dashboard":`Dashboard`,"industry.any":`Jede Branche`,"industry.trades":`Handwerk`,"industry.gastronomy":`Gastronomie`,"industry.hospitality":`Hotel & Tourismus`,"industry.realEstate":`Immobilien`,"industry.retail":`Handel`,"industry.health":`Gesundheit`,"industry.professional":`Kanzlei & Beratung`,"industry.agency":`Agentur & Marketing`,"industry.events":`Veranstaltungen`,"industry.publicSector":`Vereine & Öffentliches`,"useCase.marketing":`Marketing & Social Media`,"useCase.sales":`Angebote & Verkauf`,"useCase.accounting":`Buchhaltung & Belege`,"useCase.service":`Kundenservice`,"useCase.research":`Recherche & Analyse`,"useCase.hr":`Personal & Bewerbungen`,"useCase.operations":`Planung & Abläufe`,"useCase.website":`Helfer für die Website`,"useCase.visuals":`Bilder & Video`,"useCase.inquiries":`Anfragen & Termine`,"useCase.advice":`Beratung & Preise`,"capability.text":`Text schreiben`,"capability.web":`Websuche`,"capability.browser":`Browser bedienen`,"capability.documents":`Dokumente & Fotos lesen`,"capability.image":`Bilder erzeugen`,"capability.video":`Videos erzeugen`,"capability.speech":`Sprachausgabe`,"capability.listening":`Sprachnotizen verstehen`,"capability.code":`Code ausführen`,"capability.connectors":`Verbundene Konten & Systeme`,"capability.motion-graphics":`Motion-Grafik mit Claude Code (auf deinem Abo)`,"cost.low":`günstig`,"cost.medium":`mittel`,"cost.high":`teuer`,"plan.free":`Kostenlos`,"plan.pro":`Pro`,"outline.otherwise":`sonst`,"outline.and":`{first} und {second}`,"outline.with":`mit {name}`,"outline.without":`ohne {name}`,"outline.contains":`{name} enthält {value}`}};function yt(e,t,n,r){let i=`${e}.${t}`;return i in _t?be(vt,i,n,r):t}var V=t(n(),1);function bt(e){switch(e.type){case`page`:return de;case`agent`:return oe;case`generate`:return e.asset===`image`?A:e.asset===`video`?p:e.asset===`dashboard`?Be:O;case`widget`:return F;case`surface`:return He;case`motion-graphics`:return L;case`review`:return ue;case`wait`:return z;case`result`:return R}return v}var xt={page:`bg-cobalt-tint text-cobalt`,agent:`bg-ember-tint text-ember-strong`,generate:`bg-amber-tint text-ink-2`,widget:`bg-ember-veil text-ember-strong`,surface:`bg-ember-veil text-ember-strong`,"motion-graphics":`bg-amber-tint text-ink-2`,review:`bg-moss-tint text-moss`,wait:`bg-cobalt-tint text-cobalt`,result:`bg-paper-2 text-ink-2`},St={m:`wait.minutes`,h:`wait.hours`,d:`wait.days`};function Ct(e){let t=/^(\d+)([mhd])$/.exec(e.for??``);if(t)return t[0]===`1d`?P(`wait.day`):P(St[t[2]],{n:t[1]});let n=Date.parse(e.until??``),r=Number.isNaN(n)?e.until??``:new Intl.DateTimeFormat(N,{dateStyle:`medium`,timeStyle:`short`}).format(n);return P(`wait.until`,{date:r})}function wt(e){return P(`type.${e.type}`)}var Tt=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`,`pages`,`code`];function Et(e){return Tt.includes(e)?P(`tool.${e}`):e}function Dt(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:return e.tools.map(Et).join(` · `)||e.instructions.slice(0,90);case`generate`:{let t=[e.asset];return e.options?.aspectRatio&&t.push(e.options.aspectRatio),e.options?.duration&&t.push(`${e.options.duration}s`),e.options?.resolution&&t.push(e.options.resolution),e.options?.template&&t.push(e.options.template),t.join(` · `)}case`widget`:return[e.entry,Object.keys(e.data).join(`, `)].filter(Boolean).join(` · `);case`surface`:return e.candidates?e.candidates.map(e=>e.id).join(` · `):Object.keys(e.data).join(`, `);case`motion-graphics`:return[e.format,e.seconds?`${e.seconds}s`:null,e.skills.join(`, `)].filter(Boolean).join(` · `);case`review`:return[e.edit?P(`editor.reviewEditable`):null,e.regenerate?P(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`wait`:return Ct(e);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}var Ot=e({EntryDialog:()=>Q,MarketplaceBrowser:()=>Jt,MarketplaceCards:()=>qt,MarketplaceFit:()=>Kt,MarketplaceHits:()=>Wt,ProChip:()=>K,useFit:()=>Gt,useSettled:()=>$}),H=t(r(),1),kt=(0,V.lazy)(()=>ae(()=>import(`./FlowPreview-ykxZxWnk.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),At={useCase:``,industry:``,format:``,capability:``,plan:``},U=(e,t)=>yt(e,t,N),jt={en:ke,de:je};function Mt(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function Nt(e){return e.credits?P(`market.credits`,{n:Mt(e.credits.credits)}):U(`cost`,e.costTier)}var Pt={text:Ze,document:O,table:ie,image:A,video:p,audio:_,dashboard:I};function W({format:e,className:t}){let n=Pt[e],r=U(`format`,e);return(0,H.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,H.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var Ft=[`low`,`medium`,`high`];function G({entry:e}){let t=Ft.indexOf(e.costTier)+1,n=jt[N];return(0,H.jsxs)(`span`,{title:Nt(e),className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:Ft.slice(0,t).map((e,t)=>(0,H.jsx)(`span`,{className:b(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,H.jsx)(n,{className:`size-4`})},e))}),U(`cost`,e.costTier)]})}function K(){return(0,H.jsx)(C,{tone:`ember`,title:P(`market.proHint`),children:P(`market.pro`)})}function It({plugin:e}){return(0,H.jsx)(C,{icon:(0,H.jsx)(We,{className:`size-3.5`}),title:P(`market.fromPlugin`,{name:e.name}),children:e.name})}function q({entry:e,onOpen:t,why:n}){return(0,H.jsxs)(g,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:b(`relative flex min-h-[124px] cursor-pointer flex-col gap-5 p-4 text-left transition sm:min-h-[136px] sm:p-5 hover:shadow-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,(!e.usable||e.missing.length>0||!!e.needs?.length)&&`opacity-60`),children:[(0,H.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,H.jsx)(pe,{kind:e.avatar,costume:e.costume,size:68})}),(0,H.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,H.jsxs)(`div`,{className:`font-display font-semibold text-[0.9375rem]`,children:[e.title,e.plan===`pro`?(0,H.jsx)(`span`,{className:`ml-1.5 inline-flex align-middle`,children:(0,H.jsx)(K,{})}):null,e.starred?(0,H.jsx)(B,{className:`ml-1.5 inline size-3.5 fill-amber align-[-2px] text-amber`,"aria-label":P(`market.starred`)}):null]}),e.featured?(0,H.jsx)(`div`,{className:`mt-1`,children:(0,H.jsx)(C,{tone:`ember`,children:P(`market.recommended`)})}):null,(0,H.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,H.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:[n?(0,H.jsx)(C,{children:n}):null,e.plugin?(0,H.jsx)(It,{plugin:e.plugin}):null,e.needs?.length?(0,H.jsx)(C,{tone:`warn`,children:P(`market.needsPro`,{list:e.needs.join(`, `)})}):e.usable&&e.missing.length?(0,H.jsx)(C,{tone:`warn`,children:P(`market.missing`,{list:Y(e.missing)})}):e.usable?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,H.jsx)(o,{className:`size-3.5`}),` `,P(`market.minutes`,{n:e.effort.minutes})]}),(0,H.jsx)(G,{entry:e}),e.optional?.length?(0,H.jsx)(C,{title:P(`market.optionalHint`,{list:Y(e.optional)}),children:P(`market.without`,{list:Y(e.optional)})}):null,(0,H.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):(0,H.jsx)(C,{tone:`warn`,children:P(`market.needsUpdate`)})]})]})}function J({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Y=e=>e.map(e=>U(`capability`,e)).join(`, `),Lt={text:x,web:ce,browser:s,documents:Ke,image:A,video:p,speech:le,listening:a,code:Ye,connectors:se,"motion-graphics":L};function Rt(e){switch(e.type){case`page`:return de;case`agent`:return oe;case`generate`:return e.asset===`image`?A:e.asset===`video`?p:e.asset===`voice`?le:e.asset===`dashboard`?I:O;case`widget`:return e.video?L:F;case`surface`:return F;case`motion-graphics`:return L;case`review`:return ue;case`wait`:return z;case`result`:return R}return v}function zt(e){let t=new Set;for(let[n,r]of e.entries())for(let i of r.branches??[]){let r=i.to===`end`?e.length:e.findIndex(e=>e.id===i.to);for(let i=n+1;i<r;i++)t.add(e[i].id)}return t}function Bt(e){let t=zt(e);return e.map(e=>({id:e.id,title:e.title,icon:Rt(e),tone:xt[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function X({title:e,children:t}){return(0,H.jsx)(`span`,{title:e,className:`inline-flex items-center gap-2 border-border border-l px-4 first:border-l-0 first:pl-0`,children:t})}function Z({icon:e,children:t,more:n}){return(0,H.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,H.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function Vt({className:e,children:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)({above:!1,below:!1});(0,V.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let t=e.scrollTop>1,n=e.scrollTop+e.clientHeight<e.scrollHeight-1;i(e=>e.above===t&&e.below===n?e:{above:t,below:n})};t(),e.addEventListener(`scroll`,t,{passive:!0});let r=new ResizeObserver(t);return r.observe(e),e.firstElementChild&&r.observe(e.firstElementChild),()=>{e.removeEventListener(`scroll`,t),r.disconnect()}},[]);let a=`linear-gradient(to bottom, ${r.above?`transparent`:`black`} 0, black 28px, black calc(100% - 44px), ${r.below?`transparent`:`black`} 100%)`;return(0,H.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,H.jsx)(`div`,{children:t})})}function Q({id:e,fallback:t,onClose:n,onUse:r,busy:a}){let s=u(),l=S(),d=y({queryKey:[`marketplace-entry`,e,N],queryFn:()=>c.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${N}`),enabled:!!e,retry:!1}),f=d.data??t,p=T({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?c.put(n):c.del(n)},onSuccess:()=>Promise.all([s.invalidateQueries({queryKey:[`marketplace`]}),s.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),m=fe()===`dark`,h=_e[ge[f?.avatar||`round`]],g=m?`var(--card)`:`color-mix(in oklch, ${h??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,H.jsx)(te,{open:!!e,onClose:n,wide:!0,bare:!0,children:f?(0,H.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-48px)] flex-col rounded-2xl bg-card shadow-overlay max-sm:h-dvh max-sm:max-h-none max-sm:rounded-none`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":P(`common.close`),onClick:n,className:`sm:-top-3.5 sm:-right-3.5 absolute top-3 right-3 z-20 flex size-9 items-center justify-center rounded-full bg-card text-ink-2 shadow-elevated ring-1 ring-border-soft transition hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,children:(0,H.jsx)(D,{className:`size-4`})}),(0,H.jsxs)(`header`,{className:`relative shrink-0 border-border-soft border-b px-5 pt-5 pb-4 text-ink sm:rounded-t-2xl sm:px-7`,style:{background:g,"--coin-bg":g},children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,H.jsx)(`span`,{className:b(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,m?`opacity-[0.14]`:`opacity-80`)})}),(0,H.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,H.jsx)(pe,{kind:f.avatar,costume:f.costume,size:104})}),(0,H.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:f.title}),(0,H.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:d.data?.description||f.pitch})]}),f.usable?(0,H.jsxs)(`div`,{className:`-mx-5 sm:-mx-7 relative mt-3.5 flex flex-wrap items-center gap-y-2 border-border-soft border-t px-5 pt-3 font-medium text-[0.875rem] sm:px-7 sm:pr-40`,children:[(0,H.jsxs)(X,{title:P(`market.duration`),children:[(0,H.jsx)(o,{className:`size-4 text-ink-3`}),P(`market.minutes`,{n:f.effort.minutes})]}),(0,H.jsx)(X,{title:P(`market.cost`),children:(0,H.jsx)(G,{entry:f})}),(0,H.jsx)(X,{title:P(`market.result`),children:f.formats.map(e=>(0,H.jsx)(W,{format:e,className:`size-4`},e))})]}):null]}),f.usable?(0,H.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-7 gap-y-6 px-5 pt-6 max-sm:overflow-y-auto max-sm:pb-4 sm:grid-cols-[230px_minmax(0,1fr)] sm:grid-rows-[minmax(0,1fr)] sm:px-7`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,H.jsx)(J,{title:P(`market.duration`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(o,{className:`size-4 text-moss`}),more:P(`market.durationHint`,{n:f.effort.fields}),children:P(`market.minutes`,{n:f.effort.minutes})})}),(0,H.jsx)(J,{title:P(`market.cost`),children:(0,H.jsx)(Z,{icon:(0,H.jsx)(Ie,{className:`size-4 text-amber`}),more:f.credits?P(`market.creditsHint`):void 0,children:(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,H.jsx)(G,{entry:f}),f.credits?(0,H.jsx)(`span`,{className:`text-ink-2`,children:P(`market.creditsRange`,{n:Mt(f.credits.credits)})}):null]})})}),(0,H.jsx)(J,{title:P(`market.result`),children:(0,H.jsx)(`div`,{className:`flex flex-col gap-2`,children:(d.data?.results??[]).map(e=>(0,H.jsx)(Z,{icon:(0,H.jsx)(W,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,H.jsx)(J,{title:P(`market.needs`),children:(0,H.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.capabilities.map(e=>{let t=Lt[e],n=f.missing.includes(e),r=f.optional?.includes(e);return(0,H.jsxs)(`li`,{className:b(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,H.jsx)(t,{className:b(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),U(`capability`,e),n?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:P(`market.unavailable`)}):r?(0,H.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:P(`market.optional`)}):null]},e)})})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,H.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:P(`market.steps`)}),(0,H.jsx)(Vt,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:d.isLoading?(0,H.jsx)(w,{className:`size-5 text-ink-3`}):(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(w,{className:`size-5 text-ink-3`}),children:(0,H.jsx)(kt,{steps:Bt(d.data?.outline??[])})})})]})]}):(0,H.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,H.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:P(`market.needsUpdateHint`)})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 px-5 pt-4 pb-5 max-sm:border-border-soft max-sm:border-t sm:px-7 sm:pb-6`,children:[f.plugin?(0,H.jsx)(`span`,{className:`mr-auto flex items-center`,children:(0,H.jsx)(It,{plugin:f.plugin})}):(0,H.jsxs)(i,{variant:`ghost`,className:`mr-auto`,title:P(`market.starHint`),"aria-pressed":f.starred,busy:p.isPending,onClick:()=>p.mutate(!f.starred),children:[(0,H.jsx)(B,{className:b(`size-4`,f.starred&&`fill-amber text-amber`)}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:P(f.starred?`market.starred`:`market.star`)})]}),(0,H.jsx)(i,{variant:`secondary`,onClick:n,children:P(`common.close`)}),f.usable&&f.missing.length?(0,H.jsx)(i,{variant:`secondary`,onClick:()=>l(`/settings/models`),children:P(`editor.models.settings`)}):null,r?(0,H.jsx)(i,{disabled:!f.usable||f.missing.length>0||!!f.needs?.length,title:f.needs?.length?P(`market.needsProHint`,{list:f.needs.join(`, `)}):f.missing.length?P(`market.missingHint`,{list:Y(f.missing)}):f.optional?.length?P(`market.optionalHint`,{list:Y(f.optional)}):void 0,busy:a,onClick:()=>r(f),children:P(`market.use`)}):null]})]}):(0,H.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[0.875rem] text-ink-2 shadow-overlay`,children:d.isLoading?(0,H.jsx)(w,{className:`size-6 text-ink-3`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{children:P(`market.notFound`)}),(0,H.jsx)(i,{variant:`secondary`,onClick:n,children:P(`common.close`)})]})})})}function Ht({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,V.useState)(!1),o=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=n.find(e=>e.value===t);return(0,H.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,H.jsxs)(`div`,{className:b(`flex h-8 items-center rounded-full text-[0.8125rem] transition`,s?`bg-ember-tint text-ink`:`text-ink-2 hover:bg-paper-2 hover:text-ink`,i&&!s&&`bg-paper-2 text-ink`),children:[(0,H.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:b(`flex h-full items-center gap-1.5 rounded-full pl-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,s?`pr-1`:`pr-2.5`),children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,H.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,H.jsxs)(H.Fragment,{children:[e,(0,H.jsx)(f,{className:b(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,H.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${P(`market.reset`)}`,onClick:()=>r(``),className:`mr-1 flex size-6 items-center justify-center rounded-full text-ink-3 hover:bg-card hover:text-ink`,children:(0,H.jsx)(D,{className:`size-3.5`})}):null]}),i?(0,H.jsx)(`div`,{role:`listbox`,"aria-label":e,className:`absolute top-full left-0 z-30 mt-1.5 max-h-80 min-w-60 overflow-y-auto rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:n.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.value===t,disabled:!e.count||e.unavailable,onClick:()=>{r(e.value===t?``:e.value),a(!1)},className:b(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[0.875rem] transition coarse:py-2.5`,e.count&&!e.unavailable?`text-ink-2 hover:bg-paper-2 hover:text-ink`:`text-ink-4`,e.value===t&&`font-medium text-ink`),children:[e.icon,(0,H.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,H.jsx)(k,{className:`size-4 text-ember`}):e.unavailable?(0,H.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:P(`market.unavailable`)}):(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function $(e,t){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ut=60;function Wt({query:e,onUse:t,busy:n,limit:r=6}){let[i,a]=(0,V.useState)(null),o=$(e.trim(),250),s=y({queryKey:[`marketplace`,N,o,`hits`,r],queryFn:()=>c.get(`/api/studio/marketplace?${new URLSearchParams({lang:N,limit:String(r),offset:`0`,q:o})}`),enabled:!!o,placeholderData:ee}),l=o?s.data?.entries??[]:[];return l.length?(0,H.jsxs)(`section`,{className:`mt-10`,children:[(0,H.jsxs)(`h2`,{className:`mb-5 flex items-center gap-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:[P(`market.hits`),s.isFetching?(0,H.jsx)(w,{className:`size-3.5`}):null]}),(0,H.jsx)(`div`,{className:`flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>a(e.id)},e.id))}),(0,H.jsx)(Q,{id:i,fallback:l.find(e=>e.id===i)??null,onClose:()=>a(null),onUse:t,busy:n})]}):null}function Gt(){let e=y({queryKey:[`marketplace`,N,`fit`],queryFn:()=>c.get(`/api/studio/marketplace?${new URLSearchParams({lang:N,limit:`12`,offset:`0`,fit:`1`})}`)});return e.data?.context&&e.data.entries.some(e=>e.fit)?e.data:null}function Kt({page:e,organization:t,onUse:n,busy:r,onAll:a}){let[o,s]=(0,V.useState)(null),c=e.context??{sector:null,sectorName:null},l=e.entries,u=e=>e.fit===`sector`||e.fit===`industry`?c.sectorName:e.fit===`wish`?P(`market.fitWish`):null;return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h2`,{className:`mt-16 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:P(`market.fitTitle`,{organization:t})}),(0,H.jsx)(`p`,{className:`mt-2 mb-5 text-center text-[0.875rem] text-ink-3`,children:c.sectorName?P(`market.fitLine`,{sector:c.sectorName}):P(`market.fitLinePlain`)}),(0,H.jsx)(`div`,{className:`flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:l.map((e,t)=>(0,H.jsx)(`div`,{className:b(`contents`,t>=4&&`max-sm:hidden`,t>=8&&`sm:max-lg:hidden`),children:(0,H.jsx)(q,{entry:e,why:u(e),onOpen:()=>s(e.id)})},e.id))}),(0,H.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,H.jsx)(i,{variant:`secondary`,onClick:a,children:P(`market.fitAll`,{n:e.all||e.total})})}),(0,H.jsx)(Q,{id:o,fallback:l.find(e=>e.id===o)??null,onClose:()=>s(null),onUse:n,busy:r})]})}function qt({entries:e}){let t=u(),n=S(),{space:r}=he(),i=me()&&!!r&&!r?.readOnly,[a,o]=(0,V.useState)(null),s=T({mutationFn:e=>c.post(`/api/studio/wizards`,{spaceId:r.id,starterId:e,lang:N}),onSuccess:async({id:e})=>{await t.invalidateQueries({queryKey:d.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),o(null),n(`/edit/${e}`)}});return(0,H.jsxs)(`div`,{className:`@container mt-3`,children:[(0,H.jsx)(`div`,{className:`flex flex-col gap-4 @xl:grid @xl:grid-cols-2`,children:e.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>o(e.id)},e.id))}),s.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:s.error.message}):null,(0,H.jsx)(Q,{id:a,fallback:e.find(e=>e.id===a)??null,onClose:()=>o(null),onUse:i?e=>!s.isPending&&s.mutate(e.id):void 0,busy:s.isPending})]})}function Jt({onUse:e,busy:t,open:n,search:r,onGuestOpen:a}){let[o,s]=(0,V.useState)(``);(0,V.useEffect)(()=>{r&&s(r.text)},[r]);let[u,d]=(0,V.useState)(At),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(n??null),g=$(o.trim(),250),_=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=_.current;g&&e&&window.matchMedia(`(max-width: 639px)`).matches&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[g]);let v=Te({queryKey:[`marketplace`,N,g,u,f],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:N,limit:String(Ut),offset:String(e)});g&&t.set(`q`,g);for(let[e,n]of Object.entries(u))n&&t.set(e,n);return f&&t.set(`starred`,`1`),c.get(`/api/${a?`guest`:`studio`}/marketplace?${t}`)},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.entries.length,0);return n<e.total?n:void 0},placeholderData:ee}),y=v.data?.pages[0],x=v.data?.pages.flatMap(e=>e.entries)??[],S=y?.all??0,te=o.trim()!==g||v.isFetching&&!v.isFetchingNextPage,C=(e,t,n,r)=>n.filter(t=>y?.facets[e]?.[t]!==void 0).map(n=>({value:n,label:U(t,n),icon:r?.(n),count:(y?.facets[e])[n]??0,unavailable:e===`capability`&&ne.has(n)})),ne=new Set(y?.unavailable??[]),re=C(`useCase`,`useCase`,ht),ie=[{key:`industry`,name:P(`market.industry`),options:C(`industry`,`industry`,mt)},{key:`format`,name:P(`market.format`),options:C(`format`,`format`,pt,e=>(0,H.jsx)(W,{format:e,className:`size-4 text-ink-3`}))},{key:`plan`,name:P(`market.plan`),options:C(`plan`,`plan`,gt)},{key:`capability`,name:P(`market.capability`),options:C(`capability`,`capability`,Qe,e=>{let t=Lt[e];return(0,H.jsx)(t,{className:`size-4 text-ink-3`})})}],T=!!o.trim()||f||Object.values(u).some(Boolean),ae=()=>{d(At),s(``),p(!1)};if(v.isLoading)return(0,H.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,H.jsx)(w,{className:`size-6 text-ink-3`})});let E=y?.offline?(0,H.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(Pe,{className:`size-4 shrink-0`}),P(`market.offline`)]}):null;if(!S&&!T)return E;let O=o?(0,H.jsx)(`button`,{type:`button`,"aria-label":P(`market.reset`),onClick:()=>s(``),className:`-mr-1.5 flex size-7 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-2 hover:text-ink`,children:(0,H.jsx)(D,{className:`size-4`})}):null,k=e=>b(`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-full px-2.5 text-[0.78125rem] transition`,e?`bg-card font-medium text-ink shadow-soft ring-1 ring-border-soft`:`text-ink-3 hover:bg-card/60 hover:text-ink`);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{ref:_,className:`relative mx-auto flex h-10 max-w-md scroll-mt-4 items-center gap-2.5 rounded-full bg-card px-4 shadow-soft ring-1 ring-border-soft transition focus-within:ring-2 focus-within:ring-focus sm:h-11`,children:[te?(0,H.jsx)(w,{className:`size-4 shrink-0 text-ink-3`}):(0,H.jsx)(l,{className:`size-4 shrink-0 text-ink-3`}),(0,H.jsx)(`input`,{type:`search`,value:o,onChange:e=>s(e.target.value),placeholder:P(`market.search`),"aria-label":P(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),O]}),E,(0,H.jsxs)(`div`,{className:`max-sm:-mx-3 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-3 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:P(`market.all`)},...re].map(e=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!f&&u.useCase===e.value,onClick:()=>{p(!1),d({...u,useCase:e.value})},className:k(!f&&u.useCase===e.value),children:e.label},e.value)),a?null:(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(!f),className:k(f),children:[(0,H.jsx)(B,{className:b(`size-3.5`,f&&`fill-amber text-amber`)}),P(`market.starred`)]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[f?null:ie.map(e=>(0,H.jsx)(Ht,{name:e.name,value:u[e.key],options:e.options,onChange:t=>d({...u,[e.key]:t})},e.key)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[T?(0,H.jsxs)(`button`,{type:`button`,onClick:ae,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,H.jsx)(D,{className:`size-3.5 max-sm:size-4`}),(0,H.jsx)(`span`,{className:`max-sm:sr-only`,children:P(`market.resetShort`)})]}):null,T?(0,H.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:P(`market.countOfShort`,{n:y?.total??0,all:S})}):null,(0,H.jsx)(`span`,{className:b(`tabular-nums`,T&&`max-sm:hidden`),children:T?P(`market.countOf`,{n:y?.total??0,all:S}):P(`market.count`,{n:S})})]})]}),x.length?(0,H.jsx)(`div`,{className:`mt-4 flex flex-col gap-4 sm:grid sm:grid-cols-2 lg:grid-cols-3`,children:x.map(e=>(0,H.jsx)(q,{entry:e,onOpen:()=>a?a(e):h(e.id)},e.id))}):(0,H.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,H.jsx)(`p`,{children:P(f?`market.noneStarred`:`market.none`)}),(0,H.jsx)(i,{variant:`ghost`,className:`mt-2`,onClick:ae,children:P(`market.reset`)})]}),v.hasNextPage?(0,H.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,H.jsx)(i,{variant:`secondary`,busy:v.isFetchingNextPage,onClick:()=>void v.fetchNextPage(),children:P(`market.more`)})}):null,(0,H.jsx)(Q,{id:m,fallback:x.find(e=>e.id===m)??null,onClose:()=>h(null),onUse:e,busy:t})]})}export{R as C,I as D,L as E,F as O,z as S,Pe as T,Ze as _,Ot as a,He as b,$ as c,Dt as d,Et as f,lt as g,ct as h,Wt as i,Te as k,xt as l,yt as m,Jt as n,K as o,wt as p,Kt as r,Gt as s,Q as t,bt as u,B as v,Ie as w,Be as x,We as y};
@@ -1,7 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Kt as i,Q as a,Vr as o,X as s,c,cr as l,d as u,f as d,gr as f,hn as p,jr as m,l as h,lr as g,mn as _,mr as v,nn as y,nr as ee,o as te,p as ne,pt as b,tn as x,u as re}from"./ui-BacfkQ7Q.js";import{c as ie,n as ae,o as S,r as oe,s as se,t as C}from"./Marketplace-C97fH7UC.js";import{t as w}from"./useMutation-CgzFr4qH.js";import{i as ce}from"./marked.esm-DQ7XA7AC.js";import{on as le,pn as ue}from"./host-CCijW1hj.js";import{S as de,h as fe,i as T,m as E,t as pe,u as D}from"./session-CEJRkSP5.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-DCPDesT-.js";import{a as me,c as j,i as he,l as ge}from"./NewWizardChannels-CsSV7sm2.js";var M=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function N(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function P(e){return N(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function F(e){return e==null?``:Array.isArray(e)?e.map(F).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(F).filter(Boolean).join(` `):String(e)}function I(e,t){let n=t.map(([t,n])=>({text:F(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>P(e.text))}}function L(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function R(e,t){if(e===t)return 1;let n=0;for(let r of L(e))for(let i of L(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function z(e,t){return e.reduce((e,n)=>e+R(t,n),0)}function B(e,t,n=M){if(!t?.trim())return 0;let r=P(t);if(r.length===0)return 0;let i=I(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>z(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=P(n.text),i=z(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var V=new Set(P(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
2
- des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
3
- habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
4
- meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
5
- sucht um und uns unser unsere vom von vor was wie will wir wird wo wollen zu zum zur
6
- a about an and are as at be can do for from have how i in is it like looking me my need of on
7
- or our that the this to want we what which who with would you your`)),H=e=>e.replace(/ß/g,`ss`);function U(e){let t=P(H(e)),n=t.filter(e=>!V.has(e));return n.length?n:t}var _e=e=>e.trim().split(/\s+/).filter(Boolean).length>=3,W=e(t(),1),G=e(n(),1);function ve({variant:e=`secondary`,label:t=A(`home.import`)}){let n=v(),c=o(),{space:l}=D(),u=E(),d=(0,W.useRef)(null),f=w({mutationFn:e=>a.upload(`/api/studio/spaces/${l.id}/wizards/import`,e),onSuccess:async({id:e})=>{await c.invalidateQueries({queryKey:s.spaces()}),await c.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),p=f.error instanceof i?f.error.body?.issues??[]:[];return!u||l?.readOnly?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(r,{variant:e,busy:f.isPending,disabled:!l,onClick:()=>d.current?.click(),children:[(0,G.jsx)(O,{className:`size-4`}),` `,t]}),(0,G.jsx)(`input`,{ref:d,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&f.mutate(t)}}),(0,G.jsxs)(y,{open:f.isError,onClose:f.reset,title:A(`import.failed`),children:[(0,G.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:f.error?.message}),p.length?(0,G.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:p.slice(0,8).map(e=>(0,G.jsx)(`li`,{children:e.message},e.message))}):null,(0,G.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,G.jsx)(r,{variant:`secondary`,onClick:f.reset,children:A(`common.close`)})})]})]})}var K=10,q=3;async function ye(e,t){let n=await fetch(b(`/api/studio/wizards/${e}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`,"accept-language":k},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function J(e,t){let n=U(t);if(!n.length)return[];let r=e.map(e=>({w:e,score:B({title:e.title,summary:e.description},n.join(` `),[[`title`,10],[`summary`,6]])})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score),i=_e(t)?(r[0]?.score??0)*.4:0;return r.filter(e=>e.score>=i).slice(0,q).map(e=>e.w)}function be({wish:e,spaceId:t,busy:n,onTake:i,onMore:o}){let s=v(),[c,l]=(0,W.useState)(null),u=ie(e.trim(),300),d=f({queryKey:[`wizards`,t,`similar`],queryFn:()=>a.get(`/api/studio/spaces/${t}/wizards`)}),p=f({queryKey:[`marketplace`,k,u,`similar`],queryFn:()=>a.get(`/api/studio/marketplace?${new URLSearchParams({lang:k,limit:String(K),offset:`0`,q:u})}`),enabled:u.length>=3,placeholderData:m});if(u.length<3)return null;let h=J(d.data??[],u),g=(p.data?.entries??[]).slice(0,K-h.length),_=(p.data?.total??0)-g.length;if(!(h.length||g.length))return null;let y=`flex items-center gap-3 rounded-xl bg-card py-2 pr-2 pl-3.5 ring-1 ring-border-soft`;return(0,G.jsxs)(`section`,{className:`mt-5`,children:[(0,G.jsx)(`h2`,{className:`mb-2 px-1 text-[0.8125rem] text-ink-3`,children:A(`new.similar`)}),(0,G.jsxs)(`ul`,{className:`flex flex-col gap-1.5`,children:[h.map(e=>(0,G.jsxs)(`li`,{className:y,children:[(0,G.jsx)(x,{children:A(`new.yours`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(`/edit/${e.id}`),className:`min-w-0 flex-1 text-left`,children:[(0,G.jsx)(`span`,{className:`block truncate font-medium text-[0.9375rem]`,children:e.title}),(0,G.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.description})]}),(0,G.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>s(`/edit/${e.id}`),children:A(`new.open`)})]},e.id)),g.map(e=>(0,G.jsxs)(`li`,{className:y,children:[(0,G.jsx)(x,{children:A(`new.template`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),className:`min-w-0 flex-1 text-left`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.title}),e.plan===`pro`?(0,G.jsx)(S,{}):null]}),(0,G.jsx)(`span`,{className:`block truncate text-[0.8125rem] text-ink-3`,children:e.pitch})]}),(0,G.jsx)(r,{variant:`secondary`,size:`sm`,disabled:n,onClick:()=>i(e),children:A(`new.take`)})]},e.id))]}),_>0?(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(u),className:`mt-2 px-1 text-[0.875rem] text-ink-2 hover:text-ink coarse:min-h-11`,children:A(`new.more`,{n:_})}):null,(0,G.jsx)(C,{id:c,fallback:g.find(e=>e.id===c)??null,onClose:()=>l(null),onUse:i,busy:n})]})}function Y(){le({ownInput:!0});let e=v(),t=o(),{space:n}=D(),i=E(),m=ue(`workMode`),y=fe(),b=se(),[x,ie]=(0,W.useState)(!1),[S]=l(),[C,O]=(0,W.useState)(()=>S.get(`wish`)??T()??``),M=(0,W.useRef)(T()!==null),[N,P]=(0,W.useState)([`steps`]),[F,I]=(0,W.useState)([]),[L,R]=(0,W.useState)(!1),[z,B]=(0,W.useState)(null),V=(0,W.useRef)(null),H=(0,W.useRef)(null),U=(0,W.useRef)(null),[_e]=ne(),K=d(C,O,{deviceId:_e.deviceId}),q=f({queryKey:[`runners`],queryFn:()=>a.get(`/api/studio/runners`)}),J=e=>{let t=e.map(h);I(e=>[...e.filter(e=>!t.some(t=>t.name===e.name)),...t])},[Y,xe]=(0,W.useState)(new Map),[Se,X]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=new Map(F.map(e=>[e,URL.createObjectURL(e)]));return xe(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[F]);let Z=F.map(e=>({name:e.name,mime:e.type,size:e.size,url:Y.get(e)})),Q=w({mutationFn:e=>a.post(`/api/studio/wizards`,{spaceId:n.id,starterId:e,lang:k}),onSuccess:async({id:n})=>{await t.invalidateQueries({queryKey:s.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]}),e(`/edit/${n}`)}}),$=w({mutationFn:async()=>{let e=U.current??(await a.post(`/api/studio/wizards`,{spaceId:n.id,lang:k})).id;U.current=e,j(N)||await a.patch(`/api/studio/wizards/${e}`,{runners:ge(N)});for(let t of F)await ye(e,t);return e},onSuccess:async n=>{pe(),await t.invalidateQueries({queryKey:s.spaces()}),await t.invalidateQueries({queryKey:[`wizards`]});let r=C.trim();j(N)||(r+=`\n\n${me(N)}`),F.length&&(r+=`\n\n${A(`editor.attached`)}: ${F.map(e=>e.name).join(`, `)}`),e(`/edit/${n}?prompt=${encodeURIComponent(r)}`)}}),Ce=()=>{C.trim()&&n&&!$.isPending&&(K.listening&&K.stop(),$.mutate())};if((0,W.useEffect)(()=>{M.current&&n&&i&&!n.readOnly&&C.trim()&&(M.current=!1,$.mutate())},[n,i,C,$]),!i||n?.readOnly)return(0,G.jsx)(g,{to:`/`,replace:!0});let we=$.error??Q.error;return(0,G.jsxs)(`div`,{className:`animate-rise md:pt-4`,children:[(0,G.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsx)(`div`,{className:`size-[84px] md:size-auto`,children:(0,G.jsx)(`div`,{className:`origin-top-left scale-[0.56] md:scale-100`,children:(0,G.jsx)(de,{kind:`sprout`,size:150,fluffy:!0})})}),(0,G.jsx)(`h1`,{className:`mt-1 font-display font-semibold text-[1.5rem] leading-tight tracking-tight md:mt-2 md:text-[2.375rem]`,children:A(`new.title`)}),m?(0,G.jsx)(`p`,{className:`mt-2 max-w-lg text-[0.9375rem] text-ink-3 leading-relaxed`,children:A(`new.studioHint`)}):null]}),(0,G.jsx)(he,{value:N,onChange:P,runners:q.data,className:`mt-4 px-1 md:mt-8`}),(0,G.jsxs)(`div`,{className:p(`relative mt-3 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,L&&`ring-2 ring-focus`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),R(!0))},onDragLeave:()=>R(!1),onDrop:e=>{e.preventDefault(),R(!1),J(Array.from(e.dataTransfer.files).map(c))},children:[F.length?(0,G.jsx)(`ul`,{className:`flex flex-wrap gap-2 px-2 pt-2 pb-1`,children:Z.map((e,t)=>(0,G.jsx)(u,{file:e,onOpen:()=>X(t),onRemove:()=>I(e=>e.filter((e,n)=>n!==t))},`${e.name}-${t}`))}):null,(0,G.jsx)(re,{files:Z,at:Se,onAt:X}),(0,G.jsx)(_,{autoFocus:!0,minRows:4,value:C,onChange:e=>O(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),J(t.map(c)))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&Ce()},placeholder:K.listening?A(`editor.listening`):A(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,G.jsxs)(`div`,{className:`@container flex items-center gap-2 px-1 pb-1`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":A(`editor.attach`),title:A(`editor.attach`),onClick:()=>H.current?.click(),className:`inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-border text-ink transition hover:bg-paper-2 coarse:size-11`,children:(0,G.jsx)(ce,{className:`size-4`})}),(0,G.jsx)(`input`,{ref:H,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,J(t)}}),K.supported?(0,G.jsx)(te,{speech:K,labelled:!0}):null,(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.75rem] text-ink-4`,children:L?A(`new.dropHint`):null}),(0,G.jsxs)(r,{size:`md`,onClick:Ce,busy:$.isPending,disabled:!C.trim()||Q.isPending,children:[A(`new.build`),` `,(0,G.jsx)(ee,{className:`size-4`})]})]})]}),(0,G.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-ink-3`,children:A(`new.hint`)}),K.error?(0,G.jsx)(`p`,{className:`mt-2 px-3 text-[0.75rem] text-rose`,children:K.error===`denied`?A(`editor.micDenied`):K.error}):null,we?(0,G.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:we.message}):null,n?(0,G.jsx)(be,{wish:C,spaceId:n.id,busy:Q.isPending||$.isPending,onTake:e=>!Q.isPending&&Q.mutate(e.id),onMore:e=>{B({text:e}),V.current?.scrollIntoView({behavior:`smooth`,block:`start`})}}):null]}),b&&!x?(0,G.jsx)(`div`,{className:`mx-auto max-w-5xl`,children:(0,G.jsx)(oe,{page:b,organization:y.data?.tenant.name??``,busy:Q.isPending,onUse:e=>n&&!Q.isPending&&Q.mutate(e.id),onAll:()=>ie(!0)})}):null,(0,G.jsxs)(`section`,{ref:V,className:p(`mx-auto max-w-5xl scroll-mt-6`,b&&!x&&!z&&`hidden`),children:[(0,G.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.08em]`,children:A(`new.orStarter`)}),(0,G.jsx)(ae,{open:S.get(`starter`),search:z,busy:Q.isPending,onUse:e=>n&&!Q.isPending&&Q.mutate(e.id)})]}),(0,G.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,G.jsx)(ve,{variant:`ghost`,label:A(`new.import`)})})]})}export{Y as NewWizardPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Q as r,Vr as i,X as a,cr as o,f as s,gr as ee,hn as c,mr as te,nr as l,o as u,p as d}from"./ui-BacfkQ7Q.js";import{t as f}from"./useMutation-CgzFr4qH.js";import{s as ne,u as p}from"./marked.esm-DQ7XA7AC.js";import{S as re,T as m,_ as h,h as ie,i as ae,n as g,u as oe}from"./session-CEJRkSP5.js";import{t as se}from"./upload-CAlHC232.js";import{t as _}from"./logo-BpnjXTRy.js";import{n as v,s as y}from"./i18n-DCPDesT-.js";import{r as ce}from"./LangSwitch-iO54w9AP.js";var b=new Set([`gmail.com`,`googlemail.com`,`gmx.at`,`gmx.de`,`gmx.net`,`web.de`,`outlook.com`,`hotmail.com`,`live.com`,`icloud.com`,`me.com`,`yahoo.com`,`yahoo.de`,`aon.at`,`a1.net`,`chello.at`,`t-online.de`,`proton.me`,`protonmail.com`]),le={website:`Website`,blog:`Blog`,linkedin:`LinkedIn`,instagram:`Instagram`,facebook:`Facebook`,youtube:`YouTube`,x:`X`,xing:`XING`,tiktok:`TikTok`},ue=[[`linkedin`,/(^|\.)linkedin\.com$/],[`instagram`,/(^|\.)instagram\.com$/],[`facebook`,/(^|\.)(facebook|fb)\.com$/],[`youtube`,/(^|\.)(youtube\.com|youtu\.be)$/],[`x`,/(^|\.)(x|twitter)\.com$/],[`xing`,/(^|\.)xing\.com$/],[`tiktok`,/(^|\.)tiktok\.com$/]];function de(e){let t=e.trim();if(!t||/\s/.test(t))return null;try{let e=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);return e.hostname.includes(`.`)?e.href:null}catch{return null}}function fe(e){let t=de(e);if(!t)return`website`;let{hostname:n,pathname:r}=new URL(t),i=n.toLowerCase().replace(/^www\./,``);for(let[e,t]of ue)if(t.test(i))return e;return/^blog\./.test(i)||/^\/blog(\/|$)/.test(r)||/(^|\.)(medium|substack)\.com$/.test(i)?`blog`:`website`}var x=[{id:`bakeries`,industry:`gastronomy`,name:{de:`Bäckereien`,en:`Bakeries`},words:[`bäckerei`,`bäcker`,`backstube`,`brot`,`gebäck`,`konditorei`,`bakery`,`bread`,`pastry`]},{id:`cafes`,industry:`gastronomy`,name:{de:`Cafés`,en:`Cafés`},words:[`café`,`cafe`,`kaffeehaus`,`kaffee`,`coffee`,`espresso`]},{id:`restaurants`,industry:`gastronomy`,name:{de:`Restaurants`,en:`Restaurants`},words:[`restaurant`,`gasthaus`,`gasthof`,`wirtshaus`,`pizzeria`,`küche`,`speisekarte`,`menu`,`bistro`]},{id:`hotels`,industry:`hospitality`,name:{de:`Hotels und Pensionen`,en:`Hotels and guesthouses`},words:[`hotel`,`pension`,`zimmer`,`übernachtung`,`ferienwohnung`,`guesthouse`,`booking`,`rooms`]},{id:`architects`,industry:`professional`,name:{de:`Architekturbüros`,en:`Architects`},words:[`architekt`,`architektur`,`planung`,`entwurf`,`architect`,`architecture`]},{id:`lawFirms`,industry:`professional`,name:{de:`Kanzleien`,en:`Law firms`},words:[`rechtsanwalt`,`anwalt`,`kanzlei`,`recht`,`notar`,`law firm`,`lawyer`,`attorney`,`legal`]},{id:`taxAdvisors`,industry:`professional`,name:{de:`Steuerberatung`,en:`Tax advisors`},words:[`steuerberatung`,`steuerberater`,`steuer`,`buchhaltung`,`lohnverrechnung`,`bilanz`,`tax`,`accounting`,`bookkeeping`]},{id:`consultants`,industry:`professional`,name:{de:`Beratung`,en:`Consultants`},words:[`beratung`,`berater`,`consulting`,`coaching`,`consultant`]},{id:`physiotherapy`,industry:`health`,name:{de:`Physiotherapie`,en:`Physiotherapy`},words:[`physiotherapie`,`physio`,`massage`,`therapie`,`physiotherapy`]},{id:`practices`,industry:`health`,name:{de:`Arztpraxen`,en:`Doctors’ practices`},words:[`arzt`,`ärztin`,`praxis`,`ordination`,`zahnarzt`,`doctor`,`clinic`,`dentist`]},{id:`hairdressers`,industry:`retail`,name:{de:`Friseur und Kosmetik`,en:`Hair and beauty`},words:[`friseur`,`frisör`,`kosmetik`,`nagelstudio`,`beauty`,`hairdresser`,`salon`]},{id:`joiners`,industry:`trades`,name:{de:`Tischlereien`,en:`Joiners`},words:[`tischlerei`,`tischler`,`schreiner`,`möbel`,`holz`,`joinery`,`carpenter`,`furniture`]},{id:`electricians`,industry:`trades`,name:{de:`Elektrotechnik`,en:`Electricians`},words:[`elektriker`,`elektro`,`elektrotechnik`,`photovoltaik`,`electrician`,`electrical`]},{id:`plumbing`,industry:`trades`,name:{de:`Installateure`,en:`Plumbing and heating`},words:[`installateur`,`sanitär`,`heizung`,`klima`,`plumber`,`plumbing`,`heating`]},{id:`windows`,industry:`trades`,name:{de:`Fensterbau`,en:`Window makers`},words:[`fenster`,`türen`,`fensterbau`,`sonnenschutz`,`windows`,`doors`]},{id:`construction`,industry:`trades`,name:{de:`Bau und Handwerk`,en:`Building and trades`},words:[`bau`,`baumeister`,`maler`,`dachdecker`,`handwerk`,`construction`,`builder`,`painter`,`roofer`]},{id:`realEstate`,industry:`realEstate`,name:{de:`Immobilien`,en:`Real estate`},words:[`immobilien`,`makler`,`wohnung`,`miete`,`hausverwaltung`,`real estate`,`property`,`estate agent`]},{id:`onlineShops`,industry:`retail`,name:{de:`Online-Shops`,en:`Online shops`},words:[`online-shop`,`onlineshop`,`shop`,`versand`,`e-commerce`,`webshop`,`online store`]},{id:`retail`,industry:`retail`,name:{de:`Handel`,en:`Retail`},words:[`geschäft`,`handel`,`laden`,`boutique`,`retail`,`store`]},{id:`agencies`,industry:`agency`,name:{de:`Agenturen`,en:`Agencies`},words:[`agentur`,`werbung`,`marketing`,`design`,`kommunikation`,`agency`,`advertising`,`branding`]},{id:`photographers`,industry:`agency`,name:{de:`Fotografie`,en:`Photographers`},words:[`fotograf`,`fotografie`,`foto`,`photographer`,`photography`]},{id:`events`,industry:`events`,name:{de:`Veranstaltungen`,en:`Events`},words:[`event`,`veranstaltung`,`hochzeit`,`catering`,`konferenz`,`wedding`,`conference`]},{id:`itServices`,industry:`professional`,name:{de:`IT-Dienstleister`,en:`IT services`},words:[`it-dienstleister`,`it-service`,`software`,`webentwicklung`,`hosting`,`netzwerk`,`development`,`web design`]},{id:`cleaning`,industry:`trades`,name:{de:`Reinigung`,en:`Cleaning`},words:[`reinigung`,`gebäudereinigung`,`putz`,`cleaning`,`janitorial`]},{id:`footballClubs`,industry:`any`,name:{de:`Fußballvereine`,en:`Football clubs`},words:[`fußball`,`fussball`,`fc`,`sv`,`kicker`,`football`,`soccer`]},{id:`sportsClubs`,industry:`any`,name:{de:`Sportvereine`,en:`Sports clubs`},words:[`sportverein`,`verein`,`turnen`,`tennis`,`laufen`,`sport`,`club`]},{id:`musicClubs`,industry:`events`,name:{de:`Musikvereine und Chöre`,en:`Music clubs and choirs`},words:[`musikverein`,`blasmusik`,`chor`,`kapelle`,`orchester`,`band`,`choir`,`music`]},{id:`fireBrigades`,industry:`publicSector`,name:{de:`Feuerwehren`,en:`Fire brigades`},words:[`feuerwehr`,`rettung`,`rotes kreuz`,`fire brigade`,`rescue`]},{id:`schools`,industry:`publicSector`,name:{de:`Schulen und Bildung`,en:`Schools and education`},words:[`schule`,`kurs`,`weiterbildung`,`akademie`,`nachhilfe`,`school`,`course`,`training`]},{id:`municipalities`,industry:`publicSector`,name:{de:`Gemeinden`,en:`Municipalities`},words:[`gemeinde`,`stadt`,`bürgerservice`,`amt`,`municipality`,`council`,`town`]},{id:`associations`,industry:`any`,name:{de:`Vereine und Initiativen`,en:`Associations`},words:[`verein`,`initiative`,`ehrenamt`,`verband`,`association`,`nonprofit`,`charity`]}],S=e=>x.find(t=>t.id===e)??null;function pe(e,t=3){let n=` ${e.toLowerCase().normalize(`NFC`).replace(/[^\p{L}\p{N}-]+/gu,` `)} `;return x.map(e=>({id:e.id,score:e.words.reduce((e,t)=>e+(n.includes(` ${t}`)?Math.min(3,t.length/4):0),0)})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score).slice(0,t).map(e=>e.id)}var C=e(t(),1),w=e(n(),1),me=`oklch(50% 0.2 262)`,T=`oklch(32% 0.15 262)`,E=`oklch(90% 0.1 80)`,he={"--on":`white`,"--dot":E,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},D={kind:1,organization:1,site:2,details:3,know:4,space:5},ge=e=>e!==null&&Object.hasOwn(D,e),_e=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function ve(){return(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,w.jsx)(_,{size:28}),(0,w.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,w.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,w.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function O({children:e,busy:t,onClick:n,type:r=`button`}){return(0,w.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:T},children:[e,(0,w.jsx)(l,{className:`size-[18px]`})]})}function k({children:e,onClick:t}){return(0,w.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function A({step:e,total:t=4}){return(0,w.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":y(`onboard.step`,{n:e,total:t}),children:Array.from({length:t},(e,t)=>t+1).map(t=>(0,w.jsx)(`span`,{className:c(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}var ye=[{kind:`personal`,label:`onboard.kindPersonal`,sub:`onboard.kindPersonalSub`},{kind:`club`,label:`onboard.kindClub`,sub:`onboard.kindClubSub`},{kind:`small`,label:`onboard.kindSmall`,sub:`onboard.kindSmallSub`},{kind:`corp`,label:`onboard.kindCorp`,sub:`onboard.kindCorpSub`}];function be(e){let t=(e.split(`@`)[1]??``).trim().toLowerCase();return t?b.has(t)?{kind:`personal`,domain:t}:/(verein|club|klub|^sv-|^fc-|^ff-|feuerwehr|musik|chor)/.test(t)?{kind:`club`,domain:t}:{kind:`small`,domain:t}:{kind:null,domain:t}}var xe={club:[`0-50`,`50-250`,`250-1000`,`1000+`],small:[`1`,`2-9`,`10-49`],corp:[`50-249`,`250-999`,`1000+`]},j=e=>Number(e).toLocaleString(v),Se=e=>{if(e===`1`)return y(`onboard.justMe`);if(e.endsWith(`+`))return`${j(e.slice(0,-1))}+`;let[t,n]=e.split(`-`);return t===`0`?`≤ ${j(n)}`:`${j(t)}–${j(n)}`},Ce=[`sport`,`culture`,`social`,`education`,`environment`,`rescue`,`other`],we=[`chair`,`board`,`treasurer`,`secretary`,`member`],Te=[`management`,`it`,`marketing`,`sales`,`operations`,`other`],Ee=`w-full rounded-[14px] border border-white/30 bg-white/15 px-4 py-3 text-[1.0625rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function De({picked:e,label:t,sub:n,onClick:r}){return(0,w.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:r,className:c(`flex cursor-pointer flex-col gap-1 rounded-[18px] border px-5 py-4 text-left transition`,e?`border-white bg-white/25`:`border-white/30 bg-white/10 hover:bg-white/15`),children:[(0,w.jsx)(`span`,{className:`font-display font-semibold text-[1.125rem]`,children:t}),(0,w.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:n})]})}function M({label:e,options:t,value:n,text:r,onChange:i}){return(0,w.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,w.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:e}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,w.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>i(e),className:c(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,n===e?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:n===e?{color:T}:void 0,children:r(e)},e))})]})}function N(e,t,n){let r=`${Oe}${e}:${t}`,[i,a]=(0,C.useState)(()=>{try{let e=sessionStorage.getItem(r);return e===null?n:JSON.parse(e)}catch{return n}});return(0,C.useEffect)(()=>{try{sessionStorage.setItem(r,JSON.stringify(i))}catch{}},[r,i]),[i,a]}var Oe=`wizards.onboarding:`;function ke(){try{for(let e of Object.keys(sessionStorage))e.startsWith(Oe)&&sessionStorage.removeItem(e)}catch{}}function P(){return m(me),ie().data?.onboarding===`welcome`?(0,w.jsx)(Ne,{}):(0,w.jsx)(F,{})}function F(){let e=ie(),t=i(),n=te(),{space:s}=oe(),l=e.data?.user.id??``,u=e.data?.onboarding===`organization`,d=u?4:5,m=e.data?.startingName?null:e.data?.tenant.name??null,[h,g]=N(l,`organization`,``),[_,b]=N(l,`line`,null),[ue,x]=N(l,`ticked`,null),[S,D]=N(l,`own`,[``]),[j,Oe]=(0,C.useState)(null),[P,F]=(0,C.useState)([]),Ne=(0,C.useRef)(null),[Fe]=(0,C.useState)(ae),[z]=(0,C.useState)(()=>u?{kind:null,domain:``}:be(e.data?.user.email??``)),[B,Ie]=N(l,`profile`,{kind:z.kind,size:null,sector:``,role:null,need:``,questions:``,phone:``}),[Le,Re]=o(),V=Le.get(`page`),H=ge(V)&&(V===`kind`||B.kind)&&!(u&&V===`space`)?V:`kind`,U=e=>Re(t=>{let n=new URLSearchParams(t);return n.set(`page`,e),n}),W=e=>Ie(t=>({...t,...e})),G=B.kind===`personal`,K=m??(h.trim()||null),q=ee({queryKey:[`onboarding`,`suggest`],queryFn:()=>r.get(`/api/studio/onboarding/suggest`),enabled:!u&&!m&&!!B.kind&&!G,staleTime:1/0}).data?.site??null;(0,C.useEffect)(()=>{q&&!h&&g(q.name)},[q,h,g]);let ze=ee({queryKey:[`onboarding`,`find`,K],queryFn:()=>r.post(`/api/studio/onboarding/find`,{name:K,lang:v}),enabled:H===`site`&&!G&&!!K,staleTime:1/0}),J=ze.data?.addresses??[],Y=ue??J.filter((e,t)=>e.kind!==`website`||!J.slice(0,t).some(e=>e.kind===`website`)).map(e=>e.url),Be=S.map(e=>e.trim()).filter(e=>de(e)),X=[...Y,...Be],Ve=!G&&ze.isSuccess&&J.length===0,[Z,He]=N(l,`anyway`,!1),Ue=_!==null||Ve&&!Be.length&&!Z,We=f({mutationFn:()=>r.put(`/api/studio/organization/profile`,{kind:B.kind,size:B.size,sector:B.sector.trim()||null,role:B.role,need:B.need.trim()||null,questions:(B.questions??``).trim()||null,phone:B.phone.trim()||null,website:X.find(e=>fe(e)===`website`)??null,links:X})}),Ge=f({mutationFn:e=>r.put(`/api/studio/organization`,{name:e})}),Ke=()=>{U(`site`),t.invalidateQueries({queryKey:[`organization`]}),t.invalidateQueries({queryKey:[`me`]})},Q=f({mutationFn:e=>r.post(`/api/studio/spaces/${s?.id}/website`,{urls:e,lang:v}),onSuccess:async e=>{let n=e?.sectors?.[0];n&&Ie(e=>e.sector?e:{...e,sector:n}),Oe(e??{name:``,about:!1,colors:0,fonts:0,logo:!1,facts:0,assets:0}),await t.invalidateQueries({queryKey:a.spaces()})}}),qe=f({mutationFn:e=>r.patch(`/api/studio/spaces/${s?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:a.spaces()})}),$=f({mutationFn:()=>r.post(`/api/studio/onboarding/done`),onSuccess:async()=>{ke(),await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),Je=e.data?.user.name??``,Ye=Je.includes(`@`)?``:Je.split(` `)[0],Xe=u&&m?y(`onboard.kickerNew`,{organization:m}):Ye?y(`onboard.kicker1`,{name:Ye}):y(`onboard.kicker1Anon`),Ze=(e,t)=>K&&!G?y(e,{organization:K}):y(t),Qe=async e=>{if(e&&s){for(let t of Array.from(e)){F(e=>[...e,{name:t.name,state:`uploading`}]);try{await r.upload(`/api/studio/spaces/${s.id}/files?kind=document`,t),F(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{F(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:a.spaces()})}},$e=j?[j.about?y(`onboard.readAbout`):``,j.colors?y(`onboard.readColors`,{n:j.colors}):``,j.fonts?y(`onboard.readFonts`,{n:j.fonts}):``,j.logo?y(`onboard.readLogo`):``,j.facts?y(`onboard.readFacts`,{n:j.facts}):``,j.assets?y(`onboard.readAssets`,{n:j.assets}):``].join(``):``,et=[...new Set([...j?.sectors??[],...pe(`${K??``} ${_??``} ${B.questions??``}`,4)])].slice(0,4),tt=e=>`${window.location.host}/studio/${Me(e)}`;return(0,w.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...he,background:me},children:[(0,w.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,w.jsx)(ve,{}),(0,w.jsx)(ce,{tone:`ground`,ink:T})]}),(0,w.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,w.jsx)(re,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),Fe?(0,w.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,w.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:y(`onboard.wish`)}),(0,w.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:Fe}),(0,w.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:y(`onboard.wishNext`)})]}):null]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[H===`kind`?(0,w.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),B.kind&&U(B.kind===`personal`||m?`site`:`organization`)},children:[(0,w.jsx)(I,{children:Xe}),(0,w.jsx)(L,{children:y(`onboard.kind`)}),(0,w.jsx)(R,{children:u&&m?y(`onboard.kindSubOrganization`,{organization:m}):y(`onboard.kindSub`)}),z.kind?(0,w.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:y(`onboard.guess`,{domain:z.domain,kind:y(ye.find(e=>e.kind===z.kind)?.label??`onboard.kindSmall`)})}):null,(0,w.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:ye.map(e=>(0,w.jsx)(De,{picked:B.kind===e.kind,label:y(e.label),sub:y(e.sub),onClick:()=>W({kind:e.kind,size:e.kind===B.kind?B.size:null})},e.kind))}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{type:`submit`,children:y(`onboard.continue`)}),(0,w.jsx)(A,{step:1,total:d})]})]}):null,H===`organization`?(0,w.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=h.trim();t?Ge.mutate(t,{onSuccess:Ke}):U(`site`)},children:[(0,w.jsx)(I,{children:Xe}),(0,w.jsx)(L,{children:y(`onboard.organization`)}),(0,w.jsx)(R,{children:y(`onboard.organizationSub`)}),(0,w.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:y(`onboard.organizationPlaceholder`),maxLength:80,"aria-label":y(`onboard.organization`),className:_e}),h.trim()?(0,w.jsxs)(`p`,{className:`-mt-2 text-[0.9375rem] text-white/85`,children:[q&&h===q.name?`${y(`onboard.nameFrom`,{domain:new URL(q.url).host})} `:``,y(`onboard.address`),` `,(0,w.jsx)(`span`,{className:`font-mono text-[0.875rem]`,style:{color:E},children:tt(h)})]}):null,(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{type:`submit`,busy:Ge.isPending,children:y(`onboard.continue`)}),(0,w.jsx)(A,{step:1,total:d})]})]}):null,H===`site`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{children:G?y(`onboard.kicker2Personal`):Ze(`onboard.kicker2Named`,`onboard.kicker2`)}),(0,w.jsx)(L,{children:G?y(`onboard.linksPersonal`):Ve&&!Z&&K?y(`onboard.noneFound`,{name:K}):K?y(`onboard.siteNamed`,{organization:K}):y(`onboard.site`)}),(0,w.jsx)(R,{children:G?y(`onboard.linksPersonalSub`):Ve&&!Z&&K?y(`onboard.noneFoundSub`,{name:K}):ze.isPending?y(`onboard.searching`,{name:K??``}):y(`onboard.foundSub`)}),Ue?(0,w.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=(_??``).trim();t?qe.mutate(t,{onSuccess:()=>U(`details`)}):U(`details`)},children:[(0,w.jsx)(Ae,{value:_??``,onChange:b,rows:4,label:y(`onboard.line`),placeholder:y(G?`onboard.linePlaceholderPersonal`:`onboard.linePlaceholder`)}),(0,w.jsxs)(`button`,{type:`button`,onClick:()=>{b(null),He(!0),D(e=>e.length?e:[``])},className:`-mt-1 cursor-pointer self-start font-semibold text-[0.9375rem] text-white/85 hover:text-white`,children:[`+ `,y(`onboard.addressAfterAll`)]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{type:`submit`,busy:qe.isPending,children:y(`onboard.continue`)}),(0,w.jsx)(k,{onClick:()=>U(`details`),children:y(`onboard.skip`)}),(0,w.jsx)(A,{step:2,total:d})]})]}):(0,w.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),j?U(`details`):X.length&&!Q.isPending&&Q.mutate(X)},children:[J.length?(0,w.jsx)(`div`,{className:`flex flex-col gap-2`,children:J.map(e=>(0,w.jsx)(je,{address:e,picked:Y.includes(e.url),onToggle:()=>x(Y.includes(e.url)?Y.filter(t=>t!==e.url):[...Y,e.url])},e.url))}):null,!G&&J.length?(0,w.jsx)(`p`,{className:`-mb-2 text-[0.9375rem] text-white/85`,children:y(`onboard.own`)}):null,S.map((e,t)=>(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(`input`,{value:e,onChange:e=>D(n=>n.map((n,r)=>r===t?e.target.value:n)),placeholder:y(G?`onboard.linkPlaceholderPersonal`:`onboard.ownPlaceholder`),autoCapitalize:`none`,"aria-label":y(`onboard.own`),className:c(Ee,`pr-28`)}),de(e)?(0,w.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 right-3 rounded-full bg-white/20 px-2.5 py-0.5 font-semibold text-[0.75rem]`,children:le[fe(e)]}):null]},t)),S.length+J.length<10?(0,w.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>[...e,``]),className:`-mt-1 cursor-pointer self-start font-semibold text-[0.9375rem] text-white/85 hover:text-white`,children:[`+ `,y(`onboard.addAddress`)]}):null,j?(0,w.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,w.jsx)(p,{className:`size-4`}),j.name?y(`onboard.readDone`,{name:j.name,details:$e}):y(`onboard.readKept`,{n:X.length})]}):Q.isError?(0,w.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:y(`onboard.readFailed`)}):null,(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[j?(0,w.jsx)(O,{type:`submit`,children:y(`onboard.continue`)}):(0,w.jsx)(O,{type:`submit`,busy:Q.isPending,children:Q.isPending?y(`onboard.reading`):y(`onboard.read`)}),(0,w.jsx)(k,{onClick:()=>b(``),children:y(`onboard.line`)}),(0,w.jsx)(k,{onClick:()=>U(`details`),children:y(`onboard.skip`)}),(0,w.jsx)(A,{step:2,total:d})]})]})]}):null,H===`details`&&B.kind?(0,w.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),We.mutate(),U(`know`)},children:[(0,w.jsx)(I,{children:G||!K?Xe:K}),(0,w.jsx)(L,{small:!0,children:G?y(`onboard.personalTitle`):K?y(`onboard.aboutOrganization`,{organization:K}):y(B.kind===`club`?`onboard.clubTitle`:`onboard.businessTitle`)}),G?(0,w.jsx)(Ae,{value:B.need,onChange:e=>W({need:e}),rows:4,label:y(`onboard.personalTitle`),placeholder:y(`onboard.personalPlaceholder`)}):null,B.kind===`club`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(M,{label:y(`onboard.clubKind`),options:Ce,value:B.sector,text:e=>y(`onboard.club.${e}`),onChange:e=>W({sector:e})}),(0,w.jsx)(M,{label:y(`onboard.members`),options:xe.club,value:B.size,text:Se,onChange:e=>W({size:e})}),(0,w.jsx)(M,{label:y(`onboard.yourRole`),options:we,value:B.role,text:e=>y(`onboard.role.${e}`),onChange:e=>W({role:e})})]}):null,B.kind===`small`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(M,{label:y(`onboard.people`),options:xe.small,value:B.size,text:Se,onChange:e=>W({size:e})}),(0,w.jsx)(Pe,{value:B.sector,onChange:e=>W({sector:e}),suggested:et})]}):null,B.kind===`corp`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(M,{label:y(`onboard.people`),options:xe.corp,value:B.size,text:Se,onChange:e=>W({size:e})}),(0,w.jsx)(Pe,{value:B.sector,onChange:e=>W({sector:e}),suggested:et}),(0,w.jsx)(M,{label:y(`onboard.yourRole`),options:Te,value:B.role,text:e=>y(`onboard.role.${e}`),onChange:e=>W({role:e})}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-2 text-[0.9375rem] text-white/85`,children:[(0,w.jsxs)(`span`,{children:[y(`onboard.phone`),` `,(0,w.jsx)(`span`,{className:`text-white/60`,children:y(`onboard.phoneWhy`)})]}),(0,w.jsx)(`input`,{type:`tel`,value:B.phone,onChange:e=>W({phone:e.target.value.replace(/[^+0-9 ()/.-]/g,``)}),placeholder:`+43 …`,maxLength:40,autoComplete:`tel`,className:Ee})]})]}):null,G?null:(0,w.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,w.jsxs)(`span`,{className:`text-[0.9375rem] text-white/85`,children:[y(`onboard.questions`),` `,(0,w.jsx)(`span`,{className:`text-white/60`,children:y(`onboard.optional`)})]}),(0,w.jsx)(Ae,{value:B.questions??``,onChange:e=>W({questions:e}),rows:3,label:y(`onboard.questions`),placeholder:y(`onboard.questionsPlaceholder`)}),(0,w.jsx)(`span`,{className:`text-[0.8125rem] text-white/70`,children:y(`onboard.questionsHint`)})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{type:`submit`,busy:We.isPending,children:y(`onboard.continue`)}),(0,w.jsx)(k,{onClick:()=>window.history.state?.idx>0?n(-1):U(`site`),children:y(`onboard.back`)}),(0,w.jsx)(A,{step:3,total:d})]})]}):null,H===`know`?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{children:Ze(`onboard.kicker3Named`,`onboard.kicker3`)}),(0,w.jsx)(L,{children:y(`onboard.know`)}),(0,w.jsx)(R,{children:y(`onboard.knowSub`)}),(0,w.jsxs)(`button`,{type:`button`,onClick:()=>Ne.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),Qe(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,w.jsx)(se,{className:`size-7`}),(0,w.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:y(`onboard.drop`)}),(0,w.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,w.jsx)(`input`,{ref:Ne,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{Qe(e.target.files),e.target.value=``}})]}),P.length?(0,w.jsx)(`ul`,{className:`flex flex-col gap-2`,children:P.map(e=>(0,w.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,w.jsx)(ne,{className:`size-4 shrink-0`}),(0,w.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,w.jsx)(`span`,{className:c(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?y(`onboard.uploading`):e.state===`done`?y(`onboard.uploaded`):y(`onboard.uploadFailed`)})]},e.name))}):null,(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{busy:P.some(e=>e.state===`uploading`)||$.isPending,onClick:()=>u?$.mutate():U(`space`),children:y(u?`onboard.buildFirst`:`onboard.continue`)}),P.length||u?null:(0,w.jsx)(k,{onClick:()=>U(`space`),children:y(`onboard.skip`)}),(0,w.jsx)(A,{step:4,total:d})]})]}):null,H===`space`&&!u?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{children:Ze(`onboard.kicker4Named`,`onboard.kicker4`)}),(0,w.jsx)(L,{children:K&&!G?y(`onboard.spaceNamed`,{organization:K}):y(`onboard.space`)}),(0,w.jsx)(R,{children:y(`onboard.spaceSub`,{space:s?.name??``})}),(0,w.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(j||_)],[`partKnow`,`partKnowText`,P.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,w.jsx)(p,{className:`size-4 text-(color:--moss)`}):null,y(`onboard.${e}`)]}),(0,w.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:y(`onboard.${t}`)})]},e))}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,w.jsx)(O,{busy:$.isPending,onClick:()=>$.mutate(),children:y(`onboard.build`)}),(0,w.jsx)(A,{step:5,total:d})]})]}):null]},H)]}),(0,w.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,w.jsx)(`span`,{children:`engenty.wizards`}),(0,w.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}function I({children:e}){return(0,w.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:e})}function L({children:e,small:t}){return(0,w.jsx)(`h1`,{className:c(`font-display font-bold leading-[1.05] tracking-[-0.02em]`,t?`text-[2.25rem] sm:text-[2.75rem]`:`text-[2.5rem] sm:text-[3.25rem]`),children:e})}function R({children:e}){return(0,w.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:e})}function Ae({value:e,onChange:t,rows:n,label:r,placeholder:i}){let[a]=d(),o=s(e,t,{deviceId:a.deviceId});return(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] border border-white/30 bg-white/15 px-4 pt-3 pb-3 focus-within:border-white/60`,children:[(0,w.jsx)(`textarea`,{value:e,onChange:e=>t(e.target.value),placeholder:o.listening?y(`editor.listening`):i,rows:n,maxLength:4e3,"aria-label":r,className:`w-full resize-none bg-transparent text-[1.0625rem] text-white leading-relaxed outline-none placeholder:text-white/55`}),o.supported?(0,w.jsx)(`div`,{className:`self-end`,style:{"--ink":`white`,"--border":`rgb(255 255 255 / 0.55)`},children:(0,w.jsx)(u,{speech:o,labelled:!0})}):null]})}function je({address:e,picked:t,onToggle:n}){return(0,w.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:c(`flex cursor-pointer items-center gap-3.5 rounded-[14px] border px-4 py-2.5 text-left transition`,t?`border-white bg-white/22`:`border-white/30 bg-white/8 hover:bg-white/12`),children:[(0,w.jsx)(`span`,{className:c(`flex size-5 shrink-0 items-center justify-center rounded-md border-2`,t?`border-white bg-white`:`border-white/60`),style:t?{color:T}:void 0,children:t?(0,w.jsx)(p,{className:`size-3.5`,strokeWidth:3}):null}),(0,w.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,w.jsx)(`span`,{className:`font-semibold text-[0.6875rem] text-white/70 uppercase tracking-[0.1em]`,children:le[e.kind]}),(0,w.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.url.replace(/^https?:\/\/(www\.)?/,``).replace(/\/$/,``)}),(0,w.jsx)(`span`,{className:`truncate text-[0.8125rem] text-white/80`,children:e.title})]}),(0,w.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-white/70 max-sm:hidden`,children:y(e.source===`email`?`onboard.fromEmail`:`onboard.fromWeb`)})]})}function Me(e){return e.toLowerCase().replace(/['’]/g,``).replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,35).replace(/-+$/,``)}function Ne(){let e=ie(),t=i(),n=te(),a=h(),o=e.data?.tenant,s=ee({queryKey:[`organization`,o?.id],queryFn:()=>r.get(`/api/studio/organization`),enabled:!!o}),c=f({mutationFn:()=>r.post(`/api/studio/onboarding/done`),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`me`]}),n(`/`,{replace:!0})}});if(!(e.data&&o))return null;let l=o.name??``,u=e.data.user.name,d=u.includes(`@`)?``:u.split(` `)[0],ne=e.data.organizations.find(e=>e.id===o.id)?.invitedBy?.name,p=s.data?.members.find(t=>t.role===`owner`&&t.userId!==e.data?.user.id)?.name,m=o.role!==`member`,ae=o.slug?`${window.location.host}/studio/${o.slug}`:null;return(0,w.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...he,background:me},children:[(0,w.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,w.jsx)(ve,{}),(0,w.jsx)(ce,{tone:`ground`,ink:T})]}),(0,w.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,w.jsx)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:(0,w.jsx)(re,{kind:`drop`,size:240,fluffy:!0,coat:`fur`})}),(0,w.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[(0,w.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:d?y(`onboard.kicker1`,{name:d}):y(`onboard.kicker1Anon`)}),(0,w.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:y(`welcome.title`,{organization:l})}),(0,w.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:ne?y(`welcome.invited`,{name:ne}):p?y(`welcome.setUp`,{name:p,organization:l}):y(`welcome.plain`)}),(0,w.jsxs)(`div`,{className:`overflow-hidden rounded-[18px] bg-white/12 ring-1 ring-white/20`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3.5 px-4.5 py-3.5`,children:[(0,w.jsx)(`span`,{className:`flex size-11 shrink-0 items-center justify-center rounded-xl font-bold font-display`,style:{background:E,color:T},children:g(l)}),(0,w.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,w.jsx)(`span`,{className:`truncate font-semibold text-[1.0625rem]`,children:l}),ae?(0,w.jsx)(`span`,{className:`truncate font-mono text-[0.8125rem] text-white/75`,children:ae}):null]}),(0,w.jsx)(`span`,{className:`rounded-full bg-white/20 px-2.5 py-1 font-semibold text-[0.75rem]`,children:y(`organization.role.${o.role}`)})]}),a.data?.some(e=>e.wizardCount>0)?a.data.map(e=>(0,w.jsxs)(`div`,{className:`flex justify-between gap-3 border-white/15 border-t px-4.5 py-2.5 text-[0.9375rem]`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:e.name}),(0,w.jsx)(`span`,{className:`shrink-0 text-white/75`,children:y(`welcome.wizards`,{n:e.wizardCount})})]},e.id)):(0,w.jsx)(`p`,{className:`border-white/15 border-t px-4.5 py-3 text-[0.9375rem] text-white/80`,children:y(`welcome.noWizards`)})]}),(0,w.jsx)(`p`,{className:`text-[0.9375rem] text-white/80`,children:y(m?`welcome.canBuild`:`welcome.canMember`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap items-center gap-5`,children:(0,w.jsx)(O,{busy:c.isPending,onClick:()=>c.mutate(),children:y(`welcome.go`)})})]})]})]})}function Pe({value:e,onChange:t,suggested:n}){let[r,i]=(0,C.useState)(!1),a=S(e),o=[...new Set([...a?[a.id]:[],...n])].slice(0,4),s=e=>S(e)?.name[v===`de`?`de`:`en`]??e;return(0,w.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,w.jsx)(`legend`,{className:`mb-2 text-[0.9375rem] text-white/85`,children:y(`onboard.sector`)}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o.map(n=>(0,w.jsx)(`button`,{type:`button`,"aria-pressed":e===n,onClick:()=>t(n),className:c(`cursor-pointer rounded-full border px-4 py-2 text-[0.9375rem] transition`,e===n?`border-white bg-white`:`border-white/30 hover:bg-white/15`),style:e===n?{color:T}:void 0,children:s(n)},n)),(0,w.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>i(e=>!e),className:`cursor-pointer rounded-full border border-white/40 border-dashed px-4 py-2 text-[0.9375rem] hover:bg-white/15`,children:y(`onboard.sectorOther`)})]}),r?(0,w.jsxs)(`select`,{value:a?e:``,onChange:e=>{t(e.target.value),i(!1)},"aria-label":y(`onboard.sector`),className:c(Ee,`[&>option]:text-black`),children:[(0,w.jsx)(`option`,{value:``,children:y(`onboard.sectorPick`)}),[...x].sort((e,t)=>s(e.id).localeCompare(s(t.id),v)).map(e=>(0,w.jsx)(`option`,{value:e.id,children:s(e.id)},e.id))]}):null,a?(0,w.jsxs)(`span`,{className:`text-[0.8125rem] text-white/75`,children:[y(`onboard.sectorHint`),` `,(0,w.jsx)(`b`,{style:{color:E},children:y(`onboard.catalog`,{sector:s(a.id)})})]}):null]})}export{P as OnboardingPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,$t as i,Dn as a,Jn as o,Q as s,S as c,Tn as l,Vr as u,X as d,Zn as f,an as p,cr as m,en as h,fn as g,gr as _,hn as v,i as y,in as b,ln as x,nn as S,on as C,or as w,pn as T,rn as E,tn as D,un as O,vn as k,x as A}from"./ui-BacfkQ7Q.js";import{k as j}from"./Marketplace-C97fH7UC.js";import{t as M}from"./useMutation-CgzFr4qH.js";import{d as N,i as P,r as F}from"./marked.esm-DQ7XA7AC.js";import{$n as I,Tn as L,p as ee,pn as R,vn as te,wn as ne}from"./host-CCijW1hj.js";import{n as re}from"./volume-2-BqlBtCIJ.js";import{t as ie}from"./circle-check-DDLzlcXP.js";import{d as ae,h as oe,n as se,u as ce}from"./session-CEJRkSP5.js";import{n as z,s as B}from"./i18n-DCPDesT-.js";import{d as le,p as ue}from"./UpdateCheck-DVgAJmy8.js";var de={name:`circle-pause`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]],aliases:[`pause-circle`]};de.node;var fe=N(de),pe={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};pe.node;var me=N(pe),V=e(t(),1),H=e(n(),1),he=[`read`,`write`,`send`,`destructive`],ge={read:`connectors.group.read`,write:`connectors.group.write`,send:`connectors.group.send`,destructive:`connectors.group.destructive`};function _e({label:e,value:t,onChange:n,options:r,disabled:i,mono:a}){return(0,H.jsx)(`select`,{"aria-label":e,value:t,disabled:i,onChange:e=>n(e.target.value),className:v(`h-8 max-w-full rounded-lg border border-input bg-card px-2 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-4 focus:ring-focus-glow disabled:opacity-60 coarse:h-10`,a&&`font-mono text-[0.75rem]`),children:r.map(e=>(0,H.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function ve({actions:e,onChange:t,disabled:n}){return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border-soft`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,H.jsx)(`div`,{className:`truncate font-mono text-[0.75rem] text-ink-2`,children:e.id}),e.summary?(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-4`,children:e.summary}):null]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.group===`send`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:B(`connectors.address.recipient`)}),(0,H.jsx)(_e,{mono:!!e.recipientField,label:B(`connectors.address.recipientOf`,{id:e.id}),value:e.recipientField??``,disabled:n,onChange:n=>t(e.id,{kind:`send`,...n?{recipientField:n}:{}}),options:[{value:``,label:B(`connectors.address.recipientNone`)},...[...new Set([...e.fields??[],e.recipientField??``])].filter(Boolean).map(e=>({value:e,label:e}))]})]}):null,(0,H.jsx)(_e,{label:B(`connectors.address.kindOf`,{id:e.id}),value:e.group,disabled:n,onChange:n=>t(e.id,{kind:n}),options:he.map(e=>({value:e,label:B(ge[e])}))})]})]},e.id))})}function ye(e){let t=e.trim();return!t||/^https?:\/\//i.test(t)?t:/^(localhost|\[|\d+\.\d+\.\d+\.\d+)/i.test(t)?`http://${t}`:`https://${t}`}var be=e=>e.signIn.described===null?`header`:e.signIn.described===`none`?`none`:`described`;function xe(e,t){let{described:n,needsOAuthClient:r,keyIn:i}=e.signIn;return t===`header`?B(`connectors.address.signIn.headerHint`):t===`none`?B(n===`none`?`connectors.address.signIn.open`:`connectors.address.signIn.noneHint`):n===`oauth2`?B(r?`connectors.address.signIn.oauthClient`:`connectors.address.signIn.oauth`):B(`connectors.address.signIn.key`,{name:i??``})}function Se({spaceId:e,taken:t,onDone:n}){let r=u(),[a,o]=(0,V.useState)(``),[c,f]=(0,V.useState)(null),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[y,b]=(0,V.useState)(`described`),[x,S]=(0,V.useState)({name:`Authorization`,scheme:`Bearer`,value:``}),[w,E]=(0,V.useState)({id:``,secret:``}),[O,k]=(0,V.useState)({}),A=e=>({kind:`header`,name:x.name.trim(),...x.scheme.trim()?{scheme:x.scheme.trim()}:{},...e&&x.value?{value:x.value}:{}}),j=M({mutationFn:t=>s.post(`/api/studio/spaces/${e}/connectors/preview`,{sourceUrl:ye(a),...t?{signIn:A(!0)}:{}}),onSuccess:(e,t)=>{f(e),k(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.actions.some(e=>e.id===t)))),t||(h(e.title??e.host),_(e.suggestedToolPrefix),b(be(e)),k({}))}}),N=!!c&&j.variables===!0,P=g.replaceAll(`_`,`-`),F=/^[a-z][a-z0-9_]{1,30}$/.test(g)?t.includes(P)?B(`connectors.address.shortTaken`):null:B(`connectors.address.shortInvalid`),I=y===`described`&&c?.signIn.described===`oauth2`&&c.signIn.needsOAuthClient,L=M({mutationFn:t=>s.post(`/api/studio/spaces/${e}/connectors`,{sourceKind:t.sourceKind,sourceUrl:ye(a),id:P,toolPrefix:g,name:m.trim()||t.host,signIn:y===`header`?A(!0):{kind:y},...Object.keys(O).length?{actionKinds:O}:{},...I&&w.id&&w.secret?{oauthClientId:w.id,oauthClientSecret:w.secret}:{}}),onSuccess:async t=>{await r.invalidateQueries({queryKey:d.connectors(e)}),f(null),o(``),S(e=>({...e,value:``})),n(t.connector.id)}}),ee=e=>{e.preventDefault(),a.trim()&&(L.reset(),j.mutate(!1))},R=(c?.actions??[]).map(e=>{let t=O[e.id];return t?{...e,group:t.kind,recipientField:t.recipientField}:e}),te=c?c.signIn.described===null?[`header`,`none`]:c.signIn.described===`none`?[`none`,`header`]:[`described`,`header`,`none`]:[],ne=m.trim()||c?.host||``;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:ee,children:[(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connectors.address.hint`)}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(p,{"aria-label":B(`connectors.address.label`),className:`font-mono text-[0.8125rem]`,value:a,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:B(`connectors.address.placeholder`),onChange:e=>o(e.target.value)}),(0,H.jsxs)(i,{type:`submit`,variant:`secondary`,busy:j.isPending&&!c,children:[(0,H.jsx)(l,{className:`size-4`}),` `,B(`connectors.address.check`)]})]})]}),j.error&&!N?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:j.error.message}):null,c?(0,H.jsxs)(`div`,{className:`flex flex-col gap-5 border-border-soft border-t pt-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-11 shrink-0 items-center justify-center rounded-lg bg-paper-2 font-semibold text-[0.875rem] text-ink-2`,children:se(ne)||`?`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate font-display font-semibold text-[0.9375rem]`,children:ne}),(0,H.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[B(`connectors.address.kind.${c.sourceKind}`),` · `,c.host,` ·`,` `,c.toolsPending?B(`connectors.address.actions.pending`):B(c.actions.length===1?`connectors.address.actions.one`:`connectors.address.actions.n`,{n:c.actions.length})]})]}),c.fromAddress?(0,H.jsx)(D,{tone:`warn`,title:B(`connectors.uncheckedHint`),children:B(`connectors.unchecked`)}):null]}),c.privateAddress?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connectors.address.private`)}):null,c.blockers.map(e=>(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:e},e)),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{children:B(`connectors.address.name`)}),(0,H.jsx)(p,{"aria-label":B(`connectors.address.name`),value:m,maxLength:120,onChange:e=>h(e.target.value)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{children:B(`connectors.address.short`)}),(0,H.jsx)(p,{"aria-label":B(`connectors.address.short`),className:`font-mono text-[0.8125rem]`,value:g,maxLength:31,autoCapitalize:`off`,spellCheck:!1,onChange:e=>_(e.target.value.toLowerCase())}),(0,H.jsx)(`p`,{className:v(`mt-1.5 text-[0.75rem]`,F?`text-rose`:`text-ink-3`),children:F??B(`connectors.address.shortHint`)})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{children:B(`connectors.address.signIn`)}),c.signIn.described===null?(0,H.jsx)(`p`,{className:`mb-2 text-[0.8125rem] text-ink-2`,children:B(`connectors.address.signIn.unknown`)}):null,(0,H.jsx)(`div`,{className:`max-w-full overflow-x-auto`,children:(0,H.jsx)(T,{label:B(`connectors.address.signIn`),value:y,onChange:b,options:te.map(e=>({id:e,label:B(`connectors.address.signIn.${e}`)}))})}),(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:xe(c,y)}),y===`header`?(0,H.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[B(`connectors.address.header.name`),(0,H.jsx)(p,{className:`font-mono text-[0.8125rem]`,value:x.name,autoCapitalize:`off`,spellCheck:!1,onChange:e=>S(t=>({...t,name:e.target.value}))})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[B(`connectors.address.header.scheme`),(0,H.jsx)(p,{className:`font-mono text-[0.8125rem]`,value:x.scheme,placeholder:B(`connectors.address.header.schemePlaceholder`),autoCapitalize:`off`,spellCheck:!1,onChange:e=>S(t=>({...t,scheme:e.target.value}))})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1 text-[0.75rem] text-ink-3`,children:[B(`connectors.address.header.value`),(0,H.jsx)(p,{type:`password`,autoComplete:`off`,value:x.value,onChange:e=>S(t=>({...t,value:e.target.value}))})]})]}),j.error&&N?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:j.error.message}):null,c.sourceKind===`mcp`&&c.signIn.described!==`none`?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,H.jsx)(i,{size:`sm`,variant:`secondary`,busy:j.isPending,disabled:!(x.name.trim()&&x.value),onClick:()=>j.mutate(!0),children:B(`connectors.address.header.read`)}),(0,H.jsx)(`span`,{className:`min-w-48 flex-1 text-[0.75rem] text-ink-3`,children:B(`connectors.address.header.valueHint`)})]}):null]}):null,I?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,H.jsx)(p,{"aria-label":B(`connectors.clientId`),placeholder:B(`connectors.clientId`),value:w.id,onChange:e=>E(t=>({...t,id:e.target.value}))}),(0,H.jsx)(p,{"aria-label":B(`connectors.clientSecret`),type:`password`,autoComplete:`off`,placeholder:B(`connectors.clientSecret`),value:w.secret,onChange:e=>E(t=>({...t,secret:e.target.value}))})]}):null]}),R.length?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-[0.875rem]`,children:B(`connectors.address.kinds`)}),(0,H.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:B(`connectors.address.kindsHint`)})]}),(0,H.jsx)(`div`,{className:`max-h-96 overflow-y-auto rounded-lg bg-card ring-1 ring-border-soft`,children:(0,H.jsx)(ve,{actions:R,onChange:(e,t)=>k(n=>({...n,[e]:t}))})}),R.some(e=>e.group===`send`)?(0,H.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:B(`connectors.address.recipientHint`)}):null,c.dropped?(0,H.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:B(`connectors.address.dropped`,{n:c.dropped})}):null]}):c.toolsPending?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connectors.address.pending`)}):null,L.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:L.error.message}):null,(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,H.jsx)(i,{busy:L.isPending,disabled:!!F||c.blockers.length>0||y===`header`&&!x.name.trim(),onClick:()=>L.mutate(c),children:B(`connectors.import`)}),(0,H.jsx)(i,{variant:`ghost`,onClick:()=>f(null),children:B(`orgSettings.cancel`)}),(0,H.jsx)(`span`,{className:`min-w-48 flex-1 text-[0.8125rem] text-ink-3`,children:B(`connectors.address.after`)})]})]}):null]})}function Ce({connector:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-3 px-3 py-2 text-left`,children:[(0,H.jsx)(`span`,{className:v(`size-2 shrink-0 rounded-full`,e.usable?`bg-moss`:`bg-ink-4`)}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem]`,children:[e.name,` `,(0,H.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:e.id})]}),(0,H.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:e.usable?B(e.actions.length===1?`connectors.actions.one`:`connectors.actions.n`,{n:e.actions.length,r:e.actions.filter(e=>e.group===`read`).length}):B(`connectors.notSetUp`)})]}),t?(0,H.jsxs)(`div`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem]`,children:[e.missingSetup?(0,H.jsxs)(`p`,{className:`mb-1 text-ink-3`,children:[B(`connectors.setup`),` `,(0,H.jsx)(`span`,{className:`font-mono text-ink-2`,children:e.missingSetup})]}):null,(0,H.jsx)(`p`,{className:`text-ink-4`,children:e.actions.map(e=>e.group===`read`?e.id:`${e.id} (${B(`connectors.group.${e.group}`)})`).join(` · `)})]}):null]})}var we={none:`connectors.authNone`,oauth2:`connectors.authOauth`,api_key:`connectors.authKey`};function Te({spaceId:e,connector:t,readOnly:n,onSetUp:r}){let o=u(),[c,l]=(0,V.useState)(!1),f=()=>o.invalidateQueries({queryKey:d.connectors(e)}),p=`/api/studio/spaces/${e}/connectors/${t.id}`,m=M({mutationFn:()=>s.post(`${p}/refresh`),onSuccess:f}),h=M({mutationFn:()=>s.del(p),onSuccess:f}),g=M({mutationFn:e=>s.patch(`${p}/actions`,{actions:{[e.id]:e.choice}}),onSuccess:t=>{o.setQueryData(d.connectors(e),e=>e?.map(e=>e.id===t.id?t:e)),o.invalidateQueries({queryKey:[`space-connections`,e]})}}),_=t.actions.filter(e=>e.group===`read`).length;return(0,H.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 p-3`,children:[(0,H.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-paper-2 text-ink-2`,children:(0,H.jsx)(re,{className:`size-4`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`min-w-0 flex-1 basis-44 text-left`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium text-[0.875rem]`,children:t.name}),(0,H.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:t.id}),t.fromAddress?(0,H.jsx)(D,{tone:`warn`,title:B(`connectors.uncheckedHint`),children:B(`connectors.unchecked`)}):null]}),(0,H.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t.domain,` · `,t.sourceKind===`mcp`?`MCP`:`OpenAPI`,` ·`,` `,B(we[t.auth]),` ·`,` `,t.toolsPending?B(`connectors.pending`):B(t.actions.length===1?`connectors.actions.one`:`connectors.actions.n`,{n:t.actions.length,r:_})]})]}),n?null:(0,H.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[r?(0,H.jsx)(i,{size:`sm`,variant:`secondary`,onClick:()=>r(t.id),children:B(`capabilities.connectors.setUp`)}):null,(0,H.jsx)(b,{label:B(`connectors.refresh`),onClick:()=>m.mutate(),children:m.isPending?(0,H.jsx)(O,{className:`size-4`}):(0,H.jsx)(a,{className:`size-4`})}),(0,H.jsx)(b,{label:B(`connectors.remove`),className:`hover:text-rose`,onClick:async()=>await y(B(`connectors.removeConfirm`,{name:t.name}))&&h.mutate(),children:(0,H.jsx)(F,{className:`size-4`})})]})]}),t.needsOAuthClient?(0,H.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:B(`connectors.needsClient`)}):null,m.error??h.error??g.error?(0,H.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[0.75rem] text-rose`,children:(m.error??h.error??g.error).message}):null,c&&t.actions.length&&!n?(0,H.jsxs)(`div`,{className:`border-border-soft border-t`,children:[(0,H.jsx)(`p`,{className:`px-3 pt-2 text-[0.75rem] text-ink-3`,children:B(`connectors.address.kindsHint`)}),(0,H.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:(0,H.jsx)(ve,{actions:t.actions,disabled:g.isPending,onChange:(e,t)=>g.mutate({id:e,choice:t})})}),t.actions.some(e=>e.group===`send`)?(0,H.jsx)(`p`,{className:`px-3 pb-2 text-[0.75rem] text-ink-3`,children:B(`connectors.address.recipientHint`)}):null]}):null,c&&t.actions.length&&n?(0,H.jsx)(`ul`,{className:`max-h-64 overflow-y-auto border-border-soft border-t px-3 py-2`,children:t.actions.map(e=>(0,H.jsxs)(`li`,{className:`flex items-baseline gap-2 py-1 text-[0.75rem]`,children:[(0,H.jsx)(`span`,{className:v(`w-14 shrink-0 text-[0.6875rem] uppercase tracking-wide`,e.group===`read`?`text-moss`:e.group===`write`?`text-ink-3`:`text-rose`),children:B(`connectors.group.${e.group}`)}),(0,H.jsx)(`span`,{className:`shrink-0 font-mono text-ink-2`,children:e.id}),(0,H.jsx)(`span`,{className:`min-w-0 truncate text-ink-4`,children:e.summary})]},e.id))}):null]})}function Ee({spaceId:e,domain:t,source:n,taken:r,onDone:a}){let o=u(),[c,l]=(0,V.useState)({id:``,secret:``}),[f,m]=(0,V.useState)(!1),h=r.includes(n.suggestedId),g=M({mutationFn:()=>s.post(`/api/studio/spaces/${e}/connectors`,{domain:t,sourceKind:n.sourceKind,sourceUrl:n.sourceUrl,id:n.suggestedId,toolPrefix:n.suggestedToolPrefix,...n.name?{name:n.name}:{},...c.id&&c.secret?{oauthClientId:c.id,oauthClientSecret:c.secret}:{}}),onSuccess:async t=>{await o.invalidateQueries({queryKey:d.connectors(e)}),a(t.warnings,t.connector.id)}});return(0,H.jsxs)(`div`,{className:`rounded-lg bg-card p-3 ring-1 ring-border-soft`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(D,{tone:n.sourceKind===`mcp`?`ember`:`neutral`,children:n.sourceKind===`mcp`?`MCP`:`OpenAPI`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.8125rem]`,children:n.name??n.suggestedId}),(0,H.jsx)(`div`,{className:`truncate font-mono text-[0.6875rem] text-ink-4`,children:n.sourceUrl})]}),n.blocked||h?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:B(`connectors.ownClient`)}),(0,H.jsx)(i,{size:`sm`,busy:g.isPending,onClick:()=>g.mutate(),children:B(`connectors.import`)})]})]}),n.blocked?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:n.blocked}):null,h?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:B(`connectors.exists`)}):null,f?(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,H.jsx)(p,{placeholder:B(`connectors.clientId`),value:c.id,onChange:e=>l(t=>({...t,id:e.target.value}))}),(0,H.jsx)(p,{type:`password`,autoComplete:`off`,placeholder:B(`connectors.clientSecret`),value:c.secret,onChange:e=>l(t=>({...t,secret:e.target.value}))})]}):null,g.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-rose`,children:g.error.message}):null]})}function De({spaceId:e,readOnly:t,embedded:n,onSetUp:r,domain:a}){let o=R(`unsetConnectors`),[c,u]=(0,V.useState)(``),[m,h]=(0,V.useState)(null),[g,v]=(0,V.useState)(null),[y,b]=(0,V.useState)([]),[x,S]=(0,V.useState)(`registry`),C=_({queryKey:d.connectors(e),queryFn:()=>s.get(`/api/studio/spaces/${e}/connectors`)}),w=M({mutationFn:()=>s.post(`/api/studio/connectors/search`,{query:c}),onSuccess:e=>{h(e),v(null),b([])}}),E=M({mutationFn:e=>s.get(`/api/studio/connectors/registry/${encodeURIComponent(e)}`),onSuccess:v}),D=E.mutate;(0,V.useEffect)(()=>{a&&!t&&(S(`registry`),D(a))},[a,t,D]);let k=C.data??[],A=k.filter(e=>e.sourceKind===`builtin`&&(o||e.usable)),j=k.filter(e=>e.sourceKind!==`builtin`);return(0,H.jsxs)(n?ke:Oe,{children:[n?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:B(`connectors.title`)}),(0,H.jsx)(`p`,{className:`mt-1 mb-5 text-[0.875rem] text-ink-3`,children:B(`connectors.hint`)})]}),A.length&&!n?(0,H.jsx)(`div`,{className:`mb-5 grid gap-1.5 sm:grid-cols-2`,children:A.map(e=>(0,H.jsx)(Ce,{connector:e},e.id))}):null,j.length||t?(0,H.jsx)(`h3`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.07em]`,children:B(`connectors.imported`)}):null,j.length?(0,H.jsx)(`div`,{className:`mb-4 flex flex-col gap-2`,children:j.map(n=>(0,H.jsx)(Te,{spaceId:e,connector:n,readOnly:t,onSetUp:r},n.id))}):null,t?null:(0,H.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto`,children:(0,H.jsx)(T,{label:B(`connectors.from`),value:x,onChange:S,options:[{id:`registry`,label:B(`connectors.from.registry`)},{id:`address`,label:B(`connectors.from.address`)}]})}),t?j.length?null:(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connectors.noneImported`)}):x===`address`?(0,H.jsx)(Se,{spaceId:e,taken:k.map(e=>e.id),onDone:e=>r?.(e)}):(0,H.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),c.trim()&&w.mutate()},children:[(0,H.jsx)(p,{value:c,placeholder:B(`connectors.search`),onChange:e=>u(e.target.value)}),(0,H.jsxs)(i,{type:`submit`,variant:`secondary`,busy:w.isPending,children:[(0,H.jsx)(l,{className:`size-4`}),` `,B(`connectors.find`)]})]}),x===`registry`&&w.error?(0,H.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:w.error.message}):null,x===`registry`&&m&&!g?(0,H.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[m.length?null:(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connectors.none`)}),m.map(e=>(0,H.jsxs)(`button`,{type:`button`,disabled:!e.kinds.length,onClick:()=>E.mutate(e.domain),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-paper-2 disabled:opacity-50`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:e.domain}),(0,H.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.description})]}),(0,H.jsx)(`span`,{className:`text-[0.6875rem] text-ink-4 uppercase`,children:e.kinds.join(` · `)}),(0,H.jsx)(f,{className:`-rotate-90 size-4 text-ink-4`})]},e.domain)),E.isPending?(0,H.jsx)(O,{className:`mx-auto mt-2 size-4 text-ink-4`}):null,E.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:E.error.message}):null]}):null,x===`registry`&&g?(0,H.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:g.domain}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>v(null),className:`text-[0.75rem] text-ink-3 hover:text-ink`,children:B(`run.back`)})]}),g.summary?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:g.summary}):null,g.sources.map(t=>(0,H.jsx)(Ee,{spaceId:e,domain:g.domain,source:t,taken:k.map(e=>e.id),onDone:(e,t)=>{b(e),r?.(t)}},`${t.sourceKind}:${t.sourceUrl}`)),g.credentials.filter(e=>e.setup||e.url).map(e=>(0,H.jsxs)(`p`,{className:`text-[0.75rem] text-ink-3`,children:[(0,H.jsxs)(`span`,{className:`text-ink-2`,children:[e.label,`:`]}),` `,e.setup,` `,e.url?(0,H.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-ember underline`,children:e.url}):null]},e.label)),y.map(e=>(0,H.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:e},e))]}):null]})}function Oe({children:e}){return(0,H.jsx)(h,{className:`p-4 sm:p-6`,children:e})}function ke({children:e}){return(0,H.jsx)(`div`,{children:e})}var Ae=[`space`,`person`],je=[`admins`,`members`,`all`],Me=[`read`,`write`,`destructive`,`send`],Ne=[`allow`,`ask`,`deny`],Pe={name:80,perSpace:200,calls:1e6};function U(e){return e.audience===`all`&&e.signIn===`space`}function Fe(e){(0,V.useEffect)(()=>{let t=t=>{t.data?.type===`wizards:connected`&&e()};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}function W(e,t){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!1);return{keys:n,setKeys:r,confirm:i,setConfirm:a,signIn:M({mutationFn:async t=>{if(t)return s.post(e,{credentials:t});let n=window.open(``,`_blank`,`popup,width=520,height=700`);try{let{url:t}=await s.post(e,{oauth:!0});n?n.location.href=t:window.location.href=t}catch(e){throw n?.close(),e}},onSuccess:async(e,n)=>{n&&(r(null),await t())}}),signOut:M({mutationFn:()=>s.del(e),onSuccess:async()=>{a(!1),await t()}})}}function G({s:e,auth:t,signedIn:n}){return(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`max-sm:hidden`,children:(0,H.jsx)(D,{tone:`live`,children:B(`konto.signedIn`)})}),(0,H.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>e.setConfirm(!0),children:B(`konto.signOut`)})]}):(0,H.jsx)(i,{size:`sm`,busy:e.signIn.isPending&&!e.keys,onClick:()=>t===`api_key`?e.setKeys(e.keys?null:{}):e.signIn.mutate(void 0),children:B(`konto.connectionSignIn`)})})}function K({s:e,fields:t,signedIn:n,confirmText:r,className:a}){let{keys:o}=e;return(0,H.jsxs)(H.Fragment,{children:[o&&!n?(0,H.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),e.signIn.mutate(o??{})},className:v(`mt-3 flex flex-col gap-3`,a),children:[t.map(t=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{children:t.label}),(0,H.jsx)(p,{type:t.secret?`password`:`text`,autoComplete:`off`,placeholder:t.placeholder,required:t.required!==!1,maxLength:500,value:o[t.key]??``,onChange:n=>e.setKeys({...o,[t.key]:n.target.value})})]},t.key)),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(i,{type:`submit`,size:`sm`,busy:e.signIn.isPending,children:B(`konto.connectionSignIn`)}),(0,H.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>e.setKeys(null),children:B(`orgSettings.cancel`)})]})]}):null,e.signIn.isError?(0,H.jsx)(`p`,{className:v(`mt-2 text-[0.8125rem] text-rose`,a),children:e.signIn.error.message}):null,e.signOut.isError?(0,H.jsx)(`p`,{className:v(`mt-2 text-[0.8125rem] text-rose`,a),children:e.signOut.error.message}):null,e.confirm?(0,H.jsxs)(`div`,{className:v(`mt-3 flex flex-wrap items-center gap-3 rounded-lg bg-paper p-3 text-[0.875rem] ring-1 ring-border-soft`,a),children:[(0,H.jsx)(`p`,{className:`min-w-48 flex-1`,children:r}),(0,H.jsx)(i,{variant:`ghost`,onClick:()=>e.setConfirm(!1),children:B(`orgSettings.cancel`)}),(0,H.jsx)(i,{busy:e.signOut.isPending,onClick:()=>e.signOut.mutate(),children:B(`konto.signOut`)})]}):null]})}function Ie(e){return e===null?``:String(e)}function Le(e){let t=e.trim();if(!t)return null;if(!/^\d+$/.test(t))return;let n=Number(t);return n>=1&&n<=Pe.calls?n:void 0}function Re(e){return e.callsPerDay===null?B(`connection.callsToday`,{n:e.callsToday}):B(`connection.callsTodayOf`,{n:e.callsToday.toLocaleString(z),limit:e.callsPerDay.toLocaleString(z)})}var q=e=>[`space-connections`,e];function ze(e){return _({enabled:!!e,queryKey:q(e),queryFn:()=>s.get(`/api/studio/spaces/${e}/connections`)})}function Be(e){return _({enabled:!!e,queryKey:d.connectors(e),queryFn:()=>s.get(`/api/studio/spaces/${e}/connectors`)})}function Ve(e,t,n){let r=new Set(t.map(e=>e.connectorId));return e.filter(e=>e.sourceKind===`builtin`&&!r.has(e.id)&&(e.usable||n))}var J={admins:`connection.audience.admins`,members:`connection.audience.members`,all:`connection.audience.all`},He={admins:`connection.audience.adminsHint`,members:`connection.audience.membersHint`,all:`connection.audience.allHint`},Ue={read:`connection.kind.read`,write:`connection.kind.write`,destructive:`connection.kind.destructive`,send:`connection.kind.send`},We={read:`connection.kind.readHint`,write:`connection.kind.writeHint`,destructive:`connection.kind.destructiveHint`,send:`connection.kind.sendHint`},Ge={allow:`connection.outcome.allow`,ask:`connection.outcome.ask`,deny:`connection.outcome.deny`},Ke={space:`connection.signIn.space`,person:`connection.signIn.person`},qe={space:`connection.signIn.spaceHint`,person:`connection.signIn.personHint`},Y=e=>new Intl.DateTimeFormat(z,{dateStyle:`medium`}).format(new Date(e));function Je(e){let t=Math.round((Date.parse(e)-Date.now())/1e3),n=new Intl.RelativeTimeFormat(z,{numeric:`auto`});for(let[e,r]of[[`day`,86400],[`hour`,3600],[`minute`,60]])if(Math.abs(t)>=r)return n.format(Math.round(t/r),e);return n.format(0,`minute`)}function X(e){let t=e.connector?.name??e.connectorId;return e.name===t?e.name:`${t} · ${e.name}`}var Z=e=>e.pluginName??e.plugin??``;function Ye(){let e=oe().data,t=R(`personSignIn`);if(!e||e.mode!==`managed`||t)return{allowed:!0,why:null};let n=e.tenant.plan?.name;return{allowed:!1,why:n?B(`connection.signIn.personPlan`,{plan:n}):B(`connection.signIn.personNoPlan`)}}function Xe(e){return e.signIn===`space`?e.account?B(`connection.asSpaceAccount`,{label:e.account.label}):B(`connection.asSpaceNotYet`):B(`connection.eachPersonCount`,{n:e.signedIn})}function Ze(e){return e.lastUsedAt?B(`connection.lastUsed`,{when:Je(e.lastUsedAt)}):B(`connection.neverUsed`)}function Qe(e){let t=e.toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0].split(`.`);return t.length>1?t[t.length-2]:t[0]}function $e(e,t){if(!e)return null;let n=t.find(t=>t.id===e);if(n)return{connectorId:n.id};let r=t.find(t=>t.domain&&t.domain===e.toLowerCase());if(r)return{connectorId:r.id};let i=Qe(e),a=t.find(e=>e.sourceKind===`builtin`&&(e.id===i||e.id.endsWith(`-${i}`)||e.name.toLowerCase()===i));return a?{connectorId:a.id}:e.includes(`.`)?{domain:e}:null}function et({name:e,large:t}){return(0,H.jsx)(`span`,{"aria-hidden":`true`,className:v(`flex shrink-0 items-center justify-center rounded-lg bg-paper-2 font-semibold text-ink-2`,t?`size-12 text-[0.9375rem]`:`size-9 text-[0.75rem]`),children:se(e)||`?`})}function tt(){let[e,t]=m(),{space:n}=ce(),r=ae(),{narrow:i}=ue(),a=u(),o=n?.id??``,s=e.get(`show`),c=e.get(`setup`),l=r&&!n?.readOnly,d=ze(o),f=Be(o),p=d.data?.connections??[],h=p.find(e=>e.id===s)??null;le(h?X(h):null),Fe((0,V.useCallback)(()=>{a.invalidateQueries({queryKey:[`space-connections`]}),a.invalidateQueries({queryKey:[`person-sign-ins`]})},[a])),(0,V.useEffect)(()=>{i||ee().scrollTo({top:0})},[i,s]);let g=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,H.jsx)(H.Fragment,{children:n?(0,H.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:h?(0,H.jsx)(ot,{connection:h,connector:f.data?.find(e=>e.id===h.connectorId),writable:l,onGone:()=>g(`all`)},h.id):(0,H.jsx)(nt,{spaceId:n.id,connections:p,loading:d.isPending,error:d.error,connectors:f.data??[],writable:l,setup:c,onOpen:g,onSetUp:e=>{t({setup:e},{replace:!i}),i||ee().scrollTo({top:0,behavior:`smooth`})},onSetUpDone:()=>t({},{replace:!0})})}):null})}function nt({spaceId:e,connections:t,loading:n,error:r,connectors:a,writable:o,setup:s,onOpen:l,onSetUp:u,onSetUpDone:d}){let f=R(`unsetConnectors`),p=(0,V.useRef)(null),m=s&&a.length?$e(s,a):null,g=m&&`domain`in m?m.domain:null;(0,V.useEffect)(()=>{g&&p.current?.scrollIntoView({block:`start`,behavior:`smooth`})},[g]);let _=Ve(a,t,f);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(c,{title:B(`capabilities.connectors`),hint:B(`capabilities.connectors.hint`),plain:!0,action:o&&s===null?(0,H.jsxs)(i,{size:`sm`,onClick:()=>u(``),children:[(0,H.jsx)(P,{className:`size-4`}),` `,B(`capabilities.connectors.add`)]}):null,children:[o&&s!==null?(0,H.jsx)(at,{spaceId:e,connectors:a,initial:m&&`connectorId`in m?m.connectorId:``,onCancel:d,onDone:l},m&&`connectorId`in m?m.connectorId:`new`):null,(0,H.jsx)(`h3`,{className:`px-1 pt-2 font-display font-semibold text-base`,children:B(`capabilities.inSpace`)}),o?(0,H.jsx)(it,{connections:t,onOpen:l}):null,r?(0,H.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:r.message}):t.length?(0,H.jsx)(h,{className:`flex flex-col divide-y divide-border-soft p-0`,children:t.map(e=>(0,H.jsx)(rt,{connection:e,onOpen:()=>l(e.id)},e.id))}):n?null:(0,H.jsx)(h,{children:(0,H.jsx)(E,{children:B(o?`capabilities.connectors.noneAdmin`:`capabilities.connectors.none`)})})]}),_.length?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,H.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:B(`capabilities.connectors.builtin`)}),(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(o?`capabilities.connectors.builtinHint`:`capabilities.connectors.builtinHintMember`)}),(0,H.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:_.map(e=>(0,H.jsx)(`li`,{children:o&&e.usable?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),title:B(`capabilities.connectors.setUpNamed`,{name:e.name}),className:`inline-flex h-8 items-center gap-1.5 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,H.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`}),e.name]}):(0,H.jsx)(`span`,{title:e.missingSetup??void 0,className:v(`inline-flex h-8 items-center rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-3`,!e.usable&&`opacity-60`),children:e.name})},e.id))})]}):null,(0,H.jsx)(`div`,{ref:p,className:`scroll-mt-6`,children:(0,H.jsx)(c,{title:B(`capabilities.connectors.more`),hint:B(`capabilities.connectors.moreHint`),children:(0,H.jsx)(De,{spaceId:e,readOnly:!o,embedded:!0,onSetUp:o?u:void 0,domain:g})})})]})}function rt({connection:e,onOpen:t}){let n=u(),r=W(`/api/studio/connections/${encodeURIComponent(e.id)}/my-sign-in`,()=>n.invalidateQueries({queryKey:q(e.spaceId)})),i=Object.values(e.rules).includes(`ask`),a=e.signIn===`person`,o=U(e),s=e.connector?.fromAddress===!0;return(0,H.jsxs)(`div`,{className:`px-3.5 py-3 sm:px-5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:t,className:`-my-1 -ml-1 flex min-w-0 flex-1 items-center gap-3 rounded-lg p-1 text-left transition hover:bg-paper-2`,children:[(0,H.jsx)(et,{name:e.connector?.name??e.connectorId}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`truncate text-[0.9375rem]`,children:X(e)}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[a?(0,H.jsx)(te,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}):(0,H.jsx)(I,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`truncate`,children:[Xe(e),e.plugin?` · ${B(`connection.pluginNamed`,{plugin:Z(e)})}`:``,` · `,Ze(e)]})]}),o||e.pausedAt||s?(0,H.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5 sm:hidden`,children:[e.pausedAt?(0,H.jsx)(D,{tone:`ember`,children:B(`connection.paused`)}):null,s?(0,H.jsx)(D,{tone:`warn`,title:B(`connectors.uncheckedHint`),children:B(`connectors.unchecked`)}):null,o?(0,H.jsx)(D,{tone:`warn`,children:B(`connection.guests`)}):null]}):null]}),(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 max-sm:hidden`,children:[e.pausedAt?(0,H.jsx)(D,{tone:`ember`,children:B(`connection.paused`)}):null,s?(0,H.jsx)(D,{tone:`warn`,title:B(`connectors.uncheckedHint`),children:B(`connectors.unchecked`)}):null,i?(0,H.jsx)(D,{tone:`warn`,children:B(`connection.outcome.ask`)}):null,o?(0,H.jsx)(D,{tone:`warn`,children:B(`connection.guests`)}):(0,H.jsx)(D,{children:B(J[e.audience])})]})]}),a?(0,H.jsx)(G,{s:r,auth:e.connector?.auth,signedIn:!!e.mySignIn}):null]}),a?(0,H.jsx)(K,{s:r,fields:e.connector?.fields??[],signedIn:!!e.mySignIn,confirmText:B(`konto.connectionSignOutConfirm`,{name:X(e)}),className:`ml-12`}):null]})}function it({connections:e,onOpen:t}){let n=u(),r=e.filter(U),a=M({mutationFn:e=>s.patch(`/api/studio/connections/${encodeURIComponent(e.id)}`,{audience:`members`}),onSuccess:e=>{n.setQueryData(q(e.spaceId),t=>t&&{connections:t.connections.map(t=>t.id===e.id?e:t)}),n.invalidateQueries({queryKey:[`person-sign-ins`]})}});return r.length?(0,H.jsxs)(`section`,{className:`rounded-xl bg-paper-2 px-3.5 py-3 ring-1 ring-border-soft sm:px-5 sm:py-4`,children:[(0,H.jsx)(`h4`,{className:`font-semibold text-[0.875rem]`,children:B(`connection.guests.title`,{n:r.length})}),(0,H.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-2`,children:B(`connection.guests.hint`)}),(0,H.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border-soft`,children:r.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 py-2.5`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`max-w-full truncate text-left font-medium text-[0.875rem] hover:underline`,children:X(e)}),e.plugin?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:B(`connection.guests.plugin`,{plugin:Z(e)})}):null]}),(0,H.jsx)(i,{size:`sm`,variant:`secondary`,"aria-label":B(`connection.guests.narrowNamed`,{name:X(e)}),busy:a.isPending&&a.variables?.id===e.id,onClick:()=>a.mutate(e),children:B(`connection.guests.narrow`)})]},e.id))}),a.error?(0,H.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-rose`,children:a.error.message}):null]}):null}function at({spaceId:e,connectors:t,initial:n,onCancel:r,onDone:a}){let o=u(),c=t.filter(e=>e.usable),[l,d]=(0,V.useState)(c.some(e=>e.id===n)?n:``),f=c.find(e=>e.id===l),[m,g]=(0,V.useState)(f?.name??``),_=Ye(),[v,y]=(0,V.useState)(_.allowed&&f?.auth===`oauth2`?`person`:`space`),[b,S]=(0,V.useState)(f?.fromAddress?`admins`:`members`),[w,E]=(0,V.useState)(!1),D=M({mutationFn:()=>s.post(`/api/studio/spaces/${e}/connections`,{connectorId:l,name:m.trim()||f?.name,signIn:v,audience:b}),onSuccess:async t=>{await o.invalidateQueries({queryKey:q(e)}),await o.invalidateQueries({queryKey:[`person-sign-ins`]}),a(t.id)}});return(0,H.jsx)(h,{className:`p-3.5 sm:p-5`,children:(0,H.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),l&&D.mutate()},className:`flex flex-col gap-5`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-base`,children:B(`capabilities.connectors.add`)}),(0,H.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-3`,children:B(`connection.setupHint`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{children:B(`connection.connector`)}),(0,H.jsx)(x,{value:l,onChange:e=>{let t=c.find(t=>t.id===e);(!m.trim()||m===f?.name)&&g(t?.name??``),w||S(t?.fromAddress?`admins`:`members`),d(e)},placeholder:B(`connection.connectorPick`),options:c.map(e=>({value:e.id,label:e.name}))})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{hint:B(`connection.nameHint`),children:B(`connection.name`)}),(0,H.jsx)(p,{value:m,maxLength:Pe.name,placeholder:B(`connection.namePlaceholder`),onChange:e=>g(e.target.value)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{hint:B(qe[v]),children:B(`connection.signIn`)}),(0,H.jsx)(T,{label:B(`connection.signIn`),value:v,onChange:y,options:Ae.map(e=>({id:e,label:B(Ke[e]),disabled:e===`person`&&!_.allowed}))}),(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:_.why??B(`connection.signInLater`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(C,{hint:B(He[b]),children:B(`connection.audience`)}),(0,H.jsx)(T,{label:B(`connection.audience`),value:b,onChange:e=>{S(e),E(!0)},options:je.map(e=>({id:e,label:B(J[e])}))}),f?.fromAddress?(0,H.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-3`,children:B(`connectors.address.adminsFirst`)}):null]}),D.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:D.error.message}):null,(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(i,{type:`submit`,busy:D.isPending,disabled:!l,children:B(`capabilities.connectors.setUp`)}),(0,H.jsx)(i,{type:`button`,variant:`ghost`,onClick:r,children:B(`orgSettings.cancel`)})]})]})})}function ot({connection:e,connector:t,writable:n,onGone:r}){let a=u(),o=q(e.spaceId),c=()=>a.invalidateQueries({queryKey:o}),[l,d]=(0,V.useState)(e.name),[f,m]=(0,V.useState)(!1),[g,_]=(0,V.useState)(null),v=Ye(),y=`/api/studio/connections/${encodeURIComponent(e.id)}`,b=M({mutationFn:e=>s.patch(y,e),onSuccess:e=>{a.setQueryData(o,t=>t&&{connections:t.connections.map(t=>t.id===e.id?e:t)}),a.invalidateQueries({queryKey:[`person-sign-ins`]})}}),x=M({mutationFn:()=>s.del(y),onSuccess:async()=>{await c(),a.invalidateQueries({queryKey:[`person-sign-ins`]}),r()}}),S=M({mutationFn:e=>s.post(`${y}/${e?`pause`:`resume`}`),onSuccess:e=>{a.setQueryData(o,t=>t&&{connections:t.connections.map(t=>t.id===e.id?e:t)}),a.invalidateQueries({queryKey:[`person-sign-ins`]})}}),C=W(`${y}/sign-in`,c),E=W(`${y}/my-sign-in`,c),O=()=>{let t=l.trim();t&&t!==e.name?b.mutate({name:t}):d(e.name)},k=e.connector?.name??e.connectorId,A=e.connector?.fields??[],j=e.setUpByName?B(`konto.connectionSetUpBy`,{name:e.setUpByName,when:Y(e.setUpAt)}):B(`konto.connectionSetUpAt`,{when:Y(e.setUpAt)}),N=e.plugin?B(`connection.signIn.pluginSpace`,{plugin:Z(e)}):v.allowed?null:e.signIn===`person`?B(`connection.signIn.personKept`):v.why,P=n=>(t?.actions??[]).filter(e=>e.group===n).filter(t=>!e.actions.length||e.actions.includes(t.id));return(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.pausedAt?(0,H.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-xl bg-ember-tint p-3.5 sm:px-5`,children:[(0,H.jsx)(fe,{className:`size-5 shrink-0 text-ember-strong`,"aria-hidden":`true`}),(0,H.jsx)(`p`,{className:`min-w-48 flex-1 text-[0.875rem] text-ink`,children:e.pausedByName?B(`connection.pausedNoteBy`,{name:e.pausedByName,when:Y(e.pausedAt)}):B(`connection.pausedNote`,{when:Y(e.pausedAt)})}),n?(0,H.jsx)(i,{size:`sm`,busy:S.isPending,onClick:()=>S.mutate(!1),children:B(`connection.resume`)}):null]}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-4 px-1`,children:[(0,H.jsx)(et,{name:k,large:!0}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`h2`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1 font-display font-semibold text-lg leading-tight`,children:[k,e.connector?.fromAddress?(0,H.jsx)(D,{tone:`warn`,title:B(`connectors.uncheckedHint`),children:B(`connectors.unchecked`)}):null]}),e.connector?.description?(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.connector.description}):null]})]}),(0,H.jsxs)(h,{className:`flex flex-col gap-5 p-3.5 sm:p-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[n?(0,H.jsx)(p,{"aria-label":B(`connection.name`),className:`max-w-sm font-semibold`,value:l,maxLength:Pe.name,onChange:e=>d(e.target.value),onBlur:O,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),O())}}):(0,H.jsx)(`b`,{className:`text-[0.9375rem]`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:n?j:B(`connection.adminsManage`)})]}),(0,H.jsx)(Q,{label:B(`connection.signIn`),children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,H.jsx)(`div`,{className:`max-w-full overflow-x-auto`,children:(0,H.jsx)(T,{label:B(`connection.signIn`),value:e.signIn,onChange:t=>_(t===e.signIn?null:t),options:Ae.map(e=>({id:e,label:B(Ke[e]),disabled:e===`person`&&!!N}))})}):(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.875rem]`,children:[e.signIn===`space`?(0,H.jsx)(I,{className:`size-4 text-ink-3`,"aria-hidden":`true`}):(0,H.jsx)(te,{className:`size-4 text-ink-3`,"aria-hidden":`true`}),B(Ke[e.signIn])]}),(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:B(qe[e.signIn])}),n&&N?(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:N}):null,n&&g?(0,H.jsxs)(`div`,{className:`mt-1 flex flex-col gap-3 rounded-lg bg-paper p-3 text-[0.875rem] ring-1 ring-border-soft`,children:[(0,H.jsx)(`p`,{children:B(g===`space`?`connection.signIn.toSpaceConfirm`:`connection.signIn.toPersonConfirm`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,H.jsx)(i,{variant:`ghost`,onClick:()=>_(null),children:B(`orgSettings.cancel`)}),(0,H.jsx)(i,{busy:b.isPending,onClick:()=>b.mutate({signIn:g},{onSettled:()=>_(null)}),children:B(`connection.signIn.change`)})]})]}):null]})}),e.signIn===`space`?(0,H.jsx)(Q,{label:B(`connection.account`),children:(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`text-[0.875rem]`,children:e.account?B(`connection.accountSignedIn`,{label:e.account.label}):B(n?`connection.accountNotYetAdmin`:`connection.accountNotYet`)}),n?(0,H.jsx)(G,{s:C,auth:e.connector?.auth,signedIn:!!e.account}):null]}),n?(0,H.jsx)(K,{s:C,fields:A,signedIn:!!e.account,confirmText:B(`connection.signOutSpaceConfirm`,{name:X(e)})}):null]})}):(0,H.jsx)(Q,{label:B(`connection.people`),children:(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,H.jsxs)(`span`,{className:`text-[0.875rem]`,children:[B(`connection.peopleSignedIn`,{n:e.signedIn}),` · `,e.mySignIn?B(`connection.youSignedIn`,{label:e.mySignIn.label}):B(`connection.youNotYet`)]}),(0,H.jsx)(G,{s:E,auth:e.connector?.auth,signedIn:!!e.mySignIn})]}),(0,H.jsx)(K,{s:E,fields:A,signedIn:!!e.mySignIn,confirmText:B(`konto.connectionSignOutConfirm`,{name:X(e)})})]})}),(0,H.jsx)(Q,{label:B(`connection.audience`),children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,H.jsx)(`div`,{children:(0,H.jsx)(T,{label:B(`connection.audience`),value:e.audience,onChange:e=>b.mutate({audience:e}),options:je.map(e=>({id:e,label:B(J[e])}))})}):(0,H.jsx)(`span`,{children:(0,H.jsx)(D,{children:B(J[e.audience])})}),(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:B(He[e.audience])}),n&&e.plugin&&U(e)?(0,H.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:B(`connection.guests.plugin`,{plugin:Z(e)})}):null]})}),(0,H.jsx)(`div`,{className:`border-border-soft border-t`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:B(`connection.rules`)}),Me.map(t=>{let r=P(t);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:B(Ue[t])}),(0,H.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:B(We[t])}),r.length?(0,H.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[0.6875rem] text-ink-4`,children:r.map(e=>e.id).join(` · `)}):null]}),(0,H.jsx)(`div`,{className:`shrink-0`,children:n?(0,H.jsx)(T,{label:B(Ue[t]),value:e.rules[t],onChange:n=>b.mutate({rules:{...e.rules,[t]:n}}),options:Ne.map(e=>({id:e,label:B(Ge[e])}))}):(0,H.jsx)(D,{tone:e.rules[t]===`ask`?`warn`:`neutral`,children:B(Ge[e.rules[t]])})})]},t)}),(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(n?`connection.askHint`:`connection.askHintMember`)})]}),(0,H.jsx)(`div`,{className:`border-border-soft border-t`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,H.jsx)(`h3`,{className:`font-semibold text-[0.875rem]`,children:B(`connection.limits`)}),(0,H.jsx)(`span`,{className:`min-w-48 flex-1 text-[0.8125rem] text-ink-3`,children:B(`connection.limitsHint`)})]}),(0,H.jsx)(Q,{label:B(`connection.limits.perRun`),children:(0,H.jsx)(st,{label:B(`connection.limits.perRun`),hint:B(`connection.limits.perRunHint`),limit:e.callsPerRun,writable:n,onSave:e=>b.mutate({callsPerRun:e})})}),(0,H.jsx)(Q,{label:B(`connection.limits.perDay`),children:(0,H.jsx)(st,{label:B(`connection.limits.perDay`),hint:B(`connection.limits.perDayHint`),limit:e.callsPerDay,writable:n,onSave:e=>b.mutate({callsPerDay:e})})})]}),b.error?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:b.error.message}):null]}),(0,H.jsxs)(h,{className:`flex flex-col gap-1 p-3.5 sm:p-5`,children:[(0,H.jsx)(Q,{label:B(`connection.use`),children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,H.jsxs)(`span`,{className:`text-[0.875rem] tabular-nums`,children:[Re(e),(0,H.jsxs)(`span`,{className:`text-ink-3`,children:[` · `,Ze(e)]})]}),(0,H.jsx)(w,{to:`/capabilities/protocol?connection=${encodeURIComponent(e.id)}`,className:`inline-flex h-8 items-center rounded-full bg-paper-2 px-3 font-medium text-[0.8125rem] text-ink transition hover:bg-paper-3 coarse:h-11 coarse:px-4`,children:B(`connection.inAudit`)})]})}),e.plugin?(0,H.jsx)(Q,{label:B(`connection.plugin`),children:(0,H.jsx)(`span`,{className:`text-[0.875rem]`,children:B(`connection.pluginUses`,{plugin:Z(e)})})}):null]}),n?(0,H.jsxs)(`div`,{className:`px-1`,children:[f?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg bg-paper p-3 text-[0.875rem] ring-1 ring-border-soft`,children:[(0,H.jsx)(`p`,{className:`min-w-48 flex-1`,children:B(`connection.removeConfirm`,{name:X(e)})}),(0,H.jsx)(i,{variant:`ghost`,onClick:()=>m(!1),children:B(`orgSettings.cancel`)}),(0,H.jsx)(i,{variant:`danger`,busy:x.isPending,onClick:()=>x.mutate(),children:B(`connection.remove`)})]}):(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[e.pausedAt?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(i,{variant:`secondary`,size:`sm`,busy:S.isPending,onClick:()=>S.mutate(!0),children:B(`connection.pause`)}),(0,H.jsx)(`p`,{className:`min-w-48 flex-1 text-[0.8125rem] text-ink-3`,children:B(`connection.pauseHint`)})]}),(0,H.jsx)(i,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:B(`connection.remove`)})]}),x.error||S.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:(x.error??S.error).message}):null]}):null]})}function st({label:e,hint:t,limit:n,writable:r,onSave:i}){let[a,o]=(0,V.useState)(Ie(n));(0,V.useEffect)(()=>o(Ie(n)),[n]);let s=()=>{let e=Le(a);e===void 0||e===n?o(Ie(n)):i(e)};return(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[r?(0,H.jsx)(p,{"aria-label":e,inputMode:`numeric`,className:`w-24 text-right tabular-nums`,value:a,onChange:e=>o(e.target.value.replace(/\D/g,``)),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())}}):(0,H.jsx)(`span`,{className:`text-[0.875rem] tabular-nums`,children:n===null?B(`connection.limits.none`):n.toLocaleString(z)}),(0,H.jsx)(`span`,{className:`min-w-48 flex-1 text-[0.8125rem] text-ink-3`,children:t})]})}function Q({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[11rem_minmax(0,1fr)] sm:gap-4`,children:[(0,H.jsx)(`span`,{className:`pt-0.5 text-[0.8125rem] text-ink-3`,children:e}),t]})}var ct={not_connected:`protocol.refused.not_connected`,no_action:`protocol.refused.no_action`,not_in_grant:`protocol.refused.not_in_grant`,denied:`protocol.refused.denied`,declined:`protocol.refused.declined`,nobody:`protocol.refused.nobody`,needs_approval:`protocol.refused.needs_approval`,ai_step_writes:`protocol.refused.ai_step_writes`,not_allowed_recipient:`protocol.refused.not_allowed_recipient`,channel_not_fixed:`protocol.refused.channel_not_fixed`,run_limit:`protocol.refused.run_limit`,day_limit:`protocol.refused.day_limit`,calls_per_run:`protocol.refused.calls_per_run`,calls_per_day:`protocol.refused.calls_per_day`,run_ended:`protocol.refused.run_ended`,paused:`protocol.refused.paused`},lt={"run.cancelled":`protocol.why.runStopped`,"run.done":`protocol.why.runDone`,"run.failed":`protocol.why.runFailed`},ut={read:`protocol.kind.read`,write:`protocol.kind.write`,destructive:`protocol.kind.destructive`,send:`protocol.kind.send`},dt={read:`protocol.verb.read`,write:`protocol.verb.write`,destructive:`protocol.verb.destructive`,send:`protocol.verb.send`},ft={refused_write:`work.critical.refused_write`,outside_audience:`work.critical.outside_audience`,host_not_in_grant:`work.critical.host_not_in_grant`,limit_reached:`work.critical.limit_reached`,sign_in_failed:`work.critical.sign_in_failed`,first_use:`work.critical.first_use`,rule_changed:`work.critical.rule_changed`},pt={grant:`protocol.rule.grant`,audience:`protocol.rule.audience`,actions:`protocol.rule.actions`,ai_step_writes:`protocol.rule.ai_step_writes`,destructive:`protocol.rule.destructive`,policy:`protocol.rule.policy`,read:`protocol.rule.read`,own_job:`protocol.rule.own_job`,guest_send:`protocol.rule.guest_send`,run:`protocol.rule.run`,paused:`protocol.rule.paused`,limits:`protocol.rule.limits`},mt={admins:`protocol.audience.admins`,members:`protocol.audience.members`,all:`protocol.audience.all`};function ht(e){return e in ut}function gt(e){return ht(e)?B(ut[e]):e}function _t(e){return ht(e)?B(dt[e]):e}function vt(e){return e&&e in ft?B(ft[e]):``}function yt(e){if(!e)return B(`protocol.rule.none`);if(e.startsWith(`rules.`))return B(`protocol.rule.rules`,{kind:gt(e.slice(6))});let t=pt[e]??pt[e.split(`.`)[0]??``];return t?B(t):e}function bt(e,t,n){return e===`run_ended`&&t&&t in lt?B(lt[t]):e&&e!==`denied`&&e in ct?B(ct[e]):t===`audience`?n&&n in mt?B(`protocol.why.audienceFor`,{audience:B(mt[n])}):B(`protocol.why.audience`):t===`actions`?B(`protocol.why.actions`):t===`grant`?B(`protocol.refused.not_in_grant`):t?.startsWith(`rules.`)?B(`protocol.why.rule`):B(`protocol.refused.denied`)}var xt={waiting_input:`runs.status.waiting_input`,sleeping:`runs.status.sleeping`,running:`runs.status.running`,done:`runs.status.done`,failed:`runs.status.failed`,cancelled:`protocol.detail.runStopped`};function St(e){let t=xt[e];return t?B(t):e}function Ct(e){return e===`running`||e===`waiting_input`||e===`sleeping`}function wt(e){let{outcome:t,result:n,rule:r}=e;return n===null&&t!==`deny`?{tone:`held`,text:B(`protocol.outcome.running`)}:n===`ok`?{tone:`done`,text:B(t===`ask`?`protocol.outcome.doneApproved`:`protocol.outcome.done`)}:n===`needs_approval`?{tone:`held`,text:B(`protocol.outcome.held`)}:n===`sign_in_failed`?{tone:`failed`,text:B(`protocol.outcome.signInFailed`)}:n===`nobody`||n===`not_connected`?{tone:`failed`,text:B(`protocol.outcome.notDone`,{why:B(ct[n])})}:t===`deny`||n===`declined`?{tone:`refused`,text:B(`protocol.outcome.refused`,{why:bt(n,r)})}:{tone:`failed`,text:B(`protocol.outcome.failed`,{error:n??``})}}function Tt(e){switch(e.kind){case`guest`:return B(`protocol.who.guest`);case`person`:return e.name??B(`protocol.who.person`);case`admin`:return e.name?B(`protocol.who.adminNamed`,{name:e.name}):B(`protocol.who.admin`);case`goose`:return e.name?B(`protocol.who.gooseFor`,{name:e.name}):B(`protocol.who.goose`);case`plugin`:return B(`protocol.who.plugin`,{name:e.id??``});case`step`:return e.for?e.for.kind===`guest`?B(`protocol.who.stepForGuest`):B(`protocol.who.stepFor`,{name:e.for.name??B(`protocol.who.person`)}):B(`protocol.who.step`);default:return e.kind}}function Et(e){return e.runId?e.wizardName?B(e.runMode===`test`?`protocol.where.testRunOf`:`protocol.where.runOf`,{wizard:e.wizardName}):B(`protocol.where.run`):e.chatId?e.chatTitle?B(`protocol.where.chatNamed`,{title:e.chatTitle}):B(`protocol.where.chat`):e.who.kind===`goose`?B(`protocol.where.goose`):e.who.kind===`plugin`?B(`protocol.where.plugin`):``}function Dt(e){let{connectionId:t}=e;return e.connectionName?e.connectorName&&!e.connectionName.includes(e.connectorName)?`${e.connectorName} · ${e.connectionName}`:e.connectionName:t.startsWith(`host:`)?B(`protocol.connection.host`,{host:t.slice(5)}):t===`mail:server`?B(`protocol.connection.serverMail`):t===`rwx`?B(`protocol.connection.rwx`):e.connectorName?`${e.connectorName} · ${t}`:t}function Ot(e){switch(e.actionId){case`change_rules`:return e.input?.fields&&`paused`in e.input.fields?B(e.input.sample===`paused: yes`?`protocol.action.paused`:`protocol.action.resumed`):e.input?.fields&&Object.keys(e.input.fields).join()===`limits`?B(`protocol.action.limits`):B(`protocol.action.changeRules`);case`http_request`:return B(`protocol.action.request`);case`read_secret`:return B(`protocol.action.readSecret`);case`send_message`:return e.actionName??B(`protocol.action.sendMail`);default:return e.actionName??e.actionId}}function kt(e,t){let n={who:t.who,connection:t.connection,verb:_t(e.action.kind)};return e.outcome===`allow`?B(`protocol.ask.allow`,n):e.outcome===`ask`?B(e.admins?`protocol.ask.askAdmins`:`protocol.ask.askPerson`,n):B(`protocol.ask.deny`,{...n,why:bt(e.refused??null,e.rule,t.audience)})}function At(e){return e.fixedChannel?B(`protocol.ask.fixedChannel`):null}function jt(){let[e,t]=m(),{space:n}=ce(),a=ae(),o=e.get(`show`),c=a&&(o===`ask`||o===`notify`)?o:null,l=e=>t(e?{show:e}:{},{replace:!0}),u=e.get(`connection`)??``,d=_({queryKey:[`broker-choices`,n?.id],queryFn:()=>s.get(`/api/studio/spaces/${n?.id}/broker/choices`),enabled:!!n&&a});return n?a?(0,H.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,H.jsx)(It,{spaceId:n.id,connection:u,action:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(i,{variant:`secondary`,size:`sm`,onClick:()=>l(`ask`),children:[(0,H.jsx)(ne,{className:`size-4`}),` `,B(`protocol.ask.title`)]}),(0,H.jsx)(i,{variant:`secondary`,size:`sm`,onClick:()=>l(`notify`),"aria-label":B(`protocol.notify.title`),title:B(`protocol.notify.title`),children:(0,H.jsx)(r,{className:`size-4`})})]})}),(0,H.jsxs)(S,{open:c===`ask`,onClose:()=>l(null),wide:!0,title:B(`protocol.ask.title`),children:[(0,H.jsx)(`p`,{className:`-mt-2 mb-4 text-[0.875rem] text-ink-3`,children:B(`protocol.ask.hint`)}),(0,H.jsx)(Gt,{choices:d.data,spaceId:n.id})]}),(0,H.jsxs)(S,{open:c===`notify`,onClose:()=>l(null),title:B(`protocol.notify.title`),children:[(0,H.jsx)(`p`,{className:`-mt-2 mb-4 text-[0.875rem] text-ink-3`,children:B(`protocol.notify.hint`)}),(0,H.jsx)(Jt,{space:n})]})]}):(0,H.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:(0,H.jsx)(It,{spaceId:n.id,own:!0,connection:u})}):null}var Mt={hour:36e5,day:864e5,week:6048e5,month:2592e6},Nt=[`guest`,`person`,`admin`,`goose`,`plugin`,`step`],Pt=50;function Ft(e,t=300){let[n,r]=(0,V.useState)(e);return(0,V.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function It({spaceId:e,own:t=!1,connection:n=``,action:r}){let[a,o]=(0,V.useState)(`all`),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(n),[p,m]=(0,V.useState)(`week`),[h,g]=(0,V.useState)(``),_=Ft(h).trim(),[y,b]=(0,V.useState)(null),S=ze(e).data?.connections??[],C=j({queryKey:[`broker-log`,e,{outcome:a,who:l,connection:d,range:p,q:_}],initialPageParam:null,queryFn:({pageParam:t})=>{let n=new URLSearchParams({limit:String(Pt)});return a===`refused`?n.set(`refused`,`true`):a===`critical`?n.set(`critical`,`true`):a===`held`&&n.set(`result`,`needs_approval`),l&&n.set(`who`,l),d&&n.set(`connection`,d),p!==`all`&&n.set(`since`,new Date(Date.now()-Mt[p]).toISOString()),_&&n.set(`q`,_),t&&n.set(`cursor`,t),s.get(`/api/studio/spaces/${e}/broker/log?${n}`)},getNextPageParam:e=>e.next}),w=C.data?.pages.flatMap(e=>e.lines)??[],E=a!==`all`||l!==``||d!==``||p!==`all`||_!==``,D=new Set(S.map(e=>e.id));return(0,H.jsx)(c,{title:B(`capabilities.protocol`),hint:B(t?`protocol.own.hint`:`protocol.hint`),action:r,plain:!0,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:(0,H.jsx)(T,{value:a,onChange:o,label:B(`protocol.filter.outcome`),options:[{id:`all`,label:B(`protocol.filter.all`)},{id:`refused`,label:B(`protocol.filter.refused`)},{id:`critical`,label:B(`protocol.filter.critical`)},{id:`held`,label:B(`protocol.filter.held`)}]})}),(0,H.jsxs)(`div`,{className:v(`grid gap-2`,t?`sm:grid-cols-2`:`sm:grid-cols-3`),children:[t?null:(0,H.jsx)(x,{value:l,onChange:u,placeholder:B(`protocol.filter.everyone`),options:Nt.map(e=>({value:e,label:B(`protocol.filter.who.${e}`)}))}),(0,H.jsx)(x,{value:d,onChange:f,placeholder:B(`protocol.filter.everyConnection`),options:S.map(e=>({value:e.id,label:e.connector?`${e.connector.name} · ${e.name}`:e.name}))}),(0,H.jsx)(x,{value:p,onChange:e=>m(e),options:[`hour`,`day`,`week`,`month`,`all`].map(e=>({value:e,label:B(`protocol.range.${e}`)}))})]}),(0,H.jsx)(A,{value:h,onChange:g,placeholder:B(t?`protocol.own.search`:`protocol.search`),busy:C.isFetching&&!C.isFetchingNextPage}),C.error?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:C.error.message}):C.isPending?(0,H.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,H.jsx)(O,{className:`text-ink-3`})}):w.length===0?(0,H.jsx)(`p`,{className:`py-12 text-center text-[0.9375rem] text-ink-3`,children:B(E?`protocol.emptyFiltered`:t?`protocol.own.empty`:`protocol.empty`)}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-2`,children:w.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Bt,{line:t,spaceId:e,open:y===t.id,onToggle:()=>b(y===t.id?null:t.id),ofSpace:D.has(t.connectionId)})},t.id))}),C.hasNextPage?(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(i,{variant:`quiet`,size:`sm`,busy:C.isFetchingNextPage,onClick:()=>void C.fetchNextPage(),children:B(`protocol.more`)})}):null]})})}var Lt={done:ie,refused:me,held:o,failed:k},Rt={done:`text-moss`,refused:`text-rose`,held:`text-ember`,failed:`text-ink-3`};function zt(e,t=!1){return new Date(e).toLocaleString(z,{dateStyle:t?`medium`:`short`,timeStyle:t?`medium`:`short`})}function Bt({line:e,spaceId:t,open:n,onToggle:r,ofSpace:i}){let a=wt(e),o=Lt[a.tone],s=Et(e),c=e.critical||a.tone===`refused`;return(0,H.jsxs)(`div`,{className:v(`rounded-xl bg-card ring-1 transition`,e.critical?`ring-ember/50`:a.tone===`refused`?`ring-rose/40`:`ring-border-soft`),children:[(0,H.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`flex w-full items-start gap-3 px-3.5 py-3 text-left`,children:[(0,H.jsx)(o,{className:v(`mt-0.5 size-4 shrink-0`,Rt[a.tone])}),(0,H.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,H.jsxs)(`span`,{className:`text-[0.9375rem] text-ink leading-snug`,children:[(0,H.jsx)(`b`,{className:`font-medium`,children:Tt(e.who)}),` · `,gt(e.kind),`: `,Ot(e),` · `,Dt(e)]}),(0,H.jsxs)(`span`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:[zt(e.at),s?` · ${s}`:``,` · `,(0,H.jsx)(`span`,{className:v(c&&Rt[a.tone],c&&`font-medium`),children:a.text})]})]}),e.critical?(0,H.jsx)(`span`,{className:`shrink-0`,children:(0,H.jsx)(D,{tone:`ember`,icon:(0,H.jsx)(L,{className:`size-3`}),title:vt(e.criticalKind),children:B(`protocol.critical`)})}):null,(0,H.jsx)(f,{className:v(`mt-0.5 size-4 shrink-0 text-ink-4 transition-transform`,n&&`rotate-180`)})]}),n?(0,H.jsx)(Vt,{line:e,spaceId:t,ofSpace:i}):null]})}function $({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-0.5 sm:grid-cols-[11rem_minmax(0,1fr)] sm:gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-[0.8125rem] text-ink-3`,children:e}),(0,H.jsx)(`dd`,{className:`min-w-0 break-words text-[0.875rem] text-ink-2`,children:t})]})}function Vt({line:e,spaceId:t,ofSpace:n}){let r=_({queryKey:[`broker-line`,t,e.id],queryFn:()=>s.get(`/api/studio/spaces/${t}/broker/log/${e.id}`)}),a=r.data?.run,o=ae(),c=u(),l=M({mutationFn:()=>s.post(`/api/runs/${e.runId}/cancel`),onSuccess:()=>c.invalidateQueries({queryKey:[`broker-line`,t]})}),d=e.input,f=Object.keys(d?.fields??{}),p=e.connectionId.startsWith(`host:`);return(0,H.jsxs)(`div`,{className:`border-border-soft border-t px-3.5 py-3`,children:[(0,H.jsxs)(`dl`,{className:`grid gap-2`,children:[(0,H.jsxs)($,{label:B(`protocol.detail.when`),children:[zt(e.at,!0),` · `,B(`protocol.detail.duration`,{ms:e.durationMs})]}),e.critical?(0,H.jsx)($,{label:B(`protocol.critical`),children:vt(e.criticalKind)}):null,(0,H.jsxs)($,{label:B(`protocol.detail.input`),children:[f.length?B(`protocol.detail.inputFields`,{fields:f.join(`, `),size:d?.size??0}):B(`protocol.detail.inputEmpty`),d?.sample?(0,H.jsx)(`span`,{className:`mt-0.5 block font-mono text-[0.8125rem] text-ink-3`,children:d.sample}):null]}),(0,H.jsx)($,{label:B(`protocol.detail.result`),children:e.resultSize===null?B(`protocol.detail.resultNone`):B(`protocol.detail.resultSize`,{size:e.resultSize})}),(0,H.jsxs)($,{label:B(`protocol.detail.rule`),children:[yt(e.rule),e.reason?(0,H.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.reason}):null]}),a?(0,H.jsx)($,{label:B(`protocol.detail.run`),children:St(a.status)}):null,e.runId?(0,H.jsx)($,{label:B(`protocol.detail.grant`),children:r.isPending?(0,H.jsx)(O,{className:`size-4 text-ink-3`}):n?B(`protocol.detail.grantSpace`):a?.grant?p?a.grant.hosts.length?B(`protocol.detail.grantHosts`,{hosts:a.grant.hosts.join(`, `)}):B(`protocol.detail.grantNoHosts`):a.grant.actions?.length?B(`protocol.detail.grantActions`,{actions:a.grant.actions.join(`, `)}):B(`protocol.detail.grantNoActions`):B(`protocol.detail.grantNone`)}):null]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[e.runId&&e.wizardId?(0,H.jsx)(Ht,{to:`/edit/${e.wizardId}?run=${e.runId}`,children:B(`protocol.detail.openRun`)}):null,e.chatId?(0,H.jsx)(Ht,{to:`/work/c/${e.chatId}`,children:B(`protocol.detail.openChat`)}):null,n?(0,H.jsx)(Ht,{to:`/capabilities/connectors?show=${e.connectionId}`,children:B(`protocol.detail.openConnection`)}):null,o&&a&&Ct(a.status)?(0,H.jsx)(`span`,{className:`sm:ml-auto`,children:(0,H.jsx)(i,{variant:`danger`,size:`sm`,busy:l.isPending,onClick:async()=>{await y(B(`protocol.detail.stopRunAsk`),{detail:B(`protocol.detail.stopRunDetail`),action:B(`protocol.detail.stopRun`)})&&l.mutate()},children:B(`protocol.detail.stopRun`)})}):null]}),l.error?(0,H.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:l.error.message}):null]})}function Ht({to:e,children:t}){return(0,H.jsx)(w,{to:e,className:`inline-flex h-8 items-center rounded-full bg-paper-2 px-3 font-medium text-[0.8125rem] text-ink transition hover:bg-paper-3 coarse:h-11 coarse:px-4`,children:t})}function Ut(e,t){if(e.startsWith(`person:`)){let n=t.people.find(t=>`person:${t.id}`===e);return{who:n&&n.role!==`member`?`admin`:`person`}}return e.startsWith(`step:`)?{who:`step`,for:e.slice(5)}:{who:e}}function Wt(e,t){return e.startsWith(`person:`)?t.people.find(t=>`person:${t.id}`===e)?.name??``:B(e===`guest`?`protocol.ask.who.guest`:e===`goose`?`protocol.ask.who.goose`:`protocol.ask.who.step`)}function Gt({choices:e,spaceId:t}){let[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(``),[o,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(`run`),d=e?.connections.find(e=>e.id===i),f=d?.actions.find(e=>e.id===o),p=n.startsWith(`step:`)?`run`:l,m=!!(e&&n&&d&&f),h=_({queryKey:[`broker-ask`,t,n,i,o,p],queryFn:()=>{let r=new URLSearchParams({...Ut(n,e),resource:i,action:o,in:p});return s.get(`/api/studio/spaces/${t}/broker/ask?${r}`)},enabled:m});if(!e)return(0,H.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,H.jsx)(O,{className:`text-ink-3`})});let g=[...e.people.map(e=>({value:`person:${e.id}`,label:e.role===`member`?e.name:B(`protocol.who.adminNamed`,{name:e.name})})),{value:`guest`,label:B(`protocol.ask.who.guest`)},{value:`goose`,label:B(`protocol.ask.who.goose`)},{value:`step:guest`,label:B(`protocol.ask.who.stepGuest`)},{value:`step:person`,label:B(`protocol.ask.who.stepPerson`)}];return(0,H.jsx)(H.Fragment,{children:e.connections.length===0?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:B(`protocol.ask.noConnections`)}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(qt,{label:B(`protocol.ask.who`),children:(0,H.jsx)(x,{value:n,onChange:e=>r(e),placeholder:B(`protocol.ask.choose`),options:g})}),(0,H.jsx)(qt,{label:B(`protocol.ask.connection`),children:(0,H.jsx)(x,{value:i,onChange:e=>{a(e),c(``)},placeholder:B(`protocol.ask.choose`),options:e.connections.map(e=>({value:e.id,label:e.connector?`${e.connector.name} · ${e.name}`:e.name}))})}),(0,H.jsx)(qt,{label:B(`protocol.ask.action`),children:(0,H.jsx)(x,{value:o,onChange:c,placeholder:B(`protocol.ask.choose`),options:(d?.actions??[]).map(e=>({value:e.id,label:`${e.name} (${gt(e.kind)})`}))})}),(0,H.jsx)(qt,{label:B(`protocol.ask.where`),children:(0,H.jsx)(x,{value:p,onChange:e=>u(e),options:[{value:`run`,label:B(`protocol.ask.inRun`)},{value:`chat`,label:B(`protocol.ask.inChat`),disabled:n.startsWith(`step:`)}]})})]}),(0,H.jsx)(`div`,{className:`rounded-xl bg-paper-2 px-4 py-3.5`,children:m?h.error?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:h.error.message}):h.data?(0,H.jsx)(Kt,{answer:h.data,who:Wt(n,e),connection:d?d.connector?`${d.connector.name} · ${d.name}`:d.name:``,audience:d?.audience}):(0,H.jsx)(O,{className:`size-4 text-ink-3`}):(0,H.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:B(`protocol.ask.pick`)})})]})})}function Kt({answer:e,who:t,connection:n,audience:r}){let i=e.outcome===`allow`?`done`:e.outcome===`ask`?`held`:`refused`,a=Lt[i],o=At(e);return(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(a,{className:v(`mt-1 size-4 shrink-0`,Rt[i])}),(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[(0,H.jsx)(`p`,{className:`font-medium text-[0.9375rem] text-ink leading-snug`,children:kt(e,{who:t,connection:n,audience:r})}),o?(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:o}):null,(0,H.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:B(`protocol.ask.rule`,{rule:yt(e.rule)})}),(0,H.jsx)(`div`,{children:(0,H.jsx)(Ht,{to:`/capabilities/connectors?show=${e.connection.id}`,children:B(`protocol.ask.change`)})})]})]})}function qt({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2`,children:e}),t]})}function Jt({space:e}){let t=u(),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(null),o=e.notify??{bell:!0,mail:`hourly`},c=async n=>{r(!0),a(null);try{await s.patch(`/api/studio/spaces/${e.id}`,{notify:n}),await t.invalidateQueries({queryKey:d.spaces()})}catch(e){a(e.message)}finally{r(!1)}},l=e.readOnly||n;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(Yt,{label:B(`protocol.notify.bell`),hint:B(`protocol.notify.bellHint`),checked:o.bell,disabled:l,onChange:e=>void c({...o,bell:e})}),(0,H.jsx)(Yt,{label:B(`protocol.notify.mail`),hint:B(`protocol.notify.mailHint`),checked:o.mail===`hourly`,disabled:l,onChange:e=>void c({...o,mail:e?`hourly`:`off`})}),i?(0,H.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i}):null]})}function Yt({label:e,hint:t,checked:n,disabled:r,onChange:i}){return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`font-medium text-[0.9375rem] text-ink`,children:e}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:t})]}),(0,H.jsx)(g,{checked:n,onChange:i,label:e,disabled:r})]})}export{it as a,ze as c,Fe as d,W as f,me as h,tt as i,G as l,De as m,jt as n,Ve as o,U as p,rt as r,Be as s,Jt as t,K as u};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Q as i,at as a,gr as o,hn as s,hr as c,in as l,lr as u,mr as d,mt as f,nr as p,pr as m,pt as h,qt as g,un as _,vt as v,yt as ee}from"./ui-BacfkQ7Q.js";import{d as y,n as b}from"./marked.esm-DQ7XA7AC.js";import{c as x}from"./read-aloud-Qb719not.js";import{_ as S,b as C,d as w,f as te,g as T,h as E,m as D,n as ne,p as re,v as O,y as k}from"./theme-y_owNosi.js";import{C as A,S as j,k as ie,x as M}from"./session-CEJRkSP5.js";import{J as N,a as P,l as F,s as I}from"./i18n-DCPDesT-.js";import{n as L}from"./LangSwitch-iO54w9AP.js";var R={name:`bookmark`,size:24,node:[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]};R.node;var ae=y(R),z={name:`square-plus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]],aliases:[`plus-square`]};z.node;var oe=y(z),B=e(t(),1);function se(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`||e===`popout`?e:null}var V=se(),ce=V?new URLSearchParams(window.location.search).get(`page`):null,H=new URLSearchParams(window.location.search).get(`theme`),U=H?`?theme=${encodeURIComponent(H)}`:``,W=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`),le=()=>W(`close`);function ue(e){(0,B.useEffect)(()=>{if(V===`inline`&&!e){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>W(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(V===`modal`||V===`popout`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&W(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[e])}var G=e(n(),1),K=`wizards.runner.translate`,q=new Set;function de(){try{return localStorage.getItem(K)===`on`}catch{return!1}}function fe(e){try{localStorage.setItem(K,e?`on`:`off`)}catch{}for(let e of q)e()}function pe(){return(0,B.useSyncExternalStore)(e=>(q.add(e),()=>q.delete(e)),de)}function me(e){let t=pe(),[n]=(0,B.useState)(()=>F()),r=e?.lang??`en`,a=e?.translatable&&n&&n!==r?n:null,s=a&&t?a:r,c=e?.token,l=o({queryKey:[`public-translation`,c,s],enabled:!!(c&&s!==r),queryFn:()=>i.post(`/api/public/wizards/${c}/translation${U}`,{lang:s}),staleTime:1/0,retry:!1}),u=o({queryKey:[`public-texts`,c,s],enabled:!(!c||N(s)),queryFn:()=>i.get(`/api/public/wizards/${c}/texts/${s}`),staleTime:1/0,retry:!1}),d=!N(s),f=s===r||l.data&&(!d||u.data),p=s!==r&&(l.isError||d&&u.isError),m=f&&!p?s:r,h=(0,B.useMemo)(()=>!N(m)&&u.data?.lang===m?{lang:u.data.lang,runner:u.data.runner,notes:u.data.notes}:null,[m,u.data]);if((0,B.useEffect)(()=>{e&&P(m,h)},[e,m,h]),(0,B.useEffect)(()=>()=>P(null),[]),!e)return null;let g=m!==r&&l.data?l.data:null;return{own:r,other:a,shown:m,wizard:g??e,translating:s!==r&&!f&&!p,failed:!!p,translated:!!g,machine:g?.translation?.machine??!1,pick:e=>fe(e!==r)}}function J({page:e,tone:t=`ground`}){if(!e?.other)return null;let n=e.translating?e.other:e.shown;return(0,G.jsx)(L,{langs:[e.own,e.other],value:n,onPick:e.pick,tone:t})}function Y({page:e,small:t}){if(!e)return null;let n=t?`truncate text-[0.75rem]`:`text-[0.8125rem]`;return e.failed?(0,G.jsx)(`p`,{className:s(`text-ink-3`,n),children:I(`translation.failed`)}):e.translated?(0,G.jsxs)(`p`,{className:s(`text-ink-3`,n),children:[e.machine?(0,G.jsxs)(G.Fragment,{children:[I(`translation.machine`),` · `]}):null,(0,G.jsx)(`button`,{type:`button`,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,onClick:()=>e.pick(e.own),children:I(`translation.showOriginal`)})]}):null}function he(e,t){let n=(0,B.useRef)(null),r=t&&!t.translating?t.translated?t.shown:null:void 0;(0,B.useEffect)(()=>{if(!e||r===void 0)return;let t=`${e}:${r}`;n.current!==t&&(n.current=t,i.post(`/api/runs/${e}/lang`,{lang:r}).catch(()=>void 0))},[e,r])}function ge(e,t){(0,B.useEffect)(()=>{if(!e||!t)return;let n=h(`/api/public/wizards/${e}`),r=[{rel:`manifest`,href:`${n}/manifest.webmanifest`},{rel:`apple-touch-icon`,href:`${n}/icons/apple-touch-icon.png`},{rel:`icon`,href:`${n}/icons/favicon.png`,type:`image/png`}].flatMap(({rel:e,href:t,type:n})=>{let r=document.querySelector(`link[rel="${e}"]`);if(!r)return[];let i={href:r.getAttribute(`href`),type:r.getAttribute(`type`)};return r.setAttribute(`href`,t),n&&r.setAttribute(`type`,n),[{link:r,before:i}]}),i=document.createElement(`meta`);return i.name=`apple-mobile-web-app-title`,i.content=t,document.head.appendChild(i),()=>{for(let{link:e,before:t}of r)for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r);i.remove()}},[e,t])}var _e=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,X=_e||/Android/.test(navigator.userAgent);function ve(){let[e,t]=(0,B.useState)(()=>window.wizardInstall??null),[n,r]=(0,B.useState)(!1);if((0,B.useEffect)(()=>{let e=()=>t(window.wizardInstall??null);return window.addEventListener(`wizard-install`,e),()=>window.removeEventListener(`wizard-install`,e)},[]),window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0||X&&!e&&!_e)return null;let i=/Mac/.test(navigator.platform),a=I(X?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,G.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{X&&e?(e.prompt(),window.wizardInstall=null,t(null)):r(e=>!e)},className:`inline-flex items-center gap-1.5 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[X?(0,G.jsx)(oe,{className:`size-4`}):(0,G.jsx)(ae,{className:`size-4`}),I(X?`install.add`:`install.bookmark`)]}),n?(0,G.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function ye({brand:e,toggle:t=!0,start:n}){return(0,G.jsx)(`header`,{className:`safe-top`,children:(0,G.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[n?(0,G.jsx)(`div`,{className:`absolute left-3`,children:n}):null,e.logoUrl?(0,G.jsx)(`img`,{src:h(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,G.jsx)(`span`,{className:`max-w-[60%] truncate font-display font-semibold text-[0.9375rem] text-ink-2 tracking-tight`,children:e.name}):null,t?(0,G.jsx)(`div`,{className:`absolute right-3`,children:(0,G.jsx)(A,{})}):null]})})}function be({siteKey:e,onToken:t}){let n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let r=()=>{n.current&&window.turnstile&&!n.current.childElementCount&&window.turnstile.render(n.current,{sitekey:e,callback:t,appearance:`interaction-only`})};if(window.turnstile){r();return}let i=document.createElement(`script`);i.src=`https://challenges.cloudflare.com/turnstile/v0/api.js`,i.async=!0,i.onload=r,document.head.appendChild(i)},[e,t]),(0,G.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function xe({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||f||V?null:(0,G.jsxs)(`a`,{href:v(`${window.location.origin}${a}/w/${e}`),className:`mt-3 inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:[(0,G.jsx)(C,{className:`size-4`}),` `,I(`install.app`)]})}var Z=e=>`wz.run.${e}`,Se=()=>m().state?.elsewhere===!0,Ce=f&&new URLSearchParams(window.location.search).get(`start`)===`1`,Q=V===`inline`?`min-h-80`:`min-h-dvh`;function $(e,t,n){let r=d(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),f=(()=>{try{return localStorage.getItem(Z(e.token))}catch{return null}})();return{busy:a,error:s,captcha:l,setCaptcha:u,start:async()=>{o(!0),c(null);try{let{runId:a}=await i.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:l??void 0,embedded:V!==null,origin:ce??void 0,lang:n??void 0});try{localStorage.setItem(Z(e.token),a)}catch{}r(`${t}/${a}`,{replace:Ce})}catch(e){c(e.message),o(!1)}},resume:f?()=>r(`${t}/${f}`):null}}function we({wizard:e,page:t}){let{busy:n,error:i,captcha:a,setCaptcha:o,start:s,resume:c}=$(e,`/w/${e.token}`,t?.translated?t.shown:null),l=Se(),u=Ce&&e.available&&!e.turnstileSiteKey,d=(0,B.useRef)(!1);return(0,B.useEffect)(()=>{u&&!d.current&&(d.current=!0,s())},[u]),u&&!i?(0,G.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,G.jsx)(_,{})}):(0,G.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[l?(0,G.jsx)(`p`,{className:`mb-6 rounded-xl bg-paper-2 px-5 py-3 text-[0.875rem] text-ink-2`,children:I(`run.elsewhere`)}):null,(0,G.jsx)(j,{kind:e.avatar,costume:e.costume,size:190,fluffy:!0}),(0,G.jsx)(`h1`,{className:`wizard-title mt-2 text-balance font-display font-semibold text-[1.875rem] leading-[1.1] tracking-tight sm:text-[2.125rem]`,children:e.title}),e.description?(0,G.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,(0,G.jsx)(`div`,{className:`mt-3`,children:(0,G.jsx)(Y,{page:t})}),e.available?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(r,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!a,onClick:s,children:[I(`run.start`),` `,(0,G.jsx)(p,{className:`size-4`})]}),e.turnstileSiteKey?(0,G.jsx)(be,{siteKey:e.turnstileSiteKey,onToken:o}):null,c?(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:I(`run.resume`)}):null,(0,G.jsx)(Te,{wizard:e,current:`steps`}),V||f?null:(0,G.jsx)(ve,{}),(0,G.jsx)(xe,{token:e.token})]}):(0,G.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??I(`run.unavailable`)}),i?(0,G.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:i}):null]})}function Te({wizard:e,current:t}){let n=e.runners.filter(e=>e.id!==t&&e.kind===`page`&&e.url);return n.length?(0,G.jsx)(`p`,{className:`mt-4 flex flex-wrap justify-center gap-x-4 text-[0.875rem] text-ink-3`,children:n.map(e=>(0,G.jsx)(`a`,{href:e.url??void 0,className:`underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:I(`run.orAs`,{label:e.label})},e.id))}):null}function Ee({wizard:e,page:t}){let n=k();return(0,G.jsx)(`header`,{className:`safe-top shrink-0 border-border-soft border-b`,children:(0,G.jsxs)(`div`,{className:`mx-auto flex h-16 w-full max-w-[760px] items-center gap-3 pr-2 pl-4 sm:pr-4 sm:pl-6`,children:[(0,G.jsx)(`span`,{className:s(n?.speaking&&`animate-breathe`),children:(0,G.jsx)(j,{kind:e.avatar,costume:e.costume,size:38})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-display font-semibold text-[1rem] leading-tight tracking-tight`,children:e.title}),e.brand.name?(0,G.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:e.brand.name}):null,(0,G.jsx)(Y,{page:t,small:!0})]}),e.brand.logoUrl&&V!==`popout`?(0,G.jsx)(`img`,{src:h(e.brand.logoUrl),alt:e.brand.name,className:`h-6 max-w-[120px] object-contain max-sm:hidden`}):null,(0,G.jsx)(J,{page:t,tone:`surface`}),V?null:(0,G.jsx)(A,{}),V===`popout`?(0,G.jsx)(l,{label:I(`common.close`),onClick:le,children:(0,G.jsx)(b,{className:`size-5`})}):null]})})}function De({door:e,wizard:t,page:n,header:r,footer:i}){let{busy:a,error:o,captcha:s,setCaptcha:c,start:l,resume:u}=$(t,`/w/${t.token}/${e}`,n?.translated?n.shown:null),d=Se(),f=[];return d&&f.push({key:`elsewhere`,who:`bot`,node:I(`run.elsewhere`)}),f.push({key:`hello`,who:`bot`,node:t.description||t.title}),e!==`chat`&&f.push({key:e,who:`bot`,node:I(e===`video`?`video.hint`:`talk.joinHint`)}),t.available||f.push({key:`unavailable`,who:`bot`,node:t.unavailableReason??I(`run.unavailable`)}),o&&f.push({key:`error`,who:`bot`,node:o,tone:`error`}),t.available&&f.push(O(`start`,(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(T,{primary:!0,busy:a,disabled:!!t.turnstileSiteKey&&!s,onClick:()=>void l(),children:[I(`run.start`),` `,(0,G.jsx)(p,{className:`size-4`})]}),u?(0,G.jsx)(T,{onClick:u,children:I(`run.resume`)}):null,t.turnstileSiteKey?(0,G.jsx)(be,{siteKey:t.turnstileSiteKey,onToken:c}):null]}))),(0,G.jsxs)(D,{header:r,footer:i,children:[(0,G.jsx)(S,{avatar:t.avatar,costume:t.costume,lines:f}),(0,G.jsx)(E,{})]})}function Oe({className:e}){return(0,G.jsx)(`footer`,{className:s(`text-center text-ink-4`,e),children:(0,G.jsx)(`a`,{href:`${a}/`,target:V?`_blank`:void 0,rel:`noreferrer`,className:`inline-block hover:text-ink-2`,children:I(`run.madeWith`).replace(`engenty wizards`,M.name)})})}function ke({chat:e=!1,steps:t=!1,talk:n=!1,video:l=!1}){let{token:p,runId:m}=c(),h=d(),v=o({queryKey:[`public`,p,U],queryFn:()=>i.get(`/api/public/wizards/${p}${U}`),retry:(e,t)=>g(t)&&e<3}),y=v.data?.runners??[],b=!v.data||y.some(e=>e.id===`talk`),S=!v.data||y.some(e=>e.id===`video`),C=!v.data||y.some(e=>e.id===`chat`)||n&&b||l&&S,T=y[0]?.id,E=e||V===`popout`||!t&&!m&&C&&(T===`chat`||T===`talk`||T===`video`),D=l&&S||!t&&!e&&!n&&T===`video`,O=!D&&(n&&b||!t&&!e&&T===`talk`),k=D?`video`:O?`talk`:`chat`,A=me(v.data);he(m,A),ne(v.data?.brand.theme),ie(v.data?.avatar),ge(p,v.data?.title),ue(E);let N=A?.wizard.title??v.data?.title;(0,B.useEffect)(()=>{N&&(document.title=N)},[N]);let P=(0,B.useCallback)(e=>{try{p&&localStorage.getItem(Z(p))===m&&localStorage.removeItem(Z(p))}catch{}h(e,{replace:!0,state:{elsewhere:!0}})},[h,p,m]);if((0,B.useEffect)(()=>{p&&m&&ee(`run`,{token:p,runId:m})},[p,m]),v.isLoading)return(0,G.jsx)(`div`,{className:s(`flex items-center justify-center text-ink-4`,Q),children:(0,G.jsx)(_,{})});if(e&&v.data&&!C||n&&v.data&&!b||l&&v.data&&!S)return(0,G.jsx)(u,{to:`/w/${p}`,replace:!0});if(!v.data){let e=g(v.error);return(0,G.jsxs)(`div`,{className:s(`flex flex-col items-center justify-center gap-4 px-6 text-center`,Q),children:[(0,G.jsx)(j,{kind:`pebble`,size:80}),(0,G.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:I(e?`common.offline`:`run.notFound`)}),e?(0,G.jsx)(r,{variant:`secondary`,onClick:()=>void v.refetch(),children:I(`common.retry`)}):null]})}let F=A?.wizard??v.data,L=A?.translating?(0,G.jsxs)(`div`,{className:s(`flex flex-col items-center justify-center gap-3 text-ink-3`,Q),children:[(0,G.jsx)(_,{}),(0,G.jsx)(`p`,{className:`text-[0.875rem]`,children:I(`translation.working`)})]}):null;if(E){let e=(0,G.jsx)(Ee,{wizard:F,page:A}),t=f?(0,G.jsx)(`div`,{className:`safe-bottom`}):(0,G.jsx)(Oe,{className:`pb-[max(0.375rem,env(safe-area-inset-bottom))] text-[0.6875rem]`});return(0,G.jsxs)(`div`,{className:`wizard-page flex h-dvh flex-col`,children:[(0,G.jsx)(w,{effects:v.data.brand.theme.effects}),V||f?null:(0,G.jsx)(x,{}),L??(m?(0,G.jsx)(re,{runId:m,talk:O,call:D?`video`:O?`audio`:!1,onRestart:()=>h(`/w/${p}/${k}`),onNotFound:()=>P(`/w/${p}/${k}`),header:D||O?void 0:e,footer:t}):(0,G.jsx)(De,{wizard:F,page:A,header:e,footer:t,door:k}))]})}return(0,G.jsxs)(`div`,{className:s(`wizard-page flex flex-col`,Q),children:[(0,G.jsx)(w,{effects:v.data.brand.theme.effects}),V||f?null:(0,G.jsx)(x,{}),V===`inline`||f?null:(0,G.jsx)(ye,{brand:v.data.brand,toggle:!V,start:(0,G.jsx)(J,{page:A})}),V===`inline`||f?(0,G.jsx)(`div`,{className:`flex justify-end px-3 pt-2`,children:(0,G.jsx)(J,{page:A,tone:`surface`})}):null,m&&(A?.translated||A?.failed)?(0,G.jsx)(`div`,{className:`flex justify-center px-5`,children:(0,G.jsx)(Y,{page:A})}):null,(0,G.jsx)(`div`,{className:`flex-1`,children:L??(m?(0,G.jsx)(te,{runId:m,onRestart:()=>h(`/w/${p}`),onNotFound:()=>P(`/w/${p}`)}):(0,G.jsx)(we,{wizard:F,page:A}))}),f?(0,G.jsx)(`div`,{className:`safe-bottom`}):(0,G.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,G.jsx)(`a`,{href:`${a}/`,target:V?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:I(`run.madeWith`).replace(`engenty wizards`,M.name)})})]})}export{ye as BrandHeader,ke as PublicRunner};