wizards 0.2.27 → 0.2.28
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/mcp/tools.js +2 -0
- package/apps/runtime/dist/routes/marketplace.js +2 -1
- package/apps/runtime/dist/services/marketplace.js +35 -4
- package/apps/web/dist/assets/Account-CVMSZTCv.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-BdZ1SmEd.js → ChangelogDialog-3N1CgtWP.js} +1 -1
- package/apps/web/dist/assets/{CreditsDialog-fOYdoev3.js → CreditsDialog-BW-RETl-.js} +1 -1
- package/apps/web/dist/assets/EditorPage-DnuHM3nW.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-U2AEnKlX.js → FlowPreview-Ds6ul7-N.js} +1 -1
- package/apps/web/dist/assets/{Harness-CtDlm_2b.js → Harness-D-QoXcSe.js} +1 -1
- package/apps/web/dist/assets/HomePage-Ch0HlwVX.js +1 -0
- package/apps/web/dist/assets/{ImportWizard-BMPGjd_t.js → ImportWizard-DVcYcB6l.js} +1 -1
- package/apps/web/dist/assets/LocalRuntime-D7bzT40S.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-DvA6AX7D.js +2 -0
- package/apps/web/dist/assets/{ProjectPage-_LAtG3tn.js → ProjectPage-BWAISSfX.js} +2 -2
- package/apps/web/dist/assets/PublicRunner-D2bd95TR.js +1 -0
- package/apps/web/dist/assets/{RunDrawer-CtQoY3Ha.js → RunDrawer-DkOCgXAR.js} +3 -3
- package/apps/web/dist/assets/RunnerView-DF5uW_95.js +2 -0
- package/apps/web/dist/assets/SettingsPage-CMTGFXit.js +1 -0
- package/apps/web/dist/assets/SetupPage-BaT-VqIc.js +1 -0
- package/apps/web/dist/assets/SharePage-COKOsuvD.js +1 -0
- package/apps/web/dist/assets/arrow-right-hy38IBRU.js +1 -0
- package/apps/web/dist/assets/changelog-C8wFW63z.js +1 -0
- package/apps/web/dist/assets/{circle-alert-BC6xmJ9r.js → circle-alert-BG9P3ewL.js} +1 -1
- package/apps/web/dist/assets/definition-BiUSuZN5.js +1 -0
- package/apps/web/dist/assets/{esm-FEWi61F_.js → esm-0rdZWuyu.js} +1 -1
- package/apps/web/dist/assets/{external-link-wKL1HE6G.js → external-link-BwCtn1nW.js} +1 -1
- package/apps/web/dist/assets/{image-BMdSChOR.js → image-DG4q2P1H.js} +1 -1
- package/apps/web/dist/assets/index-DHM9S48l.js +78 -0
- package/apps/web/dist/assets/{lock-BpqzLMuv.js → lock-DH_BntP_.js} +1 -1
- package/apps/web/dist/assets/{meta-BqZ7SlZz.js → meta-DI0ahJ_z.js} +1 -1
- package/apps/web/dist/assets/{pen-line-DM-u0dES.js → pen-line-B1dsy3Sr.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-Bk7HkOIM.js → refresh-cw-B9M1g3SH.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-BM_NfZfn.js → settings-menu-DOjgaq6J.js} +1 -1
- package/apps/web/dist/assets/{star-JHzYYl5R.js → star-axQV_3EC.js} +1 -1
- package/apps/web/dist/assets/surface-BE-3Z1DP.js +56 -0
- package/apps/web/dist/assets/{trash-CdLg-Ela.js → trash-3S1_XpVa.js} +1 -1
- package/apps/web/dist/assets/{ui-8QmvuC9u.js → ui-BZ01zr3i.js} +1 -1
- package/apps/web/dist/assets/{upload-CL1R6shM.js → upload-U0i8fAW3.js} +1 -1
- package/apps/web/dist/assets/{video-BioLmXNO.js → video-Db4o719f.js} +1 -1
- package/apps/web/dist/assets/{volume-2-_IOfPNCv.js → volume-2-6f7qN_LM.js} +1 -1
- package/apps/web/dist/assets/{wand-sparkles-DYtDQSJZ.js → wand-sparkles-MelvBtiK.js} +1 -1
- package/apps/web/dist/index.html +3 -3
- package/apps/web/dist/mcp/flow.html +1 -1
- package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +4 -1
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +38 -1
- package/node_modules/@engenty-wizards/shared/dist/marketplace.js +27 -0
- package/package.json +1 -1
- package/apps/web/dist/assets/Account-DW396ig5.js +0 -1
- package/apps/web/dist/assets/EditorPage-CAARFsaI.js +0 -3
- package/apps/web/dist/assets/HomePage-Bd-mkLxW.js +0 -1
- package/apps/web/dist/assets/LocalRuntime-DjSNCRnV.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-DZPcDR9i.js +0 -2
- package/apps/web/dist/assets/PublicRunner-6Iqp0DmU.js +0 -1
- package/apps/web/dist/assets/RunnerView-BLOCNZaZ.js +0 -2
- package/apps/web/dist/assets/SettingsPage-Z6skBf6I.js +0 -1
- package/apps/web/dist/assets/SetupPage-4-Lic4pT.js +0 -1
- package/apps/web/dist/assets/SharePage-DfdhXxZm.js +0 -1
- package/apps/web/dist/assets/arrow-right-BOtqnsA1.js +0 -1
- package/apps/web/dist/assets/brand-CCAI9p0f.js +0 -2
- package/apps/web/dist/assets/changelog-DQM0oz9S.js +0 -1
- package/apps/web/dist/assets/definition-D5V79jHA.js +0 -1
- package/apps/web/dist/assets/index-YJMooz0J.js +0 -132
|
@@ -85,13 +85,15 @@ export function matchesFilters(e, f) {
|
|
|
85
85
|
e.industries.includes(f.industry) ||
|
|
86
86
|
(f.industry !== "any" && e.industries.includes("any"))) &&
|
|
87
87
|
(!f.format || e.formats.includes(f.format)) &&
|
|
88
|
-
(!f.capability || e.capabilities.includes(f.capability))
|
|
88
|
+
(!f.capability || e.capabilities.includes(f.capability)) &&
|
|
89
|
+
(!f.plan || (e.plan ?? "free") === f.plan));
|
|
89
90
|
}
|
|
90
91
|
const FACETS = {
|
|
91
92
|
useCase: (e) => e.useCases,
|
|
92
93
|
industry: (e) => e.industries,
|
|
93
94
|
format: (e) => e.formats,
|
|
94
95
|
capability: (e) => e.capabilities,
|
|
96
|
+
plan: (e) => [e.plan ?? "free"],
|
|
95
97
|
};
|
|
96
98
|
/**
|
|
97
99
|
* Per option of each filter, the found entries it would leave with the other filters as they
|
|
@@ -103,6 +105,7 @@ function facetsOf(all, found, filters) {
|
|
|
103
105
|
industry: {},
|
|
104
106
|
format: {},
|
|
105
107
|
capability: {},
|
|
108
|
+
plan: {},
|
|
106
109
|
};
|
|
107
110
|
for (const key of Object.keys(FACETS)) {
|
|
108
111
|
const options = new Set(all.flatMap(FACETS[key]));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WizardDefinition } from "./definition.js";
|
|
2
2
|
/**
|
|
3
3
|
* The marketplace: wizards anyone can start from. What an entry is sorted by — formats, industry,
|
|
4
4
|
* use case — and what follows from its definition: the AI capabilities it needs, how much a
|
|
@@ -196,14 +196,34 @@ export declare const COST_TIERS: {
|
|
|
196
196
|
};
|
|
197
197
|
};
|
|
198
198
|
export type CostTier = keyof typeof COST_TIERS;
|
|
199
|
+
/**
|
|
200
|
+
* The plan a wizard needs. Free runs on what every runtime has; Pro needs plugins, which come
|
|
201
|
+
* with the Pro and Team plans of engenty.ai.
|
|
202
|
+
*/
|
|
203
|
+
export declare const MARKETPLACE_PLANS: {
|
|
204
|
+
free: {
|
|
205
|
+
de: string;
|
|
206
|
+
en: string;
|
|
207
|
+
};
|
|
208
|
+
pro: {
|
|
209
|
+
de: string;
|
|
210
|
+
en: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
export type MarketplacePlan = keyof typeof MARKETPLACE_PLANS;
|
|
199
214
|
export declare const ITEM_FORMAT_IDS: ("text" | "image" | "audio" | "video" | "document" | "dashboard" | "table")[];
|
|
200
215
|
export declare const INDUSTRY_IDS: ("any" | "trades" | "gastronomy" | "hospitality" | "realEstate" | "retail" | "health" | "professional" | "agency" | "events" | "publicSector")[];
|
|
201
216
|
export declare const USE_CASE_IDS: ("marketing" | "sales" | "accounting" | "service" | "research" | "hr" | "operations" | "website" | "visuals" | "inquiries" | "advice")[];
|
|
202
217
|
export declare const CAPABILITY_IDS: ("code" | "text" | "image" | "browser" | "video" | "speech" | "film" | "web" | "documents" | "listening" | "connectors")[];
|
|
218
|
+
export declare const MARKETPLACE_PLAN_IDS: ("free" | "pro")[];
|
|
203
219
|
/** The formats a run hands over, read from what the result step offers. */
|
|
204
220
|
export declare function formatsOf(def: WizardDefinition): ItemFormat[];
|
|
205
221
|
/** The capabilities a definition needs, read from its steps. */
|
|
206
222
|
export declare function capabilitiesOf(def: WizardDefinition): Capability[];
|
|
223
|
+
/** The plugins a definition's steps use, by id: a runtime without one of them cannot run it. */
|
|
224
|
+
export declare function pluginsOf(def: WizardDefinition): string[];
|
|
225
|
+
/** The plan a wizard needs: Pro as soon as it uses a plugin. */
|
|
226
|
+
export declare const planOf: (plugins: readonly string[]) => MarketplacePlan;
|
|
207
227
|
/** What a person does in a run, and about how long the whole run takes. */
|
|
208
228
|
export interface Effort {
|
|
209
229
|
/** Fields to fill in, the required ones of them. */
|
|
@@ -249,6 +269,18 @@ export interface MarketplaceSummary {
|
|
|
249
269
|
steps: number;
|
|
250
270
|
/** The definition version the entry's wizard is written in (`DEFINITION_VERSION`). */
|
|
251
271
|
version: number;
|
|
272
|
+
/**
|
|
273
|
+
* The plugins its wizard uses, by id (`pluginsOf`). A marketplace older than this field leaves
|
|
274
|
+
* it out: read it as none.
|
|
275
|
+
*/
|
|
276
|
+
plugins?: string[];
|
|
277
|
+
/** The plan it needs (`planOf`); left out by an older marketplace: free. */
|
|
278
|
+
plan?: MarketplacePlan;
|
|
279
|
+
/**
|
|
280
|
+
* The plugin's own starter this entry shows in the catalog, `<plugin id>.<starter id>`: a
|
|
281
|
+
* runtime with that plugin lists the plugin's starter instead.
|
|
282
|
+
*/
|
|
283
|
+
pluginStarter?: string;
|
|
252
284
|
}
|
|
253
285
|
/** What a search narrows by, besides its words. */
|
|
254
286
|
export interface MarketplaceFilters {
|
|
@@ -256,6 +288,7 @@ export interface MarketplaceFilters {
|
|
|
256
288
|
industry?: Industry;
|
|
257
289
|
format?: ItemFormat;
|
|
258
290
|
capability?: Capability;
|
|
291
|
+
plan?: MarketplacePlan;
|
|
259
292
|
}
|
|
260
293
|
/** Per option of a filter: the entries it would leave, with the other filters as they are. */
|
|
261
294
|
export interface MarketplaceFacets {
|
|
@@ -264,6 +297,8 @@ export interface MarketplaceFacets {
|
|
|
264
297
|
format: Partial<Record<ItemFormat, number>>;
|
|
265
298
|
/** Optional: a marketplace older than this filter leaves it out. */
|
|
266
299
|
capability?: Partial<Record<Capability, number>>;
|
|
300
|
+
/** Optional: a marketplace older than this filter leaves it out. */
|
|
301
|
+
plan?: Partial<Record<MarketplacePlan, number>>;
|
|
267
302
|
}
|
|
268
303
|
/** A page of a search: the entries, best first, how many there are, and the filters' counts. */
|
|
269
304
|
export interface MarketplacePage<T extends MarketplaceSummary = MarketplaceSummary> {
|
|
@@ -319,4 +354,6 @@ export interface MarketplaceEntry extends MarketplaceSummary {
|
|
|
319
354
|
id: string;
|
|
320
355
|
name: string;
|
|
321
356
|
};
|
|
357
|
+
/** The plugins it needs that this app does not have: a wizard made from it would not run. */
|
|
358
|
+
needs?: string[];
|
|
322
359
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pluginToolOf } from "./definition.js";
|
|
1
2
|
/**
|
|
2
3
|
* The marketplace: wizards anyone can start from. What an entry is sorted by — formats, industry,
|
|
3
4
|
* use case — and what follows from its definition: the AI capabilities it needs, how much a
|
|
@@ -63,11 +64,20 @@ export const COST_TIERS = {
|
|
|
63
64
|
medium: { de: "mittel", en: "medium cost" },
|
|
64
65
|
high: { de: "teuer", en: "high cost" },
|
|
65
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* The plan a wizard needs. Free runs on what every runtime has; Pro needs plugins, which come
|
|
69
|
+
* with the Pro and Team plans of engenty.ai.
|
|
70
|
+
*/
|
|
71
|
+
export const MARKETPLACE_PLANS = {
|
|
72
|
+
free: { de: "Kostenlos", en: "Free" },
|
|
73
|
+
pro: { de: "Pro", en: "Pro" },
|
|
74
|
+
};
|
|
66
75
|
const keys = (o) => Object.keys(o);
|
|
67
76
|
export const ITEM_FORMAT_IDS = keys(ITEM_FORMATS);
|
|
68
77
|
export const INDUSTRY_IDS = keys(INDUSTRIES);
|
|
69
78
|
export const USE_CASE_IDS = keys(USE_CASES);
|
|
70
79
|
export const CAPABILITY_IDS = keys(CAPABILITIES);
|
|
80
|
+
export const MARKETPLACE_PLAN_IDS = keys(MARKETPLACE_PLANS);
|
|
71
81
|
const FORMAT_OF = {
|
|
72
82
|
pdf: "document",
|
|
73
83
|
docx: "document",
|
|
@@ -164,6 +174,23 @@ export function capabilitiesOf(def) {
|
|
|
164
174
|
}
|
|
165
175
|
return CAPABILITY_IDS.filter((c) => found.has(c));
|
|
166
176
|
}
|
|
177
|
+
/** The plugins a definition's steps use, by id: a runtime without one of them cannot run it. */
|
|
178
|
+
export function pluginsOf(def) {
|
|
179
|
+
const found = new Set();
|
|
180
|
+
for (const step of def.steps) {
|
|
181
|
+
if (step.type === "agent") {
|
|
182
|
+
for (const tool of step.tools) {
|
|
183
|
+
const of = pluginToolOf(tool);
|
|
184
|
+
if (of) {
|
|
185
|
+
found.add(of.plugin);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [...found].sort();
|
|
191
|
+
}
|
|
192
|
+
/** The plan a wizard needs: Pro as soon as it uses a plugin. */
|
|
193
|
+
export const planOf = (plugins) => plugins.length ? "pro" : "free";
|
|
167
194
|
const WORK_SECONDS = { agent: 25, tools: 70, browser: 150, image: 30, video: 120, voice: 20 };
|
|
168
195
|
export function effortOf(def) {
|
|
169
196
|
let fields = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wizards",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{R as r,p as i}from"./brand-CCAI9p0f.js";import{D as a,G as o,H as s,c,f as l,g as u,h as d,j as f,k as p,n as m,o as h,r as g,s as _,t as v,x as y}from"./ui-8QmvuC9u.js";import{n as b,r as x}from"./upload-CL1R6shM.js";import{t as S}from"./external-link-wKL1HE6G.js";import{J as ee,Q as te,_t as C,et as w,kt as T,nt as E,tt as D,wt as O}from"./index-YJMooz0J.js";import{n as k}from"./LocalRuntime-DjSNCRnV.js";var A={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`}]]};A.node;var j=o(A),M={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`}]]};M.node;var N=o(M),P={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`}]]};P.node;var F=o(P),I=e(t(),1),L=e=>[`project-files`,e];function R(e){return i({queryKey:L(e),queryFn:()=>y.get(`/api/studio/projects/${e}/files`),refetchInterval:e=>e.state.data?.files.some(e=>e.status===`pending`)?2e3:!1})}function z(e,t){return a(`/api/studio/projects/${e}/files/${t}/content`)}function B(e,t=!1){let n=r(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=()=>n.invalidateQueries({queryKey:L(e)}),l=async e=>{s(null);try{await e()}catch(e){s(e.message)}finally{await c()}};return{busy:i,error:o,readOnly:t,upload:async(t,n)=>{a(!0),await l(async()=>{for(let r of n)await y.upload(`/api/studio/projects/${e}/files?kind=${t}`,r),await c()}),a(!1)},describe:(t,n)=>l(()=>y.patch(`/api/studio/projects/${e}/files/${t}`,{description:n})),remove:t=>l(()=>y.del(`/api/studio/projects/${e}/files/${t}`)),reindex:t=>l(()=>y.post(`/api/studio/projects/${e}/files/${t}/reindex`)),order:(t,n)=>l(()=>y.put(`/api/studio/projects/${e}/files/order`,{kind:t,ids:n}))}}function V(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 U(e){return e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`}var W=e(n(),1);function G({id:e,children:t}){return(0,W.jsx)(`div`,{id:e,className:`scroll-mt-24 max-md:scroll-mt-36`,children:t})}function K({title:e,hint:t,save:n,action:r,locked:i,plain:a,children:o}){return(0,W.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),n?.state===`saving`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,W.jsx)(l,{className:`size-3`}),` `,f(`project.saving`)]}):n?.state===`saved`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-moss`,children:[(0,W.jsx)(s,{className:`size-3.5`}),` `,f(`settings.saved`)]}):null]}),t?(0,W.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-snug`,children:t}):null]}),r?(0,W.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),a?o:(0,W.jsxs)(m,{className:`p-3.5 sm:p-5`,children:[i?(0,W.jsx)(`fieldset`,{disabled:!0,className:`min-w-0`,children:o}):o,n?.state===`error`&&n.error?(0,W.jsx)(`p`,{className:`mt-4 text-[0.875rem] text-rose`,children:n.error}):null]})]})}function q({children:e,layout:t,onToggle:n}){return(0,W.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.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,W.jsx)(h,{label:f(t===`list`?`project.viewCards`:`project.viewList`),onClick:n,children:t===`list`?(0,W.jsx)(N,{className:`size-4`}):(0,W.jsx)(F,{className:`size-4`})})]})}function J({value:e,onChange:t,onEnter:n,placeholder:r,busy:i}){return(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(b,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,W.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-[0.875rem] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),i?(0,W.jsx)(l,{className:`-translate-y-1/2 absolute top-1/2 right-3 size-4 text-ink-3`}):null]})}function Y({onFiles:e,accept:t,multiple:n=!0,className:r,children:i}){return(0,W.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:u(`flex cursor-pointer items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] 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,W.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)}})]})}var X=`mt-1.5 text-[0.8125rem] text-ink-3`;function Z(e){let t=r(),[n,i]=(0,I.useState)(!1),a=T({mutationFn:e=>y.post(`/api/studio/account/link`,e),onSuccess:({url:e})=>{k(e),i(!0)}});return(0,I.useEffect)(()=>{if(!n)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),r=setTimeout(()=>i(!1),3e5);return()=>{clearInterval(e),clearTimeout(r)}},[n,t]),(0,I.useEffect)(()=>{e&&i(!1)},[e]),{link:a,waiting:n}}function Q({link:e,waiting:t}){return e.isError?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:f(`local.accountFailed`)}):t?(0,W.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.8125rem] text-ink-3`,children:[(0,W.jsx)(l,{className:`size-3.5`}),` `,f(`local.accountWaiting`)]}):null}function ne(){let e=Z(!1),{link:t}=e,[n,r]=(0,I.useState)(``);return(0,W.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-4 py-5 first:pt-0 last:pb-0`,children:[(0,W.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,W.jsx)(j,{className:`size-5`})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:f(`account.local`)}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:f(`account.localText`)})]})]}),D.account?(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 py-5 last:pb-0`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:f(`account.with`)}),(0,W.jsxs)(`ul`,{className:`mt-2 flex flex-col gap-2 text-[0.875rem] text-ink-2 leading-snug`,children:[(0,W.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,W.jsx)(x,{className:`mt-0.5 size-4 shrink-0 text-amber`}),f(`account.withCredits`)]}),(0,W.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,W.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),f(`account.withCloud`)]})]})]}),(0,W.jsx)(`div`,{children:(0,W.jsx)(v,{busy:t.isPending&&!t.variables?.signup,onClick:()=>t.mutate({}),children:f(`account.signIn`)})})]}):null,D.account?(0,W.jsxs)(`form`,{className:`flex flex-col gap-3 py-5 last:pb-0`,onSubmit:e=>{e.preventDefault(),t.mutate({signup:!0,code:n.trim()||void 0})},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:f(`account.new`)}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.875rem] text-ink-3 leading-relaxed`,children:f(`account.newHint`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(_,{value:n,maxLength:64,autoComplete:`off`,spellCheck:!1,placeholder:f(`account.code`),"aria-label":f(`account.code`),onChange:e=>r(e.target.value),className:`w-56 font-mono text-[0.875rem]`}),(0,W.jsx)(v,{type:`submit`,variant:`secondary`,className:`h-11`,busy:t.isPending&&!!t.variables?.signup,children:f(`account.create`)})]}),(0,W.jsx)(Q,{...e})]}):null]})}var $={start:`account.kind.start`,monthly:`account.kind.monthly`,gift:`account.kind.gift`};function re({account:e}){let t=r(),n=Z(e.signedIn),i=T({mutationFn:()=>y.del(`/api/studio/account`),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})}),a=new Intl.DateTimeFormat(p,{dateStyle:`medium`});return(0,W.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 py-5 first:pt-0`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.name||e.email}),e.signedIn?(0,W.jsx)(g,{tone:`live`,children:f(`account.linked`)}):null]}),(0,W.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.email})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(v,{variant:`secondary`,onClick:()=>k(e.url),children:[f(`setup.openAccount`),` `,(0,W.jsx)(S,{className:`size-4`})]}),(0,W.jsxs)(v,{variant:`ghost`,busy:i.isPending,onClick:()=>i.mutate(),children:[(0,W.jsx)(C,{className:`size-4`}),` `,f(`nav.logout`)]})]})]}),e.signedIn?null:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 py-5`,children:[(0,W.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:f(`local.accountExpired`)}),(0,W.jsx)(`div`,{children:(0,W.jsx)(v,{busy:n.link.isPending,onClick:()=>n.link.mutate({}),children:f(`account.signInAgain`)})}),(0,W.jsx)(Q,{...n})]}),e.credits===null?null:(0,W.jsxs)(`div`,{className:`py-5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:f(`account.credits`)}),(0,W.jsx)(`div`,{className:`font-display font-semibold text-[1.375rem] tabular-nums leading-tight`,children:f(`nav.credits`,{n:Math.floor(e.credits).toLocaleString()})})]}),(0,W.jsxs)(v,{variant:`secondary`,onClick:()=>k(`${e.url}/billing`),children:[f(`account.topUp`),` `,(0,W.jsx)(S,{className:`size-4`})]})]}),e.expiring.length?(0,W.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.expiring.map(e=>(0,W.jsxs)(`li`,{children:[f(`account.expires`,{n:Math.floor(e.credits).toLocaleString(),date:a.format(new Date(e.expiresAt))}),$[e.kind]?(0,W.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,f($[e.kind])]}):null]},`${e.kind}:${e.expiresAt}`))}):null]}),(0,W.jsxs)(`div`,{className:`flex items-start gap-2.5 py-5 text-[0.875rem] text-ink-2 leading-snug last:pb-0`,children:[(0,W.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),(0,W.jsx)(`p`,{children:f(`account.cloud`,{host:ee(e.cloudUrl)})})]})]})}function ie({me:e,fromAccount:t}){let n=r(),[i,a]=(0,I.useState)(e.profile),o=e=>a(t=>({...t,...e})),s=H(i,async e=>{await y.put(`/api/studio/profile`,e),await n.invalidateQueries({queryKey:[`me`]})});return(0,W.jsx)(K,{title:f(`account.profile`),hint:f(`account.hint`),save:s,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,W.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[1.75rem] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,W.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):E(i.name)||`?`}),(0,W.jsx)(`p`,{className:`text-center text-[0.75rem] text-ink-3 leading-snug`,children:f(`account.initials`)})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(c,{children:f(`account.name`)}),(0,W.jsx)(_,{value:i.name,maxLength:80,disabled:t,onChange:e=>o({name:e.target.value})}),(0,W.jsx)(`p`,{className:X,children:f(t?`account.fromAccount`:`account.nameHint`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(c,{children:f(`account.about`)}),(0,W.jsx)(d,{minRows:3,maxLength:2e3,value:i.about,onChange:e=>o({about:e.target.value})}),(0,W.jsx)(`p`,{className:X,children:f(`account.aboutHint`)})]}),(0,W.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(c,{children:f(`account.email`)}),(0,W.jsx)(_,{type:`email`,value:i.email,maxLength:200,disabled:t,onChange:e=>o({email:e.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(c,{children:f(`account.phone`)}),(0,W.jsx)(_,{type:`tel`,value:i.phone,maxLength:40,onChange:e=>o({phone:e.target.value})})]})]})]})]})})}function ae({me:e}){let t=e.mode===`managed`,n=t||!!e.account;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,W.jsx)(K,{title:f(`account.connection`),hint:f(`account.connectionHint`),children:t?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium text-[0.9375rem]`,children:e.user.name}),(0,W.jsx)(g,{tone:`live`,children:f(`account.linked`)})]}),(0,W.jsx)(`div`,{className:`truncate text-[0.875rem] text-ink-3`,children:e.user.email})]}),e.manageUrl?(0,W.jsxs)(v,{variant:`secondary`,onClick:()=>k(`${e.manageUrl}/account`),children:[f(`setup.openAccount`),` `,(0,W.jsx)(S,{className:`size-4`})]}):null]}):e.account?(0,W.jsx)(re,{account:e.account}):(0,W.jsx)(ne,{})}),(0,W.jsx)(ie,{me:e,fromAccount:n},n?`account`:`own`),(0,W.jsx)(K,{title:f(`account.look`),hint:f(`account.lookHint`),children:(0,W.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:f(`nav.language`)}),(0,W.jsx)(w,{tone:`surface`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,W.jsx)(`span`,{className:`font-medium text-[0.875rem]`,children:f(`nav.theme`)}),(0,W.jsx)(te,{})]})]})})]})}export{Y as a,K as c,H as d,B as f,N as h,G as i,U as l,R as m,Q as n,q as o,V as p,Z as r,J as s,ae as t,z as u};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{R as r,p as i,r as a}from"./brand-CCAI9p0f.js";import{$ as o,B as s,D as c,F as l,G as u,H as d,U as f,V as p,W as m,a as h,b as g,c as _,d as v,et as y,f as b,g as x,h as S,i as C,j as w,k as T,l as ee,m as E,o as D,q as te,r as O,s as k,t as A,tt as ne,u as j,x as M,z as re}from"./ui-8QmvuC9u.js";import{n as ie,o as ae,t as oe}from"./RunnerView-BLOCNZaZ.js";import{a as N,c as se,i as ce,n as P,o as le,r as ue,t as F}from"./meta-BqZ7SlZz.js";import{n as de,o as fe,r as pe,s as me,t as he}from"./RunDrawer-CtQoY3Ha.js";import{t as ge}from"./circle-alert-BC6xmJ9r.js";import{t as I}from"./image-BMdSChOR.js";import{t as _e}from"./upload-CL1R6shM.js";import{t as ve}from"./external-link-wKL1HE6G.js";import{r as ye,t as be}from"./wand-sparkles-DYtDQSJZ.js";import{n as xe,r as Se}from"./Account-DW396ig5.js";import{t as L}from"./trash-CdLg-Ela.js";import{t as Ce}from"./lock-BpqzLMuv.js";import{t as we}from"./refresh-cw-Bk7HkOIM.js";import{Ct as R,Dt as z,Et as Te,J as B,U as Ee,W as De,X as V,Y as Oe,Z as ke,bt as Ae,d as je,dt as Me,g as Ne,ht as Pe,it as Fe,kt as Ie,l as Le,mt as H,p as Re,q as ze,r as Be,rt as Ve,tt as He,u as Ue,ut as We,vt as Ge,wt as Ke,xt as qe,yt as Je}from"./index-YJMooz0J.js";import{a as Ye,b as Xe,c as Ze,d as Qe,f as $e,g as et,i as tt,l as nt,n as rt,p as it,r as at,s as ot,t as st,u as ct,v as lt}from"./definition-D5V79jHA.js";import{a as ut,c as dt,i as ft,l as pt,o as mt,r as ht,s as gt,t as _t}from"./esm-FEWi61F_.js";import{n as vt}from"./LocalRuntime-DjSNCRnV.js";var yt={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};yt.node;var bt=u(yt),xt={name:`cloud-check`,size:24,node:[[`path`,{d:`m17 15-5.5 5.5L9 18`,key:`15q87x`}],[`path`,{d:`M5.516 16.07A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 3.501 7.327`,key:`1xtj56`}]]};xt.node;var St=u(xt),Ct={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`]};Ct.node;var wt=u(Ct),Tt={name:`code-xml`,size:24,node:[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],aliases:[`code-2`]};Tt.node;var Et=u(Tt),Dt={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};Dt.node;var Ot=u(Dt),kt={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`]};kt.node;var At=u(kt),jt={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`]};jt.node;var Mt=u(jt),Nt={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`}]]};Nt.node;var Pt=u(Nt),Ft={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};Ft.node;var It=u(Ft),Lt={name:`message-circle`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]};Lt.node;var Rt=u(Lt),zt={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};zt.node;var Bt=u(zt),Vt={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`}]]};Vt.node;var Ht=u(Vt),Ut={name:`qr-code`,size:24,node:[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]};Ut.node;var Wt=u(Ut),Gt={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`}]]};Gt.node;var Kt=u(Gt),U=e(t(),1),W=e(n(),1),qt=[`auto`,`page`,`agent`,`generate`,`surface`,`widget`],Jt=[`page`,`agent`,`generate`,`widget`],Yt={auto:H,page:Ge,agent:se,generate:I,surface:le,widget:z},Xt=e=>w(e===`auto`?`addStep.auto`:`type.${e}`);function Zt(e,t){let n=e.steps[t-1],r=e.steps[t];return n&&r?w(`addStep.between`,{before:n.title,after:r.title}):n?w(`addStep.after`,{title:n.title}):w(`addStep.first`,{title:r?.title??``})}function Qt(e,{at:t,kind:n,prompt:r,when:i}){let a=Zt(e,t);return`${n===`auto`?w(`addStep.message`,{place:a}):w(`addStep.messageAs`,{place:a,kind:Xt(n)})}${i?`\n${w(i.mode===`if`?`addStep.messageIf`:`addStep.messageAsk`,{text:i.text.trim(),from:e.steps[t-1]?.title??``})}`:``}\n${r.trim()}`}function $t({place:e,branchable:t,onAdd:n,onEmpty:r,onCancel:i}){let[a,o]=(0,U.useState)(`auto`),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(!1),[m,h]=(0,U.useState)(`always`),[g,_]=(0,U.useState)(``),v=(0,U.useRef)(null);(0,U.useEffect)(()=>v.current?.focus(),[]);let y=()=>{if(!s.trim()){u(w(`addStep.empty`));return}if(m!==`always`&&!g.trim()){u(w(`addStep.whenEmpty`));return}n(a,s,m===`always`?void 0:{mode:m,text:g})||u(w(`addStep.busy`))};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-border`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-[0.875rem]`,children:w(`addStep.title`)}),(0,W.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:e})]}),(0,W.jsx)(S,{ref:v,minRows:3,maxRows:10,"aria-label":w(`addStep.title`),placeholder:w(`addStep.placeholder`),value:s,onChange:e=>{c(e.target.value),u(null)},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),y()):e.key===`Escape`&&i()}}),l?(0,W.jsx)(`p`,{className:`-mt-1.5 text-[0.75rem] text-rose`,children:l}):null,(0,W.jsx)(`fieldset`,{className:`flex flex-wrap gap-1.5`,"aria-label":w(`addStep.kind`),children:qt.map(e=>{let t=Yt[e];return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":a===e,onClick:()=>o(e),className:x(`inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-full px-3 text-[0.75rem] ring-1 transition`,a===e?`bg-ember-tint text-ember-strong ring-ember/40`:`text-ink-2 ring-border hover:bg-accent`),children:[(0,W.jsx)(t,{className:`size-3.5`}),` `,Xt(e)]},e)})}),t?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-1.5`,"aria-label":w(`addStep.when`),children:[(0,W.jsx)(`span`,{className:`mr-1 text-[0.75rem] text-ink-3`,children:w(`addStep.when`)}),[`always`,`if`,`ask`].map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":m===e,onClick:()=>{h(e),u(null)},className:x(`inline-flex h-7 items-center whitespace-nowrap rounded-full px-3 text-[0.75rem] ring-1 transition`,m===e?`bg-ember-tint text-ember-strong ring-ember/40`:`text-ink-2 ring-border hover:bg-accent`),children:w(e===`always`?`addStep.always`:e===`if`?`addStep.onlyIf`:`addStep.aiDecides`)},e))]}),m===`always`?null:(0,W.jsx)(k,{"aria-label":w(m===`if`?`addStep.onlyIf`:`addStep.aiDecides`),placeholder:w(m===`if`?`addStep.ifPlaceholder`:`addStep.askPlaceholder`),value:g,onChange:e=>{_(e.target.value),u(null)}})]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r?(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":d,onClick:()=>f(e=>!e),className:`inline-flex h-8 items-center gap-1 rounded-full px-2 text-[0.75rem] text-ink-3 hover:bg-accent hover:text-ink`,children:[w(`addStep.emptyStep`),` `,(0,W.jsx)(p,{className:`size-3.5`})]}),d?(0,W.jsx)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 flex min-w-40 flex-col rounded-xl bg-card p-1 shadow-elevated ring-1 ring-border`,children:Jt.map(e=>{let t=Yt[e];return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`inline-flex h-8 items-center gap-2 rounded-lg px-2.5 text-left text-[0.8125rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(t,{className:`size-3.5`}),` `,Xt(e)]},e)})}):null]}):null,(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsx)(A,{variant:`ghost`,size:`sm`,onClick:i,children:w(`addStep.cancel`)}),(0,W.jsxs)(A,{size:`sm`,onClick:y,children:[(0,W.jsx)(H,{className:`size-3.5`}),` `,w(`addStep.create`)]})]})]})]})}function en({adding:e,place:t,working:n,onShowChat:r}){let i=Yt[e.kind];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-border-strong border-dashed bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`inline-flex size-6 items-center justify-center rounded-md bg-paper-2 text-ink-3`,children:(0,W.jsx)(i,{className:`size-3.5`})}),(0,W.jsx)(`span`,{className:`font-medium text-[0.8125rem]`,children:w(`addStep.building`)})]}),(0,W.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:t}),e.when?(0,W.jsxs)(`p`,{className:`text-[0.75rem] text-ember-strong`,children:[w(e.when.mode===`if`?`addStep.onlyIf`:`addStep.aiDecides`),` `,e.when.text]}):null,(0,W.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-wrap text-[0.8125rem] text-ink-2`,children:e.prompt}),(0,W.jsx)(`div`,{className:`text-[0.75rem] text-ink-3`,children:n}),r?(0,W.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex h-8 items-center gap-1.5 self-start rounded-full px-2.5 text-[0.75rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(Rt,{className:`size-3.5`}),` `,w(`addStep.showChat`)]}):null]})}function tn(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}var nn={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`})};function rn(e,t,n){let r=tn(e,n===`page`?`seite`:n===`agent`?`ki`:n===`widget`?`widget`:`erzeugen`),i=[...e.steps];return i.splice(t,0,nn[n](r)),{def:{...e,steps:i},id:r}}function an(e){return e.mime.startsWith(`image/`)?I:e.mime.includes(`json`)?At:e.mime===`text/html`||e.mime.includes(`javascript`)||e.mime===`text/css`?Mt:Ae}function on(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function sn({wizardId:e,files:t,readOnly:n}){let i=r(),a=(0,U.useRef)(null),[o,s]=(0,U.useState)(!1),c=(0,U.useRef)(0),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),p=`/api/studio/wizards/${e}/files`,m=()=>i.invalidateQueries({queryKey:[`wizard`,e]}),h=async e=>{if(e?.length){s(!0),f(null);try{for(let t of Array.from(e)){let e=await fetch(`${p}/${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){f(e.message)}finally{s(!1),await m()}}},g=async e=>{if(window.confirm(w(`files.confirmDelete`,{path:e}))){f(null);try{await M.del(`${p}/${e}`)}catch(e){f(e.message)}await m()}},_=t.reduce((e,t)=>e+t.size,0);return(0,W.jsxs)(`div`,{className:`relative flex min-h-full flex-col px-5 py-5`,onDragEnter:e=>{!n&&e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),c.current+=1,u(!0))},onDragOver:e=>{!n&&e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>{c.current=Math.max(0,c.current-1),c.current===0&&u(!1)},onDrop:e=>{e.preventDefault(),c.current=0,u(!1),n||h(e.dataTransfer.files)},children:[l?(0,W.jsxs)(`div`,{className:`pointer-events-none absolute inset-3 z-10 flex flex-col items-center justify-center gap-2 rounded-2xl border-2 border-ember border-dashed bg-ember-veil text-[0.875rem] text-ember-strong`,children:[(0,W.jsx)(_e,{className:`size-6`}),w(`files.drop`)]}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?null:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a.current?.click(),className:`inline-flex h-9 items-center gap-1.5 rounded-full bg-paper-2 px-3.5 font-medium text-[0.8125rem] text-ink-2 hover:bg-paper-3 hover:text-ink`,children:[o?(0,W.jsx)(b,{className:`size-3.5`}):(0,W.jsx)(_e,{className:`size-3.5`}),w(`files.upload`)]}),(0,W.jsx)(`span`,{className:`ml-auto text-[0.75rem] text-ink-4`,children:w(`files.count`,{n:t.length,size:on(_)})}),(0,W.jsx)(`input`,{ref:a,type:`file`,multiple:!0,hidden:!0,onChange:e=>void h(e.target.files)})]}),d?(0,W.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:d}):null,(0,W.jsx)(`ul`,{className:`mt-4 flex flex-col`,children:t.map(e=>{let t=an(e);return(0,W.jsxs)(`li`,{className:`group flex items-center gap-3 rounded-lg px-2 py-1.5 hover:bg-paper-2`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.75rem]`,children:e.path}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:on(e.size)}),(0,W.jsx)(`a`,{href:`${p}/${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,W.jsx)(qe,{className:`size-4`})}),n?null:(0,W.jsx)(D,{label:w(`files.delete`),className:`opacity-0 hover:text-rose group-hover:opacity-100`,onClick:()=>void g(e.path),children:(0,W.jsx)(L,{className:`size-4`})})]},e.path)})}),t.length===0?(0,W.jsx)(`div`,{className:`mt-6 rounded-xl border border-border border-dashed px-4 py-8 text-center text-[0.8125rem] text-ink-4`,children:w(n?`files.none`:`files.empty`)}):null,n?null:(0,W.jsx)(`p`,{className:`mt-auto pt-6 text-[0.6875rem] text-ink-4 leading-relaxed`,children:w(`files.explain`)})]})}var cn=Object.defineProperty,ln=(e,t,n)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,un=(e,t)=>{for(var n in t)cn(e,n,{get:t[n],enumerable:!0})},dn=(e,t,n)=>ln(e,typeof t==`symbol`?t:t+``,n),fn={};un(fn,{Graph:()=>G,alg:()=>Tn});var pn=Object.defineProperty,mn=(e,t)=>{for(var n in t)pn(e,n,{get:t[n],enumerable:!0})},hn=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=vn(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=yn(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,gn(this._preds[a],i),gn(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?bn(this._isDirected,e):vn(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?bn(this._isDirected,e):vn(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?bn(this._isDirected,e):vn(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],_n(this._preds[t],e),_n(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 gn(e,t){e[t]?e[t]++:e[t]=1}function _n(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function vn(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 yn(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 bn(e,t){return vn(e,t.v,t.w,t.name)}mn({},{read:()=>wn,write:()=>xn});function xn(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Sn(e),edges:Cn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Sn(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 Cn(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 wn(e){let t=new hn(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 Tn={};mn(Tn,{CycleException:()=>Bn,bellmanFord:()=>Dn,components:()=>kn,dijkstra:()=>Mn,dijkstraAll:()=>Pn,findCycles:()=>In,floydWarshall:()=>Rn,isAcyclic:()=>Hn,postorder:()=>Kn,preorder:()=>qn,prim:()=>Jn,shortestPaths:()=>Yn,tarjan:()=>Fn,topsort:()=>Vn});var En=()=>1;function Dn(e,t,n,r){return On(e,String(t),n||En,r||function(t){return e.outEdges(t)??[]})}function On(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 kn(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 An=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}},jn=()=>1;function Mn(e,t,n,r){return Nn(e,String(t),n||jn,r||function(t){return e.outEdges(t)??[]})}function Nn(e,t,n,r){let i={},a=new An,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 Pn(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=Mn(e,i,t,n),r},{})}function Fn(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 In(e){return Fn(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var Ln=()=>1;function Rn(e,t,n){return zn(e,t||Ln,n||function(t){return e.outEdges(t)??[]})}function zn(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 Bn=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function Vn(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new Bn;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 Bn;return r}function Hn(e){try{Vn(e)}catch(e){if(e instanceof Bn)return!1;throw e}return!0}function Un(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=Wn(e,t,n===`post`,o,a,r,i)}),i}function Wn(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=Wn(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function Gn(e,t,n){return Un(e,t,n,function(e,t){return e.push(t),e},[])}function Kn(e,t){return Gn(e,t,`post`)}function qn(e,t){return Gn(e,t,`pre`)}function Jn(e,t){var n;let r=new hn,i={},a=new An,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 Yn(e,t,n,r){return Xn(e,t,n,r??(t=>e.outEdges(t)??[]))}function Xn(e,t,n,r){if(n===void 0)return Mn(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 Dn(e,t,n,r)}return Mn(e,t,n,r)}var G=hn;function Zn(e,t,n,r){let i=r;for(;e.hasNode(i);)i=fr(r);return n.dummy=t,e.setNode(i,n),i}function Qn(e){let t=new G().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 $n(e){let t=new G({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 er(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 tr(e){let t=pr(sr(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 nr(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=K(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function rr(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=K(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 ir(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Zn(e,`border`,i,t)}function ar(e,t=or){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var or=65535;function K(e,t){return t.length>or?e(...ar(t).map(t=>e(...t))):e(...t)}function sr(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return K(Math.max,t)}function cr(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function lr(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function ur(e,t){return t()}var dr=0;function fr(e){return e+(``+ ++dr)}function pr(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 mr(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function hr(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 gr(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var _r=`\0`;function vr(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 yr=`3.1.1`,br=class{constructor(){dn(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return xr(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&xr(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,Sr)),n=n._prev;return`[`+e.join(`, `)+`]`}};function xr(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Sr(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Cr=br,wr=()=>1;function Tr(e,t){if(e.nodeCount()<=1)return[];let n=Or(e,t||wr);return Er(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function Er(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Dr(e,t,n,o);for(;o=i.dequeue();)Dr(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(Dr(e,t,n,o,!0)||[]);break}}}return r}function Dr(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,kr(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,kr(t,n,o)}),e.removeNode(r.v),o}function Or(e,t){let n=new G,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=Ar(i+r+3).map(()=>new Cr),o=r+1;return n.nodes().forEach(e=>{kr(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function kr(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 Ar(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function jr(e,t){(e.graph().acyclicer===`greedy`?Tr(e,n(e)):Mr(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,fr(`rev`))});function n(e){return t=>e.edge(t).weight}}function Mr(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&&Pr(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 Nr(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 Pr(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 Fr(e){e.graph().dummyChains=[],e.edges().forEach(t=>Ir(e,t))}function Ir(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=Zn(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 Lr(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 Rr(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=K(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function zr(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Br=Vr;function Vr(e){let t=new G({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(;Hr(t,e)<i&&(a=Ur(t,e),a);)o=t.hasNode(a.v)?zr(e,a):-zr(e,a),Wr(t,e,o);return t}function Hr(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)&&!zr(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function Ur(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=zr(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Wr(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Gr,postorder:Kr}=Tn,qr=q;q.initLowLimValues=Zr,q.initCutValues=Jr,q.calcCutValue=Xr,q.leaveEdge=$r,q.enterEdge=ei,q.exchangeEdges=ti;function q(e){e=Qn(e),Rr(e);let t=Br(e);Zr(t),Jr(t,e);let n,r;for(;n=$r(t);)r=ei(t,e,n),ti(t,e,n,r)}function Jr(e,t){let n=Kr(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Yr(e,t,n))}function Yr(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=Xr(e,t,n)}function Xr(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,ri(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Zr(e,t){arguments.length<2&&(t=e.nodes()[0]),Qr(e,{},1,t)}function Qr(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=Qr(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function $r(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function ei(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===ii(e,e.node(t.v),s)&&c!==ii(e,e.node(t.w),s)).reduce((e,n)=>zr(t,n)<zr(t,e)?n:e)}function ti(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Zr(e),Jr(e,t),ni(e,t)}function ni(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Gr(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 ri(e,t,n){return e.hasEdge(t,n)}function ii(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var ai=oi;function oi(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:li(e);break;case`tight-tree`:ci(e);break;case`longest-path`:si(e);break;case`none`:break;default:li(e)}}var si=Rr;function ci(e){Rr(e),Br(e)}function li(e){qr(e)}var ui=di;function di(e){let t=pi(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=fi(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 fi(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 pi(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(_r).forEach(r),t}function mi(e){let t=Zn(e,`root`,{},`_root`),n=gi(e),r=Object.values(n),i=K(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=_i(e)+1;e.children(_r).forEach(r=>{hi(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function hi(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=ir(e,`_bt`),l=ir(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{hi(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 gi(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(_r).forEach(e=>n(e,1)),t}function _i(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function vi(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var yi=bi;function bi(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)xi(e,`borderLeft`,`_bl`,n,i,t),xi(e,`borderRight`,`_br`,n,i,t)}}e.children(_r).forEach(t)}function xi(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Zn(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Si(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&wi(e)}function Ci(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Ei(e),(t===`lr`||t===`rl`)&&(Oi(e),wi(e))}function wi(e){e.nodes().forEach(t=>Ti(e.node(t))),e.edges().forEach(t=>Ti(e.edge(t)))}function Ti(e){let t=e.width;e.width=e.height,e.height=t}function Ei(e){e.nodes().forEach(t=>Di(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Di),Object.hasOwn(r,`y`)&&Di(r)})}function Di(e){e.y=-e.y}function Oi(e){e.nodes().forEach(t=>ki(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ki),Object.hasOwn(r,`x`)&&ki(r)})}function ki(e){let t=e.x;e.x=e.y,e.y=t}function Ai(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=pr(K(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 vr(t,e.node(n),e.node(r))}return a}function ji(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Mi(e,t[r-1],t[r]);return n}function Mi(e,t,n){let r=gr(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 Ni(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 Pi(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))}),Fi(Object.values(n).filter(e=>!e.indegree))}function Fi(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Ii(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=>mr(e,[`vs`,`i`,`barycenter`,`weight`]))}function Ii(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 Li(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=cr(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(zi(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=Ri(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=Ri(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function Ri(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 zi(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=vr(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 Bi(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=Ni(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=Bi(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&Hi(t,r)}});let h=Pi(m,n);Vi(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=Li(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 Vi(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function Hi(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 Ui(e,t,n,r){r||=e.nodes();let i=Wi(e),a=new G({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 Wi(e){let t;for(;e.hasNode(t=fr(`_root`)););return t}function Gi(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 Ki(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Ki);return}let r=sr(e),i=qi(e,pr(1,r+1),`inEdges`),a=qi(e,pr(r-1,-1,-1),`outEdges`),o=Ai(e,n);if(Yi(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){Ji(t%2?i:a,t%4>=2,l,n),o=tr(e);let u=ji(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Yi(e,c)}function qi(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 Ui(e,t,n,r.get(t)||[])})}function Ji(e,t,n,r){let i=!0,a=new G;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=Bi(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Gi(e,a,s.vs)})}function Yi(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Xi(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=Qi(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)&&$i(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Zi(e,t){let n={};function r(t,r,i,a,o){pr(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)&&$i(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 Qi(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function $i(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 ea(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 ta(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)||ua(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=>ua(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&&!ea(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 na(e,t,n,r,i=!1){let a={},o=ra(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 ra(e,t,n,r){let i=new G,a=e.graph(),o=ca(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 ia(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=la(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 aa(e,t){let n=Object.values(t),r=K(Math.min,n),i=K(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-K(Math.min,c);a!==`l`&&(l=i-K(Math.max,c)),l&&(e[o]=hr(s,e=>e+l))})})}function oa(e,t=void 0){let n=e.ul;return n?hr(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 sa(e,t){let n=tr(e),r=Object.assign(Xi(e,n),Zi(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=ta(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=na(e,a,s.root,s.align,n===`r`);n===`r`&&(c=hr(c,e=>-e)),i[o+n]=c})}),aa(i,ia(e,i)),oa(i,e.graph().align)}function ca(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 la(e,t){return e.node(t).width}function ua(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 da(e,t){e=$n(e),fa(e),Object.entries(sa(e,t)).forEach(([t,n])=>e.node(t).x=n)}function fa(e){let t=tr(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 pa=new WeakMap;function ma(e,t={}){return ga(e,ur,t),e}function ha(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function ga(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 G({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=ha(e,t.v,r),i=ha(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)}))}}),ga(o,t,n);let l=Da(o);_a(l,t,n,null),va(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=Da(e),g=_a(h,t,n,pa.get(e)??null);pa.set(e,g),va(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 _a(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`,()=>Oa(e)),t(` removeSelfEdges`,()=>La(e)),t(` acyclic`,()=>jr(e,s)),t(` nestingGraph.run`,()=>mi(e)),t(` rank`,()=>ai($n(e))),t(` injectEdgeLabelProxies`,()=>ka(e)),t(` removeEmptyRanks`,()=>rr(e)),t(` nestingGraph.cleanup`,()=>vi(e)),t(` normalizeRanks`,()=>nr(e)),t(` assignRankMinMax`,()=>Aa(e)),t(` removeEdgeLabelProxies`,()=>ja(e)),t(` normalize.run`,()=>Fr(e)),t(` parentDummyChains`,()=>ui(e)),t(` addBorderSegments`,()=>yi(e)),t(` order`,()=>Ki(e,n,c)),t(` insertSelfEdges`,()=>Ra(e)),t(` adjustCoordinateSystem`,()=>Si(e)),t(` position`,()=>da(e,n.corePath)),t(` positionSelfEdges`,()=>za(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>Ia(e)),t(` normalize.undo`,()=>Lr(e)),t(` fixupEdgeLabelCoords`,()=>Pa(e)),t(` undoCoordinateSystem`,()=>Ci(e)),t(` translateGraph`,()=>Ma(e)),t(` assignNodeIntersects`,()=>Na(e)),t(` reversePoints`,()=>Fa(e)),t(` acyclic.undo`,()=>Nr(e)),{graph:e,rawNodes:l}}function va(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 ya=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],ba={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},xa=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],Sa=[`width`,`height`,`rank`],Ca={width:0,height:0},wa=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Ta={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Ea=[`labelpos`];function Da(e){let t=new G({multigraph:!0,compound:!0}),n=Va(e.graph());return t.setGraph(Object.assign({},ba,Ba(n,ya),mr(n,xa))),e.nodes().forEach(n=>{let r=Ba(Va(e.node(n)),Sa);Object.keys(Ca).forEach(e=>{r[e]===void 0&&(r[e]=Ca[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Va(e.edge(n));t.setEdge(n,Object.assign({},Ta,Ba(r,wa),mr(r,Ea)))}),t}function Oa(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 ka(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Zn(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function Aa(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 ja(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 Ma(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 Na(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(er(r,a)),n.points.push(er(i,o))})}function Pa(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 Fa(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ia(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 La(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 Ra(e){tr(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=>{Zn(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 za(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 Ba(e,t){return hr(mr(e,t),Number)}function Va(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Ha(e){let t=tr(e),n=new G({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 Ua={graphlib:fn,version:yr,layout:ma,debug:Ha,util:{time:lr,notime:ur}};function Wa(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 i({queryKey:[`estimate`,e,n],queryFn:()=>M.get(`/api/studio/wizards/${e}/estimate`),staleTime:3e4,refetchOnMount:`always`})}var Ga=e=>e<10?e.toLocaleString(void 0,{maximumFractionDigits:1}):Math.round(e).toLocaleString();function Ka({estimate:e,stepId:t}){let n=e?.available?e.steps[t]:void 0;return n?(0,W.jsxs)(`p`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:[w(`estimate.step`,{n:Ga(n.credits),high:Ga(n.high)}),` · `,n.measured?w(`estimate.measured`):w(`estimate.formula`)]}):null}function qa({model:e,effort:t,onChange:n}){let r=w(`class.effortAuto`);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(_,{children:w(`class.label`)}),(0,W.jsx)(v,{value:e??`high`,onChange:e=>n({model:e,effort:t}),options:ot.map(e=>({value:e,label:w(`class.${e}`)}))}),(0,W.jsx)(`p`,{className:`text-[0.75rem] text-ink-3`,children:w(`class.${e??`high`}.hint`)}),(0,W.jsx)(_,{children:w(`class.effort`)}),(0,W.jsx)(j,{value:t?w(`class.effort.${t}`):r,options:[r,...at.map(e=>w(`class.effort.${e}`))],onChange:t=>n({model:e,effort:at.find(e=>w(`class.effort.${e}`)===t)})})]})}var J=280,Ja=92;function Ya({data:e}){let{step:t,selected:n,issue:r,active:i,pulse:a,cost:o,passed:s,onAddAfter:c}=e,l=P(t);return(0,W.jsxs)(`div`,{className:x(`group 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,W.jsx)(`span`,{className:`-top-1 -right-1 absolute size-3 animate-breathe rounded-full bg-moss`}):a?(0,W.jsx)(`span`,{className:`-top-1 -right-1 absolute size-3 animate-breathe rounded-full bg-ember`}):null,(0,W.jsx)(ht,{type:`target`,position:dt.Top}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:x(`inline-flex size-6 items-center justify-center rounded-md`,F[t.type]),children:(0,W.jsx)(l,{className:`size-3.5`})}),(0,W.jsx)(`span`,{className:`font-medium text-[0.6875rem] text-ink-3 uppercase tracking-[0.07em]`,children:N(t)}),r?(0,W.jsx)(ge,{className:`ml-auto size-4 text-rose`}):s&&!i?(0,W.jsx)(d,{className:`ml-auto size-4 text-moss`}):o===null?null:(0,W.jsxs)(`span`,{className:`ml-auto text-[0.6875rem] text-ink-3 tabular-nums`,children:[`≈`,` `,w(`nav.credits`,{n:o<10?o.toLocaleString(void 0,{maximumFractionDigits:1}):Math.round(o)})]})]}),(0,W.jsx)(`div`,{className:`mt-1.5 truncate font-display font-semibold text-[0.9375rem] text-ink`,children:t.title}),(0,W.jsx)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:ue(t)||`\xA0`}),(0,W.jsx)(ht,{type:`source`,position:dt.Bottom}),c?(0,W.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},className:x(`nodrag nopan -translate-x-1/2 -translate-y-1/2 absolute top-full left-1/2 z-10 inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-full bg-card px-3 text-[0.75rem] text-ember-strong shadow-soft ring-1 ring-ember/40 transition hover:bg-ember-tint focus-visible:opacity-100`,n?`opacity-100`:`pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`),children:[(0,W.jsx)(H,{className:`size-3.5`}),` `,w(`addStep.add`)]}):null]})}function Xa({data:e}){return(0,W.jsxs)(`div`,{className:x(`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,W.jsx)(a,{kind:e.avatar,size:40,interactive:!1}),(0,W.jsx)(`span`,{className:`truncate font-display font-semibold text-[0.9375rem]`,children:e.title}),(0,W.jsx)(ht,{type:`source`,position:dt.Bottom})]})}function Za({data:e}){return(0,W.jsxs)(`div`,{className:`w-[280px] rounded-xl border border-ember/50 border-dashed bg-card/70 px-4 py-3 text-left`,children:[(0,W.jsx)(ht,{type:`target`,position:dt.Top}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[0.75rem] text-ember-strong`,children:[(0,W.jsx)(b,{className:`size-3.5`}),` `,w(`addStep.building`)]}),(0,W.jsx)(`div`,{className:`mt-1.5 line-clamp-2 text-[0.8125rem] text-ink-2`,children:e.prompt}),(0,W.jsx)(ht,{type:`source`,position:dt.Bottom})]})}function Qa(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]=pt({sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s});return(0,W.jsx)(_t,{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,W.jsx)(_t,{path:u,labelX:t.labelX,labelY:t.labelY,...c})}var $a={step:Ya,start:Xa,adding:Za},eo={branch:Qa},Y=`__adding`,to=34,no={},ro={};function io(e,t){if(t)return Object.fromEntries(Object.entries(t).filter(([t,n])=>JSON.stringify(e.steps.find(e=>e.id===t)?.next??[])===JSON.stringify(n.over)))}function ao(e){return`${Math.round(e*100)} %`}function oo(e){let t=e.ask?w(`editor.whenAsk`,{text:e.ask}):lt(e)?w(`editor.otherwise`):Qe(e.when).map(so).join(` · `);return e.max?`${t} (${w(`editor.atMost`,{count:e.max})})`:t}function so(e){let t=Array.isArray(e.value)?e.value.join(` / `):String(e.value??``);switch(e.op){case`equals`:return`${e.field} = ${t}`;case`notEquals`:return`${e.field} ≠ ${t}`;case`in`:return`${e.field} ∈ ${t}`;case`notEmpty`:return w(`editor.whenFilled`,{field:e.field});case`empty`:return w(`editor.whenEmpty`,{field:e.field});case`gt`:return`${e.field} > ${t}`;case`lt`:return`${e.field} < ${t}`;case`contains`:return w(`editor.whenContains`,{field:e.field,value:t})}}function co(e,t,n,r,i,a,o,s,c,l){let u=new Ua.graphlib.Graph;u.setGraph({rankdir:`TB`,nodesep:48,ranksep:46,marginx:20,marginy:20}),u.setDefaultEdgeLabel(()=>({})),u.setNode(`__start`,{width:J,height:52});for(let t of e.steps)u.setNode(t.id,{width:J,height:Ja});let d=[],f={markerEnd:{type:gt.ArrowClosed,width:14,height:14,color:`var(--ink-4)`}};c&&u.setNode(Y,{width:J,height:Ja});let p=(t,n,r,i={})=>{let a=e.steps[r]?.id;if(c?.at===r){u.setEdge(n,Y),d.push({id:t,source:n,target:Y,...i,...f}),a&&(u.setEdge(Y,a),d.push({id:`${t}-adding`,source:Y,target:a,...f}));return}a&&(u.hasEdge(n,a)||u.setEdge(n,a),d.push({id:t,source:n,target:a,...i,...f}))};(e.steps[0]||c)&&p(`e-start`,`__start`,0),e.steps.forEach((t,n)=>{let r=e.steps[n+1],i=s[t.id],a=i&&i.rule!==null?t.next?.[i.rule]?.goto:void 0,o=new Map;for(let n of t.next??[])n.goto!==`end`&&e.steps.some(e=>e.id===n.goto)&&o.set(n.goto,[...o.get(n.goto)??[],oo(n)]);for(let[e,n]of o){let r=n.join(` · `),o=r.length>to?`${r.slice(0,33)}…`:r,s=a===e?i?.probabilities?.[`r${i.rule}`]:void 0,c=a===e,l=c?`✓ ${o}${s===void 0?``:` · ${ao(s)}`}`:o;u.setEdge(t.id,e,{width:l.length*6.2+16,height:22,labelpos:`c`}),d.push({id:`b-${t.id}-${e}`,type:`branch`,source:t.id,target:e,label:l,className:`cursor-pointer`,labelStyle:{fontSize:11,fill:c?`var(--moss)`:`var(--ink-2)`},labelBgStyle:{fill:`var(--paper-2)`},labelBgPadding:[6,3],labelBgBorderRadius:8,style:c?{strokeDasharray:`5 4`,stroke:`var(--moss)`,strokeWidth:2}:{strokeDasharray:`5 4`},...f})}if((r||c?.at===n+1)&&t.type!==`result`&&!t.next?.some(lt)){let e=i?.rule===null,r=e?i?.probabilities?.none:void 0;p(`n-${t.id}`,t.id,n+1,{...t.next?.length?{label:e?`✓ ${w(`editor.otherwise`)}${r===void 0?``:` · ${ao(r)}`}`:w(`editor.otherwise`),className:`cursor-pointer`,labelStyle:{fontSize:11,fill:e?`var(--moss)`:`var(--ink-3)`},labelBgStyle:{fill:`var(--background)`},...e?{style:{stroke:`var(--moss)`,strokeWidth:2}}:{}}:{}})}}),Ua.layout(u);for(let e of d){if(e.type!==`branch`)continue;let t=u.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:u.node(`__start`).x-J/2,y:u.node(`__start`).y-26},data:{title:e.title,avatar:e.avatar,selected:t===`__wizard`},draggable:!1},...e.steps.map((e,s)=>{let c=u.node(e.id);return{id:e.id,type:`step`,position:{x:c.x-J/2,y:c.y-Ja/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,passed:o.has(e.id),onAddAfter:l&&e.type!==`result`?()=>l(s+1):void 0},draggable:!1}}),...c?[{id:Y,type:`adding`,position:{x:u.node(Y).x-J/2,y:u.node(Y).y-Ja/2},data:{prompt:c.prompt},draggable:!1,selectable:!1}]:[]],edges:d}}function lo(){let e=mt(),t=`inline-flex size-8 items-center justify-center rounded-full text-ink-3 hover:bg-accent hover:text-ink`;return(0,W.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,W.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.zoomOut(),"aria-label":`Zoom out`,children:(0,W.jsx)(Bt,{className:`size-4`})}),(0,W.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.fitView({padding:.2,duration:300}),"aria-label":`Fit`,children:(0,W.jsx)(Kt,{className:`size-4`})}),(0,W.jsx)(`button`,{type:`button`,className:t,onClick:()=>e.zoomIn(),"aria-label":`Zoom in`,children:(0,W.jsx)(l,{className:`size-4`})})]})}var uo=.8,fo=new Set;function po({def:e,selected:t,onSelect:n,issueSteps:r,activeStep:i,pulse:a,costs:o=no,passed:s=fo,minFitZoom:c=uo,fitKey:l,decisions:u=ro,onBranch:d,adding:f=null,onInsert:p}){let{nodes:m,edges:h}=(0,U.useMemo)(()=>co(e,t,r,i,a??[],o,s,u,f,p),[e,t,r,i,a,o,s,u,f,p]),g=mt(),_=(0,U.useRef)(null),v=e.steps.map(e=>e.id).join(`|`)+(f?`+${f.at}`:``);return(0,U.useEffect)(()=>{let e=requestAnimationFrame(()=>{let e=_.current;if(!e||!m.length)return;let t=m.map(e=>e.position.x),n=m.map(e=>e.position.y),r={x:Math.min(...t),y:Math.min(...n),width:Math.max(...t)+J-Math.min(...t),height:Math.max(...n)+Ja-Math.min(...n)},i=Math.min(e.clientWidth/(r.width*1.2),e.clientHeight/(r.height*1.15),1),a=Math.max(i,c),o=(e.clientWidth-r.width*a)/2-r.x*a,s=i>=c?(e.clientHeight-r.height*a)/2-r.y*a:24-r.y*a;g.setViewport({x:o,y:s,zoom:a},{duration:400})});return()=>cancelAnimationFrame(e)},[v,l,g]),(0,W.jsx)(`div`,{ref:_,className:`h-full w-full`,children:(0,W.jsx)(ut,{nodes:m,edges:h,nodeTypes:$a,edgeTypes:eo,onNodeClick:(e,t)=>{t.id!==Y&&n(t.id===`__start`?`__wizard`:t.id)},onEdgeClick:(t,r)=>{let i=e.steps.find(e=>e.id===(r.source===Y?``:r.source));i?.next?.length&&d?d(i.id):i&&n(i.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,W.jsx)(lo,{})})})}function mo(e){return(0,W.jsx)(ft,{children:(0,W.jsx)(po,{...e})})}function ho({wizardId:e,...t}){let n=Wa(e,t.def);return(0,W.jsx)(mo,{...t,costs:n.data?.available?n.data.steps:no})}var go=1200;function _o({label:e,onDelete:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(!1);(0,U.useEffect)(()=>()=>{for(let e of[o.current,s.current])e&&clearTimeout(e)},[]);let l=()=>{o.current||=(c.current=!1,a(!1),r(!0),setTimeout(()=>{o.current=null,c.current=!0,r(!1),t()},go))},u=()=>{o.current&&(clearTimeout(o.current),o.current=null,r(!1),c.current||(a(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>a(!1),1800)))},d=n||i;return(0,W.jsxs)(`button`,{type:`button`,"aria-label":`${e} – ${w(`editor.holdToDelete`)}`,title:w(`editor.holdToDelete`),onPointerDown:e=>{e.button===0&&l()},onPointerUp:u,onPointerLeave:u,onPointerCancel:u,onContextMenu:e=>e.preventDefault(),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&!e.repeat&&(e.preventDefault(),l())},onKeyUp:e=>{(e.key===` `||e.key===`Enter`)&&u()},onBlur:u,className:x(`relative inline-flex h-9 shrink-0 touch-none select-none items-center justify-center gap-1.5 overflow-hidden rounded-full text-[0.75rem] transition-[width,background,color] duration-150`,d?`w-auto px-3 text-rose ring-1 ring-rose/40`:`w-9 text-ink-3 hover:bg-accent hover:text-rose`),children:[(0,W.jsx)(`span`,{"aria-hidden":!0,className:x(`absolute inset-y-0 left-0 bg-rose/25`,n?`w-full transition-[width] ease-linear`:`w-0`),style:n?{transitionDuration:`${go}ms`}:void 0}),(0,W.jsx)(L,{className:`relative size-4`}),d?(0,W.jsx)(`span`,{className:`relative whitespace-nowrap`,children:w(n?`editor.deleting`:`editor.holdToDelete`)}):null]})}var vo=/preis|price|umsatz|revenue|betrag|amount|anzahl|count|summe|sum|total|wert|value|menge|score|punkte|kosten|cost/i;function yo(e){return new Set(e.flatMap(e=>{let t=e.valueKey;return typeof t==`string`?[t]:[]}))}var bo=[1240,860,420,310];function xo(e){return bo.slice(0,3).map((t,n)=>Object.fromEntries(e.map(e=>[e.key,e.number?t:`${e.label} ${n+1}`])))}function So(e,t,n){let r=yo(n),i=e=>r.has(e)||vo.test(e),a=e.steps.flatMap(e=>e.type===`page`?e.fields:[]),o=t=>{let n=$e(t),r=Xe(n);if(r)return xo((e.lists?.find(e=>e.id===r)?.columns??[]).map(e=>({key:e.id,label:e.name,number:e.type===`number`||i(e.id)})));if(n===`today`)return new Date().toLocaleDateString();if(n.startsWith(`brand.`))return w(`surface.sampleBrand`);let[o,s,c]=n.split(`.`);if(o===`steps`){let t=e.steps.find(e=>e.id===s);if(t?.type!==`agent`)return null;let n=t.output.fields??[],r=e=>{switch(e.kind){case`number`:return 42;case`list`:return[1,2,3].map(t=>`${e.id} ${t}`);case`table`:return xo((e.columns??[`name`]).map(e=>({key:e,label:e,number:i(e)})));case`yesno`:return!0;case`choice`:case`score`:return e.options?.[0]??``;default:return w(`surface.sampleText`)}};if(c){let e=n.find(e=>e.id===c);return e?r(e):null}return n.length?Object.fromEntries(n.map(e=>[e.id,r(e)])):w(`surface.sampleText`)}let l=a.find(e=>e.id===n);return l?l.kind===`number`?42:l.options?.[0]??l.label:null};return Object.fromEntries(Object.entries(t.data).map(([e,t])=>[e,o(t)]))}function Co(e){let t=[],n=/("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(\btrue\b|\bfalse\b|\bnull\b)|([{}[\],])/g,r=0;for(let i of e.matchAll(n)){let n=i.index??0;n>r&&t.push(e.slice(r,n));let[a,o,s,c,l,u]=i;o===void 0?c===void 0?l===void 0?u===void 0?t.push(a):t.push((0,W.jsx)(`span`,{className:`text-slate-400`,children:u},n)):t.push((0,W.jsx)(`span`,{className:`text-violet-300`,children:l},n)):t.push((0,W.jsx)(`span`,{className:`text-emerald-300`,children:c},n)):(t.push((0,W.jsx)(`span`,{className:s?`text-sky-300`:`text-amber-200`,children:o},n)),s&&t.push((0,W.jsx)(`span`,{className:`text-slate-400`,children:s},`${n}:`))),r=n+a.length}return t.push(e.slice(r)),t}function wo({value:e,onChange:t,onBlur:n}){let r=(0,U.useRef)(null),i=(0,U.useRef)(null),a=()=>{r.current&&i.current&&(r.current.scrollTop=i.current.scrollTop,r.current.scrollLeft=i.current.scrollLeft)},o=`m-0 whitespace-pre break-normal px-3 py-2.5 font-mono text-[0.75rem] leading-[1.6] [tab-size:2]`;return(0,W.jsxs)(`div`,{className:`relative h-[28rem] overflow-hidden rounded-lg bg-[oklch(20%_0.03_260)] ring-1 ring-border focus-within:ring-focus`,children:[(0,W.jsxs)(`pre`,{ref:r,"aria-hidden":!0,className:x(o,`absolute inset-0 overflow-hidden text-slate-200`),children:[Co(e),`
|
|
2
|
-
`]}),(0,W.jsx)(`textarea`,{ref:i,spellCheck:!1,"aria-label":w(`editor.surfaceJson`),value:e,onChange:e=>t(e.target.value),onBlur:n,onScroll:a,className:x(o,`absolute inset-0 h-full w-full resize-none overflow-auto bg-transparent text-transparent caret-white outline-none selection:bg-sky-400/30`)})]})}function To({def:e,step:t,set:n,section:r}){let i={...t.components?{components:t.components}:{},...t.candidates?{candidates:t.candidates,groups:t.groups}:{},data:t.data},a=JSON.stringify(i,null,2),[o,s]=(0,U.useState)(a),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(`preview`);(0,U.useEffect)(()=>{document.activeElement?.getAttribute(`aria-label`)!==w(`editor.surfaceJson`)&&(s(a),l(null))},[a]);let f=(0,U.useMemo)(()=>t.components??ct(t.candidates??[],(t.candidates??[]).map(e=>e.id)),[t.components,t.candidates]),p=(0,U.useMemo)(()=>So(e,t,f),[e,t,f]),m=()=>{if(o===a)return!0;try{let e=JSON.parse(o);return l(null),n({...t,...e}),!0}catch(e){return l(e.message),!1}},h=u===`preview`?(0,W.jsx)(D,{label:w(`surface.code`),className:`absolute top-2 right-2 z-10 size-8`,onClick:()=>d(`code`),children:(0,W.jsx)(Et,{className:`size-4`})}):(0,W.jsx)(D,{label:w(`surface.preview`),className:`absolute top-2 right-4 z-10 size-8 text-slate-300 hover:bg-white/10 hover:text-white`,onClick:()=>{m()&&d(`preview`)},children:(0,W.jsx)(ye,{className:`size-4`})});return r(w(`type.surface`),u===`preview`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative rounded-xl bg-paper p-4 ring-1 ring-border-soft`,children:[h,(0,W.jsx)(Ne,{surface:{components:f,data:p},assetUrl:()=>``})]}),(0,W.jsx)(`p`,{className:`text-[0.75rem] text-ink-4`,children:w(`surface.sampleNote`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`relative`,children:[h,(0,W.jsx)(wo,{value:o,onChange:s,onBlur:()=>void m()})]}),c?(0,W.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:c}):null]}))}var Eo=(0,U.createContext)(void 0),Do={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`,slot:`Termin`},Oo={slot:bt};function ko(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}}var Ao=(0,U.createContext)(!1);function jo({className:e,children:t}){return(0,U.useContext)(Ao)?(0,W.jsx)(`fieldset`,{disabled:!0,className:x(`min-w-0`,e),children:t}):(0,W.jsx)(`div`,{className:e,children:t})}function X({title:e,children:t,loose:n}){let r=`flex flex-col gap-4`;return(0,W.jsxs)(`div`,{className:`border-border-soft border-t px-5 py-5 first:border-t-0`,children:[e?(0,W.jsx)(`h4`,{className:`mb-3 font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.07em]`,children:e}):null,n?(0,W.jsx)(`div`,{className:r,children:t}):(0,W.jsx)(jo,{className:r,children:t})]})}function Mo(e,t,n){let r=e.steps.indexOf(t),i=[];for(let t of e.steps.slice(0,r))t.type===`page`?i.push(...t.fields.map(e=>e.id)):t.type===`agent`&&i.push(...(t.output.fields??[]).map(e=>`steps.${t.id}.${e.id}`));return i.push(...t.fields.filter(e=>e.id!==n.id).map(e=>e.id)),i.push(...(e.lists??[]).map(e=>`lists.${e.id}.count`)),i}function No(e,t){let n=e.steps.indexOf(t),r=[];for(let t of e.steps.slice(0,n))if(t.type===`agent`)for(let e of t.output.fields??[])e.kind===`list`?r.push(`steps.${t.id}.${e.id}`):e.kind===`table`&&r.push(...(e.columns??[]).map(n=>`steps.${t.id}.${e.id}.${n}`));for(let t of e.lists??[])t.shared||r.push(...t.columns.map(e=>`lists.${t.id}.${e.id}`));return r}function Po(e,t){let n=e.steps.flatMap(e=>e.type===`page`?e.fields:[]).find(e=>e.id===t);return n?n.label:t}function Fo({def:e,when:t,sources:n,onChange:r,label:i=w(`editor.shownWhen`),noneLabel:a=w(`editor.shownAlways`)}){let[o,...s]=Qe(t),c=e=>r(e?s.length?[e,...s]:e:s.length?s:void 0),l=o&&o.op!==`empty`&&o.op!==`notEmpty`;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:i}),(0,W.jsx)(v,{value:o?.field??``,placeholder:a,onChange:e=>c(e?{field:e,op:o?.op??`equals`,value:o?.value??``}:null),options:[{value:``,label:a},...n.map(t=>({value:t,label:Po(e,t)}))]}),o?(0,W.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,W.jsx)(v,{value:o.op,onChange:e=>{let t=e,n=t===`empty`||t===`notEmpty`?void 0:t===`in`?String(o.value??``).split(`,`).map(e=>e.trim()).filter(Boolean):t===`gt`||t===`lt`?Number(o.value)||0:Array.isArray(o.value)?o.value.join(`, `):o.value??``;c({field:o.field,op:t,...n===void 0?{}:{value:n}})},options:rt.map(e=>({value:e,label:w(`editor.op.${e}`)}))}),l?(0,W.jsx)(k,{"aria-label":w(`editor.conditionValue`),placeholder:w(`editor.conditionValue`),value:Array.isArray(o.value)?o.value.join(`, `):String(o.value??``),onChange:e=>{let t=e.target.value,n=o.op===`in`?t.split(`,`).map(e=>e.trim()):o.op===`gt`||o.op===`lt`?Number(t.replace(`,`,`.`))||0:t===`true`||t===`false`?t===`true`:t;c({...o,value:n})}}):null]}):null,s.length?(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:w(`editor.conditionsMore`,{count:s.length})}):null]})}function Io({def:e,page:t,field:n,onChange:r,onRemove:i,onMove:a}){let[o,s]=(0,U.useState)(!1),c=Oo[n.kind];return(0,W.jsxs)(`div`,{className:`rounded-lg bg-paper ring-1 ring-border-soft`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2.5 text-left`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:[n.label,n.required?(0,W.jsx)(`span`,{className:`ml-1 text-ember`,children:`*`}):null]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-4`,children:[c?(0,W.jsx)(c,{className:`size-3.5`}):null,Do[n.kind]]}),(0,W.jsx)(p,{className:x(`size-4 text-ink-4 transition`,o&&`rotate-180`)})]}),o?(0,W.jsxs)(jo,{className:`flex flex-col gap-3 border-border-soft border-t px-3 py-3`,children:[(0,W.jsx)(k,{value:n.label,onChange:e=>r({...n,label:e.target.value})}),(0,W.jsx)(v,{value:n.kind,onChange:e=>r(ko(n,e)),options:Ye.filter(e=>e!==`items`||n.kind===`items`).map(e=>({value:e,label:Do[e]}))}),(n.kind===`select`||n.kind===`multiselect`||n.kind===`slot`)&&(n.optionsFrom||No(e,t).length)?(0,W.jsx)(v,{value:n.optionsFrom??``,onChange:e=>r({...n,optionsFrom:e||void 0}),options:[{value:``,label:w(`editor.optionsFixed`)},...No(e,t).map(e=>({value:e,label:`${w(`editor.optionsFrom`)}: ${e}`}))]}):null,n.kind===`select`||n.kind===`multiselect`||n.kind===`slot`?(0,W.jsx)(k,{placeholder:n.kind===`slot`?`2026-10-12T09:00:00+02:00, 2026-10-12T09:30:00+02:00`:`Option A, Option B, Option C`,value:(n.options??[]).join(`, `),onChange:e=>r({...n,options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})}):null,n.kind===`connection`?(0,W.jsx)(v,{value:n.connection??``,placeholder:`Welches Konto?`,onChange:e=>r({...n,connection:e}),options:(e.connections??[]).map(e=>({value:e.id,label:e.title??e.id}))}):null,n.kind===`list`?(0,W.jsx)(v,{value:n.list??``,placeholder:`Welche Liste?`,onChange:e=>r({...n,list:e}),options:(e.lists??[]).map(e=>({value:e.id,label:e.title}))}):null,n.kind===`image`||n.kind===`file`?(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Mehrere Dateien`}),(0,W.jsx)(E,{checked:!!n.multiple,onChange:e=>r({...n,multiple:e||void 0,...e?{}:{min:void 0,max:void 0}})})]}):null,(n.kind===`image`||n.kind===`file`)&&n.multiple?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Wie viele?`}),(0,W.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`min`,`max`].map(e=>(0,W.jsx)(k,{type:`number`,min:1,max:30,"aria-label":e===`min`?`Mindestens`:`Höchstens`,placeholder:e===`min`?`min.`:`max.`,value:n[e]??``,onChange:t=>{let i=Math.round(Number(t.target.value));r({...n,[e]:t.target.value&&i>=1?Math.min(i,30):void 0})},className:`h-8 w-16 text-right`},e))})]}):null,n.kind===`file`?(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Auch mit der Kamera aufnehmen`}),(0,W.jsx)(E,{checked:!!n.camera,onChange:e=>r({...n,camera:e||void 0})})]}):null,n.kind===`file`?(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Kamera nimmt auch kurze Videos auf`}),(0,W.jsx)(E,{checked:!!n.video,onChange:e=>r({...n,video:e||void 0})})]}):null,n.kind===`text`?(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`QR- oder Barcode scannen`}),(0,W.jsx)(E,{checked:!!n.scan,onChange:e=>r({...n,scan:e||void 0})})]}):null,[`text`,`textarea`,`number`,`email`,`url`,`location`].includes(n.kind)?(0,W.jsx)(k,{placeholder:`Platzhalter`,value:n.placeholder??``,onChange:e=>r({...n,placeholder:e.target.value||void 0})}):null,(0,W.jsx)(k,{placeholder:`Hilfetext`,value:n.help??``,onChange:e=>r({...n,help:e.target.value||void 0})}),(0,W.jsx)(Fo,{def:e,when:n.when,sources:Mo(e,t,n),onChange:e=>r({...n,when:e})}),n.group?null:(0,W.jsx)(k,{"aria-label":w(`editor.fieldAsk`),placeholder:w(`editor.fieldAsk`),value:n.ask??``,onChange:e=>r({...n,ask:e.target.value||void 0})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:w(`run.required`)}),(0,W.jsx)(E,{checked:!!n.required,onChange:e=>r({...n,required:e})})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-ink-4`,children:`{{${n.id}}}`}),(0,W.jsxs)(`div`,{className:`flex`,children:[(0,W.jsx)(D,{label:w(`editor.moveUp`),onClick:()=>a(-1),className:`size-8`,children:(0,W.jsx)(f,{className:`size-3.5`})}),(0,W.jsx)(D,{label:w(`editor.moveDown`),onClick:()=>a(1),className:`size-8`,children:(0,W.jsx)(ae,{className:`size-3.5`})}),(0,W.jsx)(D,{label:`Entfernen`,onClick:i,className:`size-8 hover:text-rose`,children:(0,W.jsx)(L,{className:`size-3.5`})})]})]})]}):null]})}var Lo=[{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 Ro(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`||r.type===`surface`)&&n.push(`steps.${r.id}`);return[...n,`brand.name`,`today`]}function zo({def:e,step:t,set:n,files:r,wizardId:i}){let a=r.filter(e=>e.mime===`text/html`),o=r.filter(e=>e.mime===`application/json`),s=t.size??Lo[0],u=Ro(e,e.steps.indexOf(t)),d=Object.entries(t.data),f=e=>n({...t,data:Object.fromEntries(e)}),p=[r.find(e=>e.path===t.entry)?.hash.slice(0,8),r.find(e=>e.path===t.sample)?.hash.slice(0,8),s.width,s.height].join(`-`),m=r.some(e=>e.path===t.entry);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{title:`Vorschau mit Beispieldaten`,children:m?(0,W.jsx)(Re,{src:c(`/api/studio/wizards/${i}/widgets/${t.id}/preview?v=${p}`),page:s.width,height:s.height,fit:!0}):(0,W.jsx)(Bo,{step:t,wizardId:i})}),(0,W.jsxs)(X,{title:`Widget`,children:[(0,W.jsx)(_,{children:`HTML-Datei`}),(0,W.jsx)(v,{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,W.jsx)(_,{children:`Beispieldaten`}),(0,W.jsx)(v,{value:t.sample??``,onChange:e=>n({...t,sample:e||void 0}),options:[{value:``,label:`keine`},...o.map(e=>({value:e.path,label:e.path}))]}),(0,W.jsx)(_,{children:`Größe`}),(0,W.jsx)(j,{value:Lo.find(e=>e.width===s.width&&e.height===s.height)?.label??``,options:Lo.map(e=>e.label),onChange:e=>{let r=Lo.find(t=>t.label===e);r&&n({...t,size:{width:r.width,height:r.height}})}})]}),(0,W.jsxs)(X,{title:`Daten für das Widget`,children:[(0,W.jsx)(`datalist`,{id:`sources-${t.id}`,children:u.map(e=>(0,W.jsx)(`option`,{value:e},e))}),d.map(([e,n],r)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(k,{value:e,className:`w-28 font-mono text-[0.75rem]`,onChange:e=>f(d.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,W.jsx)(`span`,{className:`text-ink-4`,children:`←`}),(0,W.jsx)(k,{value:n,list:`sources-${t.id}`,className:`flex-1 font-mono text-[0.75rem]`,onChange:e=>f(d.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,W.jsx)(D,{label:w(`editor.deleteStep`),onClick:()=>f(d.filter((e,t)=>t!==r)),children:(0,W.jsx)(L,{className:`size-4`})})]},r)),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>f([...d,[`wert${d.length+1}`,u[0]??`today`]]),className:`inline-flex h-8 items-center gap-1 self-start rounded-full px-2.5 text-[0.75rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(l,{className:`size-3.5`}),` Wert`]})]})]})}function Bo({step:e,wizardId:t}){let n=(0,U.useContext)(Eo),i=(0,U.useContext)(Ao),a=r(),o=(0,U.useRef)(null),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null);if(i)return(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`widget.missing`)});let m=()=>{if(!n)return;let t=w(`widget.buildMessage`,{title:e.title,what:s.trim()}).trim();n.ask(t)?(l(``),p(null)):p(w(`addStep.busy`))},h=async n=>{if(n){d(!0),p(null);try{let r=encodeURIComponent(e.entry).replace(/%2F/g,`/`),i=await fetch(c(`/api/studio/wizards/${t}/files/${r}`),{method:`PUT`,credentials:`include`,headers:{"content-type":`text/html`},body:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??i.statusText)}}catch(e){p(e.message)}finally{d(!1),await a.invalidateQueries({queryKey:[`wizard`,t]})}}};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-border-strong border-dashed p-4`,children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:w(`widget.missing`)}),n?(0,W.jsx)(S,{minRows:2,"aria-label":w(`widget.what`),placeholder:w(`widget.what`),value:s,onChange:e=>l(e.target.value)}):null,f?(0,W.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:f}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,W.jsxs)(A,{size:`sm`,onClick:m,children:[(0,W.jsx)(H,{className:`size-3.5`}),` `,w(`widget.build`)]}):null,(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:u,onClick:()=>o.current?.click(),children:[(0,W.jsx)(_e,{className:`size-3.5`}),` `,w(`widget.upload`)]}),(0,W.jsx)(`input`,{ref:o,type:`file`,accept:`text/html,.html,.htm`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,h(t)}})]})]})}function Vo({def:e,step:t,set:n,mcpServers:r,files:i,wizardId:a}){let o=e.steps.indexOf(t),s=(0,U.useContext)(Ao),c=Be().plugins.flatMap(e=>e.tools),u=e.steps.slice(0,o).filter(e=>e.type===`agent`||e.type===`generate`||e.type===`widget`||e.type===`surface`);switch(t.type){case`widget`:return(0,W.jsx)(zo,{def:e,step:t,set:n,files:i,wizardId:a});case`surface`:return(0,W.jsx)(To,{def:e,step:t,set:n,section:(e,t)=>(0,W.jsx)(X,{title:e,children:t})});case`page`:return(0,W.jsxs)(X,{title:`Fragen`,loose:!0,children:[(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.fields.map((r,i)=>(0,W.jsx)(Io,{def:e,page:t,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))}),s?null:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n({...t,fields:[...t.fields,{id:tn(e,`frage`),label:`Neue Frage`,kind:`text`}]}),className:`inline-flex h-9 items-center gap-1.5 self-start rounded-full px-3 text-[0.8125rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(l,{className:`size-4`}),` Frage hinzufügen`]})]});case`agent`:return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(X,{title:`Auftrag`,children:[(0,W.jsx)(S,{value:t.instructions,minRows:6,maxRows:20,onChange:e=>n({...t,instructions:e.target.value}),className:`text-[0.875rem]`}),(0,W.jsxs)(`p`,{className:`text-[0.75rem] text-ink-4`,children:[`Antworten einsetzen mit `,(0,W.jsx)(`code`,{className:`font-mono`,children:`{{feld}}`}),`, frühere Ergebnisse mit `,(0,W.jsx)(`code`,{className:`font-mono`,children:`{{steps.id}}`}),`.`]})]}),(0,W.jsxs)(X,{title:`Werkzeuge`,children:[(0,W.jsx)(j,{multi:!0,value:t.tools,options:[...new Set([...Ze,...c.map(e=>e.id),...t.tools])],onChange:e=>n({...t,tools:e})}),(0,W.jsxs)(`div`,{className:`-mt-2 flex flex-wrap gap-x-3 text-[0.75rem] text-ink-4`,children:[Ze.map(e=>(0,W.jsxs)(`span`,{children:[e,` = `,ce(e)]},e)),c.map(e=>(0,W.jsxs)(`span`,{children:[e.id,` = `,e.title]},e.id))]}),e.connections?.length?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{hint:`Konten, die die Person im Durchlauf verbindet. Der Schritt liest darin, er schreibt nie.`,children:`Konten der Person`}),(0,W.jsx)(j,{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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{hint:`Nur freigegebene Systeme sind in diesem Schritt erreichbar.`,children:`Verbundene Systeme`}),(0,W.jsx)(j,{multi:!0,value:t.mcp??[],options:r.map(e=>e.id),onChange:e=>n({...t,mcp:e.length?e:void 0})})]}):null]}),(0,W.jsxs)(X,{title:`Ergebnis`,children:[(0,W.jsx)(j,{value:t.output.format,options:[`text`,`markdown`,`json`],onChange:e=>n({...t,output:{...t.output,format:e}})}),(0,W.jsx)(qa,{model:t.model,effort:t.effort,onChange:e=>n({...t,...e})}),(0,W.jsx)(k,{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,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(X,{title:`Was wird erzeugt?`,children:[(0,W.jsx)(j,{value:t.asset,options:[`image`,`video`,`voice`,`document`,`dashboard`],onChange:e=>n({...t,asset:e})}),(0,W.jsx)(S,{value:t.prompt,minRows:5,maxRows:18,onChange:e=>n({...t,prompt:e.target.value}),className:`text-[0.875rem]`})]}),(0,W.jsxs)(X,{title:`Optionen`,children:[t.asset===`document`||t.asset===`dashboard`?(0,W.jsx)(qa,{model:t.model,effort:t.effort,onChange:e=>n({...t,...e})}):null,t.asset===`image`||t.asset===`video`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{children:`Format`}),(0,W.jsx)(j,{value:t.options?.aspectRatio??``,options:[...st],onChange:e=>n({...t,options:{...t.options,aspectRatio:e}})}),(0,W.jsx)(k,{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,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{children:`Länge (Sekunden)`}),(0,W.jsx)(j,{value:String(t.options?.duration??8),options:[`4`,`6`,`8`,`10`],onChange:e=>n({...t,options:{...t.options,duration:Number(e)}})}),(0,W.jsx)(_,{children:`Auflösung`}),(0,W.jsx)(j,{value:t.options?.resolution??`720p`,options:[...nt],onChange:e=>n({...t,options:{...t.options,resolution:e}})})]}):null,t.asset===`document`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{children:`Vorlage`}),(0,W.jsx)(v,{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,W.jsxs)(X,{title:`Was wird gezeigt?`,children:[(0,W.jsx)(j,{multi:!0,value:t.show,options:u.map(e=>e.id),onChange:e=>e.length&&n({...t,show:e})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Text direkt bearbeitbar`}),(0,W.jsx)(E,{checked:!!t.edit,onChange:e=>n({...t,edit:e})})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-2`,children:`Neue Variante anfordern`}),(0,W.jsx)(E,{checked:!!t.regenerate,onChange:e=>n({...t,regenerate:e})})]})]});case`result`:return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{title:`Abschluss`,children:(0,W.jsx)(S,{minRows:2,placeholder:`Nachricht am Ende`,value:t.message??``,onChange:e=>n({...t,message:e.target.value||void 0})})}),(0,W.jsx)(X,{title:`Downloads`,children:u.map(e=>{let r=t.deliverables.find(t=>t.from===e.id),i=it(e);return(0,W.jsxs)(`div`,{className:`rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`truncate text-[0.875rem]`,children:e.title}),(0,W.jsx)(E,{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,W.jsx)(j,{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 Ho({def:e,update:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(X,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(_,{children:`Titel`}),(0,W.jsx)(k,{value:e.title,onChange:n=>t({...e,title:n.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(_,{children:`Beschreibung`}),(0,W.jsx)(S,{minRows:2,value:e.description,onChange:n=>t({...e,description:n.target.value})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(_,{hint:`Steht über der ersten Seite.`,children:`Begrüßung`}),(0,W.jsx)(S,{minRows:2,value:e.intro??``,onChange:n=>t({...e,intro:n.target.value||void 0})})]})]}),(0,W.jsx)(X,{title:`Avatar`,children:(0,W.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:tt.map(n=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>t({...e,avatar:n}),className:x(`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,W.jsx)(a,{kind:n,size:44,interactive:!1})},n))})}),e.lists?.length||e.connections?.length?(0,W.jsxs)(X,{title:`Merkt sich für jede Person`,children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] 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,W.jsxs)(`div`,{className:`rounded-lg bg-paper px-3 py-2.5 ring-1 ring-border-soft`,children:[(0,W.jsx)(`div`,{className:`text-[0.875rem]`,children:e.title??e.id}),(0,W.jsxs)(`div`,{className:`text-[0.75rem] text-ink-4`,children:[`Konto · `,e.kind]})]},e.id)),(e.lists??[]).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-paper px-3 py-2.5 ring-1 ring-border-soft`,children:[(0,W.jsx)(`div`,{className:`text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`div`,{className:`text-[0.75rem] text-ink-4`,children:[`Liste · `,e.columns.map(e=>e.name).join(`, `)]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[0.6875rem] text-ink-4`,children:`{{lists.${e.id}}}`})]},e.id))]}):null]})}var Uo=`__wizard`;function Wo({def:e,selected:t,onSelect:n,issues:r}){let i=[Uo,...e.steps.map(e=>e.id)],a=t?i.indexOf(t):-1,o=(0,U.useRef)(null);(0,U.useEffect)(()=>{o.current?.scrollIntoView({block:`nearest`,inline:`center`,behavior:`smooth`})},[t]);let c=e=>{let t=a===-1?e===1?1:i.length-1:a+e;t>=0&&t<i.length&&n(i[t])},l=(0,U.useRef)(c);l.current=c,(0,U.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(),l.current(e.key===`ArrowLeft`?-1:1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let u=`inline-flex size-8 shrink-0 items-center justify-center rounded-full transition`;return(0,W.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,W.jsx)(D,{label:w(`editor.prevStep`),className:`size-8 shrink-0`,disabled:a===0,onClick:()=>c(-1),children:(0,W.jsx)(s,{className:`size-4`})}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center overflow-x-auto p-1 [scrollbar-width:none]`,children:[(0,W.jsx)(`button`,{ref:t===Uo?o:void 0,type:`button`,title:e.title,"aria-label":e.title,"aria-current":t===Uo?`step`:void 0,onClick:()=>n(Uo),className:x(u,`bg-paper-2 text-ink-2`,t===Uo?`ring-2 ring-ember`:`hover:ring-2 hover:ring-border-soft`),children:(0,W.jsx)(be,{className:`size-4`})}),e.steps.map((e,i)=>{let a=P(e),s=e.id===t,c=r.some(t=>t.stepId===e.id);return(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,W.jsx)(`span`,{className:`h-px w-3 bg-border-soft`}),(0,W.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:x(u,`relative`,F[e.type],s?`ring-2 ring-ember`:`opacity-70 hover:opacity-100`),children:[(0,W.jsx)(a,{className:`size-4`}),c?(0,W.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,W.jsx)(`span`,{className:`shrink-0 px-1 text-[0.75rem] text-ink-4 tabular-nums`,children:a>0?`${a} / ${e.steps.length}`:``}),(0,W.jsx)(D,{label:w(`editor.nextStep`),className:`size-8 shrink-0`,disabled:a===i.length-1,onClick:()=>c(1),children:(0,W.jsx)(re,{className:`size-4`})})]})}function Go({def:e,onSelect:t,issues:n}){return(0,W.jsx)(`div`,{className:`flex flex-col gap-1 p-3`,children:e.steps.map((e,r)=>{let i=P(e),a=n.some(t=>t.stepId===e.id);return(0,W.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,W.jsx)(`span`,{className:`w-4 text-right text-[0.75rem] text-ink-4 tabular-nums`,children:r+1}),(0,W.jsx)(`span`,{className:x(`inline-flex size-7 shrink-0 items-center justify-center rounded-md`,F[e.type]),children:(0,W.jsx)(i,{className:`size-4`})}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-[0.875rem]`,children:e.title}),(0,W.jsx)(`span`,{className:`block text-[0.75rem] text-ink-4`,children:N(e)})]}),a?(0,W.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-rose`}):null]},e.id)})})}function Ko(e){let{def:t,selected:n,onSelect:r,issues:i,readOnly:a=!1}=e,o=a?()=>{}:e.update,s=t.steps.find(e=>e.id===n);return(0,W.jsx)(Ao,{value:a,children:(0,W.jsx)(Eo.Provider,{value:e.assistant,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Wo,{def:t,selected:n,onSelect:r,issues:i}),n===Uo?(0,W.jsx)(Ho,{def:t,update:o}):s?(0,W.jsx)(qo,{...e,update:o,step:s}):(0,W.jsx)(Go,{def:t,onSelect:r,issues:i})]})})})}function qo({def:e,step:t,update:n,onSelect:r,issues:i,mcpServers:a,files:o,wizardId:s,decisions:c,branchFocus:u,assistant:d}){let p=e.steps.indexOf(t),m=t.type===`result`?p:p+1,[h,g]=(0,U.useState)(!1);(0,U.useEffect)(()=>g(!1),[t.id]);let _=P(t),v=r=>n({...e,steps:e.steps.map(e=>e.id===t.id?r:e)}),y=r=>{let i=p+r;if(i<0||i>=e.steps.length-(t.type===`result`?0:1)||e.steps[i].type===`result`)return;let a=[...e.steps];[a[p],a[i]]=[a[i],a[p]],n({...e,steps:a})},b=t=>{let i=rn(e,m,t);n(i.def),g(!1),r(i.id)},C=(e,t,n)=>d?.add({at:m,kind:e,prompt:t,when:n})?(g(!1),!0):!1,T=i.filter(e=>e.stepId===t.id),ee=Wa(s,e),E=(0,U.useContext)(Ao);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-4`,children:[(0,W.jsx)(`span`,{className:x(`inline-flex size-7 items-center justify-center rounded-md`,F[t.type]),children:(0,W.jsx)(_,{className:`size-4`})}),(0,W.jsx)(`span`,{className:`font-medium text-[0.75rem] text-ink-3 uppercase tracking-[0.07em]`,children:N(t)}),(0,W.jsx)(`span`,{className:`ml-auto font-mono text-[0.6875rem] text-ink-4`,children:t.id})]}),T.length?(0,W.jsx)(`div`,{className:`mx-5 mb-4 rounded-lg bg-rose-tint px-3 py-2 text-[0.8125rem] text-rose`,children:T.map((e,t)=>(0,W.jsx)(`div`,{children:e.message},t))}):null,(0,W.jsxs)(X,{children:[(0,W.jsx)(k,{value:t.title,onChange:e=>v({...t,title:e.target.value}),className:`font-display font-semibold text-[1rem]`}),t.type===`page`||t.type===`review`?(0,W.jsx)(S,{minRows:1,placeholder:`Erklärung unter dem Titel (optional)`,value:t.description??``,onChange:e=>v({...t,description:e.target.value||void 0})}):null,(0,W.jsx)(Ka,{estimate:ee.data,stepId:t.id})]}),(0,W.jsx)(Vo,{def:e,step:t,set:v,mcpServers:a,files:o,wizardId:s}),t.type===`result`?null:(0,W.jsx)(Qo,{def:e,step:t,set:v,onSelect:r,decision:c?.[t.id],focus:u,estimate:ee.data}),E?null:(0,W.jsxs)(X,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.type===`result`?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(D,{label:w(`editor.moveUp`),onClick:()=>y(-1),children:(0,W.jsx)(f,{className:`size-4`})}),(0,W.jsx)(D,{label:w(`editor.moveDown`),onClick:()=>y(1),children:(0,W.jsx)(ae,{className:`size-4`})}),(0,W.jsx)(_o,{label:w(`editor.deleteStep`),onDelete:()=>{n({...e,steps:e.steps.filter(e=>e.id!==t.id)}),r(null)}})]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,className:`ml-auto`,"aria-expanded":h,onClick:()=>g(e=>!e),children:[(0,W.jsx)(l,{className:`size-3.5`}),` `,w(`addStep.add`)]})]}),d?.adding&&d.adding.at===m?(0,W.jsx)(en,{adding:d.adding,place:Zt(e,m),working:d.working,onShowChat:d.showChat}):h?(0,W.jsx)($t,{place:Zt(e,m),branchable:m>0,onAdd:C,onEmpty:b,onCancel:()=>g(!1)}):null]})]})}function Jo({value:e,onChange:t}){let[n,r]=(0,U.useState)(e);return(0,U.useEffect)(()=>r(e),[e]),(0,W.jsx)(S,{minRows:1,"aria-label":w(`editor.branch.statement`),value:n,onChange:e=>{r(e.target.value),e.target.value.trim()&&t(e.target.value)},onBlur:()=>r(e)})}function Yo(e,t){let n=e.steps.indexOf(t),r=[];for(let t of e.steps.slice(0,n+1))if(t.type===`page`)r.push(...t.fields.map(e=>e.id));else if(t.type===`agent`)for(let e of t.output.fields??[])r.push(`steps.${t.id}.${e.id}`),et(t)&&r.push(`steps.${t.id}.${e.id}.p`);return r.push(...(e.lists??[]).map(e=>`lists.${e.id}.count`)),r}function Xo(e,t){return`${N(t)} · ${e.steps.indexOf(t)+1} / ${e.steps.length}`}function Zo({def:e,target:t,estimate:n,onSelect:r}){let[i,a]=(0,U.useState)(!1),o=P(t),s=n?.available?n.steps[t.id]?.credits:void 0,c=e.steps.indexOf(t),l=e.steps[c+1];return(0,W.jsxs)(`div`,{className:`rounded-lg bg-paper-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2.5`,children:[(0,W.jsx)(`span`,{className:x(`inline-flex size-7 shrink-0 items-center justify-center rounded-md`,F[t.type]),children:(0,W.jsx)(o,{className:`size-4`})}),(0,W.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>r(t.id),title:w(`editor.next.open`),children:[(0,W.jsx)(`span`,{className:`block text-[0.6875rem] text-ink-4`,children:Xo(e,t)}),(0,W.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem] text-ink hover:underline`,children:t.title})]}),(0,W.jsx)(D,{label:w(i?`editor.next.fold`:`editor.next.unfold`),className:`size-8 shrink-0`,onClick:()=>a(!i),children:i?(0,W.jsx)(Te,{className:`size-4`}):(0,W.jsx)(p,{className:`size-4`})})]}),i?(0,W.jsxs)(`div`,{className:`flex flex-col gap-1 border-border-soft border-t px-3 py-2.5 text-[0.75rem] text-ink-3`,children:[ue(t)?(0,W.jsx)(`span`,{className:`text-ink-2`,children:ue(t)}):null,s===void 0?null:(0,W.jsxs)(`span`,{className:`tabular-nums`,children:[`≈`,` `,w(`nav.credits`,{n:s<10?s.toLocaleString(void 0,{maximumFractionDigits:1}):Math.round(s)})]}),(0,W.jsxs)(`span`,{children:[w(`editor.next.then`),` →`,` `,t.type===`result`?w(`editor.branch.end`):t.next?.length?w(`editor.next.ways`,{count:t.next.length+1}):l?l.title:w(`editor.branch.end`)]}),(0,W.jsxs)(`button`,{type:`button`,className:`mt-1 self-start font-medium text-ember hover:underline`,onClick:()=>r(t.id),children:[w(`editor.next.open`),` →`]})]}):null]})}function Qo({def:e,step:t,set:n,onSelect:r,decision:i,focus:a,estimate:o}){let s=(0,U.useRef)(null);(0,U.useEffect)(()=>{a&&s.current?.scrollIntoView({block:`start`,behavior:`smooth`})},[a]);let[c,u]=(0,U.useState)(null);(0,U.useEffect)(()=>u(null),[t.id]);let d=t.next??[],f=e.steps.indexOf(t),m=e.steps[f+1],h=t=>e.steps.find(e=>e.id===t)?.title??w(`editor.branch.end`),g=[...e.steps.filter(e=>e.id!==t.id).map(t=>({value:t.id,label:`${e.steps.indexOf(t)+1}. ${t.title}`})),{value:`end`,label:w(`editor.branch.end`)}],_=Yo(e,t),y=(e,r)=>{n({...t,next:r?d.map((t,n)=>n===e?r:t):d.length>1?d.filter((t,n)=>n!==e):void 0}),r||u(null)},b=e=>{let r=e.ask?d.length:d.filter(e=>e.when!==void 0).length;n({...t,next:[...d.slice(0,r),e,...d.slice(r)]}),u(r)},S=t=>{let n=e.steps.findIndex(e=>e.id===t);return n>=0&&n<=f},C=e=>i?.probabilities?.[e],T=d.some(e=>e.ask),ee=[...d.map((e,t)=>({rule:e,i:t})).filter(({rule:e})=>e.when!==void 0),...d.map((e,t)=>({rule:e,i:t})).filter(({rule:e})=>e.ask)],E=d.findIndex(lt),te=E>=0?d[E].goto:m?.id??`end`,O=e.steps.find(e=>e.id===te),A=e=>{let r=d.filter(e=>!lt(e)),i=e===(m?.id??`end`)?r:[...r,{goto:e}];n({...t,next:i.length?i:void 0})},ne=`${w(`editor.branch.how`)} ${i?w(`editor.branch.lastRun`,{source:i.source===`systemone`?w(`editor.branch.bySystemOne`):w(`editor.branch.byLlm`)}):w(`editor.branch.notYet`)}`,j=e=>e?(0,W.jsxs)(`span`,{className:`inline-flex shrink-0 cursor-help items-center gap-1 rounded-full bg-paper-3 px-2 py-0.5 font-medium text-[0.6875rem] text-ink-2`,title:ne,children:[(0,W.jsx)(H,{className:`size-3 text-ember`}),` `,w(`editor.branch.ai`),(0,W.jsx)(It,{className:`size-3 text-ink-4`})]}):null,M=(e,t)=>e===void 0?null:(0,W.jsx)(`span`,{className:x(`shrink-0 text-[0.75rem] tabular-nums`,t?`font-medium text-moss`:`text-ink-3`),children:ao(e)}),re=(e,t,n,i,a,o)=>{let s=c===e||e===`otherwise`&&c===-1;return(0,W.jsxs)(`div`,{className:x(`rounded-lg bg-paper-2 ring-1`,i?`ring-moss`:`ring-transparent`),children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 pt-2.5 text-left`,onClick:()=>u(s?null:e===`otherwise`?-1:e),children:[t,M(a,i),s?(0,W.jsx)(Te,{className:`size-4 shrink-0 text-ink-4`}):(0,W.jsx)(p,{className:`size-4 shrink-0 text-ink-4`})]}),(0,W.jsxs)(`div`,{className:`px-3 pt-1 pb-2.5 text-[0.75rem] text-ink-3`,children:[`→`,` `,n===`end`?w(`editor.branch.end`):(0,W.jsx)(`button`,{type:`button`,className:`text-ink-2 hover:text-ink hover:underline`,onClick:()=>r(n),children:h(n)}),i?(0,W.jsx)(`span`,{className:`ml-1.5 text-moss`,children:`✓`}):null]}),s?(0,W.jsx)(`div`,{className:`flex flex-col gap-2 border-border-soft border-t px-3 py-3`,children:o}):null]},e)},ie=(t,n)=>(0,W.jsxs)(W.Fragment,{children:[t.ask?(0,W.jsx)(Jo,{value:t.ask,onChange:e=>y(n,{...t,ask:e})}):(0,W.jsx)(Fo,{def:e,when:t.when,sources:_,label:w(`editor.branch.when`),noneLabel:w(`editor.branch.pick`),onChange:e=>{e&&y(n,{...t,when:e})}}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-3`,children:`→`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(v,{value:t.goto,onChange:e=>y(n,{...t,goto:e}),options:g})}),S(t.goto)?(0,W.jsx)(k,{type:`number`,min:1,max:50,className:`w-20 shrink-0`,"aria-label":w(`editor.branch.max`),title:w(`editor.branch.max`),placeholder:`10`,value:t.max??``,onChange:e=>{let r=Math.round(Number(e.target.value));y(n,{...t,max:r>=1?Math.min(r,50):void 0})}}):null,(0,W.jsx)(D,{label:w(`editor.branch.remove`),className:`shrink-0 hover:text-rose`,onClick:()=>y(n,null),children:(0,W.jsx)(L,{className:`size-4`})})]})]}),ae=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,W.jsxs)(`button`,{type:`button`,disabled:!_.length,onClick:()=>b({when:{field:_[0]??``,op:`notEmpty`},goto:m?.id??`end`}),className:`inline-flex h-8 items-center gap-1 rounded-full px-2.5 text-[0.75rem] text-ink-2 hover:bg-accent disabled:opacity-50`,children:[(0,W.jsx)(l,{className:`size-3.5`}),` `,w(`editor.branch.addWhen`)]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>b({ask:w(`editor.branch.newAsk`),goto:m?.id??`end`}),className:`inline-flex h-8 items-center gap-1 rounded-full px-2.5 text-[0.75rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(H,{className:`size-3.5`}),` `,w(`editor.branch.addAsk`)]})]});return(0,W.jsx)(`div`,{ref:s,className:`scroll-mt-14`,children:(0,W.jsxs)(X,{title:ee.length?w(`editor.next.ways`,{count:ee.length+1}):w(`editor.next.title`),loose:!0,children:[d.length?(0,W.jsxs)(W.Fragment,{children:[ee.map(({rule:e,i:t})=>re(t,(0,W.jsxs)(W.Fragment,{children:[j(!!e.ask),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] text-ink`,children:e.ask??Qe(e.when).map(so).join(` ${w(`editor.branch.and`)} `)})]}),e.goto,i?.rule===t,C(`r${t}`),ie(e,t))),re(`otherwise`,(0,W.jsx)(`span`,{className:`min-w-0 flex-1 text-[0.8125rem] text-ink-3`,children:w(T?`editor.branch.none`:`editor.otherwise`)}),te,i?.rule===null,C(`none`),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0 text-[0.8125rem] text-ink-3`,children:`→`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(v,{value:te,onChange:A,options:g})})]}),O?(0,W.jsx)(Zo,{def:e,target:O,estimate:o,onSelect:r}):null]}))]}):m?(0,W.jsx)(Zo,{def:e,target:m,estimate:o,onSelect:r}):(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:w(`editor.branch.end`)}),ae]})})}function $o({wizardId:e,projectId:t,def:n,readOnly:i}){let a=r(),o=fe(t),[s,c]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),h=[...(o.data?.pages??[]).filter(t=>t.wizardId===e).map(e=>({key:`p:${e.id}`,kind:`page`,title:e.title,at:e.updatedAt})),...(o.data?.tables??[]).filter(t=>t.wizardId===e).map(e=>({key:`t:${e.id}`,kind:`table`,title:e.title,at:e.updatedAt,rows:e.rows}))],g=n.steps.some(e=>e.type===`agent`&&e.tools.includes(`pages`)),_=(n.lists??[]).some(e=>e.shared),v=new Intl.DateTimeFormat(T,{dateStyle:`medium`}),y=()=>a.invalidateQueries({queryKey:[`space-data`,t]});if(s){let e=s.slice(2);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 px-5 py-5`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{c(null),y()},className:`inline-flex h-8 items-center gap-1.5 self-start rounded-full px-2.5 text-[0.8125rem] text-ink-2 hover:bg-accent`,children:[(0,W.jsx)(m,{className:`size-4`}),` `,w(`memory.back`)]}),s.startsWith(`p:`)?(0,W.jsx)(me,{pageId:e,onGone:()=>{c(null),y()}}):(0,W.jsx)(de,{tableId:e,onGone:()=>{c(null),y()}})]})}let S=async()=>{d(!0),p(null);try{let{id:n}=await M.post(`/api/studio/projects/${t}/pages`,{title:w(`memory.newNote`),wizardId:e});await y(),c(`p:${n}`)}catch(e){p(e.message)}finally{d(!1)}};return(0,W.jsxs)(`div`,{className:`flex min-h-full flex-col gap-4 px-5 py-5`,children:[g||_?null:(0,W.jsx)(`p`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[0.8125rem] text-ink-2`,children:w(`memory.unused`)}),o.isLoading?(0,W.jsx)(b,{className:`size-4 text-ink-4`}):h.length?(0,W.jsx)(`ul`,{className:`flex flex-col gap-1`,children:h.map(e=>{let t=pe[e.kind];return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>c(e.key),className:`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left hover:bg-paper-2`,children:[(0,W.jsx)(t,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:e.title}),(0,W.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-4 tabular-nums`,children:[e.kind===`table`?`${w(`data.rows`,{n:e.rows??0})} · `:``,v.format(new Date(e.at))]})]})},e.key)})}):(0,W.jsx)(`div`,{className:`rounded-xl border border-border border-dashed px-4 py-8 text-center text-[0.8125rem] text-ink-4`,children:w(`memory.none`)}),f?(0,W.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:f}):null,i?null:(0,W.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>void S(),className:x(`inline-flex h-9 items-center gap-1.5 self-start rounded-full bg-paper-2 px-3.5 font-medium text-[0.8125rem] text-ink-2 hover:bg-paper-3 hover:text-ink`,u&&`opacity-60`),children:[u?(0,W.jsx)(b,{className:`size-3.5`}):(0,W.jsx)(l,{className:`size-3.5`}),w(`memory.add`)]}),(0,W.jsxs)(`div`,{className:`mt-auto flex flex-col gap-1.5 pt-6 text-[0.6875rem] text-ink-4 leading-relaxed`,children:[(0,W.jsx)(`p`,{children:w(`memory.explain`)}),(0,W.jsx)(`p`,{children:w(`memory.testCopy`)})]})]})}var es={waiting_input:`wartet`,running:`läuft`,done:`fertig`,failed:`Fehler`,cancelled:`abgebrochen`};function ts({wizardId:e,onOpen:t}){let n=i({queryKey:[`runs`,e],queryFn:()=>M.get(`/api/studio/wizards/${e}/runs`),refetchInterval:1e4});if(n.data&&!n.data.length)return(0,W.jsx)(h,{children:w(`editor.noRuns`)});let r=new Intl.DateTimeFormat(T,{dateStyle:`short`,timeStyle:`short`});return(0,W.jsx)(`div`,{className:`flex flex-col p-2`,children:n.data?.map(e=>(0,W.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,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-[0.875rem]`,children:[r.format(new Date(e.createdAt)),e.mode===`test`?(0,W.jsx)(O,{children:`Test`}):(0,W.jsxs)(O,{tone:`live`,children:[`Live v`,e.version]})]}),(0,W.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[es[e.status]??e.status,e.stepTitle&&e.status!==`done`?` · ${e.stepTitle}`:``]})]}),(0,W.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:w(`nav.credits`,{n:e.credits})})]},e.id))})}var Z=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Z||{}),ns=[0,1],rs=[1,0],is=[2,3],as=[3,2],os={L:ns,M:rs,Q:is,H:as},ss=/^\d*$/,cs=/^[A-Z0-9 $%*+./:-]*$/,ls=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,us=1,ds=40,fs=3,ps=3,ms=40,hs=10,gs=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],_s=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],vs=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<us||e>ds)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Z.Timing),this.setFunctionModule(e,6,e%2==0,Z.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,$(r,e));this.setFunctionModule(8,7,$(r,6)),this.setFunctionModule(8,8,$(r,7)),this.setFunctionModule(7,8,$(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,$(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,$(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,$(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=$(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Z.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Z.Alignment)}setFunctionModule(e,t,n,r=Z.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Ns(t,n))throw RangeError(`Invalid argument`);let r=_s[n[0]][t],i=gs[n[0]][t],a=Math.floor(Ms(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=Ps(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=Fs(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(Ms(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=$(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=fs:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*ms),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*ms}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=fs:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*ms),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*ms}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=ps)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*hs,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Q(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function $(e,t){return!!(e>>>t&1)}var ys=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},bs=[1,10,12,14],xs=[2,9,11,13],Ss=[4,8,16,16];function Cs(e,t){return e[Math.floor((t+7)/17)+1]}function ws(e){let t=[];for(let n of e)Q(n,8,t);return new ys(Ss,e.length,t)}function Ts(e){if(!Os(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Q(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new ys(bs,e.length,t)}function Es(e){if(!ks(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=ls.indexOf(e.charAt(n))*45;r+=ls.indexOf(e.charAt(n+1)),Q(r,11,t)}return n<e.length&&Q(ls.indexOf(e.charAt(n)),6,t),new ys(xs,e.length,t)}function Ds(e){return e===``?[]:Os(e)?[Ts(e)]:ks(e)?[Es(e)]:[ws(js(e))]}function Os(e){return ss.test(e)}function ks(e){return cs.test(e)}function As(e,t){let n=0;for(let r of e){let e=Cs(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function js(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function Ms(e){if(e<us||e>ds)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Ns(e,t){return Math.floor(Ms(e)/8)-gs[t[0]][e]*_s[t[0]][e]}function Ps(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=Is(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Is(n,2)}return t}function Fs(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=Is(t,e))}return n}function Is(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function Ls(e,t,n=1,r=40,i=-1,a=!0){if(!(us<=n&&n<=r&&r<=ds)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Ns(o,t)*8,i=As(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[rs,is,as])a&&s<=Ns(o,e)*8&&(t=e);let c=[];for(let t of e){Q(t.mode[0],4,c),Q(t.numChars,Cs(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Ns(o,t)*8;Q(0,Math.min(4,l-c.length),c),Q(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Q(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new vs(o,t,u,i)}function Rs(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?Ds(e):Array.isArray(e)?[ws(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=Ls(c,os[n],i,a,o,r),u=zs({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function zs(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Z.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function Bs(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function Vs(e,t={}){let n=Rs(e,t),{pixelSize:r=10,whiteColor:i=`white`,blackColor:a=`black`}=t,o=n.size*r,s=n.size*r,c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${s} ${o}">`,l=[];for(let e=0;e<n.size;e++)for(let t=0;t<n.size;t++){let i=t*r,a=e*r;n.data[e][t]&&l.push(`M${i},${a}h${r}v${r}h-${r}z`)}return c+=`<rect fill="${Bs(i)}" width="${s}" height="${o}"/>`,c+=`<path fill="${Bs(a)}" d="${l.join(``)}"/>`,c+=`</svg>`,c}var Hs=e=>`${e.slice(0,4)} ${e.slice(4)}`;function Us(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}async function Ws(e,t){let n=new Image,r=URL.createObjectURL(new Blob([e],{type:`image/svg+xml`}));try{n.src=r,await n.decode();let e=document.createElement(`canvas`);e.width=1024,e.height=1024;let i=e.getContext(`2d`);if(!i)return;i.imageSmoothingEnabled=!1,i.drawImage(n,0,0,1024,1024);let a=await new Promise(t=>e.toBlob(t,`image/png`));a&&Us(a,t)}finally{URL.revokeObjectURL(r)}}function Gs({url:e,code:t,title:n}){let r=(0,U.useMemo)(()=>Vs(e,{ecc:`M`,border:2,pixelSize:8}),[e]),i=(n.trim()||`wizard`).replace(/[^\p{L}\p{N}]+/gu,`-`).toLowerCase();return(0,W.jsxs)(`div`,{className:`flex gap-4`,children:[(0,W.jsx)(`div`,{role:`img`,"aria-label":w(`share.qr`),className:`size-28 shrink-0 overflow-hidden rounded-lg bg-white [&>svg]:size-full`,dangerouslySetInnerHTML:{__html:r}}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`share.qrHint`)}),t?(0,W.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[w(`share.code`),` `,(0,W.jsx)(`span`,{className:`select-all font-mono text-[0.9375rem] text-ink tracking-wider`,children:Hs(t)})]}):null,(0,W.jsxs)(`div`,{className:`mt-auto flex gap-2`,children:[(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>void Ws(r,`${i}-qr.png`),children:[(0,W.jsx)(qe,{className:`size-3.5`}),` PNG`]}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>Us(new Blob([r],{type:`image/svg+xml`}),`${i}-qr.svg`),children:[(0,W.jsx)(qe,{className:`size-3.5`}),` SVG`]})]})]})]})}var Ks=e=>e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),qs=()=>new Intl.DateTimeFormat(T,{timeStyle:`short`});function Js({url:e,title:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.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="${Ks(t)}"`:``}><\/script>`,l=[w(`embed.inline`),w(`embed.modal`)];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(n?`embed.modalHint`:`embed.inlineHint`)}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(c),a(!0),setTimeout(()=>a(!1),1500)},children:[i?(0,W.jsx)(d,{className:`size-3.5`}):(0,W.jsx)(R,{className:`size-3.5`}),w(i?`share.copied`:`share.copy`)]})]}),(0,W.jsx)(j,{value:l[+!!n],onChange:e=>r(e===l[1]),options:l}),(0,W.jsx)(`pre`,{className:`select-all whitespace-pre-wrap break-all rounded-lg bg-paper-2 px-3 py-2.5 font-mono text-[0.75rem] text-ink-2 leading-relaxed`,children:c})]})}var Ys=e=>x(`inline-flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] transition`,e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`);function Xs({url:e,code:t,title:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),s=e=>o(t=>t===e?null:e);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(k,{readOnly:!0,value:e,onFocus:e=>e.target.select(),className:`font-mono text-[0.8125rem]`}),(0,W.jsxs)(A,{variant:`secondary`,onClick:()=>{navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)},children:[r?(0,W.jsx)(d,{className:`size-4`}):(0,W.jsx)(R,{className:`size-4`}),w(r?`share.copied`:`share.copy`)]})]}),(0,W.jsxs)(`div`,{className:`-ml-3 flex flex-wrap gap-1`,children:[(0,W.jsxs)(`button`,{type:`button`,className:Ys(!1),onClick:()=>vt(e),children:[(0,W.jsx)(ve,{className:`size-3.5`}),` `,w(`share.open`)]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":a===`website`,className:Ys(a===`website`),onClick:()=>s(`website`),children:[(0,W.jsx)(Ot,{className:`size-3.5`}),` `,w(`share.website`)]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":a===`qr`,className:Ys(a===`qr`),onClick:()=>s(`qr`),children:[(0,W.jsx)(Wt,{className:`size-3.5`}),` `,w(`share.qr`)]})]}),a===`website`?(0,W.jsx)(Js,{url:e,title:n}):null,a===`qr`?(0,W.jsx)(Gs,{url:e,code:t,title:n}):null]})}var Zs={sandbox:`cloud.problem.sandbox`,mcp:`cloud.problem.mcp`,model:`cloud.problem.model`,connector:`cloud.problem.connector`,invalid:`cloud.problem.invalid`};function Qs({problems:e,quiet:t}){return(0,W.jsx)(`ul`,{className:x(`flex flex-col gap-2 text-[0.8125rem]`,t?`text-ink-3`:`text-ink-2`),children:e.map((e,n)=>(0,W.jsxs)(`li`,{children:[e.steps.length?(0,W.jsxs)(`span`,{className:x(`font-medium`,t?`text-ink-2`:`text-ink`),children:[e.steps.map(e=>w(`cloud.stepName`,{title:e.title})).join(`, `),`:`,` `]}):null,w(Zs[e.code]??`cloud.problem.invalid`,{detail:e.detail}),e.detail&&e.code!==`mcp`&&e.code!==`sandbox`?(0,W.jsxs)(`details`,{className:`mt-0.5`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-[0.75rem] text-ink-4 hover:text-ink-3`,children:w(`share.details`)}),(0,W.jsx)(`span`,{className:`mt-0.5 block break-words font-mono text-[0.6875rem] text-ink-4`,children:e.detail})]}):null]},n))})}function $s({error:e}){let t=r(),n=e.reason===`space_limit`,a=i({queryKey:[`cloud-spaces`],queryFn:()=>M.get(`/api/studio/cloud/spaces`),enabled:n,retry:!1}),o=Ie({mutationFn:()=>M.post(`/api/studio/cloud/replace`),onSettled:()=>Promise.all([t.invalidateQueries({queryKey:[`cloud`]}),t.invalidateQueries({queryKey:[`cloud-spaces`]}),t.invalidateQueries({queryKey:[`wizards`]})])});if(!n)return(0,W.jsxs)(`p`,{children:[e.message,` `,e.reason===`signed_out`?(0,W.jsx)(te,{to:`/settings/account`,className:`font-medium underline underline-offset-2`,children:w(`local.toAccount`)}):null,e.again?(0,W.jsx)(`span`,{className:`text-ink-3`,children:w(`cloud.again`,{when:qs().format(new Date(e.again))})}):null]});let s=(a.data?.spaces??[]).map(e=>e.name);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(`p`,{children:e.message}),(0,W.jsx)(`p`,{className:`text-ink-2`,children:w(`cloud.spaceLimit`)}),s.length?(0,W.jsx)(`ul`,{className:`list-disc pl-5`,children:s.map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}):null,(0,W.jsx)(`div`,{children:(0,W.jsx)(A,{variant:`secondary`,size:`sm`,busy:o.isPending,onClick:()=>window.confirm(w(`cloud.replaceConfirm`))&&o.mutate(),children:w(`cloud.replace`)})}),o.error?(0,W.jsx)(`p`,{className:`text-rose`,children:o.error.message}):null]})}function ec({wizard:e,where:t,me:n,cloud:i}){let a=r(),o=Ie({mutationFn:()=>M.post(`/api/studio/wizards/${e.id}/cloud`),onSuccess:t=>{a.setQueryData([`cloud`,e.id],t),a.invalidateQueries({queryKey:[`wizards`]})}}),s=`flex items-start gap-2 text-[0.875rem] text-ink-2`;switch(t.kind){case`draft`:return null;case`unknown`:return(0,W.jsx)(b,{className:`size-4 text-ink-4`});case`here`:return(0,W.jsxs)(`p`,{className:s,children:[(0,W.jsx)(Je,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),` `,w(`where.hereHint`)]});case`live`:return(0,W.jsxs)(`p`,{className:s,title:i?.copy?w(`cloud.sent`,{v:i.copy.version,when:new Intl.DateTimeFormat(T,{dateStyle:`short`,timeStyle:`short`}).format(new Date(i.copy.syncedAt))}):void 0,children:[t.cloud?(0,W.jsx)(St,{className:`mt-0.5 size-4 shrink-0 text-moss`}):(0,W.jsx)(`span`,{className:`mt-[7px] size-1.5 shrink-0 rounded-full bg-moss`}),t.cloud?w(`where.liveAt`,{host:B(n.account?.cloudUrl??``),v:t.runs}):w(`editor.published`,{v:t.runs})]})}let c=i?.copy??null,l=i?.error??null,u=c&&!c.runnable?c.problems.filter(e=>e.blocking):[],d=e.published&&(!c||c.version<(e.publishedVersion??0)||l)&&l?.reason!==`space_limit`&&l?.reason!==`signed_out`;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-amber-tint px-3 py-2.5 text-[0.875rem]`,children:[l?(0,W.jsx)($s,{error:l}):t.kind===`missing`?(0,W.jsx)(`p`,{children:t.why}):null,l&&t.runs!==null?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`cloud.keepsRunning`,{v:t.runs})}):null,u.length?(0,W.jsx)(Qs,{problems:u}):null,d?(0,W.jsx)(`div`,{children:(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,busy:o.isPending,onClick:()=>o.mutate(),children:[(0,W.jsx)(wt,{className:`size-3.5`}),w(c||l?`cloud.resend`:`cloud.send`)]})}):null,o.error?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o.error.message}):null]})}function tc({wizard:e,cloud:t}){let n=t?.copy??null,r=e.publishedVersion,a=n!==null&&r!==null&&n.version<r,o=!n||e.dirty||a,s=i({queryKey:[`cloud-check`,e.id,e.revision],queryFn:()=>M.get(`/api/studio/wizards/${e.id}/cloud/check`),enabled:t?.linked===!0&&o,retry:!1,staleTime:3e4}),c=!o&&n?n.problems.filter(e=>!e.blocking):[],l=o?s.data?.problems??[]:[];return c.length||l.length||o&&s.data?.documents?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c.length?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`cloud.notes`)}),(0,W.jsx)(Qs,{problems:c,quiet:!0})]}):null,l.length?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2`,children:w(l.some(e=>e.blocking)?`cloud.checkBlocking`:`cloud.check`)}),(0,W.jsx)(Qs,{problems:l,quiet:!0})]}):null,o&&s.data?.documents?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`cloud.documents`)}):null]}):o&&s.error&&!t?.error?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:s.error.message}):null}function nc({way:e}){let t=o(),n=Se(!1);return(0,W.jsxs)(`div`,{className:x(`flex flex-col gap-3`,e?`rounded-lg bg-cobalt-tint px-3 py-3`:`border-border-soft border-t pt-5`),children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-medium text-[0.875rem]`,children:w(`share.others`)}),(0,W.jsx)(`p`,{className:`mt-1 text-[0.8125rem] text-ink-2 leading-relaxed`,children:w(e===`website`?`teaser.website`:e===`qr`?`teaser.qr`:`share.othersHint`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(A,{size:`sm`,busy:n.link.isPending,onClick:()=>n.link.mutate({}),children:w(`account.signIn`)}),(0,W.jsx)(A,{size:`sm`,variant:`secondary`,onClick:()=>t(`/settings/account`),children:w(`account.create`)})]}),(0,W.jsx)(xe,{...n})]})}function rc({wizard:e,cloud:t}){let n=r(),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(String(e.dailyRunLimit)),c=()=>Promise.all([n.invalidateQueries({queryKey:[`wizard`,e.id]}),n.invalidateQueries({queryKey:[`wizards`]})]),l=Ie({mutationFn:t=>M.patch(`/api/studio/wizards/${e.id}`,t),onSuccess:c}),u=Ie({mutationFn:()=>M.post(`/api/studio/wizards/${e.id}/rotate-link`),onSuccess:({cloud:t})=>(t&&n.setQueryData([`cloud`,e.id],{linked:!0,...t}),c())}),d=e.readOnly,f=l.error??u.error,p=Wa(e.id,e.draft),m=p.data?.available&&p.data.reserve>0?Math.round(p.data.reserve*e.dailyRunLimit):null,h=i||!!f;return(0,W.jsxs)(`div`,{className:`border-border-soft border-t pt-4`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":h,onClick:()=>a(e=>!e),className:`flex w-full items-center justify-between gap-4 text-left text-[0.875rem]`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(re,{className:x(`size-4 text-ink-3 transition`,h&&`rotate-90`)}),w(`share.settings`)]}),(0,W.jsxs)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:[w(e.shareEnabled?`share.on`:`share.off`),` ·`,` `,w(`share.perDay`,{n:e.dailyRunLimit})]})]}),h?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-col gap-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-[0.875rem]`,children:w(`share.enabled`)}),(0,W.jsx)(E,{checked:e.shareEnabled,disabled:d,onChange:e=>l.mutate({shareEnabled:e})})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,W.jsx)(`span`,{className:`whitespace-nowrap text-[0.875rem]`,children:w(`share.limit`)}),(0,W.jsx)(`div`,{className:`w-24`,children:(0,W.jsx)(k,{inputMode:`numeric`,className:`text-right`,disabled:d,value:o,onChange:e=>s(e.target.value.replace(/\D/g,``)),onBlur:()=>{let t=Number(o);t>=1&&t!==e.dailyRunLimit&&l.mutate({dailyRunLimit:t})}})})]}),m!==null&&p.data?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:w(`estimate.share`,{run:Math.round(p.data.credits).toLocaleString(),day:m.toLocaleString()})}):null,(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,W.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:w(t?.copy?`share.rotateCloud`:`share.rotateHint`)}),(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,busy:u.isPending,disabled:d,onClick:()=>u.mutate(),children:[(0,W.jsx)(we,{className:`size-3.5`}),` `,w(`share.rotate`)]})]}),f?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:f.message}):null]}):null,d?(0,W.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:w(`share.readOnly`)}):null]})}function ic({wizard:e,open:t,onClose:n,publish:r}){let a=We(),o=a.data?.mode===`local`,s=o&&!!a.data?.account,c=Fe(e.id,t&&s),l=a.data?ke(e,a.data,s?c.data:null):{kind:`unknown`},u=V(l),d=a.data?.mode===`managed`&&e.published,f=i({queryKey:[`wizard-code`,e.id,e.shareToken],queryFn:()=>M.get(`/api/studio/wizards/${e.id}/code`),enabled:t&&d}),p=!e.published||e.dirty&&!e.readOnly,[m,h]=(0,U.useState)(null);return(0,W.jsx)(C,{open:t,onClose:n,title:w(`share.title`),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p?(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-amber-tint px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-[0.875rem]`,children:w(e.published?`share.unpublished`:`share.publishFirst`)}),r?(0,W.jsx)(A,{size:`sm`,busy:r.busy,disabled:r.disabled,onClick:r.run,children:w(`editor.publish`)}):null]}),s&&!e.published?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`cloud.onPublish`)}):null]}):null,a.data&&e.published?(0,W.jsx)(ec,{wizard:e,where:l,me:a.data,cloud:c.data}):null,c.isError?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c.error.message}):null,u?(0,W.jsx)(Xs,{url:u,code:d?f.data?.code:c.data?.copy?.code,title:e.draft.title}):null,o&&!s&&e.published?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(k,{readOnly:!0,value:Oe(e),onFocus:e=>e.target.select(),className:`font-mono text-[0.8125rem] text-ink-3`}),(0,W.jsxs)(A,{variant:`secondary`,onClick:()=>vt(Oe(e)),children:[(0,W.jsx)(ve,{className:`size-4`}),` `,w(`share.open`)]})]}),He.account?(0,W.jsx)(`div`,{className:`-ml-3 flex flex-wrap gap-1`,children:[`website`,`qr`].map(e=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":m===e,className:Ys(m===e),onClick:()=>h(t=>t===e?null:e),children:[e===`website`?(0,W.jsx)(Ot,{className:`size-3.5`}):(0,W.jsx)(Wt,{className:`size-3.5`}),w(e===`website`?`share.website`:`share.qr`),(0,W.jsx)(Ke,{className:`size-3 text-cobalt`})]},e))}):null]}):null,s?(0,W.jsx)(tc,{wizard:e,cloud:c.data}):null,o&&!s&&He.account?(0,W.jsx)(nc,{way:m}):null,(0,W.jsx)(rc,{wizard:e,cloud:s?c.data:void 0}),s&&e.published?(0,W.jsxs)(`button`,{type:`button`,onClick:()=>vt(Oe(e)),className:`inline-flex items-center gap-1.5 self-start text-[0.8125rem] text-ink-3 hover:text-ink`,children:[(0,W.jsx)(Je,{className:`size-3.5`}),` `,w(`share.openHere`),(0,W.jsx)(ve,{className:`size-3`})]}):null]})})}var ac=[`title`,`description`,`avatar`,`intro`,`lists`,`connections`],oc=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function sc(e,t,n){let r={...n};for(let n of ac)oc(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||!oc(t,e)});return t.steps.forEach((e,n)=>{let r=i.get(e.id);if(r&&oc(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 cc(e){let t=r(),n=(0,U.useMemo)(()=>[`wizard`,e],[e]),i=`/api/studio/wizards/${e}`,a=(0,U.useRef)(null),o=(0,U.useRef)(Promise.resolve()),s=(0,U.useRef)(null),l=(0,U.useRef)(null),u=(0,U.useRef)(!1),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(0),[h,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(null),b=(0,U.useCallback)(()=>!!(a.current||u.current||s.current),[]),x=(0,U.useCallback)(async()=>{let e=await M.get(i);t.setQueryData(n,t=>t&&b()?{...e,draft:t.draft,title:t.title,revision:t.revision,dirty:!0}:e)},[t,n,i,b]),S=(0,U.useCallback)(()=>{o.current=o.current.then(async()=>{let e=s.current,r=t.getQueryData(n);if(e&&r){s.current=null,u.current=!0,f(!0);try{let a=await M.put(`${i}/draft`,{definition:e,baseRevision:r.revision});l.current=s.current?e:null,t.setQueryData(n,e=>e&&{...e,revision:a.revision,issues:a.issues})}catch(r){let a=Ve(r);if(a){s.current=null,l.current=null,y(a);let e=await M.get(i).catch(()=>null);e&&t.setQueryData(n,e);return}if(!(r instanceof g&&r.status===409)){s.current??=e,console.error(`[draft] save failed`,r);return}let o=await M.get(i),c=sc(l.current??o.draft,s.current??e,o.draft);l.current=o.draft,s.current=c,t.setQueryData(n,{...o,draft:c,title:c.title,dirty:!0}),m(Date.now()),S()}finally{u.current=!1,f(!1)}}})},[t,n,i]),C=(0,U.useCallback)(r=>{e&&(b()||(l.current=t.getQueryData(n)?.draft??null),s.current=r,t.setQueryData(n,e=>e&&{...e,draft:r,title:r.title,dirty:!0}),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,S()},600))},[t,n,e,b,S]);return(0,U.useEffect)(()=>{if(!e)return;let r=new EventSource(c(`/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||(x(),r.kind===`draft`&&r.source===`mcp`&&_({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&&x()}),()=>r.close()},[t,n,e,x]),(0,U.useEffect)(()=>{if(!h)return;let e=setTimeout(()=>_(null),6e3);return()=>clearTimeout(e)},[h]),(0,U.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>m(0),4e3);return()=>clearTimeout(e)},[p]),{save:C,saving:d,remote:h,merged:p>0,refused:v}}function lc({remote:e,merged:t}){return e?(0,W.jsxs)(O,{tone:`ember`,children:[(0,W.jsx)(Pe,{className:`size-3`}),` `,w(`editor.changedVia`,{client:e.client})]}):t?(0,W.jsxs)(O,{children:[(0,W.jsx)(Pt,{className:`size-3`}),` `,w(`editor.merged`)]}):null}var uc=[...ot,`image`,`video`],dc={chat:`editor.chat`,step:`editor.step`,files:`editor.files`,memory:`editor.memory`,runs:`editor.runs`},fc=`wizards.editor.pane`,pc=420,mc=340,hc=()=>Math.max(mc,window.innerWidth-480);function gc(){try{let e=Number(localStorage.getItem(fc));return e?Math.min(Math.max(e,mc),hc()):pc}catch{return pc}}function _c(){let[e,t]=(0,U.useState)(gc),n=(0,U.useCallback)(e=>{let n=Math.round(Math.min(Math.max(e,mc),hc()));t(n);try{localStorage.setItem(fc,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(pc)}}var vc=`wizards.editor.sheet`,yc=55,bc=76,xc=96,Sc=6;function Cc(){try{let e=localStorage.getItem(vc),t=e===null?NaN:Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):yc}catch{return yc}}function wc(){let[e,t]=(0,U.useState)(Cc),[n,r]=(0,U.useState)(!1),i=(0,U.useRef)(null),a=(0,U.useRef)(e||yc),o=(0,U.useCallback)((e,n=!0)=>{let r=Math.round(Math.min(Math.max(e,0),100)*10)/10;r>0&&n&&(a.current=r),t(r);try{localStorage.setItem(vc,String(r))}catch{}},[]),s=e===0,c=()=>o(s?a.current:0);return{ref:i,percent:e,height:`clamp(${bc}px, ${e}%, calc(100% - ${xc}px))`,folded:s,dragging:n,unfold:()=>{s&&o(a.current)},onPointerDown:t=>{let n=i.current,a=n?.parentElement;if(!(n&&a)||t.button!==0)return;t.preventDefault();let s=t.clientY,l=n.getBoundingClientRect().height,u=a.getBoundingClientRect().height,d=!1,f=e,p=e=>{if(!d&&Math.abs(e.clientY-s)<Sc)return;d||(d=!0,r(!0));let t=Math.min(l+s-e.clientY,u-xc);f=t<92?0:t/u*100,o(f,!1)},m=e=>{window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m),document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`),r(!1),d?o(f):e.type===`pointerup`&&c()};document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},onKeyDown:t=>{let n=t.shiftKey?25:10;t.key===`ArrowUp`?(t.preventDefault(),o(e+n)):t.key===`ArrowDown`?(t.preventDefault(),o(e-n<15?0:e-n)):(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c())}}}function Tc(){let{id:e}=y(),t=o(),n=r(),a=We(),[s,l]=ne(),u=i({queryKey:[`wizard`,e],queryFn:()=>M.get(`/api/studio/wizards/${e}`),refetchOnWindowFocus:!1}),[d,f]=(0,U.useState)(null),[p,h]=(0,U.useState)(`chat`),g=_c(),_=wc(),[v,S]=(0,U.useState)(!1),[C,T]=(0,U.useState)(null),[E,te]=(0,U.useState)(null),[k,j]=(0,U.useState)(),[re,ae]=(0,U.useState)(0),[N,se]=(0,U.useState)(null),[ce,P]=(0,U.useState)(null),le=(0,U.useCallback)(e=>P(e),[]),ue=(0,U.useCallback)(e=>{te(e&&e.status!==`done`?e.step?.id??null:null),e&&j(e.decisions)},[]),{save:F,saving:de,remote:fe,merged:pe,refused:me}=cc(e),ge=Me(),I=je(u.data,(t,r)=>{n.setQueryData([`wizard`,e],e=>e&&{...e,draft:t,revision:r,title:t.title,blank:!1})}),_e=(0,U.useRef)(!1);(0,U.useEffect)(()=>{let e=s.get(`prompt`);e&&u.data&&!_e.current&&(_e.current=!0,l({},{replace:!0}),I.send(e))},[s,u.data,I,l]);let ve=i({queryKey:[`wizard-models`,e,u.data?.revision],queryFn:()=>M.get(`/api/studio/wizards/${e}/models`),enabled:!!u.data}).data?.missing??[],ye=a.data?.mode===`local`&&!!a.data.account,be=Fe(e??``,!!e&&ye),xe=ve.some(e=>e.blocking),Se=Ie({mutationFn:()=>M.post(`/api/studio/wizards/${e}/test-runs`),onSuccess:({runId:e})=>T(e)}),L=Ie({mutationFn:()=>M.post(`/api/studio/wizards/${e}/publish`),onSuccess:async({cloud:t})=>{t&&n.setQueryData([`cloud`,e],{linked:!0,...t}),await Promise.all([n.invalidateQueries({queryKey:[`wizard`,e]}),n.invalidateQueries({queryKey:[`cloud`,e]}),n.invalidateQueries({queryKey:[`wizards`]})]),S(!0)}}),we=(0,U.useMemo)(()=>new Set((u.data?.issues??[]).map(e=>e.stepId).filter(Boolean)),[u.data?.issues]);if(u.isLoading||!a.data)return(0,W.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center text-ink-4`,children:(0,W.jsx)(b,{})});if(!u.data)return(0,W.jsx)(`div`,{className:`p-10 text-center text-ink-3`,children:w(`run.notFound`)});let R=u.data,z=R.draft,Te=io(z,k),B=I.phase!==`idle`&&R.blank&&!N,V=R.issues.length>0,Oe=ge.data?.find(e=>e.id===R.projectId),Ae=Oe?Oe.origin===`local`:a.data.limits.build||ge.isLoading,Ne=R.readOnly?w(Ae?`readonly.wizard`:`readonly.server`):null,Pe=a.data.mode===`local`&&He.account&&ve.some(e=>uc.includes(e.cls))?a.data.account?a.data.models?.source===`account`?null:`use`:`connect`:null,H=me??(L.error?L.error.message:null),Re=e=>{f(e),e&&(h(`step`),_.unfold())},Be=t=>{if(I.phase!==`idle`)return!1;let r=new Set(z.steps.map(e=>e.id));return se(t),I.send(Qt(z,t)).then(()=>{se(null);let t=(n.getQueryData([`wizard`,e])?.draft)?.steps.find(e=>!r.has(e.id));t&&(f(t.id),h(e=>e===`chat`?e:`step`))}),!0},Ve=R.readOnly?void 0:{adding:N,add:Be,ask:e=>I.phase===`idle`&&(I.send(e),!0),working:(0,W.jsx)(Ue,{chat:I}),showChat:()=>{h(`chat`),_.unfold()}};return(0,W.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[Ne?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-border-soft border-b bg-paper-2 px-4 py-2 text-[0.8125rem] text-ink-2 sm:px-6`,children:[(0,W.jsx)(Ce,{className:`size-4 shrink-0 text-ink-3`}),(0,W.jsx)(`p`,{className:`min-w-0 flex-1`,children:Ne})]}):null,H?(0,W.jsx)(`div`,{className:`shrink-0 bg-rose-tint px-4 py-2 text-[0.8125rem] text-rose sm:px-6`,children:H}):null,(0,W.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-2 px-3 sm:px-4`,children:[(0,W.jsx)(D,{label:`Zurück`,onClick:()=>t(`/`),children:(0,W.jsx)(m,{className:`size-5`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>Re(`__wizard`),className:`min-w-0 truncate rounded-md px-2 py-1 text-left hover:bg-accent`,children:(0,W.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:z.title})}),(0,W.jsx)(`span`,{className:`hidden sm:inline-flex`,children:R.published?R.dirty?(0,W.jsx)(O,{tone:`warn`,children:w(`editor.unpublishedChanges`)}):(0,W.jsx)(ze,{where:ke(R,a.data,ye?be.data:null),me:a.data,version:R.publishedVersion}):(0,W.jsx)(O,{children:w(`editor.notPublished`)})}),de?(0,W.jsx)(b,{className:`size-4 text-ink-4`}):null,(0,W.jsx)(`span`,{className:`hidden md:inline-flex`,children:(0,W.jsx)(lc,{remote:fe,merged:pe})}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,W.jsx)(`a`,{href:c(`/api/studio/wizards/${R.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,W.jsx)(qe,{className:`size-4`})}),(0,W.jsxs)(A,{variant:`secondary`,size:`sm`,disabled:V||B||xe,busy:Se.isPending,onClick:()=>Se.mutate(),children:[(0,W.jsx)(Ht,{className:`size-3.5`}),` `,w(`editor.test`)]}),R.published&&(!R.dirty||R.readOnly)?(0,W.jsxs)(A,{size:`sm`,onClick:()=>S(!0),children:[(0,W.jsx)(ie,{className:`size-3.5`}),` `,w(`editor.share`)]}):R.readOnly?null:(0,W.jsxs)(W.Fragment,{children:[ye?(0,W.jsx)(D,{label:w(`editor.share`),className:`max-sm:hidden`,onClick:()=>S(!0),children:(0,W.jsx)(ie,{className:`size-4`})}):null,(0,W.jsx)(A,{size:`sm`,disabled:V||B,busy:L.isPending,onClick:()=>L.mutate(),children:w(`editor.publish`)})]}),(0,W.jsx)(`span`,{className:`ml-2 hidden md:inline-flex`,children:(0,W.jsx)(Ee,{me:a.data})}),(0,W.jsx)(`span`,{className:`hidden sm:inline-flex`,children:(0,W.jsx)(De,{me:a.data})})]})]}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[(0,W.jsxs)(`section`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[V&&!B?(0,W.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,W.jsx)(`p`,{className:`text-[0.875rem]`,children:w(`editor.issues`)}),(0,W.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-[0.8125rem] text-ink-2`,children:R.issues.slice(0,4).map((e,t)=>(0,W.jsx)(`li`,{children:e.message},t))}),R.readOnly?null:(0,W.jsx)(A,{size:`sm`,variant:`quiet`,className:`mt-3`,disabled:I.phase!==`idle`,onClick:()=>{h(`chat`),I.send(`Bitte behebe diese Probleme im Wizard:\n${R.issues.map(e=>`- ${e.message}`).join(`
|
|
3
|
-
`)}`)},children:w(`editor.fixWithChat`)})]}):null,!V&&!B&&ve.length?(0,W.jsxs)(`div`,{className:x(`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`,xe?`ring-rose/30`:`ring-amber/30`),children:[(0,W.jsx)(`p`,{className:`text-[0.875rem]`,children:w(xe?`editor.models.blocking`:`editor.models.optional`)}),(0,W.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-[0.8125rem] text-ink-2`,children:ve.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`text-ink`,children:w(`class.${e.cls}`)}),` (`,e.steps.map(e=>`„${e.title}“`).join(`, `),`):`,` `,(0,W.jsx)(ee,{text:e.problem})]},e.cls))}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,W.jsx)(A,{size:`sm`,variant:`quiet`,onClick:()=>t(`/settings/models`),children:w(`editor.models.settings`)}),Pe===`connect`?(0,W.jsxs)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:[w(`teaser.models`),` `,(0,W.jsx)(`button`,{type:`button`,className:`font-medium text-ink underline underline-offset-2`,onClick:()=>t(`/settings/account`),children:w(`teaser.connect`)})]}):Pe===`use`?(0,W.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:w(`teaser.modelsLinked`)}):null]})]}):null,ce!==null&&Ve&&!B?(0,W.jsx)(`div`,{className:`absolute top-3 right-3 left-3 z-20 mx-auto max-w-xl animate-rise rounded-xl shadow-elevated`,children:(0,W.jsx)($t,{place:Zt(z,ce),branchable:ce>0,onAdd:(e,t,n)=>Be({at:ce,kind:e,prompt:t,when:n})?(P(null),!0):!1,onEmpty:e=>{let t=rn(z,ce,e);F(t.def),P(null),Re(t.id)},onCancel:()=>P(null)})}):null,B?(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-[0.875rem] text-ink-3`,children:(0,W.jsx)(Ue,{chat:I,spinner:`size-4 text-ember`})}):(0,W.jsx)(ho,{def:z,selected:d,onSelect:Re,issueSteps:we,activeStep:C?E:null,pulse:fe?.steps,wizardId:R.id,decisions:Te,onBranch:e=>{Re(e),ae(e=>e+1)},adding:N,onInsert:R.readOnly||N?void 0:le})]}),(0,W.jsxs)(`aside`,{ref:_.ref,className:x(`relative flex h-(--sheet) min-h-0 w-full shrink-0 flex-col rounded-t-3xl bg-card shadow-[0_0_0_1px_var(--border-soft)] lg:h-auto lg:w-(--pane) lg:rounded-tr-none`,!_.dragging&&`max-lg:motion-safe:transition-[height] max-lg:motion-safe:duration-200`),style:{"--pane":`${g.width}px`,"--sheet":_.height},children:[(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":w(`editor.resizeSheet`),"aria-valuenow":_.percent,"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,title:w(`editor.resizeSheet`),onPointerDown:_.onPointerDown,onKeyDown:_.onKeyDown,className:`group before:-top-4 relative z-10 flex h-7 shrink-0 cursor-row-resize touch-none select-none items-center justify-center outline-none before:absolute before:inset-x-0 before:h-4 lg:hidden`,children:(0,W.jsx)(`span`,{className:`h-1.5 w-10 rounded-full bg-ink-4/40 transition-all group-hover:bg-ember/70 group-focus-visible:bg-ember group-active:w-14 group-active:bg-ember`})}),(0,W.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":w(`editor.resize`),"aria-valuenow":g.width,tabIndex:0,title:w(`editor.resize`),onPointerDown:g.onPointerDown,onKeyDown:g.onKeyDown,onDoubleClick:g.reset,className:`group -left-5 absolute inset-y-0 z-10 hidden w-5 cursor-col-resize outline-none lg:block`,children:(0,W.jsx)(`span`,{className:`-translate-y-1/2 absolute top-1/2 left-[7px] 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,W.jsx)(`nav`,{className:`flex shrink-0 gap-1 px-3 lg:pt-3`,children:[`chat`,`step`,`files`,`memory`,`runs`].map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>{h(e),_.unfold()},className:x(`h-9 rounded-full px-4 font-medium text-[0.8125rem] transition`,p===e?`bg-paper-2 text-ink`:`text-ink-3 hover:text-ink`),children:w(dc[e])},e))}),(0,W.jsx)(`div`,{className:x(`min-h-0 flex-1 overflow-y-auto`,_.folded&&`max-lg:hidden`),children:p===`chat`?(0,W.jsx)(Le,{chat:I,avatar:z.avatar,closed:Ne??void 0}):p===`step`?(0,W.jsx)(Ko,{def:z,selected:d,update:F,onSelect:Re,issues:R.issues,mcpServers:R.mcpServers,files:R.files,wizardId:R.id,readOnly:R.readOnly,decisions:Te,branchFocus:re,assistant:Ve}):p===`files`?(0,W.jsx)(sn,{wizardId:R.id,files:R.files,readOnly:R.readOnly}):p===`memory`?(0,W.jsx)($o,{wizardId:R.id,projectId:R.projectId,def:z,readOnly:R.readOnly}):(0,W.jsx)(ts,{wizardId:R.id,onOpen:T})})]})]}),C?(0,W.jsx)(he,{header:(0,W.jsx)(O,{children:`Test`}),actions:(0,W.jsx)(A,{variant:`ghost`,size:`sm`,busy:Se.isPending,disabled:V,onClick:()=>Se.mutate(),children:w(`editor.restart`)}),onClose:()=>T(null),children:(0,W.jsx)(oe,{runId:C,compact:!0,onRestart:()=>Se.mutate(),onView:ue},C)}):null,(0,W.jsx)(ic,{wizard:R,open:v,onClose:()=>S(!1),publish:R.readOnly?void 0:{run:()=>L.mutate(),busy:L.isPending,disabled:V||B}})]})}export{Tc as EditorPage};
|