wizards 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/app.js +36 -4
- package/apps/runtime/dist/auth/local-ticket.js +8 -5
- package/apps/runtime/dist/cli/connect.js +531 -0
- package/apps/runtime/dist/cli/environment.js +3 -1
- package/apps/runtime/dist/cli/main.js +17 -0
- package/apps/runtime/dist/cli/mcp.js +175 -0
- package/apps/runtime/dist/cli/setup.js +49 -0
- package/apps/runtime/dist/mcp/auth.js +26 -0
- package/apps/runtime/dist/mcp/flow-app.js +94 -0
- package/apps/runtime/dist/mcp/handler.js +15 -5
- package/apps/runtime/dist/mcp/seen.js +65 -0
- package/apps/runtime/dist/mcp/tools.js +156 -4
- package/apps/runtime/dist/routes/runs.js +7 -3
- package/apps/runtime/dist/routes/studio.js +20 -0
- package/apps/runtime/dist/secrets/signing.js +21 -3
- package/apps/runtime/dist/services/runs.js +190 -28
- package/apps/runtime/dist/services/wizards.js +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-COqPzrKT.js → ChangelogDialog-Co_9fs61.js} +1 -1
- package/apps/web/dist/assets/ChatPanel-Br3nYkUc.js +1 -0
- package/apps/web/dist/assets/{CreditsDialog-pRbTW7Xh.js → CreditsDialog-D3fZRqXH.js} +1 -1
- package/apps/web/dist/assets/EditorPage-BSjQC6FE.js +2 -0
- package/apps/web/dist/assets/{FlowPreview-CDmcN1oX.js → FlowPreview-CjUK5046.js} +1 -1
- package/apps/web/dist/assets/{HomePage-DUAiS9pg.js → HomePage-8v4HqIbP.js} +1 -1
- package/apps/web/dist/assets/{ImportWizard-pzljVvcr.js → ImportWizard-DiV62Uno.js} +1 -1
- package/apps/web/dist/assets/{LocalRuntime-DPJMJlWc.js → LocalRuntime-CTyLGC98.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-BBL2yenw.js +2 -0
- package/apps/web/dist/assets/{PublicRunner-DoZdJuyW.js → PublicRunner-BwtoEVlE.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-XKosfgO-.js → RunnerView-DOizlTad.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-CBDv04YS.js +2 -0
- package/apps/web/dist/assets/{SetupPage-BFQ0V__v.js → SetupPage-CfXTOaIm.js} +1 -1
- package/apps/web/dist/assets/{SharePage-C1yg5bc2.js → SharePage-CgByqrAF.js} +1 -1
- package/apps/web/dist/assets/{api-DijQGkp-.js → api-KMi35npD.js} +1 -1
- package/apps/web/dist/assets/changelog-03JgixQA.js +1 -0
- package/apps/web/dist/assets/index-B9YVjvVY.css +1 -0
- package/apps/web/dist/assets/index-BmpnE7IO.js +10 -0
- package/apps/web/dist/assets/meta-4R1Lnr25.js +1 -0
- package/apps/web/dist/assets/oss-credits-roB62QJu.js +1 -0
- package/apps/web/dist/assets/{outputs-37WFkpRS.js → outputs-COE_nvAw.js} +1 -1
- package/apps/web/dist/assets/plug-CLjyCoHB.js +1 -0
- package/apps/web/dist/assets/{session-BerOchdC.js → session-B6-6VomQ.js} +1 -1
- package/apps/web/dist/assets/type-Bj9H3eOK.js +1 -0
- package/apps/web/dist/assets/ui-Cs6lpsmj.js +1 -0
- package/apps/web/dist/index.html +6 -5
- package/apps/web/dist/mcp/flow.html +748 -0
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/use-wizard/SKILL.md +18 -0
- package/apps/web/dist/assets/ChatPanel-aQP8iz10.js +0 -1
- package/apps/web/dist/assets/EditorPage-xkq6pvw-.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-TwYgdbKl.js +0 -2
- package/apps/web/dist/assets/SettingsPage-C0_peJuV.js +0 -2
- package/apps/web/dist/assets/changelog-sa4SXBrg.js +0 -1
- package/apps/web/dist/assets/index-BAObuqzs.js +0 -10
- package/apps/web/dist/assets/index-BOl3401k.css +0 -1
- package/apps/web/dist/assets/meta-ijlGGCOr.js +0 -1
- package/apps/web/dist/assets/oss-credits-ClwxOPrf.js +0 -1
- package/apps/web/dist/assets/type-c_dt5Ne8.js +0 -1
- package/apps/web/dist/assets/ui-DKc92qJ1.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wizards",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"homepage": "https://engenty.ai",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@mastra/docker": "0.8.0",
|
|
36
36
|
"@mastra/mcp": "2.1.2",
|
|
37
37
|
"@modelcontextprotocol/client": "2.2.0",
|
|
38
|
+
"@modelcontextprotocol/ext-apps": "2.0.3",
|
|
38
39
|
"@modelcontextprotocol/server": "2.2.0",
|
|
39
40
|
"@turbodocx/html-to-docx": "1.23.1",
|
|
40
41
|
"ai": "7.0.102",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "engenty-wizards",
|
|
3
3
|
"displayName": "engenty wizards",
|
|
4
4
|
"version": "{{VERSION}}",
|
|
5
|
-
"description": "Build page-by-page AI wizards that people open on a shared link — designed, tested and published from Claude Code.",
|
|
5
|
+
"description": "Build page-by-page AI wizards that people open on a shared link — designed, tested and published from Claude Code — and run your published ones right in the chat.",
|
|
6
6
|
"author": { "name": "engenty" },
|
|
7
7
|
"homepage": "{{APP_URL}}",
|
|
8
8
|
"keywords": ["wizards", "forms", "ai-workflows", "mcp"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: use-wizard
|
|
3
|
+
description: Run one of the person's published engenty wizards here in the chat — a social post with an image, a research briefing, an offer, a video ad … page by page, with its review and its downloads. Use when the person wants something one of their wizards makes, names a wizard, or asks what their wizards can do.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Use an engenty wizard
|
|
7
|
+
|
|
8
|
+
You work with the `engenty-wizards` MCP tools. The person you talk to runs the wizard; their answers fill its pages.
|
|
9
|
+
|
|
10
|
+
1. **Find it.** `list_wizards` lists the person's wizards; only `published` ones run. `show_wizard` only when the person wants to see a wizard before running it: apps that show MCP Apps show it as it greets a person, with its flow one click away.
|
|
11
|
+
2. **Start it.** `run_wizard` straight away; apps that show MCP Apps show the wizard itself, page by page, and the person may answer there. What the person already said for the first page goes in with `answer_page`, using the field ids in `waitingFor`. Runs spend credits like any run of the wizard.
|
|
12
|
+
3. **Follow `waitingFor`.**
|
|
13
|
+
- `page`: ask for the fields with `inChat: true`, in the person's words, then `answer_page`. Fields with `inChat: false` (files, recordings, signatures, line items) need the run page: hand over `browserUrl`.
|
|
14
|
+
- `review`: show the outputs (texts, image links), then `review_step`: accept, or regenerate one with the person's note.
|
|
15
|
+
- `ask`: a step wants to change something in a connected account. Ask the person, then `answer_ask` with `allow` or `skip`. A sign-in happens on the run page (`browserUrl`).
|
|
16
|
+
- Nothing, status `running`: `get_run` with `waitSeconds: 45`, again until it changes.
|
|
17
|
+
4. **In a widget.** When the app shows the run as a widget, the person may answer there instead of in the chat. Call `get_run` before you ask again, so you never ask for a page that is already answered.
|
|
18
|
+
5. **Hand over.** When the status is `done`, give the outputs and their download links (valid one hour). `failed`: say what went wrong; `control_run` with `retry` tries the step again.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,d as i,i as a,n as o,nt as s}from"./api-DijQGkp-.js";import{t as c}from"./createLucideIcon-q3MZMmnf.js";import{S as l,g as u,h as d,r as f,v as p}from"./outputs-37WFkpRS.js";import{r as m}from"./wand-sparkles-CKxArWPY.js";import{t as h}from"./plus-Du-Jx8aI.js";import{t as g}from"./mic-Bvz4mA2j.js";import{_,d as v,h as y,o as b,y as x}from"./ui-DKc92qJ1.js";import{l as S,u as C}from"./index-BAObuqzs.js";var w={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};w.node;var T=c(w),E=e(t(),1),D=!1;function O(){if(!(typeof window>`u`||D))return window.SpeechRecognition??window.webkitSpeechRecognition}var k=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`;function A(e,t){let n=e.trimEnd(),r=t.trim();return n&&r?`${n} ${r}`:n||r}function j(e,t){let[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),l=(0,E.useRef)(e);l.current=e;let u=(0,E.useRef)(t);u.current=t;let d=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>d.current?.stop(),[]);let f=async()=>{let e=l.current,t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{c(`denied`);return}let n=[],i=new MediaRecorder(t);i.ondataavailable=e=>e.data.size&&n.push(e.data),i.onstop=async()=>{for(let e of t.getTracks())e.stop();d.current=null,r(!1);let s=(i.mimeType||`audio/webm`).split(`;`)[0],l=new File(n,`dictation`,{type:s});if(l.size){a(!0);try{let{text:t}=await o.upload(`/api/studio/transcribe`,l);t.trim()&&u.current(A(e,t))}catch(e){c(e.message)}finally{a(!1)}}},d.current={stop:()=>i.state!==`inactive`&&i.stop()},i.start(),r(!0)},p=e=>{let t=l.current,n=``,i=new e;i.continuous=!0,i.interimResults=!0,i.lang=_===`de`?`de-DE`:`en-US`,i.onresult=e=>{let r=``;for(let t=Math.max(0,e.resultIndex);t<e.results.length;t++){let i=e.results[t],a=i[0]?.transcript??``;i.isFinal?n=A(n,a):r+=a}u.current(A(t,A(n,r)))},i.onerror=e=>{if(e.error!==`aborted`&&e.error!==`no-speech`){if(e.error===`not-allowed`){c(`denied`);return}D=!0,k&&!n?(i.onend=null,d.current=null,f()):c(e.error)}},i.onend=()=>{d.current=null,r(!1)},d.current={stop:()=>i.stop()},i.start(),r(!0)};return{supported:!!O()||k,listening:n,processing:i,error:s,toggle:()=>{if(i)return;if(d.current){d.current.stop();return}c(null);let e=O();e?p(e):f()}}}var M=e(n(),1),N=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function P(e){let t=e.filter(e=>e.type.startsWith(`image/`));return t.length?Object.fromEntries(t.map(e=>[e.name,URL.createObjectURL(e)])):void 0}function F(e){let t=e.match(/(?:^|\n\n)(?:Angehängt|Attached): ([^\n]+)$/);return t?{text:e.slice(0,t.index).trim(),names:t[1].split(`, `).filter(Boolean)}:{text:e,names:[]}}function I(e,t){if(e.name&&e.name!==`image.png`)return e;let n=e.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`,r=new Date().toISOString().slice(0,19).replace(/[-:]/g,``).replace(`T`,`-`);return new File([e],`paste-${r}${t?`-${t+1}`:``}.${n}`,{type:e.type})}function L({url:e,label:t,children:n}){return(0,M.jsxs)(`div`,{className:`group relative`,title:t,children:[(0,M.jsx)(`img`,{src:e,alt:t,width:64,height:64,className:`size-16 rounded-lg bg-paper-2 object-cover ring-1 ring-border`}),n]})}function R({names:e,previews:t,fileUrl:n}){let r=e.filter(e=>t?.[e]||n&&N.test(e)),i=e.filter(e=>!r.includes(e));return(0,M.jsxs)(`div`,{className:`flex flex-col items-end gap-1.5`,children:[r.map(e=>{let r=t?.[e]??n?.(e)??``;return(0,M.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,title:e,children:(0,M.jsx)(`img`,{src:r,alt:e,className:`max-h-60 w-auto max-w-full rounded-xl bg-paper-2 object-contain ring-1 ring-border`})},e)}),i.length?(0,M.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:i.map(e=>(0,M.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 px-2.5 py-1 text-[12px] text-ink-2`,children:[(0,M.jsx)(p,{className:`size-3 shrink-0 text-ink-4`}),(0,M.jsx)(`span`,{className:`truncate`,children:e})]},e))}):null]})}function z(e,t){let n=s(),[i,o]=(0,E.useState)([]),[c,l]=(0,E.useState)(`idle`),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)(null),[g,_]=(0,E.useState)(null),v=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(e){if(v.current!==e.id){v.current=e.id,o(e.messages);return}c===`idle`&&o(t=>e.messages.length>=t.length?e.messages:t)}},[e,c]),{messages:i,phase:c,activity:f,thought:m,startedAt:g,error:u,send:async(i,s=[])=>{if(!e||!(i.trim()||s.length)||c!==`idle`)return!1;if(d(null),_(Date.now()),h(null),s.length){l(`thinking`);try{for(let t of s){let n=await fetch(r(`/api/studio/wizards/${e.id}/files/${encodeURIComponent(t.name)}`),{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`},body:t});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}}catch(t){return d(t.message),l(`idle`),_(null),await n.invalidateQueries({queryKey:[`wizard`,e.id]}),!1}let t=`${x(`editor.attached`)}: ${s.map(e=>e.name).join(`, `)}`;i=i.trim()?`${i}\n\n${t}`:t}let u=`p-${Date.now()}`;o(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:i,previews:P(s)},{id:u,role:`assistant`,content:``,pending:!0}]),l(`thinking`),p(null);let f=!1;try{await a(`/api/studio/wizards/${e.id}/chat`,{message:i},(e,n)=>{if(e===`text`){let e=JSON.parse(n);o(t=>t.map(t=>t.id===u?{...t,content:t.content+e}:t))}else if(e===`activity`)p(JSON.parse(n));else if(e===`thought`)h(JSON.parse(n));else if(e===`building`)l(`building`);else if(e===`done`){f=!0;let e=JSON.parse(n);o(t=>t.map(t=>t.id===u?{...t,content:e.reply,changed:e.changed,pending:!1}:t)),e.changed&&t(e.draft,e.revision)}else e===`error`&&(f=!0,d(JSON.parse(n).message))}),f||d(x(`editor.chatBroken`))}catch(e){d(e.message)}finally{p(null),h(null),_(null),o(e=>e.filter(e=>!(e.id===u&&!e.content)).map(e=>({...e,pending:!1}))),l(`idle`),await n.invalidateQueries({queryKey:[`wizard`,e.id]}),await n.invalidateQueries({queryKey:[`me`]})}return!0},fileUrl:t=>r(`/api/studio/wizards/${e?.id}/files/${encodeURIComponent(t)}`)}}function B(e){let[t,n]=(0,E.useState)(()=>Date.now());return(0,E.useEffect)(()=>{if(e===null)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),e===null?null:Math.max(0,Math.floor((t-e)/1e3))}function V(e){return e<60?`${e} s`:`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)} min`}function H({chat:e,thought:t,className:n,spinner:r=`size-3.5`}){let i=B(e.startedAt);return(0,M.jsxs)(`div`,{className:y(`min-w-0`,n),children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(v,{className:y(`shrink-0`,r)}),(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.activity??(e.phase===`building`?x(`editor.building`):x(`editor.thinking`))}),i===null?null:(0,M.jsx)(`span`,{className:`shrink-0 text-ink-4 tabular-nums`,children:V(i)})]}),t&&e.thought?(0,M.jsx)(`p`,{className:`mt-0.5 truncate pl-5.5 text-[12px] text-ink-4`,children:e.thought}):null]})}function U({message:e,fileUrl:t}){let{text:n,names:r}=F(e.content);return(0,M.jsxs)(`div`,{className:`ml-8 flex flex-col items-end gap-1.5 self-end`,children:[r.length?(0,M.jsx)(R,{names:r,previews:e.previews,fileUrl:t}):null,n?(0,M.jsx)(`div`,{className:`rounded-xl rounded-br-md bg-paper-2 px-4 py-2.5 text-[14px] leading-relaxed`,children:(0,M.jsx)(`span`,{className:`whitespace-pre-wrap`,children:n})}):null]})}function W({chat:e,avatar:t,hello:n=x(`editor.chatHello`),placeholder:r=x(`editor.composer`),changedLabel:a=`Ablauf aktualisiert`,compact:o,intro:s}){let[c,_]=(0,E.useState)(!1),[w,D]=(0,E.useState)(``),[O,k]=(0,E.useState)([]),A=(0,E.useRef)(null),N=(0,E.useRef)(null),P=(0,E.useRef)(null),F=j(w,D);(0,E.useEffect)(()=>{A.current?.scrollTo({top:A.current.scrollHeight,behavior:`smooth`})},[e.messages,e.phase]),(0,E.useEffect)(()=>{let e=N.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[w]);let R=(w.trim()||O.length>0)&&e.phase===`idle`,z=e=>k(t=>[...t.filter(t=>!e.some(e=>e.name===t.name)),...e]),[B,V]=(0,E.useState)(new Map);(0,E.useEffect)(()=>{let e=new Map(O.filter(e=>e.type.startsWith(`image/`)).map(e=>[e,URL.createObjectURL(e)]));return V(e),()=>{for(let t of e.values())URL.revokeObjectURL(t)}},[O]);let W=async()=>{if(!R)return;F.listening&&F.toggle();let t={text:w,files:O};D(``),k([]),await e.send(t.text.trim(),t.files)||(D(t.text),k(t.files))},G=!o||c,K=e.messages.at(-1);return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[o&&(K||e.error)?(0,M.jsxs)(`button`,{type:`button`,"aria-expanded":c,"aria-label":x(`editor.thread`),onClick:()=>_(e=>!e),className:`flex items-center gap-2 px-4 pt-2.5 pb-0.5 text-left text-[13px] text-ink-3 transition hover:text-ink`,children:[!(e.error||c)&&K?.pending?(0,M.jsx)(H,{chat:e,className:`flex-1`}):(0,M.jsx)(`span`,{className:y(`min-w-0 flex-1 truncate`,e.error&&`text-rose`),children:e.error??(c?x(`editor.thread`):K?.content)}),c?(0,M.jsx)(m,{className:`size-4 shrink-0`}):(0,M.jsx)(T,{className:`size-4 shrink-0`})]}):null,(0,M.jsxs)(`div`,{ref:A,className:y(`min-h-0 flex-1 overflow-y-auto px-5 py-5`,!G&&`hidden`),children:[e.messages.length===0?s??(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(i,{kind:t,size:32,interactive:!1}),(0,M.jsx)(`p`,{className:`pt-1 text-[14px] text-ink-2 leading-relaxed`,children:n})]}):null,(0,M.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.messages.map(n=>n.role===`user`?(0,M.jsx)(U,{message:n,fileUrl:e.fileUrl},n.id):(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`div`,{className:`shrink-0`,children:(0,M.jsx)(i,{kind:t,size:28,interactive:!1})}),(0,M.jsxs)(`div`,{className:`min-w-0 pt-0.5 text-[14px]`,children:[n.source===`mcp`?(0,M.jsxs)(`div`,{className:`mb-1 inline-flex items-center gap-1.5 text-[12px] text-ink-3`,children:[(0,M.jsx)(C,{className:`size-3`}),` `,x(`editor.viaClient`,{client:n.client??`MCP`})]}):null,n.content?(0,M.jsx)(f,{text:n.content,className:`text-[14px]`}):null,n.pending?(0,M.jsx)(H,{chat:e,thought:!0,className:`mt-1 text-[13px] text-ink-3`}):null,n.changed?(0,M.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-full bg-ember-tint px-2.5 py-0.5 text-[12px] text-ember-strong`,children:[(0,M.jsx)(u,{className:`size-3`}),` `,a]}):null]})]},n.id))}),e.error?(0,M.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-3 py-2 text-[13px] text-rose`,children:e.error}):null]}),(0,M.jsxs)(`div`,{className:o?`p-2`:`p-3`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border focus-within:ring-focus`,children:[B.size?(0,M.jsx)(`div`,{className:`flex flex-wrap gap-2 px-1 pt-1 pb-1.5`,children:O.map((e,t)=>{let n=B.get(e);return n?(0,M.jsx)(L,{url:n,label:e.name,children:(0,M.jsx)(`button`,{type:`button`,"aria-label":x(`editor.detach`),onClick:()=>k(e=>e.filter((e,n)=>n!==t)),className:`-top-1.5 -right-1.5 absolute flex size-5 items-center justify-center rounded-full bg-ink text-paper opacity-0 shadow-soft transition focus-visible:opacity-100 group-hover:opacity-100`,children:(0,M.jsx)(S,{className:`size-3`})})},`${e.name}-${t}`):null})}):null,O.some(e=>!B.has(e))?(0,M.jsx)(`ul`,{className:`flex flex-wrap gap-1.5 px-1 pt-1 pb-1.5`,children:O.map((e,t)=>B.has(e)?null:(0,M.jsxs)(`li`,{className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-paper-2 py-1 pr-1 pl-2.5 text-[12px] text-ink-2`,children:[(0,M.jsx)(p,{className:`size-3 shrink-0 text-ink-4`}),(0,M.jsx)(`span`,{className:`truncate`,children:e.name}),(0,M.jsx)(`button`,{type:`button`,"aria-label":x(`editor.detach`),onClick:()=>k(e=>e.filter((e,n)=>n!==t)),className:`inline-flex size-5 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-paper-3 hover:text-ink`,children:(0,M.jsx)(S,{className:`size-3`})})]},`${e.name}-${t}`))}):null,(0,M.jsxs)(`div`,{className:`flex items-end gap-1`,children:[(0,M.jsx)(b,{label:x(`editor.attach`),onClick:()=>P.current?.click(),children:(0,M.jsx)(h,{className:`size-4`})}),(0,M.jsx)(`input`,{ref:P,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,z(t)}}),(0,M.jsx)(`textarea`,{ref:N,rows:1,value:w,onChange:e=>D(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&(e.preventDefault(),z(t.map(I)))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),W())},placeholder:F.listening?x(`editor.listening`):r,className:`max-h-[200px] min-h-[40px] flex-1 resize-none bg-transparent px-1.5 py-2 text-[14px] outline-none placeholder:text-ink-4`}),F.supported?(0,M.jsx)(b,{label:F.processing?x(`editor.transcribing`):F.listening?x(`editor.voiceStop`):x(`editor.voice`),"aria-pressed":F.listening,disabled:F.processing,onClick:F.toggle,className:y(F.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:F.processing?(0,M.jsx)(v,{className:`size-4`}):F.listening?(0,M.jsx)(d,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,M.jsx)(g,{className:`size-4`})}):null,(0,M.jsx)(`button`,{type:`button`,onClick:()=>void W(),disabled:!R,className:y(`inline-flex size-9 shrink-0 items-center justify-center rounded-full transition`,R?`bg-primary text-primary-foreground`:`bg-paper-2 text-ink-4`),"aria-label":`Send`,children:(0,M.jsx)(l,{className:`size-4`})})]})]}),F.error?(0,M.jsx)(`p`,{className:`mt-2 px-1 text-[12px] text-rose`,children:F.error===`denied`?x(`editor.micDenied`):F.error}):null]})]})}export{z as i,H as n,P as r,W as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{A as r,O as i,a,c as o,d as s,j as c,k as l,n as u,nt as d,t as f}from"./api-DijQGkp-.js";import{c as p,s as m}from"./session-BerOchdC.js";import{t as h}from"./createLucideIcon-q3MZMmnf.js";import{n as g,r as _,t as v}from"./RunnerView-XKosfgO-.js";import{t as y}from"./arrow-left-hTN1VoH1.js";import{S as b,m as x,n as S}from"./outputs-37WFkpRS.js";import{a as C,i as ee,n as w,r as T,s as E,t as te}from"./meta-ijlGGCOr.js";import{t as ne}from"./check-CUpby_J9.js";import{r as re,t as ie}from"./wand-sparkles-CKxArWPY.js";import{i as ae,n as oe,t as se}from"./ChatPanel-aQP8iz10.js";import{n as ce,t as D}from"./plus-Du-Jx8aI.js";import{t as le}from"./external-link-MAL7vJYj.js";import{n as O}from"./mic-Bvz4mA2j.js";import{c as ue,i as de,l as fe,n as k,o as pe,p as me,r as A,s as j,t as M}from"./definition-DndaH5Ow.js";import{t as N}from"./upload--J5bZhEM.js";import{_ as he,a as ge,c as P,d as _e,h as F,i as ve,l as I,m as L,o as R,p as z,r as B,s as V,t as H,u as U,y as W}from"./ui-DKc92qJ1.js";import{c as ye,f as be,l as xe,n as Se,t as Ce,u as we}from"./index-BAObuqzs.js";import{a as Te,c as Ee,i as De,l as Oe,o as ke,r as Ae,s as je,t as Me}from"./esm-rJY59Ixx.js";import{r as Ne}from"./LocalRuntime-DPJMJlWc.js";var Pe={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};Pe.node;var Fe=h(Pe),Ie={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ie.node;var Le=h(Ie),Re={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Re.node;var ze=h(Re),Be={name:`cloud-upload`,size:24,node:[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]],aliases:[`upload-cloud`]};Be.node;var Ve=h(Be),He={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};He.node;var Ue=h(He),We={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};We.node;var Ge=h(We),Ke={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};Ke.node;var qe=h(Ke),Je={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Je.node;var Ye=h(Je),Xe={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Xe.node;var Ze=h(Xe),Qe={name:`scan`,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`}]]};Qe.node;var $e=h(Qe),G=e(t(),1),K=e(n(),1);function et(e){return e.mime.startsWith(`image/`)?E:e.mime.includes(`json`)?Ue:e.mime===`text/html`||e.mime.includes(`javascript`)||e.mime===`text/css`?Ge:O}function tt(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function nt({wizardId:e,files:t}){let n=d(),r=(0,G.useRef)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(null),f=`/api/studio/wizards/${e}/files`,p=()=>n.invalidateQueries({queryKey:[`wizard`,e]}),m=async e=>{if(e?.length){a(!0),l(null);try{for(let t of Array.from(e)){let e=await fetch(`${f}/${encodeURIComponent(t.name).replace(/%2F/g,`/`)}`,{method:`PUT`,credentials:`include`,headers:{"content-type":t.type||`application/octet-stream`},body:t});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??e.statusText)}}}catch(e){l(e.message)}finally{a(!1),await p()}}},h=async e=>{window.confirm(W(`files.confirmDelete`,{path:e}))&&(await u.del(`${f}/${e}`),await p())},g=t.reduce((e,t)=>e+t.size,0);return(0,K.jsxs)(`div`,{className:F(`flex min-h-full flex-col px-5 py-5`,o&&`bg-ember-veil`),onDragOver:e=>{e.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:e=>{e.preventDefault(),s(!1),m(e.dataTransfer.files)},children:[(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3 leading-relaxed`,children:W(`files.explain`)}),(0,K.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r.current?.click(),className:`inline-flex h-9 items-center gap-1.5 rounded-full bg-paper-2 px-3.5 font-medium text-[13px] text-ink-2 hover:bg-paper-3 hover:text-ink`,children:[i?(0,K.jsx)(_e,{className:`size-3.5`}):(0,K.jsx)(N,{className:`size-3.5`}),W(`files.upload`)]}),(0,K.jsx)(`span`,{className:`ml-auto text-[12px] text-ink-4`,children:W(`files.count`,{n:t.length,size:tt(g)})}),(0,K.jsx)(`input`,{ref:r,type:`file`,multiple:!0,hidden:!0,onChange:e=>void m(e.target.files)})]}),c?(0,K.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-3 py-2 text-[13px] text-rose`,children:c}):null,(0,K.jsx)(`ul`,{className:`mt-4 flex flex-col`,children:t.map(e=>{let t=et(e);return(0,K.jsxs)(`li`,{className:`group flex items-center gap-3 rounded-lg px-2 py-1.5 hover:bg-paper-2`,children:[(0,K.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px]`,children:e.path}),(0,K.jsx)(`span`,{className:`text-[12px] text-ink-4 tabular-nums`,children:tt(e.size)}),(0,K.jsx)(`a`,{href:`${f}/${e.path}`,className:`inline-flex size-8 items-center justify-center rounded-full text-ink-3 opacity-0 hover:text-ink group-hover:opacity-100`,"aria-label":W(`files.download`),children:(0,K.jsx)(be,{className:`size-4`})}),(0,K.jsx)(R,{label:W(`files.delete`),className:`opacity-0 hover:text-rose group-hover:opacity-100`,onClick:()=>void h(e.path),children:(0,K.jsx)(x,{className:`size-4`})})]},e.path)})}),t.length===0?(0,K.jsx)(`div`,{className:`mt-6 rounded-xl border border-border border-dashed px-4 py-8 text-center text-[13px] text-ink-4`,children:W(`files.empty`)}):null]})}var rt=Object.defineProperty,it=(e,t,n)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,at=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},ot=(e,t,n)=>it(e,typeof t==`symbol`?t:t+``,n),st={};at(st,{Graph:()=>q,alg:()=>bt});var ct=Object.defineProperty,lt=(e,t)=>{for(var n in t)ct(e,n,{get:t[n],enumerable:!0})},ut=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=pt(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=mt(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,dt(this._preds[a],i),dt(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?ht(this._isDirected,e):pt(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?ht(this._isDirected,e):pt(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?ht(this._isDirected,e):pt(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],ft(this._preds[t],e),ft(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function dt(e,t){e[t]?e[t]++:e[t]=1}function ft(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function pt(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function mt(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function ht(e,t){return pt(e,t.v,t.w,t.name)}lt({},{read:()=>yt,write:()=>gt});function gt(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:_t(e),edges:vt(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function _t(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function vt(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function yt(e){let t=new ut(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var bt={};lt(bt,{CycleException:()=>Ft,bellmanFord:()=>St,components:()=>wt,dijkstra:()=>Dt,dijkstraAll:()=>kt,findCycles:()=>jt,floydWarshall:()=>Nt,isAcyclic:()=>Lt,postorder:()=>Vt,preorder:()=>Ht,prim:()=>Ut,shortestPaths:()=>Wt,tarjan:()=>At,topsort:()=>It});var xt=()=>1;function St(e,t,n,r){return Ct(e,String(t),n||xt,r||function(t){return e.outEdges(t)??[]})}function Ct(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function wt(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var Tt=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},Et=()=>1;function Dt(e,t,n,r){return Ot(e,String(t),n||Et,r||function(t){return e.outEdges(t)??[]})}function Ot(e,t,n,r){let i={},a=new Tt,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function kt(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=Dt(e,i,t,n),r},{})}function At(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function jt(e){return At(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var Mt=()=>1;function Nt(e,t,n){return Pt(e,t||Mt,n||function(t){return e.outEdges(t)??[]})}function Pt(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var Ft=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function It(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new Ft;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new Ft;return r}function Lt(e){try{It(e)}catch(e){if(e instanceof Ft)return!1;throw e}return!0}function Rt(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=zt(e,t,n===`post`,o,a,r,i)}),i}function zt(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=zt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function Bt(e,t,n){return Rt(e,t,n,function(e,t){return e.push(t),e},[])}function Vt(e,t){return Bt(e,t,`post`)}function Ht(e,t){return Bt(e,t,`pre`)}function Ut(e,t){var n;let r=new ut,i={},a=new Tt,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function Wt(e,t,n,r){return Gt(e,t,n,r??(t=>e.outEdges(t)??[]))}function Gt(e,t,n,r){if(n===void 0)return Dt(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return St(e,t,n,r)}return Dt(e,t,n,r)}var q=ut;function J(e,t,n,r){let i=r;for(;e.hasNode(i);)i=sn(r);return n.dummy=t,e.setNode(i,n),i}function Kt(e){let t=new q().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function qt(e){let t=new q({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Jt(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function Yt(e){let t=cn(tn(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Xt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Y(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Zt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Y(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Qt(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),J(e,`border`,i,t)}function $t(e,t=en){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var en=65535;function Y(e,t){return t.length>en?e(...$t(t).map(t=>e(...t))):e(...t)}function tn(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Y(Math.max,t)}function nn(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function rn(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function an(e,t){return t()}var on=0;function sn(e){return e+(``+ ++on)}function cn(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function ln(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function un(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function dn(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var fn=`\0`;function pn(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var mn=`3.1.1`,hn=class{constructor(){ot(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return gn(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&gn(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,_n)),n=n._prev;return`[`+e.join(`, `)+`]`}};function gn(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function _n(e,t){if(e!==`_next`&&e!==`_prev`)return t}var vn=hn,yn=()=>1;function bn(e,t){if(e.nodeCount()<=1)return[];let n=Cn(e,t||yn);return xn(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function xn(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Sn(e,t,n,o);for(;o=i.dequeue();)Sn(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Sn(e,t,n,o,!0)||[]);break}}}return r}function Sn(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,wn(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,wn(t,n,o)}),e.removeNode(r.v),o}function Cn(e,t){let n=new q,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Tn(i+r+3).map(()=>new vn),o=r+1;return n.nodes().forEach(e=>{wn(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function wn(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Tn(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function En(e,t){(e.graph().acyclicer===`greedy`?bn(e,n(e)):Dn(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,sn(`rev`))});function n(e){return t=>e.edge(t).weight}}function Dn(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&kn(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function On(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function kn(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function An(e){e.graph().dummyChains=[],e.edges().forEach(t=>jn(e,t))}function jn(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=J(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Mn(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Nn(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Y(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function X(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Pn=Fn;function Fn(e){let t=new q({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;In(t,e)<i&&(a=Ln(t,e),a);)o=t.hasNode(a.v)?X(e,a):-X(e,a),Rn(t,e,o);return t}function In(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!X(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Ln(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=X(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Rn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:zn,postorder:Bn}=bt,Vn=Z;Z.initLowLimValues=Gn,Z.initCutValues=Hn,Z.calcCutValue=Wn,Z.leaveEdge=qn,Z.enterEdge=Jn,Z.exchangeEdges=Yn;function Z(e){e=Kt(e),Nn(e);let t=Pn(e);Gn(t),Hn(t,e);let n,r;for(;n=qn(t);)r=Jn(t,e,n),Yn(t,e,n,r)}function Hn(e,t){let n=Bn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Un(e,t,n))}function Un(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=Wn(e,t,n)}function Wn(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Zn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Gn(e,t){arguments.length<2&&(t=e.nodes()[0]),Kn(e,{},1,t)}function Kn(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Kn(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function qn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Jn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===Qn(e,e.node(t.v),s)&&c!==Qn(e,e.node(t.w),s)).reduce((e,n)=>X(t,n)<X(t,e)?n:e)}function Yn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Gn(e),Hn(e,t),Xn(e,t)}function Xn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=zn(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Zn(e,t,n){return e.hasEdge(t,n)}function Qn(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var $n=er;function er(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:rr(e);break;case`tight-tree`:nr(e);break;case`longest-path`:tr(e);break;case`none`:break;default:rr(e)}}var tr=Nn;function nr(e){Nn(e),Pn(e)}function rr(e){Vn(e)}var ir=ar;function ar(e){let t=sr(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=or(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function or(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function sr(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(fn).forEach(r),t}function cr(e){let t=J(e,`root`,{},`_root`),n=ur(e),r=Object.values(n),i=Y(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=dr(e)+1;e.children(fn).forEach(r=>{lr(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function lr(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Qt(e,`_bt`),l=Qt(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{lr(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function ur(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(fn).forEach(e=>n(e,1)),t}function dr(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function fr(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var pr=mr;function mr(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)hr(e,`borderLeft`,`_bl`,n,i,t),hr(e,`borderRight`,`_br`,n,i,t)}}e.children(fn).forEach(t)}function hr(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=J(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function gr(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&vr(e)}function _r(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&br(e),(t===`lr`||t===`rl`)&&(Sr(e),vr(e))}function vr(e){e.nodes().forEach(t=>yr(e.node(t))),e.edges().forEach(t=>yr(e.edge(t)))}function yr(e){let t=e.width;e.width=e.height,e.height=t}function br(e){e.nodes().forEach(t=>xr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(xr),Object.hasOwn(r,`y`)&&xr(r)})}function xr(e){e.y=-e.y}function Sr(e){e.nodes().forEach(t=>Cr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Cr),Object.hasOwn(r,`x`)&&Cr(r)})}function Cr(e){let t=e.x;e.x=e.y,e.y=t}function wr(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=cn(Y(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return pn(t,e.node(n),e.node(r))}return a}function Tr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Er(e,t[r-1],t[r]);return n}function Er(e,t,n){let r=dn(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function Dr(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Or(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),kr(Object.values(n).filter(e=>!e.indegree))}function kr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Ar(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>ln(e,[`vs`,`i`,`barycenter`,`weight`]))}function Ar(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function jr(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=nn(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(Nr(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=Mr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=Mr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function Mr(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Nr(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=pn(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function Pr(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=Dr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Pr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Ir(t,r)}});let h=Or(m,n);Fr(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]=h[n],h.splice(n,1),n--}else _=!0}let v=jr(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function Fr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Ir(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function Lr(e,t,n,r){r||=e.nodes();let i=Rr(e),a=new q({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function Rr(e){let t;for(;e.hasNode(t=sn(`_root`)););return t}function zr(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function Br(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Br);return}let r=tn(e),i=Vr(e,cn(1,r+1),`inEdges`),a=Vr(e,cn(r-1,-1,-1),`outEdges`),o=wr(e,n);if(Ur(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Hr(t%2?i:a,t%4>=2,l,n),o=Yt(e);let u=Tr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Ur(e,c)}function Vr(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return Lr(e,t,n,r.get(t)||[])})}function Hr(e,t,n,r){let i=!0,a=new q;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Pr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),zr(e,a,s.vs)})}function Ur(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Wr(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Kr(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&qr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Gr(e,t){let n={};function r(t,r,i,a,o){cn(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&qr(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Kr(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function qr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Jr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Yr(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||ii(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>ii(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!Jr(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function Xr(e,t,n,r,i=!1){let a={},o=Zr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Zr(e,t,n,r){let i=new q,a=e.graph(),o=ni(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function Qr(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=ri(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function $r(e,t){let n=Object.values(t),r=Y(Math.min,n),i=Y(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Y(Math.min,c);a!==`l`&&(l=i-Y(Math.max,c)),l&&(e[o]=un(s,e=>e+l))})})}function ei(e,t=void 0){let n=e.ul;return n?un(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function ti(e,t){let n=Yt(e),r=Object.assign(Wr(e,n),Gr(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=Yr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Xr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=un(c,e=>-e)),i[o+n]=c})}),$r(i,Qr(e,i)),ei(i,e.graph().align)}function ni(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function ri(e,t){return e.node(t).width}function ii(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function ai(e,t){e=qt(e),oi(e),Object.entries(ti(e,t)).forEach(([t,n])=>e.node(t).x=n)}function oi(e){let t=Yt(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var si=new WeakMap;function ci(e,t={}){return ui(e,an,t),e}function li(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function ui(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new q({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=li(e,t.v,r),i=li(e,t.w,r);if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),ui(o,t,n);let l=xi(o);di(l,t,n,null),fi(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),(!isFinite(u)||!isFinite(d)||!isFinite(f)||!isFinite(p))&&(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=xi(e),g=di(h,t,n,si.get(e)??null);si.set(e,g),fi(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),delete n._dagreClusterSubgraph}})}function di(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>Si(e)),t(` removeSelfEdges`,()=>ji(e)),t(` acyclic`,()=>En(e,s)),t(` nestingGraph.run`,()=>cr(e)),t(` rank`,()=>$n(qt(e))),t(` injectEdgeLabelProxies`,()=>Ci(e)),t(` removeEmptyRanks`,()=>Zt(e)),t(` nestingGraph.cleanup`,()=>fr(e)),t(` normalizeRanks`,()=>Xt(e)),t(` assignRankMinMax`,()=>wi(e)),t(` removeEdgeLabelProxies`,()=>Ti(e)),t(` normalize.run`,()=>An(e)),t(` parentDummyChains`,()=>ir(e)),t(` addBorderSegments`,()=>pr(e)),t(` order`,()=>Br(e,n,c)),t(` insertSelfEdges`,()=>Mi(e)),t(` adjustCoordinateSystem`,()=>gr(e)),t(` position`,()=>ai(e,n.corePath)),t(` positionSelfEdges`,()=>Ni(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>Ai(e)),t(` normalize.undo`,()=>Mn(e)),t(` fixupEdgeLabelCoords`,()=>Oi(e)),t(` undoCoordinateSystem`,()=>_r(e)),t(` translateGraph`,()=>Ei(e)),t(` assignNodeIntersects`,()=>Di(e)),t(` reversePoints`,()=>ki(e)),t(` acyclic.undo`,()=>On(e)),{graph:e,rawNodes:l}}function fi(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var pi=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],mi={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},hi=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],gi=[`width`,`height`,`rank`],_i={width:0,height:0},vi=[`minlen`,`weight`,`width`,`height`,`labeloffset`],yi={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},bi=[`labelpos`];function xi(e){let t=new q({multigraph:!0,compound:!0}),n=Fi(e.graph());return t.setGraph(Object.assign({},mi,Pi(n,pi),ln(n,hi))),e.nodes().forEach(n=>{let r=Pi(Fi(e.node(n)),gi);Object.keys(_i).forEach(e=>{r[e]===void 0&&(r[e]=_i[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Fi(e.edge(n));t.setEdge(n,Object.assign({},yi,Pi(r,vi),ln(r,bi)))}),t}function Si(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Ci(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);J(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function wi(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Ti(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Ei(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function Di(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Jt(r,a)),n.points.push(Jt(i,o))})}function Oi(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function ki(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ai(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function ji(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Mi(e){Yt(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{J(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),(!Array.isArray(t.label.points)||t.label.points.length!==7)&&(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function Ni(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function Pi(e,t){return un(ln(e,t),Number)}function Fi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Ii(e){let t=Yt(e),n=new q({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var Li={graphlib:st,version:mn,layout:ci,debug:Ii,util:{time:rn,notime:an}};function Ri(e,t){let n=t.steps.map(e=>e.type===`agent`?`${e.id}:${e.model??``}:${e.tools.join(`+`)}:${e.output.format}`:e.type===`generate`?`${e.id}:${e.asset}:${e.model??``}:${e.options?.duration??``}`:e.id).join(`|`);return c({queryKey:[`estimate`,e,n],queryFn:()=>u.get(`/api/studio/wizards/${e}/estimate`),staleTime:3e4,refetchOnMount:`always`})}var zi=e=>e<10?e.toLocaleString(void 0,{maximumFractionDigits:1}):Math.round(e).toLocaleString();function Bi({estimate:e,stepId:t}){let n=e?.available?e.steps[t]:void 0;return n?(0,K.jsxs)(`p`,{className:`text-[12px] text-ink-3 tabular-nums`,children:[W(`estimate.step`,{n:zi(n.credits),high:zi(n.high)}),` · `,n.measured?W(`estimate.measured`):W(`estimate.formula`)]}):null}function Vi({model:e,effort:t,onChange:n}){let r=W(`class.effortAuto`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{children:W(`class.label`)}),(0,K.jsx)(U,{value:e??`high`,onChange:e=>n({model:e,effort:t}),options:pe.map(e=>({value:e,label:W(`class.${e}`)}))}),(0,K.jsx)(`p`,{className:`text-[12px] text-ink-3`,children:W(`class.${e??`high`}.hint`)}),(0,K.jsx)(P,{children:W(`class.effort`)}),(0,K.jsx)(I,{value:t?W(`class.effort.${t}`):r,options:[r,...k.map(e=>W(`class.effort.${e}`))],onChange:t=>n({model:e,effort:k.find(e=>W(`class.effort.${e}`)===t)})})]})}var Hi=280,Ui=92;function Wi({data:e}){let{step:t,selected:n,issue:r,active:i,pulse:a,cost:o}=e,s=w(t);return(0,K.jsxs)(`div`,{className:F(`relative w-[280px] cursor-pointer rounded-xl bg-card px-4 py-3 text-left shadow-soft ring-1 transition`,n?`shadow-elevated ring-2 ring-ember`:i?`ring-2 ring-moss`:a?`ring-2 ring-ember/60`:`ring-border-soft hover:shadow-elevated`),children:[i?(0,K.jsx)(`span`,{className:`-top-1 -right-1 absolute size-3 animate-breathe rounded-full bg-moss`}):a?(0,K.jsx)(`span`,{className:`-top-1 -right-1 absolute size-3 animate-breathe rounded-full bg-ember`}):null,(0,K.jsx)(Ae,{type:`target`,position:Ee.Top}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:F(`inline-flex size-6 items-center justify-center rounded-md`,te[t.type]),children:(0,K.jsx)(s,{className:`size-3.5`})}),(0,K.jsx)(`span`,{className:`font-medium text-[11px] text-ink-3 uppercase tracking-[0.07em]`,children:C(t)}),r?(0,K.jsx)(ze,{className:`ml-auto size-4 text-rose`}):o===null?null:(0,K.jsxs)(`span`,{className:`ml-auto text-[11px] text-ink-3 tabular-nums`,children:[`≈`,` `,o<10?o.toLocaleString(void 0,{maximumFractionDigits:1}):Math.round(o),` `,`cr`]})]}),(0,K.jsx)(`div`,{className:`mt-1.5 truncate font-display font-semibold text-[15px] text-ink`,children:t.title}),(0,K.jsx)(`div`,{className:`truncate text-[12px] text-ink-3`,children:T(t)||`\xA0`}),(0,K.jsx)(Ae,{type:`source`,position:Ee.Bottom})]})}function Gi({data:e}){return(0,K.jsxs)(`div`,{className:F(`flex w-[280px] cursor-pointer items-center gap-3 rounded-full bg-paper-2 py-1.5 pr-5 pl-2 transition`,e.selected?`ring-2 ring-ember`:`hover:bg-paper-3`),children:[(0,K.jsx)(s,{kind:e.avatar,size:40,interactive:!1}),(0,K.jsx)(`span`,{className:`truncate font-display font-semibold text-[15px]`,children:e.title}),(0,K.jsx)(Ae,{type:`source`,position:Ee.Bottom})]})}function Ki(e){let{data:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s}=e,c={label:e.label,labelStyle:e.labelStyle,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,markerEnd:e.markerEnd};if(!t?.points.length){let[e,t,l]=Oe({sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s});return(0,K.jsx)(Me,{path:e,labelX:t,labelY:l,...c})}let l=[{x:n,y:r},...t.points,{x:i,y:a}],u=l.map((e,t)=>{let n=l[t-1];if(!n)return`M ${e.x} ${e.y}`;let r=(n.y+e.y)/2;return`C ${n.x} ${r} ${e.x} ${r} ${e.x} ${e.y}`}).join(` `);return(0,K.jsx)(Me,{path:u,labelX:t.labelX,labelY:t.labelY,...c})}var qi={step:Wi,start:Gi},Ji={branch:Ki},Yi=34,Xi={};function Zi(e){let t=Array.isArray(e.when.value)?e.when.value.join(` / `):String(e.when.value??``);switch(e.when.op){case`equals`:return`${e.when.field} = ${t}`;case`notEquals`:return`${e.when.field} ≠ ${t}`;case`in`:return`${e.when.field} ∈ ${t}`;case`notEmpty`:return W(`editor.whenFilled`,{field:e.when.field});case`empty`:return W(`editor.whenEmpty`,{field:e.when.field})}}function Qi(e,t,n,r,i,a){let o=new Li.graphlib.Graph;o.setGraph({rankdir:`TB`,nodesep:48,ranksep:46,marginx:20,marginy:20}),o.setDefaultEdgeLabel(()=>({})),o.setNode(`__start`,{width:Hi,height:52});for(let t of e.steps)o.setNode(t.id,{width:Hi,height:Ui});let s=[],c={markerEnd:{type:je.ArrowClosed,width:14,height:14,color:`var(--ink-4)`}};e.steps[0]&&(o.setEdge(`__start`,e.steps[0].id),s.push({id:`e-start`,source:`__start`,target:e.steps[0].id,...c})),e.steps.forEach((t,n)=>{let r=e.steps[n+1],i=new Map;for(let n of t.next??[])n.goto!==`end`&&e.steps.some(e=>e.id===n.goto)&&i.set(n.goto,[...i.get(n.goto)??[],Zi(n)]);for(let[e,n]of i){let r=n.join(` · `),i=r.length>Yi?`${r.slice(0,33)}…`:r;o.setEdge(t.id,e,{width:i.length*6.2+16,height:22,labelpos:`c`}),s.push({id:`b-${t.id}-${e}`,type:`branch`,source:t.id,target:e,label:i,labelStyle:{fontSize:11,fill:`var(--ink-2)`},labelBgStyle:{fill:`var(--paper-2)`},labelBgPadding:[6,3],labelBgBorderRadius:8,style:{strokeDasharray:`5 4`},...c})}r&&t.type!==`result`&&(o.hasEdge(t.id,r.id)||o.setEdge(t.id,r.id),s.push({id:`n-${t.id}`,source:t.id,target:r.id,...t.next?.length?{label:W(`editor.otherwise`),labelStyle:{fontSize:11,fill:`var(--ink-3)`},labelBgStyle:{fill:`var(--background)`}}:{},...c}))}),Li.layout(o);for(let e of s){if(e.type!==`branch`)continue;let t=o.edge(e.source,e.target),n=(t.points??[]).slice(1,-1);n.length&&t.x!==void 0&&t.y!==void 0&&(e.data={points:n,labelX:t.x,labelY:t.y})}return{nodes:[{id:`__start`,type:`start`,position:{x:o.node(`__start`).x-Hi/2,y:o.node(`__start`).y-26},data:{title:e.title,avatar:e.avatar,selected:t===`__wizard`},draggable:!1},...e.steps.map((e,s)=>{let c=o.node(e.id);return{id:e.id,type:`step`,position:{x:c.x-Hi/2,y:c.y-Ui/2},data:{step:e,selected:t===e.id,issue:n.has(e.id),index:s,active:r===e.id,pulse:i.includes(e.id),cost:a[e.id]?.credits??null},draggable:!1}})],edges:s}}function $i(){let e=ke(),t=`inline-flex size-8 items-center justify-center rounded-full text-ink-3 hover:bg-accent hover:text-ink`;return(0,K.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 flex items-center gap-0.5 rounded-full bg-card p-1 shadow-soft ring-1 ring-border-soft`,children:[(0,K.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.zoomOut(),"aria-label":`Zoom out`,children:(0,K.jsx)(Ye,{className:`size-4`})}),(0,K.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.fitView({padding:.2,duration:300}),"aria-label":`Fit`,children:(0,K.jsx)($e,{className:`size-4`})}),(0,K.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.zoomIn(),"aria-label":`Zoom in`,children:(0,K.jsx)(D,{className:`size-4`})})]})}var ea=.8;function ta({def:e,selected:t,onSelect:n,issueSteps:r,activeStep:i,pulse:a,wizardId:o}){let s=Ri(o,e),c=s.data?.available?s.data.steps:Xi,{nodes:l,edges:u}=(0,G.useMemo)(()=>Qi(e,t,r,i,a??[],c),[e,t,r,i,a,c]),d=ke(),f=(0,G.useRef)(null),p=e.steps.map(e=>e.id).join(`|`);return(0,G.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=f.current;if(!e||!l.length)return;let t=l.map(e=>e.position.x),n=l.map(e=>e.position.y),r={x:Math.min(...t),y:Math.min(...n),width:Math.max(...t)+Hi-Math.min(...t),height:Math.max(...n)+Ui-Math.min(...n)},i=Math.min(e.clientWidth/(r.width*1.2),e.clientHeight/(r.height*1.15),1),a=Math.max(i,ea),o=(e.clientWidth-r.width*a)/2-r.x*a,s=i>=ea?(e.clientHeight-r.height*a)/2-r.y*a:24-r.y*a;d.setViewport({x:o,y:s,zoom:a},{duration:400})});return()=>cancelAnimationFrame(e)},[p,d]),(0,K.jsx)(`div`,{ref:f,className:`h-full w-full`,children:(0,K.jsx)(Te,{nodes:l,edges:u,nodeTypes:qi,edgeTypes:Ji,onNodeClick:(e,t)=>n(t.id===`__start`?`__wizard`:t.id),onPaneClick:()=>n(null),nodesConnectable:!1,nodesDraggable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnScroll:!1,zoomOnPinch:!0,minZoom:.3,maxZoom:1.4,proOptions:{hideAttribution:!0},children:(0,K.jsx)($i,{})})})}function na(e){return(0,K.jsx)(De,{children:(0,K.jsx)(ta,{...e})})}var ra={text:`Kurzer Text`,textarea:`Langer Text`,number:`Zahl`,select:`Auswahl`,multiselect:`Mehrfachauswahl`,date:`Datum`,email:`E-Mail`,url:`Link`,toggle:`Ja/Nein`,color:`Farbe`,image:`Bild-Upload`,file:`Datei-Upload`,items:`Positionen (Tabelle)`,connection:`Konto verbinden`,list:`Gespeicherte Liste`,location:`Standort`,audio:`Sprachnotiz`,signature:`Unterschrift`};function ia(e,t){let n=t===`image`||t===`file`;return{...e,kind:t,multiple:n?e.multiple:void 0,camera:t===`file`?e.camera:void 0,video:t===`file`?e.video:void 0,scan:t===`text`?e.scan:void 0}}function Q({title:e,children:t}){return(0,K.jsxs)(`div`,{className:`border-border-soft border-t px-5 py-5 first:border-t-0`,children:[e?(0,K.jsx)(`h4`,{className:`mb-3 font-medium text-[12px] text-ink-3 uppercase tracking-[0.07em]`,children:e}):null,(0,K.jsx)(`div`,{className:`flex flex-col gap-4`,children:t})]})}function aa(e,t){let n=new Set([...e.steps.map(e=>e.id),...e.steps.flatMap(e=>e.type===`page`?e.fields.map(e=>e.id):[])]),r=1,i=t;for(;n.has(i);)r+=1,i=`${t}${r}`;return i}function oa({def:e,field:t,onChange:n,onRemove:r,onMove:i}){let[a,o]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[14px]`,children:[t.label,t.required?(0,K.jsx)(`span`,{className:`ml-1 text-ember`,children:`*`}):null]}),(0,K.jsx)(`span`,{className:`text-[12px] text-ink-4`,children:ra[t.kind]}),(0,K.jsx)(re,{className:F(`size-4 text-ink-4 transition`,a&&`rotate-180`)})]}),a?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 border-border-soft border-t px-3 py-3`,children:[(0,K.jsx)(V,{value:t.label,onChange:e=>n({...t,label:e.target.value})}),(0,K.jsx)(U,{value:t.kind,onChange:e=>n(ia(t,e)),options:de.filter(e=>e!==`items`||t.kind===`items`).map(e=>({value:e,label:ra[e]}))}),t.kind===`select`||t.kind===`multiselect`?(0,K.jsx)(V,{placeholder:`Option A, Option B, Option C`,value:(t.options??[]).join(`, `),onChange:e=>n({...t,options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})}):null,t.kind===`connection`?(0,K.jsx)(U,{value:t.connection??``,placeholder:`Welches Konto?`,onChange:e=>n({...t,connection:e}),options:(e.connections??[]).map(e=>({value:e.id,label:e.title??e.id}))}):null,t.kind===`list`?(0,K.jsx)(U,{value:t.list??``,placeholder:`Welche Liste?`,onChange:e=>n({...t,list:e}),options:(e.lists??[]).map(e=>({value:e.id,label:e.title}))}):null,t.kind===`image`||t.kind===`file`?(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Mehrere Dateien`}),(0,K.jsx)(z,{checked:!!t.multiple,onChange:e=>n({...t,multiple:e||void 0,...e?{}:{min:void 0,max:void 0}})})]}):null,(t.kind===`image`||t.kind===`file`)&&t.multiple?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Wie viele?`}),(0,K.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`min`,`max`].map(e=>(0,K.jsx)(V,{type:`number`,min:1,max:30,"aria-label":e===`min`?`Mindestens`:`Höchstens`,placeholder:e===`min`?`min.`:`max.`,value:t[e]??``,onChange:r=>{let i=Math.round(Number(r.target.value));n({...t,[e]:r.target.value&&i>=1?Math.min(i,30):void 0})},className:`h-8 w-16 text-right`},e))})]}):null,t.kind===`file`?(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Auch mit der Kamera aufnehmen`}),(0,K.jsx)(z,{checked:!!t.camera,onChange:e=>n({...t,camera:e||void 0})})]}):null,t.kind===`file`?(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Kamera nimmt auch kurze Videos auf`}),(0,K.jsx)(z,{checked:!!t.video,onChange:e=>n({...t,video:e||void 0})})]}):null,t.kind===`text`?(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`QR- oder Barcode scannen`}),(0,K.jsx)(z,{checked:!!t.scan,onChange:e=>n({...t,scan:e||void 0})})]}):null,[`text`,`textarea`,`number`,`email`,`url`,`location`].includes(t.kind)?(0,K.jsx)(V,{placeholder:`Platzhalter`,value:t.placeholder??``,onChange:e=>n({...t,placeholder:e.target.value||void 0})}):null,(0,K.jsx)(V,{placeholder:`Hilfetext`,value:t.help??``,onChange:e=>n({...t,help:e.target.value||void 0})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:W(`run.required`)}),(0,K.jsx)(z,{checked:!!t.required,onChange:e=>n({...t,required:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-ink-4`,children:`{{${t.id}}}`}),(0,K.jsxs)(`div`,{className:`flex`,children:[(0,K.jsx)(R,{label:W(`editor.moveUp`),onClick:()=>i(-1),className:`size-8`,children:(0,K.jsx)(b,{className:`size-3.5`})}),(0,K.jsx)(R,{label:W(`editor.moveDown`),onClick:()=>i(1),className:`size-8`,children:(0,K.jsx)(_,{className:`size-3.5`})}),(0,K.jsx)(R,{label:`Entfernen`,onClick:r,className:`size-8 hover:text-rose`,children:(0,K.jsx)(x,{className:`size-3.5`})})]})]})]}):null]})}var sa=[{label:`16:9`,width:1280,height:720},{label:`1:1`,width:1080,height:1080},{label:`4:5`,width:1080,height:1350},{label:`9:16`,width:1080,height:1920}];function ca(e,t){let n=[];for(let r of e.steps.slice(0,t))r.type===`page`?n.push(...r.fields.map(e=>e.id)):r.type===`agent`?n.push(`steps.${r.id}`,...(r.output.fields??[]).map(e=>`steps.${r.id}.${e.id}`)):(r.type===`generate`||r.type===`widget`)&&n.push(`steps.${r.id}`);return[...n,`brand.name`,`today`]}function la({def:e,step:t,set:n,files:r,wizardId:i}){let a=r.filter(e=>e.mime===`text/html`),s=r.filter(e=>e.mime===`application/json`),c=t.size??sa[0],l=ca(e,e.steps.indexOf(t)),u=Object.entries(t.data),d=e=>n({...t,data:Object.fromEntries(e)}),f=[r.find(e=>e.path===t.entry)?.hash.slice(0,8),r.find(e=>e.path===t.sample)?.hash.slice(0,8),c.width,c.height].join(`-`),p=r.some(e=>e.path===t.entry);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Q,{title:`Vorschau mit Beispieldaten`,children:p?(0,K.jsx)(S,{src:o(`/api/studio/wizards/${i}/widgets/${t.id}/preview?v=${f}`),page:c.width,height:c.height,fit:!0}):(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:`Das Widget ist noch nicht gebaut. Bitte im Gespräch darum – oder lade eine HTML-Datei unter „Dateien“ hoch.`})}),(0,K.jsxs)(Q,{title:`Widget`,children:[(0,K.jsx)(P,{children:`HTML-Datei`}),(0,K.jsx)(U,{value:t.entry,onChange:e=>n({...t,entry:e}),options:(a.some(e=>e.path===t.entry)?a:[{path:t.entry},...a]).map(e=>({value:e.path,label:e.path}))}),(0,K.jsx)(P,{children:`Beispieldaten`}),(0,K.jsx)(U,{value:t.sample??``,onChange:e=>n({...t,sample:e||void 0}),options:[{value:``,label:`keine`},...s.map(e=>({value:e.path,label:e.path}))]}),(0,K.jsx)(P,{children:`Größe`}),(0,K.jsx)(I,{value:sa.find(e=>e.width===c.width&&e.height===c.height)?.label??``,options:sa.map(e=>e.label),onChange:e=>{let r=sa.find(t=>t.label===e);r&&n({...t,size:{width:r.width,height:r.height}})}})]}),(0,K.jsxs)(Q,{title:`Daten für das Widget`,children:[(0,K.jsx)(`datalist`,{id:`sources-${t.id}`,children:l.map(e=>(0,K.jsx)(`option`,{value:e},e))}),u.map(([e,n],r)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(V,{value:e,className:`w-28 font-mono text-[12px]`,onChange:e=>d(u.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,K.jsx)(`span`,{className:`text-ink-4`,children:`←`}),(0,K.jsx)(V,{value:n,list:`sources-${t.id}`,className:`flex-1 font-mono text-[12px]`,onChange:e=>d(u.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,K.jsx)(R,{label:W(`editor.deleteStep`),onClick:()=>d(u.filter((e,t)=>t!==r)),children:(0,K.jsx)(x,{className:`size-4`})})]},r)),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d([...u,[`wert${u.length+1}`,l[0]??`today`]]),className:`inline-flex h-8 items-center gap-1 self-start rounded-full px-2.5 text-[12px] text-ink-2 hover:bg-accent`,children:[(0,K.jsx)(D,{className:`size-3.5`}),` Wert`]})]})]})}function ua({def:e,step:t,set:n,mcpServers:r,files:i,wizardId:a}){let o=e.steps.indexOf(t),s=ye().plugins.flatMap(e=>e.tools),c=e.steps.slice(0,o).filter(e=>e.type===`agent`||e.type===`generate`||e.type===`widget`);switch(t.type){case`widget`:return(0,K.jsx)(la,{def:e,step:t,set:n,files:i,wizardId:a});case`page`:return(0,K.jsxs)(Q,{title:`Fragen`,children:[(0,K.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.fields.map((r,i)=>(0,K.jsx)(oa,{def:e,field:r,onChange:e=>n({...t,fields:t.fields.map((t,n)=>n===i?e:t)}),onRemove:()=>t.fields.length>1&&n({...t,fields:t.fields.filter((e,t)=>t!==i)}),onMove:e=>{let r=i+e;if(r<0||r>=t.fields.length)return;let a=[...t.fields];[a[i],a[r]]=[a[r],a[i]],n({...t,fields:a})}},r.id))}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n({...t,fields:[...t.fields,{id:aa(e,`frage`),label:`Neue Frage`,kind:`text`}]}),className:`inline-flex h-9 items-center gap-1.5 self-start rounded-full px-3 text-[13px] text-ink-2 hover:bg-accent`,children:[(0,K.jsx)(D,{className:`size-4`}),` Frage hinzufügen`]})]});case`agent`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Q,{title:`Auftrag`,children:[(0,K.jsx)(L,{value:t.instructions,minRows:6,maxRows:20,onChange:e=>n({...t,instructions:e.target.value}),className:`text-[14px]`}),(0,K.jsxs)(`p`,{className:`text-[12px] text-ink-4`,children:[`Antworten einsetzen mit `,(0,K.jsx)(`code`,{className:`font-mono`,children:`{{feld}}`}),`, frühere Ergebnisse mit `,(0,K.jsx)(`code`,{className:`font-mono`,children:`{{steps.id}}`}),`.`]})]}),(0,K.jsxs)(Q,{title:`Werkzeuge`,children:[(0,K.jsx)(I,{multi:!0,value:t.tools,options:[...new Set([...j,...s.map(e=>e.id),...t.tools])],onChange:e=>n({...t,tools:e})}),(0,K.jsxs)(`div`,{className:`-mt-2 flex flex-wrap gap-x-3 text-[12px] text-ink-4`,children:[j.map(e=>(0,K.jsxs)(`span`,{children:[e,` = `,ee(e)]},e)),s.map(e=>(0,K.jsxs)(`span`,{children:[e.id,` = `,e.title]},e.id))]}),e.connections?.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{hint:`Konten, die die Person im Durchlauf verbindet. Der Schritt liest darin, er schreibt nie.`,children:`Konten der Person`}),(0,K.jsx)(I,{multi:!0,value:t.connections??[],options:e.connections.map(e=>e.id),onChange:e=>n({...t,connections:e.length?e:void 0})})]}):null,r.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{hint:`Nur freigegebene Systeme sind in diesem Schritt erreichbar.`,children:`Verbundene Systeme`}),(0,K.jsx)(I,{multi:!0,value:t.mcp??[],options:r.map(e=>e.id),onChange:e=>n({...t,mcp:e.length?e:void 0})})]}):null]}),(0,K.jsxs)(Q,{title:`Ergebnis`,children:[(0,K.jsx)(I,{value:t.output.format,options:[`text`,`markdown`,`json`],onChange:e=>n({...t,output:{...t.output,format:e}})}),(0,K.jsx)(Vi,{model:t.model,effort:t.effort,onChange:e=>n({...t,...e})}),(0,K.jsx)(V,{placeholder:`Text während der Arbeit, z. B. „Recherchiert …“`,value:t.working??``,onChange:e=>n({...t,working:e.target.value||void 0})})]})]});case`generate`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Q,{title:`Was wird erzeugt?`,children:[(0,K.jsx)(I,{value:t.asset,options:[`image`,`video`,`voice`,`document`,`dashboard`],onChange:e=>n({...t,asset:e})}),(0,K.jsx)(L,{value:t.prompt,minRows:5,maxRows:18,onChange:e=>n({...t,prompt:e.target.value}),className:`text-[14px]`})]}),(0,K.jsxs)(Q,{title:`Optionen`,children:[t.asset===`document`||t.asset===`dashboard`?(0,K.jsx)(Vi,{model:t.model,effort:t.effort,onChange:e=>n({...t,...e})}):null,t.asset===`image`||t.asset===`video`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{children:`Format`}),(0,K.jsx)(I,{value:t.options?.aspectRatio??``,options:[...M],onChange:e=>n({...t,options:{...t.options,aspectRatio:e}})}),(0,K.jsx)(V,{placeholder:`Stil, z. B. „helle Fotografie, minimalistisch“`,value:t.options?.style??``,onChange:e=>n({...t,options:{...t.options,style:e.target.value||void 0}})})]}):null,t.asset===`video`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{children:`Länge (Sekunden)`}),(0,K.jsx)(I,{value:String(t.options?.duration??8),options:[`4`,`6`,`8`,`10`],onChange:e=>n({...t,options:{...t.options,duration:Number(e)}})}),(0,K.jsx)(P,{children:`Auflösung`}),(0,K.jsx)(I,{value:t.options?.resolution??`720p`,options:[...ue],onChange:e=>n({...t,options:{...t.options,resolution:e}})})]}):null,t.asset===`document`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(P,{children:`Vorlage`}),(0,K.jsx)(U,{value:t.options?.template??`free`,onChange:e=>n({...t,options:{...t.options,template:e}}),options:[`free`,`invoice`,`offer`,`briefing`,`letter`,`report`].map(e=>({value:e,label:e}))})]}):null]})]});case`review`:return(0,K.jsxs)(Q,{title:`Was wird gezeigt?`,children:[(0,K.jsx)(I,{multi:!0,value:t.show,options:c.map(e=>e.id),onChange:e=>e.length&&n({...t,show:e})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Text direkt bearbeitbar`}),(0,K.jsx)(z,{checked:!!t.edit,onChange:e=>n({...t,edit:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Neue Variante anfordern`}),(0,K.jsx)(z,{checked:!!t.regenerate,onChange:e=>n({...t,regenerate:e})})]})]});case`result`:return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Q,{title:`Abschluss`,children:(0,K.jsx)(L,{minRows:2,placeholder:`Nachricht am Ende`,value:t.message??``,onChange:e=>n({...t,message:e.target.value||void 0})})}),(0,K.jsx)(Q,{title:`Downloads`,children:c.map(e=>{let r=t.deliverables.find(t=>t.from===e.id),i=fe(e);return(0,K.jsxs)(`div`,{className:`rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`truncate text-[14px]`,children:e.title}),(0,K.jsx)(z,{checked:!!r,onChange:r=>n({...t,deliverables:r?[...t.deliverables,{from:e.id,label:e.title,formats:[i[0]]}]:t.deliverables.filter(t=>t.from!==e.id)})})]}),r?(0,K.jsx)(I,{multi:!0,value:r.formats,options:i,onChange:r=>r.length&&n({...t,deliverables:t.deliverables.map(t=>t.from===e.id?{...t,formats:r}:t)})}):null]},e.id)})})]})}}function da({def:e,update:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(Q,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(P,{children:`Titel`}),(0,K.jsx)(V,{value:e.title,onChange:n=>t({...e,title:n.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(P,{children:`Beschreibung`}),(0,K.jsx)(L,{minRows:2,value:e.description,onChange:n=>t({...e,description:n.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(P,{hint:`Steht über der ersten Seite.`,children:`Begrüßung`}),(0,K.jsx)(L,{minRows:2,value:e.intro??``,onChange:n=>t({...e,intro:n.target.value||void 0})})]})]}),(0,K.jsx)(Q,{title:`Avatar`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:A.map(n=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>t({...e,avatar:n}),className:F(`flex aspect-square items-center justify-center rounded-xl transition`,e.avatar===n?`bg-ember-tint ring-2 ring-ember`:`bg-paper hover:bg-paper-2`),"aria-label":n,children:(0,K.jsx)(s,{kind:n,size:44,interactive:!1})},n))})}),e.lists?.length||e.connections?.length?(0,K.jsxs)(Q,{title:`Merkt sich für jede Person`,children:[(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:`Bleibt zwischen den Durchläufen erhalten – getrennt für jede Person, die den Wizard nutzt. Ändern kannst du das im Gespräch.`}),(e.connections??[]).map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-paper px-3 py-2.5 ring-1 ring-border-soft`,children:[(0,K.jsx)(`div`,{className:`text-[14px]`,children:e.title??e.id}),(0,K.jsxs)(`div`,{className:`text-[12px] text-ink-4`,children:[`Konto · `,e.kind]})]},e.id)),(e.lists??[]).map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-paper px-3 py-2.5 ring-1 ring-border-soft`,children:[(0,K.jsx)(`div`,{className:`text-[14px]`,children:e.title}),(0,K.jsxs)(`div`,{className:`text-[12px] text-ink-4`,children:[`Liste · `,e.columns.map(e=>e.name).join(`, `)]}),(0,K.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-ink-4`,children:`{{lists.${e.id}}}`})]},e.id))]}):null]})}var fa={page:e=>({id:e,type:`page`,title:`Neue Seite`,fields:[{id:`${e}Text`,label:`Neue Frage`,kind:`text`}]}),agent:e=>({id:e,type:`agent`,title:`KI-Schritt`,instructions:`Beschreibe die Aufgabe …`,tools:[],output:{format:`markdown`}}),generate:e=>({id:e,type:`generate`,title:`Bild erzeugen`,asset:`image`,prompt:`Beschreibe das Bild …`}),widget:e=>({id:e,type:`widget`,title:`Widget`,entry:`${e}/index.html`,data:{},sample:`${e}/sample.json`})},$=`__wizard`;function pa({def:e,selected:t,onSelect:n,issues:r}){let i=[$,...e.steps.map(e=>e.id)],a=t?i.indexOf(t):-1,o=(0,G.useRef)(null);(0,G.useEffect)(()=>{o.current?.scrollIntoView({block:`nearest`,inline:`center`,behavior:`smooth`})},[t]);let s=e=>{let t=a===-1?e===1?1:i.length-1:a+e;t>=0&&t<i.length&&n(i[t])},c=(0,G.useRef)(s);c.current=s,(0,G.useEffect)(()=>{let e=e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.target?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [role="separator"], [role="slider"], [role="dialog"], .react-flow`)||(e.preventDefault(),c.current(e.key===`ArrowLeft`?-1:1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let l=`inline-flex size-8 shrink-0 items-center justify-center rounded-full transition`;return(0,K.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-1 border-border-soft border-b bg-card/95 px-2 py-2 backdrop-blur`,children:[(0,K.jsx)(R,{label:W(`editor.prevStep`),className:`size-8 shrink-0`,disabled:a===0,onClick:()=>s(-1),children:(0,K.jsx)(Fe,{className:`size-4`})}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center overflow-x-auto p-1 [scrollbar-width:none]`,children:[(0,K.jsx)(`button`,{ref:t===$?o:void 0,type:`button`,title:e.title,"aria-label":e.title,"aria-current":t===$?`step`:void 0,onClick:()=>n($),className:F(l,`bg-paper-2 text-ink-2`,t===$?`ring-2 ring-ember`:`hover:ring-2 hover:ring-border-soft`),children:(0,K.jsx)(ie,{className:`size-4`})}),e.steps.map((e,i)=>{let a=w(e),s=e.id===t,c=r.some(t=>t.stepId===e.id);return(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,K.jsx)(`span`,{className:`h-px w-3 bg-border-soft`}),(0,K.jsxs)(`button`,{ref:s?o:void 0,type:`button`,title:`${i+1}. ${e.title}`,"aria-label":`${i+1}. ${e.title}`,"aria-current":s?`step`:void 0,onClick:()=>n(e.id),className:F(l,`relative`,te[e.type],s?`ring-2 ring-ember`:`opacity-70 hover:opacity-100`),children:[(0,K.jsx)(a,{className:`size-4`}),c?(0,K.jsx)(`span`,{className:`-top-0.5 -right-0.5 absolute size-2.5 rounded-full bg-rose ring-2 ring-card`}):null]})]},e.id)})]}),(0,K.jsx)(`span`,{className:`shrink-0 px-1 text-[12px] text-ink-4 tabular-nums`,children:a>0?`${a} / ${e.steps.length}`:``}),(0,K.jsx)(R,{label:W(`editor.nextStep`),className:`size-8 shrink-0`,disabled:a===i.length-1,onClick:()=>s(1),children:(0,K.jsx)(Le,{className:`size-4`})})]})}function ma({def:e,onSelect:t,issues:n}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-1 p-3`,children:e.steps.map((e,r)=>{let i=w(e),a=n.some(t=>t.stepId===e.id);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-paper-2`,children:[(0,K.jsx)(`span`,{className:`w-4 text-right text-[12px] text-ink-4 tabular-nums`,children:r+1}),(0,K.jsx)(`span`,{className:F(`inline-flex size-7 shrink-0 items-center justify-center rounded-md`,te[e.type]),children:(0,K.jsx)(i,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-[14px]`,children:e.title}),(0,K.jsx)(`span`,{className:`block text-[12px] text-ink-4`,children:C(e)})]}),a?(0,K.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-rose`}):null]},e.id)})})}function ha(e){let{def:t,selected:n,update:r,onSelect:i,issues:a}=e,o=t.steps.find(e=>e.id===n);return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(pa,{def:t,selected:n,onSelect:i,issues:a}),n===$?(0,K.jsx)(da,{def:t,update:r}):o?(0,K.jsx)(ga,{...e,step:o}):(0,K.jsx)(ma,{def:t,onSelect:i,issues:a})]})}function ga({def:e,step:t,update:n,onSelect:r,issues:i,mcpServers:a,files:o,wizardId:s}){let c=e.steps.indexOf(t),l=w(t),u=r=>n({...e,steps:e.steps.map(e=>e.id===t.id?r:e)}),d=r=>{let i=c+r;if(i<0||i>=e.steps.length-(t.type===`result`?0:1)||e.steps[i].type===`result`)return;let a=[...e.steps];[a[c],a[i]]=[a[i],a[c]],n({...e,steps:a})},f=i=>{let a=aa(e,i===`page`?`seite`:i===`agent`?`ki`:i===`widget`?`widget`:`erzeugen`),o=[...e.steps];o.splice(t.type===`result`?c:c+1,0,fa[i](a)),n({...e,steps:o}),r(a)},p=i.filter(e=>e.stepId===t.id),m=Ri(s,e);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-4`,children:[(0,K.jsx)(`span`,{className:F(`inline-flex size-7 items-center justify-center rounded-md`,te[t.type]),children:(0,K.jsx)(l,{className:`size-4`})}),(0,K.jsx)(`span`,{className:`font-medium text-[12px] text-ink-3 uppercase tracking-[0.07em]`,children:C(t)}),(0,K.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-ink-4`,children:t.id})]}),p.length?(0,K.jsx)(`div`,{className:`mx-5 mb-4 rounded-lg bg-rose-tint px-3 py-2 text-[13px] text-rose`,children:p.map((e,t)=>(0,K.jsx)(`div`,{children:e.message},t))}):null,(0,K.jsxs)(Q,{children:[(0,K.jsx)(V,{value:t.title,onChange:e=>u({...t,title:e.target.value}),className:`font-display font-semibold text-[16px]`}),t.type===`page`||t.type===`review`?(0,K.jsx)(L,{minRows:1,placeholder:`Erklärung unter dem Titel (optional)`,value:t.description??``,onChange:e=>u({...t,description:e.target.value||void 0})}):null,(0,K.jsx)(Bi,{estimate:m.data,stepId:t.id})]}),(0,K.jsx)(ua,{def:e,step:t,set:u,mcpServers:a,files:o,wizardId:s}),(0,K.jsx)(Q,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[t.type===`result`?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(R,{label:W(`editor.moveUp`),onClick:()=>d(-1),children:(0,K.jsx)(b,{className:`size-4`})}),(0,K.jsx)(R,{label:W(`editor.moveDown`),onClick:()=>d(1),children:(0,K.jsx)(_,{className:`size-4`})}),(0,K.jsx)(R,{label:W(`editor.deleteStep`),className:`hover:text-rose`,onClick:()=>{n({...e,steps:e.steps.filter(e=>e.id!==t.id)}),r(null)},children:(0,K.jsx)(x,{className:`size-4`})})]}),(0,K.jsx)(`span`,{className:`ml-auto text-[12px] text-ink-4`,children:`Danach einfügen:`}),[`page`,`agent`,`generate`,`widget`].map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>f(e),className:`inline-flex h-8 items-center gap-1 rounded-full px-2.5 text-[12px] text-ink-2 hover:bg-accent`,children:[(0,K.jsx)(D,{className:`size-3.5`}),` `,W(`type.${e}`)]},e))]})})]})}var _a={waiting_input:`wartet`,running:`läuft`,done:`fertig`,failed:`Fehler`,cancelled:`abgebrochen`};function va({wizardId:e,onOpen:t}){let n=c({queryKey:[`runs`,e],queryFn:()=>u.get(`/api/studio/wizards/${e}/runs`),refetchInterval:1e4});if(n.data&&!n.data.length)return(0,K.jsx)(ge,{children:W(`editor.noRuns`)});let r=new Intl.DateTimeFormat(he,{dateStyle:`short`,timeStyle:`short`});return(0,K.jsx)(`div`,{className:`flex flex-col p-2`,children:n.data?.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),className:`flex items-center gap-3 rounded-lg px-3 py-3 text-left hover:bg-accent`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[r.format(new Date(e.createdAt)),e.mode===`test`?(0,K.jsx)(B,{children:`Test`}):(0,K.jsxs)(B,{tone:`live`,children:[`Live v`,e.version]})]}),(0,K.jsxs)(`div`,{className:`truncate text-[12px] text-ink-3`,children:[_a[e.status]??e.status,e.stepTitle&&e.status!==`done`?` · ${e.stepTitle}`:``]})]}),(0,K.jsxs)(`span`,{className:`text-[12px] text-ink-4 tabular-nums`,children:[e.credits,` cr`]})]},e.id))})}var ya=e=>e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`);function ba({url:e,title:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),[,o,s]=e.match(/^(.*)\/w\/([^/]+)$/)??[];if(!s)return null;let c=`<script async src="${o}/embed.js" data-wizard="${s}"${n?` data-mode="modal" data-label="${ya(t)}"`:``}><\/script>`,l=[W(`embed.inline`),W(`embed.modal`)];return(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 border-border-soft border-t pt-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[14px]`,children:W(`embed.title`)}),(0,K.jsxs)(H,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(c),a(!0),setTimeout(()=>a(!1),1500)},children:[i?(0,K.jsx)(ne,{className:`size-3.5`}):(0,K.jsx)(ce,{className:`size-3.5`}),W(i?`share.copied`:`share.copy`)]})]}),(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:W(n?`embed.modalHint`:`embed.inlineHint`)}),(0,K.jsx)(I,{value:l[+!!n],onChange:e=>r(e===l[1]),options:l}),(0,K.jsx)(`pre`,{className:`select-all whitespace-pre-wrap break-all rounded-lg bg-paper-2 px-3 py-2.5 font-mono text-[12px] text-ink-2 leading-relaxed`,children:c})]})}function xa({wizard:e}){let t=d(),n=c({queryKey:[`cloud`,e.id],queryFn:()=>u.get(`/api/studio/wizards/${e.id}/cloud`)}),r=p({mutationFn:()=>u.post(`/api/studio/wizards/${e.id}/cloud`),onSuccess:()=>t.invalidateQueries({queryKey:[`cloud`,e.id]})}),i=n.data?.copy?.shareUrl;return(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 border-border-soft border-t pt-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[14px]`,children:W(`cloud.title`)}),(0,K.jsxs)(H,{variant:`secondary`,size:`sm`,busy:r.isPending,onClick:()=>r.mutate(),children:[(0,K.jsx)(Ve,{className:`size-3.5`}),W(i?`cloud.update`:`cloud.publish`)]})]}),(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:W(`cloud.hint`)}),i?(0,K.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 self-start font-mono text-[13px] text-ink-2 hover:text-ink`,onClick:()=>Ne(i),children:[(0,K.jsx)(le,{className:`size-3.5`}),` `,i]}):null,i?(0,K.jsx)(ba,{url:i,title:e.draft.title}):null,r.isError?(0,K.jsx)(`p`,{className:`text-[13px] text-rose`,children:r.error instanceof f?r.error.message:W(`cloud.failed`)}):null]})}function Sa({wizard:e,open:t,onClose:n}){let r=d(),[i,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(String(e.dailyRunLimit)),l=()=>r.invalidateQueries({queryKey:[`wizard`,e.id]}),f=p({mutationFn:t=>u.patch(`/api/studio/wizards/${e.id}`,t),onSuccess:l}),h=p({mutationFn:()=>u.post(`/api/studio/wizards/${e.id}/rotate-link`),onSuccess:l}),g=`${window.location.origin}${a}/w/${e.shareToken}`,_=m(),v=Ri(e.id,e.draft),y=v.data?.available&&v.data.reserve>0?Math.round(v.data.reserve*e.dailyRunLimit):null;return(0,K.jsxs)(ve,{open:t,onClose:n,title:W(`share.title`),children:[e.published?null:(0,K.jsx)(`p`,{className:`mb-4 rounded-lg bg-amber-tint px-3 py-2 text-[14px]`,children:W(`share.publishFirst`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(V,{readOnly:!0,value:g,onFocus:e=>e.target.select(),className:`font-mono text-[13px]`}),(0,K.jsxs)(H,{variant:`secondary`,onClick:()=>{navigator.clipboard.writeText(g),o(!0),setTimeout(()=>o(!1),1500)},children:[i?(0,K.jsx)(ne,{className:`size-4`}):(0,K.jsx)(ce,{className:`size-4`}),W(i?`share.copied`:`share.copy`)]})]}),(0,K.jsxs)(`a`,{href:g,target:`_blank`,rel:`noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 text-[13px] text-ink-3 hover:text-ink`,children:[(0,K.jsx)(le,{className:`size-3.5`}),` `,W(`share.open`)]}),(0,K.jsx)(ba,{url:g,title:e.draft.title}),(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col gap-5 border-border-soft border-t pt-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[14px]`,children:W(`share.enabled`)}),(0,K.jsx)(z,{checked:e.shareEnabled,onChange:e=>f.mutate({shareEnabled:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`whitespace-nowrap text-[14px]`,children:W(`share.limit`)}),(0,K.jsx)(`div`,{className:`w-24`,children:(0,K.jsx)(V,{inputMode:`numeric`,className:`text-right`,value:s,onChange:e=>c(e.target.value.replace(/\D/g,``)),onBlur:()=>{let t=Number(s);t>=1&&t!==e.dailyRunLimit&&f.mutate({dailyRunLimit:t})}})})]}),y!==null&&v.data?(0,K.jsx)(`p`,{className:`text-[13px] text-ink-3 tabular-nums`,children:W(`estimate.share`,{run:Math.round(v.data.credits).toLocaleString(),day:y.toLocaleString()})}):null,(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`span`,{className:`text-[13px] text-ink-3`,children:W(`share.rotateHint`)}),(0,K.jsxs)(H,{variant:`ghost`,size:`sm`,busy:h.isPending,onClick:()=>h.mutate(),children:[(0,K.jsx)(me,{className:`size-3.5`}),` `,W(`share.rotate`)]})]})]}),_.data?.mode===`local`&&_.data.account?(0,K.jsx)(xa,{wizard:e}):null]})}var Ca=[`title`,`description`,`avatar`,`intro`,`lists`,`connections`],wa=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Ta(e,t,n){let r={...n};for(let n of Ca)wa(t[n],e[n])||Object.assign(r,{[n]:t[n]});let i=new Map(e.steps.map(e=>[e.id,e])),a=new Set(t.steps.map(e=>e.id)),o=n.steps.filter(e=>{let t=i.get(e.id);return a.has(e.id)||!t||!wa(t,e)});return t.steps.forEach((e,n)=>{let r=i.get(e.id);if(r&&wa(r,e))return;let a=o.findIndex(t=>t.id===e.id);if(a!==-1){o[a]=e;return}let s=t.steps.slice(0,n).reverse().find(e=>o.some(t=>t.id===e.id));o.splice(s?o.findIndex(e=>e.id===s.id)+1:0,0,e)}),{...r,steps:o}}function Ea(e){let t=d(),n=(0,G.useMemo)(()=>[`wizard`,e],[e]),r=`/api/studio/wizards/${e}`,i=(0,G.useRef)(null),a=(0,G.useRef)(Promise.resolve()),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(0),[_,v]=(0,G.useState)(null),y=(0,G.useCallback)(()=>!!(i.current||l.current||s.current),[]),b=(0,G.useCallback)(async()=>{let e=await u.get(r);t.setQueryData(n,t=>t&&y()?{...e,draft:t.draft,title:t.title,revision:t.revision,dirty:!0}:e)},[t,n,r,y]),x=(0,G.useCallback)(()=>{a.current=a.current.then(async()=>{let e=s.current,i=t.getQueryData(n);if(e&&i){s.current=null,l.current=!0,m(!0);try{let a=await u.put(`${r}/draft`,{definition:e,baseRevision:i.revision});c.current=s.current?e:null,t.setQueryData(n,e=>e&&{...e,revision:a.revision,issues:a.issues})}catch(i){if(!(i instanceof f&&i.status===409)){s.current??=e,console.error(`[draft] save failed`,i);return}let a=await u.get(r),o=Ta(c.current??a.draft,s.current??e,a.draft);c.current=a.draft,s.current=o,t.setQueryData(n,{...a,draft:o,title:o.title,dirty:!0}),g(Date.now()),x()}finally{l.current=!1,m(!1)}}})},[t,n,r]),S=(0,G.useCallback)(r=>{e&&(y()||(c.current=t.getQueryData(n)?.draft??null),s.current=r,t.setQueryData(n,e=>e&&{...e,draft:r,title:r.title,dirty:!0}),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,x()},600))},[t,n,e,y,x]);return(0,G.useEffect)(()=>{if(!e)return;let r=new EventSource(o(`/api/studio/wizards/${e}/stream`));return r.addEventListener(`change`,e=>{let r=JSON.parse(e.data),i=t.getQueryData(n);r.kind===`draft`&&i&&r.revision<=i.revision||(b(),r.kind===`draft`&&r.source===`mcp`&&v({client:r.client??`MCP`,steps:r.touched,at:Date.now()}))}),r.addEventListener(`hello`,e=>{let{revision:r}=JSON.parse(e.data),i=t.getQueryData(n);i&&r!==i.revision&&b()}),()=>r.close()},[t,n,e,b]),(0,G.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>v(null),6e3);return()=>clearTimeout(e)},[_]),(0,G.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>g(0),4e3);return()=>clearTimeout(e)},[h]),{save:S,saving:p,remote:_,merged:h>0}}function Da({remote:e,merged:t}){return e?(0,K.jsxs)(B,{tone:`ember`,children:[(0,K.jsx)(we,{className:`size-3`}),` `,W(`editor.changedVia`,{client:e.client})]}):t?(0,K.jsxs)(B,{children:[(0,K.jsx)(qe,{className:`size-3`}),` `,W(`editor.merged`)]}):null}var Oa={chat:`editor.chat`,step:`editor.step`,files:`editor.files`,runs:`editor.runs`},ka=`wizards.editor.pane`,Aa=420,ja=340,Ma=()=>Math.max(ja,window.innerWidth-480);function Na(){try{let e=Number(localStorage.getItem(ka));return e?Math.min(Math.max(e,ja),Ma()):Aa}catch{return Aa}}function Pa(){let[e,t]=(0,G.useState)(Na),n=(0,G.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,ja),Ma()));t(n);try{localStorage.setItem(ka,String(n))}catch{}},[]);return{width:e,onPointerDown:t=>{t.preventDefault();let r=t.clientX,i=e,a=e=>n(i+r-e.clientX),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},onKeyDown:t=>{let r=t.shiftKey?64:16;t.key===`ArrowLeft`?(t.preventDefault(),n(e+r)):t.key===`ArrowRight`&&(t.preventDefault(),n(e-r))},reset:()=>n(Aa)}}function Fa(){let{id:e}=l(),t=i(),n=d(),a=m(),[s,f]=r(),h=c({queryKey:[`wizard`,e],queryFn:()=>u.get(`/api/studio/wizards/${e}`),refetchOnWindowFocus:!1}),[_,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(`chat`),C=Pa(),[ee,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(null),[te,ne]=(0,G.useState)(null),re=(0,G.useCallback)(e=>ne(e&&e.status!==`done`?e.step?.id??null:null),[]),{save:ie,saving:ce,remote:D,merged:le}=Ea(e),O=ae(h.data,(t,r)=>{n.setQueryData([`wizard`,e],e=>e&&{...e,draft:t,revision:r,title:t.title,blank:!1})}),ue=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let e=s.get(`prompt`);e&&h.data&&!ue.current&&(ue.current=!0,f({},{replace:!0}),O.send(e))},[s,h.data,O,f]);let de=c({queryKey:[`wizard-models`,e,h.data?.revision],queryFn:()=>u.get(`/api/studio/wizards/${e}/models`),enabled:!!h.data}).data?.missing??[],fe=de.some(e=>e.blocking),k=p({mutationFn:()=>u.post(`/api/studio/wizards/${e}/test-runs`),onSuccess:({runId:e})=>E(e)}),pe=p({mutationFn:()=>u.post(`/api/studio/wizards/${e}/publish`),onSuccess:async()=>{await n.invalidateQueries({queryKey:[`wizard`,e]}),w(!0)}}),me=(0,G.useMemo)(()=>new Set((h.data?.issues??[]).map(e=>e.stepId).filter(Boolean)),[h.data?.issues]);if(h.isLoading||!a.data)return(0,K.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center text-ink-4`,children:(0,K.jsx)(_e,{})});if(!h.data)return(0,K.jsx)(`div`,{className:`p-10 text-center text-ink-3`,children:W(`run.notFound`)});let A=h.data,j=A.draft,M=O.phase!==`idle`&&A.blank,N=A.issues.length>0,he=e=>{b(e),e&&S(`step`)};return(0,K.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-2 px-3 sm:px-4`,children:[(0,K.jsx)(R,{label:`Zurück`,onClick:()=>t(`/`),children:(0,K.jsx)(y,{className:`size-5`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>he(`__wizard`),className:`min-w-0 truncate rounded-md px-2 py-1 text-left hover:bg-accent`,children:(0,K.jsx)(`span`,{className:`font-display font-semibold text-[17px] tracking-tight`,children:j.title})}),(0,K.jsx)(`span`,{className:`hidden sm:inline-flex`,children:A.published?A.dirty?(0,K.jsx)(B,{tone:`warn`,children:W(`editor.unpublishedChanges`)}):(0,K.jsx)(B,{tone:`live`,children:W(`editor.published`,{v:A.publishedVersion??0})}):(0,K.jsx)(B,{children:W(`editor.notPublished`)})}),ce?(0,K.jsx)(_e,{className:`size-4 text-ink-4`}):null,(0,K.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,K.jsx)(Da,{remote:D,merged:le})}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,K.jsx)(`a`,{href:o(`/api/studio/wizards/${A.id}/export`),download:!0,"aria-label":W(`editor.export`),title:W(`editor.export`),className:`hidden size-9 shrink-0 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink sm:inline-flex`,children:(0,K.jsx)(be,{className:`size-4`})}),(0,K.jsxs)(H,{variant:`secondary`,size:`sm`,disabled:N||M||fe,busy:k.isPending,onClick:()=>k.mutate(),children:[(0,K.jsx)(Ze,{className:`size-3.5`}),` `,W(`editor.test`)]}),A.published&&!A.dirty?(0,K.jsxs)(H,{size:`sm`,onClick:()=>w(!0),children:[(0,K.jsx)(g,{className:`size-3.5`}),` `,W(`editor.share`)]}):(0,K.jsx)(H,{size:`sm`,disabled:N||M,busy:pe.isPending,onClick:()=>pe.mutate(),children:W(`editor.publish`)}),(0,K.jsx)(`span`,{className:`ml-2 hidden md:inline-flex`,children:(0,K.jsx)(Ce,{me:a.data})}),(0,K.jsx)(`span`,{className:`hidden sm:inline-flex`,children:(0,K.jsx)(Se,{me:a.data})})]})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[(0,K.jsxs)(`section`,{className:`relative min-h-[45vh] flex-1 overflow-hidden lg:min-h-0`,children:[N&&!M?(0,K.jsxs)(`div`,{className:`absolute top-3 right-3 left-3 z-10 mx-auto max-w-xl animate-rise rounded-xl bg-card p-4 shadow-elevated ring-1 ring-rose/30`,children:[(0,K.jsx)(`p`,{className:`text-[14px]`,children:W(`editor.issues`)}),(0,K.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-[13px] text-ink-2`,children:A.issues.slice(0,4).map((e,t)=>(0,K.jsx)(`li`,{children:e.message},t))}),(0,K.jsx)(H,{size:`sm`,variant:`quiet`,className:`mt-3`,disabled:O.phase!==`idle`,onClick:()=>{S(`chat`),O.send(`Bitte behebe diese Probleme im Wizard:\n${A.issues.map(e=>`- ${e.message}`).join(`
|
|
2
|
-
`)}`)},children:W(`editor.fixWithChat`)})]}):null,!N&&!M&&de.length?(0,K.jsxs)(`div`,{className:F(`absolute top-3 right-3 left-3 z-10 mx-auto max-w-xl animate-rise rounded-xl bg-card p-4 shadow-elevated ring-1`,fe?`ring-rose/30`:`ring-amber/30`),children:[(0,K.jsx)(`p`,{className:`text-[14px]`,children:W(fe?`editor.models.blocking`:`editor.models.optional`)}),(0,K.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-[13px] text-ink-2`,children:de.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-ink`,children:W(`class.${e.cls}`)}),` (`,e.steps.map(e=>`„${e.title}“`).join(`, `),`): `,e.problem]},e.cls))}),(0,K.jsx)(H,{size:`sm`,variant:`quiet`,className:`mt-3`,onClick:()=>t(`/settings/models`),children:W(`editor.models.settings`)})]}):null,M?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-[14px] text-ink-3`,children:(0,K.jsx)(oe,{chat:O,spinner:`size-4 text-ember`})}):(0,K.jsx)(na,{def:j,selected:_,onSelect:he,issueSteps:me,activeStep:T?te:null,pulse:D?.steps,wizardId:A.id})]}),(0,K.jsxs)(`aside`,{className:`relative flex h-[55vh] min-h-0 w-full shrink-0 flex-col bg-card shadow-[0_0_0_1px_var(--border-soft)] lg:h-auto lg:w-(--pane) lg:rounded-tl-3xl`,style:{"--pane":`${C.width}px`},children:[(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":W(`editor.resize`),"aria-valuenow":C.width,tabIndex:0,title:W(`editor.resize`),onPointerDown:C.onPointerDown,onKeyDown:C.onKeyDown,onDoubleClick:C.reset,className:`group -left-1.5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none lg:block`,children:(0,K.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[9px] h-12 w-1.5 rounded-full bg-ink-4/40 transition group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:h-16 group-active:bg-ember`})}),(0,K.jsx)(`nav`,{className:`flex shrink-0 gap-1 px-3 pt-3`,children:[`chat`,`step`,`files`,`runs`].map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>S(e),className:F(`h-9 rounded-full px-4 font-medium text-[13px] transition`,x===e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`),children:W(Oa[e])},e))}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:x===`chat`?(0,K.jsx)(se,{chat:O,avatar:j.avatar}):x===`step`?(0,K.jsx)(ha,{def:j,selected:_,update:ie,onSelect:he,issues:A.issues,mcpServers:A.mcpServers,files:A.files,wizardId:A.id}):x===`files`?(0,K.jsx)(nt,{wizardId:A.id,files:A.files}):(0,K.jsx)(va,{wizardId:A.id,onOpen:E})})]})]}),T?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-[oklch(20%_0.01_60/0.22)] backdrop-blur-[1px]`,onClick:()=>E(null),children:(0,K.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,K.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center justify-between px-4`,children:[(0,K.jsx)(B,{children:`Test`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(H,{variant:`ghost`,size:`sm`,busy:k.isPending,disabled:N,onClick:()=>k.mutate(),children:W(`editor.restart`)}),(0,K.jsx)(R,{label:W(`editor.close`),onClick:()=>E(null),children:(0,K.jsx)(xe,{className:`size-5`})})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,K.jsx)(v,{runId:T,compact:!0,onRestart:()=>k.mutate(),onView:re},T)})]})}):null,(0,K.jsx)(Sa,{wizard:A,open:ee,onClose:()=>w(!1)})]})}export{Fa as EditorPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowPreview-CDmcN1oX.js","assets/jsx-runtime-D3jfb0Ew.js","assets/ui-DKc92qJ1.js","assets/esm-rJY59Ixx.js","assets/react-dom-DenslgJm.js"])))=>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}from"./api-DijQGkp-.js";import{a as h,c as g}from"./session-BerOchdC.js";import{t as _}from"./preload-helper-CNEI7N0N.js";import{t as v}from"./createLucideIcon-q3MZMmnf.js";import{t as y}from"./arrow-right-6FyN3e7D.js";import{c as ee,l as b,o as x,s as S,t as C}from"./meta-ijlGGCOr.js";import{t as w}from"./check-CUpby_J9.js";import{n as te,r as T,t as ne}from"./wand-sparkles-CKxArWPY.js";import{n as E,t as re}from"./mic-Bvz4mA2j.js";import{n as ie,t as D}from"./video-CjgmvRDk.js";import{n as O,r as ae,t as oe}from"./type-c_dt5Ne8.js";import{l as se,u as ce}from"./engenty-Cm8yZLON.js";import{_ as k,d as A,h as j,i as le,m as ue,n as de,r as fe,t as M,y as N}from"./ui-DKc92qJ1.js";import{l as P,p as pe,u as me}from"./index-BAObuqzs.js";import{t as he}from"./ImportWizard-pzljVvcr.js";var ge=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 _e(e,t){return s(e,ge,t)}var F={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`}]]};F.node;var ve=v(F),I={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`]};I.node;var L=v(I),R={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`}]]};R.node;var ye=v(R),z={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`}]]};z.node;var be=v(z),B={name:`clapperboard`,size:24,node:[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]};B.node;var xe=v(B),V={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};V.node;var H=v(V),Se={name:`cloud-off`,size:24,node:[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Se.node;var Ce=v(Se),we={name:`coins`,size:24,node:[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]};we.node;var Te=v(we),Ee={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};Ee.node;var De=v(Ee),Oe={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`}]]};Oe.node;var ke=v(Oe),Ae={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`}]]};Ae.node;var je=v(Ae),Me={name:`table-2`,size:24,node:[[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]};Me.node;var Ne=v(Me),Pe={name:`terminal`,size:24,node:[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]};Pe.node;var Fe=v(Pe),Ie={name:`volume-2`,size:24,node:[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]};Ie.node;var Le=v(Ie),U=e(t(),1),W={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`}},Re={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`}},ze={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`}},G={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`}},Be={low:{de:`günstig`,en:`low cost`},medium:{de:`mittel`,en:`medium cost`},high:{de:`teuer`,en:`high cost`}},K=e=>Object.keys(e);K(W),K(Re),K(ze),K(G);var q=e(n(),1),Ve=(0,U.lazy)(()=>_(()=>import(`./FlowPreview-CDmcN1oX.js`),__vite__mapDeps([0,1,2,3,4]))),He={useCase:``,industry:``,format:``,capability:``},J=(e,t)=>e[t]?.[k]??t;function Ue(e){if(e<1)return 1;let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t}function We(e){return e.credits?N(`market.credits`,{n:Ue(e.credits.credits)}):Be[e.costTier][k]}var Ge={text:oe,document:E,table:Ne,image:S,video:D,audio:ve,dashboard:L};function Y({format:e,className:t}){let n=Ge[e],r=J(W,e);return(0,q.jsx)(`span`,{title:r,className:`inline-flex`,children:(0,q.jsx)(n,{className:t,"aria-label":r,role:`img`})})}var Ke=[`low`,`medium`,`high`];function X({entry:e}){let t=Ke.indexOf(e.costTier)+1,n=k===`de`?be:ye;return(0,q.jsxs)(`span`,{title:We(e),className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0`,children:Ke.slice(0,t).map((e,t)=>(0,q.jsx)(`span`,{className:j(`rounded-full bg-(--coin-bg,var(--color-card))`,t>0&&`-ml-1.5`),children:(0,q.jsx)(n,{className:`size-4`})},e))}),Be[e.costTier][k]]})}function qe({entry:e,onOpen:t}){return(0,q.jsxs)(de,{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,q.jsx)(`span`,{className:`-top-4 pointer-events-none absolute right-4`,children:(0,q.jsx)(u,{kind:e.avatar,size:68,interactive:!1})}),(0,q.jsxs)(`div`,{className:`min-w-0 pr-20`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-display font-semibold text-[15px]`,children:[e.title,e.starred?(0,q.jsx)(O,{className:`size-3.5 shrink-0 fill-amber text-amber`,"aria-label":N(`market.starred`)}):null]}),(0,q.jsx)(`div`,{className:`mt-0.5 text-[13px] text-ink-3 leading-snug`,children:e.pitch})]}),(0,q.jsx)(`div`,{className:`mt-auto flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px] text-ink-3`,children:e.usable&&e.missing.length?(0,q.jsx)(fe,{tone:`warn`,children:N(`market.missing`,{list:Je(e.missing)})}):e.usable?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(H,{className:`size-3.5`}),` `,N(`market.minutes`,{n:e.effort.minutes})]}),(0,q.jsx)(X,{entry:e}),(0,q.jsx)(`span`,{className:`ml-auto inline-flex items-center gap-1.5`,children:e.formats.map(e=>(0,q.jsx)(Y,{format:e,className:`size-4`},e))})]}):(0,q.jsx)(fe,{tone:`warn`,children:N(`market.needsUpdate`)})})]})}function Z({title:e,children:t}){return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`mb-1.5 font-medium text-[12px] text-ink-3 uppercase tracking-[0.06em]`,children:e}),t]})}var Je=e=>e.map(e=>J(G,e)).join(`, `),Ye={text:ie,web:De,browser:ke,documents:je,image:S,video:D,speech:Le,listening:re,code:Fe,connectors:me};function Xe(e){switch(e.type){case`page`:return x;case`agent`:return b;case`generate`:return e.asset===`image`?S:e.asset===`video`?D:e.asset===`voice`?Le:e.asset===`dashboard`?L:E;case`widget`:return e.video?xe:pe;case`review`:return te;case`result`:return ee}return ne}function Ze(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=Ze(e);return e.map(e=>({id:e.id,title:e.title,icon:Xe(e),tone:C[e.type]??`bg-paper-2 text-ink-2`,optional:t.has(e.id),branches:e.branches}))}function Q({title:e,children:t}){return(0,q.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,q.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`text-[14px] text-ink leading-snug`,children:t}),n?(0,q.jsx)(`div`,{className:`text-[12px] text-ink-3 leading-snug`,children:n}):null]})]})}function $e({className:e,children:t}){let n=(0,U.useRef)(null),[r,i]=(0,U.useState)({above:!1,below:!1});(0,U.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,q.jsx)(`div`,{ref:n,className:e,style:{maskImage:a,WebkitMaskImage:a},children:(0,q.jsx)(`div`,{children:t})})}function et({id:e,fallback:t,onClose:n,onUse:r,busy:i}){let a=m(),o=l(),s=f({queryKey:[`marketplace-entry`,e,k],queryFn:()=>p.get(`/api/studio/marketplace/${encodeURIComponent(e)}?lang=${k}`),enabled:!!e,retry:!1}),c=s.data??t,h=g({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]})])}),_=d()===`dark`,v=se[ce[c?.avatar||`round`]],y=_?`var(--card)`:`color-mix(in oklch, ${v??`var(--ink-4)`} 14%, var(--paper-2))`;return(0,q.jsx)(le,{open:!!e,onClose:n,wide:!0,bare:!0,children:c?(0,q.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,q.jsx)(`button`,{type:`button`,"aria-label":N(`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,q.jsx)(P,{className:`size-4`})}),(0,q.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:y,"--coin-bg":y},children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden sm:rounded-t-2xl`,children:(0,q.jsx)(`span`,{className:j(`-top-28 -right-10 absolute size-80 rounded-full bg-white blur-3xl`,_?`opacity-[0.14]`:`opacity-80`)})}),(0,q.jsx)(`div`,{className:`-bottom-5 absolute right-9 z-10 max-sm:hidden`,children:(0,q.jsx)(u,{kind:c.avatar,size:104})}),(0,q.jsxs)(`div`,{className:`relative sm:pr-36`,children:[(0,q.jsx)(`h2`,{className:`font-display font-semibold text-[22px] leading-tight tracking-tight max-sm:pr-10`,children:c.title}),(0,q.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-2 leading-snug`,children:s.data?.description||c.pitch})]}),c.usable?(0,q.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-[14px] sm:px-7 sm:pr-40`,children:[(0,q.jsxs)(Q,{title:N(`market.duration`),children:[(0,q.jsx)(H,{className:`size-4 text-ink-3`}),N(`market.minutes`,{n:c.effort.minutes})]}),(0,q.jsx)(Q,{title:N(`market.cost`),children:(0,q.jsx)(X,{entry:c})}),(0,q.jsx)(Q,{title:N(`market.result`),children:c.formats.map(e=>(0,q.jsx)(Y,{format:e,className:`size-4`},e))})]}):null]}),c.usable?(0,q.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,q.jsxs)(`div`,{className:`flex flex-col gap-5 sm:min-h-0 sm:overflow-y-auto`,children:[(0,q.jsx)(Z,{title:N(`market.duration`),children:(0,q.jsx)($,{icon:(0,q.jsx)(H,{className:`size-4 text-moss`}),more:N(`market.durationHint`,{n:c.effort.fields}),children:N(`market.minutes`,{n:c.effort.minutes})})}),(0,q.jsx)(Z,{title:N(`market.cost`),children:(0,q.jsx)($,{icon:(0,q.jsx)(Te,{className:`size-4 text-amber`}),more:c.credits?N(`market.creditsHint`):void 0,children:(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2`,children:[(0,q.jsx)(X,{entry:c}),c.credits?(0,q.jsx)(`span`,{className:`text-ink-2`,children:N(`market.creditsRange`,{n:Ue(c.credits.credits)})}):null]})})}),(0,q.jsx)(Z,{title:N(`market.result`),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,children:(s.data?.results??[]).map(e=>(0,q.jsx)($,{icon:(0,q.jsx)(Y,{format:e.kind,className:`size-4 text-ember-strong`}),more:e.formats.map(e=>e.toUpperCase()).join(` · `),children:e.title},e.title))})}),(0,q.jsx)(Z,{title:N(`market.needs`),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:c.capabilities.map(e=>{let t=Ye[e],n=c.missing.includes(e);return(0,q.jsxs)(`li`,{className:j(`flex items-center gap-2.5 text-[14px]`,n?`text-ink-3`:`text-ink-2`),children:[(0,q.jsx)(t,{className:j(`size-4 shrink-0`,n?`text-rose`:`text-cobalt`)}),J(G,e),n?(0,q.jsx)(`span`,{className:`text-[12px] text-rose`,children:N(`market.unavailable`)}):null]},e)})})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col sm:min-h-0`,children:[(0,q.jsx)(`div`,{className:`mb-1.5 shrink-0 font-medium text-[12px] text-ink-3 uppercase tracking-[0.06em]`,children:N(`market.steps`)}),(0,q.jsx)($e,{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,q.jsx)(A,{className:`size-5 text-ink-3`}):(0,q.jsx)(U.Suspense,{fallback:(0,q.jsx)(A,{className:`size-5 text-ink-3`}),children:(0,q.jsx)(Ve,{steps:Qe(s.data?.outline??[])})})})]})]}):(0,q.jsx)(`div`,{className:`flex-1 px-5 pt-6 sm:px-7`,children:(0,q.jsx)(`p`,{className:`rounded-lg bg-amber-tint p-3 text-[14px] text-ink-2`,children:N(`market.needsUpdateHint`)})}),(0,q.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,q.jsxs)(M,{variant:`ghost`,className:`mr-auto`,title:N(`market.starHint`),"aria-pressed":c.starred,busy:h.isPending,onClick:()=>h.mutate(!c.starred),children:[(0,q.jsx)(O,{className:j(`size-4`,c.starred&&`fill-amber text-amber`)}),(0,q.jsx)(`span`,{className:`max-sm:sr-only`,children:N(c.starred?`market.starred`:`market.star`)})]}),(0,q.jsx)(M,{variant:`secondary`,onClick:n,children:N(`common.close`)}),c.usable&&c.missing.length?(0,q.jsx)(M,{variant:`secondary`,onClick:()=>o(`/settings/models`),children:N(`editor.models.settings`)}):null,(0,q.jsx)(M,{disabled:!c.usable||c.missing.length>0,title:c.missing.length?N(`market.missingHint`,{list:Je(c.missing)}):void 0,busy:i,onClick:()=>r(c),children:N(`market.use`)})]})]}):(0,q.jsx)(`div`,{className:`flex min-h-48 flex-col items-center justify-center gap-3 rounded-2xl bg-card p-8 text-[14px] text-ink-2 shadow-overlay`,children:s.isLoading?(0,q.jsx)(A,{className:`size-6 text-ink-3`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{children:N(`market.notFound`)}),(0,q.jsx)(M,{variant:`secondary`,onClick:n,children:N(`common.close`)})]})})})}function tt({name:e,value:t,options:n,onChange:r}){let[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null);(0,U.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,q.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,q.jsxs)(`div`,{className:j(`flex h-8 items-center rounded-full text-[13px] 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,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-ink-3`,children:e}),(0,q.jsx)(`span`,{className:`font-medium`,children:s.label})]}):(0,q.jsxs)(q.Fragment,{children:[e,(0,q.jsx)(T,{className:j(`size-3.5 transition`,i&&`rotate-180`)})]})}),s?(0,q.jsx)(`button`,{type:`button`,"aria-label":`${e}: ${N(`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,q.jsx)(P,{className:`size-3.5`})}):null]}),i?(0,q.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,q.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-[14px] 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,q.jsx)(`span`,{className:`flex-1 whitespace-nowrap`,children:e.label}),e.value===t?(0,q.jsx)(w,{className:`size-4 text-ember`}):e.unavailable?(0,q.jsx)(`span`,{className:`whitespace-nowrap text-[12px] text-ink-4`,children:N(`market.unavailable`)}):(0,q.jsx)(`span`,{className:`text-[12px] text-ink-4 tabular-nums`,children:e.count})]},e.value))}):null]})}function nt(e,t){let[n,r]=(0,U.useState)(e);return(0,U.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var rt=60;function it({onUse:e,busy:t,open:n}){let[r,i]=(0,U.useState)(``),[a,s]=(0,U.useState)(He),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(n??null),f=nt(r.trim(),250),m=_e({queryKey:[`marketplace`,k,f,a,c],queryFn:({pageParam:e})=>{let t=new URLSearchParams({lang:k,limit:String(rt),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:J(t,r),icon:n?.(r),count:(h?.facets[e])[r]??0,unavailable:e===`capability`&&ee.has(r)})),ee=new Set(h?.unavailable??[]),b=y(`useCase`,ze),x=[{key:`industry`,name:N(`market.industry`),options:y(`industry`,Re)},{key:`format`,name:N(`market.format`),options:y(`format`,W,e=>(0,q.jsx)(Y,{format:e,className:`size-4 text-ink-3`}))},{key:`capability`,name:N(`market.capability`),options:y(`capability`,G,e=>{let t=Ye[e];return(0,q.jsx)(t,{className:`size-4 text-ink-3`})})}],S=!!r.trim()||c||Object.values(a).some(Boolean),C=()=>{s(He),i(``),l(!1)};if(m.isLoading)return(0,q.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,q.jsx)(A,{className:`size-6 text-ink-3`})});let w=h?.offline?(0,q.jsxs)(`p`,{className:`mt-4 flex items-center justify-center gap-2 text-[13px] text-ink-3`,children:[(0,q.jsx)(Ce,{className:`size-4 shrink-0`}),N(`market.offline`)]}):null;if(!_&&!S)return w;let te=r?(0,q.jsx)(`button`,{type:`button`,"aria-label":N(`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,q.jsx)(P,{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-[12.5px] 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,q.jsxs)(`div`,{children:[(0,q.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,q.jsx)(A,{className:`size-4 shrink-0 text-ink-3`}):(0,q.jsx)(ae,{className:`size-4 shrink-0 text-ink-3`}),(0,q.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:N(`market.search`),"aria-label":N(`market.search`),className:`min-w-0 flex-1 bg-transparent text-[15px] outline-none placeholder:text-ink-4 [&::-webkit-search-cancel-button]:hidden`}),te]}),w,(0,q.jsxs)(`div`,{className:`max-sm:-mx-4 mt-4 flex gap-1 max-sm:overflow-x-auto max-sm:px-4 max-sm:[scrollbar-width:none] sm:flex-wrap sm:justify-center max-sm:[&::-webkit-scrollbar]:hidden`,children:[[{value:``,label:N(`market.all`)},...b].map(e=>(0,q.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,q.jsxs)(`button`,{type:`button`,"aria-pressed":c,onClick:()=>l(!c),className:T(c),children:[(0,q.jsx)(O,{className:j(`size-3.5`,c&&`fill-amber text-amber`)}),N(`market.starred`)]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-1 gap-y-2 sm:mt-6`,children:[c?null:x.map(e=>(0,q.jsx)(tt,{name:e.name,value:a[e.key],options:e.options,onChange:t=>s({...a,[e.key]:t})},e.key)),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-3 whitespace-nowrap pl-2 text-[13px] text-ink-3`,children:[S?(0,q.jsxs)(`button`,{type:`button`,onClick:C,className:`inline-flex items-center gap-1 text-ember-strong underline-offset-2 hover:underline`,children:[(0,q.jsx)(P,{className:`size-3.5 max-sm:size-4`}),(0,q.jsx)(`span`,{className:`max-sm:sr-only`,children:N(`market.resetShort`)})]}):null,S?(0,q.jsx)(`span`,{className:`tabular-nums sm:hidden`,children:N(`market.countOfShort`,{n:h?.total??0,all:_})}):null,(0,q.jsx)(`span`,{className:j(`tabular-nums`,S&&`max-sm:hidden`),children:S?N(`market.countOf`,{n:h?.total??0,all:_}):N(`market.count`,{n:_})})]})]}),g.length?(0,q.jsx)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:g.map(e=>(0,q.jsx)(qe,{entry:e,onOpen:()=>d(e.id)},e.id))}):(0,q.jsxs)(`div`,{className:`py-10 text-center text-[14px] text-ink-3`,children:[(0,q.jsx)(`p`,{children:N(c?`market.noneStarred`:`market.none`)}),(0,q.jsx)(M,{variant:`ghost`,className:`mt-2`,onClick:C,children:N(`market.reset`)})]}),m.hasNextPage?(0,q.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,q.jsx)(M,{variant:`secondary`,busy:m.isFetchingNextPage,onClick:()=>void m.fetchNextPage(),children:N(`market.more`)})}):null,(0,q.jsx)(et,{id:u,fallback:g.find(e=>e.id===u)??null,onClose:()=>d(null),onUse:e,busy:t})]})}var at={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 ot(){let e=l(),t=m(),{project:n}=h(),[i,a]=(0,U.useState)(``),[o]=r(),s=g({mutationFn:e=>p.post(`/api/studio/wizards`,{projectId:n.id,starterId:e,lang:k}),onSuccess:async({id:n},r)=>{await t.invalidateQueries({queryKey:[`projects`]}),await t.invalidateQueries({queryKey:[`wizards`]}),e(r?`/edit/${n}`:`/edit/${n}?prompt=${encodeURIComponent(i.trim())}`)}}),c=()=>{i.trim()&&n&&s.mutate(void 0)};return(0,q.jsxs)(`div`,{className:`animate-rise pt-4`,children:[(0,q.jsxs)(`div`,{className:`mx-auto max-w-2xl`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,q.jsx)(u,{kind:`sprout`,size:150,fluffy:!0}),(0,q.jsx)(`h1`,{className:`mt-2 font-display font-semibold text-[32px] leading-tight tracking-tight sm:text-[38px]`,children:N(`new.title`)})]}),(0,q.jsxs)(`div`,{className:`mt-8 rounded-2xl bg-card p-2 shadow-elevated ring-1 ring-border-soft focus-within:ring-focus`,children:[(0,q.jsx)(ue,{autoFocus:!0,minRows:4,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&c()},placeholder:N(`new.placeholder`),className:`border-0 bg-transparent text-[16px] shadow-none focus:ring-0`}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-1`,children:[(0,q.jsx)(`span`,{className:`hidden text-[12px] text-ink-4 sm:block`,children:N(`new.hint`)}),(0,q.jsxs)(M,{size:`md`,onClick:c,busy:s.isPending&&!s.variables,disabled:!i.trim(),children:[N(`new.build`),` `,(0,q.jsx)(y,{className:`size-4`})]})]})]}),(0,q.jsx)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:at[k].map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`rounded-full bg-paper-2 px-3.5 py-1.5 text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:e},e))})]}),(0,q.jsxs)(`section`,{className:`mx-auto max-w-5xl`,children:[(0,q.jsx)(`h2`,{className:`mt-16 mb-5 text-center font-medium text-[13px] text-ink-3 uppercase tracking-[0.08em]`,children:N(`new.orStarter`)}),(0,q.jsx)(it,{open:o.get(`starter`),busy:s.isPending&&!!s.variables,onUse:e=>n&&!s.isPending&&s.mutate(e.id)}),s.error?(0,q.jsx)(`p`,{className:`mt-3 text-center text-[14px] text-rose`,children:s.error.message}):null]}),(0,q.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,q.jsx)(he,{variant:`ghost`,label:N(`new.import`)})})]})}export{ot as NewWizardPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{O as r,S as i,c as a,d as o,i as s,j as c,k as l,n as u,nt as d,w as f}from"./api-DijQGkp-.js";import{a as p,c as m,o as h,s as g,t as _}from"./session-BerOchdC.js";import{t as v}from"./createLucideIcon-q3MZMmnf.js";import{t as ee}from"./arrow-right-6FyN3e7D.js";import{S as te,_ as ne,b as re,g as ie,m as y,r as ae,x as oe,y as se}from"./outputs-37WFkpRS.js";import{t as b}from"./check-CUpby_J9.js";import{n as x,r as ce,t as le}from"./wand-sparkles-CKxArWPY.js";import{r as ue,t as de}from"./ChatPanel-aQP8iz10.js";import{n as fe,t as S}from"./plus-Du-Jx8aI.js";import{t as C}from"./external-link-MAL7vJYj.js";import{n as pe}from"./mic-Bvz4mA2j.js";import{p as me}from"./definition-DndaH5Ow.js";import{n as he,r as ge,t as _e}from"./type-c_dt5Ne8.js";import{t as ve}from"./upload--J5bZhEM.js";import{_ as ye,c as w,d as T,f as be,h as E,i as D,l as xe,m as O,n as k,o as A,p as Se,r as j,s as M,t as N,u as Ce,y as P}from"./ui-DKc92qJ1.js";import{a as we,c as Te,i as Ee,o as De,r as Oe,s as ke,u as Ae}from"./index-BAObuqzs.js";import{o as je,r as Me,t as Ne}from"./LocalRuntime-DPJMJlWc.js";import{ProjectSwitcher as Pe}from"./HomePage-DUAiS9pg.js";var Fe={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`}]]};Fe.node;var Ie=v(Fe),Le={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Le.node;var Re=v(Le),ze={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};ze.node;var Be=v(ze),Ve={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`}]]};Ve.node;var He=v(Ve),Ue={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ue.node;var We=v(Ue),Ge={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Ge.node;var Ke=v(Ge),qe={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};qe.node;var Je=v(qe),Ye={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`}]]};Ye.node;var Xe=v(Ye),Ze={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`}]]};Ze.node;var Qe=v(Ze),F={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};F.node;var $e=v(F),et={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`]};et.node;var tt=v(et),nt={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`}]]};nt.node;var rt=v(nt),I=e(t(),1),L=e(n(),1);function R({title:e,hint:t,save:n,action:r,children:i}){return(0,L.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),n?.state===`saving`?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-ink-3`,children:[(0,L.jsx)(T,{className:`size-3`}),` `,P(`project.saving`)]}):n?.state===`saved`?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-moss`,children:[(0,L.jsx)(b,{className:`size-3.5`}),` `,P(`settings.saved`)]}):null]}),t?(0,L.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-3 leading-snug`,children:t}):null]}),r?(0,L.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),(0,L.jsxs)(k,{className:`p-5`,children:[i,n?.state===`error`&&n.error?(0,L.jsx)(`p`,{className:`mt-4 text-[14px] text-rose`,children:n.error}):null]})]})}function it({children:e,layout:t,onToggle:n}){return(0,L.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(`div`,{className:`w-56 max-w-full transition-[width] duration-200 focus-within:w-full has-[input:not(:placeholder-shown)]:w-full`,children:e})}),(0,L.jsx)(A,{label:P(t===`list`?`project.viewCards`:`project.viewList`),onClick:n,children:t===`list`?(0,L.jsx)(Ke,{className:`size-4`}):(0,L.jsx)(Je,{className:`size-4`})})]})}function at({value:e,onChange:t,onEnter:n,placeholder:r,busy:i}){return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(ge,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,L.jsx)(`input`,{type:`search`,value:e,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n?.(),className:`h-9 w-full rounded-lg border border-input bg-card pr-3 pl-9 text-[14px] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),i?(0,L.jsx)(T,{className:`-translate-y-1/2 absolute top-1/2 right-3 size-4 text-ink-3`}):null]})}function z({onFiles:e,accept:t,multiple:n=!0,className:r,children:i}){return(0,L.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),e.currentTarget.dataset.over=`1`},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:t=>{t.preventDefault(),delete t.currentTarget.dataset.over;let r=Array.from(t.dataTransfer.files);r.length&&e(n?r:r.slice(0,1))},className:E(`flex cursor-pointer items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[14px] text-ink-3 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow hover:border-ink-4 hover:text-ink data-[over]:border-focus data-[over]:bg-paper-2 data-[over]:text-ink`,r),children:[i,(0,L.jsx)(`input`,{className:`sr-only`,type:`file`,accept:t,multiple:n,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,n.length&&e(n)}})]})}function ot(){let e=Te(),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(null),a=async e=>{n(e??`*`),i(null);try{await ke(e)}catch(e){i(e.message)}finally{n(null)}};return(0,L.jsxs)(R,{title:P(`plugins.title`),hint:e.canReload?P(`plugins.hint`):P(`plugins.hintManaged`),action:e.canReload?(0,L.jsx)(N,{variant:`secondary`,busy:t===`*`,onClick:()=>void a(),children:P(`plugins.rescan`)}):null,children:[(0,L.jsxs)(`ul`,{className:`divide-y divide-border-soft`,children:[e.plugins.map(n=>{let r=e.failed[n.id];return(0,L.jsxs)(`li`,{className:`flex items-start gap-4 py-4 first:pt-0 last:pb-0`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`font-medium text-[15px]`,children:n.name}),n.name===n.id?null:(0,L.jsxs)(`span`,{className:`font-mono text-[12px] text-ink-4`,children:[n.id,` · `,n.version]})]}),n.description?(0,L.jsx)(`p`,{className:`mt-0.5 text-[14px] text-ink-3`,children:n.description}):null,n.tools.length?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[12px] text-ink-3`,children:[P(`plugins.tools`),n.tools.map(e=>(0,L.jsx)(j,{children:e.id},e.id))]}):null,n.error?(0,L.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:P(`plugins.serverFailed`,{error:n.error})}):null,r?(0,L.jsx)(`p`,{className:`mt-2 text-[13px] text-rose`,children:P(`plugins.studioFailed`,{error:r})}):null]}),e.canReload?(0,L.jsx)(A,{label:P(`plugins.reload`),disabled:t!==null,onClick:()=>void a(n.id),children:(0,L.jsx)($e,{className:t===n.id?`size-4 animate-spin`:`size-4`})}):null]},n.id)}),e.problems.map(e=>(0,L.jsxs)(`li`,{className:`py-4 first:pt-0 last:pb-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,L.jsx)(j,{tone:`warn`,children:P(`plugins.problems`)}),(0,L.jsx)(`span`,{className:`break-all font-mono text-[12px] text-ink-3`,children:e.path})]}),(0,L.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:e.message})]},e.path))]}),r?(0,L.jsx)(`p`,{className:`mt-4 text-[13px] text-rose`,children:r}):null]})}var st=e=>[`project-files`,e];function ct(e){return c({queryKey:st(e),queryFn:()=>u.get(`/api/studio/projects/${e}/files`),refetchInterval:e=>e.state.data?.files.some(e=>e.status===`pending`)?2e3:!1})}function B(e,t){return a(`/api/studio/projects/${e}/files/${t}/content`)}function V(e){let t=d(),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(null),o=()=>t.invalidateQueries({queryKey:st(e)}),s=async e=>{a(null);try{await e()}catch(e){a(e.message)}finally{await o()}};return{busy:n,error:i,upload:async(t,n)=>{r(!0),await s(async()=>{for(let r of n)await u.upload(`/api/studio/projects/${e}/files?kind=${t}`,r),await o()}),r(!1)},describe:(t,n)=>s(()=>u.patch(`/api/studio/projects/${e}/files/${t}`,{description:n})),remove:t=>s(()=>u.del(`/api/studio/projects/${e}/files/${t}`)),reindex:t=>s(()=>u.post(`/api/studio/projects/${e}/files/${t}/reindex`)),order:(t,n)=>s(()=>u.put(`/api/studio/projects/${e}/files/order`,{kind:t,ids:n}))}}function lt(e,t){let n=`wz.layout.${e}`,[r,i]=(0,I.useState)(()=>{try{let e=localStorage.getItem(n);return e===`list`||e===`cards`?e:t}catch{return t}});return[r,()=>i(e=>{let t=e===`list`?`cards`:`list`;try{localStorage.setItem(n,t)}catch{}return t})]}function H(e,t,n=700){let[r,i]=(0,I.useState)(`idle`),[a,o]=(0,I.useState)(null),s=JSON.stringify(e),c=(0,I.useRef)(s),l=(0,I.useRef)({value:e,json:s,save:t});l.current={value:e,json:s,save:t};let u=(0,I.useRef)(Promise.resolve()),d=(0,I.useCallback)(()=>{let e=l.current;e.json!==c.current&&(c.current=e.json,i(`saving`),u.current=u.current.then(async()=>{try{await e.save(e.value),o(null),i(`saved`)}catch(e){c.current=``,o(e.message),i(`error`)}}))},[]);return(0,I.useEffect)(()=>{if(s===c.current)return;let e=setTimeout(d,n);return()=>clearTimeout(e)},[s,n,d]),(0,I.useEffect)(()=>d,[d]),{state:r,error:a}}function ut(e){return e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`}var dt=`mt-1.5 text-[13px] text-ink-3`;function ft({me:e}){let t=d(),n=e.mode===`managed`,[r,i]=(0,I.useState)(e.profile),a=e=>i(t=>({...t,...e})),o=H(r,async e=>{await u.put(`/api/studio/profile`,e),await t.invalidateQueries({queryKey:[`me`]})}),s=e.manageUrl?`${e.manageUrl}/account`:e.account?.url??null;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,L.jsx)(R,{title:P(`account.title`),hint:P(`account.hint`),save:o,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,L.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[28px] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,L.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):_(r.name)||`?`}),(0,L.jsx)(`p`,{className:`text-center text-[12px] text-ink-3 leading-snug`,children:P(`account.initials`)})]}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`account.name`)}),(0,L.jsx)(M,{value:r.name,maxLength:80,disabled:n,onChange:e=>a({name:e.target.value})}),(0,L.jsx)(`p`,{className:dt,children:P(n?`account.fromAccount`:`account.nameHint`)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`account.about`)}),(0,L.jsx)(O,{minRows:3,maxLength:2e3,value:r.about,onChange:e=>a({about:e.target.value})}),(0,L.jsx)(`p`,{className:dt,children:P(`account.aboutHint`)})]}),(0,L.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`account.email`)}),(0,L.jsx)(M,{type:`email`,value:r.email,maxLength:200,disabled:n,onChange:e=>a({email:e.target.value})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`account.phone`)}),(0,L.jsx)(M,{type:`tel`,value:r.phone,maxLength:40,onChange:e=>a({phone:e.target.value})})]})]})]})]})}),(0,L.jsx)(R,{title:P(`account.connection`),hint:P(`account.connectionHint`),children:e.mode===`local`&&!e.account?(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,L.jsx)(Be,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`font-medium text-[15px]`,children:P(`account.local`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-3 leading-relaxed`,children:P(`account.localText`)})]})]}):(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium text-[15px]`,children:e.account?.name??e.user.name}),(0,L.jsx)(j,{tone:`live`,children:P(`account.linked`)})]}),(0,L.jsx)(`div`,{className:`truncate text-[14px] text-ink-3`,children:e.account?.email??e.user.email})]}),s?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Me(s),className:`inline-flex h-10 items-center gap-2 rounded-full border border-border bg-card px-4 font-medium text-sm transition hover:bg-paper-2`,children:[P(`setup.openAccount`),` `,(0,L.jsx)(C,{className:`size-4`})]}):null]})}),(0,L.jsx)(R,{title:P(`account.look`),hint:P(`account.lookHint`),children:(0,L.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,L.jsx)(`span`,{className:`font-medium text-[14px]`,children:P(`nav.language`)}),(0,L.jsx)(we,{tone:`surface`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,L.jsx)(`span`,{className:`font-medium text-[14px]`,children:P(`nav.theme`)}),(0,L.jsx)(Oe,{})]})]})})]})}function pt({connector:e}){let[t,n]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-3 px-3 py-2 text-left`,children:[(0,L.jsx)(`span`,{className:E(`size-2 shrink-0 rounded-full`,e.usable?`bg-moss`:`bg-ink-4`)}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:[e.name,` `,(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-ink-4`,children:e.id})]}),(0,L.jsx)(`span`,{className:`shrink-0 text-[12px] text-ink-3`,children:e.usable?P(`connectors.actions`,{n:e.actions.length,r:e.actions.filter(e=>e.group===`read`).length}):P(`connectors.notSetUp`)})]}),t?(0,L.jsxs)(`div`,{className:`border-border-soft border-t px-3 py-2 text-[12px]`,children:[e.missingSetup?(0,L.jsxs)(`p`,{className:`mb-1 text-ink-3`,children:[P(`connectors.setup`),` `,(0,L.jsx)(`span`,{className:`font-mono text-ink-2`,children:e.missingSetup})]}):null,(0,L.jsx)(`p`,{className:`text-ink-4`,children:e.actions.map(e=>e.group===`read`?e.id:`${e.id} (${P(`connectors.group.${e.group}`)})`).join(` · `)})]}):null]})}var mt={none:`connectors.authNone`,oauth2:`connectors.authOauth`,api_key:`connectors.authKey`};function ht({projectId:e,connector:t}){let n=d(),[r,i]=(0,I.useState)(!1),a=()=>n.invalidateQueries({queryKey:[`connectors`,e]}),o=`/api/studio/projects/${e}/connectors/${t.id}`,s=m({mutationFn:()=>u.post(`${o}/refresh`),onSuccess:a}),c=m({mutationFn:()=>u.del(o),onSuccess:a}),l=t.actions.filter(e=>e.group===`read`).length;return(0,L.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,L.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-paper-2 text-ink-2`,children:(0,L.jsx)(Ae,{className:`size-4`})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`min-w-0 flex-1 text-left`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium text-[14px]`,children:t.name}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-ink-4`,children:t.id})]}),(0,L.jsxs)(`div`,{className:`truncate text-[12px] text-ink-3`,children:[t.domain,` · `,t.sourceKind===`mcp`?`MCP`:`OpenAPI`,` ·`,` `,P(mt[t.auth]),` ·`,` `,t.toolsPending?P(`connectors.pending`):P(`connectors.actions`,{n:t.actions.length,r:l})]})]}),(0,L.jsx)(A,{label:P(`connectors.refresh`),onClick:()=>s.mutate(),children:s.isPending?(0,L.jsx)(T,{className:`size-4`}):(0,L.jsx)(me,{className:`size-4`})}),(0,L.jsx)(A,{label:P(`connectors.remove`),className:`hover:text-rose`,onClick:()=>confirm(`${t.name}: ${P(`connectors.remove`)}?`)&&c.mutate(),children:(0,L.jsx)(y,{className:`size-4`})})]}),t.needsOAuthClient?(0,L.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[12px] text-rose`,children:P(`connectors.needsClient`)}):null,s.error?(0,L.jsx)(`p`,{className:`border-border-soft border-t px-3 py-2 text-[12px] text-rose`,children:s.error.message}):null,r&&t.actions.length?(0,L.jsx)(`ul`,{className:`max-h-64 overflow-y-auto border-border-soft border-t px-3 py-2`,children:t.actions.map(e=>(0,L.jsxs)(`li`,{className:`flex items-baseline gap-2 py-1 text-[12px]`,children:[(0,L.jsx)(`span`,{className:E(`w-14 shrink-0 text-[11px] uppercase tracking-wide`,e.group===`read`?`text-moss`:e.group===`write`?`text-ink-3`:`text-rose`),children:P(`connectors.group.${e.group}`)}),(0,L.jsx)(`span`,{className:`shrink-0 font-mono text-ink-2`,children:e.id}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-ink-4`,children:e.summary})]},e.id))}):null]})}function gt({projectId:e,domain:t,source:n,taken:r,onDone:i}){let a=d(),[o,s]=(0,I.useState)({id:``,secret:``}),[c,l]=(0,I.useState)(!1),f=r.includes(n.suggestedId),p=m({mutationFn:()=>u.post(`/api/studio/projects/${e}/connectors`,{domain:t,sourceKind:n.sourceKind,sourceUrl:n.sourceUrl,id:n.suggestedId,toolPrefix:n.suggestedToolPrefix,...n.name?{name:n.name}:{},...o.id&&o.secret?{oauthClientId:o.id,oauthClientSecret:o.secret}:{}}),onSuccess:async t=>{await a.invalidateQueries({queryKey:[`connectors`,e]}),i(t.warnings)}});return(0,L.jsxs)(`div`,{className:`rounded-lg bg-card p-3 ring-1 ring-border-soft`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(j,{tone:n.sourceKind===`mcp`?`ember`:`neutral`,children:n.sourceKind===`mcp`?`MCP`:`OpenAPI`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[13px]`,children:n.name??n.suggestedId}),(0,L.jsx)(`div`,{className:`truncate font-mono text-[11px] text-ink-4`,children:n.sourceUrl})]}),n.blocked||f?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`text-[12px] text-ink-3 hover:text-ink`,children:P(`connectors.ownClient`)}),(0,L.jsx)(N,{size:`sm`,busy:p.isPending,onClick:()=>p.mutate(),children:P(`connectors.import`)})]})]}),n.blocked?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-ink-3`,children:n.blocked}):null,f?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-ink-3`,children:P(`connectors.exists`)}):null,c?(0,L.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[(0,L.jsx)(M,{placeholder:`OAuth Client-ID`,value:o.id,onChange:e=>s(t=>({...t,id:e.target.value}))}),(0,L.jsx)(M,{type:`password`,autoComplete:`off`,placeholder:`OAuth Client-Secret`,value:o.secret,onChange:e=>s(t=>({...t,secret:e.target.value}))})]}):null,p.error?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-rose`,children:p.error.message}):null]})}function _t({projectId:e}){let[t,n]=(0,I.useState)(``),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(null),[s,l]=(0,I.useState)([]),d=c({queryKey:[`connectors`,e],queryFn:()=>u.get(`/api/studio/projects/${e}/connectors`)}),f=m({mutationFn:()=>u.post(`/api/studio/connectors/search`,{query:t}),onSuccess:e=>{i(e),o(null),l([])}}),p=m({mutationFn:e=>u.get(`/api/studio/connectors/registry/${encodeURIComponent(e)}`),onSuccess:o}),h=d.data??[],g=h.filter(e=>e.sourceKind===`builtin`&&(je.unsetConnectors||e.usable)),_=h.filter(e=>e.sourceKind!==`builtin`);return(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:P(`connectors.title`)}),(0,L.jsx)(`p`,{className:`mt-1 mb-5 text-[14px] text-ink-3`,children:P(`connectors.hint`)}),g.length?(0,L.jsx)(`div`,{className:`mb-5 grid gap-1.5 sm:grid-cols-2`,children:g.map(e=>(0,L.jsx)(pt,{connector:e},e.id))}):null,(0,L.jsx)(`h3`,{className:`mb-2 font-medium text-[12px] text-ink-3 uppercase tracking-[0.07em]`,children:P(`connectors.imported`)}),_.length?(0,L.jsx)(`div`,{className:`mb-4 flex flex-col gap-2`,children:_.map(t=>(0,L.jsx)(ht,{projectId:e,connector:t},t.id))}):null,(0,L.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),t.trim()&&f.mutate()},children:[(0,L.jsx)(M,{value:t,placeholder:P(`connectors.search`),onChange:e=>n(e.target.value)}),(0,L.jsxs)(N,{type:`submit`,variant:`secondary`,busy:f.isPending,children:[(0,L.jsx)(ge,{className:`size-4`}),` `,P(`connectors.find`)]})]}),f.error?(0,L.jsx)(`p`,{className:`mt-3 text-[13px] text-rose`,children:f.error.message}):null,r&&!a?(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1`,children:[r.length?null:(0,L.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:P(`connectors.none`)}),r.map(e=>(0,L.jsxs)(`button`,{type:`button`,disabled:!e.kinds.length,onClick:()=>p.mutate(e.domain),className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left transition hover:bg-paper-2 disabled:opacity-50`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[14px]`,children:e.domain}),(0,L.jsx)(`div`,{className:`truncate text-[12px] text-ink-3`,children:e.description})]}),(0,L.jsx)(`span`,{className:`text-[11px] text-ink-4 uppercase`,children:e.kinds.join(` · `)}),(0,L.jsx)(ce,{className:`-rotate-90 size-4 text-ink-4`})]},e.domain)),p.isPending?(0,L.jsx)(T,{className:`mx-auto mt-2 size-4 text-ink-4`}):null,p.error?(0,L.jsx)(`p`,{className:`text-[13px] text-rose`,children:p.error.message}):null]}):null,a?(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`div`,{className:`font-medium text-[14px]`,children:a.domain}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`text-[12px] text-ink-3 hover:text-ink`,children:P(`run.back`)})]}),a.summary?(0,L.jsx)(`p`,{className:`text-[13px] text-ink-3`,children:a.summary}):null,a.sources.map(t=>(0,L.jsx)(gt,{projectId:e,domain:a.domain,source:t,taken:h.map(e=>e.id),onDone:l},`${t.sourceKind}:${t.sourceUrl}`)),a.credentials.filter(e=>e.setup||e.url).map(e=>(0,L.jsxs)(`p`,{className:`text-[12px] text-ink-3`,children:[(0,L.jsxs)(`span`,{className:`text-ink-2`,children:[e.label,`:`]}),` `,e.setup,` `,e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`text-ember underline`,children:e.url}):null]},e.label)),s.map(e=>(0,L.jsx)(`p`,{className:`text-[12px] text-ink-3`,children:e},e))]}):null]})}var vt=[`Claude Code`,`Codex`,`Cursor`,`Gemini CLI`,`claude.ai`],U=`engenty-wizards`,yt=`ENGENTY_WIZARDS_KEY`;function W({text:e}){let[t,n]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg bg-paper-2 p-3`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-[12px] leading-relaxed`,children:e}),(0,L.jsx)(A,{label:P(t?`settings.copied`:`settings.copy`),onClick:async()=>{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},children:t?(0,L.jsx)(b,{className:`size-4`}):(0,L.jsx)(fe,{className:`size-4`})})]})}function bt(e){try{let t=new URL(e);return t.protocol===`https:`&&!/(^|\.)localhost$/.test(t.hostname)&&!/^(127\.|10\.|192\.168\.|\[::1\])/.test(t.hostname)}catch{return!1}}function G({n:e,title:t,children:n}){return(0,L.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-x-3`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-full bg-paper-2 font-semibold text-[13px] text-ink-2 ring-1 ring-border-soft`,children:e}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 pt-0.5 pb-7`,children:[(0,L.jsx)(`h3`,{className:`font-medium text-[15px]`,children:t}),n]})]})}function K({children:e}){return(0,L.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:e})}function xt({client:e,url:t,apiKey:n}){let r=n?`Authorization: Bearer ${n}`:null;switch(e){case`Claude Code`:{let e=t.replace(/\/api\/mcp$/,`/api/claude-plugin`);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.terminal`)}),(0,L.jsx)(W,{text:`claude mcp add --transport http --scope user ${U} ${t}${r?` --header "${r}"`:``}`}),!n&&bt(t)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.ccPlugin`)}),(0,L.jsx)(W,{text:`claude plugin marketplace add ${e}/marketplace.json`}),(0,L.jsx)(W,{text:`claude plugin install ${U}@engenty`})]}):null]})}case`Codex`:return n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.codexKey`)}),(0,L.jsx)(W,{text:`echo 'export ${yt}=${n}' >> ~/.zshrc && source ~/.zshrc`}),(0,L.jsx)(W,{text:`codex mcp add ${U} --url ${t} --bearer-token-env-var ${yt}`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.terminal`)}),(0,L.jsx)(W,{text:`codex mcp add ${U} --url ${t}`}),(0,L.jsx)(W,{text:`codex mcp login ${U}`})]});case`Cursor`:return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.cursor`)}),(0,L.jsx)(W,{text:JSON.stringify({mcpServers:{[U]:n?{url:t,headers:{Authorization:`Bearer ${n}`}}:{url:t}}},null,2)})]});case`Gemini CLI`:return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.terminal`)}),(0,L.jsx)(W,{text:`gemini mcp add --scope user --transport http ${U} ${t}${r?` -H "${r}"`:``}`})]});case`claude.ai`:return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.claudeAi`)}),(0,L.jsx)(W,{text:t})]})}}function St(){let e=d(),t=c({queryKey:[`api-keys`],queryFn:()=>u.get(`/api/studio/api-keys`)}),n=m({mutationFn:e=>u.del(`/api/studio/api-keys/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:[`api-keys`]})});return t.data?.length?(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:P(`mcp.keys`)}),(0,L.jsx)(`p`,{className:`mt-1 mb-5 text-[14px] text-ink-3`,children:P(`mcp.keysHint`)}),(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.data.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-paper px-3 py-2 ring-1 ring-border-soft`,children:[(0,L.jsx)(We,{className:`size-4 shrink-0 text-ink-4`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[14px]`,children:e.name}),(0,L.jsxs)(`div`,{className:`font-mono text-[11px] text-ink-4`,children:[e.start,`… ·`,` `,e.lastRequest?P(`settings.lastUsed`,{when:new Date(e.lastRequest).toLocaleString()}):P(`settings.neverUsed`)]})]}),(0,L.jsx)(A,{label:P(`settings.revoke`),onClick:()=>n.mutate(e.id),className:`hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]},e.id))})]}):null}function Ct(){let e=g(),t=d(),[n,r]=(0,I.useState)(`Claude Code`),[i,a]=(0,I.useState)({}),o=m({mutationFn:e=>u.post(`/api/studio/api-keys`,{name:e}),onSuccess:async e=>{a(t=>({...t,[n]:e.key})),await t.invalidateQueries({queryKey:[`api-keys`]})}});if(!e.data)return null;let s=e.data.mode===`managed`,c=e.data.mcpUrl??``,l=bt(c),f=i[n],p=n===`claude.ai`&&!(s&&l),h=1;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:P(`mcp.title`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-2`,children:P(`mcp.lead`)}),(0,L.jsxs)(`div`,{className:`my-6 flex flex-wrap items-center gap-3 text-[14px]`,children:[(0,L.jsx)(`span`,{className:`rounded-full bg-paper-2 px-3.5 py-1.5 ring-1 ring-border-soft`,children:P(`mcp.yourClient`)}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[12px] text-ink-3`,children:[`MCP `,(0,L.jsx)(ee,{className:`size-4`})]}),(0,L.jsx)(`span`,{className:`rounded-full bg-ember-tint px-3.5 py-1.5 font-medium text-ember-strong`,children:`engenty wizards`})]}),(0,L.jsx)(`h3`,{className:`font-medium text-[14px]`,children:P(`mcp.canTitle`)}),(0,L.jsxs)(`ul`,{className:`mt-2 flex list-disc flex-col gap-1 pl-5 text-[14px] text-ink-2`,children:[(0,L.jsx)(`li`,{children:P(`mcp.can1`)}),(0,L.jsx)(`li`,{children:P(`mcp.can2`)}),(0,L.jsx)(`li`,{children:P(`mcp.can3`)}),(0,L.jsx)(`li`,{children:P(`mcp.can4`)})]}),(0,L.jsx)(`p`,{className:`mt-5 text-[13px] text-ink-3`,children:P(`mcp.notReverse`)})]}),(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`mb-6 font-display font-semibold text-lg`,children:P(`mcp.setup`)}),(0,L.jsxs)(`ol`,{className:`flex flex-col`,children:[(0,L.jsx)(G,{n:h++,title:P(`mcp.pick`),children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsx)(xe,{value:n,onChange:r,options:[...vt]})})}),p?(0,L.jsx)(G,{n:h++,title:P(`mcp.notHere`),children:(0,L.jsx)(K,{children:P(s?`mcp.needsPublic`:`mcp.claudeAiLocal`)})}):(0,L.jsxs)(L.Fragment,{children:[s?null:(0,L.jsx)(G,{n:h++,title:P(`mcp.keyTitle`),children:f?(0,L.jsxs)(`p`,{className:`flex items-center gap-2 text-[14px] text-ink-2`,children:[(0,L.jsx)(b,{className:`size-4 text-moss`}),` `,P(`mcp.keyReady`)]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{children:P(`mcp.keyHint`)}),(0,L.jsx)(`div`,{children:(0,L.jsxs)(N,{variant:`secondary`,busy:o.isPending,onClick:()=>o.mutate(n),children:[(0,L.jsx)(S,{className:`size-4`}),` `,P(`mcp.keyCreate`,{client:n})]})})]})}),(0,L.jsxs)(G,{n:h++,title:P(`mcp.add`),children:[s||f?(0,L.jsx)(xt,{client:n,url:c,apiKey:f}):(0,L.jsx)(K,{children:P(`mcp.keyFirst`)}),s?(0,L.jsx)(K,{children:P(`mcp.oauth`)}):null]}),(0,L.jsxs)(G,{n:h++,title:P(`mcp.try`),children:[(0,L.jsx)(K,{children:P(`mcp.tryHint`)}),(0,L.jsx)(W,{text:P(`mcp.tryPrompt`)})]})]})]}),(0,L.jsxs)(`div`,{className:`border-border-soft border-t pt-5`,children:[(0,L.jsx)(`h3`,{className:`font-medium text-[14px]`,children:P(`mcp.address`)}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(W,{text:c})}),(0,L.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3`,children:P(l?`mcp.addressPublic`:`mcp.addressLocal`)})]})]}),s?(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:P(`mcp.keys`)}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-[14px] text-ink-3`,children:P(`setup.keysInAccount`)}),(0,L.jsx)(`div`,{children:(0,L.jsx)(N,{variant:`secondary`,onClick:()=>window.open(`${e.data?.manageUrl}/account`,`_blank`,`noopener`),children:P(`setup.openAccount`)})})]}):(0,L.jsx)(St,{})]})}function wt(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}function Tt(e,t){let n=d(),[r,i]=(0,I.useState)([]),[a,o]=(0,I.useState)(`idle`),[c,l]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),g=(0,I.useRef)(null),_=()=>(g.current??=(async()=>{await Promise.all([n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`project-files`,e]})]),t(),g.current=null})(),g.current);return{messages:r,phase:a,activity:f,startedAt:m,error:c,send:async(t,c=[])=>{if(!(t.trim()||c.length)||a!==`idle`)return!1;if(l(null),o(`thinking`),h(Date.now()),c.length){try{for(let t of c)await u.upload(`/api/studio/projects/${e}/files?kind=${wt(t)}`,t)}catch(e){return l(e.message),o(`idle`),h(null),await _(),!1}await _();let n=`${P(`editor.attached`)}: ${c.map(e=>e.name).join(`, `)}`;t=t.trim()?`${t}\n\n${n}`:n}let d=r.map(({role:e,content:t})=>({role:e,content:t})).slice(-12),f=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:t,previews:ue(c)},{id:f,role:`assistant`,content:``,pending:!0}]),p(null);let m=!1;try{await s(`/api/studio/projects/${e}/assist`,{message:t,history:d},(e,t)=>{if(e===`text`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:t.content+e}:t))}else if(e===`activity`)p(JSON.parse(t));else if(e===`changed`)o(`building`),_();else if(e===`done`){m=!0;let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:e.reply,changed:e.changed,pending:!1}:t))}else e===`error`&&(m=!0,l(JSON.parse(t).message))}),m||l(P(`editor.chatBroken`))}catch(e){l(e.message)}finally{p(null),h(null),i(e=>e.filter(e=>!(e.id===f&&!e.content)).map(e=>({...e,pending:!1}))),o(`idle`),await g.current,await _(),await n.invalidateQueries({queryKey:[`me`]})}return!0}}}function Et(){return(0,L.jsxs)(`div`,{className:`sm:pr-36`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-tight tracking-tight`,children:P(`project.assistantTitle`)}),(0,L.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[15px] text-ink-2 leading-relaxed`,children:P(`project.assistantHello`)})]})}var Dt=72,Ot=720;function kt({projectId:e,onChanged:t}){let n=Tt(e,t),r=(0,I.useRef)(null),[i,a]=(0,I.useState)(null);return(0,I.useEffect)(()=>{let e=()=>{let e=r.current?.getBoundingClientRect();e&&a(t=>{if(e.bottom>=Dt)return null;let n=Math.min(e.width,Ot),r=e.left+(e.width-n)/2;return t&&t.left===r&&t.width===n?t:{left:r,width:n,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)}},[]),(0,L.jsxs)(`div`,{ref:r,style:i?{minHeight:i.height}:void 0,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 px-1 font-medium text-[12px] text-ember-strong uppercase tracking-[0.07em]`,children:[(0,L.jsx)(ie,{className:`size-3.5`}),` `,P(`project.assistant`)]}),(0,L.jsxs)(`div`,{className:`relative`,children:[!i&&n.messages.length===0?(0,L.jsx)(`div`,{className:`absolute -top-14 right-10 z-10 max-sm:hidden`,children:(0,L.jsx)(o,{kind:`round`,size:104})}):null,(0,L.jsx)(`div`,{className:E(`flex flex-col overflow-hidden bg-card`,i?`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:i?{left:i.left,width:i.width}:void 0,children:(0,L.jsx)(de,{chat:n,avatar:`round`,compact:!!i,intro:(0,L.jsx)(Et,{}),placeholder:P(`project.assistantComposer`),changedLabel:P(`project.assistantChanged`)})})]})]})}var At=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],jt=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Mt=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,Nt=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Pt=/^(https?:\/\/|www\.)\S+$/i,Ft=/^\+?[\d\s()/.-]{7,20}$/,It=/^(ja|nein|yes|no|true|false)$/i;function Lt(e){let t=e.trim();return t?t.includes(`
|
|
2
|
-
`)||t.length>140?`longtext`:It.test(t)?`boolean`:Nt.test(t)?`email`:Pt.test(t)?`url`:jt.test(t)?`date`:Mt.test(t)&&!/^(\+|0\d)/.test(t)?`number`:Ft.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function Rt(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 zt=[{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`}],q={facts:100,colors:12,files:{logo:8,asset:100,document:50},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},J=/^#[0-9a-fA-F]{6}$/;function Bt({onAdd:e,onClose:t}){let[n,r]=(0,I.useState)(`#e0531b`),[i,a]=(0,I.useState)(``),o=J.test(n);return(0,L.jsx)(D,{open:!0,onClose:t,title:P(`project.colorAddTitle`),children:(0,L.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`project.colorValue`)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(be,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,L.jsx)(M,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[14px]`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`project.colorUseLabel`)}),(0,L.jsx)(M,{autoFocus:!0,value:i,maxLength:120,placeholder:P(`project.colorName`),onChange:e=>a(e.target.value)}),(0,L.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:P(`project.colorUse`)})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(N,{variant:`ghost`,onClick:t,children:P(`common.cancel`)}),(0,L.jsx)(N,{type:`submit`,disabled:!o,children:P(`project.add`)})]})]})})}function Vt({colors:e,save:t}){let n=(0,I.useRef)(0),[r,i]=(0,I.useState)(()=>e.map(e=>({...e,id:`c${n.current++}`}))),[a,o]=(0,I.useState)(!1),s=H(r.filter(e=>J.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),c=(e,t)=>i(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,L.jsxs)(R,{title:P(`project.colors`),hint:P(`project.colorsHint`),save:s,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(be,{value:J.test(e.value)?e.value:`#888888`,onChange:t=>c(e.id,{value:t.target.value})}),(0,L.jsx)(M,{value:e.name,placeholder:P(`project.colorName`),maxLength:120,onChange:t=>c(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,L.jsx)(M,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>c(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[13px]`}),(0,L.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,L.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,L.jsx)(j,{tone:`ember`,children:P(`project.colorAccent`)})}):(0,L.jsx)(A,{label:P(`project.colorFirst`),onClick:()=>i(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,L.jsx)(te,{className:`size-4`})}),(0,L.jsx)(A,{label:P(`project.remove`),onClick:()=>i(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]})]},e.id))}),r.length?(0,L.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:P(`project.colorUse`)}):null,r.length<q.colors?(0,L.jsxs)(N,{variant:`secondary`,size:`sm`,className:r.length?`mt-3`:void 0,onClick:()=>o(!0),children:[(0,L.jsx)(S,{className:`size-4`}),` `,P(`project.colorAdd`)]}):null,a?(0,L.jsx)(Bt,{onClose:()=>o(!1),onAdd:e=>i(t=>[...t,{...e,id:`c${n.current++}`}])}):null]})}var Ht={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Y({file:e,actions:t}){let[n,r]=(0,I.useState)(e.description),i=(0,I.useRef)(e.description),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,I.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return(0,L.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:P(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-[13px] 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 X(e,t){confirm(P(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Z({projectId:e,file:t,small:n}){let r=B(e,t.id);return t.mime.startsWith(`image/`)?(0,L.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:E(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,L.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,L.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,L.jsx)(Xe,{className:n?`size-5`:`size-7`}):(0,L.jsx)(oe,{className:n?`size-5`:`size-7`})})}function Ut({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:o}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,L.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,L.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,L.jsx)(j,{tone:`ember`,children:P(`project.logoMain`)})}):null,(0,L.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Ht:void 0,children:[o&&i.mime.startsWith(`image/`)?(0,L.jsx)(`button`,{type:`button`,"aria-label":`${P(`project.preview`)}: ${i.name}`,onClick:()=>o(i),className:`block size-full cursor-zoom-in`,children:(0,L.jsx)(Z,{projectId:e,file:i})}):(0,L.jsx)(Z,{projectId:e,file:i}),(0,L.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,L.jsx)(A,{label:P(`project.preview`),onClick:()=>o(i),className:`size-8 bg-card shadow-soft`,children:(0,L.jsx)(x,{className:`size-4`})}):null,t===`logo`&&a>0?(0,L.jsx)(A,{label:P(`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,L.jsx)(he,{className:`size-4`})}):null,(0,L.jsx)(A,{label:P(`project.remove`),onClick:()=>X(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]})]}),t===`asset`?(0,L.jsx)(`div`,{className:`truncate px-0.5 text-[12px] text-ink-3`,title:i.name,children:i.name}):null,(0,L.jsx)(Y,{file:i,actions:r})]},i.id)),a?(0,L.jsxs)(z,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,L.jsx)(T,{className:`size-5`}):(0,L.jsx)(S,{className:`size-5`}),a]}):null]})}function Wt({projectId:e,data:t}){let n=V(e);return(0,L.jsxs)(R,{title:P(`project.logos`),hint:P(`project.logosHint`),children:[(0,L.jsx)(Ut,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:n,accept:`image/*`,addLabel:P(`project.logoAdd`)}),n.error?(0,L.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:n.error}):null]})}var Gt=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),ut(e.size)].filter(Boolean).join(` · `);function Kt({projectId:e,file:t,actions:n,onClose:r}){let i=B(e,t.id);return(0,L.jsxs)(D,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,L.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`text-[13px] text-ink-3`,children:Gt(t)}),(0,L.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":P(`project.openOriginal`),title:P(`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,L.jsx)(C,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,L.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Ht,children:(0,L.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,L.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,L.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(Y,{file:t,actions:n})})]})}function qt({projectId:e,file:t,actions:n,onPreview:r}){return(0,L.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":`${P(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,L.jsx)(Z,{projectId:e,file:t,small:!0})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[14px] hover:underline`,children:t.name}),(0,L.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:Gt(t)})]}),(0,L.jsx)(Y,{file:t,actions:n})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,L.jsx)(A,{label:P(`project.preview`),onClick:r,children:(0,L.jsx)(x,{className:`size-4`})}),(0,L.jsx)(A,{label:P(`project.remove`),onClick:()=>X(t,n),className:`hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]})]})}function Jt({projectId:e,data:t}){let n=V(e),[r,i]=lt(`assets`,`cards`),[a,o]=(0,I.useState)(``),[s,c]=(0,I.useState)(null),l=t.files.filter(e=>e.kind===`asset`),u=l.find(e=>e.id===s),d=a.trim().toLowerCase(),f=d?l.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(d)):l;return(0,L.jsxs)(R,{title:P(`project.assets`),hint:P(`project.assetsHint`),children:[l.length?(0,L.jsx)(it,{layout:r,onToggle:i,children:(0,L.jsx)(at,{value:a,onChange:o,placeholder:P(`project.assetSearch`)})}):null,f.length?(0,L.jsx)(`div`,{className:`mb-3`,children:r===`cards`?(0,L.jsx)(Ut,{projectId:e,kind:`asset`,files:f,actions:n,onPreview:e=>c(e.id)}):(0,L.jsx)(`ul`,{className:`flex flex-col gap-2`,children:f.map(t=>(0,L.jsx)(qt,{projectId:e,file:t,actions:n,onPreview:()=>c(t.id)},t.id))})}):null,(0,L.jsxs)(z,{accept:`image/*,video/*,audio/*`,onFiles:e=>n.upload(`asset`,e),className:`h-16 w-full`,children:[n.busy?(0,L.jsx)(T,{className:`size-4`}):(0,L.jsx)(ve,{className:`size-4`}),P(`project.drop`),` `,(0,L.jsx)(`span`,{className:`underline`,children:P(`project.assetAdd`)})]}),n.error?(0,L.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:n.error}):null,u?(0,L.jsx)(Kt,{projectId:e,file:u,actions:n,onClose:()=>c(null)}):null]})}function Yt(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 Xt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var Q=e=>[Xt(e),e.pages?P(`project.pages`,{n:e.pages}):null,ut(e.size)].filter(Boolean).join(` · `);function $({file:e}){return e.status===`pending`?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-ink-3`,children:[(0,L.jsx)(T,{className:`size-3`}),` `,P(`project.reading`)]}):e.status===`failed`?(0,L.jsx)(`span`,{className:`text-[12px] text-rose`,children:e.error}):e.indexed?(0,L.jsx)(j,{tone:`live`,children:e.indexed===`embeddings`?P(`project.indexed`):P(`project.indexedKeywords`)}):(0,L.jsx)(j,{tone:`warn`,children:P(`project.notIndexed`)})}function Zt({file:e,actions:t,onPreview:n}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{label:P(`project.preview`),onClick:n,children:(0,L.jsx)(x,{className:`size-4`})}),e.status===`pending`?null:(0,L.jsx)(A,{label:P(`project.reindex`),onClick:()=>t.reindex(e.id),children:(0,L.jsx)(me,{className:`size-4`})}),(0,L.jsx)(A,{label:P(`project.remove`),onClick:()=>X(e,t),className:`hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]})}function Qt({file:e,actions:t,onPreview:n}){let r=/sheet|csv|excel/.test(e.mime);return(0,L.jsxs)(`li`,{className:`flex gap-3 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 text-ink-3`,children:r?(0,L.jsx)(Re,{className:`size-5`}):(0,L.jsx)(pe,{className:`size-5`})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,title:e.name,className:`min-w-0 truncate font-medium text-[14px] hover:underline`,children:e.name}),(0,L.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:Q(e)}),(0,L.jsx)($,{file:e})]}),(0,L.jsx)(Y,{file:e,actions:t})]}),(0,L.jsx)(`div`,{className:`-my-1 flex shrink-0 items-start`,children:(0,L.jsx)(Zt,{file:e,actions:t,onPreview:n})})]})}function $t({projectId:e,file:t}){let n=Yt(e,t,1500);return t.mime.startsWith(`image/`)?(0,L.jsx)(`img`,{src:B(e,t.id),alt:``,className:`size-full object-cover`}):t.status===`pending`||n.isLoading?(0,L.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-4`,children:(0,L.jsx)(T,{className:`size-5`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`w-[222%] origin-top-left scale-[0.45] p-6`,children:(0,L.jsx)(ae,{text:n.data?.text??``})}),(0,L.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-12 bg-linear-to-t from-card to-transparent`})]})}function en({projectId:e,file:t,actions:n,onPreview:r}){return(0,L.jsxs)(`li`,{className:`group flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`${P(`project.preview`)}: ${t.name}`,className:`relative block h-44 w-full overflow-hidden rounded-md bg-card text-left ring-1 ring-border-soft transition hover:ring-border`,children:(0,L.jsx)($t,{projectId:e,file:t})}),(0,L.jsx)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100 [&>button]:size-8 [&>button]:bg-card [&>button]:shadow-soft`,children:(0,L.jsx)(Zt,{file:t,actions:n,onPreview:r})})]}),(0,L.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1 px-0.5`,children:[(0,L.jsx)(`div`,{className:`truncate font-medium text-[13px]`,title:t.name,children:t.name}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,L.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:Q(t)}),(0,L.jsx)($,{file:t})]})]}),(0,L.jsx)(Y,{file:t,actions:n})]})}var tn=2e5;function nn({projectId:e,file:t,onClose:n}){let r=t.mime===`application/pdf`||t.mime.startsWith(`image/`),[i,a]=(0,I.useState)(r?`original`:`text`),o=Yt(e,t,tn),s=B(e,t.id),c=(e,t)=>(0,L.jsx)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>a(e),className:E(`h-8 rounded-full px-3 text-[13px] transition`,i===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,L.jsxs)(D,{open:!0,onClose:n,wide:`page`,title:t.name,children:[(0,L.jsxs)(`div`,{className:`-mt-2 mb-4 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,L.jsx)(`span`,{className:`text-[13px] text-ink-3`,children:Q(t)}),(0,L.jsx)($,{file:t}),(0,L.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[r?(0,L.jsxs)(L.Fragment,{children:[c(`original`,P(`project.original`)),c(`text`,P(`project.readText`))]}):null,(0,L.jsx)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,"aria-label":P(`project.openOriginal`),title:P(`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,L.jsx)(C,{className:`size-4`})})]})]}),i===`original`?t.mime===`application/pdf`?(0,L.jsx)(`iframe`,{src:s,title:t.name,className:`h-[70dvh] w-full rounded-lg bg-paper-2 ring-1 ring-border-soft`}):(0,L.jsx)(`img`,{src:s,alt:``,className:`mx-auto max-h-[70dvh] rounded-lg object-contain`}):o.isLoading?(0,L.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,L.jsx)(T,{})}):o.data?.text?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-lg bg-paper p-5 ring-1 ring-border-soft`,children:(0,L.jsx)(ae,{text:o.data.text,className:`text-[14px]`})}),o.data.chars>o.data.text.length?(0,L.jsx)(`p`,{className:`mt-3 text-[13px] text-ink-3`,children:P(`project.textCut`,{shown:o.data.text.length.toLocaleString(),total:o.data.chars.toLocaleString()})}):null]}):(0,L.jsx)(`p`,{className:`py-8 text-center text-[14px] text-ink-3`,children:P(`project.noText`)})]})}function rn({projectId:e}){let[t,n]=(0,I.useState)(``),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!1),s=async()=>{if(!t.trim()){i(null);return}o(!0);try{let n=await u.post(`/api/studio/projects/${e}/search`,{query:t});i(n.hits)}catch{i([])}finally{o(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(at,{value:t,placeholder:P(`project.searchTest`),busy:a,onEnter:()=>void s(),onChange:e=>{n(e),e.trim()||i(null)}}),r?r.length?(0,L.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2`,children:r.map((e,t)=>(0,L.jsxs)(`li`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[13px]`,children:[(0,L.jsx)(`div`,{className:`mb-0.5 font-medium text-[12px] text-ink-3`,children:e.name}),(0,L.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-line text-ink-2`,children:e.text})]},t))}):(0,L.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3`,children:P(`project.searchNone`)}):null]})}function an({projectId:e,data:t}){let n=V(e),[r,i]=lt(`documents`,`list`),[a,o]=(0,I.useState)(null),s=t.files.filter(e=>e.kind===`document`),c=s.find(e=>e.id===a),l=r===`cards`?en:Qt;return(0,L.jsxs)(R,{title:P(`project.documents`),hint:P(`project.documentsHint`),children:[s.length?(0,L.jsx)(it,{layout:r,onToggle:i,children:(0,L.jsx)(rn,{projectId:e})}):null,s.length?(0,L.jsx)(`ul`,{className:E(`mb-3`,r===`cards`?`grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-3`:`flex flex-col gap-2`),children:s.map(t=>(0,L.jsx)(l,{projectId:e,file:t,actions:n,onPreview:()=>o(t.id)},t.id))}):null,(0,L.jsxs)(z,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:e=>n.upload(`document`,e),className:`h-16 w-full`,children:[n.busy?(0,L.jsx)(T,{className:`size-4`}):(0,L.jsx)(ve,{className:`size-4`}),P(`project.drop`),` `,(0,L.jsx)(`span`,{className:`underline`,children:P(`project.documentAdd`)})]}),n.error?(0,L.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:n.error}):null,s.length&&!t.embeddings?(0,L.jsx)(`p`,{className:`mt-3 text-[13px] text-ink-3`,children:P(`project.keywordsOnly`)}):null,c?(0,L.jsx)(nn,{projectId:e,file:c,onClose:()=>o(null)}):null]})}var on=e=>/^(ja|yes|true)$/i.test(e.trim()),sn={text:_e,longtext:tt,number:He,date:Ie,url:re,email:se,phone:Qe,boolean:rt};function cn({type:e,detected:t,onChange:n}){let[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null);(0,I.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=`${P(`project.factType`)}: ${P(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[14px] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,L.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,L.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:E(`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,L.jsx)(c,{className:`size-4`})}),r?(0,L.jsxs)(`div`,{role:`menu`,className:E(`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,L.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,L.jsx)(le,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`flex-1`,children:P(`project.factAuto`)}),(0,L.jsx)(`span`,{className:`text-[12px] text-ink-4`,children:P(`project.type.${t}`)}),(0,L.jsx)(b,{className:E(`size-4 shrink-0`,e&&`invisible`)})]}),(0,L.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),At.map(t=>{let n=sn[t];return(0,L.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,L.jsx)(n,{className:`size-4 shrink-0`}),(0,L.jsx)(`span`,{className:`flex-1`,children:P(`project.type.${t}`)}),(0,L.jsx)(b,{className:E(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function ln({facts:e,save:t}){let n=(0,I.useRef)(0),r=(0,I.useRef)(null),[i,a]=(0,I.useState)(()=>e.map(e=>({...e,id:`f${n.current++}`}))),o=H(i.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),s=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n)),c=(e,t,i=!1)=>{let o=`f${n.current++}`;r.current=`${o}:${t}`;let s={id:o,key:``,label:``,value:``,...e};a(e=>i?[s,...e]:[...e,s])},l=e=>t=>{t&&r.current===e&&(r.current=null,t.focus())},u=zt.filter(e=>!i.some(t=>t.key===e.key));return(0,L.jsxs)(R,{title:P(`project.facts`),hint:P(`project.factsHint`),save:o,action:i.length<q.facts?(0,L.jsxs)(N,{variant:`secondary`,size:`sm`,onClick:()=>c({},`label`,!0),children:[(0,L.jsx)(S,{className:`size-4`}),` `,P(`project.factAdd`)]}):null,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>{let t=Lt(e.value),n=e.type??t;return(0,L.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,L.jsx)(M,{ref:l(`${e.id}:label`),value:e.label,placeholder:P(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>s(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&s(e.id,{key:Rt(e.label,i.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,L.jsx)(Se,{checked:on(e.value),label:e.label,onChange:t=>s(e.id,{value:P(t?`project.yes`:`project.no`)})}),(0,L.jsx)(`span`,{className:`text-[14px] text-ink-2`,children:on(e.value)?P(`project.yes`):P(`project.no`)})]}):(0,L.jsx)(O,{ref:l(`${e.id}:value`),rows:1,minRows:n===`longtext`?2:1,maxRows:10,value:e.value,placeholder:P(`project.factValue`),onChange:t=>s(e.id,{value:t.target.value}),className:`min-h-11`}),(0,L.jsx)(cn,{type:e.type,detected:t,onChange:t=>s(e.id,{type:t})}),(0,L.jsx)(A,{label:P(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})})]},e.id)})}),i.length<q.facts?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${i.length?`mt-4`:``}`,children:[(0,L.jsxs)(N,{variant:`secondary`,size:`sm`,onClick:()=>c({},`label`),children:[(0,L.jsx)(S,{className:`size-4`}),` `,P(`project.factAdd`)]}),u.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c({key:e.key,label:ye===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,L.jsx)(S,{className:`size-3.5`}),` `,ye===`en`?e.en:e.de]},e.key))]}):null]})}function un({project:e,save:t}){let[n,r]=(0,I.useState)(e.brand.name??``),[i,a]=(0,I.useState)(e.brand.about??``),o=H({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,L.jsx)(R,{title:P(`project.base`),hint:P(`project.baseHint`),save:o,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`project.title`)}),(0,L.jsx)(M,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,L.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:P(`project.titleHint`)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(w,{children:P(`project.about`)}),(0,L.jsx)(O,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,L.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:P(`project.aboutHint`)})]})]})})}function dn({project:e,save:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(e.name),o=m({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{label:P(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,L.jsx)(ne,{className:`size-4`})}),(0,L.jsx)(D,{open:n,onClose:()=>r(!1),title:P(`project.rename`),children:(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,L.jsx)(M,{autoFocus:!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,L.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:o.error.message}):null,(0,L.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,L.jsx)(N,{variant:`ghost`,onClick:()=>r(!1),children:P(`common.cancel`)}),(0,L.jsx)(N,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:P(`settings.save`)})]})]})})]})}function fn({project:e}){let t=d(),n=ct(e.id),[r,i]=(0,I.useState)(0),a=async n=>{await u.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})},o=m({mutationFn:()=>u.del(`/api/studio/projects/${e.id}`),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),s=h(),c=n.data??{files:[],embeddings:!0},l=`${e.id}:${r}`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[s?(0,L.jsxs)(`div`,{className:`-mb-3 flex items-center gap-1`,children:[(0,L.jsx)(Pe,{}),(0,L.jsx)(dn,{project:e,save:a})]}):null,(0,L.jsx)(kt,{projectId:e.id,onChanged:()=>i(e=>e+1)},e.id),(0,L.jsx)(un,{project:e,save:a},`base:${l}`),(0,L.jsx)(Wt,{projectId:e.id,data:c}),(0,L.jsx)(Vt,{colors:e.brand.colors??[],save:e=>a({brand:{colors:e}})},`colors:${l}`),(0,L.jsx)(Jt,{projectId:e.id,data:c}),(0,L.jsx)(an,{projectId:e.id,data:c}),(0,L.jsx)(ln,{facts:e.facts,save:e=>a({facts:e})},`facts:${l}`),s?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(N,{variant:`danger`,busy:o.isPending,onClick:()=>confirm(`${P(`settings.delete`)}?`)&&o.mutate(),children:P(`settings.delete`)}),o.error?(0,L.jsx)(`p`,{className:`mt-2 text-[14px] text-rose`,children:o.error.message}):null]}):null]})}function pn(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/^[^a-z]+/,``).slice(0,24)||`system`,r=n,i=2;for(;t.includes(r);)r=`${n}_${i++}`;return r}function mn({project:e}){let t=d(),[n,r]=(0,I.useState)(e.mcpServers.map(e=>({...e,auth:e.headers?.Authorization??e.headers?.authorization??``}))),[i,a]=(0,I.useState)(!1),o=m({mutationFn:()=>u.patch(`/api/studio/projects/${e.id}`,{mcpServers:n.filter(e=>e.name&&e.url).map(({auth:e,headers:t,...n})=>({...n,headers:e?{...t,Authorization:e}:void 0}))}),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`projects`]}),a(!0),setTimeout(()=>a(!1),1800)}});return(0,L.jsxs)(k,{className:`p-6`,children:[(0,L.jsx)(`h2`,{className:`font-display font-semibold text-lg`,children:P(`settings.mcp`)}),(0,L.jsx)(`p`,{className:`mt-1 mb-5 text-[14px] text-ink-3`,children:P(`settings.mcpHint`)}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.map((e,t)=>(0,L.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft sm:grid-cols-[1fr_2fr_auto]`,children:[(0,L.jsx)(M,{placeholder:P(`settings.serverName`),value:e.name,onChange:e=>r(n=>n.map((r,i)=>i===t?{...r,name:e.target.value,id:r.id||pn(e.target.value,n.map(e=>e.id))}:r))}),(0,L.jsx)(M,{placeholder:`${P(`settings.serverUrl`)} (https://…/mcp)`,value:e.url,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,url:e.target.value}:n))}),(0,L.jsx)(A,{label:`Entfernen`,onClick:()=>r(e=>e.filter((e,n)=>n!==t)),className:`hover:text-rose`,children:(0,L.jsx)(y,{className:`size-4`})}),(0,L.jsx)(M,{className:`sm:col-span-2`,placeholder:P(`settings.serverHeader`),value:e.auth??``,onChange:e=>r(n=>n.map((n,r)=>r===t?{...n,auth:e.target.value}:n))}),e.id?(0,L.jsx)(`span`,{className:`self-center font-mono text-[11px] text-ink-4`,children:e.id}):null]},t)),(0,L.jsxs)(N,{variant:`secondary`,className:`self-start`,onClick:()=>r(e=>[...e,{id:``,name:``,url:``,auth:``}]),children:[(0,L.jsx)(S,{className:`size-4`}),` `,P(`settings.addServer`)]})]}),(0,L.jsxs)(`div`,{className:`mt-5 flex items-center justify-end gap-3`,children:[o.error?(0,L.jsx)(`p`,{className:`text-[14px] text-rose`,children:o.error.message}):null,(0,L.jsx)(N,{busy:o.isPending,onClick:()=>o.mutate(),children:P(i?`settings.saved`:`settings.save`)})]})]})}function hn(){let{section:e}=l(),t=r(),n=g(),{project:a}=p(),o=h(),[s,c]=(0,I.useState)(a?.id);(0,I.useEffect)(()=>c(a?.id),[a?.id]);let u=Te(),d=Ee(n.data,u),m=d.find(t=>t.id===e);if(!m)return u.status===`ready`?(0,L.jsx)(f,{to:`/settings/project`,replace:!0}):null;let _=m.id===`connectors`&&o;return(0,L.jsxs)(`div`,{className:`animate-rise`,children:[(0,L.jsx)(`h1`,{className:`font-display font-semibold text-[28px] tracking-tight`,children:P(`settings.title`)}),(0,L.jsxs)(`div`,{className:`mt-6 grid gap-6 md:mt-8 md:grid-cols-[200px_minmax(0,1fr)] md:gap-10`,children:[(0,L.jsx)(`nav`,{className:`max-md:hidden`,children:(0,L.jsx)(`ul`,{className:`sticky top-24 flex flex-col gap-0.5`,children:d.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(i,{to:`/settings/${e.id}`,"aria-current":e.id===m.id?`page`:void 0,className:E(`block rounded-lg px-3 py-2 text-[14px] transition`,e.id===m.id?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:bg-accent hover:text-ink`),children:e.label})},e.id))})}),(0,L.jsx)(Ce,{className:`md:hidden`,value:m.id,onChange:e=>t(`/settings/${e}`),options:d.map(e=>({value:e.id,label:e.label}))}),(0,L.jsxs)(`div`,{className:E(`min-w-0`,m.id!==`project`&&`max-w-2xl`),children:[_?(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsx)(Pe,{})}):null,m.id===`project`&&a?(0,L.jsx)(fn,{project:a},s):null,m.id===`connectors`&&a?(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(_t,{projectId:a.id},s),(0,L.jsx)(mn,{project:a},s)]}):null,m.id===`models`?(0,L.jsx)(Ne,{}):null,m.id===`build`?(0,L.jsx)(Ct,{}):null,m.id===`account`&&n.data?(0,L.jsx)(ft,{me:n.data}):null,m.id===`plugins`?(0,L.jsx)(ot,{}):null,m.plugin?(0,L.jsx)(De,{of:m.plugin,children:(0,L.jsx)(m.plugin.component,{})}):null]})]})]})}export{hn as SettingsPage};
|