wizards 0.2.17 → 0.2.19

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 (68) hide show
  1. package/apps/runtime/dist/agents/project-assistant.js +20 -2
  2. package/apps/runtime/dist/authoring/guide.js +6 -3
  3. package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +104 -0
  4. package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +2837 -0
  5. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  6. package/apps/runtime/dist/db/schema.js +160 -8
  7. package/apps/runtime/dist/engine/steps.js +3 -11
  8. package/apps/runtime/dist/env.js +2 -0
  9. package/apps/runtime/dist/files/storage.js +15 -0
  10. package/apps/runtime/dist/models.js +38 -0
  11. package/apps/runtime/dist/plugins/loader.js +2 -0
  12. package/apps/runtime/dist/routes/studio.js +147 -6
  13. package/apps/runtime/dist/services/cloud.js +59 -1
  14. package/apps/runtime/dist/services/knowledge-model.js +558 -0
  15. package/apps/runtime/dist/services/knowledge.js +721 -0
  16. package/apps/runtime/dist/services/project-files.js +114 -6
  17. package/apps/runtime/dist/services/project-index.js +632 -94
  18. package/apps/runtime/dist/services/relevance.js +90 -0
  19. package/apps/runtime/dist/services/space-categories.js +882 -0
  20. package/apps/runtime/dist/services/space-data.js +466 -38
  21. package/apps/runtime/dist/services/space-origin.js +164 -0
  22. package/apps/runtime/dist/services/spaces.js +155 -1
  23. package/apps/runtime/dist/tools/pages.js +27 -22
  24. package/apps/runtime/dist/tools/project.js +130 -40
  25. package/apps/web/dist/assets/{Account-LVXhagaS.js → Account-O6OTAY88.js} +1 -1
  26. package/apps/web/dist/assets/{ChangelogDialog-DM0KAoy6.js → ChangelogDialog-DLrXuyLL.js} +1 -1
  27. package/apps/web/dist/assets/{ChatPanel-CxOQmtv-.js → ChatPanel-BPD-iQK0.js} +1 -1
  28. package/apps/web/dist/assets/{CreditsDialog-DkW3YT44.js → CreditsDialog-Ckema8Ss.js} +1 -1
  29. package/apps/web/dist/assets/{EditorPage-hbisE1Wf.js → EditorPage-Dtu9j41h.js} +1 -1
  30. package/apps/web/dist/assets/{FlowPreview-v7or29ku.js → FlowPreview-DB-86F8z.js} +1 -1
  31. package/apps/web/dist/assets/{Harness-RZF-bBmb.js → Harness-D-DSa4ip.js} +1 -1
  32. package/apps/web/dist/assets/{HomePage-mxG-a_KU.js → HomePage-ZrCxIiJT.js} +1 -1
  33. package/apps/web/dist/assets/{ImportWizard-CiPyUt3E.js → ImportWizard-DtZH-PgS.js} +1 -1
  34. package/apps/web/dist/assets/{LocalRuntime-Dqp9wkN3.js → LocalRuntime-o1OAvp7c.js} +1 -1
  35. package/apps/web/dist/assets/NewWizardPage-Bbt-w8tE.js +2 -0
  36. package/apps/web/dist/assets/ProjectPage-MHxFqA98.js +5 -0
  37. package/apps/web/dist/assets/{PublicRunner-TGkOwbAP.js → PublicRunner-CYo2F8H4.js} +1 -1
  38. package/apps/web/dist/assets/{RunnerView-DzHGshZj.js → RunnerView-Bqp0paLi.js} +1 -1
  39. package/apps/web/dist/assets/{SettingsPage-CG3Xtfej.js → SettingsPage-XyRrZeMr.js} +1 -1
  40. package/apps/web/dist/assets/{SetupPage-O1GfPlqX.js → SetupPage-CdBYFmh1.js} +1 -1
  41. package/apps/web/dist/assets/{SharePage-CCNUhtry.js → SharePage-B7ON0pe1.js} +1 -1
  42. package/apps/web/dist/assets/{api-DB22_B7G.js → api-CVG-xDEn.js} +1 -1
  43. package/apps/web/dist/assets/changelog-B2U80Wtl.js +1 -0
  44. package/apps/web/dist/assets/{esm-3TT9i_rv.js → esm-DutMJAod.js} +1 -1
  45. package/apps/web/dist/assets/index-Bwyehu0k.css +1 -0
  46. package/apps/web/dist/assets/{index-CLe9Wrpu.js → index-hpNaR92X.js} +3 -3
  47. package/apps/web/dist/assets/{meta-CEsBCPfA.js → meta--kpiTOS-.js} +1 -1
  48. package/apps/web/dist/assets/{settings-menu-pOcjznGJ.js → settings-menu-BXpT5jOB.js} +1 -1
  49. package/apps/web/dist/assets/ui-BPY2pIh0.js +1 -0
  50. package/apps/web/dist/index.html +4 -4
  51. package/apps/web/dist/mcp/flow.html +2 -2
  52. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +164 -0
  53. package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +199 -0
  54. package/node_modules/@engenty-wizards/shared/dist/knowledge.js +68 -0
  55. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +13 -1
  56. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +3 -0
  57. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +1 -16
  58. package/node_modules/@engenty-wizards/shared/dist/projects.js +1 -1
  59. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +8 -0
  60. package/node_modules/@engenty-wizards/shared/dist/run.js +5 -0
  61. package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +20 -0
  62. package/node_modules/@engenty-wizards/shared/dist/space-data.js +2 -1
  63. package/package.json +1 -1
  64. package/apps/web/dist/assets/NewWizardPage-DHwRsi0_.js +0 -2
  65. package/apps/web/dist/assets/ProjectPage-Bb7jN_6n.js +0 -4
  66. package/apps/web/dist/assets/changelog-BkIJdZ7M.js +0 -1
  67. package/apps/web/dist/assets/index-BPpKz65x.css +0 -1
  68. package/apps/web/dist/assets/ui-I7QYMX0F.js +0 -1
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{h as r}from"./ui-I7QYMX0F.js";import{a as i,c as a,i as o,n as s,r as c,s as l,t as u}from"./esm-3TT9i_rv.js";var d=e(t(),1),f=e(n(),1),p=208,m=42,h=26,g=22,_=132;function v({data:e}){let t=e.icon;return(0,f.jsxs)(`div`,{style:{width:p,height:m},className:r(`flex cursor-default items-center gap-2.5 rounded-xl px-2.5`,e.optional?`border border-ink-4 border-dashed`:`bg-paper-2 ring-1 ring-border-soft`),children:[(0,f.jsx)(c,{type:`target`,position:a.Top}),(0,f.jsx)(c,{type:`target`,id:`in`,position:a.Right}),(0,f.jsx)(`span`,{className:r(`inline-flex size-6 shrink-0 items-center justify-center rounded-md`,e.tone),children:(0,f.jsx)(t,{className:`size-3.5`})}),(0,f.jsx)(`span`,{className:`truncate font-medium text-[0.8125rem] text-ink`,children:e.title}),(0,f.jsx)(c,{type:`source`,position:a.Bottom}),(0,f.jsx)(c,{type:`source`,id:`out`,position:a.Right})]})}function y({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,markerEnd:a}){let o=Math.max(e,n)+g,c=[`M ${e} ${t}`,`H ${o-8}`,`Q ${o} ${t} ${o} ${t+8}`,`V ${r-8}`,`Q ${o} ${r} ${o-8} ${r}`,`H ${n}`].join(` `);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u,{path:c,markerEnd:a,style:{strokeDasharray:`5 4`}}),(0,f.jsx)(s,{children:(0,f.jsx)(`div`,{style:{width:_,transform:`translate(${o+8}px, ${(t+r)/2}px) translateY(-50%)`},className:`absolute text-[0.6875rem] text-ink-2 leading-snug`,children:i})})]})}var b={step:v},x={branch:y};function S(e){let t={markerEnd:{type:l.ArrowClosed,width:14,height:14,color:`var(--ink-4)`}},n=e.map((e,t)=>({id:e.id,type:`step`,position:{x:0,y:t*68},data:{title:e.title,icon:e.icon,tone:e.tone,optional:e.optional},draggable:!1})),r=[],i=!1;return e.forEach((n,a)=>{let o=e[a+1];for(let[a,o]of(n.branches??[]).entries())e.some(e=>e.id===o.to)&&(i=!0,r.push({id:`b-${n.id}-${a}`,type:`branch`,source:n.id,sourceHandle:`out`,target:o.to,targetHandle:`in`,label:o.when,...t}));o&&r.push({id:`n-${n.id}`,type:`straight`,source:n.id,target:o.id,...t})}),{nodes:n,edges:r,width:p+(i?162:0),height:e.length*68-h}}function C({steps:e}){let{nodes:t,edges:n,width:r,height:a}=(0,d.useMemo)(()=>S(e),[e]);return e.length?(0,f.jsx)(`div`,{className:`max-w-full`,style:{width:r,height:a+4},children:(0,f.jsx)(o,{children:(0,f.jsx)(i,{nodes:t,edges:n,nodeTypes:b,edgeTypes:x,defaultViewport:{x:1,y:2,zoom:1},minZoom:1,maxZoom:1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,edgesFocusable:!1,elementsSelectable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0}})})}):null}export{C as default};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{h as r}from"./ui-BPY2pIh0.js";import{a as i,c as a,i as o,n as s,r as c,s as l,t as u}from"./esm-DutMJAod.js";var d=e(t(),1),f=e(n(),1),p=208,m=42,h=26,g=22,_=132;function v({data:e}){let t=e.icon;return(0,f.jsxs)(`div`,{style:{width:p,height:m},className:r(`flex cursor-default items-center gap-2.5 rounded-xl px-2.5`,e.optional?`border border-ink-4 border-dashed`:`bg-paper-2 ring-1 ring-border-soft`),children:[(0,f.jsx)(c,{type:`target`,position:a.Top}),(0,f.jsx)(c,{type:`target`,id:`in`,position:a.Right}),(0,f.jsx)(`span`,{className:r(`inline-flex size-6 shrink-0 items-center justify-center rounded-md`,e.tone),children:(0,f.jsx)(t,{className:`size-3.5`})}),(0,f.jsx)(`span`,{className:`truncate font-medium text-[0.8125rem] text-ink`,children:e.title}),(0,f.jsx)(c,{type:`source`,position:a.Bottom}),(0,f.jsx)(c,{type:`source`,id:`out`,position:a.Right})]})}function y({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,markerEnd:a}){let o=Math.max(e,n)+g,c=[`M ${e} ${t}`,`H ${o-8}`,`Q ${o} ${t} ${o} ${t+8}`,`V ${r-8}`,`Q ${o} ${r} ${o-8} ${r}`,`H ${n}`].join(` `);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u,{path:c,markerEnd:a,style:{strokeDasharray:`5 4`}}),(0,f.jsx)(s,{children:(0,f.jsx)(`div`,{style:{width:_,transform:`translate(${o+8}px, ${(t+r)/2}px) translateY(-50%)`},className:`absolute text-[0.6875rem] text-ink-2 leading-snug`,children:i})})]})}var b={step:v},x={branch:y};function S(e){let t={markerEnd:{type:l.ArrowClosed,width:14,height:14,color:`var(--ink-4)`}},n=e.map((e,t)=>({id:e.id,type:`step`,position:{x:0,y:t*68},data:{title:e.title,icon:e.icon,tone:e.tone,optional:e.optional},draggable:!1})),r=[],i=!1;return e.forEach((n,a)=>{let o=e[a+1];for(let[a,o]of(n.branches??[]).entries())e.some(e=>e.id===o.to)&&(i=!0,r.push({id:`b-${n.id}-${a}`,type:`branch`,source:n.id,sourceHandle:`out`,target:o.to,targetHandle:`in`,label:o.when,...t}));o&&r.push({id:`n-${n.id}`,type:`straight`,source:n.id,target:o.id,...t})}),{nodes:n,edges:r,width:p+(i?162:0),height:e.length*68-h}}function C({steps:e}){let{nodes:t,edges:n,width:r,height:a}=(0,d.useMemo)(()=>S(e),[e]);return e.length?(0,f.jsx)(`div`,{className:`max-w-full`,style:{width:r,height:a+4},children:(0,f.jsx)(o,{children:(0,f.jsx)(i,{nodes:t,edges:n,nodeTypes:b,edgeTypes:x,defaultViewport:{x:1,y:2,zoom:1},minZoom:1,maxZoom:1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,edgesFocusable:!1,elementsSelectable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0}})})}):null}export{C as default};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,n as i,nt as a}from"./api-DB22_B7G.js";import{t as o}from"./refresh-cw-BNtHis1x.js";import{t as s}from"./check-CUpby_J9.js";import{b as c,h as l,t as u}from"./ui-I7QYMX0F.js";import{U as d}from"./index-CLe9Wrpu.js";import{n as f}from"./LocalRuntime-Dqp9wkN3.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,n as i,nt as a}from"./api-CVG-xDEn.js";import{t as o}from"./refresh-cw-BNtHis1x.js";import{t as s}from"./check-CUpby_J9.js";import{b as c,h as l,t as u}from"./ui-BPY2pIh0.js";import{U as d}from"./index-hpNaR92X.js";import{n as f}from"./LocalRuntime-o1OAvp7c.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ze=w(`CharSizeService`),Be=w(`CoreBrowserService`),Ve=w(`MouseService`),He=w(`RenderService`),Ue=w(`SelectionService`),We=w(`CharacterJoinerService`),Ge=w(`ThemeService`),Ke=w(`LinkProviderService`),qe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$e.isErrorNoTelemetry(e)?new $e(e.message+`
4
4
 
@@ -1 +1 @@
1
- import{a as e,i as t,n,t as r}from"./jsx-runtime-D3jfb0Ew.js";import{O as i,d as a,j as o,n as s,nt as c,w as l}from"./api-DB22_B7G.js";import{t as u}from"./createLucideIcon-q3MZMmnf.js";import{t as d}from"./check-CUpby_J9.js";import{n as f,t as p}from"./plus-Du-Jx8aI.js";import{n as m,r as h}from"./Account-LVXhagaS.js";import{a as g,b as _,i as v,n as y,o as b,r as x,s as S,t as C,u as w,v as T}from"./ui-I7QYMX0F.js";import{D as E,E as D,U as O,a as k,c as A,l as j,p as M,s as N,w as P}from"./index-CLe9Wrpu.js";import{n as F}from"./LocalRuntime-Dqp9wkN3.js";import{t as I}from"./ImportWizard-CiPyUt3E.js";var L={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};L.node;var R=u(L),z=t({HomePage:()=>J,ProjectSwitcher:()=>H}),B=e(n(),1),V=e(r(),1);function H(){let{project:e,projects:t,select:n}=P(),r=E().data?.limits.projects??1,i=D(),a=c(),[o,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=O({mutationFn:()=>s.post(`/api/studio/projects`,{name:u}),onSuccess:async({id:e})=>{await a.invalidateQueries({queryKey:[`projects`]}),n(e),l(!1),d(``)}});return!e||r<=1?null:(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(w,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?l(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[t.length<r?{value:`__new`,label:`+ ${_(`home.newProject`)}`}:{value:`__new`,label:_(`home.projectLimit`,{n:r}),disabled:!0}]:[]]}),(0,V.jsx)(v,{open:o,onClose:()=>l(!1),title:_(`home.newProject`),children:(0,V.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.trim()&&f.mutate()},children:[(0,V.jsx)(S,{autoFocus:!0,placeholder:_(`home.projectName`),value:u,onChange:e=>d(e.target.value)}),(0,V.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,V.jsx)(C,{variant:`ghost`,onClick:()=>l(!1),children:_(`common.cancel`)}),(0,V.jsx)(C,{type:`submit`,busy:f.isPending,disabled:!u.trim(),children:_(`home.newProject`)})]})]})})]})}function U({url:e}){let[t,n]=(0,B.useState)(!1);return(0,V.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,V.jsx)(d,{className:`size-3.5`}):(0,V.jsx)(f,{className:`size-3.5`}),_(t?`share.copied`:`share.link`)]})}function W(){let e=i(),t=h(!1),[n,r]=(0,B.useState)(!1),a=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!n)return;let e=e=>{a.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,V.jsxs)(`div`,{className:`relative`,ref:a,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,V.jsx)(f,{className:`size-3.5`}),` `,_(`share.link`)]}),n?(0,V.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,V.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:_(`teaser.link`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:_(`account.signIn`)}),(0,V.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:_(`account.create`)})]}),(0,V.jsx)(m,{...t})]}):null]})}function G({w:e,me:t}){let n=i(),r=j(e,t,e.cloud),o=A(r),s=o??(e.published?N(e):null);return(0,V.jsxs)(`div`,{className:`relative pt-6`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,V.jsx)(a,{kind:e.avatar,size:52,interactive:!1})}),(0,V.jsxs)(y,{className:`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,onClick:()=>n(`/edit/${e.id}`),children:[(0,V.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,V.jsx)(k,{where:r,me:t}):(0,V.jsx)(x,{children:_(`home.draft`)})}),(0,V.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,V.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,V.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:_(`home.steps`,{n:e.stepCount})}),(0,V.jsxs)(`div`,{className:`flex items-center`,children:[o?(0,V.jsx)(U,{url:o}):r.kind===`here`&&M.account?(0,V.jsx)(W,{}):null,s?(0,V.jsx)(b,{label:_(o?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),F(s)},children:(0,V.jsx)(R,{className:`size-4`})}):null]})]})]})]})}var K=`curl -fsSL https://engenty.ai/install.sh | bash`;function q(){let[e,t]=(0,B.useState)(!1),n=[_(`home.local.install`),_(`home.local.signIn`),_(`home.local.publish`)];return(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,V.jsx)(a,{kind:`round`,size:120}),(0,V.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:_(`home.local.title`)}),(0,V.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:_(`home.local.text`)}),(0,V.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,V.jsxs)(`li`,{className:`flex gap-3`,children:[(0,V.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,V.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,V.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,V.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:K}),(0,V.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(K),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,V.jsx)(d,{className:`size-3.5`}):(0,V.jsx)(f,{className:`size-3.5`}),_(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function J(){let e=i(),{project:t,projects:n,loading:r}=P(),a=E().data,c=D(),u=o({queryKey:[`wizards`,t?.id,!!a?.account],queryFn:()=>s.get(`/api/studio/projects/${t.id}/wizards`),enabled:!!t}),d=n.reduce((e,t)=>e+t.wizardCount,0),f=c&&!t?.readOnly;return!r&&f&&n.length&&d===0?(0,V.jsx)(l,{to:`/new`,replace:!0}):!r&&!c&&n.length===0?(0,V.jsx)(q,{}):(0,V.jsxs)(`div`,{className:`animate-rise`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(H,{})}),f?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(I,{}),(0,V.jsxs)(C,{onClick:()=>e(`/new`),children:[(0,V.jsx)(p,{className:`size-4`}),` `,_(`home.new`)]})]}):null]}),(0,V.jsx)(`h1`,{className:`mt-10 font-display font-semibold text-[1.75rem] tracking-tight`,children:_(`home.title`)}),t?.origin===`local`?(0,V.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[_(`home.fromLocal`),` `,t.syncedAt?_(`home.syncedAt`,{when:new Intl.DateTimeFormat(T,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.syncedAt))}):null]}):null,u.data&&u.data.length===0?(0,V.jsx)(g,{children:_(`home.empty`)}):null,(0,V.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:a?u.data?.map(e=>(0,V.jsx)(G,{w:e,me:a},e.id)):null})]})}export{H as n,z as t};
1
+ import{a as e,i as t,n,t as r}from"./jsx-runtime-D3jfb0Ew.js";import{O as i,d as a,j as o,n as s,nt as c,w as l}from"./api-CVG-xDEn.js";import{t as u}from"./createLucideIcon-q3MZMmnf.js";import{t as d}from"./check-CUpby_J9.js";import{n as f,t as p}from"./plus-Du-Jx8aI.js";import{n as m,r as h}from"./Account-O6OTAY88.js";import{a as g,b as _,i as v,n as y,o as b,r as x,s as S,t as C,u as w,v as T}from"./ui-BPY2pIh0.js";import{D as E,E as D,U as O,a as k,c as A,l as j,p as M,s as N,w as P}from"./index-hpNaR92X.js";import{n as F}from"./LocalRuntime-o1OAvp7c.js";import{t as I}from"./ImportWizard-DtZH-PgS.js";var L={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};L.node;var R=u(L),z=t({HomePage:()=>J,ProjectSwitcher:()=>H}),B=e(n(),1),V=e(r(),1);function H(){let{project:e,projects:t,select:n}=P(),r=E().data?.limits.projects??1,i=D(),a=c(),[o,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=O({mutationFn:()=>s.post(`/api/studio/projects`,{name:u}),onSuccess:async({id:e})=>{await a.invalidateQueries({queryKey:[`projects`]}),n(e),l(!1),d(``)}});return!e||r<=1?null:(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(w,{className:`w-56`,value:e.id,onChange:e=>e===`__new`?l(!0):n(e),options:[...t.map(e=>({value:e.id,label:e.name})),...i?[t.length<r?{value:`__new`,label:`+ ${_(`home.newProject`)}`}:{value:`__new`,label:_(`home.projectLimit`,{n:r}),disabled:!0}]:[]]}),(0,V.jsx)(v,{open:o,onClose:()=>l(!1),title:_(`home.newProject`),children:(0,V.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u.trim()&&f.mutate()},children:[(0,V.jsx)(S,{autoFocus:!0,placeholder:_(`home.projectName`),value:u,onChange:e=>d(e.target.value)}),(0,V.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,V.jsx)(C,{variant:`ghost`,onClick:()=>l(!1),children:_(`common.cancel`)}),(0,V.jsx)(C,{type:`submit`,busy:f.isPending,disabled:!u.trim(),children:_(`home.newProject`)})]})]})})]})}function U({url:e}){let[t,n]=(0,B.useState)(!1);return(0,V.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[t?(0,V.jsx)(d,{className:`size-3.5`}):(0,V.jsx)(f,{className:`size-3.5`}),_(t?`share.copied`:`share.link`)]})}function W(){let e=i(),t=h(!1),[n,r]=(0,B.useState)(!1),a=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!n)return;let e=e=>{a.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]),(0,V.jsxs)(`div`,{className:`relative`,ref:a,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[(0,V.jsx)(f,{className:`size-3.5`}),` `,_(`share.link`)]}),n?(0,V.jsxs)(`div`,{className:`absolute right-0 bottom-10 z-20 flex w-72 animate-rise flex-col gap-3 rounded-xl bg-card p-3.5 shadow-overlay ring-1 ring-border-soft`,children:[(0,V.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-relaxed`,children:_(`teaser.link`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{size:`sm`,busy:t.link.isPending,onClick:()=>t.link.mutate({}),children:_(`account.signIn`)}),(0,V.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>e(`/settings/account`),children:_(`account.create`)})]}),(0,V.jsx)(m,{...t})]}):null]})}function G({w:e,me:t}){let n=i(),r=j(e,t,e.cloud),o=A(r),s=o??(e.published?N(e):null);return(0,V.jsxs)(`div`,{className:`relative pt-6`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute top-0 left-4 z-10`,children:(0,V.jsx)(a,{kind:e.avatar,size:52,interactive:!1})}),(0,V.jsxs)(y,{className:`relative flex h-full cursor-pointer flex-col px-5 pt-10 pb-3 transition hover:shadow-elevated`,onClick:()=>n(`/edit/${e.id}`),children:[(0,V.jsx)(`div`,{className:`absolute top-3 right-3`,children:e.published?(0,V.jsx)(k,{where:r,me:t}):(0,V.jsx)(x,{children:_(`home.draft`)})}),(0,V.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem] leading-snug`,children:e.title}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[0.875rem] text-ink-3`,children:e.description}),(0,V.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between pt-3`,children:[(0,V.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:_(`home.steps`,{n:e.stepCount})}),(0,V.jsxs)(`div`,{className:`flex items-center`,children:[o?(0,V.jsx)(U,{url:o}):r.kind===`here`&&M.account?(0,V.jsx)(W,{}):null,s?(0,V.jsx)(b,{label:_(o?`share.open`:`share.openHere`),className:`ml-1 size-8`,onClick:e=>{e.stopPropagation(),F(s)},children:(0,V.jsx)(R,{className:`size-4`})}):null]})]})]})]})}var K=`curl -fsSL https://engenty.ai/install.sh | bash`;function q(){let[e,t]=(0,B.useState)(!1),n=[_(`home.local.install`),_(`home.local.signIn`),_(`home.local.publish`)];return(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-xl animate-rise flex-col items-center pt-4 text-center`,children:[(0,V.jsx)(a,{kind:`round`,size:120}),(0,V.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[1.75rem] leading-tight tracking-tight`,children:_(`home.local.title`)}),(0,V.jsx)(`p`,{className:`mt-3 text-[0.9375rem] text-ink-2 leading-relaxed`,children:_(`home.local.text`)}),(0,V.jsx)(`ol`,{className:`mt-8 flex w-full flex-col gap-4 text-left`,children:n.map((n,r)=>(0,V.jsxs)(`li`,{className:`flex gap-3`,children:[(0,V.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-paper-2 font-medium text-[0.8125rem] text-ink-2`,children:r+1}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,V.jsx)(`p`,{className:`text-[0.9375rem] leading-snug`,children:n}),r===0?(0,V.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 rounded-lg bg-paper-2 py-1.5 pr-1.5 pl-3`,children:[(0,V.jsx)(`code`,{className:`min-w-0 flex-1 select-all overflow-x-auto whitespace-nowrap font-mono text-[0.8125rem] text-ink-2`,children:K}),(0,V.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(K),t(!0),setTimeout(()=>t(!1),1500)},children:[e?(0,V.jsx)(d,{className:`size-3.5`}):(0,V.jsx)(f,{className:`size-3.5`}),_(e?`share.copied`:`share.copy`)]})]}):null]})]},n))})]})}function J(){let e=i(),{project:t,projects:n,loading:r}=P(),a=E().data,c=D(),u=o({queryKey:[`wizards`,t?.id,!!a?.account],queryFn:()=>s.get(`/api/studio/projects/${t.id}/wizards`),enabled:!!t}),d=n.reduce((e,t)=>e+t.wizardCount,0),f=c&&!t?.readOnly;return!r&&f&&n.length&&d===0?(0,V.jsx)(l,{to:`/new`,replace:!0}):!r&&!c&&n.length===0?(0,V.jsx)(q,{}):(0,V.jsxs)(`div`,{className:`animate-rise`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(H,{})}),f?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(I,{}),(0,V.jsxs)(C,{onClick:()=>e(`/new`),children:[(0,V.jsx)(p,{className:`size-4`}),` `,_(`home.new`)]})]}):null]}),(0,V.jsx)(`h1`,{className:`mt-10 font-display font-semibold text-[1.75rem] tracking-tight`,children:_(`home.title`)}),t?.origin===`local`?(0,V.jsxs)(`p`,{className:`mt-2 text-[0.875rem] text-ink-3`,children:[_(`home.fromLocal`),` `,t.syncedAt?_(`home.syncedAt`,{when:new Intl.DateTimeFormat(T,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.syncedAt))}):null]}):null,u.data&&u.data.length===0?(0,V.jsx)(g,{children:_(`home.empty`)}):null,(0,V.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:a?u.data?.map(e=>(0,V.jsx)(G,{w:e,me:a},e.id)):null})]})}export{H as n,z as t};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,n as i,nt as a,t as o}from"./api-DB22_B7G.js";import{t as s}from"./upload-DNRENWzQ.js";import{b as c,i as l,t as u}from"./ui-I7QYMX0F.js";import{E as d,U as f,w as p}from"./index-CLe9Wrpu.js";var m=e(t(),1),h=e(n(),1);function g({variant:e=`secondary`,label:t=c(`home.import`)}){let n=r(),g=a(),{project:_}=p(),v=d(),y=(0,m.useRef)(null),b=f({mutationFn:e=>i.upload(`/api/studio/projects/${_.id}/wizards/import`,e),onSuccess:async({id:e})=>{await g.invalidateQueries({queryKey:[`projects`]}),await g.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),x=b.error instanceof o?b.error.body?.issues??[]:[];return!v||_?.readOnly?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(u,{variant:e,busy:b.isPending,disabled:!_,onClick:()=>y.current?.click(),children:[(0,h.jsx)(s,{className:`size-4`}),` `,t]}),(0,h.jsx)(`input`,{ref:y,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b.mutate(t)}}),(0,h.jsxs)(l,{open:b.isError,onClose:b.reset,title:c(`import.failed`),children:[(0,h.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:b.error?.message}),x.length?(0,h.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:x.slice(0,8).map(e=>(0,h.jsx)(`li`,{children:e.message},e.message))}):null,(0,h.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,h.jsx)(u,{variant:`secondary`,onClick:b.reset,children:c(`common.close`)})})]})]})}export{g as t};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,n as i,nt as a,t as o}from"./api-CVG-xDEn.js";import{t as s}from"./upload-DNRENWzQ.js";import{b as c,i as l,t as u}from"./ui-BPY2pIh0.js";import{E as d,U as f,w as p}from"./index-hpNaR92X.js";var m=e(t(),1),h=e(n(),1);function g({variant:e=`secondary`,label:t=c(`home.import`)}){let n=r(),g=a(),{project:_}=p(),v=d(),y=(0,m.useRef)(null),b=f({mutationFn:e=>i.upload(`/api/studio/projects/${_.id}/wizards/import`,e),onSuccess:async({id:e})=>{await g.invalidateQueries({queryKey:[`projects`]}),await g.invalidateQueries({queryKey:[`wizards`]}),n(`/edit/${e}`)}}),x=b.error instanceof o?b.error.body?.issues??[]:[];return!v||_?.readOnly?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(u,{variant:e,busy:b.isPending,disabled:!_,onClick:()=>y.current?.click(),children:[(0,h.jsx)(s,{className:`size-4`}),` `,t]}),(0,h.jsx)(`input`,{ref:y,hidden:!0,type:`file`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b.mutate(t)}}),(0,h.jsxs)(l,{open:b.isError,onClose:b.reset,title:c(`import.failed`),children:[(0,h.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:b.error?.message}),x.length?(0,h.jsx)(`ul`,{className:`mt-3 flex list-disc flex-col gap-1 pl-5 text-[0.8125rem] text-ink-2`,children:x.slice(0,8).map(e=>(0,h.jsx)(`li`,{children:e.message},e.message))}):null,(0,h.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,h.jsx)(u,{variant:`secondary`,onClick:b.reset,children:c(`common.close`)})})]})]})}export{g as t};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{n as r,nt as i}from"./api-DB22_B7G.js";import{t as a}from"./check-CUpby_J9.js";import{b as o,c as s,s as c,t as l}from"./ui-I7QYMX0F.js";import{U as u}from"./index-CLe9Wrpu.js";import{a as d}from"./definition-Dp0DR2D6.js";var f=e(t(),1),p=e(n(),1);function m(e){let t=window.engentyDesktop;t?t.open(e):window.open(e,`_blank`,`noopener`)}var h={gateway:`Vercel AI Gateway`,anthropic:`Anthropic`,openai:`OpenAI`};function g({models:e}){let t=i(),[n,m]=(0,f.useState)({}),[g,_]=(0,f.useState)(e.bindings),[v,y]=(0,f.useState)(e.ollamaUrl),[b,x]=(0,f.useState)(!1),S=u({mutationFn:()=>r.put(`/api/studio/local/models`,{keys:n,bindings:g,ollamaUrl:v}),onSuccess:async()=>{m({}),x(!0),setTimeout(()=>x(!1),1500),await t.invalidateQueries({queryKey:[`me`]})}});return(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(s,{children:o(`local.keys`)}),(0,p.jsx)(`p`,{className:`mb-3 text-[0.8125rem] text-ink-3`,children:o(`local.keysHint`)}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.keys(h).map(i=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:h[i]}),(0,p.jsx)(c,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:e.keys[i]?o(`local.keySet`):o(`local.keyEmpty`),value:n[i]??``,onChange:e=>m({...n,[i]:e.target.value})}),e.keys[i]?(0,p.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>{m({...n,[i]:``}),r.put(`/api/studio/local/models`,{keys:{[i]:``}}).then(()=>t.invalidateQueries({queryKey:[`me`]}))},children:o(`local.keyRemove`)}):null]},i))})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(s,{children:o(`local.classes`)}),(0,p.jsx)(`p`,{className:`mb-3 text-[0.8125rem] text-ink-3`,children:o(`local.classesHint`)}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d.map(e=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:o(`class.${e}`)}),(0,p.jsx)(c,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:g[e]??``,onChange:t=>_({...g,[e]:t.target.value})})]},e)),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:`Ollama`}),(0,p.jsx)(c,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:v,onChange:e=>y(e.target.value)})]})]})]}),(0,p.jsx)(`div`,{children:(0,p.jsxs)(l,{variant:`secondary`,busy:S.isPending,onClick:()=>S.mutate(),children:[b?(0,p.jsx)(a,{className:`size-4`}):null,o(b?`local.saved`:`local.save`)]})})]})}export{m as n,g as t};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{n as r,nt as i}from"./api-CVG-xDEn.js";import{t as a}from"./check-CUpby_J9.js";import{b as o,c as s,s as c,t as l}from"./ui-BPY2pIh0.js";import{U as u}from"./index-hpNaR92X.js";import{a as d}from"./definition-Dp0DR2D6.js";var f=e(t(),1),p=e(n(),1);function m(e){let t=window.engentyDesktop;t?t.open(e):window.open(e,`_blank`,`noopener`)}var h={gateway:`Vercel AI Gateway`,anthropic:`Anthropic`,openai:`OpenAI`};function g({models:e}){let t=i(),[n,m]=(0,f.useState)({}),[g,_]=(0,f.useState)(e.bindings),[v,y]=(0,f.useState)(e.ollamaUrl),[b,x]=(0,f.useState)(!1),S=u({mutationFn:()=>r.put(`/api/studio/local/models`,{keys:n,bindings:g,ollamaUrl:v}),onSuccess:async()=>{m({}),x(!0),setTimeout(()=>x(!1),1500),await t.invalidateQueries({queryKey:[`me`]})}});return(0,p.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(s,{children:o(`local.keys`)}),(0,p.jsx)(`p`,{className:`mb-3 text-[0.8125rem] text-ink-3`,children:o(`local.keysHint`)}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.keys(h).map(i=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:h[i]}),(0,p.jsx)(c,{type:`password`,autoComplete:`off`,className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,placeholder:e.keys[i]?o(`local.keySet`):o(`local.keyEmpty`),value:n[i]??``,onChange:e=>m({...n,[i]:e.target.value})}),e.keys[i]?(0,p.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>{m({...n,[i]:``}),r.put(`/api/studio/local/models`,{keys:{[i]:``}}).then(()=>t.invalidateQueries({queryKey:[`me`]}))},children:o(`local.keyRemove`)}):null]},i))})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(s,{children:o(`local.classes`)}),(0,p.jsx)(`p`,{className:`mb-3 text-[0.8125rem] text-ink-3`,children:o(`local.classesHint`)}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d.map(e=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:o(`class.${e}`)}),(0,p.jsx)(c,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:g[e]??``,onChange:t=>_({...g,[e]:t.target.value})})]},e)),(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`w-40 text-[0.875rem] text-ink-2`,children:`Ollama`}),(0,p.jsx)(c,{className:`min-w-0 flex-1 font-mono text-[0.8125rem]`,value:v,onChange:e=>y(e.target.value)})]})]})]}),(0,p.jsx)(`div`,{children:(0,p.jsxs)(l,{variant:`secondary`,busy:S.isPending,onClick:()=>S.mutate(),children:[b?(0,p.jsx)(a,{className:`size-4`}):null,o(b?`local.saved`:`local.save`)]})})]})}export{m as n,g as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-DB-86F8z.js","assets/jsx-runtime-D3jfb0Ew.js","assets/ui-BPY2pIh0.js","assets/esm-DutMJAod.js","assets/index-hpNaR92X.js","assets/api-CVG-xDEn.js","assets/preload-helper-CNEI7N0N.js","assets/createLucideIcon-q3MZMmnf.js","assets/engenty-Cm8yZLON.js","assets/index-Bwyehu0k.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,F as i,I as a,K as o,M as s,N as c,O as l,d as u,g as d,j as f,n as p,nt as m,w as h}from"./api-CVG-xDEn.js";import{t as g}from"./preload-helper-CNEI7N0N.js";import{t as _}from"./createLucideIcon-q3MZMmnf.js";import{t as v}from"./arrow-right-6FyN3e7D.js";import{o as y,s as b,t as ee}from"./meta--kpiTOS-.js";import{t as te}from"./check-CUpby_J9.js";import{t as x}from"./chevron-down-DymW-2BP.js";import{n as S,r as C,t as w}from"./volume-2-Bp2tyaKE.js";import{n as ne,r as T}from"./upload-DNRENWzQ.js";import{n as re,t as ie}from"./wand-sparkles-Clj3VRB5.js";import{t as E}from"./image-BShbErBm.js";import{n as ae,t as D}from"./video-9fDPRPCv.js";import{t as oe}from"./pen-line-NK46C_nG.js";import{n as O,t as se}from"./table-2-BdDuBcF2.js";import{l as ce,u as le}from"./engenty-Cm8yZLON.js";import{b as k,d as A,h as j,i as ue,m as de,n as fe,r as M,t as N,v as P}from"./ui-BPY2pIh0.js";import{A as pe,B as F,E as me,F as I,N as he,U as L,V as ge,j as _e,k as R,w as ve,z as ye}from"./index-hpNaR92X.js";import{t as be}from"./ImportWizard-DtZH-PgS.js";var xe=class extends c{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:o,isRefetching:s,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=o&&u===`forward`,p=c&&u===`backward`,m=o&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:i(t,n.data),hasPreviousPage:a(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function Se(e,t){return s(e,xe,t)}var z={name:`audio-lines`,size:24,node:[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]};z.node;var Ce=_(z),B={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`]};B.node;var we=_(B),Te={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`}]]};Te.node;var Ee=_(Te),De={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`}]]};De.node;var Oe=_(De),ke={name:`mouse-pointer-click`,size:24,node:[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]};ke.node;var Ae=_(ke),je={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`}]]};je.node;var Me=_(je),Ne={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Ne.node;var Pe=_(Ne),V=e(t(),1),H={text:{de:`Text`,en:`Text`},document:{de:`Dokument (PDF, Word)`,en:`Document (PDF, Word)`},table:{de:`Tabelle`,en:`Table`},image:{de:`Bild`,en:`Image`},video:{de:`Video`,en:`Video`},audio:{de:`Audio`,en:`Audio`},dashboard:{de:`Dashboard`,en:`Dashboard`}},Fe={any:{de:`Jede Branche`,en:`Any industry`},trades:{de:`Handwerk`,en:`Trades`},gastronomy:{de:`Gastronomie`,en:`Food service`},hospitality:{de:`Hotel & Tourismus`,en:`Hotels & tourism`},realEstate:{de:`Immobilien`,en:`Real estate`},retail:{de:`Handel`,en:`Retail`},health:{de:`Gesundheit`,en:`Health`},professional:{de:`Kanzlei & Beratung`,en:`Professional services`},agency:{de:`Agentur & Marketing`,en:`Agency & marketing`},events:{de:`Veranstaltungen`,en:`Events`},publicSector:{de:`Vereine & Öffentliches`,en:`Associations & public sector`}},Ie={marketing:{de:`Marketing & Social Media`,en:`Marketing & social media`},sales:{de:`Angebote & Verkauf`,en:`Offers & sales`},accounting:{de:`Buchhaltung & Belege`,en:`Accounting & receipts`},service:{de:`Kundenservice`,en:`Customer service`},research:{de:`Recherche & Analyse`,en:`Research & analysis`},hr:{de:`Personal & Bewerbungen`,en:`HR & applications`},operations:{de:`Planung & Abläufe`,en:`Planning & operations`},website:{de:`Helfer für die Website`,en:`Website helpers`},visuals:{de:`Bilder & Video`,en:`Images & video`},inquiries:{de:`Anfragen & Termine`,en:`Inquiries & bookings`},advice:{de:`Beratung & Preise`,en:`Advice & pricing`}},U={text:{de:`Text schreiben`,en:`Writes text`},web:{de:`Websuche`,en:`Web search`},browser:{de:`Browser bedienen`,en:`Drives a browser`},documents:{de:`Dokumente & Fotos lesen`,en:`Reads documents & photos`},image:{de:`Bilder erzeugen`,en:`Makes images`},video:{de:`Videos erzeugen`,en:`Makes video`},speech:{de:`Sprachausgabe`,en:`Speech output`},listening:{de:`Sprachnotizen verstehen`,en:`Understands voice notes`},code:{de:`Code ausführen`,en:`Runs code`},connectors:{de:`Verbundene Konten & Systeme`,en:`Connected accounts & systems`}},Le={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},W=e=>Object.keys(e);W(H),W(Fe),W(Ie),W(U);var G=e(n(),1),Re=(0,V.lazy)(()=>g(()=>import(`./FlowPreview-DB-86F8z.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ze={useCase:``,industry:``,format:``,capability:``},K=(e,t)=>e[t]?.[P]??t;function Be(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function Ve(e){return e.credits?k(`market.credits`,{n:Be(e.credits.credits)}):Le[e.costTier][P]}var He={text:pe,document:I,table:se,image:E,video:D,audio:Ce,dashboard:we};function q({format:e,className:t}){let n=He[e],r=K(H,e);return(0,G.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,G.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var J=[`low`,`medium`,`high`];function Y({entry:e}){let t=J.indexOf(e.costTier)+1,n=P===`de`?Oe:Ee;return(0,G.jsxs)(`span`,{title:Ve(e),className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:J.slice(0,t).map((e,t)=>(0,G.jsx)(`span`,{className:j(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,G.jsx)(n,{className:`size-4`})},e))}),Le[e.costTier][P]]})}function Ue({entry:e,onOpen:t}){return(0,G.jsxs)(fe,{role:`button`,tabIndex:0,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},className:j(`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)&&`opacity-60`),children:[(0,G.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,G.jsx)(u,{kind:e.avatar,size:68,interactive:!1})}),(0,G.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[0.9375rem]`,children:[e.title,e.starred?(0,G.jsx)(O,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":k(`market.starred`)}):null]}),(0,G.jsx)(`div`,{className:`mt-0.5 text-[0.8125rem] text-ink-3 leading-snug`,children:e.pitch})]}),(0,G.jsx)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[0.75rem] text-ink-3`,children:e.usable&&e.missing.length?(0,G.jsx)(M,{tone:`warn`,children:k(`market.missing`,{list:Z(e.missing)})}):e.usable?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(F,{className:`size-3.5`}),` `,k(`market.minutes`,{n:e.effort.minutes})]}),(0,G.jsx)(Y,{entry:e}),e.optional?.length?(0,G.jsx)(M,{title:k(`market.optionalHint`,{list:Z(e.optional)}),children:k(`market.without`,{list:Z(e.optional)})}):null,(0,G.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,G.jsx)(q,{format:e,className:`size-4`},e))})]}):(0,G.jsx)(M,{tone:`warn`,children:k(`market.needsUpdate`)})})]})}function X({title:e,children:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1.5 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Z=e=>e.map(e=>K(U,e)).join(`, `),We={text:oe,web:S,browser:Ae,documents:Me,image:E,video:D,speech:w,listening:ae,code:Pe,connectors:_e};function Ge(e){switch(e.type){case`page`:return he;case`agent`:return b;case`generate`:return e.asset===`image`?E:e.asset===`video`?D:e.asset===`voice`?w:e.asset===`dashboard`?we:I;case`widget`:return e.video?C:ge;case`review`:return re;case`result`:return y}return ie}function Ke(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 qe(e){let t=Ke(e);return e.map(e=>({id:e.id,title:e.title,icon:Ge(e),tone:ee[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,G.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 $({icon:e,children:t,more:n}){return(0,G.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-[0.875rem] text-ink leading-snug`,children:t}),n?(0,G.jsx)(`div`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:n}):null]})]})}function Je({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,G.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,G.jsx)(`div`,{children:t})})}function Ye({id:e,fallback:t,onClose:n,onUse:r,busy:i}){let a=m(),o=l(),s=f({queryKey:[`marketplace-entry`,e,P],queryFn:()=>p.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${P}`),enabled:!!e,retry:!1}),c=s.data??t,h=L({mutationFn:t=>{let n=`/api/studio/marketplace/${encodeURIComponent(e)}/star`;return t?p.put(n):p.del(n)},onSuccess:()=>Promise.all([a.invalidateQueries({queryKey:[`marketplace`]}),a.invalidateQueries({queryKey:[`marketplace-entry`,e]})])}),g=d()===`dark`,_=ce[le[c?.avatar||`round`]],v=g?`var(--card)`:`color-mix(in oklch, ${_??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,G.jsx)(ue,{open:!!e,onClose:n,wide:!0,bare:!0,children:c?(0,G.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,G.jsx)(`button`,{type:`button`,"aria-label":k(`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,G.jsx)(R,{className:`size-4`})}),(0,G.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:v,"--coin-bg":v},children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,G.jsx)(`span`,{className:j(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,g?`opacity-[0.14]`:`opacity-80`)})}),(0,G.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,G.jsx)(u,{kind:c.avatar,size:104})}),(0,G.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,G.jsx)(`h2`,{className:`font-display font-semibold text-[1.375rem] leading-tight tracking-tight max-sm:pr-10`,children:c.title}),(0,G.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-2 leading-snug`,children:s.data?.description||c.pitch})]}),c.usable?(0,G.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,G.jsxs)(Q,{title:k(`market.duration`),children:[(0,G.jsx)(F,{className:`size-4 text-ink-3`}),k(`market.minutes`,{n:c.effort.minutes})]}),(0,G.jsx)(Q,{title:k(`market.cost`),children:(0,G.jsx)(Y,{entry:c})}),(0,G.jsx)(Q,{title:k(`market.result`),children:c.formats.map(e=>(0,G.jsx)(q,{format:e,className:`size-4`},e))})]}):null]}),c.usable?(0,G.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,G.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,G.jsx)(X,{title:k(`market.duration`),children:(0,G.jsx)($,{icon:(0,G.jsx)(F,{className:`size-4 text-moss`}),more:k(`market.durationHint`,{n:c.effort.fields}),children:k(`market.minutes`,{n:c.effort.minutes})})}),(0,G.jsx)(X,{title:k(`market.cost`),children:(0,G.jsx)($,{icon:(0,G.jsx)(T,{className:`size-4 text-amber`}),more:c.credits?k(`market.creditsHint`):void 0,children:(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,G.jsx)(Y,{entry:c}),c.credits?(0,G.jsx)(`span`,{className:`text-ink-2`,children:k(`market.creditsRange`,{n:Be(c.credits.credits)})}):null]})})}),(0,G.jsx)(X,{title:k(`market.result`),children:(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:(s.data?.results??[]).map(e=>(0,G.jsx)($,{icon:(0,G.jsx)(q,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,G.jsx)(X,{title:k(`market.needs`),children:(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:c.capabilities.map(e=>{let t=We[e],n=c.missing.includes(e),r=c.optional?.includes(e);return(0,G.jsxs)(`li`,{className:j(`flex items-center gap-2.5 text-[0.875rem]`,n?`text-ink-3`:`text-ink-2`),children:[(0,G.jsx)(t,{className:j(`size-4 shrink-0`,n?`text-rose`:r?`text-amber`:`text-cobalt`)}),K(U,e),n?(0,G.jsx)(`span`,{className:`text-[0.75rem] text-rose`,children:k(`market.unavailable`)}):r?(0,G.jsx)(`span`,{className:`text-[0.75rem] text-amber`,children:k(`market.optional`)}):null]},e)})})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,G.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.06em]`,children:k(`market.steps`)}),(0,G.jsx)(Je,{className:`-mr-2 overscroll-contain pt-1 pr-2 pl-1 sm:min-h-0 sm:flex-1 sm:overflow-y-auto`,children:s.isLoading?(0,G.jsx)(A,{className:`size-5 text-ink-3`}):(0,G.jsx)(V.Suspense,{fallback:(0,G.jsx)(A,{className:`size-5 text-ink-3`}),children:(0,G.jsx)(Re,{steps:qe(s.data?.outline??[])})})})]})]}):(0,G.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,G.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[0.875rem] text-ink-2`,children:k(`market.needsUpdateHint`)})}),(0,G.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:[(0,G.jsxs)(N,{variant:`ghost`,className:`mr-auto`,title:k(`market.starHint`),"aria-pressed":c.starred,busy:h.isPending,onClick:()=>h.mutate(!c.starred),children:[(0,G.jsx)(O,{className:j(`size-4`,c.starred&&`fill-amber text-amber`)}),(0,G.jsx)(`span`,{className:`max-sm:sr-only`,children:k(c.starred?`market.starred`:`market.star`)})]}),(0,G.jsx)(N,{variant:`secondary`,onClick:n,children:k(`common.close`)}),c.usable&&c.missing.length?(0,G.jsx)(N,{variant:`secondary`,onClick:()=>o(`/settings/models`),children:k(`editor.models.settings`)}):null,r?(0,G.jsx)(N,{disabled:!c.usable||c.missing.length>0,title:c.missing.length?k(`market.missingHint`,{list:Z(c.missing)}):c.optional?.length?k(`market.optionalHint`,{list:Z(c.optional)}):void 0,busy:i,onClick:()=>r(c),children:k(`market.use`)}):null]})]}):(0,G.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:s.isLoading?(0,G.jsx)(A,{className:`size-6 text-ink-3`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{children:k(`market.notFound`)}),(0,G.jsx)(N,{variant:`secondary`,onClick:n,children:k(`common.close`)})]})})})}function Xe({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,G.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,G.jsxs)(`div`,{className:j(`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,G.jsx)(`button`,{type:`button`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(!i),className:j(`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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,G.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,G.jsxs)(G.Fragment,{children:[e,(0,G.jsx)(x,{className:j(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,G.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${k(`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,G.jsx)(R,{className:`size-3.5`})}):null]}),i?(0,G.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,G.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:j(`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,G.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,G.jsx)(te,{className:`size-4 text-ember`}):e.unavailable?(0,G.jsx)(`span`,{className:`whitespace-nowrap text-[0.75rem] text-ink-4`,children:k(`market.unavailable`)}):(0,G.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function Ze(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 Qe=60;function $e({onUse:e,busy:t,open:n}){let[r,i]=(0,V.useState)(``),[a,s]=(0,V.useState)(ze),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(n??null),f=Ze(r.trim(),250),m=Se({queryKey:[`marketplace`,P,f,a,c],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:P,limit:String(Qe),offset:String(e)});f&&t.set(`q`,f);for(let[e,n]of Object.entries(a))n&&t.set(e,n);return c&&t.set(`starred`,`1`),p.get(`/api/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:o}),h=m.data?.pages[0],g=m.data?.pages.flatMap(e=>e.entries)??[],_=h?.all??0,v=r.trim()!==f||m.isFetching&&!m.isFetchingNextPage,y=(e,t,n)=>Object.keys(t).filter(t=>h?.facets[e]?.[t]!==void 0).map(r=>({value:r,label:K(t,r),icon:n?.(r),count:(h?.facets[e])[r]??0,unavailable:e===`capability`&&b.has(r)})),b=new Set(h?.unavailable??[]),ee=y(`useCase`,Ie),te=[{key:`industry`,name:k(`market.industry`),options:y(`industry`,Fe)},{key:`format`,name:k(`market.format`),options:y(`format`,H,e=>(0,G.jsx)(q,{format:e,className:`size-4 text-ink-3`}))},{key:`capability`,name:k(`market.capability`),options:y(`capability`,U,e=>{let t=We[e];return(0,G.jsx)(t,{className:`size-4 text-ink-3`})})}],x=!!r.trim()||c||Object.values(a).some(Boolean),S=()=>{s(ze),i(``),l(!1)};if(m.isLoading)return(0,G.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,G.jsx)(A,{className:`size-6 text-ink-3`})});let C=h?.offline?(0,G.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,G.jsx)(ye,{className:`size-4 shrink-0`}),k(`market.offline`)]}):null;if(!_&&!x)return C;let w=r?(0,G.jsx)(`button`,{type:`button`,"aria-label":k(`market.reset`),onClick:()=>i(``),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,G.jsx)(R,{className:`size-4`})}):null,T=e=>j(`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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`relative mx-auto flex h-10 max-w-md 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:[v?(0,G.jsx)(A,{className:`size-4 shrink-0 text-ink-3`}):(0,G.jsx)(ne,{className:`size-4 shrink-0 text-ink-3`}),(0,G.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:k(`market.search`),"aria-label":k(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[0.9375rem] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),w]}),C,(0,G.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:k(`market.all`)},...ee].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":!c&&a.useCase===e.value,onClick:()=>{l(!1),s({...a,useCase:e.value})},className:T(!c&&a.useCase===e.value),children:e.label},e.value)),(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":c,onClick:()=>l(!c),className:T(c),children:[(0,G.jsx)(O,{className:j(`size-3.5`,c&&`fill-amber text-amber`)}),k(`market.starred`)]})]}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[c?null:te.map(e=>(0,G.jsx)(Xe,{name:e.name,value:a[e.key],options:e.options,onChange:t=>s({...a,[e.key]:t})},e.key)),(0,G.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[0.8125rem] text-ink-3`,children:[x?(0,G.jsxs)(`button`,{type:`button`,onClick:S,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,G.jsx)(R,{className:`size-3.5 max-sm:size-4`}),(0,G.jsx)(`span`,{className:`max-sm:sr-only`,children:k(`market.resetShort`)})]}):null,x?(0,G.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:k(`market.countOfShort`,{n:h?.total??0,all:_})}):null,(0,G.jsx)(`span`,{className:j(`tabular-nums`,x&&`max-sm:hidden`),children:x?k(`market.countOf`,{n:h?.total??0,all:_}):k(`market.count`,{n:_})})]})]}),g.length?(0,G.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,G.jsx)(Ue,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,G.jsxs)(`div`,{className:`py-10 text-center text-[0.875rem] text-ink-3`,children:[(0,G.jsx)(`p`,{children:k(c?`market.noneStarred`:`market.none`)}),(0,G.jsx)(N,{variant:`ghost`,className:`mt-2`,onClick:S,children:k(`market.reset`)})]}),m.hasNextPage?(0,G.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,G.jsx)(N,{variant:`secondary`,busy:m.isFetchingNextPage,onClick:()=>void m.fetchNextPage(),children:k(`market.more`)})}):null,(0,G.jsx)(Ye,{id:u,fallback:g.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}var et={de:[`Stellenanzeige aus ein paar Stichworten, als PDF und LinkedIn-Post`,`Produktbeschreibung für den Onlineshop mit drei Bildvarianten`,`Wettbewerbsanalyse zu einer Firma mit Quellen`,`Lead aus einem Formular in unser CRM eintragen`],en:[`A job ad from a few keywords, as PDF and LinkedIn post`,`A shop product description with three image variants`,`A competitor analysis for a company, with sources`,`Put a lead from a form into our CRM`]};function tt(){let e=l(),t=m(),{project:n}=ve(),i=me(),[a,o]=(0,V.useState)(``),[s]=r(),c=L({mutationFn:e=>p.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:P}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(a.trim())}`)}}),d=()=>{a.trim()&&n&&c.mutate(void 0)};return!i||n?.readOnly?(0,G.jsx)(h,{to:`/`,replace:!0}):(0,G.jsxs)(`div`,{className:`animate-rise 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)(u,{kind:`sprout`,size:150,fluffy:!0}),(0,G.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[2rem] leading-tight tracking-tight sm:text-[2.375rem]`,children:k(`new.title`)})]}),(0,G.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,G.jsx)(de,{autoFocus:!0,minRows:4,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&d()},placeholder:k(`new.placeholder`),className:`border-0 bg-transparent text-[1rem] shadow-none focus:ring-0`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,G.jsx)(`span`,{className:`hidden text-[0.75rem] text-ink-4 sm:block`,children:k(`new.hint`)}),(0,G.jsxs)(N,{size:`md`,onClick:d,busy:c.isPending&&!c.variables,disabled:!a.trim(),children:[k(`new.build`),` `,(0,G.jsx)(v,{className:`size-4`})]})]})]}),(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:et[P].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,G.jsxs)(`section`,{className:`mx-auto max-w-5xl`,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:k(`new.orStarter`)}),(0,G.jsx)($e,{open:s.get(`starter`),busy:c.isPending&&!!c.variables,onUse:e=>n&&!c.isPending&&c.mutate(e.id)}),c.error?(0,G.jsx)(`p`,{className:`mt-3 text-center text-[0.875rem] text-rose`,children:c.error.message}):null]}),(0,G.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,G.jsx)(be,{variant:`ghost`,label:k(`new.import`)})})]})}export{tt as NewWizardPage};
@@ -0,0 +1,5 @@
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,D as i,O as a,d as o,i as s,j as c,k as l,n as u,nt as d,t as f,w as p}from"./api-CVG-xDEn.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{f as h,g,h as _,i as v,m as y,p as b,t as x,u as S}from"./RunnerView-Bqp0paLi.js";import{t as ee}from"./refresh-cw-BNtHis1x.js";import{n as te}from"./HomePage-ZrCxIiJT.js";import{t as C}from"./check-CUpby_J9.js";import{t as w}from"./chevron-down-DymW-2BP.js";import{n as T}from"./lock-DZL2N67v.js";import{r as E,t as ne}from"./ChatPanel-BPD-iQK0.js";import{n as re,t as ie}from"./upload-DNRENWzQ.js";import{t as D}from"./plus-Du-Jx8aI.js";import{t as ae}from"./external-link-MAL7vJYj.js";import{n as O,t as oe}from"./wand-sparkles-Clj3VRB5.js";import{a as se,c as k,d as A,f as ce,h as le,i as ue,l as de,m as j,o as fe,p as M,s as N,u as P}from"./Account-O6OTAY88.js";import{n as F,t as I}from"./trash-0IafyhZB.js";import{n as L,t as pe}from"./table-2-BdDuBcF2.js";import{a as me,b as R,c as z,d as B,f as he,h as V,i as H,l as U,m as ge,n as W,o as G,p as _e,r as K,s as q,t as J,u as Y,v as X}from"./ui-BPY2pIh0.js";import{A as ve,F as ye,T as be,U as Z,_ as xe,b as Se,g as Ce,i as we,k as Te,m as Ee,v as De,w as Oe,y as ke}from"./index-hpNaR92X.js";import"./definition-Dp0DR2D6.js";import{a as Ae,c as je,f as Me,i as Ne,m as Pe,n as Fe,o as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve}from"./settings-menu-BXpT5jOB.js";var He={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};He.node;var Ue=m(He),We={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};We.node;var Ge=m(We),Ke={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};Ke.node;var qe=m(Ke),Je={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Je.node;var Ye=m(Je),Xe={name:`messages-square`,size:24,node:[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]};Xe.node;var Ze=m(Xe),Qe={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};Qe.node;var $e=m(Qe),et={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};et.node;var tt=m(et),nt={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`}]]};nt.node;var rt=m(nt),it={name:`tags`,size:24,node:[[`path`,{d:`M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z`,key:`16rjxf`}],[`path`,{d:`M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193`,key:`178nd4`}],[`circle`,{cx:`10.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`12ikhr`}]]};it.node;var at=m(it),ot={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};ot.node;var st=m(ot),ct={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};ct.node;var lt=m(ct),Q=e(t(),1),$=e(n(),1),ut={choice:at,date:Ue,number:qe,text:ve,boolean:lt},dt=e=>[`knowledge`,e];function ft(e){return e===1?R(`know.item`):R(`know.items`,{n:e})}function pt(e,t){if(e.type===`boolean`||typeof t==`boolean`)return R(t?`know.yes`:`know.no`);if(e.type===`date`&&typeof t==`string`){let[e,n]=t.split(` `),r=new Date(`${e}T00:00:00`),i=Number.isNaN(r.getTime())?t:r.toLocaleDateString(X,{day:`2-digit`,month:`2-digit`,year:`numeric`});return n?`${i} ${n}`:i}return e.type===`number`&&typeof t==`number`?`${t.toLocaleString(X)}${e.unit?` ${e.unit}`:``}`:String(t)}function mt(e,t){return e.flatMap(e=>{let n=t.find(t=>t.categoryId===e.id);return n?e.type===`boolean`?n.values[0]===!0?[e.name]:[]:[n.values.map(t=>pt(e,t)).join(`, `)]:[]}).join(` · `)}function ht({trigger:e,open:t,onOpen:n,children:r}){let i=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,$.jsxs)(`div`,{ref:i,className:`relative inline-flex`,children:[e,t?(0,$.jsx)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:r}):null]})}function gt({category:e,current:t,onSave:n}){let[r,i]=(0,Q.useState)(t[0]===void 0?``:String(t[0]));if(e.type===`choice`){let a=t.map(String);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.values.length?(0,$.jsx)(U,{multi:!0,value:a,options:e.values.map(e=>e.value),onChange:t=>n(e.multiple?t:t.filter(e=>!a.includes(e)).slice(0,1))}):null,(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),r.trim()&&n(e.multiple?[...a,r.trim()]:[r.trim()])},children:[(0,$.jsx)(q,{"data-autofocus":!0,value:a.includes(r)?``:r,placeholder:R(`know.addValue`),onChange:e=>i(e.target.value),className:`h-9`}),(0,$.jsx)(G,{label:R(`know.addValue`),type:`submit`,children:(0,$.jsx)(D,{className:`size-4`})})]})]})}return e.type===`boolean`?(0,$.jsx)(U,{value:t[0]===!0?R(`know.yes`):t[0]===!1?R(`know.no`):``,options:[R(`know.yes`),R(`know.no`)],onChange:e=>n([e===R(`know.yes`)])}):(0,$.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),n(r.trim()?[e.type===`number`?Number(r.replace(`,`,`.`)):r.trim()]:[])},children:[(0,$.jsx)(q,{"data-autofocus":!0,type:e.type===`date`?`date`:e.type===`number`?`number`:`text`,step:`any`,value:e.type===`date`?r.slice(0,10):r,onChange:e=>i(e.target.value),className:`h-9`}),(0,$.jsx)(J,{type:`submit`,size:`sm`,children:`OK`})]})}function _t({projectId:e,itemKey:t,has:n,categories:r,readOnly:i}){let a=d(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(n);(0,Q.useEffect)(()=>l(n),[n]);let f=Z({mutationFn:({categoryId:n,next:r})=>u.put(`/api/studio/projects/${e}/items/${t}/categories/${n}`,{values:r}),onSuccess:()=>a.invalidateQueries({queryKey:dt(e)})}),p=r.filter(e=>!(e.proposed||e.tableId)),m=(e,t)=>{l(n=>[...n.filter(t=>t.categoryId!==e.id),...t.length?[{categoryId:e.id,values:t,by:`person`}]:[]]),f.mutate({categoryId:e.id,next:t}),s(null)},h=p.filter(e=>c.some(t=>t.categoryId===e.id)),g=p.filter(e=>!c.some(t=>t.categoryId===e.id));return p.length?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(e=>{let t=c.find(t=>t.categoryId===e.id),n=ut[e.type],r=(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:`${e.name} · ${R(`know.by.${t.by}`)}`,onClick:()=>s(o===e.id?null:e.id),className:`inline-flex h-7 items-center gap-1.5 rounded-full bg-paper-2 px-2.5 text-[0.75rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink disabled:pointer-events-none`,children:[(0,$.jsx)(n,{className:`size-3.5 text-ink-3`}),(0,$.jsx)(`span`,{className:`text-ink-3`,children:e.name}),(0,$.jsx)(`span`,{className:`font-medium`,children:t.values.map(t=>pt(e,t)).join(`, `)})]},e.id);return i?(0,$.jsx)(`span`,{children:r},e.id):(0,$.jsxs)(ht,{trigger:r,open:o===e.id,onOpen:t=>s(t?e.id:null),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:e.name}),(0,$.jsx)(G,{label:R(`know.remove`),onClick:()=>m(e,[]),className:`size-7`,children:(0,$.jsx)(Te,{className:`size-3.5`})})]}),(0,$.jsx)(gt,{category:e,current:t.values,onSave:t=>m(e,t)})]},e.id)}),i||!g.length?null:(0,$.jsx)(ht,{open:o===`+`,onOpen:e=>s(e?`+`:null),trigger:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(o===`+`?null:`+`),className:`inline-flex h-7 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 ring-1 ring-border-soft transition hover:text-ink hover:ring-border`,children:[(0,$.jsx)(D,{className:`size-3.5`}),` `,R(`know.category`)]}),children:(0,$.jsx)(vt,{categories:g,onSave:m})})]}):null}function vt({categories:e,onSave:t}){let[n,r]=(0,Q.useState)(e[0]?.id??``),i=e.find(e=>e.id===n);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,$.jsx)(Y,{value:n,onChange:r,options:e.map(e=>({value:e.id,label:e.name}))}),i?(0,$.jsx)(gt,{category:i,current:[],onSave:e=>t(i,e)},i.id):null]})}function yt({projectId:e,open:t,onClose:n,onMade:r}){let i=d(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`choice`),[l,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),x=Z({mutationFn:()=>u.post(`/api/studio/projects/${e}/categories`,{name:a.trim(),type:s,unit:s===`number`&&l.trim()||null,multiple:s===`choice`&&p,ordered:s===`choice`&&h,hint:y.trim()||null,values:s===`choice`?_.split(`
2
+ `).map(e=>e.trim()).filter(Boolean):void 0}),onSuccess:async({id:t})=>{await i.invalidateQueries({queryKey:dt(e)}),o(``),v(``),b(``),r(t)}});return(0,$.jsx)(H,{open:t,onClose:n,title:R(`know.newCategory`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.trim()&&x.mutate()},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`know.name`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:a,maxLength:80,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`know.type`)}),(0,$.jsx)(Y,{value:s,onChange:e=>c(e),options:[`choice`,`date`,`number`,`text`,`boolean`].map(e=>({value:e,label:R(`know.type.${e}`)}))})]}),s===`number`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{hint:R(`know.unitHint`),children:R(`know.unit`)}),(0,$.jsx)(q,{value:l,maxLength:20,onChange:e=>f(e.target.value)})]}):null,s===`choice`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{hint:R(`know.valuesHint`),children:R(`know.values`)}),(0,$.jsx)(ge,{minRows:3,value:_,onChange:e=>v(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[R(`know.multiple`),(0,$.jsx)(_e,{checked:p,onChange:m})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[R(`know.ordered`),(0,$.jsx)(_e,{checked:h,onChange:g})]})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{hint:R(`know.hintFieldHint`),children:R(`know.hintField`)}),(0,$.jsx)(q,{value:y,maxLength:120,onChange:e=>b(e.target.value)})]}),x.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:x.error.message}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:n,children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:x.isPending,disabled:!a.trim(),children:R(`know.create`)})]})]})})}function bt({projectId:e,category:t,readOnly:n,onOpen:r,onGone:i}){let a=d(),o=()=>a.invalidateQueries({queryKey:dt(e)}),[s,c]=(0,Q.useState)(``),l=Z({mutationFn:e=>e(),onSuccess:o}),f=ut[t.type],p=new Map(t.values.map(e=>[e.id,e]));return(0,$.jsxs)(k,{title:t.name,hint:[R(`know.type.${t.type}`),t.unit,t.hint].filter(Boolean).join(` · `),plain:!0,action:n?null:(0,$.jsx)(G,{label:R(`know.deleteCategory`),className:`hover:text-rose`,onClick:()=>confirm(R(`know.confirmCategory`,{name:t.name}))&&l.mutate(async()=>{await u.del(`/api/studio/categories/${t.id}`),i()}),children:(0,$.jsx)(I,{className:`size-4`})}),children:[t.proposed&&!n?(0,$.jsxs)(W,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,$.jsx)(K,{tone:`ember`,children:R(`know.proposed`)}),(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:R(`know.proposedHint`)}),(0,$.jsx)(J,{size:`sm`,onClick:()=>l.mutate(()=>u.patch(`/api/studio/categories/${t.id}`,{proposed:!1})),children:R(`know.accept`)})]}):null,t.alike.map(([e,t])=>{let r=p.get(e),i=p.get(t);if(!(r&&i))return null;let[a,o]=r.count<i.count?[r,i]:[i,r];return(0,$.jsxs)(W,{className:`flex flex-wrap items-center gap-3 p-4`,children:[(0,$.jsx)(`span`,{className:`flex-1 text-[0.875rem] text-ink-2`,children:R(`know.alike`,{a:a.value,b:o.value})}),n?null:(0,$.jsx)(J,{size:`sm`,variant:`secondary`,busy:l.isPending,onClick:()=>l.mutate(()=>u.post(`/api/studio/values/${a.id}/merge`,{into:o.id})),children:R(`know.merge`)})]},`${e}:${t}`)}),(0,$.jsxs)(W,{className:`flex flex-col p-1.5`,children:[t.type===`choice`?t.values.length?t.values.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(`v:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.value}),e.summary?(0,$.jsx)(K,{children:R(`know.summary`)}):null,(0,$.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:ft(e.count)})]},e.id)):(0,$.jsx)(me,{children:R(`know.empty`)}):(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 text-[0.875rem]`,children:[(0,$.jsx)(f,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`flex-1 text-ink-2`,children:t.range?R(`know.range`,{min:pt(t,t.range.min),max:pt(t,t.range.max)}):R(`know.unset`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:ft(t.count)})]}),t.type===`choice`&&!n?(0,$.jsxs)(`form`,{className:`flex gap-2 border-border-soft border-t p-2`,onSubmit:e=>{e.preventDefault();let n=s.trim();n&&(c(``),l.mutate(()=>u.post(`/api/studio/categories/${t.id}/values`,{value:n})))},children:[(0,$.jsx)(q,{value:s,placeholder:R(`know.addValue`),onChange:e=>c(e.target.value),className:`h-9`}),(0,$.jsx)(G,{label:R(`know.addValue`),type:`submit`,children:(0,$.jsx)(D,{className:`size-4`})})]}):null]}),l.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l.error.message}):null]})}function xt(e){return c({queryKey:[`knowledge-value`,e],queryFn:()=>u.get(`/api/studio/values/${e}`),enabled:!!e})}function St({value:e,readOnly:t,children:n}){let r=d(),i=Z({mutationFn:()=>u.post(`/api/studio/values/${e.id}/summary`),onSuccess:()=>r.invalidateQueries({queryKey:[`knowledge-value`,e.id]})});return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,$.jsx)(k,{title:R(`know.summary`),hint:R(`know.summaryHint`),plain:!0,action:t?null:(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,busy:i.isPending,onClick:()=>i.mutate(),children:[e.summary?(0,$.jsx)(ee,{className:`size-4`}):null,e.summary?R(`know.summaryAgain`):R(`know.summaryWrite`)]}),children:(0,$.jsxs)(W,{className:`p-4 sm:p-5`,children:[i.isPending?(0,$.jsx)(`div`,{className:`flex h-24 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}):e.summary?(0,$.jsx)(v,{text:e.summary,className:`text-[0.875rem]`}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:R(`know.summaryEmpty`)}),i.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:i.error.message}):null]})}),(0,$.jsx)(k,{title:R(`know.toc`),plain:!0,children:n})]})}var Ct={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function wt({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:R(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function Tt(e,t){confirm(R(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Et({projectId:e,file:t,small:n}){let r=P(e,t.id);return t.mime.startsWith(`image/`)?(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:V(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,$.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,$.jsx)($e,{className:n?`size-5`:`size-7`}):(0,$.jsx)(_,{className:n?`size-5`:`size-7`})})}function Dt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:o}){return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,$.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(K,{tone:`ember`,children:R(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Ct:void 0,children:[o&&i.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${R(`project.preview`)}: ${i.name}`,onClick:()=>o(i),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Et,{projectId:e,file:i})}):(0,$.jsx)(Et,{projectId:e,file:i}),(0,$.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[o?(0,$.jsx)(G,{label:R(`project.preview`),onClick:()=>o(i),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(O,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,$.jsx)(G,{label:R(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(L,{className:`size-4`})}):null,r.readOnly?null:(0,$.jsx)(G,{label:R(`project.remove`),onClick:()=>Tt(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:i.name,children:i.name}):null,(0,$.jsx)(wt,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,$.jsxs)(se,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(B,{className:`size-5`}):(0,$.jsx)(D,{className:`size-5`}),a]}):null]})}function Ot({projectId:e,data:t,readOnly:n}){let r=ce(e,n);return(0,$.jsxs)(k,{title:R(`project.logos`),hint:R(`project.logosHint`),children:[(0,$.jsx)(Dt,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:R(`project.logoAdd`)}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null]})}var kt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),de(e.size)].filter(Boolean).join(` · `);function At({projectId:e,file:t,actions:n,onClose:r}){let i=P(e,t.id);return(0,$.jsxs)(H,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:kt(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":R(`project.openOriginal`),title:R(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(ae,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Ct,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(wt,{file:t,actions:n})})]})}function jt({projectId:e,file:t,actions:n,onPreview:r}){return(0,$.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${R(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Et,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:kt(t)})]}),(0,$.jsx)(wt,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,$.jsx)(G,{label:R(`project.preview`),onClick:r,children:(0,$.jsx)(O,{className:`size-4`})}),n.readOnly?null:(0,$.jsx)(G,{label:R(`project.remove`),onClick:()=>Tt(t,n),className:`hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]})]})}function Mt({projectId:e,data:t,readOnly:n}){let r=ce(e,n),[i,a]=M(`assets`,`cards`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,$.jsxs)(k,{title:R(`project.assets`),hint:R(`project.assetsHint`),children:[u.length?(0,$.jsx)(fe,{layout:i,onToggle:a,children:(0,$.jsx)(N,{value:o,onChange:s,placeholder:R(`project.assetSearch`)})}):null,p.length?(0,$.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,$.jsx)(Dt,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,$.jsx)(jt,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:R(`project.staysLocal`)}):(0,$.jsxs)(se,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(ie,{className:`size-4`}),R(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:R(`project.assetAdd`)})]}),r.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:r.error}):null,d?(0,$.jsx)(At,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function Nt(e){return c({queryKey:[`knowledge`,e],queryFn:()=>u.get(`/api/studio/projects/${e}/knowledge`),enabled:!!e,refetchInterval:e=>e.state.data?.items.some(e=>e.status===`pending`)?2e3:!1})}function Pt(e){return e.kind===`table`?e.format===`faq`?Ze:pe:e.kind===`file`?b:e.children?Ge:ye}function Ft({item:e,categories:t,onOpen:n}){let r=Pt(e),i=[mt(t,e.categories),e.children?e.children===1?R(`know.oneSub`):R(`know.sub`,{n:e.children}):``,e.rows===null?``:e.rows===1?R(`know.row`):R(`know.rows`,{n:e.rows}),e.originLabel??``].filter(Boolean).join(` · `);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),disabled:e.status===`pending`,className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,$.jsx)(r,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),i?(0,$.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3`,children:i}):null]}),e.status===`pending`?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,$.jsx)(B,{className:`size-3`}),` `,R(`know.reading`)]}):e.review?(0,$.jsx)(K,{tone:`warn`,title:e.review,children:R(`know.review`)}):null]})}function It({projectId:e,itemKey:t,has:n,originLabel:r,kept:i,review:a,file:o,readOnly:s,onReviewed:c}){let l=Nt(e),u=[r?R(i?`know.kept`:`know.from`,{label:r}):``].filter(Boolean);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[l.data?(0,$.jsx)(_t,{projectId:e,itemKey:t,has:n,categories:l.data.categories,readOnly:s}):null,u.length||o||a?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.8125rem] text-ink-3`,children:[u.map(e=>(0,$.jsx)(`span`,{children:e},e)),o?(0,$.jsxs)(`a`,{href:P(e,o.id),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline-offset-2 hover:text-ink hover:underline`,children:[(0,$.jsx)(b,{className:`size-3.5`}),` `,R(`know.original`),`: `,o.name]}):null,a?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(K,{tone:`warn`,children:R(`know.review`)}),(0,$.jsx)(`span`,{children:a}),s?null:(0,$.jsx)(`button`,{type:`button`,onClick:c,className:`underline hover:text-ink`,children:R(`know.reviewed`)})]}):null]}):null]})}function Lt(e){let t=e.filter(Number.isFinite).sort((e,t)=>e-t);if(new Set(t).size<=4)return[];let n=t[0],r=t.at(-1),i=e=>e.slice(0,-1).map((t,n)=>({lo:t,hi:e[n+1]})).filter(e=>t.some(t=>t>=e.lo&&t<e.hi));if(n>0&&r/n>=30){let e=Math.floor(Math.log10(n)),t=Math.floor(Math.log10(r))+1;for(let a of[[1,2,5],[1,3],[1]]){let o=[];for(let n=e;n<=t;n++)for(let e of a)o.push(e*10**n);let s=i(o.filter((e,t)=>e<=n||o[t-1]<=r));if(s.length<=7)return s}}let a=(r-n)/5,o=10**Math.floor(Math.log10(a)),s=([1,2,2.5,5,10].map(e=>e*o).find(e=>e>=a)??a)||1,c=[];for(let e=Math.floor(n/s)*s;e<=r;e+=s)c.push(e);return c.push(c.at(-1)+s),i(c)}function Rt({projectId:e,category:t,categories:n,onOpen:r}){let i=c({queryKey:[`knowledge`,e,`category`,t.id],queryFn:()=>u.get(`/api/studio/categories/${t.id}/items`)});if(!i.data)return i.isLoading?(0,$.jsx)(B,{className:`mx-auto size-4 text-ink-3`}):null;let a=e=>e.categories.find(e=>e.categoryId===t.id)?.values[0],o=[...i.data.items].sort((e,t)=>{let n=a(e),r=a(t);return typeof n==`number`&&typeof r==`number`?n-r:String(r??``).localeCompare(String(n??``),X)}),s=t.type===`number`?Lt(o.map(a).filter(e=>typeof e==`number`)):[],l=new Intl.NumberFormat(X,{notation:`compact`,maximumFractionDigits:1}),d=t.unit?` ${t.unit}`:``,f=new Map;for(let e of o){let n=a(e),r=typeof n==`number`?s.find(e=>n>=e.lo&&n<e.hi):void 0,i=n===void 0?``:t.type===`date`?new Date(`${String(n).slice(0,7)}-01T00:00:00`).toLocaleDateString(X,{month:`long`,year:`numeric`}):r?R(`know.range`,{min:`${l.format(r.lo)}${d}`,max:`${l.format(r.hi)}${d}`}):pt(t,n);f.set(i,[...f.get(i)??[],e])}return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[[...f].map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e?(0,$.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e}):null,(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:t.map(e=>(0,$.jsx)(Ft,{item:e,categories:n,onOpen:r},e.key))})]},e)),i.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>r(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:R(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})}function zt(e,t,n){return Array.isArray(n)?t.some(e=>n.map(String).includes(String(e))):typeof n==`object`&&n?t.some(t=>{if(e.type===`number`&&typeof t==`number`)return(n.gte===void 0||t>=n.gte)&&(n.lte===void 0||t<=n.lte);if(e.type===`date`){let e=String(t).slice(0,10);return(!n.after||e>=n.after)&&(!n.before||e<=n.before)}return!n.contains||String(t).toLowerCase().includes(n.contains.toLowerCase())}):t.some(e=>e===n)}function Bt(e,t){if(Array.isArray(t))return t.map(String).join(`, `);if(typeof t==`boolean`)return R(t?`know.yes`:`know.no`);if(typeof t==`object`&&t){let n=t.gte??t.after,r=t.lte??t.before;return t.contains?`${R(`know.contains`)} ${t.contains}`:[n===void 0?``:`${R(`know.minimum`)} ${pt(e,n)}`,r===void 0?``:`${R(`know.maximum`)} ${pt(e,r)}`].filter(Boolean).join(` `)}return String(t)}function Vt({category:e,value:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>!a.current?.contains(e.target)&&i(!1);return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let o=ut[e.type],s=typeof t==`object`&&t&&!Array.isArray(t)?t:{},c=(t,r)=>{let i={...s,[t]:r===``?void 0:e.type===`number`?Number(r):r},a=Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0));n(Object.keys(a).length?a:void 0)};return(0,$.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:V(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] transition`,t===void 0?`text-ink-2 ring-1 ring-border-soft hover:ring-border`:`bg-ember-tint text-ink ring-1 ring-ember/30`),children:[(0,$.jsx)(o,{className:`size-3.5 text-ink-3`}),e.name,t===void 0?null:(0,$.jsxs)(`span`,{className:`font-medium`,children:[`: `,Bt(e,t)]}),(0,$.jsx)(w,{className:`size-3.5 text-ink-3`})]}),r?(0,$.jsxs)(`div`,{className:`absolute top-full left-0 z-30 mt-1.5 w-72 max-w-[calc(100vw-32px)] rounded-xl bg-card p-3 shadow-overlay ring-1 ring-border-soft`,children:[e.type===`choice`?(0,$.jsx)(U,{multi:!0,value:Array.isArray(t)?t.map(String):[],options:e.values.map(e=>e.value),onChange:e=>n(e.length?e:void 0)}):e.type===`boolean`?(0,$.jsx)(U,{value:t===!0?R(`know.yes`):t===!1?R(`know.no`):``,options:[R(`know.yes`),R(`know.no`)],onChange:e=>n(e===R(`know.yes`))}):e.type===`text`?(0,$.jsx)(q,{"data-autofocus":!0,value:s.contains??``,placeholder:R(`know.contains`),onChange:e=>n(e.target.value?{contains:e.target.value}:void 0),className:`h-9`}):(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(e.type===`number`?[`gte`,`lte`]:[`after`,`before`]).map((t,n)=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(n===0?`know.minimum`:`know.maximum`)}),(0,$.jsx)(q,{type:e.type===`number`?`number`:`date`,step:`any`,value:String(s[t]??``),placeholder:e.range?String(n===0?e.range.min:e.range.max):``,onChange:e=>c(t,e.target.value),className:`h-9`})]},t))}),t===void 0?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),i(!1)},className:`mt-3 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:R(`know.clear`)})]}):null]})}function Ht({found:e,onOpen:t}){return e.hits.length?(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`px-3 pt-1 pb-2 text-[0.75rem] text-ink-3`,children:e.checked?R(`know.searchStats`,{candidates:e.candidates,hits:e.hits.length}):R(`know.searchUnchecked`,{hits:e.hits.length})}),e.hits.map(e=>{let n=e.open;return(0,$.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>n&&t(n),className:`flex items-start gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent disabled:pointer-events-none`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`block truncate text-[0.875rem]`,children:[e.title,e.heading&&e.heading!==e.title?(0,$.jsxs)(`span`,{className:`text-ink-3`,children:[` › `,e.heading]}):null]}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-3`,children:e.text})]}),e.relevance===null?null:(0,$.jsx)(`span`,{className:`shrink-0 font-medium text-[0.75rem] text-moss tabular-nums`,children:e.relevance.toLocaleString(X,{minimumFractionDigits:2})})]},`${e.key}:${e.heading}`)})]}):(0,$.jsx)(`p`,{className:`px-3 py-4 text-[0.875rem] text-ink-3`,children:R(`know.searchNone`)})}function Ut({kind:e,projectId:t,onClose:n,onMade:r}){let i=d(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=Z({mutationFn:()=>u.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:a.trim(),...e===`table`&&s?{format:`faq`}:{}}),onSuccess:async({id:n})=>{await i.invalidateQueries({queryKey:[`knowledge`,t]}),r(`${e===`table`?`t`:`p`}:${n}`),o(``),c(!1)}});return(0,$.jsx)(H,{open:e!==null,onClose:n,title:R(e===`table`?`know.newTable`:`know.newPage`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.trim()&&l.mutate()},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.title`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:a,maxLength:120,onChange:e=>o(e.target.value)})]}),e===`table`?(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-[0.875rem]`,children:[R(`know.asFaq`),(0,$.jsx)(_e,{checked:s,onChange:c})]}):null,l.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l.error.message}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:n,children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:l.isPending,disabled:!a.trim(),children:R(`know.create`)})]})]})})}function Wt({projectId:e,data:t,readOnly:n,onOpen:r}){let i=d(),a=ce(e,n),[o,s]=(0,Q.useState)({}),[c,l]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),v=t.categories.filter(e=>!e.proposed&&e.count>0),y=t.categories.filter(e=>e.proposed),b=t.items.filter(e=>Object.entries(o).every(([n,r])=>{let i=t.categories.find(e=>e.name===n),a=e.categories.find(e=>e.categoryId===i?.id);return i&&a?zt(i,a.values,r):!1})),x=async()=>{if(!c.trim()){p(null);return}h(!0);try{p(await u.post(`/api/studio/projects/${e}/search`,{query:c,...Object.keys(o).length?{where:o}:{}}))}catch{p({hits:[],candidates:0,checked:!1,filtered:null})}finally{h(!1)}},S=Z({mutationFn:({id:e,keep:t})=>t?u.patch(`/api/studio/categories/${e}`,{proposed:!1}):u.del(`/api/studio/categories/${e}`),onSuccess:()=>i.invalidateQueries({queryKey:[`knowledge`,e]})});return(0,$.jsxs)(k,{title:R(`know.title`),hint:R(`know.hint`),plain:!0,action:n?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>_(`page`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`know.page`)]}),(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>_(`table`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`know.table`)]}),(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>_(`category`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`know.category`)]})]}),children:[y.length&&!n?(0,$.jsx)(W,{className:`flex flex-col gap-2 p-4`,children:y.map(e=>{let t=ut[e.type];return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,$.jsx)(K,{tone:`ember`,children:R(`know.proposed`)}),(0,$.jsx)(t,{className:`size-4 text-ink-3`}),(0,$.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:e.name}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink-3`,children:[R(`know.type.${e.type}`),e.hint].filter(Boolean).join(` · `)}),(0,$.jsx)(J,{size:`sm`,variant:`ghost`,onClick:()=>S.mutate({id:e.id,keep:!1}),children:R(`know.dismiss`)}),(0,$.jsx)(J,{size:`sm`,onClick:()=>S.mutate({id:e.id,keep:!0}),children:R(`know.accept`)})]},e.id)})}):null,t.items.length?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(N,{value:c,placeholder:R(`know.search`),busy:m,onEnter:()=>void x(),onChange:e=>{l(e),e.trim()||p(null)}}),v.length?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v.map(e=>(0,$.jsx)(Vt,{category:e,value:o[e.name],onChange:t=>{p(null),s(n=>{let r={...n};return t===void 0?delete r[e.name]:r[e.name]=t,r})}},e.id)),Object.keys(o).length?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({}),className:`px-2 text-[0.8125rem] text-ink-3 underline hover:text-ink`,children:R(`know.clear`)}):null]}):null]}):null,(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:f?(0,$.jsx)(Ht,{found:f,onOpen:r}):b.length?b.map(e=>(0,$.jsx)(Ft,{item:e,categories:t.categories,onOpen:r},e.key)):(0,$.jsx)(me,{children:R(`know.empty`)})}),n?null:(0,$.jsxs)(se,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:async t=>{await a.upload(`document`,t),await i.invalidateQueries({queryKey:[`knowledge`,e]})},className:`h-14 w-full`,children:[a.busy?(0,$.jsx)(B,{className:`size-4`}):(0,$.jsx)(ie,{className:`size-4`}),R(`know.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:R(`know.pick`)})]}),a.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:a.error}):null,t.items.length&&!(t.checked&&t.embeddings)?(0,$.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[t.embeddings?``:R(`know.keywordsOnly`),t.checked?``:R(`know.unchecked`)].filter(Boolean).join(` `)}):null,(0,$.jsx)(Ut,{kind:g===`page`||g===`table`?g:null,projectId:e,onClose:()=>_(null),onMade:e=>{_(null),r(e)}}),(0,$.jsx)(yt,{projectId:e,open:g===`category`,onClose:()=>_(null),onMade:e=>{_(null),r(`c:${e}`)}})]})}function Gt(e,t,n){return c({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>u.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function Kt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var qt=e=>[Kt(e),e.pages?R(`project.pages`,{n:e.pages}):null,de(e.size)].filter(Boolean).join(` · `),Jt=2e5;function Yt({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=d(),a=j(e),o=Nt(e),s=ce(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[u,f]=(0,Q.useState)(null);if(!c)return a.isLoading?(0,$.jsx)(B,{className:`mx-auto text-ink-3`}):null;let p=u??(l?`original`:`text`),m=o.data?.items.find(e=>e.key===`f:${c.id}`),h=P(e,c.id),g=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:V(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:c.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:qt(c)}),(0,$.jsx)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,"aria-label":R(`project.openOriginal`),title:R(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(ae,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:R(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(ee,{className:`size-4`})}),(0,$.jsx)(G,{label:R(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(R(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(I,{className:`size-4`})})]})]}),(0,$.jsx)(It,{projectId:e,itemKey:`f:${c.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(wt,{file:c,actions:s})}),c.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,$.jsxs)(W,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[l?g(`original`,R(`project.original`)):null,g(`text`,R(`project.readText`))]}),p===`original`?c.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:h,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:h,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(Xt,{projectId:e,file:c})]})]})}function Xt({projectId:e,file:t}){let n=Gt(e,t,Jt);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(B,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(v,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:R(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:R(`project.noText`)})}function Zt({page:e,onGone:t,onOpen:n}){let r=d(),[i,a]=(0,Q.useState)(e.title),[o,s]=(0,Q.useState)(e.markdown),[c,l]=(0,Q.useState)(e.markdown?`read`:`write`),f=e.knowledge,p=async()=>{await r.invalidateQueries({queryKey:[`space-data`,e.projectId]}),await r.invalidateQueries({queryKey:[`knowledge`,e.projectId]})},m=A({title:i.trim()||e.title,markdown:o},async t=>{await u.patch(`/api/studio/pages/${e.id}`,t),r.setQueryData([`space-page`,e.id],e=>e&&{...e,...t}),t.title!==e.title&&await p()}),h=Z({mutationFn:()=>u.del(`/api/studio/pages/${e.id}`),onSuccess:async()=>{await p(),t()}}),g=Z({mutationFn:()=>u.post(`/api/studio/projects/${e.projectId}/pages`,{title:R(`know.addSub`),parentId:e.id}),onSuccess:async({id:e})=>{await p(),n?.(`p:${e}`)}}),_=Z({mutationFn:()=>u.patch(`/api/studio/pages/${e.id}`,{review:null}),onSuccess:()=>r.invalidateQueries({queryKey:[`space-page`,e.id]})}),y=async t=>{let r=t.target.closest(`a`)?.getAttribute(`href`);if(!(r?.startsWith(`pages/`)&&n))return;t.preventDefault();let i=await u.get(`/api/studio/projects/${e.projectId}/resolve?path=${encodeURIComponent(r)}`).catch(()=>null);i?.kind===`page`&&n(`p:${i.id}`)},b=e.readOnly,x=f?.file&&(f.file.mime===`application/pdf`||f.file.mime.startsWith(`image/`))?f.file:null,S=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>l(e),className:V(`rounded-full px-3 py-1 text-[0.8125rem] transition`,c===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[f?.parents.length&&n?(0,$.jsx)(`nav`,{className:`-mb-1.5 flex flex-wrap items-center gap-1 px-1 text-[0.8125rem] text-ink-3`,children:f.parents.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`hover:text-ink`,children:e.title}),(0,$.jsx)(T,{className:`size-3.5`})]},e.id))}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`input`,{value:i,disabled:b,maxLength:200,onChange:e=>a(e.target.value),"aria-label":R(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),m.state===`saving`?(0,$.jsx)(B,{className:`size-3.5 text-ink-3`}):m.state===`saved`?(0,$.jsx)(C,{className:`size-4 text-moss`,"aria-label":R(`settings.saved`)}):null,b?null:(0,$.jsx)(G,{label:R(`data.deletePage`),onClick:()=>confirm(R(`data.confirmDelete`,{title:e.title}))&&h.mutate(),className:`hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]}),f?(0,$.jsx)(It,{projectId:e.projectId,itemKey:`p:${e.id}`,has:f.categories,originLabel:f.originLabel,kept:f.kept,review:f.review,file:x?null:f.file,readOnly:b,onReviewed:()=>_.mutate()}):null,(0,$.jsxs)(W,{className:`flex flex-col`,children:[b&&!x?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[b?null:S(`write`,R(`data.write`)),S(`read`,R(`data.preview`)),x?S(`original`,R(`know.original`)):null,(0,$.jsx)(`span`,{className:`ml-auto truncate px-2 text-[0.75rem] text-ink-4 max-sm:hidden`,children:c===`original`&&x?x.name:R(`data.markdownHint`)})]}),c===`original`&&x?x.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:P(e.projectId,x.id),title:x.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:P(e.projectId,x.id),alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):c===`write`&&!b?(0,$.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),"aria-label":e.title,placeholder:R(`data.pageEmpty`),className:`field-sizing-content min-h-[50vh] w-full resize-none bg-transparent p-4 font-mono text-[0.8125rem] leading-relaxed outline-none placeholder:text-ink-4 sm:p-5`}):(0,$.jsx)(`div`,{className:`min-h-40 p-4 sm:p-5`,onClick:y,children:o.trim()?(0,$.jsx)(v,{text:o}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:R(`data.pageEmpty`)})})]}),m.state===`error`&&m.error?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:m.error}):null,f&&n&&(f.children.length||!b)?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:f.children.length?R(`know.subPages`):null}),b?null:(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,busy:g.isPending,onClick:()=>g.mutate(),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`know.addSub`)]})]}),f.children.length?(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:f.children.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(`p:${e.id}`),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-accent`,children:[(0,$.jsx)(ye,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title})]},e.id))}):null]}):null]})}function Qt({pageId:e,onGone:t,onOpen:n}){let r=c({queryKey:[`space-page`,e],queryFn:()=>u.get(`/api/studio/pages/${e}`),refetchOnWindowFocus:!1});return r.data?(0,$.jsx)(Zt,{page:r.data,onGone:t,onOpen:n},r.data.id):r.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:r.error.message}):null}function $t(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}function en(e,t,n){let r=d(),[i,a]=(0,Q.useState)([]),[o,c]=(0,Q.useState)(`idle`),[l,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(null),_=(0,Q.useRef)(null),v=()=>(_.current??=(async()=>{await Promise.all([r.invalidateQueries({queryKey:[`projects`]}),r.invalidateQueries({queryKey:[`project-files`,e]}),r.invalidateQueries({queryKey:[`knowledge`,e]})]),n(),_.current=null})(),_.current);return{messages:i,phase:o,activity:p,startedAt:h,error:l,send:async(n,l=[])=>{if(!(n.trim()||l.length)||o!==`idle`)return!1;if(f(null),c(`thinking`),g(Date.now()),l.length){try{for(let t of l)await u.upload(`/api/studio/projects/${e}/files?kind=${$t(t)}`,t)}catch(e){return f(e.message),c(`idle`),g(null),await v(),!1}await v();let t=`${R(`editor.attached`)}: ${l.map(e=>e.name).join(`, `)}`;n=n.trim()?`${n}\n\n${t}`:t}let d=i.map(({role:e,content:t})=>({role:e,content:t})).slice(-12),p=`p-${Date.now()}`;a(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:n,previews:E(l)},{id:p,role:`assistant`,content:``,pending:!0}]),m(null);let h=!1;try{await s(`/api/studio/projects/${e}/assist`,{message:n,history:d,part:t},(e,t)=>{if(e===`text`){let e=JSON.parse(t);a(t=>t.map(t=>t.id===p?{...t,content:t.content+e}:t))}else if(e===`activity`)m(JSON.parse(t));else if(e===`card`){let e=JSON.parse(t);a(t=>t.map(t=>t.id===p?{...t,cards:[...t.cards??[],{...e,id:`${p}-${t.cards?.length??0}`}]}:t))}else if(e===`changed`)c(`building`),v();else if(e===`done`){h=!0;let e=JSON.parse(t);a(t=>t.map(t=>t.id===p?{...t,content:e.reply,changed:e.changed,pending:!1}:t))}else e===`error`&&(h=!0,f(JSON.parse(t).message))}),h||f(R(`editor.chatBroken`))}catch(e){f(e.message)}finally{m(null),g(null),a(e=>e.filter(e=>!(e.id===p&&!e.content&&!e.cards?.length)).map(e=>({...e,pending:!1}))),c(`idle`),await _.current,await v(),await r.invalidateQueries({queryKey:[`me`]})}return!0}}}function tn({card:e,send:t}){let n=Ce().cards.find(t=>t.plugin===e.plugin&&t.tool===e.tool);return n?(0,$.jsx)(Ee,{of:n,children:(0,$.jsx)(n.component,{data:e.data,send:e=>void t(e)})}):null}function nn({part:e}){return(0,$.jsxs)(`div`,{className:`sm:pr-36`,children:[(0,$.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-tight tracking-tight`,children:R(e===`knowledge`?`project.assistantTitleKnowledge`:`project.assistantTitle`)}),(0,$.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:R(e===`knowledge`?`project.assistantHelloKnowledge`:`project.assistantHello`)})]})}var rn=72,an=720;function on({projectId:e,part:t,docked:n=!1,onChanged:r}){let i=en(e,t,r),a=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let e=()=>{let e=a.current?.getBoundingClientRect();e&&c(t=>{if(!n&&e.bottom>=rn)return null;let r=Math.min(e.width,an),i=e.left+(e.width-r)/2;return t&&t.left===i&&t.width===r?t:{left:i,width:r,height:t?.height??e.height}})};return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[n]),(0,$.jsxs)(`div`,{ref:a,style:s&&!n?{minHeight:s.height}:void 0,className:n?`-mb-9 h-0`:void 0,children:[n?null:(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 px-1 font-medium text-[0.75rem] text-ember-strong uppercase tracking-[0.07em]`,children:[(0,$.jsx)(S,{className:`size-3.5`}),` `,R(`project.assistant`)]}),(0,$.jsxs)(`div`,{className:`relative`,children:[!s&&i.messages.length===0?(0,$.jsx)(`div`,{className:`absolute -top-14 right-10 z-10 max-sm:hidden`,children:(0,$.jsx)(o,{kind:`round`,size:104})}):null,(0,$.jsx)(`div`,{className:V(`flex flex-col overflow-hidden bg-card`,s?`fixed bottom-4 z-30 max-h-[70dvh] animate-dock rounded-2xl shadow-overlay ring-1 ring-border`:`max-h-[520px] rounded-xl bg-linear-to-br from-ember-tint via-card to-card shadow-soft ring-1 ring-ember-veil`),style:s?{left:s.left,width:s.width}:void 0,children:(0,$.jsx)(ne,{chat:i,avatar:`round`,compact:!!s,intro:(0,$.jsx)(nn,{part:t}),placeholder:R(t===`knowledge`?`project.assistantComposerKnowledge`:`project.assistantComposer`),changedLabel:R(`project.assistantChanged`),card:e=>(0,$.jsx)(tn,{card:e,send:i.send})})})]})]})}var sn=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],cn=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,ln=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,un=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,dn=/^(https?:\/\/|www\.)\S+$/i,fn=/^\+?[\d\s()/.-]{7,20}$/,pn=/^(ja|nein|yes|no|true|false)$/i;function mn(e){let t=e.trim();return t?t.includes(`
3
+ `)||t.length>140?`longtext`:pn.test(t)?`boolean`:un.test(t)?`email`:dn.test(t)?`url`:cn.test(t)?`date`:ln.test(t)&&!/^(\+|0\d)/.test(t)?`number`:fn.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function hn(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var gn=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],_n={facts:100,colors:12,files:{logo:8,asset:100,document:2e3},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},vn=/^#[0-9a-fA-F]{6}$/;function yn({onAdd:e,onClose:t}){let[n,r]=(0,Q.useState)(`#e0531b`),[i,a]=(0,Q.useState)(``),o=vn.test(n);return(0,$.jsx)(H,{open:!0,onClose:t,title:R(`project.colorAddTitle`),children:(0,$.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(he,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,$.jsx)(q,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`project.colorUseLabel`)}),(0,$.jsx)(q,{autoFocus:!0,value:i,maxLength:120,placeholder:R(`project.colorName`),onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`project.colorUse`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:t,children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,disabled:!o,children:R(`project.add`)})]})]})})}function bn({colors:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),[i,a]=(0,Q.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,Q.useState)(!1),c=A(i.filter(e=>vn.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,$.jsxs)(k,{title:R(`project.colors`),hint:R(`project.colorsHint`),save:c,locked:n,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(he,{value:vn.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,$.jsx)(q,{value:e.name,placeholder:R(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(q,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(K,{tone:`ember`,children:R(`project.colorAccent`)})}):n?null:(0,$.jsx)(G,{label:R(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,$.jsx)(g,{className:`size-4`})}),n?null:(0,$.jsx)(G,{label:R(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`project.colorUse`)}):null,i.length<_n.colors&&!n?(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`project.colorAdd`)]}):null,o?(0,$.jsx)(yn,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var xn=e=>/^(ja|yes|true)$/i.test(e.trim()),Sn={text:ve,longtext:st,number:qe,date:Ue,url:F,email:y,phone:tt,boolean:lt};function Cn({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=Sn[e??t],l=`${R(`project.factType`)}: ${R(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:V(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,$.jsx)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:V(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,$.jsx)(oe,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:R(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:R(`project.type.${t}`)}),(0,$.jsx)(C,{className:V(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),sn.map(t=>{let n=Sn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:R(`project.type.${t}`)}),(0,$.jsx)(C,{className:V(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function wn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=A(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=gn.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(k,{title:R(`project.facts`),hint:R(`project.factsHint`),save:s,locked:n,action:a.length<_n.facts&&!n?(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=mn(e.value),r=e.type??t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,$.jsx)(q,{ref:u(`${e.id}:label`),value:e.label,placeholder:R(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:hn(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(_e,{checked:xn(e.value),label:e.label,onChange:t=>c(e.id,{value:R(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:xn(e.value)?R(`project.yes`):R(`project.no`)})]}):(0,$.jsx)(ge,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:R(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Cn,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,$.jsx)(G,{label:R(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]},e.id)})}),a.length<_n.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`project.factAdd`)]}),d.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:X===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(D,{className:`size-3.5`}),` `,X===`en`?e.en:e.de]},e.key))]}):null]})}function Tn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),o=A({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(k,{title:R(`project.base`),hint:R(`project.baseHint`),save:o,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`project.title`)}),(0,$.jsx)(q,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`project.about`)}),(0,$.jsx)(ge,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:R(`project.aboutHint`)})]})]})})}function En({project:e,group:t,docked:n=!1,children:r}){let i=d(),a=j(e.id),[o,s]=(0,Q.useState)(0),c=async t=>{await u.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},l=Z({mutationFn:()=>u.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),f=be(),p=a.data??{files:[],embeddings:!0},m=`${e.id}:${o}`,h=e.readOnly;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[h?(0,$.jsx)(Le,{children:Pe(e)}):(0,$.jsx)(on,{projectId:e.id,part:t,docked:n,onChanged:()=>s(e=>e+1)},e.id),t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{id:`base`,children:(0,$.jsx)(Tn,{project:e,save:c},`base:${m}`)}),(0,$.jsx)(ue,{id:`logos`,children:(0,$.jsx)(Ot,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(ue,{id:`colors`,children:(0,$.jsx)(bn,{colors:e.brand.colors??[],save:e=>c({brand:{colors:e}}),readOnly:h},`colors:${m}`)}),(0,$.jsx)(ue,{id:`assets`,children:(0,$.jsx)(Mt,{projectId:e.id,data:p,readOnly:h})}),(0,$.jsx)(ue,{id:`facts`,children:(0,$.jsx)(wn,{facts:e.facts,save:e=>c({facts:e}),readOnly:h},`facts:${m}`)})]}):null,r,t===`info`&&f&&!h?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(J,{variant:`danger`,busy:l.isPending,onClick:()=>confirm(`${R(`settings.delete`)}?`)&&l.mutate(),children:R(`settings.delete`)}),l.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:l.error.message}):null]}):null]})}var Dn={q:``,mode:``,days:0};function On(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let i=r.toString();return c({queryKey:[`results`,e,i],queryFn:()=>u.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function kn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(re,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(q,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:R(`space.resultsSearch`),"aria-label":R(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(Y,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:R(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(Y,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:R(`space.resultsAnyTime`)},{value:`1`,label:R(`space.resultsDay`)},{value:`7`,label:R(`space.resultsDays`,{n:7})},{value:`30`,label:R(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function An({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(X,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(k,{title:t?o(t):R(`space.resultsAll`),hint:R(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(kn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,R(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:R(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(b,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(K,{children:`Test`}):(0,$.jsxs)(K,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(W,{children:(0,$.jsx)(me,{children:n.q.trim()||n.mode||n.days?R(`space.resultsNone`):R(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:()=>a(null),children:(0,$.jsxs)(`div`,{className:`flex h-full w-full max-w-[680px] animate-rise flex-col bg-background shadow-overlay`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(K,{children:`Test`}):(0,$.jsxs)(K,{tone:`live`,children:[`Live v`,i.version]}),(0,$.jsx)(G,{label:R(`editor.close`),onClick:()=>a(null),children:(0,$.jsx)(Te,{className:`size-5`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(x,{runId:i.id,compact:!0},i.id)})]})}):null]})}function jn(e){return c({queryKey:[`space-data`,e],queryFn:()=>u.get(`/api/studio/projects/${e}/data`),enabled:!!e})}function Mn(e){let t=t=>[...e.tables.filter(e=>e.wizardId===t).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,rows:e.rows})),...e.pages.filter(e=>e.wizardId===t).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title}))];return[{key:`own`,label:R(`data.own`),items:t(null)},...e.wizards.map(e=>({key:e.id,label:e.title,items:t(e.id)}))].filter(e=>e.items.length)}var Nn={table:pe,page:ye};function Pn({kind:e,projectId:t,data:n,onClose:r,onMade:i}){let a=d(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),f=Z({mutationFn:()=>u.post(`/api/studio/projects/${t}/${e===`table`?`tables`:`pages`}`,{title:o.trim(),wizardId:c||null}),onSuccess:async({id:n})=>{await a.invalidateQueries({queryKey:[`space-data`,t]}),i(`${e===`table`?`t`:`p`}:${n}`),s(``),l(``)}});return(0,$.jsx)(H,{open:e!==null,onClose:r,title:R(e===`table`?`data.newTable`:`data.newPage`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),o.trim()&&f.mutate()},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.title`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:o,maxLength:120,onChange:e=>s(e.target.value)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.owner`)}),(0,$.jsx)(Y,{value:c,onChange:l,options:[{value:``,label:R(`data.own`)},...n.wizards.map(e=>({value:e.id,label:e.title}))]})]}),f.error?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:r,children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:f.isPending,disabled:!o.trim(),children:R(`data.create`)})]})]})})}function Fn({projectId:e,data:t,readOnly:n,onOpen:r}){let[i,a]=(0,Q.useState)(null),o=Mn(t),s=new Map([...t.tables.map(e=>[`t:${e.id}`,e.updatedAt]),...t.pages.map(e=>[`p:${e.id}`,e.updatedAt])]),c=new Intl.DateTimeFormat(X,{dateStyle:`medium`});return(0,$.jsxs)(k,{title:R(`space.data`),hint:R(`data.hint`),plain:!0,action:n?null:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>a(`table`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`data.table`)]}),(0,$.jsxs)(J,{variant:`secondary`,size:`sm`,onClick:()=>a(`page`),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`data.page`)]})]}),children:[o.length?(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,children:o.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`p`,{className:`px-1 font-medium text-[0.6875rem] text-ink-4 uppercase tracking-[0.12em]`,children:e.label}),(0,$.jsx)(W,{className:`flex flex-col p-1.5`,children:e.items.map(e=>{let t=Nn[e.kind];return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,$.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3 tabular-nums`,children:[e.kind===`table`?`${R(`data.rows`,{n:e.rows??0})} · `:``,c.format(new Date(s.get(e.key)??Date.now()))]})]},e.key)})})]},e.key))}):(0,$.jsx)(W,{children:(0,$.jsx)(me,{children:R(`data.empty`)})}),(0,$.jsx)(Pn,{kind:i,projectId:e,data:t,onClose:()=>a(null),onMade:e=>{a(null),r(e)}})]})}function In({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),o=Z({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{label:R(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(h,{className:`size-4`})}),(0,$.jsx)(H,{open:n,onClose:()=>r(!1),title:R(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,$.jsx)(q,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:o.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(J,{variant:`ghost`,onClick:()=>r(!1),children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:R(`settings.save`)})]})]})})]})}function Ln({project:e}){let t=d();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(te,{}),e.readOnly?null:(0,$.jsx)(In,{project:e,save:async n=>{await u.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Rn(e,t){let n=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,48)||`column`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}var zn={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5},Bn=[`text`,`number`,`date`,`duration`,`select`,`boolean`];function Vn(e,t){if(t==null)return``;if(e.type===`duration`&&typeof t==`number`)return String(t/zn[e.format.inputUnit]);if(e.type===`date`&&e.format.kind===`datetime`&&typeof t==`string`){let e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}return String(t)}function Hn(e,t){return t.trim()===``?null:e.type===`date`&&e.format.kind===`datetime`?new Date(t).toISOString():t}var Un=`w-full min-w-0 rounded-md bg-transparent px-2 py-1.5 text-[0.875rem] outline-none transition placeholder:text-ink-4 hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`;function Wn({column:e,value:t,readOnly:n,invalid:r,onSave:i}){let a=Vn(e,t),[o,s]=(0,Q.useState)(a);(0,Q.useEffect)(()=>s(a),[a]);let c=(t=o)=>{t!==a&&i(Hn(e,t))};if(e.type===`boolean`)return(0,$.jsx)(`div`,{className:`px-2 py-1.5`,children:(0,$.jsx)(`input`,{type:`checkbox`,checked:t===!0,disabled:n,onChange:e=>i(e.target.checked),"aria-label":e.name,className:`size-4 accent-[var(--ember)]`})});if(e.type===`select`&&e.format.multiple){let r=Array.isArray(t)?t:[],a=t=>e.format.options.find(e=>e.id===t)?.label??t;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-2 py-1`,children:[r.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-paper-2 py-0.5 pr-1 pl-2 text-[0.75rem]`,children:[a(e),n?null:(0,$.jsx)(`button`,{type:`button`,"aria-label":R(`data.removeOption`),onClick:()=>i(r.filter(t=>t!==e)),className:`rounded-full text-ink-3 hover:text-ink`,children:(0,$.jsx)(Te,{className:`size-3`})})]},e)),n?null:(0,$.jsxs)(`select`,{value:``,onChange:e=>e.target.value&&i([...r,e.target.value]),"aria-label":e.name,className:`h-7 rounded-md bg-transparent px-1 text-[0.75rem] text-ink-3 outline-none hover:bg-accent`,children:[(0,$.jsx)(`option`,{value:``,children:`+`}),e.format.options.filter(e=>!r.includes(e.id)).map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]})}if(e.type===`select`)return(0,$.jsxs)(`select`,{value:typeof t==`string`?t:``,disabled:n,onChange:e=>i(e.target.value||null),"aria-label":e.name,className:Un,children:[(0,$.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))]});if(e.type===`text`&&e.format?.style&&e.format.style!==`single`)return(0,$.jsx)(`textarea`,{value:o,rows:1,disabled:n,onChange:e=>s(e.target.value),onBlur:()=>c(),"aria-label":e.name,className:V(Un,`field-sizing-content max-h-40 resize-none`)});let l=e.type===`date`?{date:`date`,datetime:`datetime-local`,time:`time`}[e.format.kind]:`text`;return(0,$.jsx)(`input`,{type:l,inputMode:e.type===`number`||e.type===`duration`?`decimal`:void 0,value:o,disabled:n,onChange:t=>{s(t.target.value),e.type===`date`&&c(t.target.value)},onBlur:()=>e.type!==`date`&&c(),onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&s(a)},"aria-label":e.name,className:V(Un,(e.type===`number`||e.type===`duration`)&&`text-right tabular-nums`,r&&`ring-1 ring-rose`)})}function Gn(e){return e.type===`number`&&e.format.style===`currency`?e.format.currency??null:e.type===`number`&&e.format.style===`percent`?`%`:e.type===`duration`?R(`data.unit.${e.format.inputUnit}`):null}function Kn(e){return{name:e?.name??``,type:e?.type??`text`,required:e?.required??!1,textStyle:e?.type===`text`&&(e.format?.style??`single`)!==`single`?`multiline`:`single`,numberStyle:e?.type===`number`?e.format.style:`decimal`,currency:e?.type===`number`?e.format.currency??`EUR`:`EUR`,dateKind:e?.type===`date`?e.format.kind:`date`,unit:e?.type===`duration`&&[`minutes`,`hours`,`days`].includes(e.format.inputUnit)?e.format.inputUnit:`minutes`,options:e?.type===`select`?e.format.options.map(e=>e.label).join(`
4
+ `):``,multiple:e?.type===`select`&&!!e.format.multiple}}function qn(e,t,n){let r={id:t,name:e.name.trim(),...e.required?{required:!0}:{}};switch(e.type){case`number`:return{...r,type:`number`,format:e.numberStyle===`currency`?{style:`currency`,currency:e.currency.trim().toUpperCase()}:{style:e.numberStyle}};case`date`:return{...r,type:`date`,format:{kind:e.dateKind}};case`duration`:return{...r,type:`duration`,format:{inputUnit:e.unit,display:`hms`}};case`select`:{let t=n?.type===`select`?n.format.options:[],i=[],a=e.options.split(`
5
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t.find(t=>t.label===e)?.id??Rn(e,i);return i.push(n),{id:n,label:e}});return{...r,type:`select`,format:{allowCustom:!1,options:a,...e.multiple?{multiple:!0}:{}}}}case`boolean`:return{...r,type:`boolean`};default:return{...r,type:`text`,...e.textStyle===`multiline`?{format:{style:`multiline`}}:{}}}}function Jn({open:e,column:t,columns:n,onClose:r,onSave:i}){let[a,o]=(0,Q.useState)(()=>Kn(t)),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(o(Kn(t)),c(null))},[e,t]);let d=e=>o(t=>({...t,...e})),f=async e=>{u(!0),c(null);try{await i(e),r()}catch(e){c(e.message)}finally{u(!1)}},p=()=>{let e=t?.id??Rn(a.name,n.map(e=>e.id)),r=qn(a,e,t);return f(t?n.map(e=>e.id===t.id?r:e):[...n,r])};return(0,$.jsx)(H,{open:e,onClose:r,title:t?t.name:R(`data.newColumn`),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),a.name.trim()&&p()},children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.columnName`)}),(0,$.jsx)(q,{"data-autofocus":!0,value:a.name,maxLength:128,onChange:e=>d({name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.columnType`)}),(0,$.jsx)(Y,{value:a.type,onChange:e=>d({type:e}),options:Bn.map(e=>({value:e,label:R(`data.type.${e}`)}))})]})]}),a.type===`text`?(0,$.jsx)(Y,{value:a.textStyle,onChange:e=>d({textStyle:e}),options:[{value:`single`,label:R(`data.text.single`)},{value:`multiline`,label:R(`data.text.multiline`)}]}):null,a.type===`number`?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(Y,{value:a.numberStyle,onChange:e=>d({numberStyle:e}),options:[`integer`,`decimal`,`percent`,`currency`].map(e=>({value:e,label:R(`data.number.${e}`)}))}),a.numberStyle===`currency`?(0,$.jsx)(q,{value:a.currency,maxLength:3,"aria-label":R(`data.currency`),placeholder:`EUR`,onChange:e=>d({currency:e.target.value})}):null]}):null,a.type===`date`?(0,$.jsx)(Y,{value:a.dateKind,onChange:e=>d({dateKind:e}),options:[`date`,`datetime`,`time`].map(e=>({value:e,label:R(`data.date.${e}`)}))}):null,a.type===`duration`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.unit`)}),(0,$.jsx)(Y,{value:a.unit,onChange:e=>d({unit:e}),options:[`minutes`,`hours`,`days`].map(e=>({value:e,label:R(`data.unit.${e}`)}))})]}):null,a.type===`select`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(z,{children:R(`data.options`)}),(0,$.jsx)(ge,{minRows:3,value:a.options,onChange:e=>d({options:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,$.jsx)(_e,{checked:a.multiple,onChange:e=>d({multiple:e})}),R(`data.multiple`)]})]}):null,(0,$.jsxs)(`label`,{className:`flex items-center gap-3 text-[0.875rem]`,children:[(0,$.jsx)(_e,{checked:a.required,onChange:e=>d({required:e})}),R(`data.required`)]}),s?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:s}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&n.length>1?(0,$.jsx)(J,{variant:`ghost`,className:`text-rose`,disabled:l,onClick:()=>confirm(R(`data.confirmDelete`,{title:t.name}))&&void f(n.filter(e=>e.id!==t.id)),children:R(`data.deleteColumn`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(J,{variant:`ghost`,onClick:r,children:R(`common.cancel`)}),(0,$.jsx)(J,{type:`submit`,busy:l,disabled:!a.name.trim(),children:R(`settings.save`)})]})]})})}function Yn({tableId:e,onGone:t}){let n=d(),r=[`space-table`,e],i=c({queryKey:r,queryFn:()=>u.get(`/api/studio/tables/${e}`)}),[a,o]=(0,Q.useState)(null),[s,l]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``);(0,Q.useEffect)(()=>g(i.data?.title??``),[i.data?.title]);let _=async()=>{await n.invalidateQueries({queryKey:[`space-data`,i.data?.projectId]}),await n.invalidateQueries({queryKey:[`knowledge`,i.data?.projectId]})},v=e=>n.setQueryData(r,t=>t&&{...t,rows:e(t.rows)}),y=e=>{l(e.message),i.refetch()},b=async t=>{await u.patch(`/api/studio/tables/${e}`,t),await i.refetch(),await _()},x=Z({mutationFn:({row:t,column:n,value:r})=>u.patch(`/api/studio/tables/${e}/rows/${t}`,{cells:{[n]:r}}),onSuccess:(e,{row:t,column:n})=>{l(null),m(e=>e===`${t}:${n}`?null:e),v(t=>t.map(t=>t.id===e.id?{...t,cells:e.cells}:t))},onError:(e,{row:t,column:n})=>{if(e instanceof f&&e.body?.column===n){let e=i.data?.columns.find(e=>e.id===n)?.name??n;m(`${t}:${n}`),l(R(`data.badCell`,{column:e}));return}y(e)}}),S=Z({mutationFn:()=>u.post(`/api/studio/tables/${e}/rows`,{}),onSuccess:async e=>{v(t=>[...t,{...e,updatedAt:new Date().toISOString()}]),await _()},onError:y}),ee=Z({mutationFn:t=>u.post(`/api/studio/tables/${e}/rows/delete`,{ids:[t]}),onSuccess:async(e,t)=>{v(e=>e.filter(e=>e.id!==t)),await _()},onError:y}),te=Z({mutationFn:()=>u.del(`/api/studio/tables/${e}`),onSuccess:async()=>{await _(),t()}});if(!i.data)return i.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:i.error.message}):null;let{columns:C,rows:w,readOnly:T}=i.data,E=!!i.data.list;return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`input`,{value:h,disabled:T,maxLength:120,onChange:e=>g(e.target.value),onBlur:()=>h.trim()&&h!==i.data?.title&&void b({title:h}).catch(y),onKeyDown:e=>e.key===`Enter`&&e.target.blur(),"aria-label":R(`data.title`),className:`-ml-1 min-w-0 flex-1 rounded-md bg-transparent px-1 font-display font-semibold text-lg outline-none hover:bg-accent focus:bg-paper focus:ring-1 focus:ring-ring disabled:hover:bg-transparent`}),T?null:(0,$.jsx)(G,{label:R(`data.deleteTable`),onClick:()=>confirm(R(`data.confirmDelete`,{title:i.data.title}))&&te.mutate(),className:`hover:text-rose`,children:(0,$.jsx)(I,{className:`size-4`})})]}),E?(0,$.jsx)(`p`,{className:`-mt-1.5 px-1 text-[0.8125rem] text-ink-3`,children:R(`data.fromList`)}):null,i.data.knowledge?(0,$.jsx)(It,{projectId:i.data.projectId,itemKey:`t:${i.data.id}`,has:i.data.knowledge.categories,originLabel:i.data.knowledge.originLabel,kept:i.data.knowledge.kept,review:i.data.knowledge.review,file:i.data.knowledge.file,readOnly:T,onReviewed:()=>void u.patch(`/api/studio/tables/${e}`,{review:null}).then(()=>i.refetch()).catch(y)}):null,(0,$.jsxs)(W,{className:`overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-border-soft border-b`,children:[C.map(e=>(0,$.jsx)(`th`,{className:`min-w-36 border-border-soft border-l p-1 font-medium first:border-l-0`,children:(0,$.jsxs)(`button`,{type:`button`,disabled:T||E,onClick:()=>o(e),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-left text-[0.8125rem] text-ink-2 transition hover:bg-accent hover:text-ink disabled:hover:bg-transparent`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.name}),e.required?(0,$.jsx)(`span`,{className:`text-ember`,children:`*`}):null,Gn(e)?(0,$.jsx)(`span`,{className:`font-normal text-ink-4`,children:Gn(e)}):null]})},e.id)),(0,$.jsx)(`th`,{className:`w-10 p-1`,children:T||E?null:(0,$.jsx)(G,{label:R(`data.newColumn`),onClick:()=>o(`new`),className:`size-8`,children:(0,$.jsx)(D,{className:`size-4`})})})]})}),(0,$.jsx)(`tbody`,{children:w.map(e=>(0,$.jsxs)(`tr`,{className:`group border-border-soft border-b last:border-b-0`,children:[C.map(t=>(0,$.jsx)(`td`,{className:`border-border-soft border-l p-1 align-top first:border-l-0`,children:(0,$.jsx)(Wn,{column:t,value:e.cells[t.id],readOnly:T,invalid:p===`${e.id}:${t.id}`,onSave:n=>x.mutate({row:e.id,column:t.id,value:n})})},t.id)),(0,$.jsx)(`td`,{className:`w-10 p-1 align-top`,children:T?null:(0,$.jsx)(G,{label:R(`data.deleteRow`),onClick:()=>ee.mutate(e.id),className:`size-8 opacity-0 hover:text-rose focus:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:(0,$.jsx)(I,{className:`size-3.5`})})})]},e.id))})]})}),w.length?null:(0,$.jsx)(`p`,{className:`px-4 py-6 text-center text-[0.875rem] text-ink-3`,children:R(`data.noRows`)}),T?null:(0,$.jsx)(`div`,{className:`border-border-soft border-t p-1.5`,children:(0,$.jsxs)(J,{variant:`ghost`,size:`sm`,busy:S.isPending,onClick:()=>S.mutate(),children:[(0,$.jsx)(D,{className:`size-4`}),` `,R(`data.addRow`)]})})]}),s?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:s}):null,(0,$.jsx)(Jn,{open:a!==null,column:a===`new`?null:a,columns:C,onClose:()=>o(null),onSave:e=>b({columns:e})})]})}function Xn(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=window.scrollY>0&&window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-4,i=Math.max(160,window.innerHeight/3),a=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=i&&(a=t)}r(t?e.at(-1):a)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a)}},[t]),n}function Zn(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Qn({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Ae,{icon:e.icon??rt,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Ne,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function $n(){let{group:e}=l(),[t,n]=r(),o=a(),s=i(),{hash:c}=s,{project:u,loading:d}=Oe(),f=be(),m=Ce(),h=Ve(),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S=De(e)?e:void 0,ee=s.state?.parts===!0,te=Se().map(e=>({...e,to:`/space/${e.id}`})),C=te.find(e=>e.id===S),w=t.get(`show`),T=S?w?2:1:0,E=h?Math.min(T,1):S&&b!==S&&!ee?1:0,ne=Me(E),re=Me(T),ie=(0,Q.useMemo)(()=>({slot:g,narrow:h,setDetail:y}),[g,h]),D=u?u.brand.name?.trim()||u.name:R(`nav.project`),ae=S&&S!==`results`?ke(S,m):[],O=S?ke(S,m).filter(e=>e.plugin):[],se=Xn([...ae,...S===`results`?O:[]].flatMap(e=>e.sections.map(e=>e.id))),A=S===`results`&&w&&w!==`all`?w:null,[ce,de]=(0,Q.useState)(Dn),j=On(S===`results`?u?.id:void 0,A,ce),fe=j.data?.wizards.find(e=>e.id===A)?.title,M=S===`data`&&w&&w!==`all`||S===`knowledge`&&w&&/^[ptfcvs]:/.test(w)?w:null,N=M?.startsWith(`s:`)?m.spaceSections.find(e=>e.id===M.slice(2)):void 0,P=S===`knowledge`&&M&&/^[ptf]:/.test(M)?M:null,F=jn(S===`data`?u?.id:void 0),I=Nt(S===`knowledge`?u?.id:void 0),L=xt(M?.startsWith(`v:`)?M.slice(2):``),pe=I.data?.categories.find(e=>e.id===(M?.startsWith(`c:`)?M.slice(2):L.data?.category.id)),z=S===`knowledge`?N?N.label():M?.startsWith(`v:`)?L.data&&`${L.data.category.name}: ${L.data.value}`:M?.startsWith(`c:`)?pe?.name:I.data?.items.find(e=>e.key===M)?.title:F.data?Mn(F.data).flatMap(e=>e.items).find(e=>e.key===M)?.title:void 0;we([{label:D,to:`/space`},...C?[{label:C.label,to:`/space/${C.id}`}]:[],...C&&(v??fe??z)?[{label:v??fe??z}]:[]]);let B=S===`results`||S===`data`||M?c.slice(1):w||c.slice(1),he=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${S}#${B}`;B&&he.current!==e&&document.getElementById(B)&&(he.current=e,requestAnimationFrame(()=>Zn(B,!1)))},[S,B,u?.id,m.spaceSections]),!S){let t=c.slice(1),n=t?xe(t,m):null;if(n===`knowledge`&&m.spaceSections.some(e=>e.id===t))return(0,$.jsx)(p,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(p,{to:h?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&m.status!==`ready`)return null;if(e!==void 0||!h)return(0,$.jsx)(p,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(S===`knowledge`&&!w&&m.spaceSections.some(e=>e.id===c.slice(1)))return(0,$.jsx)(p,{to:`/space/knowledge?show=s:${c.slice(1)}`,replace:!0});let H=e=>{if(h){o({search:`?show=${e}`});return}he.current=`${S}#${e}`,Zn(e,!0),o({search:``,hash:e},{replace:!0})},U=e=>h?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),ge=e=>e.flatMap(e=>e.sections).map(e=>m.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(ue,{id:e.id,children:(0,$.jsx)(k,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(Ee,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),W=h?void 0:se;return(0,$.jsx)(Ie.Provider,{value:ie,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:V(`min-w-0 md:sticky md:top-20 md:self-start`,h&&T===2&&`hidden`,h&&re===`back`&&je(`back`)),children:[(0,$.jsx)(Fe,{title:D,open:E===1?C??null:null,onBack:()=>h?o(`/space`):x(S??null)}),(0,$.jsx)(`div`,{className:V(je(ne)),children:E===0?(0,$.jsx)(Re,{entries:te,current:h?void 0:C,onPick:()=>x(null)}):(0,$.jsx)(`div`,{ref:_})},E)]}),S?(0,$.jsxs)(`div`,{className:V(`min-w-0`,h&&T<2&&`hidden`,h&&re===`deeper`&&je(`deeper`)),children:[h?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Be,{label:C?.label??D,onBack:()=>o(`/space/${S}`)})}):null,f&&u?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Ln,{project:u})}):null,S===`results`?(0,$.jsxs)(ze,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Ae,{icon:Ye,label:R(`space.resultsAll`),selected:!h&&!A,onPick:()=>U(`all`)}),j.data?.wizards.filter(e=>e.results||e.id===A).map(e=>(0,$.jsx)(Ae,{icon:oe,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!h&&e.id===A,onPick:()=>U(e.id)},e.id))]}),(0,$.jsx)(Qn,{groups:O,current:W,onPick:H})]}):S===`data`?(0,$.jsxs)(ze,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Ae,{icon:le,label:R(`data.all`),selected:!h&&!M,onPick:()=>U(`all`)})}),F.data?Mn(F.data).map(e=>(0,$.jsx)(Ne,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Ae,{icon:Nn[e.kind],label:e.title,selected:!h&&e.key===M,onPick:()=>U(e.key)},e.key))},e.key)):null,(0,$.jsx)(Qn,{groups:O,current:W,onPick:H})]}):S===`knowledge`?(0,$.jsxs)(ze,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Ae,{icon:le,label:R(`know.all`),selected:!(h||M),onPick:()=>U(`all`)})}),I.data?.categories.length?(0,$.jsx)(Ne,{label:R(`know.categories`),children:I.data.categories.map(e=>(0,$.jsx)(Ae,{icon:ut[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!h&&(M===`c:${e.id}`||L.data?.category.id===e.id),onPick:()=>U(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(Qn,{groups:O,current:h?void 0:N?.id,onPick:e=>U(`s:${e}`)})]}):(0,$.jsx)(ze,{children:(0,$.jsx)(Qn,{groups:ae,current:W,onPick:H})}),u&&(S===`info`||S===`knowledge`)?(0,$.jsxs)(En,{project:u,group:S,docked:S===`knowledge`&&!!M&&!N,children:[S===`knowledge`?P?P.startsWith(`p:`)?(0,$.jsx)(Qt,{pageId:P.slice(2),onGone:()=>U(`all`),onOpen:U},P):P.startsWith(`t:`)?(0,$.jsx)(Yn,{tableId:P.slice(2),onGone:()=>U(`all`)},P):(0,$.jsx)(Yt,{projectId:u.id,fileId:P.slice(2),readOnly:u.readOnly,onGone:()=>U(`all`)},P):I.data?N?(0,$.jsx)(k,{title:N.label(),hint:N.hint?.(),plain:!0,children:(0,$.jsx)(Ee,{of:N,children:(0,$.jsx)(N.component,{})})},M):M?.startsWith(`c:`)?pe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(bt,{projectId:u.id,category:pe,readOnly:u.readOnly,onOpen:U,onGone:()=>U(`all`)}),pe.type===`choice`?null:(0,$.jsx)(Rt,{projectId:u.id,category:pe,categories:I.data.categories,onOpen:U})]},M):null:M?.startsWith(`v:`)?L.data?(0,$.jsx)(St,{value:L.data,readOnly:u.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[L.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:L.data.items.map(e=>(0,$.jsx)(Ft,{item:e,categories:I.data.categories.filter(e=>e.id!==L.data?.category.id),onOpen:U},e.key))}):null,L.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:R(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},M):null:(0,$.jsx)(ue,{id:`documents`,children:(0,$.jsx)(Wt,{projectId:u.id,data:I.data,readOnly:u.readOnly,onOpen:U})}):null:null,S===`info`?ge(O):null]},u.id):null,u&&S===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:M?.startsWith(`t:`)?(0,$.jsx)(Yn,{tableId:M.slice(2),onGone:()=>U(`all`)},M):M?.startsWith(`p:`)?(0,$.jsx)(Qt,{pageId:M.slice(2),onGone:()=>U(`all`)},M):(0,$.jsxs)($.Fragment,{children:[F.data?(0,$.jsx)(Fn,{projectId:u.id,data:F.data,readOnly:u.readOnly,onOpen:U}):null,ge(O)]})}):null,u&&S===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[j.data?(0,$.jsx)(An,{data:j.data,wizardId:A,filter:ce,onFilter:de}):null,j.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:j.error.message}):null,ge(O)]}):null,u||d?null:(0,$.jsx)(me,{children:R(`settings.noProject`)})]}):null]})})})}export{$n as ProjectPage};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-DB22_B7G.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{c as h,o as g,s as _,t as v}from"./RunnerView-DzHGshZj.js";import{t as y}from"./arrow-right-6FyN3e7D.js";import{b,d as x,h as S,t as C}from"./ui-I7QYMX0F.js";var w={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`}]]};w.node;var T=m(w),E={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};E.node;var D=m(E),O={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`]};O.node;var k=m(O),A=e(t(),1);function j(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`?e:null}var M=j(),N=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`);function P(){(0,A.useEffect)(()=>{if(M===`inline`){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>N(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(M===`modal`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&N(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[])}var F=e(n(),1);function I(e){(0,A.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function L(e,t){(0,A.useEffect)(()=>{if(!e||!t)return;let n=a(`/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 R=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,z=R||/Android/.test(navigator.userAgent);function B(){let[e,t]=(0,A.useState)(()=>window.wizardInstall??null),[n,r]=(0,A.useState)(!1);if((0,A.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||z&&!e&&!R)return null;let i=/Mac/.test(navigator.platform),a=b(z?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,F.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{z&&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:[z?(0,F.jsx)(k,{className:`size-4`}):(0,F.jsx)(T,{className:`size-4`}),b(z?`install.add`:`install.bookmark`)]}),n?(0,F.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function V({brand:e,toggle:t=!0}){return(0,F.jsx)(`header`,{className:`safe-top`,children:(0,F.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,F.jsx)(`img`,{src:a(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,F.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,F.jsx)(`div`,{className:`absolute right-3`,children:(0,F.jsx)(s,{})}):null]})})}function H({siteKey:e,onToken:t}){let n=(0,A.useRef)(null);return(0,A.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,F.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function U({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||g||M?null:(0,F.jsxs)(`a`,{href:_(`${window.location.origin}${i}/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,F.jsx)(D,{className:`size-4`}),` `,b(`install.app`)]})}var W=e=>`wz.run.${e}`,G=g&&new URLSearchParams(window.location.search).get(`start`)===`1`,K=M===`inline`?`min-h-80`:`min-h-dvh`;function q({wizard:e}){let t=r(),[n,i]=(0,A.useState)(!1),[a,s]=(0,A.useState)(null),[c,l]=(0,A.useState)(null),u=(()=>{try{return localStorage.getItem(W(e.token))}catch{return null}})(),d=async()=>{i(!0),s(null);try{let{runId:n}=await f.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:M!==null});try{localStorage.setItem(W(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:G})}catch(e){s(e.message),i(!1)}},p=G&&e.available&&!e.turnstileSiteKey,m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{p&&!m.current&&(m.current=!0,d())},[p]),p&&!a?(0,F.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,F.jsx)(x,{})}):(0,F.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,F.jsx)(o,{kind:e.avatar,size:190,fluffy:!0}),(0,F.jsx)(`h1`,{className:`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,F.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(C,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!c,onClick:d,children:[b(`run.start`),` `,(0,F.jsx)(y,{className:`size-4`})]}),e.turnstileSiteKey?(0,F.jsx)(H,{siteKey:e.turnstileSiteKey,onToken:l}):null,u?(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(`/w/${e.token}/${u}`),className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:b(`run.resume`)}):null,M||g?null:(0,F.jsx)(B,{}),(0,F.jsx)(U,{token:e.token})]}):(0,F.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??b(`run.unavailable`)}),a?(0,F.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:a}):null]})}function J(){let{token:e,runId:t}=u(),n=r(),a=l({queryKey:[`public`,e],queryFn:()=>f.get(`/api/public/wizards/${e}`),retry:(e,t)=>p(t)&&e<3});if(I(a.data?.brand.accent),c(a.data?.avatar),L(e,a.data?.title),P(),(0,A.useEffect)(()=>{a.data&&(document.title=a.data.title)},[a.data]),(0,A.useEffect)(()=>{e&&t&&h(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,F.jsx)(`div`,{className:S(`flex items-center justify-center text-ink-4`,K),children:(0,F.jsx)(x,{})});if(!a.data){let e=p(a.error);return(0,F.jsxs)(`div`,{className:S(`flex flex-col items-center justify-center gap-4 px-6 text-center`,K),children:[(0,F.jsx)(o,{kind:`pebble`,size:80}),(0,F.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:b(e?`common.offline`:`run.notFound`)}),e?(0,F.jsx)(C,{variant:`secondary`,onClick:()=>void a.refetch(),children:b(`common.retry`)}):null]})}return(0,F.jsxs)(`div`,{className:S(`flex flex-col`,K),children:[M===`inline`||g?null:(0,F.jsx)(V,{brand:a.data.brand,toggle:!M}),(0,F.jsx)(`div`,{className:`flex-1`,children:t?(0,F.jsx)(v,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,F.jsx)(q,{wizard:a.data})}),g?(0,F.jsx)(`div`,{className:`safe-bottom`}):(0,F.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,F.jsx)(`a`,{href:`${i}/`,target:M?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:b(`run.madeWith`).replace(`engenty wizards`,d.name)})})]})}export{V as BrandHeader,J as PublicRunner,I as useBrandAccent};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,a as i,c as a,d as o,f as s,h as c,j as l,k as u,l as d,n as f,r as p}from"./api-CVG-xDEn.js";import{t as m}from"./createLucideIcon-q3MZMmnf.js";import{c as h,o as g,s as _,t as v}from"./RunnerView-Bqp0paLi.js";import{t as y}from"./arrow-right-6FyN3e7D.js";import{b,d as x,h as S,t as C}from"./ui-BPY2pIh0.js";var w={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`}]]};w.node;var T=m(w),E={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};E.node;var D=m(E),O={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`]};O.node;var k=m(O),A=e(t(),1);function j(){if(window.self===window.top)return null;let e=new URLSearchParams(window.location.search).get(`embed`);return e===`inline`||e===`modal`?e:null}var M=j(),N=(e,t={})=>window.parent.postMessage({type:`engenty-wizard:${e}`,...t},`*`);function P(){(0,A.useEffect)(()=>{if(M===`inline`){let e=document.documentElement;document.getElementById(`root`)?.style.setProperty(`min-height`,`0`),e.style.overflow=`hidden`;let t=new ResizeObserver(()=>N(`height`,{height:Math.ceil(e.getBoundingClientRect().height)}));return t.observe(e),()=>t.disconnect()}if(M===`modal`){let e=e=>{e.key===`Escape`&&!document.querySelector(`dialog[open]`)&&N(`close`)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}},[])}var F=e(n(),1);function I(e){(0,A.useEffect)(()=>{if(!e)return;let t=document.documentElement;return t.style.setProperty(`--raw-primary`,e),()=>{t.style.removeProperty(`--raw-primary`)}},[e])}function L(e,t){(0,A.useEffect)(()=>{if(!e||!t)return;let n=a(`/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 R=/iPhone|iPad|iPod/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1,z=R||/Android/.test(navigator.userAgent);function B(){let[e,t]=(0,A.useState)(()=>window.wizardInstall??null),[n,r]=(0,A.useState)(!1);if((0,A.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||z&&!e&&!R)return null;let i=/Mac/.test(navigator.platform),a=b(z?`install.ios`:i?`install.bookmark.mac`:`install.bookmark.pc`);return(0,F.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>{z&&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:[z?(0,F.jsx)(k,{className:`size-4`}):(0,F.jsx)(T,{className:`size-4`}),b(z?`install.add`:`install.bookmark`)]}),n?(0,F.jsx)(`p`,{className:`max-w-xs leading-relaxed`,children:a}):null]})}function V({brand:e,toggle:t=!0}){return(0,F.jsx)(`header`,{className:`safe-top`,children:(0,F.jsxs)(`div`,{className:`relative flex h-14 items-center justify-center px-5`,children:[e.logoUrl?(0,F.jsx)(`img`,{src:a(e.logoUrl),alt:e.name,className:`h-7 max-w-[160px] object-contain`}):e.name?(0,F.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,F.jsx)(`div`,{className:`absolute right-3`,children:(0,F.jsx)(s,{})}):null]})})}function H({siteKey:e,onToken:t}){let n=(0,A.useRef)(null);return(0,A.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,F.jsx)(`div`,{ref:n,className:`mt-4 flex justify-center`})}function U({token:e}){return!/iPhone|iPad|iPod|Android/.test(navigator.userAgent)||g||M?null:(0,F.jsxs)(`a`,{href:_(`${window.location.origin}${i}/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,F.jsx)(D,{className:`size-4`}),` `,b(`install.app`)]})}var W=e=>`wz.run.${e}`,G=g&&new URLSearchParams(window.location.search).get(`start`)===`1`,K=M===`inline`?`min-h-80`:`min-h-dvh`;function q({wizard:e}){let t=r(),[n,i]=(0,A.useState)(!1),[a,s]=(0,A.useState)(null),[c,l]=(0,A.useState)(null),u=(()=>{try{return localStorage.getItem(W(e.token))}catch{return null}})(),d=async()=>{i(!0),s(null);try{let{runId:n}=await f.post(`/api/public/wizards/${e.token}/runs`,{turnstileToken:c??void 0,embedded:M!==null});try{localStorage.setItem(W(e.token),n)}catch{}t(`/w/${e.token}/${n}`,{replace:G})}catch(e){s(e.message),i(!1)}},p=G&&e.available&&!e.turnstileSiteKey,m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{p&&!m.current&&(m.current=!0,d())},[p]),p&&!a?(0,F.jsx)(`div`,{className:`flex min-h-[60dvh] items-center justify-center text-ink-4`,children:(0,F.jsx)(x,{})}):(0,F.jsxs)(`div`,{className:`mx-auto flex max-w-lg animate-rise flex-col items-center px-6 pt-6 pb-12 text-center sm:pt-16 sm:pb-16`,children:[(0,F.jsx)(o,{kind:e.avatar,size:190,fluffy:!0}),(0,F.jsx)(`h1`,{className:`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,F.jsx)(`p`,{className:`mt-3 text-[1rem] text-ink-2 leading-relaxed`,children:e.description}):null,e.available?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(C,{size:`lg`,className:`mt-10 min-w-48`,busy:n,disabled:!!e.turnstileSiteKey&&!c,onClick:d,children:[b(`run.start`),` `,(0,F.jsx)(y,{className:`size-4`})]}),e.turnstileSiteKey?(0,F.jsx)(H,{siteKey:e.turnstileSiteKey,onToken:l}):null,u?(0,F.jsx)(`button`,{type:`button`,onClick:()=>t(`/w/${e.token}/${u}`),className:`mt-4 text-[0.875rem] text-ink-3 underline-offset-4 hover:text-ink hover:underline coarse:min-h-11`,children:b(`run.resume`)}):null,M||g?null:(0,F.jsx)(B,{}),(0,F.jsx)(U,{token:e.token})]}):(0,F.jsx)(`p`,{className:`mt-10 rounded-xl bg-paper-2 px-5 py-4 text-[0.9375rem] text-ink-2`,children:e.unavailableReason??b(`run.unavailable`)}),a?(0,F.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:a}):null]})}function J(){let{token:e,runId:t}=u(),n=r(),a=l({queryKey:[`public`,e],queryFn:()=>f.get(`/api/public/wizards/${e}`),retry:(e,t)=>p(t)&&e<3});if(I(a.data?.brand.accent),c(a.data?.avatar),L(e,a.data?.title),P(),(0,A.useEffect)(()=>{a.data&&(document.title=a.data.title)},[a.data]),(0,A.useEffect)(()=>{e&&t&&h(`run`,{token:e,runId:t})},[e,t]),a.isLoading)return(0,F.jsx)(`div`,{className:S(`flex items-center justify-center text-ink-4`,K),children:(0,F.jsx)(x,{})});if(!a.data){let e=p(a.error);return(0,F.jsxs)(`div`,{className:S(`flex flex-col items-center justify-center gap-4 px-6 text-center`,K),children:[(0,F.jsx)(o,{kind:`pebble`,size:80}),(0,F.jsx)(`p`,{className:`max-w-xs text-ink-3`,children:b(e?`common.offline`:`run.notFound`)}),e?(0,F.jsx)(C,{variant:`secondary`,onClick:()=>void a.refetch(),children:b(`common.retry`)}):null]})}return(0,F.jsxs)(`div`,{className:S(`flex flex-col`,K),children:[M===`inline`||g?null:(0,F.jsx)(V,{brand:a.data.brand,toggle:!M}),(0,F.jsx)(`div`,{className:`flex-1`,children:t?(0,F.jsx)(v,{runId:t,onRestart:()=>n(`/w/${e}`)}):(0,F.jsx)(q,{wizard:a.data})}),g?(0,F.jsx)(`div`,{className:`safe-bottom`}):(0,F.jsx)(`footer`,{className:`safe-bottom pt-6 text-center text-[0.75rem] text-ink-4`,children:(0,F.jsx)(`a`,{href:`${i}/`,target:M?`_blank`:void 0,rel:`noreferrer`,className:`inline-block py-3.5 hover:text-ink-2`,children:b(`run.madeWith`).replace(`engenty wizards`,d.name)})})]})}export{V as BrandHeader,J as PublicRunner,I as useBrandAccent};