diff --git a/ventures/havre/abilities.js b/ventures/havre/abilities.js index 672ec6b..443a385 100644 --- a/ventures/havre/abilities.js +++ b/ventures/havre/abilities.js @@ -270,25 +270,27 @@ export function clipOptions(model, last = {}) { /** * A conversation with pictures and voice notes in it, as plain messages for a text model. A photo or clip the - * character sent is mentioned in the next thing the person says ("(You sent me a photo: …)"), so the model knows - * about it without learning to write "[photo]" itself. Your photo is "[a photo: what it shows]", your voice note is - * the words you said. + * character sent is in their own turn, as a stage direction ("*sends a photo: …*"), the way characters narrate what + * they do, so the model knows what it sent and who sent it (told in the person's turn, "you sent me a photo" read as + * the person's, and characters got confused about whose photo it was). Your photo is "[a photo: what it shows]", your + * voice note is the words you said. */ export function apiHistory(history) { const out = []; - let notes = []; for (const m of history || []) { if (!m || m.demo) continue; const media = m.media || null; if (m.role === "assistant") { if (media && (media.kind === "photo" || media.kind === "clip")) { const shot = clip(str(media.shot).trim(), 300).replace(/[.!?…\s]+$/, ""); - notes.push(`(You sent me ${media.kind === "clip" ? "a short video" : "a photo"}${shot ? ": " + shot : ""}.)`); + const sent = `*sends ${media.kind === "clip" ? "a short video" : "a photo"}${shot ? ": " + shot : ""}*`; + const last = out.at(-1); + if (last && last.role === "assistant") last.content += "\n\n" + sent; // with the words it came after + else out.push({ role: "assistant", content: sent }); } else if (str(m.content).trim()) out.push({ role: "assistant", content: str(m.content) }); } else if (m.role === "user") { let content = str(m.content); if (media && media.kind === "photo-in") content = `[a photo${media.saw ? ": " + media.saw : ""}]` + (content ? " " + content : ""); - if (notes.length) { content = notes.join(" ") + (content ? "\n\n" + content : ""); notes = []; } out.push({ role: "user", content, ...(m.hidden ? { hidden: true } : {}) }); } } @@ -334,10 +336,14 @@ export const MOVE_SCHEMA = { }; /** the messages for a text model to decide the character's next move (adult: their pictures can be adult, adultCheck) */ -export function moveMessages(card, history, { adult = false } = {}) { +/** the move prompt as it stands, or, for someone set to send things every round, told to lean in rather than hold back */ +export const EAGER = " This character is set to send things every round: choose \"photo\" (or \"voice\" or \"clip\" when that fits better) " + + "whenever a picture of them could go with what was just said, however small the reason; \"nothing\" only when a photo would make no sense at all."; +export function moveMessages(card, history, { adult = false, eager = false } = {}) { const lines = transcript(card, history, 12); const look = card.look && card.look.description; - return [{ role: "system", content: adult ? MOVE_SYSTEM_ADULT : MOVE_SYSTEM }, { role: "user", content: [ + const system = (adult ? MOVE_SYSTEM_ADULT : MOVE_SYSTEM) + (eager ? EAGER : ""); + return [{ role: "system", content: system }, { role: "user", content: [ `The character: ${card.name}${card.tagline ? ". " + card.tagline : ""}`, look ? `How they look: ${look}` : "", "The conversation, latest last (their reply just now is the last line):\n" + lines.join("\n"), @@ -353,7 +359,7 @@ export function normalizeMove(o) { // words that make a move likely: asking to see or hear them, or a reply about where they are and what they're doing const ASKS = /\b(pics?|picture|photo|selfie|snap|show me|see you|see it|what (?:do )?you look like|look like|wearing|outfit|send (?:me )?(?:a|one|it)|video|clip|film|hear you|your voice|say it|sing|whisper|out loud|aloud)\b/i; -const SHOWS = /\b(look at (?:this|my|the)|wearing|outfit|dress|view from|sunset|sunrise|my (?:room|place|desk|garden|kitchen|car|boat|bed|window)|just got (?:back|a|my)|i'?m (?:at|in|on) the|picture|photo|selfie|whisper)\b/i; +const SHOWS = /\b(sends? (?:you )?(?:a |another )?(?:photo|pic|selfie|snap)|look at (?:this|my|the)|wearing|outfit|dress|view from|sunset|sunrise|my (?:room|place|desk|garden|kitchen|car|boat|bed|window)|just got (?:back|a|my)|i'?m (?:at|in|on) the|picture|photo|selfie|whisper)\b/i; /** * Whether to think about a move after this reply: when the person asked to see or hear them, when the reply talks diff --git a/ventures/havre/app.js b/ventures/havre/app.js index 144dfa2..dfe126d 100644 --- a/ventures/havre/app.js +++ b/ventures/havre/app.js @@ -5,6 +5,8 @@ import * as A from "./abilities.js"; import * as M from "./media.js"; import * as T from "./threads.js"; import * as R from "./memory.js"; +import * as W from "./workflows.js"; +import * as B from "./backup.js"; import { Venice, VeniceError } from "./venice.js"; import CAST from "./cast/index.js"; @@ -82,11 +84,14 @@ const S = { // or clip being asked for, and a voice note being recorded lists: { inpaint: null, image: null, tts: null, asr: null, video: null }, listErr: {}, ab: { photo: "", clip: {}, hear: false, hearModel: "", see: false, seeModel: "", own: true, allowance: 0.25, memory: true, - adult: true, adultPhoto: "", adultClip: "" }, voiceOn: {}, jobs: [], ask: null, + adult: true, adultPhoto: "", adultClip: "", awayMin: 360 }, voiceOn: {}, jobs: [], ask: null, rec: null, moving: new Set(), inflight: 0, }; // what characters do on their own (photos, voice notes) comes out of a daily allowance, counted here by local day const ALLOWANCES = [0.1, 0.25, 1, 5]; +/** how long you've been away before a character texts first: minutes, as the setting shows them */ +const AWAYS = [[1, "a minute"], [5, "5 minutes"], [15, "15 minutes"], [30, "half an hour"], [60, "an hour"], [180, "3 hours"], [360, "6 hours"], [1440, "a day"]]; +const backAfter = () => (S.ab.awayMin || 360) * 60e3; const localDay = () => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; }; const spentToday = () => A.spentToday(local.get(K.spent, null), localDay()); const canAfford = (usd) => A.canSpend(local.get(K.spent, null), localDay(), S.ab.allowance, usd); @@ -137,6 +142,7 @@ function boot() { S.ab = { ...S.ab, ...(local.get(K.ab, {}) || {}) }; S.ab.clip = S.ab.clip && typeof S.ab.clip === "object" ? S.ab.clip : {}; if (!ALLOWANCES.includes(S.ab.allowance)) S.ab.allowance = 0.25; + if (!AWAYS.some(([m]) => m === S.ab.awayMin)) S.ab.awayMin = 360; S.voiceOn = local.get(K.voiceOn, {}) || {}; S.jobs = (local.get(K.jobs, []) || []).filter((j) => j && j.queueId && j.model && Date.now() - (j.started || 0) < 23 * 3600e3); pruneEmpty(); @@ -393,7 +399,7 @@ function setPane(which) { const st = $("#studio"); st.classList.toggle("pane-chat", S.pane === "chat"); st.classList.toggle("pane-list", S.pane === "list"); - if (S.pane === "chat") scrollLog(); // drawn while hidden, it couldn't scroll: now it can + if (S.pane === "chat") scrollLog(true); // drawn while hidden, it couldn't scroll: now it can } function renderLeft() { for (const [w, tab, panel] of [["chats", "#lt-chats", "#lp-chats"], ["chars", "#lt-chars", "#lp-chars"], ["harbor", "#lt-harbor", "#lp-harbor"]]) { @@ -700,7 +706,7 @@ function selectCard(id, { talk = false, scroll = false, open } = {}) { if (was !== id) renderCard(); if (!talk) return; setPane("chat"); - if (scroll || narrow()) (narrow() ? $("#chat") : $("#studio")).scrollIntoView({ behavior: motion(), block: "start" }); + if (scroll || narrow()) $("#studio").scrollIntoView({ behavior: motion(), block: "start" }); // on a phone: the tabs, then the chat under them if (!narrow()) $("#say").focus({ preventScroll: true }); speakFirst(); } @@ -809,7 +815,7 @@ function comeBack(t) { if (T.byLatest(threadsOf(c.id))[0] !== t) return Promise.resolve(); // only in their latest chat with you const go = () => { const tried = local.get(K.tried, {}) || {}; - if (!S.threads[t.id] || S.busy.has(t.id) || !T.readyToTextFirst(t.msgs, { now: Date.now(), after: A.BACK_AFTER, tried: tried[t.id] })) return; + if (!S.threads[t.id] || S.busy.has(t.id) || !T.readyToTextFirst(t.msgs, { now: Date.now(), after: backAfter(), tried: tried[t.id] })) return; const kept = Object.fromEntries(Object.entries(tried).filter(([id]) => S.threads[id])); if (!local.set(K.tried, { ...kept, [t.id]: Date.now() })) return; // can't write it down: don't risk asking twice return send(A.comeBack(A.since(t.msgs, Date.now()), here(t)), { hidden: true, to: t, own: true }); @@ -824,9 +830,9 @@ function comeBack(t) { async function comingBack() { if (!S.key || !S.ab.own || !seen()) return; comeBack(thread()); - if (Date.now() - (Number(local.get(K.came, 0)) || 0) < A.BACK_AFTER) return; + if (Date.now() - (Number(local.get(K.came, 0)) || 0) < backAfter()) return; const others = T.textFirst(Object.values(S.threads).filter((t) => t.card !== S.sel && cardOf(t)), (t) => t.msgs, - { now: Date.now(), after: A.BACK_AFTER, tried: local.get(K.tried, {}) || {}, max: 3 }); + { now: Date.now(), after: backAfter(), tried: local.get(K.tried, {}) || {}, max: 3 }); if (!others.length || !local.set(K.came, Date.now())) return; for (const t of others) { await sleep(1500 + Math.random() * 2500); @@ -908,9 +914,18 @@ function put(el) { log.append(el); return el; } -/** to the latest message: now, after the next paint, and once more when late layout (a pane shown, a font) has settled */ -function scrollLog() { - const l = $("#log"), go = () => { l.scrollTop = l.scrollHeight; }; +/** + * To the latest message: now, after the next paint, and once more when late layout (a pane shown, a font) has settled. + * Only if you were at the end already: scrolled up to read, the chat stays where you are while they talk. force: it + * was you (you sent something, opened the chat), so to the end whatever. + */ +let pinned = true; // at the end of the chat, as of the last scroll +const nearEnd = (l) => l.scrollHeight - l.scrollTop - l.clientHeight < 160; +function scrollLog(force = false) { + const l = $("#log"); + if (!force && !pinned) return; + const go = () => { l.scrollTop = l.scrollHeight; }; + pinned = true; go(); requestAnimationFrame(go); setTimeout(go, 250); } /** a photo or clip that loads after the chat is drawn pushes the bottom down: follow it, if you were at the bottom */ @@ -997,11 +1012,48 @@ function jumpTo(t, m) { function msgTools(el, t, m) { if (!t || !m || !m.id) return; el.dataset.msg = m.id; + const c = cardOf(t), words = !!String(m.content || "").trim() && c && !c.plain && S.ab.memory; el.append(h("span", { class: "msgtools" }, ...slashed([ m.role === "user" && !m.media ? linkish("edit", () => editMsg(t, m), { "aria-label": "Edit this message" }) : null, + words ? linkish("remember", () => rememberMsg(t, m), { "aria-label": "Add this to what they remember", title: "into their memory, in these words" }) : null, + words ? linkish("remind", () => remindMsg(t, m), { "aria-label": "Remind them of this at a time", title: "back to mind at a time you pick" }) : null, linkish("delete", () => deleteMsg(t, m), { "aria-label": "Delete this message" }), ]))); } +// ---------- memory from the chat: remember this, remind me, recall ---------- +/** a message into their long-term memory, in its own words (yours as "They said", theirs as "I said"); with a time, as a reminder */ +function rememberMsg(t, m, until) { + const c = cardOf(t); + if (!c || c.plain) return; + const text = `${m.role === "user" ? "They said" : "I said"}: ${String(m.content || "").replace(/\s+/g, " ").trim()}`; + const mem = memoryOf(c.id); + const notes = R.appended(mem.notes, [R.note(text, { kind: "mine", from: { thread: t.id, msg: m.id }, until })]) || mem.notes; + saveMemory(c.id, { ...mem, notes }); + if ((card() || {}).id === c.id) renderMemory(c); + toast(until ? `${c.name} will have that in mind ${R.lines([R.note(text, { until })])[0].slice(1).split(")")[0]}.` : `${c.name} will remember that.`); +} +function remindMsg(t, m) { + const when = prompt("When should they have this in mind? (tomorrow, in 3 days, friday, next week, 2026-11-01)"); + if (when == null) return; + const until = R.parseWhen(when); + if (!until) { toast("That's not a time Havre knows: try tomorrow, in 3 days, friday, next week, or 2026-11-01."); return; } + rememberMsg(t, m, until); +} +/** /recall : what they remember about that (long-term notes, then the chats themselves), brought to mind for a while */ +function recall(query) { + const c = card(); + if (!c || c.plain) { err("/recall needs a character: pick one in the harbor first."); return; } + if (!query) { put(line("/recall needs words to look for: /recall their sister", "havre", "note")); scrollLog(); return; } + const mem = memoryOf(c.id), found = R.search(mem.notes, query, 5); + const theirs = Object.values(S.threads).filter((x) => x.card === c.id); + const deep = R.searchDeep(theirs, (x) => x.msgs, query, 6).filter((d) => !found.some((n) => n.text.endsWith(d.text))).slice(0, 3); + if (!found.length && !deep.length) { put(line(`${c.name} doesn't remember anything about that.`, "havre", "note")); scrollLog(); return; } + saveMemory(c.id, { ...mem, notes: R.recalled(mem.notes, { found, deep }) }); + const shown = [...found.map((n) => n.text), ...deep.map((d) => `${d.role === "user" ? "you" : c.name}: ${d.text}`)]; + put(line(`${c.name} has in mind now:\n` + shown.map((s) => " " + s).join("\n"), "havre", "note")); + scrollLog(); + if ((card() || {}).id === c.id) renderMemory(c); +} /** take one message out of a chat; another tab's copy doesn't bring it back */ function deleteMsg(t, m) { if (S.busy.has(t.id)) return toast("Wait for the reply first."); @@ -1064,7 +1116,7 @@ function renderLog() { if (t && S.doing.has(t.id)) put(typingLine(t, S.doing.get(t.id))); renderJobs(); followMedia(log); - scrollLog(); + scrollLog(true); } /** a character texts in short bubbles; a plain chat answers in one piece */ @@ -1072,7 +1124,7 @@ const bubblesOf = (c, text) => (c.plain ? [C.stripThinking(text)].filter(Boolean /** what the model reads: the conversation, with photos and voice notes as words (see abilities.js), and what they remember */ function messagesFor(c, hist) { const api = A.apiHistory(hist); - return c.plain ? C.alternate(api.slice(-40).map(({ role, content }) => ({ role, content }))) : C.chatMessages(c, api, { memory: memoryFor(c) }); + return c.plain ? C.alternate(api.slice(-40).map(({ role, content }) => ({ role, content }))) : C.chatMessages(c, api, { memory: memoryFor(c), can: canOf(c) }); } // ---------- what they remember ---------- @@ -1084,7 +1136,9 @@ function saveMemory(id, m) { if (!local.set(K.memory, all)) full(); } /** what goes into their prompt: nothing with memory switched off; for a Venice character, beside Venice's own prompt */ -const memoryFor = (c) => (S.ab.memory && c && !c.plain ? memoryOf(c.id).notes : []); +const memoryFor = (c) => (S.ab.memory && c && !c.plain ? R.lines(R.select(memoryOf(c.id).notes)) : []); +/** what they can send in this chat, for their prompt (card.js canBlock): photos and clips need a key, "on their own", and a picture of them */ +const canOf = (c) => (c && !c.plain ? { photos: !!S.key && S.ab.own !== false, pictured: refsOf(c).length > 0 } : null); const remembering = new Set(), memoryMissed = new Map(); /** * After every dozen messages in a chat (or a few, when you leave it), its character writes down what they remember now: @@ -1099,10 +1153,11 @@ async function remember(t, enough = R.EVERY) { remembering.add(c.id); S.inflight++; try { - const r = await new Venice(S.key).chat({ model: await jsonModel(c), messages: R.memoryMessages(c, before.notes, R.transcript(c, fresh.slice(-40))), + const r = await new Venice(S.key).chat({ model: await jsonModel(c), messages: R.memoryMessages(c, R.select(before.notes), R.transcript(c, fresh.slice(-40))), schema: R.MEMORY_SCHEMA, maxTokens: 700, temperature: 0.3 }); - const now = memoryOf(c.id), notes = R.merged(now.notes, R.normalizeNotes(C.parseJsonLoose(r.text))); - if (!notes) throw new Error("no notes"); + const now = memoryOf(c.id), added = R.normalizeNotes(C.parseJsonLoose(r.text), R.MAX_NOTES, { have: now.notes }); + if (!added) throw new Error("no notes"); + const notes = R.appended(now.notes, added); memoryMissed.delete(t.id); if (S.cards.some((x) => x.id === c.id)) { const upTo = Object.fromEntries(Object.entries({ ...now.upTo, [t.id]: fresh.at(-1).id }).filter(([id]) => S.threads[id])); @@ -1174,7 +1229,7 @@ async function send(text, { hidden = false, media = null, picture = "", to = nul saveThread(t); if (here(t)) { for (const el of $$("#log .suggest, #log .note")) el.remove(); - if (!hidden) put(media ? mediaLine(c, said) : line(text, "me")); + if (!hidden) { put(media ? mediaLine(c, said) : line(text, "me")); scrollLog(true); } } const ctrl = new AbortController(); S.busy.set(t.id, ctrl); @@ -1243,7 +1298,7 @@ async function send(text, { hidden = false, media = null, picture = "", to = nul } arrived(t, msg); await play(t, bubblesOf(c, reply), ctrl.signal, c, msg, drawn); - if (!ctrl.signal.aborted && !demo && !c.plain && !hidden && !msg.voice) onTheirOwn(t); + if (!ctrl.signal.aborted && !demo && !c.plain && !hidden) onTheirOwn(t, { voiced: !!msg.voice }); } catch (e) { if (e && e.name === "AbortError") return; done(t); @@ -1334,7 +1389,16 @@ function mediaLine(c, m) { if (md.kind === "photo" || md.kind === "photo-in") { const alt = md.kind === "photo" ? `A photo from ${c.name}${md.shot ? ": " + md.shot : ""}` : "Your photo"; said.append(h("figure", { class: "pic" }, mediaEl("img", md.id, { alt, title: md.shot || null, decoding: "async" }, "photo"))); - if (md.kind === "photo") said.append(cost(["photo", md.model, md.price != null && A.usd(md.price), md.adult && "18+", md.own && "on their own", md.blurred && "blurred by venice's safe mode"])); + if (md.kind === "photo") said.append(cost([md.offer === "portrait" ? "portrait: " + (md.shot || "") : "photo", md.model, md.price != null && A.usd(md.price), md.adult && "18+", md.own && "on their own", md.blurred && "blurred by venice's safe mode"])); + // a photo of them from the chat, kept on their card: as their portrait (offered as one), or as one of their pictures + if (md.kind === "photo" && !me && !c.plain) { + const full = !!c.portrait && c.look.references.length >= C.MAX_REFERENCES, row = h("p", { class: "mono" }); + if (md.offer === "portrait") row.append(h("button", { type: "button", class: "linkish", text: md.kept === "portrait" ? "their portrait now" : "use as their portrait", disabled: md.kept === "portrait" || null, + onclick: () => keepFromChat(c, m, "portrait") }), " / "); + row.append(h("button", { type: "button", class: "linkish", text: md.kept === "ref" ? "on their card" : full ? "their card has three pictures already" : "keep on their card", + disabled: md.kept === "ref" || full || null, title: "one of the pictures their photos and clips are made from", onclick: () => keepFromChat(c, m, "") })); + said.append(row); + } else if (md.saw) said.append(h("span", { class: "cap", text: `${md.seer || "a model"} told them: ${md.saw}` })); } else if (md.kind === "clip" && !md.id) { // a clip this browser couldn't download: it plays from Venice's link until the link lapses @@ -1737,7 +1801,7 @@ function renderAbilities() { allowance.addEventListener("change", () => { S.ab.allowance = Number(allowance.value); saveAb(); renderAbilities(); renderTools(); }); tb.append( row("ON THEIR OWN", tick("characters text first when you come back, and send photos and voice notes when they like", S.ab.own, (on) => setOwn(on)), - ["up to ", allowance, " a day · how often: ", tempoSelect(), ` · ${A.usd(spentToday())} spent today · clips are offered with venice's price, and made only if you say yes`]), + ["up to ", allowance, " a day · how often: ", tempoSelect(), " · text first after you've been away: ", awaySelect(), ` · ${A.usd(spentToday())} spent today · clips are offered with venice's price, and made only if you say yes`]), row("MEMORY", tick("characters remember your chats with them", S.ab.memory, (on) => { S.ab.memory = on; saveAb(); @@ -1789,7 +1853,7 @@ function askFor(kind) { if (refsOf(c).length) writeShot(); if (narrow()) $("#ask").scrollIntoView({ behavior: motion(), block: "nearest" }); else $("#studio").scrollIntoView({ behavior: motion(), block: "start" }); - scrollLog(); + scrollLog(true); } function closeAsk() { if (S.ask && S.ask.busy) return; S.ask = null; renderAsk(); } function renderAsk() { @@ -2136,6 +2200,7 @@ function lightbox(src, alt) { d.append(h("img", { src, alt: alt || "" })); d.showModal(); } +$("#log").addEventListener("scroll", () => { pinned = nearEnd($("#log")); }, { passive: true }); document.addEventListener("click", (e) => { const img = e.target && e.target.closest && e.target.closest(".log .pic img"); if (img && img.src) { e.preventDefault(); lightbox(img.src, img.alt); } @@ -2206,7 +2271,199 @@ function renderMakers() { b.textContent = "make one with ai" + (price != null ? " · " + A.usd(price) : ""); b.disabled = drawing || (as !== "portrait" && !!c.portrait && c.look.references.length >= C.MAX_REFERENCES); } + const { price: one } = makerPlan(c, "portrait"), three = $("#portrait-three"); + three.textContent = "three to pick from" + (one != null ? " · " + A.usd(one * 3) : ""); + three.disabled = drawing || portraitsBusy; } +// ---------- workflows: the things the harbor does, by name, from any door (workflows.js) ---------- +/** a slash command from the chat box: /help, a workflow, or a word Havre doesn't know */ +function runCommand({ id, arg }) { + if (id === "help") { put(line("commands:\n" + W.helpLines().map((l) => " " + l).join("\n"), "havre", "note")); scrollLog(); return; } + if (id === "unknown") { put(line(`no /${arg} here. /help lists what there is.`, "havre", "note")); scrollLog(); return; } + runWorkflow(id, { door: "chat", idea: arg }); +} +/** one workflow, by id, from a door: the same run whichever door opened it */ +function runWorkflow(id, { door = "chat", idea = "", name = "" } = {}) { + const w = W.byId(id); + if (!w) return; + if (!S.key) return needKey(`${w.title} needs your venice key.`); + if (id === "portraits") return threePortraits({ door }); + if (id === "new") return writeFromIdea(idea, { door, name }); + if (id === "photoshoot") return photoshoot(idea, { door }); + if (id === "recall") return recall(idea); +} +/** the chat a workflow's result lands in: the one of theirs on screen, else their latest, else a new one */ +function threadFor(c) { + const t = thread(); + if (t && t.card === c.id) return t; + const latest = T.latestOf(Object.values(S.threads), c.id); + if (latest) return latest; + const fresh = startThread(c); + if (here(fresh)) renderChatMeta(); + return fresh; +} +/** + * Three portraits: three ways they could look, written from their card by a text model, each drawn by the portrait + * model, delivered into their chat as three pictures with a link under each to make it their portrait. Costs three + * portraits on your key, asked first. + */ +let portraitsBusy = false; +async function threePortraits({ door = "chat" } = {}) { + const c = card(); + if (!c || c.plain) { if (door === "chat") err("/portraits needs a character: pick one in the harbor first."); return; } + if (portraitsBusy) { toast("Three portraits are already on their way."); return; } + await loadList("image"); + const { model: pm, adult } = drawPlan(c); + if (!pm || pm.price == null) { const why = S.listErr.image || "Venice has no model for that right now."; if (door === "chat") err(why); else lookStatus("#portrait-status", why, true); return; } + const price = pm.price * 3; + if (!confirm(`Draw ${c.name} three ways with ${pm.name}, to pick a portrait from? It costs about ${A.usd(price)} on your Venice key.`)) return; + const t = threadFor(c); + if (door !== "chat") { openThread(t.id); setLeft("chats"); } + portraitsBusy = true; + S.inflight++; + renderMakers(); + doing(t, "is imagining three ways they could look…"); + try { + const v = new Venice(S.key); + const o = await askJson(await jsonModel(c), { messages: W.directionsMessages(c), schema: W.DIRECTIONS_SCHEMA, maxTokens: 900, temperature: 0.95, what: "three looks" }); + const dirs = W.normalizeDirections(o); + if (!dirs.length) throw new Error("The model sent back no looks. Try again, or pick another model on the card."); + doing(t, `is being drawn ${dirs.length} ways with ${pm.name}…`); + const drawn = await Promise.allSettled(dirs.map((d) => drawPicture(c, d.look, v))); + done(t); + let n = 0, why = null; + for (let i = 0; i < dirs.length; i++) { + const r = drawn[i]; + if (r.status !== "fulfilled") { why = why || r.reason; continue; } + const id = await M.put(dataBlob(r.value)); + deliver(t, { role: "assistant", content: "", media: { kind: "photo", id, shot: dirs[i].title, look: dirs[i].look, model: pm.name, price: pm.price, offer: "portrait", ...(adult ? { adult: true } : {}) } }); + n++; + } + if (!n) throw why || new Error("None of the three came out."); + if (why) err(`${dirs.length - n} of the three didn't come out: ${redraw(why)}`); + if (door !== "chat") toast(`${n} portraits of ${c.name} are in your chat with them: pick one.`); + } catch (e) { + done(t); + err(redraw(e)); + } finally { + portraitsBusy = false; + S.inflight--; + renderMakers(); + balanceSoon(); + } +} +/** + * A photoshoot: a few photos of them from the pictures on their card. One call writes the shots (the single photo's + * rules, several at once), the photo model makes each from the same pictures, and they land in their chat. The words + * after /photoshoot: a count (1 to 6, else 3), then what the shoot is about. Costs that many photos, asked first. + */ +let shooting = false; +async function photoshoot(arg, { door = "chat" } = {}) { + const c = card(); + if (!c || c.plain) { err("/photoshoot needs a character: pick one in the harbor first."); return; } + if (!refsOf(c).length) { err(`${c.name} has no picture yet, and a shoot is made from their pictures: /portraits first, or add one on their card.`); return; } + if (shooting) { toast("A shoot is already under way."); return; } + const { count, brief } = W.parseShoot(arg); + await loadList("inpaint"); + const t = threadFor(c), adult = adultFor(c, t, brief).ok; + const pm = adult ? adultPhotoModel() : photoModel(); + if (!pm || pm.price == null) { err(S.listErr.inpaint || "Venice has no model for that right now."); return; } + const pics = refsOf(c).slice(0, Math.max(1, pm.maxIn)), each = A.photoPrice(pm, pics.length), price = each * count; + if (!confirm(`A shoot of ${count} photo${count === 1 ? "" : "s"} of ${c.name} with ${pm.name}${brief ? " (" + brief + ")" : ""}? It costs about ${A.usd(price)} on your Venice key.`)) return; + if (door !== "chat") { openThread(t.id); setLeft("chats"); } + shooting = true; + S.inflight++; + doing(t, "is planning a shoot…"); + try { + const v = new Venice(S.key); + const lines = t.msgs.filter((m) => !m.hidden && (m.role === "user" || m.role === "assistant")).slice(-10) + .map((m) => `${m.role === "user" ? "Them" : c.name}: ${String(m.content || "").replace(/\s+/g, " ").trim().slice(0, 300)}`); + const o = await askJson(await jsonModel(c), { messages: W.shootMessages(c, adult ? A.PHOTO_SYSTEM_ADULT : A.PHOTO_SYSTEM, { count, brief, lines }), schema: W.SHOOT_SCHEMA, + maxTokens: 300 * count + 200, temperature: 0.9, what: "the shots" }); + const shots = W.normalizeShots(o, count); + if (!shots.length) throw new Error("The model sent back no shots. Try again, or pick another model on the card."); + doing(t, `is shooting ${shots.length} photo${shots.length === 1 ? "" : "s"} with ${pm.name}…`); + const made = await Promise.allSettled(shots.map((s) => v.editImage({ model: pm.id, prompt: A.photoPrompt(c, s.shot, pics.length, pm.promptLimit, { adult }), images: pics, safe: !adult }))); + done(t); + let n = 0, why = null; + for (let i = 0; i < shots.length; i++) { + const r = made[i]; + if (r.status !== "fulfilled") { why = why || r.reason; continue; } + const id = await M.put(r.value.blob); + deliver(t, { role: "assistant", content: "", media: { kind: "photo", id, shot: shots[i].shot, model: pm.name, price: each, ...(adult ? { adult: true } : {}), ...(r.value.blurred ? { blurred: true } : {}) } }); + n++; + } + if (!n) throw why || new Error("None of the shots came out."); + if (why) err(`${shots.length - n} of the shoot didn't come out: ${why.message || why}`); + } catch (e) { + done(t); + err(e.message || String(e)); + } finally { + shooting = false; + S.inflight--; + balanceSoon(); + } +} +/** + * A photo of them from the chat, kept on their card: as their portrait (as = "portrait"; the look it was drawn from goes + * on the card too if it had none), or as one of the pictures their photos and clips are made from (as = ""). + */ +async function keepFromChat(c, m, as = "") { + const md = m.media || {}, blob = await M.get(md.id); + if (!blob) { toast("That picture isn't kept in this browser any more."); return; } + const now = S.cards.find((x) => x.id === c.id); + if (!now) return; + if (as !== "portrait" && now.portrait && now.look.references.length >= C.MAX_REFERENCES) { toast(`${c.name}'s card has three pictures already: remove one first (card → look).`); return; } + const pic = await shrinkImage(blob, as === "portrait" ? 512 : 768, "image/webp", { svg: false }); + keepPicture(now, pic, as === "portrait" ? md.look || "" : "", as); + md.kept = as === "portrait" || !now.portrait ? "portrait" : "ref"; + const t = Object.values(S.threads).find((x) => x.msgs.includes(m)); + if (t) saveThread(t); + if (t && here(t)) renderLog(); + toast(md.kept === "portrait" ? `${c.name} has a new portrait.` : `That picture is on ${c.name}'s card now.`); +} +/** + * Someone new from an idea: one call writes the card (name, tagline, greeting, persona, examples, how they look), and + * they join the harbor with their chat open, for you to say hello. From the harbor form the idea is what's typed + * under who they are (and the name, if one was given); from the chat it's the words after /new. + */ +let writingIdea = false; +async function writeFromIdea(idea, { door = "chat", name = "" } = {}) { + idea = (idea || "").trim(); + if (!idea) { + if (door === "chat") { put(line("/new needs an idea after it: /new a lighthouse keeper who writes letters to the sea", "havre", "note")); scrollLog(); } + else $("#nc-persona").focus(); + return; + } + if (writingIdea) { toast("Someone is already being written."); return; } + writingIdea = true; + S.inflight++; + const note = door === "chat" ? put(line("havre is writing someone new…", "havre", "typing")) : null; + if (note) scrollLog(); + const btn = $("#nc-ai"); + btn.disabled = true; + try { + const model = S.model, writer = await jsonModel({ model }); + if (door !== "chat") $("#nc-persona").placeholder = `writing with ${modelName(writer)}…`; + const o = await askJson(writer, { messages: W.ideaMessages(idea, name), schema: W.IDEA_SCHEMA, maxTokens: 2000, temperature: 0.95, what: "a character" }); + const c = addCard(W.cardFromIdea(o, { model }), { select: false }); + if (note) note.remove(); + if (door !== "chat") $("#card-new").reset(); + selectCard(c.id, { talk: true, scroll: true, open: null }); + setTab("edit"); + toast(`${c.name} joined the harbor. Say hello, or /portraits to see them.`); + } catch (e) { + if (note) note.remove(); + if (door === "chat") err(e.message); else toast(e.message); + } finally { + writingIdea = false; + S.inflight--; + btn.disabled = false; + $("#nc-persona").placeholder = "who they are, what they care about, how they talk"; + balanceSoon(); + } +} + /** a picture for their card, made with AI on your key: a new portrait ("portrait"), or one more picture of them */ async function makePicture(as = "") { const c = card(), st = as === "portrait" ? "#portrait-status" : "#look-status"; @@ -2303,26 +2560,41 @@ async function startClip(c, cm, shot, opts, price, where, { adult = false } = {} * showing, or now and then), the character's model decides: a photo or a voice note, sent out of the day's * allowance, or a clip, offered with Venice's price for you to take or leave. */ -async function onTheirOwn(t) { +const noPicSaid = new Set(), moveSaid = new Set(); +let allowanceSaid = ""; +async function onTheirOwn(t, { voiced = false } = {}) { // voiced: the reply came with a voice note already, so not another const c = cardOf(t); if (!c || c.plain || !S.key || !S.ab.own || S.moving.has(t.id) || !A.moveLikely(t.msgs, { every: tempoEvery() })) return; // the call that decides is paid for too: set aside its most, from what's left today, and settle after const model = (S.models || []).find((m) => m.id === (c.model || S.model)) || null; - const messages = A.moveMessages(c, A.apiHistory(t.msgs), { adult: adultFor(c, t).ok }), most = A.callEstimate(messages, 300, model); - if (!reserve(most)) return; + const messages = A.moveMessages(c, A.apiHistory(t.msgs), { adult: adultFor(c, t).ok, eager: tempoEvery() === 1 }), most = A.callEstimate(messages, 300, model); + if (!reserve(most)) { // today's allowance is spent: said once a day, not every round + const day = localDay(); + if (allowanceSaid !== day && here(t)) { allowanceSaid = day; err(`nothing on their own today: the allowance (${A.usd(S.ab.allowance)} a day, under abilities) is spent.`); } + return; + } S.moving.add(t.id); // one move at a time in a chat let held = most; try { - const r = await new Venice(S.key).chat({ model: c.model || S.model, messages, schema: A.MOVE_SCHEMA, maxTokens: 300, temperature: 0.7 }); + const r = await new Venice(S.key).chat({ model: await jsonModel(c), messages, schema: A.MOVE_SCHEMA, maxTokens: 300, temperature: 0.7 }); settle(held, A.callCost(r.usage, model)); held = 0; if (!S.threads[t.id] || !cardOf(t)) return; // the chat, or they, went meanwhile - const { move, shot } = A.normalizeMove(C.parseJsonLoose(r.text)); + let { move, shot } = A.normalizeMove(C.parseJsonLoose(r.text)); const lately = A.sentLately(t.msgs, tempoEvery() === 1 ? 1 : 4); // never two photos in a row - if (move === "photo" && !lately) await ownPhoto(t, shot); - else if (move === "voice") await ownVoice(t); + if (tempoEvery() === 1 && (move === "nothing" || (move === "voice" && voiced)) && !lately && refsOf(c).length) { // every round means every round: a photo, then + const sr = await new Venice(S.key).chat({ model: c.model || S.model, messages: A.shotMessages(c, A.apiHistory(t.msgs), "", "photo", { adult: adultFor(c, t).ok }), maxTokens: 260, temperature: 0.8 }); + shot = A.cleanText(sr.text); + if (shot) move = "photo"; + } + if ((move === "photo" || move === "clip") && !refsOf(c).length) { // nothing to make one from: say so, once per chat + if (!noPicSaid.has(t.id) && here(t)) { noPicSaid.add(t.id); err(`${c.name} wanted to send a ${move}, but has no picture yet to make one from: /portraits, or add one on their card (card → look).`); } + } else if (move === "photo" && !lately) await ownPhoto(t, shot); + else if (move === "voice" && !voiced) await ownVoice(t); else if (move === "clip" && !lately) await offerClip(t, shot); - } catch { /* then they just text */ } finally { refund(held); S.moving.delete(t.id); } + } catch (e) { // then they just text; set to every round, the reason is shown once + if (tempoEvery() === 1 && !moveSaid.has(t.id) && here(t)) { moveSaid.add(t.id); err(`nothing on their own this time: ${e && e.message ? e.message : e}`); } + } finally { refund(held); S.moving.delete(t.id); } } /** something they started on their own that didn't come (a photo, a voice note): said in its chat, or in a word elsewhere */ function missed(t, what, e) { @@ -2343,9 +2615,10 @@ async function ownPhoto(t, shot) { const adult = adultFor(c, t, shot).ok; // an adult character's can be adult (abilities.js adultCheck) const refs = refsOf(c), tried = []; let pm = adult ? adultPhotoModel() : photoModel(), why = null; + if (!pm) why = new Error("no photo model is available (abilities → photos)."); while (pm && refs.length && tried.length < 2) { // no picture of them yet: nothing to send const pics = refs.slice(0, Math.max(1, pm.maxIn)), price = A.photoPrice(pm, pics.length); - if (!reserve(price)) break; // set aside first: nothing else can spend it meanwhile + if (!reserve(price)) { why = new Error(`it doesn't fit in what's left of today's allowance (${A.usd(price)} for the photo; the allowance is under abilities).`); break; } tried.push(pm.id); doing(t, "is taking a photo…"); try { @@ -2572,7 +2845,7 @@ async function hearVoice(blob, to) { if (blob.size < 600) { toast("That voice note was too short to hear."); return; } const id = await M.put(blob); const note = put(line("hearing your voice note…", "havre", "typing")); - scrollLog(); + scrollLog(true); try { await loadList("asr"); const hm = hearModel(), ext = /mp4/.test(blob.type) ? "m4a" : /ogg/.test(blob.type) ? "ogg" : "webm"; @@ -2609,7 +2882,7 @@ async function showPhoto(file) { const sm = seeModel(); if (!sm) { err("No Venice model can see photos right now."); return; } const note = put(line(`${sm.name} is looking at your photo…`, "havre", "typing")); - scrollLog(); + scrollLog(true); try { const r = await new Venice(S.key).chat({ model: sm.id, maxTokens: 220, temperature: 0.2, messages: [{ role: "user", content: [{ type: "text", text: A.SEE_PROMPT }, { type: "image_url", image_url: { url: pic } }] }] }); @@ -2675,18 +2948,20 @@ function renderMemory(c) { if (!c || c.plain) return; const linked = false, { notes } = memoryOf(c.id); how.textContent = (S.ab.memory - ? `every dozen messages, one short call on your key writes down what ${c.name} remembers of your chats. it goes into every chat with them, here in this browser, and never into their card.` + ? `every dozen messages, one short call on your key writes down what's new for ${c.name} to remember. everything is kept, here in this browser and never in their card; the newest, a reminder as its day nears, and what was just recalled (/recall) go into their chats. remember and remind, under any message, add to it by hand.` : "memory is switched off under abilities: nothing goes into their chats, and nothing new is written down."); $("#memory-add").hidden = linked; $("#memory-forget").hidden = linked || !notes.length; ul.textContent = ""; if (linked) return; if (!notes.length) { ul.append(h("li", { class: "empty", text: "nothing yet: a few messages in, they start remembering." })); return; } - notes.forEach((n, i) => ul.append(h("li", {}, n, " ", linkish("forget", () => { - const m = memoryOf(c.id); - saveMemory(c.id, { ...m, notes: m.notes.filter((x) => x !== n) }); - renderMemory(card()); - }, { "aria-label": `Forget: ${n}` })))); + const inMind = new Set(R.select(notes).map((n) => n.text)); + [...notes].reverse().forEach((n) => ul.append(h("li", { class: inMind.has(n.text) ? "" : "faint", title: inMind.has(n.text) ? "in mind: goes into their chats now" : "kept, not in mind now; /recall brings it back" }, + n.until ? R.lines([n])[0] : n.text, n.kind === "mine" || n.kind === "remind" ? h("span", { class: "hint", text: " · yours" }) : "", " ", linkish("forget", () => { + const m = memoryOf(c.id); + saveMemory(c.id, { ...m, notes: R.without(m.notes, n.text) }); + renderMemory(card()); + }, { "aria-label": `Forget: ${n.text}` })))); } /** a persona that calls them by another name than their card's: the model would answer to either, so it's said, with the fix */ function renderNameNote(c) { @@ -2778,6 +3053,12 @@ function setTempo(v) { if ($("#abilitydlg").open) renderAbilities(); toast(`Photos and voice notes on their own: ${TEMPOS.find(([k]) => k === v)[1]}.`); } +function awaySelect() { + const s = h("select", { "aria-label": "How long you've been away before they text first" }, AWAYS.map(([v, t]) => h("option", { value: String(v), text: t }))); + s.value = String(S.ab.awayMin || 360); + s.addEventListener("change", () => { S.ab.awayMin = Number(s.value); saveAb(); toast(`They text first after you've been away ${AWAYS.find(([v]) => v === S.ab.awayMin)[1]}.`); }); + return s; +} function tempoSelect() { const s = h("select", { "aria-label": "How often they send things on their own" }, TEMPOS.map(([v, t]) => h("option", { value: v, text: t }))); s.value = S.ab.tempo || "sometimes"; @@ -2993,9 +3274,50 @@ function forgetKey() { } // ---------- import ---------- +/** the pictures and clips with these ids, as data: URLs (the ones this browser still has) */ +async function mediaAsData(ids) { + const out = {}; + for (const id of ids) { + const blob = await M.get(id); + if (!blob) continue; + out[id] = await new Promise((resolve) => { const r = new FileReader(); r.onload = () => resolve(String(r.result)); r.onerror = () => resolve(""); r.readAsDataURL(blob); }); + if (!out[id]) delete out[id]; + } + return out; +} +/** + * A bundle (one character with memory and chats, or everything) put back: cards not already here are added, notes are + * appended to what's remembered, chats by id are added if missing, pictures are put back by id. Never replaces. + */ +async function restoreBundle(bundle) { + const m = B.merge(bundle, { cards: S.cards, memory: local.get(K.memory, {}) || {}, threads: S.threads }); + for (const c of m.addCards) addCard(c, { select: false }); + for (const [id, mem] of Object.entries(m.memory)) if (S.cards.some((c) => c.id === id)) saveMemory(id, mem); + let pics = 0; + for (const [id, d] of Object.entries(bundle.media)) { try { await M.put(dataBlob(d), id); pics++; } catch { /* that one's gone */ } } + for (const t of m.addThreads) { if (S.cards.some((c) => c.id === t.card) || t.card === PLAIN) { S.threads[t.id] = t; saveThread(t); } } + if (bundle.settings) { + if (bundle.settings.abilities && typeof bundle.settings.abilities === "object") { S.ab = { ...S.ab, ...bundle.settings.abilities, clip: { ...S.ab.clip, ...(bundle.settings.abilities.clip || {}) } }; saveAb(); } + if (bundle.settings.voiceOn && typeof bundle.settings.voiceOn === "object") { S.voiceOn = { ...S.voiceOn, ...bundle.settings.voiceOn }; local.set(K.voiceOn, S.voiceOn); } + } + renderAll(); + const bits = [`${m.addCards.length} character${m.addCards.length === 1 ? "" : "s"}`, `${m.addThreads.length} chat${m.addThreads.length === 1 ? "" : "s"}`, `${pics} picture${pics === 1 ? "" : "s"}`]; + const skipped = [m.skippedCards && `${m.skippedCards} character${m.skippedCards === 1 ? "" : "s"}`, m.skippedThreads && `${m.skippedThreads} chat${m.skippedThreads === 1 ? "" : "s"}`].filter(Boolean); + toast(`Restored ${bits.join(", ")}${skipped.length ? "; already here: " + skipped.join(", ") : ""}.`); +} async function importFile(file) { const st = $("#impstatus"); try { + if (/\.json$/i.test(file.name) && file.size <= 200 * 1024 * 1024) { + let parsed = null; + try { parsed = JSON.parse(await file.text()); } catch { /* not a bundle, then */ } + const bundle = B.readBundle(parsed); + if (bundle) { + if ($("#importdlg").open) $("#importdlg").close(); + await restoreBundle(bundle); + return; + } + } if (file.size > 12 * 1024 * 1024) throw new Error("That file is too big for a character card."); const bytes = new Uint8Array(await file.arrayBuffer()); const { card: c, kind } = C.fromAny(bytes); @@ -3306,6 +3628,17 @@ async function exportAs(kind) { else if (kind === "v3") download(C.fileName(c, "card.json"), JSON.stringify(C.toCharacterCardV3(abs), null, 1) + "\n", "application/json"); else if (kind === "prompt") download(C.fileName(c, "txt"), C.systemPrompt(c) + "\n", "text/plain"); else if (kind === "png") download(C.fileName(c, "png"), new Blob([C.toPngCard(await cardPng(c), abs)], { type: "image/png" }), "image/png"); + else if (kind === "full" || kind === "all") { + if (c.plain && kind === "full") throw new Error("A plain chat has no card to export."); + const threads = Object.values(S.threads).map((t) => ({ ...t })); + const mine = kind === "all" ? threads : threads.filter((t) => t.card === c.id); + toast(`Gathering ${kind === "all" ? "everything" : c.name + "'s pictures"}…`); + const media = await mediaAsData(B.mediaIds(mine)); + const bundle = kind === "all" + ? B.bundleAll({ cards: S.cards.map(absolute), memory: local.get(K.memory, {}) || {}, threads, media, settings: { abilities: S.ab, model: S.model, voiceOn: S.voiceOn } }) + : B.bundleOne(abs, { memory: memoryOf(c.id), threads: mine, media }); + download(B.bundleName(kind === "all" ? null : c), JSON.stringify(bundle) + "\n", "application/json"); + } toast("Made in your browser. Nothing was uploaded."); } catch (e) { toast(e.message); } } @@ -3394,7 +3727,8 @@ function bind() { if (!t.trim() || (thread() && S.busy.has(thread().id))) return; say.value = ""; growSay(); - send(t); + const cmd = W.parseCommand(t); + if (cmd) runCommand(cmd); else send(t); }); say.addEventListener("keydown", (e) => { if (e.key === "Enter" && !e.shiftKey && !e.isComposing) { e.preventDefault(); $("#composer").requestSubmit(); } }); say.addEventListener("input", growSay); @@ -3441,6 +3775,12 @@ function bind() { $("#vprev").addEventListener("click", () => loadVenice(Math.max(0, S.v.offset - PAGE), { paging: true })); $("#vnext").addEventListener("click", () => loadVenice(S.v.offset + PAGE, { paging: true })); + $("#card-fresh").addEventListener("click", () => { + S.fresh = true; + if (S.left !== "harbor") setLeft("harbor"); else syncNew(); + $("#card").scrollIntoView({ behavior: motion(), block: "start" }); + $("#nc-name").focus({ preventScroll: true }); + }); $("#new").addEventListener("click", () => { addCard({ name: "New character", persona: "", greeting: "", voice: { short_form: true }, model: S.model, license: "remix-with-credit" }); openCard("edit"); @@ -3456,6 +3796,7 @@ function bind() { openCard("edit"); }); $("#nc-import").addEventListener("click", () => $("#import").click()); + $("#restore").addEventListener("click", () => $("#import").click()); $("#import").addEventListener("click", () => { $("#impstatus").textContent = ""; $("#impstatus").classList.remove("bad"); $("#importdlg").showModal(); }); $("#impcancel").addEventListener("click", () => $("#importdlg").close()); $("#imp-paste").addEventListener("click", importText); @@ -3509,6 +3850,8 @@ function bind() { }); $("#ref-file").addEventListener("change", () => { const rf = $("#ref-file").files[0]; $("#ref-file").value = ""; if (rf) addReference(rf); }); $("#portrait-make").addEventListener("click", () => makePicture("portrait")); + $("#portrait-three").addEventListener("click", () => runWorkflow("portraits", { door: "sheet" })); + $("#nc-ai").addEventListener("click", () => runWorkflow("new", { door: "harbor", idea: $("#nc-persona").value.trim(), name: $("#nc-name").value.trim() })); $("#ref-make").addEventListener("click", () => makePicture()); $("#speech-sample").addEventListener("click", hearSample); $("#speech-group").addEventListener("toggle", () => { if ($("#speech-group").open) loadList("tts"); }); diff --git a/ventures/havre/backup.js b/ventures/havre/backup.js new file mode 100644 index 0000000..0577b7b --- /dev/null +++ b/ventures/havre/backup.js @@ -0,0 +1,77 @@ +// backup.js: a character with everything this browser keeps about them, or the whole harbor, as one file, and back. +// Pure functions, no DOM: the page imports this module, and so do the tests. +// +// a bundle { havre_backup: 1, at, cards: [card], memory: { : memory }, threads: [thread + msgs], +// media: { : data: URL }, settings?: { abilities, model, voiceOn } } +// +// A card file (.havre.json) carries the character and nothing else, by design: it's the thing you share. A bundle +// is the thing you keep: the card, what they remember, your chats with them and the pictures in those chats. "Full" +// is every character, every chat, every picture, and your settings (never your key). Restoring merges: a card already +// in the harbor is left as it is, notes are appended, chats by id are added if missing, pictures by id are put back. + +import { normalizeCard } from "./card.js"; +import { readMemory, appended } from "./memory.js"; + +export const BACKUP = 1; + +const str = (v, max = 20000) => (typeof v === "string" ? v : v == null ? "" : String(v)).slice(0, max); +const arr = (v) => (Array.isArray(v) ? v : []); +const obj = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : {}); + +/** the media ids a thread's messages point at */ +export function mediaIds(threads) { + const ids = new Set(); + for (const t of arr(threads)) for (const m of arr(t.msgs)) if (m && m.media && typeof m.media.id === "string" && m.media.id) ids.add(m.media.id); + return [...ids]; +} + +/** one character's bundle: the card, their memory, the chats with them (with messages), the pictures those chats hold */ +export function bundleOne(card, { memory = null, threads = [], media = {}, at = Date.now() } = {}) { + const mine = arr(threads).filter((t) => t && t.card === card.id); + const ids = new Set(mediaIds(mine)); + return { havre_backup: BACKUP, at, cards: [card], memory: memory ? { [card.id]: memory } : {}, threads: mine, + media: Object.fromEntries(Object.entries(obj(media)).filter(([id]) => ids.has(id))) }; +} + +/** the whole harbor: every card, memory, chat and picture, and the settings worth carrying (never the key) */ +export function bundleAll({ cards = [], memory = {}, threads = [], media = {}, settings = null, at = Date.now() } = {}) { + return { havre_backup: BACKUP, at, cards: arr(cards), memory: obj(memory), threads: arr(threads), media: obj(media), + ...(settings ? { settings } : {}) }; +} + +/** a bundle as read from a file, made safe; null if the text isn't one */ +export function readBundle(o) { + if (!o || typeof o !== "object" || Number(o.havre_backup) !== BACKUP) return null; + const cards = arr(o.cards).filter((c) => c && typeof c === "object" && c.name).map((c) => normalizeCard(c)); + const memory = {}; + for (const [id, m] of Object.entries(obj(o.memory))) { const r = readMemory(m); if (r.notes.length || Object.keys(r.upTo).length) memory[str(id, 80)] = r; } + const threads = arr(o.threads).filter((t) => t && typeof t === "object" && typeof t.id === "string" && typeof t.card === "string") + .map((t) => ({ ...t, id: str(t.id, 80), card: str(t.card, 80), msgs: arr(t.msgs).filter((m) => m && typeof m === "object" && (m.role === "user" || m.role === "assistant")) })); + const media = {}; + for (const [id, d] of Object.entries(obj(o.media))) if (typeof d === "string" && /^data:(image|audio|video)\//.test(d) && d.length < 20_000_000) media[str(id, 80)] = d; + const settings = obj(o.settings); + return { at: Number(o.at) || 0, cards, memory, threads, media, settings: Object.keys(settings).length ? settings : null }; +} + +/** + * What restoring a bundle into a harbor comes to, without touching anything: cards to add (not already there, by + * id), memories merged (notes appended to what's there), threads to add (by id, not already there). Pictures are + * put back as they are. The counts say what happened. + */ +export function merge(bundle, { cards = [], memory = {}, threads = {} } = {}) { + const have = new Set(arr(cards).map((c) => c.id)); + const addCards = bundle.cards.filter((c) => !have.has(c.id)); + const mergedMemory = {}; + for (const [id, m] of Object.entries(bundle.memory)) { + const now = readMemory(obj(memory)[id]); + mergedMemory[id] = { notes: appended(now.notes, m.notes) || now.notes, upTo: { ...m.upTo, ...now.upTo }, at: Math.max(now.at, m.at) }; + } + const addThreads = bundle.threads.filter((t) => !obj(threads)[t.id]); + return { addCards, memory: mergedMemory, addThreads, skippedCards: bundle.cards.length - addCards.length, skippedThreads: bundle.threads.length - addThreads.length }; +} + +/** a file name for a bundle: one character's, or the harbor's, with the day */ +export function bundleName(card, at = Date.now()) { + const day = new Date(at).toISOString().slice(0, 10); + return card ? `${card.id}.havre-full.json` : `havre-backup-${day}.json`; +} diff --git a/ventures/havre/card.js b/ventures/havre/card.js index 373313f..dbb0a72 100644 --- a/ventures/havre/card.js +++ b/ventures/havre/card.js @@ -172,7 +172,20 @@ const quoted = (s, max = 600) => `"${str(s).replace(/\s+/g, " ").trim().slice(0, * The system prompt: who they are, how they talk (with their examples, which teach the voice), their flow, what they * remember of your chats (memory: notes from memory.js, never part of the card), their name, and the house rules. */ -export function systemPrompt(card, { memory = [] } = {}) { +/** + * What they can send in this chat, for the prompt: photos and clips (the app makes them from their pictures when they + * decide to), not yet (no picture on their card), or not at all (no key, or switched off). "" when nothing is known. + */ +export function canBlock(can) { + if (!can || typeof can !== "object") return ""; + if (!can.photos) return "In this chat you can't send pictures, clips or voice notes: if they ask for one, say so plainly, in your own voice."; + if (!can.pictured) return "You could send photos of yourself here, but there's no picture of you on your card yet. If they ask for one, say so: they can " + + "make your portrait on your card (or type /portraits in this chat), and after that you can send photos."; + return "In this chat you can send photos of yourself and short clips: when you decide to, they are made from your pictures and arrive " + + "with your message. Decide the way a person would, and never say you can't send pictures. Never describe a photo you didn't send."; +} + +export function systemPrompt(card, { memory = [], can = null } = {}) { const parts = [`You are ${card.name}.${card.tagline ? " " + card.tagline : ""}`]; if (card.persona) parts.push(fill(card.persona, card)); const voice = [card.voice.notes && fill(card.voice.notes, card), card.voice.short_form && SHORT_FORM].filter(Boolean); @@ -189,6 +202,8 @@ export function systemPrompt(card, { memory = [] } = {}) { } const mem = memoryBlock(memory); if (mem) parts.push(mem); + const able = canBlock(can); + if (able) parts.push(able); if (card.adult) parts.push(ADULT_RULE); parts.push(identityRule(card), HOUSE_RULES); return parts.join("\n\n"); @@ -206,11 +221,12 @@ export function memoryBlock(memory = []) { * of Havre's own (not a Venice character, who brings their own prompt), the last thing said ends with a reminder of * who is answering. memory: what they remember, for the system prompt. */ -export function chatMessages(card, history, { memory = [] } = {}) { +export function chatMessages(card, history, { memory = [], can = null } = {}) { const own = !card.engine.venice_character; - // a Venice character brings its own prompt: beside it go only what they remember and, if they're adult, the 18+ rule - const extra = own ? "" : [memoryBlock(memory), card.adult ? ADULT_RULE : ""].filter(Boolean).join("\n\n"); - const msgs = own ? [{ role: "system", content: systemPrompt(card, { memory }) }] : extra ? [{ role: "system", content: extra }] : []; + // a Venice character brings its own prompt: beside it go only what they remember, what they can send here and, if + // they're adult, the 18+ rule + const extra = own ? "" : [memoryBlock(memory), canBlock(can), card.adult ? ADULT_RULE : ""].filter(Boolean).join("\n\n"); + const msgs = own ? [{ role: "system", content: systemPrompt(card, { memory, can }) }] : extra ? [{ role: "system", content: extra }] : []; // the greeting starts the conversation, so it goes once the conversation's start is out of the window if (card.greeting && own && history.length <= 40) msgs.push({ role: "assistant", content: fill(card.greeting, card) }); for (const m of history.slice(-40)) if (m.role === "user" || m.role === "assistant") msgs.push({ role: m.role, content: str(m.content, 8000) }); diff --git a/ventures/havre/index.html b/ventures/havre/index.html index cb7c679..3619808 100644 --- a/ventures/havre/index.html +++ b/ventures/havre/index.html @@ -30,7 +30,7 @@

HAVRE

a harbor for characters.
talk to venice characters on your own key.
no account. no server. nothing kept but what you keep.

- +
@@ -110,7 +110,7 @@
- +
@@ -123,7 +123,7 @@

CARD

- the character as a file: edit it, remix it, export it. + the character as a file: edit it, remix it, export it. /

no character yet. the card shows up here once someone is in your harbor.

@@ -131,7 +131,7 @@ -

+

@@ -145,7 +145,7 @@
-

/ /

+

/ / /

@@ -247,8 +247,10 @@
  • +
  • +
  • -

    files are made here, in your browser. nothing is uploaded.

    +

    files are made here, in your browser. nothing is uploaded. a .havre-full or backup file restores through : what's already here stays, the rest is added.

    diff --git a/ventures/havre/memory.js b/ventures/havre/memory.js index 520005b..fe76be5 100644 --- a/ventures/havre/memory.js +++ b/ventures/havre/memory.js @@ -1,49 +1,96 @@ // memory.js: what a character remembers of your chats with them. Pure functions, no DOM: the page imports this // module, and so do the tests (node --test). // -// a memory { notes: ["They're called Princess.", "I told them I grew up in Brest."], upTo: { : }, at } +// Three tiers, one ladder: // -// One per character, kept in the browser with your chats and never in their card: a card you export or share carries -// none of it. Every dozen messages in a chat, and when you leave a chat with a few new ones, a model (theirs, if it keeps -// to JSON) reads what they remembered and the messages since, and writes down what they remember now. The notes ride in -// the system prompt of every chat with them -// (card.js systemPrompt), so a new chat with someone picks up where the last one left off, and a long chat keeps what -// has scrolled out of the forty messages the model reads. +// deep every message of every chat with them, as they are (threads.js): never read whole, searched +// long notes: { text, at, kind, from?, until? }. Every note ever written, dated, never pruned. A character's +// model writes them every dozen messages (notes from the messages since: facts); "remember this" adds +// one by hand, verbatim; "remind" adds one with an `until`, a time it should come back to mind +// short what rides in the prompt: a few hundred tokens' worth of long, chosen each turn by select() below: +// the newest notes, a reminder as its time nears, what was recalled. That is the one seam a memory +// strategy plugs into: everything else is a store and a writer. +// +// a memory { notes: [note], upTo: { : }, at } +// +// One per character, kept in the browser with your chats and never in their card: a card you export or share +// carries none of it. Notes older than the store keeps (KEEP) roll off the end, oldest ordinary first; a note with a +// time (a reminder) or one you added yourself stays as long as it can. const str = (v, max = 20000) => (typeof v === "string" ? v : v == null ? "" : String(v)).slice(0, max); const clip = (s, n) => (s.length <= n ? s : s.slice(0, Math.max(0, n - 1)).replace(/\s+\S*$/, "") + "…"); +const arr = (v) => (Array.isArray(v) ? v : []); +/** notes the store keeps, at most: well past what one person says to one character in a year */ +export const KEEP = 600; +/** the most notes a model is asked to write from one batch of messages */ export const MAX_NOTES = 16; -/** messages in a chat (yours and theirs) between one update of the memory and the next */ +/** notes in the prompt, at most, within the token budget */ +export const SHORT = 16; +/** the budget for notes in the prompt, in characters (a few hundred tokens) */ +export const BUDGET = 2400; +/** messages in a chat (yours and theirs) between one writing of notes and the next */ export const EVERY = 12; /** a chat you leave with at least this many messages it hasn't read is read then, so a new chat picks up from it */ export const LEAVING = 4; +/** how long a recalled note stays in mind */ +export const RECALLED_FOR = 3 * 3600e3; +/** a reminder comes to mind this long before its time */ +export const AHEAD = 36 * 3600e3; +/** and stays this long after */ +export const AFTER = 48 * 3600e3; + +export const KINDS = ["fact", "mine", "remind", "recalled", "dream"]; export const MEMORY_SYSTEM = "You keep the memory of a character in a chat app: what they remember of their chats with one " + - "person. From what they remembered before and the latest messages, write down what they remember now, as short notes: " + - "what the person has told them about themselves (their name, their life, what they like and don't), what has happened " + - "between them, plans and promises, running jokes, and what the character has said about themselves (their past, their " + - "home, their likes), so they keep to it. Write about the person as \"they\" and the character as \"I\". At most " + - MAX_NOTES + " notes, the most important first, each under 25 words. Keep what still matters, merge what repeats, update " + - "what changed, and leave out small talk. Only what the messages say: never invent anything. Reply with one JSON " + - "object: {\"notes\": [\"...\"]}."; + "person. From what they remembered before and the latest messages, write down what is new to remember, as short " + + "notes: what the person has told them about themselves (their name, their life, what they like and don't), what has " + + "happened between them, plans and promises, running jokes, and what the character has said about themselves (their " + + "past, their home, their likes), so they keep to it. Write about the person as \"they\" and the character as \"I\". " + + "Only what the latest messages add or change: never repeat what they remembered before, never invent anything, " + + "and leave out small talk. At most " + MAX_NOTES + " notes, the most important first, each under 25 words; none " + + "if nothing new was said. Reply with one JSON object: {\"notes\": [\"...\"]}."; export const MEMORY_SCHEMA = { type: "object", additionalProperties: false, required: ["notes"], properties: { notes: { type: "array", items: { type: "string" } } }, }; -/** notes as a list: short, distinct, at most `max`; null when there is no list at all (a reply that went wrong) */ -export function normalizeNotes(o, max = MAX_NOTES) { +// ---------- notes ---------- + +const noteText = (v) => clip(str(v, 2000).replace(/\s+/g, " ").trim().replace(/^(?:[-•*]|\d+[.)])\s*/, ""), 240); + +/** a note as kept, from whatever was stored (a bare string from before notes had dates reads as an undated fact) */ +export function readNote(n, at = 0) { + if (typeof n === "string" || typeof n === "number") { const text = noteText(n); return text ? { text, at, kind: "fact" } : null; } + if (!n || typeof n !== "object") return null; + const text = noteText(n.text); + if (!text) return null; + const note = { text, at: Number(n.at) || at, kind: KINDS.includes(n.kind) ? n.kind : "fact" }; + if (n.from && typeof n.from === "object" && n.from.thread && n.from.msg) note.from = { thread: str(n.from.thread, 80), msg: str(n.from.msg, 80) }; + if (Number(n.until) > 0) note.until = Number(n.until); + if (Number(n.seen) > 0) note.seen = Number(n.seen); + return note; +} + +/** a new note: what the model wrote (a fact), what you added ("mine"), or a reminder with its time */ +export function note(text, { at = Date.now(), kind = "fact", from, until } = {}) { + return readNote({ text, at, kind: until ? "remind" : kind, from, until }); +} + +/** + * The model's reply, as new notes: short, distinct, at most `max`, none already in `have`; null when there is no + * list at all (a reply that went wrong). at: when they were written. + */ +export function normalizeNotes(o, max = MAX_NOTES, { at = Date.now(), have = [] } = {}) { const list = Array.isArray(o) ? o : o && Array.isArray(o.notes) ? o.notes : null; if (!list) return null; - const seen = new Set(), out = []; + const seen = new Set(have.map((n) => (typeof n === "string" ? n : n.text).toLowerCase())), out = []; for (const n of list) { - const t = clip(str(n, 2000).replace(/\s+/g, " ").trim().replace(/^(?:[-•*]|\d+[.)])\s*/, ""), 240); - const k = t.toLowerCase(); + const t = noteText(n), k = t.toLowerCase(); if (!t || seen.has(k)) continue; seen.add(k); - out.push(t); + out.push({ text: t, at, kind: "fact" }); if (out.length >= max) break; } return out; @@ -54,9 +101,140 @@ export function readMemory(m) { const o = m && typeof m === "object" ? m : {}; const upTo = {}; for (const [k, v] of Object.entries(o.upTo && typeof o.upTo === "object" ? o.upTo : {})) if (typeof v === "string" && v) upTo[k] = v; - return { notes: normalizeNotes(o.notes || []) || [], upTo, at: Number(o.at) || 0 }; + const at = Number(o.at) || 0, seen = new Set(), notes = []; + for (const raw of arr(o.notes)) { + const n = readNote(raw, at); + if (!n || seen.has(n.text.toLowerCase())) continue; + seen.add(n.text.toLowerCase()); + notes.push(n); + } + return { notes, upTo, at }; } +/** + * Notes added to the store: new ones on the end (the store reads oldest first), none twice, and when it's past what + * it keeps, the oldest ordinary notes go, never a reminder or one you added. null: nothing to add. + */ +export function appended(notes, added, keep = KEEP) { + if (!added) return null; + const have = new Set(notes.map((n) => n.text.toLowerCase())); + const fresh = added.filter((n) => n && n.text && !have.has(n.text.toLowerCase())); + let all = [...notes, ...fresh]; + while (all.length > keep) { + const i = all.findIndex((n) => !n.until && n.kind !== "mine" && n.kind !== "remind"); + if (i < 0) break; + all = [...all.slice(0, i), ...all.slice(i + 1)]; + } + return all; +} + +/** a note you give them yourself: added as yours, once */ +export function withNote(notes, text, opts = {}) { + const n = note(text, { ...opts, kind: opts.kind || "mine" }); + return n ? appended(notes, [n]) : notes; +} + +/** the notes without one (by text) */ +export const without = (notes, text) => notes.filter((n) => n.text !== text); + +// ---------- short: what rides in the prompt ---------- + +/** + * How much a note wants to be in mind right now, 0 to 1. The one function a memory strategy changes: today it is + * recency for notes, how near its time for a reminder, and a stretch after being recalled; nothing is learned yet. + */ +export function salience(n, now = Date.now()) { + if (n.seen && now - n.seen < RECALLED_FOR && !n.until) return Math.max(0.5, 0.95 * (1 - (now - n.seen) / RECALLED_FOR)); // recalled just now: in mind + if (n.until) { + const dt = n.until - now; + if (dt > AHEAD) return 0.05 + 0.15 * Math.max(0, 1 - dt / (30 * 86400e3)); // far off: faint, a little nearer each day + if (dt >= 0) return 0.6 + 0.4 * (1 - dt / AHEAD); // coming up: climbs to 1 + if (-dt <= AFTER) return 0.7; // just passed: still in mind + return 0; // over + } + if (n.kind === "recalled") return 0; // a recalled line, once it's faded: back to deep + const age = Math.max(0, now - (n.at || 0)); + const days = age / 86400e3; + return n.kind === "mine" ? 0.5 + 0.4 / (1 + days / 30) : 0.3 + 0.6 / (1 + days / 7); +} + +/** + * The notes for the prompt now: the most salient, the newer batch first among equals and a batch in the order it was + * written (the most important first), as many as fit the budget. With no + * reminders and nothing recalled this comes down to the newest notes, which is what it was before. + */ +export function select(notes, { now = Date.now(), budget = BUDGET, max = SHORT } = {}) { + const scored = notes.map((n, i) => ({ n, i, s: salience(n, now) })).filter((x) => x.s > 0) + .sort((a, b) => b.s - a.s || (b.n.at || 0) - (a.n.at || 0) || a.i - b.i); + const out = []; + let used = 0; + for (const { n } of scored) { + if (out.length >= max) break; + const cost = n.text.length + 3; + if (used + cost > budget) continue; + out.push(n); + used += cost; + } + return out; +} + +/** the selected notes as the lines a prompt carries, a reminder with its day */ +export function lines(selected, now = Date.now()) { + return selected.map((n) => { + if (!n.until) return n.text; + const d = Math.round((n.until - now) / 86400e3); + const when = d > 1 ? `in ${d} days` : d === 1 ? "tomorrow" : d === 0 ? "today" : d === -1 ? "yesterday" : `${-d} days ago`; + return `(${when}) ${n.text}`; + }); +} + +// ---------- recall: search long, and deep ---------- + +const WORDS = (s) => str(s, 4000).toLowerCase().match(/[\p{L}\p{N}]{3,}/gu) || []; + +/** notes that share words with the query, best first; at most n */ +export function search(notes, query, n = 5) { + const q = [...new Set(WORDS(query))]; + if (!q.length) return []; + return notes.map((note) => { + const w = new Set(WORDS(note.text)); + const hits = q.filter((x) => w.has(x)).length; + return { note, hits }; + }).filter((x) => x.hits > 0).sort((a, b) => b.hits - a.hits || (b.note.at || 0) - (a.note.at || 0)).slice(0, n).map((x) => x.note); +} + +/** lines of chats (deep) that share words with the query, best first: { thread, msg, text, at }, at most n */ +export function searchDeep(threads, msgsOf, query, n = 5) { + const q = [...new Set(WORDS(query))]; + if (!q.length) return []; + const out = []; + for (const t of threads) { + for (const m of msgsOf(t)) { + if (!m || m.hidden || m.demo || (m.role !== "user" && m.role !== "assistant")) continue; + const text = str(m.content).replace(/\s+/g, " ").trim(); + if (!text) continue; + const w = new Set(WORDS(text)); + const hits = q.filter((x) => w.has(x)).length; + if (hits) out.push({ thread: t.id, msg: m.id, role: m.role, text: clip(text, 240), at: m.at || 0, hits }); + } + } + return out.sort((a, b) => b.hits - a.hits || b.at - a.at).slice(0, n).map(({ hits, ...r }) => r); +} + +/** + * What was recalled, brought to mind: notes found in long get `seen` now (and stay in mind for RECALLED_FOR); lines + * found in deep become notes of their own, kind "recalled", that fade back out after. Returns the notes to keep. + */ +export function recalled(notes, { found = [], deep = [] } = {}, now = Date.now()) { + const hit = new Set(found.map((n) => n.text)); + const marked = notes.map((n) => (hit.has(n.text) ? { ...n, seen: now } : n)); + const fresh = deep.map((f) => readNote({ text: `${f.role === "user" ? "They said" : "I said"}: ${f.text}`, at: f.at || now, kind: "recalled", + from: f.thread ? { thread: f.thread, msg: f.msg } : undefined, seen: now })).filter(Boolean); + return appended(marked, fresh) || marked; +} + +// ---------- the writer: every dozen messages ---------- + /** the things said in a chat that count: not the hidden nudges, not the replies made up without a key */ const said = (history) => (history || []).filter((m) => m && !m.demo && !m.hidden && (m.role === "user" || m.role === "assistant")); @@ -80,29 +258,42 @@ export function transcript(card, messages, max = 400) { }).filter(Boolean); } -/** the messages for the character's model to write what they remember now */ +/** the messages for the character's model to write what is new to remember (notes: what it's shown of before) */ export function memoryMessages(card, notes, lines) { + const texts = notes.map((n) => (typeof n === "string" ? n : n.text)); const user = [ `The character: ${card.name}${card.tagline ? ". " + card.tagline : ""}`, - notes.length ? "What they remember so far:\n" + notes.map((n) => "- " + n).join("\n") : "What they remember so far: nothing yet.", + texts.length ? "What they remember so far:\n" + texts.map((n) => "- " + n).join("\n") : "What they remember so far: nothing yet.", "The latest messages, oldest first:\n" + lines.join("\n"), - `Write what ${card.name} remembers now.`, + `Write what is new for ${card.name} to remember.`, ].join("\n\n"); return [{ role: "system", content: MEMORY_SYSTEM }, { role: "user", content: user }]; } -/** - * What they remember after an update: the model's notes, unless it lost everything they knew (an empty list when - * there were notes is a reply gone wrong, so the old notes stay). null: keep what was there. - */ +/** @deprecated the old whole-list rewrite; kept for a reply with no list (null: keep what was there) */ export function merged(before, after) { if (!after) return null; return !after.length && before.length ? null : after; } -/** a note you give them yourself: first in the list, not twice, and the oldest goes if there's no room */ -export function withNote(notes, text, max = MAX_NOTES) { - const t = clip(str(text, 2000).replace(/\s+/g, " ").trim(), 240); - if (!t) return notes; - return [t, ...notes.filter((n) => n.toLowerCase() !== t.toLowerCase())].slice(0, max); +// ---------- reminders: when ---------- + +/** a time from plain words: "tomorrow", "in 3 days", "in 2 weeks", "next month", "friday", "2026-11-01"; null if none */ +export function parseWhen(text, now = Date.now()) { + const s = str(text, 200).toLowerCase().trim(); + const day = 86400e3, at = new Date(now); + const morning = (d) => { const x = new Date(d); x.setHours(10, 0, 0, 0); return x.getTime(); }; + if (!s) return null; + if (/^(today|tonight)$/.test(s)) return now + 6 * 3600e3; + if (s === "tomorrow") return morning(now + day); + let m = /^in\s+(\d+)\s*(hour|day|week|month)s?$/.exec(s) || /^(\d+)\s*(hour|day|week|month)s?$/.exec(s); + if (m) { const n = Number(m[1]); const unit = { hour: 3600e3, day, week: 7 * day, month: 30 * day }[m[2]]; return unit === 3600e3 ? now + n * unit : morning(now + n * unit); } + m = /^next\s+(week|month)$/.exec(s); + if (m) return morning(now + (m[1] === "week" ? 7 : 30) * day); + const days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; + const di = days.findIndex((d) => d === s || d.slice(0, 3) === s || ("next " + d) === s); + if (di >= 0) { let ahead = (di - at.getDay() + 7) % 7; if (!ahead) ahead = 7; return morning(now + ahead * day); } + m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s); + if (m) { const t = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]), 10, 0, 0, 0).getTime(); return Number.isFinite(t) ? t : null; } + return null; } diff --git a/ventures/havre/open/assets/index-DGlm5dpH.css b/ventures/havre/open/assets/index-DGlm5dpH.css deleted file mode 100644 index 45731b1..0000000 --- a/ventures/havre/open/assets/index-DGlm5dpH.css +++ /dev/null @@ -1 +0,0 @@ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-outline-style:solid;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:"Inter", "InterVariable", system-ui, sans-serif;--font-mono:"JetBrains Mono", "SF Mono", monospace;--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-sky-300:oklch(82.8% .111 230.318);--color-sky-400:oklch(74.6% .16 232.661);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-violet-300:oklch(81.1% .111 293.571);--color-violet-400:oklch(70.2% .183 293.541);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-pink-300:oklch(82.3% .12 346.018);--color-pink-400:oklch(71.8% .202 349.761);--color-pink-500:oklch(65.6% .241 354.308);--color-rose-200:oklch(89.2% .058 10.001);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-3xl:48rem;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--leading-loose:2;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--ease-out:cubic-bezier(0, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-sm:8px;--blur-md:12px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg-base:#0a0a0c;--color-bg-raised:#111114;--color-text-primary:rgba(var(--fg), .92);--color-accent:#6ee7d3;--color-accent-soft:#6ee7d329}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.-top-1\.5{top:calc(var(--spacing) * -1.5)}.top-0{top:calc(var(--spacing) * 0)}.top-0\.5{top:calc(var(--spacing) * .5)}.top-1\.5{top:calc(var(--spacing) * 1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-3{top:calc(var(--spacing) * 3)}.top-\[2px\]{top:2px}.top-full{top:100%}.-right-1\.5{right:calc(var(--spacing) * -1.5)}.right-0{right:calc(var(--spacing) * 0)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.right-2{right:calc(var(--spacing) * 2)}.right-3{right:calc(var(--spacing) * 3)}.right-4{right:calc(var(--spacing) * 4)}.bottom-4{bottom:calc(var(--spacing) * 4)}.left-0{left:calc(var(--spacing) * 0)}.left-0\.5{left:calc(var(--spacing) * .5)}.left-3{left:calc(var(--spacing) * 3)}.left-\[2px\]{left:2px}.left-\[16px\]{left:16px}.left-\[20px\]{left:20px}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.-m-0\.5{margin:calc(var(--spacing) * -.5)}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-px{margin-top:1px}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.-ml-1{margin-left:calc(var(--spacing) * -1)}.ml-auto{margin-left:auto}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-6{-webkit-line-clamp:6;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-8{-webkit-line-clamp:8;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.aspect-square{aspect-ratio:1}.\!h-3{height:calc(var(--spacing) * 3)!important}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-14{height:calc(var(--spacing) * 14)}.h-16{height:calc(var(--spacing) * 16)}.h-24{height:calc(var(--spacing) * 24)}.h-\[14px\]{height:14px}.h-\[16px\]{height:16px}.h-\[18px\]{height:18px}.h-\[100dvh\]{height:100dvh}.h-full{height:100%}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-\[55vh\]{max-height:55vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[380px\]{max-height:380px}.max-h-\[calc\(100vh-240px\)\]{max-height:calc(100vh - 240px)}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-\[40px\]{min-height:40px}.min-h-\[60px\]{min-height:60px}.min-h-full{min-height:100%}.\!w-3{width:calc(var(--spacing) * 3)!important}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1{width:calc(var(--spacing) * 1)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-96{width:calc(var(--spacing) * 96)}.w-\[14px\]{width:14px}.w-\[16px\]{width:16px}.w-\[72px\]{width:72px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[78\%\]{max-width:78%}.max-w-\[88\%\]{max-width:88%}.max-w-\[90vw\]{max-width:90vw}.max-w-\[140px\]{max-width:140px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[860px\]{max-width:860px}.max-w-\[960px\]{max-width:960px}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[60px\]{min-width:60px}.min-w-\[80px\]{min-width:80px}.min-w-\[240px\]{min-width:240px}.min-w-\[300px\]{min-width:300px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize-none{resize:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-px{gap:1px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[7px\]{border-radius:7px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-br-md{border-bottom-right-radius:var(--radius-md)}.\!border-2{border-style:var(--tw-border-style)!important;border-width:2px!important}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-\[\#111\]{border-color:#111!important}.\!border-white\/\[0\.06\]{border-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\!border-white\/\[0\.06\]{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}.border-\[var\(--color-accent\)\]{border-color:var(--color-accent)}.border-\[var\(--color-accent\)\]\/30{border-color:#6ee7d34d}@supports (color:color-mix(in lab,red,red)){.border-\[var\(--color-accent\)\]\/30{border-color:color-mix(in oklab,var(--color-accent) 30%,transparent)}}.border-amber-400\/20{border-color:#fcbb0033}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/20{border-color:color-mix(in oklab,var(--color-amber-400) 20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500) 30%,transparent)}}.border-emerald-400\/20{border-color:#00d29433}@supports (color:color-mix(in lab,red,red)){.border-emerald-400\/20{border-color:color-mix(in oklab,var(--color-emerald-400) 20%,transparent)}}.border-green-300\/60{border-color:#7bf1a899}@supports (color:color-mix(in lab,red,red)){.border-green-300\/60{border-color:color-mix(in oklab,var(--color-green-300) 60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.border-green-500\/\[0\.08\]{border-color:#00c75814}@supports (color:color-mix(in lab,red,red)){.border-green-500\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-green-500) 8%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500) 30%,transparent)}}.border-pink-400\/20{border-color:#fb64b633}@supports (color:color-mix(in lab,red,red)){.border-pink-400\/20{border-color:color-mix(in oklab,var(--color-pink-400) 20%,transparent)}}.border-pink-500\/30{border-color:#f6339a4d}@supports (color:color-mix(in lab,red,red)){.border-pink-500\/30{border-color:color-mix(in oklab,var(--color-pink-500) 30%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500) 30%,transparent)}}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.border-red-500\/\[0\.08\]{border-color:#fb2c3614}@supports (color:color-mix(in lab,red,red)){.border-red-500\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-red-500) 8%,transparent)}}.border-rose-400\/20{border-color:#ff667f33}@supports (color:color-mix(in lab,red,red)){.border-rose-400\/20{border-color:color-mix(in oklab,var(--color-rose-400) 20%,transparent)}}.border-sky-400\/20{border-color:#00bcfe33}@supports (color:color-mix(in lab,red,red)){.border-sky-400\/20{border-color:color-mix(in oklab,var(--color-sky-400) 20%,transparent)}}.border-violet-400\/20{border-color:#a685ff33}@supports (color:color-mix(in lab,red,red)){.border-violet-400\/20{border-color:color-mix(in oklab,var(--color-violet-400) 20%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/15{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.border-white\/15{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.border-white\/\[0\.1\]{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.1\]{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/\[0\.04\]{border-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.04\]{border-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.border-white\/\[0\.05\]{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.05\]{border-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.border-white\/\[0\.06\]{border-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.06\]{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.border-white\/\[0\.07\]{border-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.07\]{border-color:color-mix(in oklab,var(--color-white) 7%,transparent)}}.border-white\/\[0\.08\]{border-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.border-white\/\[0\.10\]{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.10\]{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/\[0\.12\]{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.12\]{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.border-white\/\[0\.15\]{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.15\]{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.border-white\/\[0\.25\]{border-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.25\]{border-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500) 30%,transparent)}}.border-t-\[var\(--color-accent\)\]{border-top-color:var(--color-accent)}.border-t-transparent{border-top-color:#0000}.border-t-white\/40{border-top-color:#fff6}@supports (color:color-mix(in lab,red,red)){.border-t-white\/40{border-top-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.\!bg-\[\#0a0a0a\]{background-color:#0a0a0a!important}.\!bg-\[\#111\]{background-color:#111!important}.\!bg-white\/30{background-color:#ffffff4d!important}@supports (color:color-mix(in lab,red,red)){.\!bg-white\/30{background-color:color-mix(in oklab,var(--color-white) 30%,transparent)!important}}.bg-\[\#0a0a0a\]{background-color:#0a0a0a}.bg-\[\#0a0a0c\]{background-color:#0a0a0c}.bg-\[\#0c0c10\]{background-color:#0c0c10}.bg-\[\#0d0d11\]{background-color:#0d0d11}.bg-\[\#0e0e0e\]{background-color:#0e0e0e}.bg-\[\#0e0e12\]{background-color:#0e0e12}.bg-\[\#111\]{background-color:#111}.bg-\[\#080808\]{background-color:#080808}.bg-\[\#101015\]{background-color:#101015}.bg-\[\#111114\]{background-color:#111114}.bg-\[var\(--color-accent\)\]{background-color:var(--color-accent)}.bg-\[var\(--color-accent-soft\)\]{background-color:var(--color-accent-soft)}.bg-amber-400{background-color:var(--color-amber-400)}.bg-amber-400\/15{background-color:#fcbb0026}@supports (color:color-mix(in lab,red,red)){.bg-amber-400\/15{background-color:color-mix(in oklab,var(--color-amber-400) 15%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-black\/75{background-color:#000000bf}@supports (color:color-mix(in lab,red,red)){.bg-black\/75{background-color:color-mix(in oklab,var(--color-black) 75%,transparent)}}.bg-black\/85{background-color:#000000d9}@supports (color:color-mix(in lab,red,red)){.bg-black\/85{background-color:color-mix(in oklab,var(--color-black) 85%,transparent)}}.bg-black\/95{background-color:#000000f2}@supports (color:color-mix(in lab,red,red)){.bg-black\/95{background-color:color-mix(in oklab,var(--color-black) 95%,transparent)}}.bg-emerald-400{background-color:var(--color-emerald-400)}.bg-emerald-400\/15{background-color:#00d29426}@supports (color:color-mix(in lab,red,red)){.bg-emerald-400\/15{background-color:color-mix(in oklab,var(--color-emerald-400) 15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500) 20%,transparent)}}.bg-green-500\/\[0\.04\]{background-color:#00c7580a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-green-500) 4%,transparent)}}.bg-green-500\/\[0\.06\]{background-color:#00c7580f}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-green-500) 6%,transparent)}}.bg-pink-400\/15{background-color:#fb64b626}@supports (color:color-mix(in lab,red,red)){.bg-pink-400\/15{background-color:color-mix(in oklab,var(--color-pink-400) 15%,transparent)}}.bg-red-400\/80{background-color:#ff6568cc}@supports (color:color-mix(in lab,red,red)){.bg-red-400\/80{background-color:color-mix(in oklab,var(--color-red-400) 80%,transparent)}}.bg-red-500\/\[0\.04\]{background-color:#fb2c360a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-red-500) 4%,transparent)}}.bg-red-500\/\[0\.06\]{background-color:#fb2c360f}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-red-500) 6%,transparent)}}.bg-rose-400{background-color:var(--color-rose-400)}.bg-rose-400\/15{background-color:#ff667f26}@supports (color:color-mix(in lab,red,red)){.bg-rose-400\/15{background-color:color-mix(in oklab,var(--color-rose-400) 15%,transparent)}}.bg-sky-400\/15{background-color:#00bcfe26}@supports (color:color-mix(in lab,red,red)){.bg-sky-400\/15{background-color:color-mix(in oklab,var(--color-sky-400) 15%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-400\/15{background-color:#a685ff26}@supports (color:color-mix(in lab,red,red)){.bg-violet-400\/15{background-color:color-mix(in oklab,var(--color-violet-400) 15%,transparent)}}.bg-white{background-color:var(--color-white)}.bg-white\/25{background-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.bg-white\/25{background-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.bg-white\/30{background-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.bg-white\/30{background-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.bg-white\/\[0\.1\]{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.1\]{background-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.bg-white\/\[0\.02\]{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.02\]{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.bg-white\/\[0\.03\]{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.03\]{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.bg-white\/\[0\.04\]{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.bg-white\/\[0\.05\]{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.05\]{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.bg-white\/\[0\.06\]{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.bg-white\/\[0\.07\]{background-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.07\]{background-color:color-mix(in oklab,var(--color-white) 7%,transparent)}}.bg-white\/\[0\.08\]{background-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.08\]{background-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.bg-white\/\[0\.09\]{background-color:#ffffff17}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.09\]{background-color:color-mix(in oklab,var(--color-white) 9%,transparent)}}.bg-white\/\[0\.015\]{background-color:#ffffff04}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.015\]{background-color:color-mix(in oklab,var(--color-white) 1.5%,transparent)}}.bg-yellow-400\/70{background-color:#fac800b3}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/70{background-color:color-mix(in oklab,var(--color-yellow-400) 70%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-\[repeating-conic-gradient\(\#1a1a1a_0\%_25\%\,\#111_0\%_50\%\)_0_0\/20px_20px\]{background-image:repeating-conic-gradient(#1a1a1a 0% 25%,#111 0% 50%) 0 0/20px 20px}.from-white\/95{--tw-gradient-from:#fffffff2}@supports (color:color-mix(in lab,red,red)){.from-white\/95{--tw-gradient-from:color-mix(in oklab, var(--color-white) 95%, transparent)}}.from-white\/95{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-white\/75{--tw-gradient-to:#ffffffbf}@supports (color:color-mix(in lab,red,red)){.to-white\/75{--tw-gradient-to:color-mix(in oklab, var(--color-white) 75%, transparent)}}.to-white\/75{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-3\.5{padding:calc(var(--spacing) * 3.5)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-\[2px\]{padding-block:2px}.py-\[3px\]{padding-block:3px}.py-\[6px\]{padding-block:6px}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-8{padding-top:calc(var(--spacing) * 8)}.pb-0\.5{padding-bottom:calc(var(--spacing) * .5)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-1\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-2\.5{padding-bottom:calc(var(--spacing) * 2.5)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-5{padding-bottom:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-\[10\.5px\]{font-size:10.5px}.text-\[10px\]{font-size:10px}.text-\[11\.5px\]{font-size:11.5px}.text-\[11px\]{font-size:11px}.text-\[12\.5px\]{font-size:12.5px}.text-\[12px\]{font-size:12px}.text-\[13\.5px\]{font-size:13.5px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.text-\[15\.5px\]{font-size:15.5px}.text-\[15px\]{font-size:15px}.text-\[16px\]{font-size:16px}.text-\[17px\]{font-size:17px}.text-\[20px\]{font-size:20px}.leading-loose{--tw-leading:var(--leading-loose);line-height:var(--leading-loose)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.02em\]{--tw-tracking:-.02em;letter-spacing:-.02em}.tracking-\[0\.1em\]{--tw-tracking:.1em;letter-spacing:.1em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--color-accent\)\]{color:var(--color-accent)}.text-amber-300{color:var(--color-amber-300)}.text-black{color:var(--color-black)}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/50{color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/50{color:color-mix(in oklab,var(--color-blue-400) 50%,transparent)}}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-green-200\/85{color:#b9f8cfd9}@supports (color:color-mix(in lab,red,red)){.text-green-200\/85{color:color-mix(in oklab,var(--color-green-200) 85%,transparent)}}.text-green-300{color:var(--color-green-300)}.text-green-400\/40{color:#05df7266}@supports (color:color-mix(in lab,red,red)){.text-green-400\/40{color:color-mix(in oklab,var(--color-green-400) 40%,transparent)}}.text-green-400\/50{color:#05df7280}@supports (color:color-mix(in lab,red,red)){.text-green-400\/50{color:color-mix(in oklab,var(--color-green-400) 50%,transparent)}}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab,red,red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400) 60%,transparent)}}.text-green-400\/70{color:#05df72b3}@supports (color:color-mix(in lab,red,red)){.text-green-400\/70{color:color-mix(in oklab,var(--color-green-400) 70%,transparent)}}.text-orange-400\/50{color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/50{color:color-mix(in oklab,var(--color-orange-400) 50%,transparent)}}.text-pink-300{color:var(--color-pink-300)}.text-pink-400\/50{color:#fb64b680}@supports (color:color-mix(in lab,red,red)){.text-pink-400\/50{color:color-mix(in oklab,var(--color-pink-400) 50%,transparent)}}.text-purple-400\/50{color:#c07eff80}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/50{color:color-mix(in oklab,var(--color-purple-400) 50%,transparent)}}.text-red-200\/85{color:#ffcacad9}@supports (color:color-mix(in lab,red,red)){.text-red-200\/85{color:color-mix(in oklab,var(--color-red-200) 85%,transparent)}}.text-red-300{color:var(--color-red-300)}.text-red-300\/70{color:#ffa3a3b3}@supports (color:color-mix(in lab,red,red)){.text-red-300\/70{color:color-mix(in oklab,var(--color-red-300) 70%,transparent)}}.text-red-300\/95{color:#ffa3a3f2}@supports (color:color-mix(in lab,red,red)){.text-red-300\/95{color:color-mix(in oklab,var(--color-red-300) 95%,transparent)}}.text-red-400\/40{color:#ff656866}@supports (color:color-mix(in lab,red,red)){.text-red-400\/40{color:color-mix(in oklab,var(--color-red-400) 40%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400) 70%,transparent)}}.text-rose-300{color:var(--color-rose-300)}.text-rose-300\/85{color:#ffa2aed9}@supports (color:color-mix(in lab,red,red)){.text-rose-300\/85{color:color-mix(in oklab,var(--color-rose-300) 85%,transparent)}}.text-sky-300{color:var(--color-sky-300)}.text-violet-300{color:var(--color-violet-300)}.text-white{color:var(--color-white)}.text-white\/10{color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.text-white\/10{color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.text-white\/15{color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.text-white\/15{color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.text-white\/18{color:#ffffff2e}@supports (color:color-mix(in lab,red,red)){.text-white\/18{color:color-mix(in oklab,var(--color-white) 18%,transparent)}}.text-white\/20{color:#fff3}@supports (color:color-mix(in lab,red,red)){.text-white\/20{color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.text-white\/25{color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.text-white\/25{color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.text-white\/35{color:#ffffff59}@supports (color:color-mix(in lab,red,red)){.text-white\/35{color:color-mix(in oklab,var(--color-white) 35%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.text-white\/45{color:#ffffff73}@supports (color:color-mix(in lab,red,red)){.text-white\/45{color:color-mix(in oklab,var(--color-white) 45%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.text-white\/55{color:#ffffff8c}@supports (color:color-mix(in lab,red,red)){.text-white\/55{color:color-mix(in oklab,var(--color-white) 55%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white) 60%,transparent)}}.text-white\/65{color:#ffffffa6}@supports (color:color-mix(in lab,red,red)){.text-white\/65{color:color-mix(in oklab,var(--color-white) 65%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.text-white\/75{color:#ffffffbf}@supports (color:color-mix(in lab,red,red)){.text-white\/75{color:color-mix(in oklab,var(--color-white) 75%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.text-white\/85{color:#ffffffd9}@supports (color:color-mix(in lab,red,red)){.text-white\/85{color:color-mix(in oklab,var(--color-white) 85%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.text-white\/95{color:#fffffff2}@supports (color:color-mix(in lab,red,red)){.text-white\/95{color:color-mix(in oklab,var(--color-white) 95%,transparent)}}.text-yellow-300\/85{color:#ffe02ad9}@supports (color:color-mix(in lab,red,red)){.text-yellow-300\/85{color:color-mix(in oklab,var(--color-yellow-300) 85%,transparent)}}.text-yellow-400\/50{color:#fac80080}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/50{color:color-mix(in oklab,var(--color-yellow-400) 50%,transparent)}}.uppercase{text-transform:uppercase}.italic{font-style:italic}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.accent-white{accent-color:var(--color-white)}.accent-white\/50{accent-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.accent-white\/50{accent-color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-40{opacity:.4}.opacity-80{opacity:.8}.opacity-100{opacity:1}.\!shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgba\(255\,255\,255\,0\.05\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff0d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-black\/30{--tw-shadow-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.shadow-black\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/50{--tw-shadow-color:#00000080}@supports (color:color-mix(in lab,red,red)){.shadow-black\/50{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 50%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/60{--tw-shadow-color:#0009}@supports (color:color-mix(in lab,red,red)){.shadow-black\/60{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 60%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/70{--tw-shadow-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.shadow-black\/70{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 70%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-green-500\/30{--tw-ring-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.ring-green-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-green-500) 30%, transparent)}}.ring-red-500\/30{--tw-ring-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.ring-red-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-red-500) 30%, transparent)}}.ring-white\/20{--tw-ring-color:#fff3}@supports (color:color-mix(in lab,red,red)){.ring-white\/20{--tw-ring-color:color-mix(in oklab, var(--color-white) 20%, transparent)}}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.group-focus-within\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media(hover:hover){.group-hover\:text-\[var\(--color-accent\)\]:is(:where(.group):hover *){color:var(--color-accent)}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/code\:opacity-100:is(:where(.group\/code):hover *){opacity:1}}.placeholder\:text-white\/8::placeholder{color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/8::placeholder{color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.placeholder\:text-white\/12::placeholder{color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/12::placeholder{color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.placeholder\:text-white\/15::placeholder{color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/15::placeholder{color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.placeholder\:text-white\/25::placeholder{color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/25::placeholder{color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.placeholder\:text-white\/30::placeholder{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/30::placeholder{color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.focus-within\:border-white\/\[0\.22\]:focus-within{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.focus-within\:border-white\/\[0\.22\]:focus-within{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.focus-within\:shadow-xl:focus-within{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-within\:shadow-black\/40:focus-within{--tw-shadow-color:#0006}@supports (color:color-mix(in lab,red,red)){.focus-within\:shadow-black\/40:focus-within{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 40%, transparent) var(--tw-shadow-alpha), transparent)}}@media(hover:hover){.hover\:border-white\/\[0\.1\]:hover{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.1\]:hover{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.hover\:border-white\/\[0\.2\]:hover{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.2\]:hover{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.hover\:border-white\/\[0\.12\]:hover{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.12\]:hover{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.hover\:border-white\/\[0\.14\]:hover{border-color:#ffffff24}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.14\]:hover{border-color:color-mix(in oklab,var(--color-white) 14%,transparent)}}.hover\:border-white\/\[0\.15\]:hover{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.15\]:hover{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.hover\:border-white\/\[0\.16\]:hover{border-color:#ffffff29}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.16\]:hover{border-color:color-mix(in oklab,var(--color-white) 16%,transparent)}}.hover\:border-white\/\[0\.18\]:hover{border-color:#ffffff2e}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.18\]:hover{border-color:color-mix(in oklab,var(--color-white) 18%,transparent)}}.hover\:border-white\/\[0\.22\]:hover{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.22\]:hover{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.hover\:bg-black:hover{background-color:var(--color-black)}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black) 80%,transparent)}}.hover\:bg-black\/85:hover{background-color:#000000d9}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/85:hover{background-color:color-mix(in oklab,var(--color-black) 85%,transparent)}}.hover\:bg-green-500\/30:hover{background-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/30:hover{background-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.hover\:bg-white\/90:hover{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/90:hover{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.hover\:bg-white\/95:hover{background-color:#fffffff2}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/95:hover{background-color:color-mix(in oklab,var(--color-white) 95%,transparent)}}.hover\:bg-white\/\[0\.02\]:hover{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.02\]:hover{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.hover\:bg-white\/\[0\.03\]:hover{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.03\]:hover{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.hover\:bg-white\/\[0\.04\]:hover{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.04\]:hover{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.hover\:bg-white\/\[0\.05\]:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.05\]:hover{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.hover\:bg-white\/\[0\.06\]:hover{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.06\]:hover{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.hover\:bg-white\/\[0\.14\]:hover{background-color:#ffffff24}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.14\]:hover{background-color:color-mix(in oklab,var(--color-white) 14%,transparent)}}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400\/60:hover{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.hover\:text-red-400\/60:hover{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.hover\:text-rose-200:hover{color:var(--color-rose-200)}.hover\:text-rose-300:hover{color:var(--color-rose-300)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/35:hover{color:#ffffff59}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/35:hover{color:color-mix(in oklab,var(--color-white) 35%,transparent)}}.hover\:text-white\/40:hover{color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/40:hover{color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.hover\:text-white\/45:hover{color:#ffffff73}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/45:hover{color:color-mix(in oklab,var(--color-white) 45%,transparent)}}.hover\:text-white\/50:hover{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/50:hover{color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.hover\:text-white\/55:hover{color:#ffffff8c}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/55:hover{color:color-mix(in oklab,var(--color-white) 55%,transparent)}}.hover\:text-white\/60:hover{color:#fff9}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/60:hover{color:color-mix(in oklab,var(--color-white) 60%,transparent)}}.hover\:text-white\/65:hover{color:#ffffffa6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/65:hover{color:color-mix(in oklab,var(--color-white) 65%,transparent)}}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.hover\:text-white\/85:hover{color:#ffffffd9}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/85:hover{color:color-mix(in oklab,var(--color-white) 85%,transparent)}}.hover\:text-white\/90:hover{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/90:hover{color:color-mix(in oklab,var(--color-white) 90%,transparent)}}}.focus\:border-white\/\[0\.1\]:focus{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.1\]:focus{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.focus\:border-white\/\[0\.2\]:focus{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.2\]:focus{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.focus\:border-white\/\[0\.12\]:focus{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.12\]:focus{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.focus\:border-white\/\[0\.22\]:focus{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.22\]:focus{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.focus\:border-white\/\[0\.25\]:focus{border-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.25\]:focus{border-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.focus-visible\:opacity-100:focus-visible{opacity:1}.focus-visible\:outline:focus-visible,.focus-visible\:outline-1:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-\[var\(--color-accent\)\]:focus-visible{outline-color:var(--color-accent)}.focus-visible\:outline-white\/30:focus-visible{outline-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/30:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.focus-visible\:outline-white\/40:focus-visible{outline-color:#fff6}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/40:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.focus-visible\:outline-white\/50:focus-visible{outline-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/50:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.active\:scale-\[0\.99\]:active{scale:.99}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-60:disabled{opacity:.6}@media(min-width:40rem){.sm\:block{display:block}.sm\:inline{display:inline}.sm\:w-64{width:calc(var(--spacing) * 64)}.sm\:px-5{padding-inline:calc(var(--spacing) * 5)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}}@media(min-width:48rem){.md\:static{position:static}.md\:block{display:block}.md\:hidden{display:none}.md\:inline{display:inline}.md\:h-full{height:100%}.md\:max-h-none{max-height:none}.md\:w-64{width:calc(var(--spacing) * 64)}.md\:w-\[60px\]{width:60px}.md\:w-\[360px\]{width:360px}.md\:w-auto{width:auto}.md\:translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:flex-row{flex-direction:row}.md\:justify-center{justify-content:center}.md\:p-7{padding:calc(var(--spacing) * 7)}.md\:px-0{padding-inline:calc(var(--spacing) * 0)}.md\:px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.md\:px-3{padding-inline:calc(var(--spacing) * 3)}.md\:py-2{padding-block:calc(var(--spacing) * 2)}}@media(min-width:64rem){.lg\:w-\[400px\]{width:400px}}@media(min-width:80rem){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\[\&_button\]\:\!px-2 button{padding-inline:calc(var(--spacing) * 2)!important}.\[\&_button\]\:\!py-1 button{padding-block:calc(var(--spacing) * 1)!important}.\[\&_button\]\:\!text-\[13px\] button{font-size:13px!important}.\[\&\>button\]\:\!border-white\/\[0\.06\]>button{border-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\]\:\!border-white\/\[0\.06\]>button{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}.\[\&\>button\]\:\!bg-\[\#111\]>button{background-color:#111!important}.\[\&\>button\]\:\!text-white\/30>button{color:#ffffff4d!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\]\:\!text-white\/30>button{color:color-mix(in oklab,var(--color-white) 30%,transparent)!important}}.\[\&\>button\:hover\]\:\!bg-white\/\[0\.06\]>button:hover{background-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\:hover\]\:\!bg-white\/\[0\.06\]>button:hover{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}}body{background:var(--color-bg-base);color:var(--color-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"ss01","cv11";margin:0}::selection{color:#fff;background:#6ee7d340}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:rgba(var(--fg),.1);background-clip:padding-box;border:2px solid #0000;border-radius:8px}::-webkit-scrollbar-thumb:hover{background:rgba(var(--fg),.2);background-clip:padding-box;border:2px solid #0000}*{scrollbar-width:thin;scrollbar-color:rgba(var(--fg),.1) transparent}@keyframes fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}@keyframes scale-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes pulse-dot{0%,to{opacity:.2}50%{opacity:.7}}@keyframes shimmer{0%{background-position:-1000px 0}to{background-position:1000px 0}}.animate-fade-in{animation:.18s cubic-bezier(.2,.8,.2,1) fade-in}.animate-scale-in{animation:.14s cubic-bezier(.2,.8,.2,1) scale-in}.animate-pulse-dot{animation:1.4s ease-in-out infinite pulse-dot}.skeleton{background:linear-gradient(90deg,rgba(var(--fg),.03),rgba(var(--fg),.07),rgba(var(--fg),.03));background-size:1000px 100%;animation:2s linear infinite shimmer}@media(prefers-reduced-motion:reduce){*,:before,:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}input[type=range]{appearance:none;background:rgba(var(--fg),.1);border-radius:999px;outline:none;height:3px;margin-top:6px}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;cursor:pointer;background:#fff;border:none;border-radius:50%;width:14px;height:14px;transition:box-shadow .12s ease-out,transform .12s ease-out;box-shadow:0 1px 4px #0006}input[type=range]::-webkit-slider-thumb:hover{transform:scale(1.1)}input[type=range]::-moz-range-thumb{cursor:pointer;background:#fff;border:none;border-radius:50%;width:14px;height:14px;transition:box-shadow .12s ease-out,transform .12s ease-out;box-shadow:0 1px 4px #0006}input[type=range]:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 4px var(--color-accent-soft),0 1px 4px #0006}input[type=range]:focus-visible::-moz-range-thumb{box-shadow:0 0 0 4px var(--color-accent-soft),0 1px 4px #0006}textarea{field-sizing:content}:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px;border-radius:6px}button:focus,a:focus,textarea:focus,input:focus,select:focus{outline:none}@media(pointer:coarse){button,a,[role=button]{min-height:36px}}.prose-venice{word-break:break-word}.prose-venice>:first-child{margin-top:0!important}.prose-venice>:last-child{margin-bottom:0!important}.prose-venice p{margin:.6em 0;line-height:1.7}.prose-venice p:first-child{margin-top:0}.prose-venice p:last-child{margin-bottom:0}.prose-venice h1,.prose-venice h2,.prose-venice h3,.prose-venice h4{color:rgba(var(--fg),.95);letter-spacing:-.012em;margin:1.3em 0 .4em;font-weight:600;line-height:1.3}.prose-venice h1{font-size:1.25em}.prose-venice h2{font-size:1.12em}.prose-venice h3{font-size:1em}.prose-venice strong{color:rgba(var(--fg),.95);font-weight:600}.prose-venice em{color:rgba(var(--fg),.78)}.prose-venice code{font-family:var(--font-mono);background:rgba(var(--fg),.06);color:rgba(var(--fg),.88);border-radius:4px;padding:.13em .4em;font-size:.86em}.prose-venice pre{background:rgba(var(--fg),.025);border:1px solid rgba(var(--fg),.07);border-radius:8px;margin:.8em 0;padding:1.9em 1em 1em;overflow-x:auto}.prose-venice pre code{color:rgba(var(--fg),.82);tab-size:2;background:0 0;border-radius:0;padding:0;font-size:.85em;line-height:1.65}.prose-venice ul,.prose-venice ol{margin:.5em 0;padding-left:1.4em}.prose-venice ul{list-style-type:disc}.prose-venice ol{list-style-type:decimal}.prose-venice li{margin:.25em 0;line-height:1.65}.prose-venice li::marker{color:rgba(var(--fg),.35)}.prose-venice blockquote{border-left:3px solid var(--color-accent);color:rgba(var(--fg),.65);margin:.8em 0;padding-left:1em;font-style:italic}.prose-venice table{border-collapse:collapse;width:100%;margin:.8em 0;font-size:.9em}.prose-venice th,.prose-venice td{border:1px solid rgba(var(--fg),.08);text-align:left;padding:.5em .75em}.prose-venice th{background:rgba(var(--fg),.04);color:rgba(var(--fg),.75);text-transform:uppercase;letter-spacing:.04em;font-size:.85em;font-weight:600}.prose-venice a{color:var(--color-accent);text-underline-offset:2px;-webkit-text-decoration:underline #6ee7d366;text-decoration:underline #6ee7d366;transition:text-decoration-color .1s}.prose-venice a:hover{-webkit-text-decoration-color:var(--color-accent);text-decoration-color:var(--color-accent)}.prose-venice hr{border:none;border-top:1px solid rgba(var(--fg),.08);margin:1.2em 0}.prose-venice img{border-radius:8px;max-width:100%}:root{--fg:255, 255, 255;--font-sans:"Times New Roman", Times, "Liberation Serif", "Nimbus Roman", "DejaVu Serif", serif;--font-mono:"Courier New", Courier, "Liberation Mono", "Nimbus Mono PS", "DejaVu Sans Mono", monospace;--color-bg-base:#0d0d0d;--color-bg-raised:#141414;--color-bg-overlay:#1c1c1c;--color-bg-input:#111;--color-accent:#8cb4ff;--color-accent-soft:#8cb4ff29;color-scheme:dark}:root[data-theme=light]{--fg:0, 0, 0;--color-white:#000;--color-black:#fff;--color-bg-base:#fff;--color-bg-raised:#fff;--color-bg-overlay:#f2f2f2;--color-bg-input:#fff;--color-border-faint:#0000001a;--color-border-soft:#0000002e;--color-border-strong:#00000080;--color-text-primary:#000;--color-text-secondary:#000000b8;--color-text-tertiary:#0000008c;--color-text-quaternary:#0000006b;--color-accent:#00e;--color-accent-soft:#0000ee1a;color-scheme:light}@media(prefers-color-scheme:light){:root:not([data-theme=dark]){--fg:0, 0, 0;--color-white:#000;--color-black:#fff;--color-bg-base:#fff;--color-bg-raised:#fff;--color-bg-overlay:#f2f2f2;--color-bg-input:#fff;--color-border-faint:#0000001a;--color-border-soft:#0000002e;--color-border-strong:#00000080;--color-text-primary:#000;--color-text-secondary:#000000b8;--color-text-tertiary:#0000008c;--color-text-quaternary:#0000006b;--color-accent:#00e;--color-accent-soft:#0000ee1a;color-scheme:light}}html{color-scheme:normal}body{font-feature-settings:normal;font-size:17px}*,:before,:after{border-radius:0!important}.animate-spin{border-radius:9999px!important}label,kbd,code,pre,.font-mono,[class*=uppercase]{font-family:var(--font-mono)}.bg-\[\#080808\],.bg-\[\#0a0a0a\],.bg-\[\#0a0a0c\],.bg-\[\#0c0c10\]{background-color:var(--color-bg-base)!important}.bg-\[\#0d0d11\],.bg-\[\#0e0e0e\],.bg-\[\#0e0e12\],.bg-\[\#101015\],.bg-\[\#111114\],.bg-\[\#111\]{background-color:var(--color-bg-raised)!important}.border-\[\#111\]{border-color:var(--color-bg-raised)!important}:root[data-theme=light] .text-white\/10,:root[data-theme=light] .placeholder\:text-white\/10::placeholder,:root[data-theme=light] .text-white\/15,:root[data-theme=light] .placeholder\:text-white\/15::placeholder,:root[data-theme=light] .text-white\/20,:root[data-theme=light] .placeholder\:text-white\/20::placeholder,:root[data-theme=light] .text-white\/25,:root[data-theme=light] .placeholder\:text-white\/25::placeholder{color:#00000073!important}:root[data-theme=light] .text-white\/30,:root[data-theme=light] .placeholder\:text-white\/30::placeholder,:root[data-theme=light] .text-white\/35,:root[data-theme=light] .placeholder\:text-white\/35::placeholder{color:#0000008c!important}:root[data-theme=light] .text-white\/40,:root[data-theme=light] .placeholder\:text-white\/40::placeholder,:root[data-theme=light] .text-white\/45,:root[data-theme=light] .placeholder\:text-white\/45::placeholder{color:#0000009e!important}:root[data-theme=light] .text-white\/50,:root[data-theme=light] .placeholder\:text-white\/50::placeholder,:root[data-theme=light] .text-white\/55,:root[data-theme=light] .placeholder\:text-white\/55::placeholder{color:#000000ad!important}@media(prefers-color-scheme:light){:root:not([data-theme=dark]) .text-white\/10,:root:not([data-theme=dark]) .placeholder\:text-white\/10::placeholder,:root:not([data-theme=dark]) .text-white\/15,:root:not([data-theme=dark]) .placeholder\:text-white\/15::placeholder,:root:not([data-theme=dark]) .text-white\/20,:root:not([data-theme=dark]) .placeholder\:text-white\/20::placeholder,:root:not([data-theme=dark]) .text-white\/25,:root:not([data-theme=dark]) .placeholder\:text-white\/25::placeholder{color:#00000073!important}:root:not([data-theme=dark]) .text-white\/30,:root:not([data-theme=dark]) .placeholder\:text-white\/30::placeholder,:root:not([data-theme=dark]) .text-white\/35,:root:not([data-theme=dark]) .placeholder\:text-white\/35::placeholder{color:#0000008c!important}:root:not([data-theme=dark]) .text-white\/40,:root:not([data-theme=dark]) .placeholder\:text-white\/40::placeholder,:root:not([data-theme=dark]) .text-white\/45,:root:not([data-theme=dark]) .placeholder\:text-white\/45::placeholder{color:#0000009e!important}:root:not([data-theme=dark]) .text-white\/50,:root:not([data-theme=dark]) .placeholder\:text-white\/50::placeholder,:root:not([data-theme=dark]) .text-white\/55,:root:not([data-theme=dark]) .placeholder\:text-white\/55::placeholder{color:#000000ad!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/ventures/havre/open/assets/index-DaJeA1VZ.css b/ventures/havre/open/assets/index-DaJeA1VZ.css new file mode 100644 index 0000000..988fd5c --- /dev/null +++ b/ventures/havre/open/assets/index-DaJeA1VZ.css @@ -0,0 +1 @@ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-outline-style:solid;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:"Inter", "InterVariable", system-ui, sans-serif;--font-mono:"JetBrains Mono", "SF Mono", monospace;--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-300:oklch(82.8% .111 230.318);--color-sky-400:oklch(74.6% .16 232.661);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-violet-300:oklch(81.1% .111 293.571);--color-violet-400:oklch(70.2% .183 293.541);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-pink-300:oklch(82.3% .12 346.018);--color-pink-400:oklch(71.8% .202 349.761);--color-pink-500:oklch(65.6% .241 354.308);--color-rose-200:oklch(89.2% .058 10.001);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-3xl:48rem;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-snug:1.375;--leading-relaxed:1.625;--leading-loose:2;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--ease-out:cubic-bezier(0, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-sm:8px;--blur-md:12px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg-base:#0a0a0c;--color-bg-raised:#111114;--color-text-primary:rgba(var(--fg), .92);--color-accent:#6ee7d3;--color-accent-soft:#6ee7d329}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.-top-1\.5{top:calc(var(--spacing) * -1.5)}.top-0{top:calc(var(--spacing) * 0)}.top-0\.5{top:calc(var(--spacing) * .5)}.top-1\.5{top:calc(var(--spacing) * 1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-3{top:calc(var(--spacing) * 3)}.top-\[2px\]{top:2px}.top-full{top:100%}.-right-1\.5{right:calc(var(--spacing) * -1.5)}.right-0{right:calc(var(--spacing) * 0)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.right-2{right:calc(var(--spacing) * 2)}.right-3{right:calc(var(--spacing) * 3)}.right-4{right:calc(var(--spacing) * 4)}.bottom-4{bottom:calc(var(--spacing) * 4)}.left-0{left:calc(var(--spacing) * 0)}.left-0\.5{left:calc(var(--spacing) * .5)}.left-3{left:calc(var(--spacing) * 3)}.left-\[2px\]{left:2px}.left-\[16px\]{left:16px}.left-\[20px\]{left:20px}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[100\]{z-index:100}.-m-0\.5{margin:calc(var(--spacing) * -.5)}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-px{margin-top:1px}.-mr-1{margin-right:calc(var(--spacing) * -1)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.-ml-1{margin-left:calc(var(--spacing) * -1)}.ml-auto{margin-left:auto}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-6{-webkit-line-clamp:6;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-8{-webkit-line-clamp:8;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.list-item{display:list-item}.aspect-square{aspect-ratio:1}.\!h-3{height:calc(var(--spacing) * 3)!important}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-14{height:calc(var(--spacing) * 14)}.h-16{height:calc(var(--spacing) * 16)}.h-24{height:calc(var(--spacing) * 24)}.h-\[14px\]{height:14px}.h-\[16px\]{height:16px}.h-\[18px\]{height:18px}.h-\[100dvh\]{height:100dvh}.h-full{height:100%}.max-h-24{max-height:calc(var(--spacing) * 24)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-\[55vh\]{max-height:55vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[380px\]{max-height:380px}.max-h-\[calc\(100vh-240px\)\]{max-height:calc(100vh - 240px)}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-\[40px\]{min-height:40px}.min-h-\[60px\]{min-height:60px}.min-h-full{min-height:100%}.\!w-3{width:calc(var(--spacing) * 3)!important}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1{width:calc(var(--spacing) * 1)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-24{width:calc(var(--spacing) * 24)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-96{width:calc(var(--spacing) * 96)}.w-\[14px\]{width:14px}.w-\[16px\]{width:16px}.w-\[72px\]{width:72px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[78\%\]{max-width:78%}.max-w-\[88\%\]{max-width:88%}.max-w-\[90vw\]{max-width:90vw}.max-w-\[140px\]{max-width:140px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[340px\]{max-width:340px}.max-w-\[860px\]{max-width:860px}.max-w-\[960px\]{max-width:960px}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[60px\]{min-width:60px}.min-w-\[80px\]{min-width:80px}.min-w-\[240px\]{min-width:240px}.min-w-\[300px\]{min-width:300px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize-none{resize:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-px{gap:1px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[7px\]{border-radius:7px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-br-md{border-bottom-right-radius:var(--radius-md)}.\!border-2{border-style:var(--tw-border-style)!important;border-width:2px!important}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.\!border-\[\#111\]{border-color:#111!important}.\!border-white\/\[0\.06\]{border-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\!border-white\/\[0\.06\]{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}.border-\[var\(--color-accent\)\]{border-color:var(--color-accent)}.border-\[var\(--color-accent\)\]\/30{border-color:#6ee7d34d}@supports (color:color-mix(in lab,red,red)){.border-\[var\(--color-accent\)\]\/30{border-color:color-mix(in oklab,var(--color-accent) 30%,transparent)}}.border-amber-400\/20{border-color:#fcbb0033}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/20{border-color:color-mix(in oklab,var(--color-amber-400) 20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500) 30%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500) 30%,transparent)}}.border-emerald-400\/20{border-color:#00d29433}@supports (color:color-mix(in lab,red,red)){.border-emerald-400\/20{border-color:color-mix(in oklab,var(--color-emerald-400) 20%,transparent)}}.border-green-300\/60{border-color:#7bf1a899}@supports (color:color-mix(in lab,red,red)){.border-green-300\/60{border-color:color-mix(in oklab,var(--color-green-300) 60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.border-green-500\/\[0\.08\]{border-color:#00c75814}@supports (color:color-mix(in lab,red,red)){.border-green-500\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-green-500) 8%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500) 30%,transparent)}}.border-pink-400\/20{border-color:#fb64b633}@supports (color:color-mix(in lab,red,red)){.border-pink-400\/20{border-color:color-mix(in oklab,var(--color-pink-400) 20%,transparent)}}.border-pink-500\/30{border-color:#f6339a4d}@supports (color:color-mix(in lab,red,red)){.border-pink-500\/30{border-color:color-mix(in oklab,var(--color-pink-500) 30%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500) 30%,transparent)}}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.border-red-500\/\[0\.08\]{border-color:#fb2c3614}@supports (color:color-mix(in lab,red,red)){.border-red-500\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-red-500) 8%,transparent)}}.border-rose-400\/20{border-color:#ff667f33}@supports (color:color-mix(in lab,red,red)){.border-rose-400\/20{border-color:color-mix(in oklab,var(--color-rose-400) 20%,transparent)}}.border-sky-400\/20{border-color:#00bcfe33}@supports (color:color-mix(in lab,red,red)){.border-sky-400\/20{border-color:color-mix(in oklab,var(--color-sky-400) 20%,transparent)}}.border-violet-400\/20{border-color:#a685ff33}@supports (color:color-mix(in lab,red,red)){.border-violet-400\/20{border-color:color-mix(in oklab,var(--color-violet-400) 20%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/15{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.border-white\/15{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.border-white\/\[0\.1\]{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.1\]{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/\[0\.04\]{border-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.04\]{border-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.border-white\/\[0\.05\]{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.05\]{border-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.border-white\/\[0\.06\]{border-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.06\]{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.border-white\/\[0\.07\]{border-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.07\]{border-color:color-mix(in oklab,var(--color-white) 7%,transparent)}}.border-white\/\[0\.08\]{border-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.08\]{border-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.border-white\/\[0\.10\]{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.10\]{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/\[0\.12\]{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.12\]{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.border-white\/\[0\.15\]{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.15\]{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.border-white\/\[0\.25\]{border-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.25\]{border-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500) 30%,transparent)}}.border-t-\[var\(--color-accent\)\]{border-top-color:var(--color-accent)}.border-t-transparent{border-top-color:#0000}.border-t-white\/40{border-top-color:#fff6}@supports (color:color-mix(in lab,red,red)){.border-t-white\/40{border-top-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.\!bg-\[\#0a0a0a\]{background-color:#0a0a0a!important}.\!bg-\[\#111\]{background-color:#111!important}.\!bg-white\/30{background-color:#ffffff4d!important}@supports (color:color-mix(in lab,red,red)){.\!bg-white\/30{background-color:color-mix(in oklab,var(--color-white) 30%,transparent)!important}}.bg-\[\#0a0a0a\]{background-color:#0a0a0a}.bg-\[\#0a0a0c\]{background-color:#0a0a0c}.bg-\[\#0c0c10\]{background-color:#0c0c10}.bg-\[\#0d0d11\]{background-color:#0d0d11}.bg-\[\#0e0e0e\]{background-color:#0e0e0e}.bg-\[\#0e0e12\]{background-color:#0e0e12}.bg-\[\#111\]{background-color:#111}.bg-\[\#080808\]{background-color:#080808}.bg-\[\#101015\]{background-color:#101015}.bg-\[\#111114\]{background-color:#111114}.bg-\[var\(--color-accent\)\]{background-color:var(--color-accent)}.bg-\[var\(--color-accent-soft\)\]{background-color:var(--color-accent-soft)}.bg-amber-400{background-color:var(--color-amber-400)}.bg-amber-400\/15{background-color:#fcbb0026}@supports (color:color-mix(in lab,red,red)){.bg-amber-400\/15{background-color:color-mix(in oklab,var(--color-amber-400) 15%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-black\/75{background-color:#000000bf}@supports (color:color-mix(in lab,red,red)){.bg-black\/75{background-color:color-mix(in oklab,var(--color-black) 75%,transparent)}}.bg-black\/85{background-color:#000000d9}@supports (color:color-mix(in lab,red,red)){.bg-black\/85{background-color:color-mix(in oklab,var(--color-black) 85%,transparent)}}.bg-black\/95{background-color:#000000f2}@supports (color:color-mix(in lab,red,red)){.bg-black\/95{background-color:color-mix(in oklab,var(--color-black) 95%,transparent)}}.bg-emerald-400{background-color:var(--color-emerald-400)}.bg-emerald-400\/15{background-color:#00d29426}@supports (color:color-mix(in lab,red,red)){.bg-emerald-400\/15{background-color:color-mix(in oklab,var(--color-emerald-400) 15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500) 20%,transparent)}}.bg-green-500\/\[0\.04\]{background-color:#00c7580a}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-green-500) 4%,transparent)}}.bg-green-500\/\[0\.06\]{background-color:#00c7580f}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-green-500) 6%,transparent)}}.bg-pink-400\/15{background-color:#fb64b626}@supports (color:color-mix(in lab,red,red)){.bg-pink-400\/15{background-color:color-mix(in oklab,var(--color-pink-400) 15%,transparent)}}.bg-red-400\/80{background-color:#ff6568cc}@supports (color:color-mix(in lab,red,red)){.bg-red-400\/80{background-color:color-mix(in oklab,var(--color-red-400) 80%,transparent)}}.bg-red-500\/\[0\.04\]{background-color:#fb2c360a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-red-500) 4%,transparent)}}.bg-red-500\/\[0\.06\]{background-color:#fb2c360f}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-red-500) 6%,transparent)}}.bg-rose-400{background-color:var(--color-rose-400)}.bg-rose-400\/15{background-color:#ff667f26}@supports (color:color-mix(in lab,red,red)){.bg-rose-400\/15{background-color:color-mix(in oklab,var(--color-rose-400) 15%,transparent)}}.bg-sky-400\/15{background-color:#00bcfe26}@supports (color:color-mix(in lab,red,red)){.bg-sky-400\/15{background-color:color-mix(in oklab,var(--color-sky-400) 15%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-400\/15{background-color:#a685ff26}@supports (color:color-mix(in lab,red,red)){.bg-violet-400\/15{background-color:color-mix(in oklab,var(--color-violet-400) 15%,transparent)}}.bg-white{background-color:var(--color-white)}.bg-white\/25{background-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.bg-white\/25{background-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.bg-white\/30{background-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.bg-white\/30{background-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.bg-white\/\[0\.1\]{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.1\]{background-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.bg-white\/\[0\.02\]{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.02\]{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.bg-white\/\[0\.03\]{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.03\]{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.bg-white\/\[0\.04\]{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.04\]{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.bg-white\/\[0\.05\]{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.05\]{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.bg-white\/\[0\.06\]{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.bg-white\/\[0\.07\]{background-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.07\]{background-color:color-mix(in oklab,var(--color-white) 7%,transparent)}}.bg-white\/\[0\.08\]{background-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.08\]{background-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.bg-white\/\[0\.09\]{background-color:#ffffff17}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.09\]{background-color:color-mix(in oklab,var(--color-white) 9%,transparent)}}.bg-white\/\[0\.015\]{background-color:#ffffff04}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.015\]{background-color:color-mix(in oklab,var(--color-white) 1.5%,transparent)}}.bg-yellow-400\/70{background-color:#fac800b3}@supports (color:color-mix(in lab,red,red)){.bg-yellow-400\/70{background-color:color-mix(in oklab,var(--color-yellow-400) 70%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-\[repeating-conic-gradient\(\#1a1a1a_0\%_25\%\,\#111_0\%_50\%\)_0_0\/20px_20px\]{background-image:repeating-conic-gradient(#1a1a1a 0% 25%,#111 0% 50%) 0 0/20px 20px}.from-white\/95{--tw-gradient-from:#fffffff2}@supports (color:color-mix(in lab,red,red)){.from-white\/95{--tw-gradient-from:color-mix(in oklab, var(--color-white) 95%, transparent)}}.from-white\/95{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-white\/75{--tw-gradient-to:#ffffffbf}@supports (color:color-mix(in lab,red,red)){.to-white\/75{--tw-gradient-to:color-mix(in oklab, var(--color-white) 75%, transparent)}}.to-white\/75{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-3\.5{padding:calc(var(--spacing) * 3.5)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-\[2px\]{padding-block:2px}.py-\[3px\]{padding-block:3px}.py-\[6px\]{padding-block:6px}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-8{padding-top:calc(var(--spacing) * 8)}.pb-0\.5{padding-bottom:calc(var(--spacing) * .5)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-1\.5{padding-bottom:calc(var(--spacing) * 1.5)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-2\.5{padding-bottom:calc(var(--spacing) * 2.5)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-5{padding-bottom:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-\[10\.5px\]{font-size:10.5px}.text-\[10px\]{font-size:10px}.text-\[11\.5px\]{font-size:11.5px}.text-\[11px\]{font-size:11px}.text-\[12\.5px\]{font-size:12.5px}.text-\[12px\]{font-size:12px}.text-\[13\.5px\]{font-size:13.5px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.text-\[15\.5px\]{font-size:15.5px}.text-\[15px\]{font-size:15px}.text-\[16px\]{font-size:16px}.text-\[17px\]{font-size:17px}.text-\[20px\]{font-size:20px}.leading-loose{--tw-leading:var(--leading-loose);line-height:var(--leading-loose)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.02em\]{--tw-tracking:-.02em;letter-spacing:-.02em}.tracking-\[0\.1em\]{--tw-tracking:.1em;letter-spacing:.1em}.tracking-\[0\.08em\]{--tw-tracking:.08em;letter-spacing:.08em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[var\(--color-accent\)\]{color:var(--color-accent)}.text-amber-300{color:var(--color-amber-300)}.text-black{color:var(--color-black)}.text-blue-400\/50{color:#54a2ff80}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/50{color:color-mix(in oklab,var(--color-blue-400) 50%,transparent)}}.text-cyan-400\/50{color:#00d2ef80}@supports (color:color-mix(in lab,red,red)){.text-cyan-400\/50{color:color-mix(in oklab,var(--color-cyan-400) 50%,transparent)}}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-green-200\/85{color:#b9f8cfd9}@supports (color:color-mix(in lab,red,red)){.text-green-200\/85{color:color-mix(in oklab,var(--color-green-200) 85%,transparent)}}.text-green-300{color:var(--color-green-300)}.text-green-400\/40{color:#05df7266}@supports (color:color-mix(in lab,red,red)){.text-green-400\/40{color:color-mix(in oklab,var(--color-green-400) 40%,transparent)}}.text-green-400\/50{color:#05df7280}@supports (color:color-mix(in lab,red,red)){.text-green-400\/50{color:color-mix(in oklab,var(--color-green-400) 50%,transparent)}}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab,red,red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400) 60%,transparent)}}.text-green-400\/70{color:#05df72b3}@supports (color:color-mix(in lab,red,red)){.text-green-400\/70{color:color-mix(in oklab,var(--color-green-400) 70%,transparent)}}.text-orange-400\/50{color:#ff8b1a80}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/50{color:color-mix(in oklab,var(--color-orange-400) 50%,transparent)}}.text-pink-300{color:var(--color-pink-300)}.text-pink-400\/50{color:#fb64b680}@supports (color:color-mix(in lab,red,red)){.text-pink-400\/50{color:color-mix(in oklab,var(--color-pink-400) 50%,transparent)}}.text-purple-400\/50{color:#c07eff80}@supports (color:color-mix(in lab,red,red)){.text-purple-400\/50{color:color-mix(in oklab,var(--color-purple-400) 50%,transparent)}}.text-red-200\/85{color:#ffcacad9}@supports (color:color-mix(in lab,red,red)){.text-red-200\/85{color:color-mix(in oklab,var(--color-red-200) 85%,transparent)}}.text-red-300{color:var(--color-red-300)}.text-red-300\/70{color:#ffa3a3b3}@supports (color:color-mix(in lab,red,red)){.text-red-300\/70{color:color-mix(in oklab,var(--color-red-300) 70%,transparent)}}.text-red-300\/95{color:#ffa3a3f2}@supports (color:color-mix(in lab,red,red)){.text-red-300\/95{color:color-mix(in oklab,var(--color-red-300) 95%,transparent)}}.text-red-400\/40{color:#ff656866}@supports (color:color-mix(in lab,red,red)){.text-red-400\/40{color:color-mix(in oklab,var(--color-red-400) 40%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab,red,red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400) 70%,transparent)}}.text-rose-300{color:var(--color-rose-300)}.text-rose-300\/85{color:#ffa2aed9}@supports (color:color-mix(in lab,red,red)){.text-rose-300\/85{color:color-mix(in oklab,var(--color-rose-300) 85%,transparent)}}.text-sky-300{color:var(--color-sky-300)}.text-violet-300{color:var(--color-violet-300)}.text-white{color:var(--color-white)}.text-white\/10{color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.text-white\/10{color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.text-white\/15{color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.text-white\/15{color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.text-white\/18{color:#ffffff2e}@supports (color:color-mix(in lab,red,red)){.text-white\/18{color:color-mix(in oklab,var(--color-white) 18%,transparent)}}.text-white\/20{color:#fff3}@supports (color:color-mix(in lab,red,red)){.text-white\/20{color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.text-white\/25{color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.text-white\/25{color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.text-white\/30{color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.text-white\/35{color:#ffffff59}@supports (color:color-mix(in lab,red,red)){.text-white\/35{color:color-mix(in oklab,var(--color-white) 35%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.text-white\/45{color:#ffffff73}@supports (color:color-mix(in lab,red,red)){.text-white\/45{color:color-mix(in oklab,var(--color-white) 45%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.text-white\/55{color:#ffffff8c}@supports (color:color-mix(in lab,red,red)){.text-white\/55{color:color-mix(in oklab,var(--color-white) 55%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white) 60%,transparent)}}.text-white\/65{color:#ffffffa6}@supports (color:color-mix(in lab,red,red)){.text-white\/65{color:color-mix(in oklab,var(--color-white) 65%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.text-white\/75{color:#ffffffbf}@supports (color:color-mix(in lab,red,red)){.text-white\/75{color:color-mix(in oklab,var(--color-white) 75%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.text-white\/85{color:#ffffffd9}@supports (color:color-mix(in lab,red,red)){.text-white\/85{color:color-mix(in oklab,var(--color-white) 85%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.text-white\/90{color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.text-white\/95{color:#fffffff2}@supports (color:color-mix(in lab,red,red)){.text-white\/95{color:color-mix(in oklab,var(--color-white) 95%,transparent)}}.text-yellow-300\/85{color:#ffe02ad9}@supports (color:color-mix(in lab,red,red)){.text-yellow-300\/85{color:color-mix(in oklab,var(--color-yellow-300) 85%,transparent)}}.text-yellow-400\/50{color:#fac80080}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/50{color:color-mix(in oklab,var(--color-yellow-400) 50%,transparent)}}.uppercase{text-transform:uppercase}.italic{font-style:italic}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.accent-white{accent-color:var(--color-white)}.accent-white\/50{accent-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.accent-white\/50{accent-color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-40{opacity:.4}.opacity-80{opacity:.8}.opacity-100{opacity:1}.\!shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgba\(255\,255\,255\,0\.05\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff0d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-black\/30{--tw-shadow-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.shadow-black\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/50{--tw-shadow-color:#00000080}@supports (color:color-mix(in lab,red,red)){.shadow-black\/50{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 50%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/60{--tw-shadow-color:#0009}@supports (color:color-mix(in lab,red,red)){.shadow-black\/60{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 60%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/70{--tw-shadow-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.shadow-black\/70{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 70%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-green-500\/30{--tw-ring-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.ring-green-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-green-500) 30%, transparent)}}.ring-red-500\/30{--tw-ring-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.ring-red-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-red-500) 30%, transparent)}}.ring-white\/20{--tw-ring-color:#fff3}@supports (color:color-mix(in lab,red,red)){.ring-white\/20{--tw-ring-color:color-mix(in oklab, var(--color-white) 20%, transparent)}}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[video\:\\]{video:}.group-focus-within\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media(hover:hover){.group-hover\:text-\[var\(--color-accent\)\]:is(:where(.group):hover *){color:var(--color-accent)}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/code\:opacity-100:is(:where(.group\/code):hover *){opacity:1}}.placeholder\:text-white\/8::placeholder{color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/8::placeholder{color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.placeholder\:text-white\/12::placeholder{color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/12::placeholder{color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.placeholder\:text-white\/15::placeholder{color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/15::placeholder{color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.placeholder\:text-white\/25::placeholder{color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/25::placeholder{color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.placeholder\:text-white\/30::placeholder{color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.placeholder\:text-white\/30::placeholder{color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.focus-within\:border-white\/\[0\.22\]:focus-within{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.focus-within\:border-white\/\[0\.22\]:focus-within{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.focus-within\:shadow-xl:focus-within{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-within\:shadow-black\/40:focus-within{--tw-shadow-color:#0006}@supports (color:color-mix(in lab,red,red)){.focus-within\:shadow-black\/40:focus-within{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 40%, transparent) var(--tw-shadow-alpha), transparent)}}@media(hover:hover){.hover\:border-white\/\[0\.1\]:hover{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.1\]:hover{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.hover\:border-white\/\[0\.2\]:hover{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.2\]:hover{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.hover\:border-white\/\[0\.12\]:hover{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.12\]:hover{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.hover\:border-white\/\[0\.14\]:hover{border-color:#ffffff24}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.14\]:hover{border-color:color-mix(in oklab,var(--color-white) 14%,transparent)}}.hover\:border-white\/\[0\.15\]:hover{border-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.15\]:hover{border-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.hover\:border-white\/\[0\.16\]:hover{border-color:#ffffff29}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.16\]:hover{border-color:color-mix(in oklab,var(--color-white) 16%,transparent)}}.hover\:border-white\/\[0\.18\]:hover{border-color:#ffffff2e}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.18\]:hover{border-color:color-mix(in oklab,var(--color-white) 18%,transparent)}}.hover\:border-white\/\[0\.22\]:hover{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.hover\:border-white\/\[0\.22\]:hover{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.hover\:bg-black:hover{background-color:var(--color-black)}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black) 80%,transparent)}}.hover\:bg-black\/85:hover{background-color:#000000d9}@supports (color:color-mix(in lab,red,red)){.hover\:bg-black\/85:hover{background-color:color-mix(in oklab,var(--color-black) 85%,transparent)}}.hover\:bg-green-500\/30:hover{background-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/30:hover{background-color:color-mix(in oklab,var(--color-green-500) 30%,transparent)}}.hover\:bg-white\/90:hover{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/90:hover{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.hover\:bg-white\/95:hover{background-color:#fffffff2}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/95:hover{background-color:color-mix(in oklab,var(--color-white) 95%,transparent)}}.hover\:bg-white\/\[0\.02\]:hover{background-color:#ffffff05}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.02\]:hover{background-color:color-mix(in oklab,var(--color-white) 2%,transparent)}}.hover\:bg-white\/\[0\.03\]:hover{background-color:#ffffff08}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.03\]:hover{background-color:color-mix(in oklab,var(--color-white) 3%,transparent)}}.hover\:bg-white\/\[0\.04\]:hover{background-color:#ffffff0a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.04\]:hover{background-color:color-mix(in oklab,var(--color-white) 4%,transparent)}}.hover\:bg-white\/\[0\.05\]:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.05\]:hover{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.hover\:bg-white\/\[0\.06\]:hover{background-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.06\]:hover{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.hover\:bg-white\/\[0\.14\]:hover{background-color:#ffffff24}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.14\]:hover{background-color:color-mix(in oklab,var(--color-white) 14%,transparent)}}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400\/60:hover{color:#ff656899}@supports (color:color-mix(in lab,red,red)){.hover\:text-red-400\/60:hover{color:color-mix(in oklab,var(--color-red-400) 60%,transparent)}}.hover\:text-rose-200:hover{color:var(--color-rose-200)}.hover\:text-rose-300:hover{color:var(--color-rose-300)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/35:hover{color:#ffffff59}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/35:hover{color:color-mix(in oklab,var(--color-white) 35%,transparent)}}.hover\:text-white\/40:hover{color:#fff6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/40:hover{color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.hover\:text-white\/45:hover{color:#ffffff73}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/45:hover{color:color-mix(in oklab,var(--color-white) 45%,transparent)}}.hover\:text-white\/50:hover{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/50:hover{color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.hover\:text-white\/55:hover{color:#ffffff8c}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/55:hover{color:color-mix(in oklab,var(--color-white) 55%,transparent)}}.hover\:text-white\/60:hover{color:#fff9}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/60:hover{color:color-mix(in oklab,var(--color-white) 60%,transparent)}}.hover\:text-white\/65:hover{color:#ffffffa6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/65:hover{color:color-mix(in oklab,var(--color-white) 65%,transparent)}}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.hover\:text-white\/85:hover{color:#ffffffd9}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/85:hover{color:color-mix(in oklab,var(--color-white) 85%,transparent)}}.hover\:text-white\/90:hover{color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.hover\:text-white\/90:hover{color:color-mix(in oklab,var(--color-white) 90%,transparent)}}}.focus\:border-white\/\[0\.1\]:focus{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.1\]:focus{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.focus\:border-white\/\[0\.2\]:focus{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.2\]:focus{border-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.focus\:border-white\/\[0\.12\]:focus{border-color:#ffffff1f}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.12\]:focus{border-color:color-mix(in oklab,var(--color-white) 12%,transparent)}}.focus\:border-white\/\[0\.22\]:focus{border-color:#ffffff38}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.22\]:focus{border-color:color-mix(in oklab,var(--color-white) 22%,transparent)}}.focus\:border-white\/\[0\.25\]:focus{border-color:#ffffff40}@supports (color:color-mix(in lab,red,red)){.focus\:border-white\/\[0\.25\]:focus{border-color:color-mix(in oklab,var(--color-white) 25%,transparent)}}.focus-visible\:opacity-100:focus-visible{opacity:1}.focus-visible\:outline:focus-visible,.focus-visible\:outline-1:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-\[var\(--color-accent\)\]:focus-visible{outline-color:var(--color-accent)}.focus-visible\:outline-white\/30:focus-visible{outline-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/30:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 30%,transparent)}}.focus-visible\:outline-white\/40:focus-visible{outline-color:#fff6}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/40:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.focus-visible\:outline-white\/50:focus-visible{outline-color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.focus-visible\:outline-white\/50:focus-visible{outline-color:color-mix(in oklab,var(--color-white) 50%,transparent)}}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.active\:scale-\[0\.99\]:active{scale:.99}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-60:disabled{opacity:.6}@media(min-width:40rem){.sm\:block{display:block}.sm\:inline{display:inline}.sm\:w-64{width:calc(var(--spacing) * 64)}.sm\:px-5{padding-inline:calc(var(--spacing) * 5)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}}@media(min-width:48rem){.md\:static{position:static}.md\:block{display:block}.md\:hidden{display:none}.md\:inline{display:inline}.md\:h-full{height:100%}.md\:max-h-none{max-height:none}.md\:w-64{width:calc(var(--spacing) * 64)}.md\:w-\[60px\]{width:60px}.md\:w-\[360px\]{width:360px}.md\:w-auto{width:auto}.md\:translate-x-0{--tw-translate-x:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.md\:flex-row{flex-direction:row}.md\:justify-center{justify-content:center}.md\:p-7{padding:calc(var(--spacing) * 7)}.md\:px-0{padding-inline:calc(var(--spacing) * 0)}.md\:px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.md\:px-3{padding-inline:calc(var(--spacing) * 3)}.md\:py-2{padding-block:calc(var(--spacing) * 2)}}@media(min-width:64rem){.lg\:w-\[400px\]{width:400px}}@media(min-width:80rem){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(min-width:96rem){.\32xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\[\&_button\]\:\!px-2 button{padding-inline:calc(var(--spacing) * 2)!important}.\[\&_button\]\:\!py-1 button{padding-block:calc(var(--spacing) * 1)!important}.\[\&_button\]\:\!text-\[13px\] button{font-size:13px!important}.\[\&\>button\]\:\!border-white\/\[0\.06\]>button{border-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\]\:\!border-white\/\[0\.06\]>button{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}.\[\&\>button\]\:\!bg-\[\#111\]>button{background-color:#111!important}.\[\&\>button\]\:\!text-white\/30>button{color:#ffffff4d!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\]\:\!text-white\/30>button{color:color-mix(in oklab,var(--color-white) 30%,transparent)!important}}.\[\&\>button\:hover\]\:\!bg-white\/\[0\.06\]>button:hover{background-color:#ffffff0f!important}@supports (color:color-mix(in lab,red,red)){.\[\&\>button\:hover\]\:\!bg-white\/\[0\.06\]>button:hover{background-color:color-mix(in oklab,var(--color-white) 6%,transparent)!important}}}body{background:var(--color-bg-base);color:var(--color-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-feature-settings:"ss01","cv11";margin:0}::selection{color:#fff;background:#6ee7d340}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:rgba(var(--fg),.1);background-clip:padding-box;border:2px solid #0000;border-radius:8px}::-webkit-scrollbar-thumb:hover{background:rgba(var(--fg),.2);background-clip:padding-box;border:2px solid #0000}*{scrollbar-width:thin;scrollbar-color:rgba(var(--fg),.1) transparent}@keyframes fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}@keyframes scale-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes pulse-dot{0%,to{opacity:.2}50%{opacity:.7}}@keyframes shimmer{0%{background-position:-1000px 0}to{background-position:1000px 0}}.animate-fade-in{animation:.18s cubic-bezier(.2,.8,.2,1) fade-in}.animate-scale-in{animation:.14s cubic-bezier(.2,.8,.2,1) scale-in}.animate-pulse-dot{animation:1.4s ease-in-out infinite pulse-dot}.skeleton{background:linear-gradient(90deg,rgba(var(--fg),.03),rgba(var(--fg),.07),rgba(var(--fg),.03));background-size:1000px 100%;animation:2s linear infinite shimmer}@media(prefers-reduced-motion:reduce){*,:before,:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}input[type=range]{appearance:none;background:rgba(var(--fg),.1);border-radius:999px;outline:none;height:3px;margin-top:6px}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;cursor:pointer;background:#fff;border:none;border-radius:50%;width:14px;height:14px;transition:box-shadow .12s ease-out,transform .12s ease-out;box-shadow:0 1px 4px #0006}input[type=range]::-webkit-slider-thumb:hover{transform:scale(1.1)}input[type=range]::-moz-range-thumb{cursor:pointer;background:#fff;border:none;border-radius:50%;width:14px;height:14px;transition:box-shadow .12s ease-out,transform .12s ease-out;box-shadow:0 1px 4px #0006}input[type=range]:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 4px var(--color-accent-soft),0 1px 4px #0006}input[type=range]:focus-visible::-moz-range-thumb{box-shadow:0 0 0 4px var(--color-accent-soft),0 1px 4px #0006}textarea{field-sizing:content}:focus-visible{outline:2px solid var(--color-accent);outline-offset:2px;border-radius:6px}button:focus,a:focus,textarea:focus,input:focus,select:focus{outline:none}@media(pointer:coarse){button,a,[role=button]{min-height:36px}}.prose-venice{word-break:break-word}.prose-venice>:first-child{margin-top:0!important}.prose-venice>:last-child{margin-bottom:0!important}.prose-venice p{margin:.6em 0;line-height:1.7}.prose-venice p:first-child{margin-top:0}.prose-venice p:last-child{margin-bottom:0}.prose-venice h1,.prose-venice h2,.prose-venice h3,.prose-venice h4{color:rgba(var(--fg),.95);letter-spacing:-.012em;margin:1.3em 0 .4em;font-weight:600;line-height:1.3}.prose-venice h1{font-size:1.25em}.prose-venice h2{font-size:1.12em}.prose-venice h3{font-size:1em}.prose-venice strong{color:rgba(var(--fg),.95);font-weight:600}.prose-venice em{color:rgba(var(--fg),.78)}.prose-venice code{font-family:var(--font-mono);background:rgba(var(--fg),.06);color:rgba(var(--fg),.88);border-radius:4px;padding:.13em .4em;font-size:.86em}.prose-venice pre{background:rgba(var(--fg),.025);border:1px solid rgba(var(--fg),.07);border-radius:8px;margin:.8em 0;padding:1.9em 1em 1em;overflow-x:auto}.prose-venice pre code{color:rgba(var(--fg),.82);tab-size:2;background:0 0;border-radius:0;padding:0;font-size:.85em;line-height:1.65}.prose-venice ul,.prose-venice ol{margin:.5em 0;padding-left:1.4em}.prose-venice ul{list-style-type:disc}.prose-venice ol{list-style-type:decimal}.prose-venice li{margin:.25em 0;line-height:1.65}.prose-venice li::marker{color:rgba(var(--fg),.35)}.prose-venice blockquote{border-left:3px solid var(--color-accent);color:rgba(var(--fg),.65);margin:.8em 0;padding-left:1em;font-style:italic}.prose-venice table{border-collapse:collapse;width:100%;margin:.8em 0;font-size:.9em}.prose-venice th,.prose-venice td{border:1px solid rgba(var(--fg),.08);text-align:left;padding:.5em .75em}.prose-venice th{background:rgba(var(--fg),.04);color:rgba(var(--fg),.75);text-transform:uppercase;letter-spacing:.04em;font-size:.85em;font-weight:600}.prose-venice a{color:var(--color-accent);text-underline-offset:2px;-webkit-text-decoration:underline #6ee7d366;text-decoration:underline #6ee7d366;transition:text-decoration-color .1s}.prose-venice a:hover{-webkit-text-decoration-color:var(--color-accent);text-decoration-color:var(--color-accent)}.prose-venice hr{border:none;border-top:1px solid rgba(var(--fg),.08);margin:1.2em 0}.prose-venice img{border-radius:8px;max-width:100%}:root{--fg:255, 255, 255;--font-sans:"Times New Roman", Times, "Liberation Serif", "Nimbus Roman", "DejaVu Serif", serif;--font-mono:"Courier New", Courier, "Liberation Mono", "Nimbus Mono PS", "DejaVu Sans Mono", monospace;--color-bg-base:#0d0d0d;--color-bg-raised:#141414;--color-bg-overlay:#1c1c1c;--color-bg-input:#111;--color-accent:#8cb4ff;--color-accent-soft:#8cb4ff29;color-scheme:dark}:root[data-theme=light]{--fg:0, 0, 0;--color-white:#000;--color-black:#fff;--color-bg-base:#fff;--color-bg-raised:#fff;--color-bg-overlay:#f2f2f2;--color-bg-input:#fff;--color-border-faint:#0000001a;--color-border-soft:#0000002e;--color-border-strong:#00000080;--color-text-primary:#000;--color-text-secondary:#000000b8;--color-text-tertiary:#0000008c;--color-text-quaternary:#0000006b;--color-accent:#00e;--color-accent-soft:#0000ee1a;color-scheme:light}@media(prefers-color-scheme:light){:root:not([data-theme=dark]){--fg:0, 0, 0;--color-white:#000;--color-black:#fff;--color-bg-base:#fff;--color-bg-raised:#fff;--color-bg-overlay:#f2f2f2;--color-bg-input:#fff;--color-border-faint:#0000001a;--color-border-soft:#0000002e;--color-border-strong:#00000080;--color-text-primary:#000;--color-text-secondary:#000000b8;--color-text-tertiary:#0000008c;--color-text-quaternary:#0000006b;--color-accent:#00e;--color-accent-soft:#0000ee1a;color-scheme:light}}html{color-scheme:normal}body{font-feature-settings:normal;font-size:17px}*,:before,:after{border-radius:0!important}.animate-spin{border-radius:9999px!important}label,kbd,code,pre,.font-mono,[class*=uppercase]{font-family:var(--font-mono)}.bg-\[\#080808\],.bg-\[\#0a0a0a\],.bg-\[\#0a0a0c\],.bg-\[\#0c0c10\]{background-color:var(--color-bg-base)!important}.bg-\[\#0d0d11\],.bg-\[\#0e0e0e\],.bg-\[\#0e0e12\],.bg-\[\#101015\],.bg-\[\#111114\],.bg-\[\#111\]{background-color:var(--color-bg-raised)!important}.border-\[\#111\]{border-color:var(--color-bg-raised)!important}:root[data-theme=light] .text-white\/10,:root[data-theme=light] .placeholder\:text-white\/10::placeholder,:root[data-theme=light] .text-white\/15,:root[data-theme=light] .placeholder\:text-white\/15::placeholder,:root[data-theme=light] .text-white\/20,:root[data-theme=light] .placeholder\:text-white\/20::placeholder,:root[data-theme=light] .text-white\/25,:root[data-theme=light] .placeholder\:text-white\/25::placeholder{color:#00000073!important}:root[data-theme=light] .text-white\/30,:root[data-theme=light] .placeholder\:text-white\/30::placeholder,:root[data-theme=light] .text-white\/35,:root[data-theme=light] .placeholder\:text-white\/35::placeholder{color:#0000008c!important}:root[data-theme=light] .text-white\/40,:root[data-theme=light] .placeholder\:text-white\/40::placeholder,:root[data-theme=light] .text-white\/45,:root[data-theme=light] .placeholder\:text-white\/45::placeholder{color:#0000009e!important}:root[data-theme=light] .text-white\/50,:root[data-theme=light] .placeholder\:text-white\/50::placeholder,:root[data-theme=light] .text-white\/55,:root[data-theme=light] .placeholder\:text-white\/55::placeholder{color:#000000ad!important}@media(prefers-color-scheme:light){:root:not([data-theme=dark]) .text-white\/10,:root:not([data-theme=dark]) .placeholder\:text-white\/10::placeholder,:root:not([data-theme=dark]) .text-white\/15,:root:not([data-theme=dark]) .placeholder\:text-white\/15::placeholder,:root:not([data-theme=dark]) .text-white\/20,:root:not([data-theme=dark]) .placeholder\:text-white\/20::placeholder,:root:not([data-theme=dark]) .text-white\/25,:root:not([data-theme=dark]) .placeholder\:text-white\/25::placeholder{color:#00000073!important}:root:not([data-theme=dark]) .text-white\/30,:root:not([data-theme=dark]) .placeholder\:text-white\/30::placeholder,:root:not([data-theme=dark]) .text-white\/35,:root:not([data-theme=dark]) .placeholder\:text-white\/35::placeholder{color:#0000008c!important}:root:not([data-theme=dark]) .text-white\/40,:root:not([data-theme=dark]) .placeholder\:text-white\/40::placeholder,:root:not([data-theme=dark]) .text-white\/45,:root:not([data-theme=dark]) .placeholder\:text-white\/45::placeholder{color:#0000009e!important}:root:not([data-theme=dark]) .text-white\/50,:root:not([data-theme=dark]) .placeholder\:text-white\/50::placeholder,:root:not([data-theme=dark]) .text-white\/55,:root:not([data-theme=dark]) .placeholder\:text-white\/55::placeholder{color:#000000ad!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/ventures/havre/open/assets/index-BK6OjN4-.js b/ventures/havre/open/assets/index-fmJ2VqHZ.js similarity index 99% rename from ventures/havre/open/assets/index-BK6OjN4-.js rename to ventures/havre/open/assets/index-fmJ2VqHZ.js index eb8cb1f..66bea32 100644 --- a/ventures/havre/open/assets/index-BK6OjN4-.js +++ b/ventures/havre/open/assets/index-fmJ2VqHZ.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workflows-view-CqSB6AnK.js","assets/workflow-engine-BHZwbSiT.js","assets/workflow-engine-BZV40eAE.css","assets/playground-view-BLUXm2C6.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/workflows-view-C9DNDVch.js","assets/workflow-engine-BuXGtBGn.js","assets/workflow-engine-BZV40eAE.css","assets/playground-view-B6WRI_IZ.js"])))=>i.map(i=>d[i]); (function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))u(s);new MutationObserver(s=>{for(const c of s)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&u(f)}).observe(document,{childList:!0,subtree:!0});function a(s){const c={};return s.integrity&&(c.integrity=s.integrity),s.referrerPolicy&&(c.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?c.credentials="include":s.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function u(s){if(s.ep)return;s.ep=!0;const c=a(s);fetch(s.href,c)}})();function lf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var sc={exports:{}},Ha={};var Tp;function N1(){if(Tp)return Ha;Tp=1;var n=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function a(u,s,c){var f=null;if(c!==void 0&&(f=""+c),s.key!==void 0&&(f=""+s.key),"key"in s){c={};for(var d in s)d!=="key"&&(c[d]=s[d])}else c=s;return s=c.ref,{$$typeof:n,type:u,key:f,ref:s!==void 0?s:null,props:c}}return Ha.Fragment=l,Ha.jsx=a,Ha.jsxs=a,Ha}var Ap;function O1(){return Ap||(Ap=1,sc.exports=N1()),sc.exports}var p=O1(),oc={exports:{}},we={};var _p;function z1(){if(_p)return we;_p=1;var n=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),f=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),b=Symbol.iterator;function w(_){return _===null||typeof _!="object"?null:(_=b&&_[b]||_["@@iterator"],typeof _=="function"?_:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,A={};function E(_,Y,C){this.props=_,this.context=Y,this.refs=A,this.updater=C||k}E.prototype.isReactComponent={},E.prototype.setState=function(_,Y){if(typeof _!="object"&&typeof _!="function"&&_!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,_,Y,"setState")},E.prototype.forceUpdate=function(_){this.updater.enqueueForceUpdate(this,_,"forceUpdate")};function O(){}O.prototype=E.prototype;function z(_,Y,C){this.props=_,this.context=Y,this.refs=A,this.updater=C||k}var X=z.prototype=new O;X.constructor=z,N(X,E.prototype),X.isPureReactComponent=!0;var V=Array.isArray;function R(){}var ee={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function ue(_,Y,C){var le=C.ref;return{$$typeof:n,type:_,key:Y,ref:le!==void 0?le:null,props:C}}function U(_,Y){return ue(_.type,Y,_.props)}function ne(_){return typeof _=="object"&&_!==null&&_.$$typeof===n}function ie(_){var Y={"=":"=0",":":"=2"};return"$"+_.replace(/[=:]/g,function(C){return Y[C]})}var me=/\/+/g;function re(_,Y){return typeof _=="object"&&_!==null&&_.key!=null?ie(""+_.key):Y.toString(36)}function $(_){switch(_.status){case"fulfilled":return _.value;case"rejected":throw _.reason;default:switch(typeof _.status=="string"?_.then(R,R):(_.status="pending",_.then(function(Y){_.status==="pending"&&(_.status="fulfilled",_.value=Y)},function(Y){_.status==="pending"&&(_.status="rejected",_.reason=Y)})),_.status){case"fulfilled":return _.value;case"rejected":throw _.reason}}throw _}function L(_,Y,C,le,de){var oe=typeof _;(oe==="undefined"||oe==="boolean")&&(_=null);var Se=!1;if(_===null)Se=!0;else switch(oe){case"bigint":case"string":case"number":Se=!0;break;case"object":switch(_.$$typeof){case n:case l:Se=!0;break;case x:return Se=_._init,L(Se(_._payload),Y,C,le,de)}}if(Se)return de=de(_),Se=le===""?"."+re(_,0):le,V(de)?(C="",Se!=null&&(C=Se.replace(me,"$&/")+"/"),L(de,Y,C,"",function($e){return $e})):de!=null&&(ne(de)&&(de=U(de,C+(de.key==null||_&&_.key===de.key?"":(""+de.key).replace(me,"$&/")+"/")+Se)),Y.push(de)),1;Se=0;var fe=le===""?".":le+":";if(V(_))for(var ve=0;ve<_.length;ve++)le=_[ve],oe=fe+re(le,ve),Se+=L(le,Y,C,oe,de);else if(ve=w(_),typeof ve=="function")for(_=ve.call(_),ve=0;!(le=_.next()).done;)le=le.value,oe=fe+re(le,ve++),Se+=L(le,Y,C,oe,de);else if(oe==="object"){if(typeof _.then=="function")return L($(_),Y,C,le,de);throw Y=String(_),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(_).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return Se}function P(_,Y,C){if(_==null)return _;var le=[],de=0;return L(_,le,"","",function(oe){return Y.call(C,oe,de++)}),le}function F(_){if(_._status===-1){var Y=_._result;Y=Y(),Y.then(function(C){(_._status===0||_._status===-1)&&(_._status=1,_._result=C)},function(C){(_._status===0||_._status===-1)&&(_._status=2,_._result=C)}),_._status===-1&&(_._status=0,_._result=Y)}if(_._status===1)return _._result.default;throw _._result}var he=typeof reportError=="function"?reportError:function(_){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof _=="object"&&_!==null&&typeof _.message=="string"?String(_.message):String(_),error:_});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",_);return}console.error(_)},j={map:P,forEach:function(_,Y,C){P(_,function(){Y.apply(this,arguments)},C)},count:function(_){var Y=0;return P(_,function(){Y++}),Y},toArray:function(_){return P(_,function(Y){return Y})||[]},only:function(_){if(!ne(_))throw Error("React.Children.only expected to receive a single React element child.");return _}};return we.Activity=y,we.Children=j,we.Component=E,we.Fragment=a,we.Profiler=s,we.PureComponent=z,we.StrictMode=u,we.Suspense=g,we.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ee,we.__COMPILER_RUNTIME={__proto__:null,c:function(_){return ee.H.useMemoCache(_)}},we.cache=function(_){return function(){return _.apply(null,arguments)}},we.cacheSignal=function(){return null},we.cloneElement=function(_,Y,C){if(_==null)throw Error("The argument must be a React element, but you passed "+_+".");var le=N({},_.props),de=_.key;if(Y!=null)for(oe in Y.key!==void 0&&(de=""+Y.key),Y)!W.call(Y,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&Y.ref===void 0||(le[oe]=Y[oe]);var oe=arguments.length-2;if(oe===1)le.children=C;else if(1>>1,j=L[he];if(0>>1;he<_;){var Y=2*(he+1)-1,C=L[Y],le=Y+1,de=L[le];if(0>s(C,F))les(de,C)?(L[he]=de,L[le]=F,he=le):(L[he]=C,L[Y]=F,he=Y);else if(les(de,F))L[he]=de,L[le]=F,he=le;else break e}}return P}function s(L,P){var F=L.sortIndex-P.sortIndex;return F!==0?F:L.id-P.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;n.unstable_now=function(){return c.now()}}else{var f=Date,d=f.now();n.unstable_now=function(){return f.now()-d}}var g=[],m=[],x=1,y=null,b=3,w=!1,k=!1,N=!1,A=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;function X(L){for(var P=a(m);P!==null;){if(P.callback===null)u(m);else if(P.startTime<=L)u(m),P.sortIndex=P.expirationTime,l(g,P);else break;P=a(m)}}function V(L){if(N=!1,X(L),!k)if(a(g)!==null)k=!0,R||(R=!0,ie());else{var P=a(m);P!==null&&$(V,P.startTime-L)}}var R=!1,ee=-1,W=5,ue=-1;function U(){return A?!0:!(n.unstable_now()-ueL&&U());){var he=y.callback;if(typeof he=="function"){y.callback=null,b=y.priorityLevel;var j=he(y.expirationTime<=L);if(L=n.unstable_now(),typeof j=="function"){y.callback=j,X(L),P=!0;break t}y===a(g)&&u(g),X(L)}else u(g);y=a(g)}if(y!==null)P=!0;else{var _=a(m);_!==null&&$(V,_.startTime-L),P=!1}}break e}finally{y=null,b=F,w=!1}P=void 0}}finally{P?ie():R=!1}}}var ie;if(typeof z=="function")ie=function(){z(ne)};else if(typeof MessageChannel<"u"){var me=new MessageChannel,re=me.port2;me.port1.onmessage=ne,ie=function(){re.postMessage(null)}}else ie=function(){E(ne,0)};function $(L,P){ee=E(function(){L(n.unstable_now())},P)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(L){L.callback=null},n.unstable_forceFrameRate=function(L){0>L||125he?(L.sortIndex=F,l(m,L),a(g)===null&&L===a(m)&&(N?(O(ee),ee=-1):N=!0,$(V,F-he))):(L.sortIndex=j,l(g,L),k||w||(k=!0,R||(R=!0,ie()))),L},n.unstable_shouldYield=U,n.unstable_wrapCallback=function(L){var P=b;return function(){var F=b;b=P;try{return L.apply(this,arguments)}finally{b=F}}}})(hc)),hc}var Op;function R1(){return Op||(Op=1,fc.exports=D1()),fc.exports}var dc={exports:{}},vt={};var zp;function L1(){if(zp)return vt;zp=1;var n=af();function l(g){var m="https://react.dev/errors/"+g;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(l){console.error(l)}}return n(),dc.exports=L1(),dc.exports}var Rp;function B1(){if(Rp)return qa;Rp=1;var n=R1(),l=af(),a=U1();function u(e){var t="https://react.dev/errors/"+e;if(1j||(e.current=he[j],he[j]=null,j--)}function C(e,t){j++,he[j]=e.current,e.current=t}var le=_(null),de=_(null),oe=_(null),Se=_(null);function fe(e,t){switch(C(oe,t),C(de,e),C(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jm(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jm(t),e=Pm(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(le),C(le,e)}function ve(){Y(le),Y(de),Y(oe)}function $e(e){e.memoizedState!==null&&C(Se,e);var t=le.current,i=Pm(t,e.type);t!==i&&(C(de,e),C(le,i))}function Bt(e){de.current===e&&(Y(le),Y(de)),Se.current===e&&(Y(Se),Ra._currentValue=F)}var Ht,Tt;function cn(e){if(Ht===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Ht=t&&t[1]||"",Tt=-1)":-10&&!a&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const gE={tokenize:CE,partial:!0};function yE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:wE,continuation:{tokenize:SE},exit:kE}},text:{91:{name:"gfmFootnoteCall",tokenize:bE},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:xE,resolveTo:vE}}}}function xE(n,l,a){const u=this;let s=u.events.length;const c=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let f;for(;s--;){const g=u.events[s][1];if(g.type==="labelImage"){f=g;break}if(g.type==="gfmFootnoteCall"||g.type==="labelLink"||g.type==="label"||g.type==="image"||g.type==="link")break}return d;function d(g){if(!f||!f._balanced)return a(g);const m=pn(u.sliceSerialize({start:f.end,end:u.now()}));return m.codePointAt(0)!==94||!c.includes(m.slice(1))?a(g):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),l(g))}}function vE(n,l){let a=n.length;for(;a--;)if(n[a][1].type==="labelImage"&&n[a][0]==="enter"){n[a][1];break}n[a+1][1].type="data",n[a+3][1].type="gfmFootnoteCallLabelMarker";const u={type:"gfmFootnoteCall",start:Object.assign({},n[a+3][1].start),end:Object.assign({},n[n.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},n[a+3][1].end),end:Object.assign({},n[a+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},n[n.length-1][1].start)},f={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},d=[n[a+1],n[a+2],["enter",u,l],n[a+3],n[a+4],["enter",s,l],["exit",s,l],["enter",c,l],["enter",f,l],["exit",f,l],["exit",c,l],n[n.length-2],n[n.length-1],["exit",u,l]];return n.splice(a,n.length-a+1,...d),n}function bE(n,l,a){const u=this,s=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let c=0,f;return d;function d(y){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(y),n.exit("gfmFootnoteCallLabelMarker"),g}function g(y){return y!==94?a(y):(n.enter("gfmFootnoteCallMarker"),n.consume(y),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",m)}function m(y){if(c>999||y===93&&!f||y===null||y===91||Xe(y))return a(y);if(y===93){n.exit("chunkString");const b=n.exit("gfmFootnoteCallString");return s.includes(pn(u.sliceSerialize(b)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(y),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),l):a(y)}return Xe(y)||(f=!0),c++,n.consume(y),y===92?x:m}function x(y){return y===91||y===92||y===93?(n.consume(y),c++,m):m(y)}}function wE(n,l,a){const u=this,s=u.parser.gfmFootnotes||(u.parser.gfmFootnotes=[]);let c,f=0,d;return g;function g(k){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(k){return k===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",x):a(k)}function x(k){if(f>999||k===93&&!d||k===null||k===91||Xe(k))return a(k);if(k===93){n.exit("chunkString");const N=n.exit("gfmFootnoteDefinitionLabelString");return c=pn(u.sliceSerialize(N)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),b}return Xe(k)||(d=!0),f++,n.consume(k),k===92?y:x}function y(k){return k===91||k===92||k===93?(n.consume(k),f++,x):x(k)}function b(k){return k===58?(n.enter("definitionMarker"),n.consume(k),n.exit("definitionMarker"),s.includes(c)||s.push(c),Re(n,w,"gfmFootnoteDefinitionWhitespace")):a(k)}function w(k){return l(k)}}function SE(n,l,a){return n.check(Wa,l,n.attempt(gE,l,a))}function kE(n){n.exit("gfmFootnoteDefinition")}function CE(n,l,a){const u=this;return Re(n,s,"gfmFootnoteDefinitionIndent",5);function s(c){const f=u.events[u.events.length-1];return f&&f[1].type==="gfmFootnoteDefinitionIndent"&&f[2].sliceSerialize(f[1],!0).length===4?l(c):a(c)}}function EE(n){let a=(n||{}).singleTilde;const u={name:"strikethrough",tokenize:c,resolveAll:s};return a==null&&(a=!0),{text:{126:u},insideSpan:{null:[u]},attentionMarkers:{null:[126]}};function s(f,d){let g=-1;for(;++g1?g(k):(f.consume(k),y++,w);if(y<2&&!a)return g(k);const A=f.exit("strikethroughSequenceTemporary"),E=Gl(k);return A._open=!E||E===2&&!!N,A._close=!N||N===2&&!!E,d(k)}}}class jE{constructor(){this.map=[]}add(l,a,u){TE(this,l,a,u)}consume(l){if(this.map.sort(function(c,f){return c[0]-f[0]}),this.map.length===0)return;let a=this.map.length;const u=[];for(;a>0;)a-=1,u.push(l.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),l.length=this.map[a][0];u.push(l.slice()),l.length=0;let s=u.pop();for(;s;){for(const c of s)l.push(c);s=u.pop()}this.map.length=0}}function TE(n,l,a,u){let s=0;if(!(a===0&&u.length===0)){for(;s-1;){const re=u.events[ne][1].type;if(re==="lineEnding"||re==="linePrefix")ne--;else break}const ie=ne>-1?u.events[ne][1].type:null,me=ie==="tableHead"||ie==="tableRow"?R:g;return me===R&&u.parser.lazy[u.now().line]?a(U):me(U)}function g(U){return n.enter("tableHead"),n.enter("tableRow"),m(U)}function m(U){return U===124||(f=!0,c+=1),x(U)}function x(U){return U===null?a(U):ge(U)?c>1?(c=0,u.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(U),n.exit("lineEnding"),w):a(U):Ne(U)?Re(n,x,"whitespace")(U):(c+=1,f&&(f=!1,s+=1),U===124?(n.enter("tableCellDivider"),n.consume(U),n.exit("tableCellDivider"),f=!0,x):(n.enter("data"),y(U)))}function y(U){return U===null||U===124||Xe(U)?(n.exit("data"),x(U)):(n.consume(U),U===92?b:y)}function b(U){return U===92||U===124?(n.consume(U),y):y(U)}function w(U){return u.interrupt=!1,u.parser.lazy[u.now().line]?a(U):(n.enter("tableDelimiterRow"),f=!1,Ne(U)?Re(n,k,"linePrefix",u.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):k(U))}function k(U){return U===45||U===58?A(U):U===124?(f=!0,n.enter("tableCellDivider"),n.consume(U),n.exit("tableCellDivider"),N):V(U)}function N(U){return Ne(U)?Re(n,A,"whitespace")(U):A(U)}function A(U){return U===58?(c+=1,f=!0,n.enter("tableDelimiterMarker"),n.consume(U),n.exit("tableDelimiterMarker"),E):U===45?(c+=1,E(U)):U===null||ge(U)?X(U):V(U)}function E(U){return U===45?(n.enter("tableDelimiterFiller"),O(U)):V(U)}function O(U){return U===45?(n.consume(U),O):U===58?(f=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(U),n.exit("tableDelimiterMarker"),z):(n.exit("tableDelimiterFiller"),z(U))}function z(U){return Ne(U)?Re(n,X,"whitespace")(U):X(U)}function X(U){return U===124?k(U):U===null||ge(U)?!f||s!==c?V(U):(n.exit("tableDelimiterRow"),n.exit("tableHead"),l(U)):V(U)}function V(U){return a(U)}function R(U){return n.enter("tableRow"),ee(U)}function ee(U){return U===124?(n.enter("tableCellDivider"),n.consume(U),n.exit("tableCellDivider"),ee):U===null||ge(U)?(n.exit("tableRow"),l(U)):Ne(U)?Re(n,ee,"whitespace")(U):(n.enter("data"),W(U))}function W(U){return U===null||U===124||Xe(U)?(n.exit("data"),ee(U)):(n.consume(U),U===92?ue:W)}function ue(U){return U===92||U===124?(n.consume(U),W):W(U)}}function NE(n,l){let a=-1,u=!0,s=0,c=[0,0,0,0],f=[0,0,0,0],d=!1,g=0,m,x,y;const b=new jE;for(;++aa[2]+1){const k=a[2]+1,N=a[3]-a[2]-1;n.add(k,N,[])}}n.add(a[3]+1,0,[["exit",y,l]])}return s!==void 0&&(c.end=Object.assign({},ql(l.events,s)),n.add(s,0,[["exit",c,l]]),c=void 0),c}function Qg(n,l,a,u,s){const c=[],f=ql(l.events,a);s&&(s.end=Object.assign({},f),c.push(["exit",s,l])),u.end=Object.assign({},f),c.push(["exit",u,l]),n.add(a+1,0,c)}function ql(n,l){const a=n[l],u=a[0]==="enter"?"start":"end";return a[1][u]}const OE={name:"tasklistCheck",tokenize:DE};function zE(){return{text:{91:OE}}}function DE(n,l,a){const u=this;return s;function s(g){return u.previous!==null||!u._gfmTasklistFirstContentOfListItem?a(g):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(g),n.exit("taskListCheckMarker"),c)}function c(g){return Xe(g)?(n.enter("taskListCheckValueUnchecked"),n.consume(g),n.exit("taskListCheckValueUnchecked"),f):g===88||g===120?(n.enter("taskListCheckValueChecked"),n.consume(g),n.exit("taskListCheckValueChecked"),f):a(g)}function f(g){return g===93?(n.enter("taskListCheckMarker"),n.consume(g),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),d):a(g)}function d(g){return ge(g)?l(g):Ne(g)?n.check({tokenize:RE},l,a)(g):a(g)}}function RE(n,l,a){return Re(n,u,"whitespace");function u(s){return s===null?a(s):l(s)}}function LE(n){return Cy([uE(),yE(),EE(n),_E(),zE()])}const UE={};function BE(n){const l=this,a=n||UE,u=l.data(),s=u.micromarkExtensions||(u.micromarkExtensions=[]),c=u.fromMarkdownExtensions||(u.fromMarkdownExtensions=[]),f=u.toMarkdownExtensions||(u.toMarkdownExtensions=[]);s.push(LE(a)),c.push(iE()),f.push(lE(a))}const HE=/^(https?:|mailto:|#|\/|\.)/i;function qE(n,l){if(!n)return"";const a=Yy(n);return a&&(l==="src"&&a.startsWith("data:image/")||HE.test(a))?a:""}function QE({children:n,className:l,...a}){const u=/language-(\w+)/.exec(l||""),s=u?u[1]:"",c=String(n).replace(/\n$/,""),[f,d]=q.useState(!1);return!l&&!String(n).includes(` `)?p.jsx("code",{className:l,...a,children:n}):p.jsxs("div",{className:"relative group/code",children:[s&&p.jsx("div",{className:"absolute top-0 left-0 px-3 py-1.5 text-[13px] text-white/15 font-mono uppercase tracking-wider select-none",children:s}),p.jsx("button",{onClick:()=>{navigator.clipboard.writeText(c),d(!0),setTimeout(()=>d(!1),1500)},className:"absolute top-1.5 right-1.5 px-2 py-1 text-[13px] font-medium text-white/15 hover:text-white/40 bg-white/[0.03] hover:bg-white/[0.06] rounded-md transition-all opacity-0 group-hover/code:opacity-100",children:f?"Copied":"Copy"}),p.jsx("code",{className:l,...a,children:n})]})}function VE(n){if(typeof n=="string")return{text:n,images:[]};let l="";const a=[];for(const u of n)u.type==="text"&&u.text&&(l+=u.text),u.type==="image_url"&&u.image_url?.url&&a.push(u.image_url.url);return{text:l,images:a}}function GE({message:n,onCopy:l,onDelete:a,onRegenerate:u}){const[s,c]=q.useState(!1),[f,d]=q.useState(!1),[g,m]=q.useState(!1),x=n.role==="user",{text:y,images:b}=VE(n.content),w=()=>{navigator.clipboard.writeText(y),d(!0),l(),setTimeout(()=>d(!1),1500)},k=p.jsxs("div",{className:`flex items-center gap-0.5 h-6 transition-opacity duration-150 ${s?"opacity-100":"opacity-0"}`,children:[p.jsx(zc,{label:f?"Copied":"Copy",onClick:w,children:f?p.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M20 6L9 17l-5-5"})}):p.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),p.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),!x&&u&&p.jsx(zc,{label:"Regenerate",onClick:u,children:p.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M1 4v6h6"}),p.jsx("path",{d:"M3.51 15a9 9 0 102.13-9.36L1 10"})]})}),p.jsx(zc,{label:"Delete",onClick:a,children:p.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})})})]});return x?p.jsx("div",{className:"flex justify-end",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:p.jsxs("div",{className:"flex items-end gap-1.5 max-w-[78%]",children:[k,p.jsxs("div",{className:"bg-white/[0.07] border border-white/[0.05] rounded-2xl rounded-br-md px-4 py-2.5 shadow-sm",children:[b.length>0&&p.jsx("div",{className:"flex gap-1.5 mb-2",children:b.map((N,A)=>p.jsx("img",{src:N,alt:`Attachment ${A+1}`,className:"h-24 rounded-lg border border-white/[0.06]"},A))}),p.jsx("div",{className:"text-white/95 text-[15.5px] leading-relaxed whitespace-pre-wrap break-words",children:y})]})]})}):p.jsxs("div",{className:"flex gap-3",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[p.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-white/95 to-white/75 flex items-center justify-center shrink-0 mt-0.5 shadow-sm",children:p.jsx("svg",{viewBox:"0 0 32 32",width:"14",height:"14",fill:"none",children:p.jsxs("g",{fill:"#0a0a0c",children:[p.jsx("rect",{x:"6.2",y:"7.5",width:"1.6",height:"18",rx:"0.8",transform:"rotate(-42 6.2 7.5)"}),p.jsx("rect",{x:"24.2",y:"6.3",width:"1.6",height:"18",rx:"0.8",transform:"rotate(42 24.2 6.3)"}),p.jsx("polygon",{points:"7.2,8.8 3.8,7.2 4.5,5.5 8.5,7.2"}),p.jsx("polygon",{points:"24.8,8.8 28.2,7.2 27.5,5.5 23.5,7.2"}),p.jsx("rect",{x:"14.3",y:"14.3",width:"3.4",height:"3.4",rx:"0.4",transform:"rotate(45 16 16)"}),p.jsx("circle",{cx:"9.2",cy:"24.5",r:"4"}),p.jsx("circle",{cx:"9.2",cy:"24.5",r:"1.7",fill:"#fff"}),p.jsx("circle",{cx:"22.8",cy:"24.5",r:"4"}),p.jsx("circle",{cx:"22.8",cy:"24.5",r:"1.7",fill:"#fff"}),p.jsx("path",{d:"M16 5.5L12.5 8.5V12.5L16 10.5L19.5 12.5V8.5Z"})]})})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[n.reasoning_content&&p.jsxs("div",{className:"mb-2",children:[p.jsxs("button",{onClick:()=>m(!g),className:"flex items-center gap-1.5 text-[14px] text-white/20 hover:text-white/35 transition-colors mb-1",children:[p.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:Te("transition-transform duration-150",g&&"rotate-90"),children:p.jsx("path",{d:"M3.5 2L6.5 5L3.5 8"})}),"Thinking"]}),g&&p.jsx("div",{className:"bg-white/[0.02] border border-white/[0.04] rounded-lg px-3 py-2 text-[15px] text-white/30 leading-relaxed whitespace-pre-wrap animate-fade-in max-h-60 overflow-y-auto",children:n.reasoning_content})]}),y?p.jsx("div",{className:"prose-venice text-[15.5px] leading-relaxed text-white/85",children:p.jsx(jk,{remarkPlugins:[BE],urlTransform:qE,components:{code:QE,a:({href:N,children:A,...E})=>p.jsx("a",{...E,href:N,target:"_blank",rel:"noopener noreferrer ugc",children:A})},children:y})}):p.jsxs("span",{className:"inline-flex gap-1.5 py-1.5",children:[p.jsx("span",{className:"w-1 h-1 rounded-full bg-white/25 animate-pulse-dot"}),p.jsx("span",{className:"w-1 h-1 rounded-full bg-white/25 animate-pulse-dot",style:{animationDelay:"0.2s"}}),p.jsx("span",{className:"w-1 h-1 rounded-full bg-white/25 animate-pulse-dot",style:{animationDelay:"0.4s"}})]}),p.jsx("div",{className:"mt-0.5",children:k})]})]})}function zc({label:n,onClick:l,children:a}){return p.jsx("button",{onClick:l,title:n,className:"p-1 text-white/15 hover:text-white/40 transition-colors rounded-md hover:bg-white/[0.04]",children:a})}function FE({onSend:n,onStop:l,isStreaming:a,disabled:u}){const[s,c]=q.useState(""),[f,d]=q.useState([]),[g,m]=q.useState(!1),x=q.useRef(null),y=q.useRef(null);q.useEffect(()=>{x.current?.focus()},[]);const b=()=>{const k=s.trim();!k||u||(n(k,f.length>0?f:void 0),c(""),d([]),x.current&&(x.current.style.height="auto"))},w=k=>{k&&Array.from(k).forEach(N=>{const A=new FileReader;A.onload=()=>d(E=>[...E,A.result]),A.readAsDataURL(N)})};return p.jsx("div",{className:"px-4 sm:px-6 pb-5 pt-2",children:p.jsxs("div",{className:"w-full max-w-[860px] mx-auto",children:[f.length>0&&p.jsx("div",{className:"flex gap-2 mb-2 overflow-x-auto pb-1",children:f.map((k,N)=>p.jsxs("div",{className:"relative group shrink-0",children:[p.jsx("img",{src:k,alt:`Attachment ${N+1}`,className:"h-16 w-16 object-cover rounded-lg border border-white/[0.08]"}),p.jsx("button",{onClick:()=>d(A=>A.filter((E,O)=>O!==N)),"aria-label":`Remove attachment ${N+1}`,className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-black/85 hover:bg-black border border-white/15 rounded-full flex items-center justify-center text-white/70 hover:text-white transition-colors focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/50",children:p.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},N))}),p.jsxs("div",{className:Te("relative bg-[#0e0e12] border rounded-2xl overflow-hidden transition-all shadow-lg shadow-black/30","focus-within:border-white/[0.22] focus-within:shadow-xl focus-within:shadow-black/40",g?"border-[var(--color-accent)] bg-[var(--color-accent-soft)]":"border-white/[0.08]"),onDragOver:k=>{k.preventDefault(),k.stopPropagation(),m(!0)},onDragLeave:k=>{k.preventDefault(),k.stopPropagation(),m(!1)},onDrop:k=>{k.preventDefault(),k.stopPropagation(),m(!1),w(k.dataTransfer.files)},children:[p.jsx("textarea",{ref:x,value:s,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),b())},onPaste:k=>{const N=k.clipboardData?.items;if(N){for(const A of N)if(A.type.startsWith("image/")){const E=A.getAsFile();if(E){const O=new FileReader;O.onload=()=>d(z=>[...z,O.result]),O.readAsDataURL(E)}}}},placeholder:u?"Connect an API key to start…":g?"Drop image to attach":"Ask anything — Enter to send, Shift+Enter for newline",rows:1,"aria-label":"Message input",className:"w-full bg-transparent px-5 pt-4 pb-1 text-[16px] text-white outline-none resize-none max-h-48 placeholder:text-white/30 leading-relaxed",disabled:u}),p.jsxs("div",{className:"flex items-center justify-between px-3 pb-2.5",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("input",{ref:y,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:k=>w(k.target.files)}),p.jsx("button",{onClick:()=>y.current?.click(),disabled:u,"aria-label":"Attach image",className:"flex items-center gap-1.5 px-2 py-1.5 text-white/50 hover:text-white text-[13px] transition-colors rounded-lg hover:bg-white/[0.05] disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)]",title:"Attach image (or drag/paste)",children:p.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})})})]}),a?p.jsxs("button",{onClick:l,"aria-label":"Stop generating",className:"flex items-center gap-1.5 px-3 py-1.5 text-[13px] font-medium text-white/85 bg-white/[0.08] hover:bg-white/[0.14] border border-white/[0.12] rounded-lg transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)]",children:[p.jsx("svg",{width:"9",height:"9",viewBox:"0 0 8 8",fill:"currentColor",children:p.jsx("rect",{width:"8",height:"8",rx:"1"})}),"Stop"]}):p.jsx("button",{onClick:b,disabled:!s.trim()||u,"aria-label":"Send message",className:Te("w-10 h-10 flex items-center justify-center rounded-xl transition-all duration-150 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)] focus-visible:outline-offset-2",s.trim()&&!u?"bg-white text-black hover:bg-white/95 active:scale-95 shadow-sm":"bg-white/[0.06] text-white/25"),children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]})]})]})})}function Vg(){const{veniceParams:n,setVeniceParams:l,systemPrompt:a,setSystemPrompt:u,temperature:s,setTemperature:c,topP:f,setTopP:d,maxTokens:g,setMaxTokens:m}=xt(),[x,y]=q.useState(!1);return p.jsxs("div",{className:"px-4 py-1.5",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx(YE,{value:n.enable_web_search||"off",onChange:b=>l({enable_web_search:b})}),p.jsx(Gg,{label:"Citations",active:n.enable_web_citations===!0,onClick:()=>l({enable_web_citations:!n.enable_web_citations})}),p.jsx(Gg,{label:"Search in stream",active:n.include_search_results_in_stream===!0,onClick:()=>l({include_search_results_in_stream:!n.include_search_results_in_stream})}),p.jsx("div",{className:"ml-auto",children:p.jsxs("button",{onClick:()=>y(!x),className:Te("flex items-center gap-1 text-[13px] font-medium px-2 py-[2px] rounded-full transition-colors duration-100",x?"bg-white/90 text-black":"bg-white/[0.03] text-white/18 hover:text-white/35 hover:bg-white/[0.05]"),children:[p.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"3"}),p.jsx("path",{d:"M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 112.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9c.26.604.852.997 1.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"})]}),"Settings"]})})]}),x&&p.jsxs("div",{className:"mt-2.5 pb-1 flex flex-col gap-2.5",children:[p.jsxs("div",{children:[p.jsx("label",{className:"text-[13px] text-white/15 font-medium mb-1 block uppercase tracking-[0.08em]",children:"System Prompt"}),p.jsx("textarea",{value:a,onChange:b=>u(b.target.value),placeholder:"You are a helpful assistant...",rows:2,className:"w-full bg-white/[0.02] border border-white/[0.05] rounded-lg px-3 py-2 text-[15px] text-white/50 outline-none resize-none placeholder:text-white/8 focus:border-white/[0.1] transition-colors"})]}),p.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[p.jsx(Dc,{label:"Temperature",value:s,onChange:c,min:0,max:2,step:.1}),p.jsx(Dc,{label:"Top P",value:f,onChange:d,min:0,max:1,step:.05}),p.jsx(Dc,{label:"Max Tokens",value:g,onChange:m,min:256,max:32768,step:256,format:b=>b>=1e3?`${(b/1e3).toFixed(b%1e3===0?0:1)}k`:String(b)})]}),p.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[p.jsx(Lc,{label:"Venice system prompt",active:n.include_venice_system_prompt!==!1,onChange:b=>l({include_venice_system_prompt:b})}),p.jsx(Lc,{label:"Disable thinking",active:n.disable_thinking===!0,onChange:b=>l({disable_thinking:b})}),p.jsx(Lc,{label:"Strip thinking",active:n.strip_thinking_response===!0,onChange:b=>l({strip_thinking_response:b})})]})]})]})}function Dc({label:n,value:l,onChange:a,min:u,max:s,step:c,format:f}){const d=f?f(l):String(l);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[p.jsx("label",{className:"text-[12px] text-white/15 font-medium uppercase tracking-[0.08em]",children:n}),p.jsx("span",{className:"text-[12px] text-white/25 font-mono",children:d})]}),p.jsx("input",{type:"range",min:u,max:s,step:c,value:l,onChange:g=>a(Number(g.target.value)),className:"w-full"})]})}function Gg({label:n,active:l,onClick:a}){return p.jsx("button",{onClick:a,className:Te("text-[13px] font-medium px-2 py-[2px] rounded-full transition-colors duration-100",l?"bg-white/90 text-black":"bg-white/[0.03] text-white/18 hover:text-white/35 hover:bg-white/[0.05]"),children:n})}const Rc=["off","on","auto"];function YE({value:n,onChange:l}){const a=Rc.indexOf(n),u=()=>l(Rc[(a+1)%Rc.length]),s=`Search: ${n}`,c=n!=="off";return p.jsx("button",{onClick:u,className:Te("text-[13px] font-medium px-2 py-[2px] rounded-full transition-colors duration-100",c?"bg-white/90 text-black":"bg-white/[0.03] text-white/18 hover:text-white/35 hover:bg-white/[0.05]"),children:s})}function Lc({label:n,active:l,onChange:a}){return p.jsxs("button",{onClick:()=>a(!l),className:"flex items-center gap-2 text-[14px] text-white/30 hover:text-white/50 transition-colors",children:[p.jsx("div",{className:Te("w-6 h-3.5 rounded-full transition-colors duration-150 relative",l?"bg-white/80":"bg-white/[0.08]"),children:p.jsx("div",{className:Te("absolute top-0.5 w-2.5 h-2.5 rounded-full transition-all duration-150",l?"left-3 bg-black":"left-0.5 bg-white/30")})}),n]})}const IE=["Explain how RSA encryption works using a metaphor a 10-year-old could grasp.","Draft a polite but firm email asking my landlord to fix the heating.","Compare REST and GraphQL — when does each shine?","Brainstorm five novel side-project ideas using LLMs and a Raspberry Pi."];function XE(){const n=xt(E=>E.deleteMessage),l=xt(E=>E.temporaryMode),a=xt(E=>E.setTemporaryMode),u=xt(E=>{const O=E.activeConversationId;return O?E.conversations.find(z=>z.id===O):void 0}),s=gn(E=>E.apiKey),c=on(E=>E.selectedModels.chat),{data:f}=Si("text"),d=c||f?.[0]?.id||"llama-3.3-70b",{send:g,stop:m,regenerate:x,isStreaming:y}=pb(),b=q.useRef(null),w=u?.messages.length??0,k=u?.messages[w-1]?.content,N=typeof k=="string"?k.length:0,A=`${w}-${Math.floor(N/200)}`;return q.useEffect(()=>{b.current?.scrollIntoView({behavior:"smooth",block:"end"})},[A]),p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-1.5 border-b border-white/[0.04]",children:[l&&p.jsx("span",{className:"text-[12px] text-white/45 mr-auto",children:"Temporary chat: not saved to history, gone when you leave or turn it off."}),p.jsxs("button",{type:"button",onClick:()=>a(!l),"aria-pressed":l,title:l?"Turn off temporary chat":"Start a temporary chat that is not saved",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] border transition-colors "+(l?"border-[var(--color-accent)] text-[var(--color-accent)]":"border-white/[0.10] text-white/55 hover:text-white/85"),children:[p.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"9",strokeDasharray:"3 3"}),p.jsx("path",{d:"M12 7v5l3 2"})]}),"Temporary chat"]})]}),p.jsx("div",{className:"flex-1 overflow-y-auto",children:!u||u.messages.length===0?p.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-6 gap-6",children:[p.jsxs("div",{className:"flex flex-col items-center gap-3",children:[p.jsx(hf,{size:32,className:"opacity-80"}),p.jsx("div",{className:"text-[20px] font-semibold text-white/85",children:"How can I help today?"}),p.jsx("p",{className:"text-[14px] text-white/45 max-w-sm",children:s?"Pick a model in the header above, then start a conversation. Streaming, web search, and citations are all built in.":"Connect a Venice API key from the header above to get started."})]}),s&&p.jsxs("div",{className:"w-full max-w-md flex flex-col gap-2",children:[p.jsx("div",{className:"text-[12px] uppercase tracking-[0.08em] text-white/35 font-medium text-left",children:"Try one of these"}),p.jsx("div",{className:"flex flex-col gap-1.5",children:IE.map(E=>p.jsx("button",{type:"button",onClick:()=>g(E,d),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.14] hover:bg-white/[0.04] transition-all text-[14px] text-white/65 focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",children:E},E))})]}),p.jsx(Vg,{})]}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"border-b border-white/[0.04]",children:p.jsx(Vg,{})}),p.jsxs("div",{className:"w-full max-w-[960px] mx-auto py-5 px-4 sm:px-5 flex flex-col gap-5",children:[u.messages.map((E,O)=>p.jsx(GE,{message:E,index:O,onCopy:()=>{},onDelete:()=>{u&&n(u.id,O)},onRegenerate:E.role==="assistant"&&O===u.messages.length-1?()=>x(d):void 0},O)),p.jsx("div",{ref:b})]})]})}),p.jsx(FE,{onSend:(E,O)=>g(E,d,O),onStop:m,isStreaming:y,disabled:!s})]})}function KE(){return ly({queryKey:["image-styles"],queryFn:()=>Ji("/image/styles",{noAuth:!0}),staleTime:600*1e3,select:n=>n.data})}function ZE(){return Fn({mutationFn:n=>Ji("/image/generate",{method:"POST",body:JSON.stringify(n)})})}function tr({controls:n,output:l,history:a,className:u}){return p.jsxs("div",{className:Te("flex flex-col md:flex-row h-full bg-[#0a0a0c]",u),children:[p.jsxs("aside",{className:"md:w-[360px] lg:w-[400px] shrink-0 border-r border-white/[0.05] flex flex-col bg-[#0c0c10] max-h-[55vh] md:max-h-none",children:[p.jsx("div",{className:"p-5 flex flex-col gap-4 overflow-y-auto",children:n}),a&&p.jsx("div",{className:"border-t border-white/[0.05] flex-1 min-h-0 overflow-y-auto p-3",children:a})]}),p.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto p-5 md:p-7",children:l})]})}const JE=["A serene mountain lake at golden hour, low fog over the water, painterly","Macro photo of a dewdrop on a spider web, sunrise lighting","Cyberpunk street market at night, neon signs reflecting in puddles","Children's book illustration of a fox reading a book under a mushroom"];function Uc(n){return n.startsWith("data:")?n:n.startsWith("/9j/")?`data:image/jpeg;base64,${n}`:n.startsWith("iVBOR")?`data:image/png;base64,${n}`:n.startsWith("UklGR")?`data:image/webp;base64,${n}`:`data:image/png;base64,${n}`}const PE=[{value:"0",label:"512"},{value:"1",label:"768"},{value:"2",label:"1024"},{value:"3",label:"1280"}],$E=[{w:512,h:512},{w:768,h:768},{w:1024,h:1024},{w:1280,h:1280}];function WE(){const n=gn(fe=>fe.apiKey),l=on(fe=>fe.selectedModels.image),{data:a}=Si("image"),{data:u}=KE(),s=l||a?.[0]?.id||"z-image-turbo",f=a?.find(fe=>fe.id===s)?.model_spec?.constraints,d=f?.aspectRatios&&f.aspectRatios.length>0,g=f?.resolutions&&f.resolutions.length>0,m=f?.steps?.max||50,x=f?.steps?.default||20,y=f?.promptCharacterLimit||4096,[b,w]=q.useState(""),[k,N]=q.useState(""),[A,E]=q.useState("2"),[O,z]=q.useState(""),[X,V]=q.useState(""),[R,ee]=q.useState(""),[W,ue]=q.useState(null),U=Math.min(W?.model===s?W.v:x,m),ne=fe=>ue({model:s,v:fe}),ie=!!f?.steps,[me,re]=q.useState(1),[$]=q.useState(!0),[L,P]=q.useState([]),[F,he]=q.useState(null),j=q.useMemo(()=>d?[{value:"",label:"Auto"},...f.aspectRatios.map(fe=>({value:fe,label:fe}))]:[],[f,d]),_=q.useMemo(()=>g?f.resolutions.map(fe=>({value:fe,label:fe})):[],[f,g]),Y=(fe,ve)=>{const $e=document.createElement("a");$e.href=Uc(fe),$e.download=`venice-image${ve!==void 0?`-${ve+1}`:""}.png`,$e.click()},C=ZE(),le=[{value:"",label:"None"},...u?.map(fe=>({value:fe,label:fe}))??[]],de=()=>{if(!b.trim())return;const fe=$E[Number(A)],ve={prompt:b.trim(),negative_prompt:k.trim()||void 0,model:s,style_preset:R||void 0,variants:me,hide_watermark:$,steps:ie?U:void 0};d&&O?ve.aspect_ratio=O:d||(ve.width=fe.w,ve.height=fe.h),g&&X&&(ve.resolution=X),C.mutate(ve,{onSuccess:$e=>{const Bt=$e.images.map(Ht=>typeof Ht=="string"?Ht:Ht.b64_json);P(Ht=>[...Bt,...Ht])}})},oe=p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(je,{hint:`${b.length}/${y}`,children:"Prompt"}),p.jsx(Sn,{value:b,onChange:w,placeholder:"A serene mountain landscape at golden hour…"})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Negative prompt"}),p.jsx(Sn,{value:k,onChange:N,placeholder:"blurry, low quality…",rows:2})]}),d?p.jsxs("div",{children:[p.jsx(je,{children:"Aspect Ratio"}),p.jsx(Au,{options:j,value:O,onChange:z})]}):p.jsxs("div",{children:[p.jsx(je,{children:"Size"}),p.jsx(Au,{options:PE,value:A,onChange:E})]}),g&&p.jsxs("div",{children:[p.jsx(je,{children:"Resolution"}),p.jsx(Au,{options:_,value:X||_[0]?.value||"",onChange:V})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Style"}),p.jsx(Gn,{value:R,onChange:ee,options:le,searchable:!0,placeholder:"None"})]}),ie&&p.jsxs("div",{children:[p.jsx(je,{hint:String(U),children:"Steps"}),p.jsx("input",{type:"range",min:1,max:m,value:U,onChange:fe=>ne(Number(fe.target.value)),className:"w-full"})]}),p.jsxs("div",{children:[p.jsx(je,{hint:String(me),children:"Variants"}),p.jsx("input",{type:"range",min:1,max:4,value:me,onChange:fe=>re(Number(fe.target.value)),className:"w-full"})]}),p.jsx(Xi,{onClick:de,disabled:!b.trim()||!n,loading:C.isPending,size:"lg",children:C.isPending?"Generating…":"Generate"}),C.error&&p.jsx(Ki,{children:C.error.message})]}),Se=p.jsxs(p.Fragment,{children:[F&&p.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/95 backdrop-blur-sm animate-fade-in",onClick:()=>he(null),children:p.jsxs("div",{className:"relative",onClick:fe=>fe.stopPropagation(),children:[p.jsx("img",{src:Uc(F),alt:"Generated",className:"max-w-[90vw] max-h-[90vh] rounded-xl shadow-2xl"}),p.jsxs("div",{className:"absolute top-3 right-3 flex gap-1.5",children:[p.jsx("button",{onClick:()=>Y(F),"aria-label":"Download",className:"p-2 bg-black/60 hover:bg-black/80 rounded-lg text-white/70 hover:text-white transition-colors backdrop-blur-sm",children:p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})})}),p.jsx("button",{onClick:()=>he(null),"aria-label":"Close",className:"p-2 bg-black/60 hover:bg-black/80 rounded-lg text-white/70 hover:text-white transition-colors backdrop-blur-sm",children:p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]})}),L.length===0?p.jsx("div",{className:"flex items-center justify-center h-full",children:C.isPending?p.jsxs("div",{className:"flex flex-col items-center gap-3",role:"status","aria-live":"polite",children:[p.jsx("div",{className:"w-8 h-8 border-2 border-white/[0.08] border-t-[var(--color-accent)] rounded-full animate-spin"}),p.jsx("span",{className:"text-[13px] text-white/55",children:"Generating…"})]}):p.jsx(ab,{items:JE,onPick:w})}):p.jsxs("div",{className:"grid grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4",children:[C.isPending&&Array.from({length:me}).map((fe,ve)=>p.jsx("div",{className:"aspect-square rounded-xl skeleton"},`skel-${ve}`)),L.map((fe,ve)=>p.jsxs("div",{className:"relative group",children:[p.jsx("img",{src:Uc(fe),alt:`Generated ${ve+1}`,className:"w-full rounded-xl cursor-pointer border border-white/[0.05] hover:border-white/[0.18] transition-all duration-200",onClick:()=>he(fe)}),p.jsx("button",{onClick:$e=>{$e.stopPropagation(),Y(fe,ve)},"aria-label":"Download",className:"absolute top-2 right-2 p-1.5 bg-black/60 hover:bg-black/85 rounded-lg text-white/70 hover:text-white opacity-0 group-hover:opacity-100 transition-all backdrop-blur-sm",title:"Download",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})})})]},ve))]})]});return p.jsx(tr,{controls:oe,output:Se})}function e5(){return Fn({mutationFn:n=>qu("/image/edit",n)})}function t5(){return Fn({mutationFn:n=>qu("/image/upscale",n)})}function n5(){return Fn({mutationFn:n=>qu("/image/background-remove",{image:n})})}function px(){const[n,l]=q.useState(null),a=q.useRef(null),u=q.useCallback(c=>{if(a.current&&(URL.revokeObjectURL(a.current),a.current=null),c){const f=URL.createObjectURL(c);a.current=f,l(f)}else l(null)},[]),s=q.useCallback(()=>u(null),[u]);return q.useEffect(()=>()=>{a.current&&(URL.revokeObjectURL(a.current),a.current=null)},[]),[n,u,s]}function i5(){const n=gn(F=>F.apiKey),[l,a]=q.useState("edit"),[u,s]=q.useState(null),[c,f]=q.useState(""),[d,g,m]=px(),x=q.useRef(null),[y,b]=q.useState(""),{data:w}=Si("inpaint"),k=(w??[]).map(F=>({value:F.id,label:F.model_spec?.name||F.id})),[N,A]=q.useState(""),E=k.some(F=>F.value===N)?N:k[0]?.value??"",[O,z]=q.useState(2),[X,V]=q.useState(!1),[R,ee]=q.useState(.5),[W,ue]=q.useState(""),U=e5(),ne=t5(),ie=n5(),me=F=>{const he=new FileReader;he.onload=()=>{s(he.result),f(F.name),m()},he.readAsDataURL(F)},re=()=>{if(!u)return;m();const F={onSuccess:he=>g(he),onError:he=>Fi.fromError(he,"Image tool failed")};l==="edit"?U.mutate({image:u,prompt:y.trim(),modelId:E},F):l==="upscale"?ne.mutate({image:u,scale:O,enhance:X,enhanceCreativity:X?R:void 0,enhancePrompt:X&&W.trim()?W.trim():void 0},F):ie.mutate(u,F)},$=U.isPending||ne.isPending||ie.isPending,L=U.error||ne.error||ie.error,P=()=>{if(!d)return;const F=document.createElement("a");F.href=d,F.download=`venice-${l}-result.png`,F.click()};return p.jsxs("div",{className:"flex h-full",children:[p.jsxs("div",{className:"w-96 border-r border-white/[0.06] p-6 flex flex-col gap-4 overflow-y-auto shrink-0",children:[p.jsx("div",{className:"flex gap-px bg-white/[0.02] rounded-lg p-0.5 border border-white/[0.04]",children:[["edit","Edit"],["upscale","Upscale"],["remove-bg","Remove BG"]].map(([F,he])=>p.jsx("button",{onClick:()=>{a(F),m()},className:Te("flex-1 px-2 py-2.5 text-[14px] font-medium rounded-[7px] transition-all duration-150",l===F?"bg-white text-black":"text-white/25 hover:text-white/45"),children:he},F))}),p.jsxs("div",{children:[p.jsx(je,{children:"Source image"}),u?p.jsxs("div",{className:"relative group",children:[p.jsx("img",{src:u,alt:"Source",className:"w-full rounded-lg border border-white/[0.06]"}),p.jsx("button",{onClick:()=>{s(null),f(""),m()},"aria-label":"Remove image",className:"absolute top-1.5 right-1.5 p-1 bg-black/60 rounded-md text-white/60 hover:text-white opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-all focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",children:p.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),p.jsx("span",{className:"text-[13px] text-white/15 mt-1 block truncate",children:c})]}):p.jsxs("button",{type:"button",onClick:()=>x.current?.click(),className:"w-full border border-dashed border-white/[0.08] hover:border-white/[0.15] rounded-lg py-8 text-center transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/30 focus-visible:outline-offset-2",children:[p.jsx("input",{ref:x,type:"file",accept:"image/*",className:"hidden",onChange:F=>{F.target.files?.[0]&&me(F.target.files[0])}}),p.jsx("p",{className:"text-[14px] text-white/40",children:"Click to upload image"})]})]}),l==="edit"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(je,{children:"Edit prompt"}),p.jsx(Sn,{value:y,onChange:b,placeholder:"Change the background to a sunset beach...",rows:3})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Model"}),p.jsx(Gn,{value:E,onChange:A,options:k,searchable:!0})]})]}),l==="upscale"&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-1",children:[p.jsx(je,{children:"Scale"}),p.jsxs("span",{className:"text-[13px] text-white/30 font-mono",children:[O,"x"]})]}),p.jsx("input",{type:"range",min:1,max:4,step:1,value:O,onChange:F=>z(Number(F.target.value)),className:"w-full"})]}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Enhance"}),p.jsx("button",{onClick:()=>V(!X),className:Te("w-8 h-[18px] rounded-full transition-colors relative",X?"bg-white":"bg-white/[0.08]"),children:p.jsx("div",{className:Te("absolute top-[2px] w-[14px] h-[14px] rounded-full transition-all",X?"left-[16px] bg-black":"left-[2px] bg-white/30")})})]}),X&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-1",children:[p.jsx(je,{children:"Creativity"}),p.jsx("span",{className:"text-[13px] text-white/30 font-mono",children:R.toFixed(2)})]}),p.jsx("input",{type:"range",min:0,max:1,step:.05,value:R,onChange:F=>ee(Number(F.target.value)),className:"w-full"})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Enhance prompt"}),p.jsx(Sn,{value:W,onChange:ue,placeholder:"Make it more vibrant...",rows:2})]})]})]}),p.jsx(Xi,{onClick:re,disabled:!u||!n||$||l==="edit"&&!y.trim(),loading:$,children:l==="edit"?"Edit Image":l==="upscale"?"Upscale Image":"Remove Background"}),L&&p.jsx(Ki,{children:L.message})]}),p.jsx("div",{className:"flex-1 p-6 overflow-y-auto flex flex-col min-w-0",children:d?p.jsxs("div",{className:"animate-fade-in flex flex-col gap-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Result"}),p.jsxs("button",{onClick:P,className:"text-[14px] text-white/20 hover:text-white/40 transition-colors flex items-center gap-1.5",children:[p.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Download"]})]}),p.jsx("img",{src:d,alt:"Result",className:Te("w-full rounded-lg border border-white/[0.04]",l==="remove-bg"&&"bg-[repeating-conic-gradient(#1a1a1a_0%_25%,#111_0%_50%)_0_0/20px_20px]")})]}):p.jsx(zu,{children:l==="edit"?"Edited image appears here":l==="upscale"?"Upscaled image appears here":"Result appears here"})})]})}function l5(){const[n,l]=q.useState("generate");return p.jsxs("div",{className:"flex flex-col h-full",children:[p.jsx("div",{className:"flex items-center gap-1 px-4 py-2.5 border-b border-white/[0.04]",children:["generate","tools"].map(a=>p.jsx("button",{onClick:()=>l(a),className:Te("text-[14px] font-medium px-2.5 py-[3px] rounded-full transition-all duration-150",n===a?"bg-white text-black":"bg-white/[0.03] text-white/20 hover:text-white/40 hover:bg-white/[0.05]"),children:a==="generate"?"Generate":"Edit / Upscale / BG Remove"},a))}),p.jsx("div",{className:"flex-1 min-h-0",children:n==="generate"?p.jsx(WE,{}):p.jsx(i5,{})})]})}function a5(){return Fn({mutationFn:n=>qu("/audio/speech",n)})}function r5(){return Fn({mutationFn:n=>{const l=new FormData;return l.append("file",n),l.append("model","whisper-large-v3"),nb("/audio/transcriptions",l)}})}const u5=["Welcome to OpenVenice. The future of voice is here, and it speaks every language.","In a quiet town nestled between two mountains, a small library held a very old book.","Did you know? A single octopus has nine brains — one central, plus one in each arm."],s5=["af_alloy","af_aoede","af_bella","af_heart","af_jessica","af_kore","af_nicole","af_nova","af_river","af_sarah","af_sky","am_adam","am_echo","am_eric","am_fable","am_liam","am_michael","am_onyx","bf_alice","bf_emma","bf_isabella","bf_lily","bm_daniel","bm_fable","bm_george","bm_lewis","zf_xiaobei","zf_xiaoni","zf_xiaoxuan","zf_xiaoyan","zf_xiaoyi","zm_yunjian","zm_yunxi","zm_yunxia","zm_yunyang","jf_alpha","jf_gongitsune","jf_nezumi","jf_tebukuro","jm_kumo","ff_siwis","hf_alpha","hf_beta","hm_omega","hm_psi","if_sara","im_nicola","pf_dora","pm_alex","pm_santa","ef_dora","em_alex","em_santa"],o5=["mp3","opus","aac","flac","wav"];function c5(){const n=gn(F=>F.apiKey),l=on(F=>F.selectedModels.audio),{data:a}=Si("tts"),u=l||a?.[0]?.id||"tts-kokoro",s=a?.find(F=>F.id===u)?.model_spec??{},c=s.voices?.length?s.voices:s5,f=s.supported_formats?.length?s.supported_formats:[...o5],[d,g]=q.useState("tts"),[m,x]=q.useState(""),[y,b]=q.useState("af_heart"),[w,k]=q.useState(1),[N,A]=q.useState("mp3"),[E,O]=px(),[z,X]=q.useState(null),[V,R]=q.useState(""),ee=q.useRef(null),W=a5(),ue=r5(),U=c.includes(y)?y:s.default_voice&&c.includes(s.default_voice)?s.default_voice:c[0],ne=f.includes(N)?N:s.default_format&&f.includes(s.default_format)?s.default_format:f[0],ie=s.supports_speed!==!1,me=c.map(F=>{const he=F.slice(0,2),j={af:{flag:"🇺🇸",gender:"F",lang:"American English (Female)"},am:{flag:"🇺🇸",gender:"M",lang:"American English (Male)"},bf:{flag:"🇬🇧",gender:"F",lang:"British English (Female)"},bm:{flag:"🇬🇧",gender:"M",lang:"British English (Male)"},zf:{flag:"🇨🇳",gender:"F",lang:"Mandarin (Female)"},zm:{flag:"🇨🇳",gender:"M",lang:"Mandarin (Male)"},jf:{flag:"🇯🇵",gender:"F",lang:"Japanese (Female)"},jm:{flag:"🇯🇵",gender:"M",lang:"Japanese (Male)"},ff:{flag:"🇫🇷",gender:"F",lang:"French (Female)"},hf:{flag:"🇮🇳",gender:"F",lang:"Hindi (Female)"},hm:{flag:"🇮🇳",gender:"M",lang:"Hindi (Male)"},if:{flag:"🇮🇹",gender:"F",lang:"Italian (Female)"},im:{flag:"🇮🇹",gender:"M",lang:"Italian (Male)"},pf:{flag:"🇧🇷",gender:"F",lang:"Portuguese (Female)"},pm:{flag:"🇧🇷",gender:"M",lang:"Portuguese (Male)"},ef:{flag:"🇪🇸",gender:"F",lang:"Spanish (Female)"},em:{flag:"🇪🇸",gender:"M",lang:"Spanish (Male)"}},_=/^[a-z]{2}_/.test(F)?j[he]:void 0,Y=F.slice(3),C=_?`${_.flag} ${_.gender} · ${Y} (${_.lang})`:F;return{value:F,label:C}}),re=f.map(F=>({value:F,label:F.toUpperCase()})),$=()=>{m.trim()&&W.mutate({model:u,input:m.trim(),voice:U,...ie?{speed:w}:{},response_format:ne},{onSuccess:F=>O(F),onError:F=>Fi.fromError(F,"TTS failed")})},L=p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"flex gap-px bg-white/[0.03] rounded-lg p-0.5 border border-white/[0.05]",children:["tts","transcribe"].map(F=>p.jsx("button",{onClick:()=>g(F),className:Te("flex-1 px-3 py-2 text-[13px] font-medium rounded-[7px] transition-all duration-150 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)]",d===F?"bg-white text-black shadow-sm":"text-white/55 hover:text-white/85"),children:F==="tts"?"Text to Speech":"Transcribe"},F))}),d==="tts"?p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(je,{hint:`${m.length}/4096`,children:"Text"}),p.jsx(Sn,{value:m,onChange:x,placeholder:"Enter text to convert to speech…",rows:5})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Voice"}),p.jsx(Gn,{value:U,onChange:b,options:me,searchable:!0})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[p.jsxs("div",{children:[p.jsx(je,{children:"Format"}),p.jsx(Gn,{value:ne,onChange:A,options:re})]}),p.jsxs("div",{children:[p.jsx(je,{hint:`${w}×`,children:"Speed"}),p.jsx("input",{type:"range",min:.25,max:4,step:.25,value:w,onChange:F=>k(Number(F.target.value)),className:"w-full"})]})]}),p.jsx(Xi,{onClick:$,disabled:!m.trim()||!n,loading:W.isPending,size:"lg",children:"Generate Speech"}),W.error&&p.jsx(Ki,{children:W.error.message})]}):p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",onClick:()=>ee.current?.click(),className:"w-full border border-dashed border-white/[0.1] hover:border-white/[0.22] hover:bg-white/[0.02] rounded-xl p-8 text-center transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)]",children:[p.jsx("input",{ref:ee,type:"file",accept:"audio/*",className:"hidden",onChange:F=>X(F.target.files?.[0]??null)}),p.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"mx-auto mb-2 text-white/40",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12"})}),p.jsx("p",{className:"text-[14px] text-white/65",children:z?z.name:"Click to select audio file"})]}),p.jsx(Xi,{onClick:()=>{z&&ue.mutate(z,{onSuccess:F=>R(F.text),onError:F=>Fi.fromError(F,"Transcription failed")})},disabled:!z||!n,loading:ue.isPending,size:"lg",children:"Transcribe"}),ue.error&&p.jsx(Ki,{children:ue.error.message})]})]}),P=p.jsx("div",{className:"flex flex-col min-h-full",children:d==="tts"?E?p.jsxs("div",{className:"flex flex-col gap-4 animate-fade-in",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Output"}),p.jsxs("a",{href:E,download:`venice-speech.${N}`,className:"text-[14px] text-white/20 hover:text-white/40 transition-colors flex items-center gap-1.5",children:[p.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Download"]})]}),p.jsx("audio",{controls:!0,src:E,className:"w-full"}),p.jsx("div",{className:"bg-white/[0.02] border border-white/[0.04] rounded-lg p-4",children:p.jsx("p",{className:"text-[15px] text-white/30 leading-relaxed",children:m})})]}):m?p.jsx(zu,{children:"Press Generate to synthesize speech"}):p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsxs("div",{className:"max-w-md w-full flex flex-col gap-2",children:[p.jsx("div",{className:"text-[12px] uppercase tracking-[0.08em] text-white/35 font-medium text-left",children:"Try one of these"}),u5.map(F=>p.jsx("button",{type:"button",onClick:()=>x(F),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.14] hover:bg-white/[0.04] transition-all text-[14px] text-white/65 focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",children:F},F))]})}):V?p.jsxs("div",{className:"flex flex-col gap-3 animate-fade-in",children:[p.jsx(je,{children:"Transcript"}),p.jsx("div",{className:"bg-[#111114] border border-white/[0.06] rounded-xl p-6 text-[15px] text-white/85 whitespace-pre-wrap leading-relaxed",children:V})]}):p.jsx(zu,{children:"Transcript appears here"})});return p.jsx(tr,{controls:L,output:P})}const f5=3e3,Fg=120;function h5(){const[n,l]=q.useState("idle"),[a,u]=q.useState(null),[s,c]=q.useState(null),[f,d]=q.useState(0),g=q.useRef(void 0),m=q.useRef(void 0),x=q.useRef(null),y=q.useRef(""),b=q.useRef(void 0),w=q.useRef(null),k=q.useRef(0),N=q.useRef(!1),A=q.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0),m.current&&(clearInterval(m.current),m.current=void 0)},[]);q.useEffect(()=>()=>A(),[A]);const E=q.useCallback(()=>{k.current=0,w.current=Date.now(),d(0),m.current=setInterval(()=>{w.current&&d(Date.now()-w.current)},1e3),g.current=setInterval(async()=>{if(!N.current){if(k.current+=1,k.current>Fg){A(),c("Generation took too long. Cancel and try again."),l("failed");return}try{const V=await oy("audio",y.current,x.current||"",{downloadUrl:b.current});V.state==="done"?(l("completed"),u(V.url),A()):V.state==="failed"?(l("failed"),c(V.error),A()):l(V.status==="queued"?"queued":"processing")}catch(V){k.current>=Fg&&(c(V instanceof Error?V.message:"Polling failed"),A())}}},f5)},[A]),O=Fn({mutationFn:V=>Ji("/audio/queue",{method:"POST",body:JSON.stringify(V)}),onSuccess:V=>{N.current=!1,x.current=V.queue_id,y.current=V.model,b.current=V.download_url,l("queued"),u(null),c(null),E()},onError:V=>{c(V instanceof Error?V.message:"Queue failed"),l("failed")}}),z=q.useCallback(()=>{N.current=!0,A(),l("idle"),c(null),x.current=null,w.current=null,d(0)},[A]),X=q.useCallback(()=>{z(),u(null)},[z]);return{queue:O.mutate,isQueueing:O.isPending,status:n,audioUrl:a,error:s,elapsedMs:f,cancel:z,reset:X}}function d5(n,l){const a=l.duration_options;return a?.length?a.reduce((u,s)=>Math.abs(s-n)$.apiKey),l=on($=>$.selectedModels.music),{data:a}=Si("music"),u=l||a?.[0]?.id||"",s=a?.find($=>$.id===u)?.model_spec??{},c={lyrics:!!s.supports_lyrics,instrumental:!!s.supports_force_instrumental,voice:!!s.voices?.length,duration:!!(s.duration_options?.length||s.max_duration)},f=s.min_prompt_length??1,[d,g]=q.useState(""),[m,x]=q.useState(""),[y,b]=q.useState(null),w=d5(y?.model===u?y.v:s.default_duration??s.min_duration??30,s),[k,N]=q.useState(""),A=s.voices?.includes(k)?k:s.default_voice??s.voices?.[0]??"",[E,O]=q.useState(!1),{queue:z,isQueueing:X,status:V,audioUrl:R,error:ee,reset:W,cancel:ue,elapsedMs:U}=h5(),ne=V==="queued"||V==="processing",ie=()=>{if(d.trim().length1?s.duration_options[1]-s.duration_options[0]:1,value:w,onChange:$=>b({model:u,v:Number($.target.value)}),className:"w-full"})]}),c.voice&&p.jsxs("div",{children:[p.jsx(je,{children:"Voice"}),p.jsx(Gn,{value:A,onChange:N,options:(s.voices??[]).map($=>({value:$,label:$})),searchable:!0})]}),c.instrumental&&p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Instrumental only"}),p.jsx("button",{onClick:()=>O(!E),"aria-pressed":E,className:Te("w-9 h-5 rounded-full transition-colors relative",E?"bg-[var(--color-accent)]":"bg-white/[0.1]"),children:p.jsx("div",{className:Te("absolute top-[2px] w-[16px] h-[16px] rounded-full bg-white transition-all",E?"left-[20px]":"left-[2px]")})})]}),p.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.lyrics&&p.jsx(Eu,{children:"Lyrics"}),c.instrumental&&p.jsx(Eu,{children:"Instrumental"}),c.voice&&p.jsx(Eu,{children:"Voice"}),c.duration&&p.jsx(Eu,{children:"Custom Duration"})]}),p.jsx(Xi,{onClick:ie,disabled:d.trim().length0&&p.jsxs("span",{className:"block text-[12px] text-white/30 font-mono mt-1",children:[g5(U)," · typically 20s–90s"]})]}),p.jsx("button",{onClick:ue,className:"text-[13px] text-white/35 hover:text-white/65 underline underline-offset-2 transition-colors",children:"Cancel"})]}):d?p.jsx("span",{children:"Press Generate to create your track"}):p.jsxs("div",{className:"max-w-md w-full flex flex-col gap-2",children:[p.jsx("div",{className:"text-[12px] uppercase tracking-[0.08em] text-white/35 font-medium text-left",children:"Try one of these"}),p5.map($=>p.jsx("button",{type:"button",onClick:()=>g($),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.14] hover:bg-white/[0.04] transition-all text-[14px] text-white/65 focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",children:$},$))]})})});return p.jsx(tr,{controls:me,output:re})}const p5=["Lo-fi hip-hop beat with vinyl crackle and rain — 80 bpm, mellow","Cinematic orchestral build — slow strings rising into triumphant brass","Synthwave with retro arpeggios, warm pads, gated reverb drums — 105 bpm","Acoustic folk fingerpicking, soft female vocals, intimate room sound"];function g5(n){const l=Math.floor(n/1e3),a=Math.floor(l/60);return a>0?`${a}m ${l%60}s`:`${l}s`}function Eu({children:n}){return p.jsx("span",{className:"text-[12px] text-white/55 bg-white/[0.04] border border-white/[0.06] rounded px-1.5 py-0.5",children:n})}const y5=3e3,Yg=200;function x5(){const[n,l]=q.useState("idle"),[a,u]=q.useState(null),[s,c]=q.useState(null),[f,d]=q.useState(0),g=q.useRef(void 0),m=q.useRef(void 0),x=q.useRef(null),y=q.useRef(""),b=q.useRef(void 0),w=q.useRef(null),k=q.useRef(0),N=q.useRef(!1),A=q.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0),m.current&&(clearInterval(m.current),m.current=void 0)},[]);q.useEffect(()=>()=>A(),[A]);const E=q.useCallback(()=>{k.current=0,w.current=Date.now(),d(0),m.current=setInterval(()=>{w.current&&d(Date.now()-w.current)},1e3),g.current=setInterval(async()=>{if(!N.current){if(k.current+=1,k.current>Yg){A(),c("Generation took too long. Cancel and try again, or check your Venice dashboard."),l("failed");return}try{const V=await oy("video",y.current,x.current||"",{downloadUrl:b.current});V.state==="done"?(l("completed"),u(V.url),A()):V.state==="failed"?(l("failed"),c(V.error),A()):l(V.status==="queued"?"queued":"processing")}catch(V){k.current>=Yg&&(c(V instanceof Error?V.message:"Polling failed"),A())}}},y5)},[A]),O=Fn({mutationFn:V=>Ji("/video/queue",{method:"POST",body:JSON.stringify(V)}),onSuccess:V=>{N.current=!1,x.current=V.queue_id||V.id||"",y.current=V.model,b.current=V.download_url,l("queued"),u(null),c(null),E()},onError:V=>{c(V instanceof Error?V.message:"Queue failed"),l("failed")}}),z=q.useCallback(()=>{N.current=!0,A(),l("idle"),c(null),x.current=null,w.current=null,d(0)},[A]),X=q.useCallback(()=>{z(),u(null)},[z]);return{queue:O.mutate,isQueueing:O.isPending,status:n,videoUrl:a,error:s,elapsedMs:f,cancel:z,reset:X}}function v5(){const n=gn(be=>be.apiKey),{groups:l,isLoading:a}=ib(),[u,s]=q.useState(""),[c,f]=q.useState("text"),[d,g]=q.useState(""),[m,x]=q.useState(""),[y,b]=q.useState(""),[w,k]=q.useState(""),[N,A]=q.useState(""),[E,O]=q.useState(null),[z,X]=q.useState(""),[V,R]=q.useState(!0),ee=q.useRef(null),{queue:W,isQueueing:ue,status:U,videoUrl:ne,error:ie,reset:me,cancel:re,elapsedMs:$}=x5(),L=U==="queued"||U==="processing",P=q.useMemo(()=>!u&&l.length>0?l[0]:l.find(be=>be.name===u),[l,u]),F=c==="image"?P?.imageModel?"image":"text":P?.textModel?"text":"image",he=F==="image"?P?.imageModel:P?.textModel,j=he?.model_spec?.constraints,_=P?.name||"",Y=!!P?.imageModel,C=!!P?.textModel,le=q.useMemo(()=>(j?.durations||[]).map(be=>({value:be,label:be})),[j]),de=q.useMemo(()=>(j?.resolutions||[]).map(be=>({value:be,label:be})),[j]),oe=q.useMemo(()=>(j?.aspect_ratios||[]).map(be=>({value:be,label:be})),[j]),Se=le.some(be=>be.value===y)?y:le[0]?.value||"",fe=de.some(be=>be.value===w)?w:de[0]?.value||"",ve=oe.some(be=>be.value===N)?N:oe[0]?.value||"",$e=q.useMemo(()=>l.map(be=>({value:be.name,label:be.name})),[l]),Bt=be=>{const Xn=new FileReader;Xn.onload=()=>{O(Xn.result),X(be.name)},Xn.readAsDataURL(be)},Ht=()=>{if(!d.trim()||!he)return;const be={model:he.id,prompt:d.trim(),negative_prompt:m.trim()||void 0,duration:Se||void 0,resolution:fe||void 0,aspect_ratio:ve||void 0};F==="image"&&E&&(be.image_url=E),j?.audio&&j.audio_configurable&&(be.audio=V),W(be)},Tt=[];P&&(P.sets.includes("uncensored")&&Tt.push("Uncensored"),P.sets.includes("open_source")&&Tt.push("Open Source"),P.sets.includes("photorealistic")&&Tt.push("Photorealistic"),P.sets.includes("cinematic")&&Tt.push("Cinematic"),P.sets.includes("fast")&&Tt.push("Fast"),j?.audio&&Tt.push("Audio"),j?.audio_input&&Tt.push("Audio Input"));const cn=p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(je,{children:"Model"}),p.jsx(Gn,{value:_,onChange:be=>{s(be),b(""),k(""),A("")},options:$e,searchable:!0,placeholder:a?"Loading...":"Select model..."})]}),(C||Y)&&p.jsxs("div",{className:"flex gap-px bg-white/[0.02] rounded-lg p-0.5 border border-white/[0.04]",children:[C&&p.jsx("button",{onClick:()=>f("text"),className:Te("flex-1 px-3 py-2.5 text-[15px] font-medium rounded-[7px] transition-all duration-150",F==="text"?"bg-white text-black":"text-white/25 hover:text-white/45"),children:"Text to Video"}),Y&&p.jsx("button",{onClick:()=>f("image"),className:Te("flex-1 px-3 py-2.5 text-[15px] font-medium rounded-[7px] transition-all duration-150",F==="image"?"bg-white text-black":"text-white/25 hover:text-white/45"),children:"Image to Video"})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Prompt"}),p.jsx(Sn,{value:d,onChange:g,placeholder:"A cinematic drone shot over misty mountains at sunrise...",rows:4})]}),p.jsxs("div",{children:[p.jsx(je,{children:"Negative prompt"}),p.jsx(Sn,{value:m,onChange:x,placeholder:"low quality, blurry...",rows:2})]}),F==="image"&&p.jsxs("div",{children:[p.jsx(je,{children:"Reference image"}),E?p.jsxs("div",{className:"relative group",children:[p.jsx("img",{src:E,alt:"Reference",className:"w-full rounded-lg border border-white/[0.06]"}),p.jsx("button",{onClick:()=>{O(null),X("")},className:"absolute top-1.5 right-1.5 p-1 bg-black/60 rounded-md text-white/50 hover:text-white opacity-0 group-hover:opacity-100 transition-all",children:p.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),p.jsx("span",{className:"text-[16px] text-white/15 mt-1 block truncate",children:z})]}):p.jsxs("div",{onClick:()=>ee.current?.click(),className:"border border-dashed border-white/[0.08] hover:border-white/[0.15] rounded-lg py-5 text-center cursor-pointer transition-colors",children:[p.jsx("input",{ref:ee,type:"file",accept:"image/*",className:"hidden",onChange:be=>{be.target.files?.[0]&&Bt(be.target.files[0])}}),p.jsx("p",{className:"text-[14px] text-white/15",children:"Click to add image"})]})]}),le.length>0&&p.jsxs("div",{children:[p.jsx(je,{children:"Duration"}),le.length<=5?p.jsx(Au,{options:le,value:Se,onChange:b}):p.jsx(w5,{options:le.map(be=>be.value),value:Se,onChange:b})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[de.length>0&&p.jsxs("div",{children:[p.jsx(je,{children:"Resolution"}),p.jsx(Gn,{value:fe,onChange:k,options:de})]}),oe.length>0&&p.jsxs("div",{children:[p.jsx(je,{children:"Aspect"}),p.jsx(Gn,{value:ve,onChange:A,options:oe})]})]}),j?.audio&&j.audio_configurable&&p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Generate audio"}),p.jsx("button",{onClick:()=>R(!V),className:Te("w-8 h-[18px] rounded-full transition-colors relative",V?"bg-white":"bg-white/[0.08]"),children:p.jsx("div",{className:Te("absolute top-[2px] w-[14px] h-[14px] rounded-full transition-all",V?"left-[16px] bg-black":"left-[2px] bg-white/30")})})]}),Tt.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1",children:Tt.map(be=>p.jsx("span",{className:"text-[16px] text-white/20 bg-white/[0.03] border border-white/[0.04] rounded px-1.5 py-0.5",children:be},be))}),p.jsx(Xi,{onClick:Ht,disabled:!d.trim()||!n||!he||ue||L||c==="image"&&!E,loading:ue||L,children:L?U==="queued"?"Queued...":"Processing...":"Generate Video"}),ie&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx(Ki,{children:ie}),p.jsx("button",{onClick:me,className:"text-[13px] text-white/55 hover:text-white underline underline-offset-2 shrink-0 transition-colors",children:"Reset"})]})]}),In=p.jsx("div",{className:"flex flex-col h-full",children:ne?p.jsxs("div",{className:"animate-fade-in flex flex-col gap-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx(je,{children:"Output"}),p.jsxs("a",{href:ne,download:"venice-video.mp4",target:"_blank",rel:"noopener noreferrer",className:"text-[14px] text-white/20 hover:text-white/40 transition-colors flex items-center gap-1.5",children:[p.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})}),"Download"]})]}),p.jsx("video",{controls:!0,src:ne,className:"w-full rounded-lg bg-black border border-white/[0.04]"}),p.jsx("button",{onClick:me,className:"self-start text-[14px] text-white/15 hover:text-white/35 transition-colors",children:"Generate another"})]}):p.jsx("div",{className:"flex items-center justify-center flex-1 text-white/30 text-[15px]",children:L?p.jsxs("div",{className:"flex flex-col items-center gap-3",role:"status","aria-live":"polite",children:[p.jsx("div",{className:"w-7 h-7 border border-white/[0.08] border-t-white/40 rounded-full animate-spin"}),p.jsxs("span",{className:"text-white/55 text-center",children:[U==="queued"?"Queued — waiting for a slot":"Generating your video",$>0&&p.jsxs("span",{className:"block text-[12px] text-white/30 font-mono mt-1",children:[b5($)," · typically 30s–2min"]})]}),p.jsx("button",{onClick:re,className:"text-[13px] text-white/35 hover:text-white/65 underline underline-offset-2 transition-colors",children:"Cancel"})]}):p.jsxs("div",{className:"flex flex-col items-center gap-2",children:[p.jsx("span",{children:"Generated videos appear here"}),p.jsx("span",{className:"text-[12px] text-white/35",children:"Average generation time: 30s–2min"})]})})});return p.jsx(tr,{controls:cn,output:In})}function b5(n){const l=Math.floor(n/1e3),a=Math.floor(l/60);return a>0?`${a}m ${l%60}s`:`${l}s`}function w5({options:n,value:l,onChange:a}){const u=n.indexOf(l),s=u>=0?u:0;return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-1",children:[p.jsx("span",{className:"text-[16px] text-white/30 font-mono",children:n[s]}),p.jsxs("span",{className:"text-[16px] text-white/15",children:[n[0]," — ",n[n.length-1]]})]}),p.jsx("input",{type:"range",min:0,max:n.length-1,value:s,onChange:c=>a(n[Number(c.target.value)]),className:"w-full"})]})}function S5(){return Fn({mutationFn:n=>Ji("/embeddings",{method:"POST",body:JSON.stringify(n)})})}const ju=100;function k5(){const n=gn(A=>A.apiKey),l=on(A=>A.selectedModels.embeddings),{data:a}=Si("embedding"),u=l||a?.[0]?.id||"bge-m3",[s,c]=q.useState(""),[f,d]=q.useState(!1),g=S5(),m=g.data,x=m?.data[0]?.embedding,y=x?.length??0,b=f?x:x?.slice(0,ju),w=()=>{x&&navigator.clipboard.writeText(JSON.stringify(x))},k=p.jsxs(p.Fragment,{children:[p.jsxs("div",{children:[p.jsx(je,{children:"Input text"}),p.jsx(Sn,{value:s,onChange:c,placeholder:"Enter text to embed…",rows:6})]}),p.jsx(Xi,{onClick:()=>{g.mutate({model:u,input:s.trim()}),d(!1)},disabled:!s.trim()||!n,loading:g.isPending,size:"lg",children:"Generate Embeddings"}),g.error&&p.jsx(Ki,{children:g.error.message})]}),N=p.jsx("div",{className:"flex flex-col h-full",children:!m&&!s?p.jsx("div",{className:"flex items-center justify-center h-full",children:p.jsxs("div",{className:"max-w-md w-full flex flex-col gap-2",children:[p.jsx("div",{className:"text-[12px] uppercase tracking-[0.08em] text-white/35 font-medium text-left",children:"Try one of these"}),["The quick brown fox jumps over the lazy dog.","Embeddings turn text into a vector you can search by meaning.","San Francisco is a city in northern California known for its fog and bridges."].map(A=>p.jsx("button",{type:"button",onClick:()=>c(A),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.14] hover:bg-white/[0.04] transition-all text-[14px] text-white/65 focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",children:A},A))]})}):m?p.jsxs("div",{className:"animate-fade-in flex flex-col gap-4",children:[p.jsxs("div",{className:"flex items-center gap-6 text-[14px]",children:[p.jsx(Bc,{label:"Model",value:m.model}),p.jsx(Bc,{label:"Dimensions",value:String(y)}),p.jsx(Bc,{label:"Tokens",value:String(m.usage.prompt_tokens)})]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[p.jsxs(je,{children:["Vector (",y," dimensions)"]}),p.jsx("button",{onClick:w,className:"text-[13px] text-white/20 hover:text-white/40 transition-colors",children:"Copy"})]}),p.jsx("div",{className:"bg-white/[0.02] border border-white/[0.04] rounded-lg p-4 max-h-[calc(100vh-240px)] overflow-y-auto",children:p.jsxs("code",{className:"text-[14px] text-white/35 font-mono break-all leading-loose",children:["[",b?.map((A,E)=>p.jsxs("span",{children:[p.jsx("span",{className:"text-white/50",children:A.toFixed(6)}),Eju&&p.jsx("span",{className:"text-white/15",children:", ..."}),"]"]})}),y>ju&&p.jsx("button",{onClick:()=>d(!f),className:"text-[13px] text-white/20 hover:text-white/40 mt-2 transition-colors",children:f?`Show first ${ju}`:`Show all ${y} values`})]})]}):p.jsx(zu,{children:"Embedding vectors appear here"})});return p.jsx(tr,{controls:k,output:N})}function Bc({label:n,value:l}){return p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"text-white/20",children:n}),p.jsx("span",{className:"text-white/55 bg-white/[0.03] border border-white/[0.04] rounded px-2 py-0.5 font-mono text-[13px]",children:l})]})}class gx extends q.Component{state={error:null};static getDerivedStateFromError(l){return{error:l}}componentDidCatch(l,a){this.props.onError&&this.props.onError(l,a),console.error("[OpenVenice ErrorBoundary]",l,a)}reset=()=>this.setState({error:null});render(){return this.state.error?this.props.fallback?this.props.fallback({error:this.state.error,reset:this.reset}):p.jsx(C5,{error:this.state.error,reset:this.reset}):this.props.children}}function C5({error:n,reset:l}){return p.jsx("div",{className:"flex flex-col items-center justify-center h-full px-6 text-center",role:"alert",children:p.jsxs("div",{className:"max-w-md",children:[p.jsx("div",{className:"text-[20px] font-semibold text-white/85 mb-2",children:"Something went wrong"}),p.jsx("p",{className:"text-[14px] text-white/40 mb-4",children:"The app hit an unexpected error and couldn't render this view. Your work is safe — refresh to recover."}),p.jsxs("details",{className:"mb-5 text-left",children:[p.jsx("summary",{className:"text-[13px] text-white/30 cursor-pointer hover:text-white/55",children:"Show details"}),p.jsxs("pre",{className:"mt-2 text-[12px] text-red-300/70 bg-white/[0.03] border border-white/[0.06] rounded-lg p-3 overflow-auto max-h-40 whitespace-pre-wrap break-words",children:[n.message,n.stack?` -${n.stack}`:""]})]}),p.jsxs("div",{className:"flex gap-2 justify-center",children:[p.jsx("button",{onClick:l,className:"px-4 py-2 text-[14px] font-medium bg-white text-black rounded-md hover:bg-white/90 transition-colors",children:"Try again"}),p.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 text-[14px] font-medium border border-white/[0.1] text-white/60 hover:text-white/80 hover:border-white/[0.2] rounded-md transition-colors",children:"Reload page"})]})]})})}const E5={info:"border-white/[0.08] bg-[#111]",success:"border-green-500/30 bg-green-500/[0.06]",error:"border-red-500/30 bg-red-500/[0.06]"},j5={info:"text-white/75",success:"text-green-200/85",error:"text-red-200/85"};function T5(){const n=Ql(a=>a.toasts),l=Ql(a=>a.dismiss);return n.length===0?null:p.jsx("div",{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2 max-w-sm pointer-events-none",role:"region","aria-live":"polite","aria-label":"Notifications",children:n.map(a=>p.jsx("div",{role:a.variant==="error"?"alert":"status",className:Te("pointer-events-auto rounded-lg border px-3.5 py-2.5 shadow-xl shadow-black/60 backdrop-blur-md animate-scale-in",E5[a.variant]),children:p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:Te("text-[13.5px] font-medium",j5[a.variant]),children:a.title}),a.description&&p.jsx("div",{className:"text-[12.5px] text-white/45 mt-0.5 leading-relaxed break-words",children:a.description}),a.action&&p.jsx("button",{onClick:()=>{a.action?.onClick(),l(a.id)},className:"mt-1.5 text-[12.5px] font-medium text-white/70 hover:text-white underline underline-offset-2",children:a.action.label})]}),p.jsx("button",{onClick:()=>l(a.id),"aria-label":"Dismiss notification",className:"text-white/25 hover:text-white/60 transition-colors p-0.5 -m-0.5 shrink-0 rounded focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/30",children:p.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})},a.id))})}const A5=q.lazy(()=>ay(()=>import("./workflows-view-CqSB6AnK.js"),__vite__mapDeps([0,1,2])).then(n=>({default:n.WorkflowsView})));function _5(){return p.jsx(q.Suspense,{fallback:p.jsx("div",{className:"flex items-center justify-center h-full text-[12px] text-white/30",children:"Loading workflows…"}),children:p.jsx(A5,{})})}const M5=q.lazy(()=>ay(()=>import("./playground-view-BLUXm2C6.js"),__vite__mapDeps([3,1,2])).then(n=>({default:n.PlaygroundView})));function N5(){return p.jsx(q.Suspense,{fallback:p.jsx("div",{className:"flex items-center justify-center h-full text-[12px] text-white/30",children:"Loading playground…"}),children:p.jsx(M5,{})})}const O5={chat:XE,image:l5,audio:c5,music:m5,video:v5,embeddings:k5,workflows:_5,playground:N5},Ig=["chat","image","audio","music","video","embeddings","workflows","playground"];function z5(){const n=gn(g=>g.hasEncrypted&&!g.apiKey),[l,a]=q.useState(n),[u,s]=q.useState(!1),c=on(g=>g.activeTab),f=on(g=>g.setActiveTab),d=O5[c];return q.useEffect(()=>{const g=m=>{if(!(m.metaKey||m.ctrlKey))return;if(m.key==="n"){m.preventDefault(),f("chat"),s(!1),xt.getState().setActiveConversation(null);return}const y=parseInt(m.key,10);if(y>=1&&y<=Ig.length){m.preventDefault(),f(Ig[y-1]),s(!1);return}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[f]),p.jsxs("div",{className:"flex h-[100dvh] w-screen overflow-hidden",children:[u&&p.jsx("button",{"aria-label":"Close menu",className:"md:hidden fixed inset-0 z-30 bg-black/60 backdrop-blur-sm animate-fade-in",onClick:()=>s(!1)}),p.jsx(Kv,{mobileOpen:u,onMobileClose:()=>s(!1)}),p.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[p.jsx(fb,{onOpenApiKey:()=>a(!0),onOpenMobileSidebar:()=>s(!0)}),p.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:p.jsx(gx,{children:p.jsx(d,{})},c)})]}),p.jsx(db,{open:l,onClose:()=>a(!1)}),p.jsx(T5,{})]})}const D5=new cv({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});window.addEventListener("unhandledrejection",n=>{console.error("[unhandledrejection]",n.reason)});q1.createRoot(document.getElementById("root")).render(p.jsx(q.StrictMode,{children:p.jsx(gx,{children:p.jsx(fv,{client:D5,children:p.jsx(z5,{})})})}));export{on as A,af as B,lf as C,U1 as D,qu as E,oy as F,nv as Q,vu as R,Gn as S,Fl as a,Kg as b,Te as c,ny as d,hv as e,pv as f,Nv as g,vv as h,gv as i,p as j,yv as k,Et as l,wv as m,ct as n,Xp as o,xv as p,Bu as q,q as r,Mu as s,Fi as t,Si as u,ry as v,ff as w,uy as x,Ji as y,gn as z}; +${n.stack}`:""]})]}),p.jsxs("div",{className:"flex gap-2 justify-center",children:[p.jsx("button",{onClick:l,className:"px-4 py-2 text-[14px] font-medium bg-white text-black rounded-md hover:bg-white/90 transition-colors",children:"Try again"}),p.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 text-[14px] font-medium border border-white/[0.1] text-white/60 hover:text-white/80 hover:border-white/[0.2] rounded-md transition-colors",children:"Reload page"})]})]})})}const E5={info:"border-white/[0.08] bg-[#111]",success:"border-green-500/30 bg-green-500/[0.06]",error:"border-red-500/30 bg-red-500/[0.06]"},j5={info:"text-white/75",success:"text-green-200/85",error:"text-red-200/85"};function T5(){const n=Ql(a=>a.toasts),l=Ql(a=>a.dismiss);return n.length===0?null:p.jsx("div",{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2 max-w-sm pointer-events-none",role:"region","aria-live":"polite","aria-label":"Notifications",children:n.map(a=>p.jsx("div",{role:a.variant==="error"?"alert":"status",className:Te("pointer-events-auto rounded-lg border px-3.5 py-2.5 shadow-xl shadow-black/60 backdrop-blur-md animate-scale-in",E5[a.variant]),children:p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:Te("text-[13.5px] font-medium",j5[a.variant]),children:a.title}),a.description&&p.jsx("div",{className:"text-[12.5px] text-white/45 mt-0.5 leading-relaxed break-words",children:a.description}),a.action&&p.jsx("button",{onClick:()=>{a.action?.onClick(),l(a.id)},className:"mt-1.5 text-[12.5px] font-medium text-white/70 hover:text-white underline underline-offset-2",children:a.action.label})]}),p.jsx("button",{onClick:()=>l(a.id),"aria-label":"Dismiss notification",className:"text-white/25 hover:text-white/60 transition-colors p-0.5 -m-0.5 shrink-0 rounded focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/30",children:p.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})},a.id))})}const A5=q.lazy(()=>ay(()=>import("./workflows-view-C9DNDVch.js"),__vite__mapDeps([0,1,2])).then(n=>({default:n.WorkflowsView})));function _5(){return p.jsx(q.Suspense,{fallback:p.jsx("div",{className:"flex items-center justify-center h-full text-[12px] text-white/30",children:"Loading workflows…"}),children:p.jsx(A5,{})})}const M5=q.lazy(()=>ay(()=>import("./playground-view-B6WRI_IZ.js"),__vite__mapDeps([3,1,2])).then(n=>({default:n.PlaygroundView})));function N5(){return p.jsx(q.Suspense,{fallback:p.jsx("div",{className:"flex items-center justify-center h-full text-[12px] text-white/30",children:"Loading playground…"}),children:p.jsx(M5,{})})}const O5={chat:XE,image:l5,audio:c5,music:m5,video:v5,embeddings:k5,workflows:_5,playground:N5},Ig=["chat","image","audio","music","video","embeddings","workflows","playground"];function z5(){const n=gn(g=>g.hasEncrypted&&!g.apiKey),[l,a]=q.useState(n),[u,s]=q.useState(!1),c=on(g=>g.activeTab),f=on(g=>g.setActiveTab),d=O5[c];return q.useEffect(()=>{const g=m=>{if(!(m.metaKey||m.ctrlKey))return;if(m.key==="n"){m.preventDefault(),f("chat"),s(!1),xt.getState().setActiveConversation(null);return}const y=parseInt(m.key,10);if(y>=1&&y<=Ig.length){m.preventDefault(),f(Ig[y-1]),s(!1);return}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[f]),p.jsxs("div",{className:"flex h-[100dvh] w-screen overflow-hidden",children:[u&&p.jsx("button",{"aria-label":"Close menu",className:"md:hidden fixed inset-0 z-30 bg-black/60 backdrop-blur-sm animate-fade-in",onClick:()=>s(!1)}),p.jsx(Kv,{mobileOpen:u,onMobileClose:()=>s(!1)}),p.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[p.jsx(fb,{onOpenApiKey:()=>a(!0),onOpenMobileSidebar:()=>s(!0)}),p.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:p.jsx(gx,{children:p.jsx(d,{})},c)})]}),p.jsx(db,{open:l,onClose:()=>a(!1)}),p.jsx(T5,{})]})}const D5=new cv({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});window.addEventListener("unhandledrejection",n=>{console.error("[unhandledrejection]",n.reason)});q1.createRoot(document.getElementById("root")).render(p.jsx(q.StrictMode,{children:p.jsx(gx,{children:p.jsx(fv,{client:D5,children:p.jsx(z5,{})})})}));export{on as A,af as B,lf as C,U1 as D,qu as E,oy as F,nv as Q,vu as R,Gn as S,Fl as a,Kg as b,Te as c,ny as d,hv as e,pv as f,Nv as g,vv as h,gv as i,p as j,yv as k,Et as l,wv as m,ct as n,Xp as o,xv as p,Bu as q,q as r,Mu as s,Fi as t,Si as u,ry as v,ff as w,uy as x,Ji as y,gn as z}; diff --git a/ventures/havre/open/assets/playground-view-B6WRI_IZ.js b/ventures/havre/open/assets/playground-view-B6WRI_IZ.js new file mode 100644 index 0000000..932ccd0 --- /dev/null +++ b/ventures/havre/open/assets/playground-view-B6WRI_IZ.js @@ -0,0 +1,86 @@ +import{a as ne,n as D,s as re,b as oe,Q as Z,d as ie,e as ae,f as le,r as b,h as ce,i as de,k as ue,l as pe,m as B,o as he,p as me,q as fe,v as ge,w as xe,x as we,y as F,u as be,g as U,z as ye,A as V,j as r,c as R,t as Q}from"./index-fmJ2VqHZ.js";import{g as ve,N as O,h as ke,H as J,P as z,R as je,b as Ne,c as Se,a as _e,i as Re,B as $e,e as Te,C as Ce,u as L,v as Oe,f as Ee}from"./workflow-engine-BuXGtBGn.js";function H(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function Pe(e,t,n){const s=e.slice(0);return s[t]=n,s}var Me=class extends ne{#n;#e;#r;#o;#t;#s;#i;#a;#l;#c=[];constructor(e,t,n){super(),this.#n=e,this.#o=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#o=t,D.batch(()=>{const n=this.#t,s=this.#p(this.#r);s.forEach(p=>p.observer.setOptions(p.defaultedQueryOptions));const o=s.map(p=>p.observer),i=o.map(p=>p.getCurrentResult()),a=n.length!==o.length,l=o.some((p,h)=>p!==n[h]),d=a||l,x=d?!0:i.some((p,h)=>{const w=this.#e[h];return!w||!re(p,w)});!d&&!x||(d&&(this.#c=s,this.#t=o),this.#e=i,this.hasListeners()&&(d&&(H(n,o).forEach(p=>{p.destroy()}),H(o,n).forEach(p=>{p.subscribe(h=>{this.#h(p,h)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#p(e),s=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[s,i=>this.#u(i??s,t,o),()=>this.#d(s,n)]}#d(e,t){return t.map((n,s)=>{const o=e[s];return n.defaultedQueryOptions.notifyOnChangeProps?o:n.observer.trackResult(o,i=>{t.forEach(a=>{a.observer.trackProp(i)})})})}#u(e,t,n){if(t){const s=this.#l,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((i,a)=>i!==s[a]));return(!this.#s||this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,n!==void 0&&(this.#l=n),this.#s=oe(this.#s,t(e))),this.#s}return e}#p(e){const t=new Map;this.#t.forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#n.defaultQueryOptions(s),a=t.get(o.queryHash)?.shift()??new Z(this.#n,o);n.push({defaultedQueryOptions:o,observer:a})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Pe(this.#e,n,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),n=this.#u(t,this.#o?.combine);e!==n&&D.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function Ae({queries:e,...t},n){const s=ie(),o=ae(),i=le(),a=b.useMemo(()=>e.map(m=>{const u=s.defaultQueryOptions(m);return u._optimisticResults=o?"isRestoring":"optimistic",u}),[e,s,o]);a.forEach(m=>{ce(m);const u=s.getQueryCache().get(m.queryHash);de(m,i,u)}),ue(i);const[l]=b.useState(()=>new Me(s,a,t)),[d,x,p]=l.getOptimisticResult(a,t.combine),h=!o&&t.subscribed!==!1;b.useSyncExternalStore(b.useCallback(m=>h?l.subscribe(D.batchCalls(m)):pe,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),b.useEffect(()=>{l.setQueries(a,t)},[a,t,l]);const y=d.some((m,u)=>B(a[u],m))?d.flatMap((m,u)=>{const g=a[u];if(g&&B(g,m)){const N=new Z(s,g);return he(g,N,i)}return[]}):[];if(y.length>0)throw Promise.all(y);const $=d.find((m,u)=>{const g=a[u];return g&&me({result:m,errorResetBoundary:i,throwOnError:g.throwOnError,query:s.getQueryCache().get(g.queryHash),suspense:g.suspense})});if($?.error)throw $.error;return x(p())}const S=fe()(ge((e,t)=>({messages:[],draft:{nodes:[],edges:[]},linkedWorkflowId:null,isThinking:!1,runResults:{},isRunning:!1,addMessage:n=>e(s=>({messages:[...s.messages,n]})),updateMessage:(n,s)=>e(o=>({messages:o.messages.map(i=>i.id===n?{...i,...s}:i)})),setThinking:n=>e({isThinking:n}),applyAgentPatches:n=>{const{nodes:s,edges:o}=t().draft,i=ve({nodes:s,edges:o},n);return e({draft:{nodes:i.nodes,edges:i.edges},runResults:{}}),i},resetDraft:()=>e({draft:{nodes:[],edges:[]},runResults:{},linkedWorkflowId:null}),clearConversation:()=>e({messages:[],draft:{nodes:[],edges:[]},runResults:{},linkedWorkflowId:null}),setRunResults:n=>e({runResults:n}),updateRunNode:(n,s)=>e(o=>({runResults:{...o.runResults,[n]:{...o.runResults[n],...s}}})),setIsRunning:n=>e({isRunning:n}),clearResults:()=>e({runResults:{}}),loadWorkflow:(n,s,o)=>e({draft:{nodes:s,edges:o},linkedWorkflowId:n,runResults:{},messages:[]}),unlinkWorkflow:()=>e({linkedWorkflowId:null})}),{name:"venice-playground",version:1,storage:xe(()=>we()),partialize:e=>({messages:e.messages.slice(-40),draft:e.draft,linkedWorkflowId:e.linkedWorkflowId})})),We=["text","image","tts","music","video"];function q(e){return e?e.data.filter(t=>!t.model_spec?.offline).map(t=>t.id).sort():[]}function qe(){const e=Ae({queries:We.map(s=>({queryKey:["models",s],queryFn:()=>F(`/models?type=${s}`,{noAuth:!0}),staleTime:3e5}))}),t={text:q(e[0].data),image:q(e[1].data),tts:q(e[2].data),music:q(e[3].data),video:q(e[4].data)},n=e.some(s=>s.isLoading);return{catalog:t,isLoading:n}}const Ie=["function_calling_default","most_intelligent","default"],Le=new Set(["qwen3-next-80b","zai-org-glm-4.7","mistral-small-3-2-24b-instruct"]);function Ve(e){if((e.model_spec?.traits??[]).some(s=>Ie.includes(s))||Le.has(e.id))return 0;const n=e.model_spec?.capabilities??{};return n.supportsResponseSchema&&n.supportsFunctionCalling?n.supportsReasoning?2:1:n.supportsResponseSchema||n.supportsFunctionCalling?2:3}function ee(){const{data:e,isLoading:t}=be("text");return{models:b.useMemo(()=>e?e.filter(s=>!s.model_spec?.offline).map(s=>{const o=s.model_spec?.capabilities??{},i=s.model_spec?.traits??[],a=Ve(s);return{id:s.id,name:s.model_spec?.name||s.id,capabilities:o,traits:i,contextTokens:s.model_spec?.availableContextTokens,recommended:a===0,tier:a,reasoning:o.supportsReasoning===!0,uncensored:i.includes("most_uncensored")}}).sort((s,o)=>s.tier!==o.tier?s.tier-o.tier:s.name.localeCompare(o.name)):[],[e]),isLoading:t}}const De=new Set(["add_node","remove_node","set_params","move_node","connect","disconnect","clear"]),te="qwen3-next-80b";function Ue(){return Object.values(O).map(e=>{const t=e.params.map(n=>{const s=[`${n.name}: ${n.type}${n.required?" (required)":""}`];return n.default!==void 0&&n.default!==""&&s.push(`default=${JSON.stringify(n.default)}`),n.enumValues&&s.push(`one of [${n.enumValues.filter(Boolean).join(", ")}]`),(n.min!==void 0||n.max!==void 0)&&s.push(`range ${n.min??"-"}..${n.max??"-"}`),` - ${s.join(" — ")}`}).join(` +`);return`- ${e.type} (${e.label}) | input=${e.input} output=${e.output} + ${e.description}${t?` + params: +${t}`:""}`}).join(` + +`)}function Fe(e){if(!e)return"";const t=[];return e.text.length&&t.push(`chat: ${e.text.join(", ")}`),e.image.length&&t.push(`imageGen: ${e.image.join(", ")}`),e.tts.length&&t.push(`tts: ${e.tts.join(", ")}`),e.music.length&&t.push(`music: ${e.music.join(", ")}`),e.video.length&&t.push(`video: ${e.video.join(", ")}`),t.length===0?"":` + +Available models per node type (use ONLY these ids; pick the one that best matches the user's intent or use the default if no preference): +${t.map(n=>`- ${n}`).join(` +`)}`}const Be=`You are a workflow designer for OpenVenice. You help the user author visual workflows that chain Venice AI models. + +You have these node types available: + +${Ue()} + +You respond by emitting patches to mutate the current draft workflow. Each patch is one of: +- {"op":"add_node","nodeType":"","id":"optional_id","params":{...}} — add a new node +- {"op":"set_params","id":"","params":{...}} — update a node's params +- {"op":"connect","source":"","target":""} — connect two nodes +- {"op":"disconnect","id":""} — remove an edge +- {"op":"remove_node","id":""} — remove a node +- {"op":"clear"} — remove all nodes and edges + +RULES: +1. Every response MUST be a single valid JSON object, nothing before or after. Do not wrap in markdown fences. +2. Schema: {"say": string, "patches": Array}. +3. "say" is a short (1–3 sentences) narration of what you just did or a question to the user. +4. When building a new workflow from scratch, start with {"op":"clear"} then add nodes top-to-bottom and connect them. +5. Always assign explicit ids when adding multiple nodes in one turn so you can reference them in connect patches. +6. Workflows need at least one textInput (or a generation node with a self-contained prompt) and an output node at the end. +7. Use {{input}} inside a node's prompt to place upstream text precisely, or leave prompt empty to append input after. +7b. To show a picture while a sound plays (cover + track, still + narration), add a "compose" node with one imageGen and one music/tts node connected into it, then connect it to an output. It has no model or prompt. Video models cannot take audio, so never connect music or tts to a video node. +8. Keep to the param names and enum values listed above. Omit params to accept defaults. +9. If the user just asks a question, respond with a "say" and an empty "patches" array. +10. Do not narrate patches you aren't emitting. Do not produce commentary outside the JSON. + +Example response: +{"say":"I built a pipeline that researches a topic, summarizes it, and narrates the summary.","patches":[{"op":"clear"},{"op":"add_node","nodeType":"textInput","id":"in","params":{"inputText":"Quantum computing progress in 2025"}},{"op":"add_node","nodeType":"chat","id":"research","params":{"prompt":"Research this topic thoroughly.","webSearch":"on"}},{"op":"add_node","nodeType":"chat","id":"summary","params":{"prompt":"Summarize into 5 bullet points.","temperature":0.3}},{"op":"add_node","nodeType":"tts","id":"narrate","params":{"voice":"af_sky"}},{"op":"add_node","nodeType":"output","id":"out"},{"op":"connect","source":"in","target":"research"},{"op":"connect","source":"research","target":"summary"},{"op":"connect","source":"summary","target":"narrate"},{"op":"connect","source":"narrate","target":"out"}]}`;function Qe(e){return Be+Fe(e)}function Je(e){if(e.nodes.length===0)return"Current draft is empty.";const t=e.nodes.map(s=>{const o=[],i=s.data;for(const a of O[s.data.nodeType]?.params??[]){const l=i[a.name];if(l!==void 0&&l!==""&&l!==null){const d=typeof l=="string"?l.length>60?l.slice(0,60)+"…":l:JSON.stringify(l);o.push(`${a.name}=${d}`)}}return` - ${s.id} [${s.data.nodeType}] ${o.join(" ")}`}),n=e.edges.map(s=>` - ${s.id}: ${s.source} → ${s.target}`);return`Current draft: +Nodes: +${t.join(` +`)} +Edges: +${n.join(` +`)||" (none)"}`}function ze(e){const t=e.trim(),n=t.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)return n[1].trim();const s=t.indexOf("{"),o=t.lastIndexOf("}");return s!==-1&&o!==-1&&o>s?t.slice(s,o+1):t}function He(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.op!="string"||!De.has(t.op))return!1;switch(t.op){case"clear":return!0;case"add_node":return typeof t.nodeType=="string"&&t.nodeType in O;case"remove_node":case"disconnect":return typeof t.id=="string"&&t.id.length>0;case"set_params":return typeof t.id=="string"&&t.id.length>0&&typeof t.params=="object"&&t.params!==null;case"move_node":return typeof t.id=="string"&&typeof t.position=="object"&&t.position!==null;case"connect":return typeof t.source=="string"&&typeof t.target=="string"&&t.source!==t.target}return!1}function Ye(e,t){const n=O[e];if(!n)return{};const s=new Set(["model","prompt",...n.params.map(i=>i.name)]),o={};for(const[i,a]of Object.entries(t))s.has(i)&&(o[i]=a);return o}function Y(e){const t=ze(e);let n;try{n=JSON.parse(t)}catch{return{say:"",patches:[],invalidPatches:0}}const s=typeof n.say=="string"?n.say:"",o=Array.isArray(n.patches)?n.patches:[],i=[];let a=0;for(const l of o){if(!He(l)){a++;continue}l.op==="add_node"&&l.params?i.push({...l,params:Ye(l.nodeType,l.params)}):(l.op,i.push(l))}return{say:s,patches:i,invalidPatches:a}}async function G(e){const t={model:e.model,messages:e.messages,temperature:e.temperature,max_tokens:4096};return e.useResponseFormat&&(t.response_format={type:"json_object"}),(await F("/chat/completions",{method:"POST",body:JSON.stringify(t),signal:e.signal})).choices[0]?.message?.content??""}async function Ge({userMessage:e,draft:t,history:n,catalog:s,model:o,capabilities:i,signal:a}){const l=o,d=i?.supportsResponseSchema===!0,x=[{role:"system",content:Qe(s)},...n.map(w=>({role:w.role,content:w.content})),{role:"user",content:`${Je(t)} + +User: ${e} + +Reply with a single JSON object: {"say": "...", "patches": [...]}. No prose, no markdown fences.`}],p=await G({model:l,messages:x,temperature:.3,useResponseFormat:d,signal:a}),h=Y(p);if(h.patches.length===0&&!h.say&&p.length>0){const w=[...x,{role:"assistant",content:p},{role:"user",content:'That was not valid JSON. Reply again with ONLY a single JSON object matching {"say": string, "patches": Patch[]}. No commentary, no fences.'}];try{const y=await G({model:l,messages:w,temperature:0,useResponseFormat:d,signal:a});return Y(y)}catch{}}return h}const Ke=Object.keys(O),Xe=[{type:"function",function:{name:"clear",description:"Remove all nodes and edges. Use when starting a fresh workflow.",parameters:{type:"object",properties:{},additionalProperties:!1}}},{type:"function",function:{name:"add_node",description:'Add a node to the canvas. Returns the assigned id (use it for connect calls). For "params": include only the fields you want to set; defaults apply otherwise. Use {{input}} inside any prompt field to inject upstream text.',parameters:{type:"object",properties:{node_type:{type:"string",enum:Ke,description:"The kind of node to add."},id:{type:"string",description:"Optional explicit id. If omitted, a uuid is generated. Use this id in subsequent connect/set_params calls."},params:{type:"object",description:"Node-specific params (model, prompt, temperature, etc). See system prompt for the full schema per node type.",additionalProperties:!0}},required:["node_type"],additionalProperties:!1}}},{type:"function",function:{name:"connect",description:"Connect two nodes (data flows from source to target).",parameters:{type:"object",properties:{source:{type:"string",description:"Source node id."},target:{type:"string",description:"Target node id."}},required:["source","target"],additionalProperties:!1}}},{type:"function",function:{name:"set_params",description:"Update params on an existing node. Merged with current params.",parameters:{type:"object",properties:{id:{type:"string"},params:{type:"object",additionalProperties:!0}},required:["id","params"],additionalProperties:!1}}},{type:"function",function:{name:"remove_node",description:"Remove a node and all its connected edges.",parameters:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1}}},{type:"function",function:{name:"pick_model",description:"Get a recommended model id for a node type, optionally biased by preference. Use this BEFORE add_node if unsure which id to use — you will get back an id you can pass directly.",parameters:{type:"object",properties:{node_type:{type:"string",enum:["chat","imageGen","tts","music","video","compose"]},prefer:{type:"string",enum:["fast","best","web","reasoning","uncensored"],description:"'fast' = cheap & quick (default), 'best' = highest quality, 'web' = native web search, 'reasoning' = chain-of-thought, 'uncensored' = no refusals."}},required:["node_type"],additionalProperties:!1}}},{type:"function",function:{name:"ask_user",description:'Pause the build to ask the user a clarifying question (e.g., "Vertical (9:16) or square (1:1)?"). The build will resume on their reply.',parameters:{type:"object",properties:{question:{type:"string"}},required:["question"],additionalProperties:!1}}},{type:"function",function:{name:"done",description:"Signal the workflow is complete. Provide a one-sentence summary of what you built for the user.",parameters:{type:"object",properties:{summary:{type:"string"}},required:["summary"],additionalProperties:!1}}}];function Ze(){return Object.values(O).map(e=>{const t=e.params.map(n=>{const s=[`${n.name}: ${n.type}${n.required?" (required)":""}`];return n.default!==void 0&&n.default!==""&&s.push(`default=${JSON.stringify(n.default)}`),n.enumValues&&s.push(`one of [${n.enumValues.filter(Boolean).join(", ")}]`),(n.min!==void 0||n.max!==void 0)&&s.push(`range ${n.min??"-"}..${n.max??"-"}`),` - ${s.join(" — ")}`}).join(` +`);return`- ${e.type} (${e.label}) | input=${e.input} output=${e.output} + ${e.description}${t?` + params: +${t}`:""}`}).join(` + +`)}const et=`You are a workflow designer for OpenVenice. You build visual workflows that chain Venice AI models by calling tools. + +Available node types: + +${Ze()} + +How you work: +1. Use the provided tools — never reply with prose-only when actions are needed. +2. For a fresh build, call clear() first, then add_node(...) for each step, then connect(source, target) edges, then done(summary). +3. Always assign explicit ids when adding nodes (e.g., id="research", "script", "video"), so you can reference them in connect/set_params calls. +4. **Templates**: Inside any prompt/inputText field, use {{input}} to inject the concatenated text from upstream parents. There is no {{node_id}} syntax — referencing other nodes by name does NOT work. Each node only sees {{input}} = its parents' outputs joined. +5. **No placeholder content**: write inputText fields with realistic example content the user will likely keep, not "Enter the topic here". +6. **Model ids must come from the live Venice catalog** — DO NOT guess names like "suno-v3" or "runway-gen-2". When in doubt, call pick_model({node_type, prefer}) FIRST and use its returned id. add_node will reject unknown model ids and tell you to call pick_model. +7. **Cost & speed**: prefer fast cheap chat models (qwen3-next-80b, mistral-small-3-2-24b-instruct, zai-org-glm-4.7). Only escalate to claude-opus or qwen-thinking when the task explicitly demands top reasoning. Use pick_model with prefer="fast" by default, "best" for premium quality, "web" for native search, "reasoning" for analysis-heavy tasks. +8. **Web search**: only useful on chat nodes whose model has supportsWebSearch. pick_model({node_type:"chat", prefer:"web"}) returns a good one. +9. **For social-video / reel requests**: canonical shape is textInput → chat(research, web) → chat(script) → video (9:16, 1080p, 5-10s) → output. Video models cannot take an audio track, so never connect music or tts to a video node. +9b. **To combine a picture with a sound** (a cover that shows while a track plays, a slideshow still with narration, a music video from a still): use a compose node ("Cover + Track"). Connect one imageGen node and one music (or tts) node into it, and connect it to an output. It has no model and no prompt. Shape: textInput → imageGen (cover) and textInput → music (track), both → compose → output. The output is one video file the user can preview and download. +10. If the request is ambiguous (which platform? which style?), call ask_user with one specific question. +11. End every successful build with done(summary). + +Workflows must terminate at an output node (or the user won't see results). Multiple branches with their own outputs are fine and encouraged for multi-modal results.`,K=16;function tt(e){if(e.nodes.length===0)return"Current draft is empty.";const t=e.nodes.map(s=>` - ${s.id} [${s.data.nodeType}]`).join(` +`),n=e.edges.map(s=>` - ${s.source} → ${s.target}`).join(` +`)||" (none)";return`Current draft: +Nodes: +${t} +Edges: +${n}`}function st(e,t,n){const s=n.catalog;return s?e==="chat"?s.text.includes(t):e==="imageGen"?s.image.includes(t):e==="tts"?s.tts.includes(t):e==="music"?s.music.includes(t):e==="video"?s.video.includes(t):!0:!0}function nt(e,t,n){const s=n.catalog;if(!s)return;if(e==="chat"){const i=n.agentModels??[];if(i.length===0)return s.text[0];const a=i.map(l=>{let d=0;const x=l.capabilities;return t==="web"&&(d+=x.supportsWebSearch?100:0),t==="reasoning"&&(d+=x.supportsReasoning?100:0),t==="uncensored"&&(d+=l.uncensored?100:0),t==="best"&&(l.traits.includes("most_intelligent")&&(d+=80),l.contextTokens&&l.contextTokens>=2e5&&(d+=20)),(t==="fast"||!t)&&(x.supportsReasoning&&(d-=30),l.traits.includes("function_calling_default")&&(d+=50),l.recommended&&(d+=30)),x.supportsResponseSchema&&(d+=10),d-=l.tier*5,{id:l.id,score:d}});return a.sort((l,d)=>d.score-l.score),a[0]?.id}return(e==="imageGen"?s.image:e==="tts"?s.tts:e==="music"?s.music:e==="video"?s.video:[])[0]}function rt(e){if(!e)return{};try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function ot(e,t,n){try{switch(e){case"clear":return n.applyPatch({op:"clear"}),{ok:!0};case"add_node":{const s=t.node_type;if(!s||!(s in O))return{error:`Unknown node_type: ${String(s)}`};const o=typeof t.id=="string"&&t.id||U(),i=typeof t.params=="object"&&t.params!==null?t.params:{},a=i.model;if(typeof a=="string"&&a.length>0&&!st(s,a,n))return{error:`Unknown model '${a}' for ${s}. Call pick_model({node_type:'${s==="chat"?"chat":s}'}) to get a valid id, then retry add_node with that id.`};const l=O[s],d=new Set(["model","prompt",...l.params.map(h=>h.name)]),x={};for(const[h,w]of Object.entries(i))d.has(h)&&(x[h]=w);for(const h of l.params)if(h.enumValues&&x[h.name]!==void 0){const w=x[h.name];if(typeof w=="boolean"){x[h.name]=w?h.enumValues.includes("on")?"on":h.enumValues[0]:h.enumValues.includes("off")?"off":"";continue}if(typeof w!="string"||!h.enumValues.includes(w))return{error:`Invalid value for ${s}.${h.name}: ${JSON.stringify(w)}. Must be one of [${h.enumValues.filter(Boolean).join(", ")}].`}}const p=n.applyPatch({op:"add_node",nodeType:s,id:o,params:x});return"error"in p?{error:p.error}:{ok:!0,id:p.id??o}}case"connect":{const s=String(t.source??""),o=String(t.target??"");if(!s||!o)return{error:"Both source and target are required."};const i=n.applyPatch({op:"connect",source:s,target:o});return"error"in i?{error:i.error}:{ok:!0,edge_id:i.edge_id}}case"set_params":{const s=String(t.id??""),o=typeof t.params=="object"&&t.params!==null?t.params:{},i=n.applyPatch({op:"set_params",id:s,params:o});return"error"in i?{error:i.error}:{ok:!0}}case"remove_node":{const s=String(t.id??""),o=n.applyPatch({op:"remove_node",id:s});return"error"in o?{error:o.error}:{ok:!0}}case"pick_model":{const s=String(t.node_type??""),o=typeof t.prefer=="string"?t.prefer:void 0,i=nt(s,o,n);return i?{ok:!0,model:i}:{error:`No model available for ${s}`}}case"ask_user":return{ok:!0,message:String(t.question??"")};case"done":return{ok:!0,message:String(t.summary??"Done.")}}return{error:`Unknown tool: ${e}`}}catch(s){return{error:s instanceof Error?s.message:"Tool failed"}}}async function it(e){const t=[{role:"system",content:et},...e.history.map(o=>o.role==="user"?{role:"user",content:o.content}:{role:"assistant",content:o.content}),{role:"user",content:`${tt(e.draft)} + +User request: ${e.userMessage}`}];let n=0,s=!1;for(let o=0;of.apiKey!==null),d=V(f=>f.playgroundAgentModel)||te,{catalog:x}=qe(),{models:p}=ee(),h=p.find(f=>f.id===d)?.capabilities,[w,y]=b.useState(""),[$,m]=b.useState(null),u=b.useRef(null),g=b.useRef(null);b.useEffect(()=>{u.current?.scrollTo({top:u.current.scrollHeight,behavior:"smooth"})},[e,n]);const N=async f=>{const C=f.trim();if(!C||n)return;if(!l){m("Connect your Venice API key first.");return}m(null),y("");const P={id:U(),role:"user",content:C},E={id:U(),role:"assistant",content:"",pending:!0,activity:[]};s(P),s(E),i(!0),g.current?.abort();const A=new AbortController;g.current=A;const I=e.filter(T=>!T.pending&&!T.error).slice(-10).map(T=>({role:T.role,content:T.content}));try{if(h?.supportsFunctionCalling===!0){const k=[],W=await it({userMessage:C,draft:t,history:I,catalog:x,agentModels:p,model:d,capabilities:h,signal:A.signal,applyPatch:c=>{try{const j=S.getState().draft,v=ke({nodes:j.nodes,edges:j.edges},c);return S.setState({draft:{nodes:v.nodes,edges:v.edges}}),{ok:!0,id:v.addedNodeId,edge_id:v.addedEdgeId}}catch(j){return{error:j instanceof Error?j.message:"Patch failed"}}},onStep:c=>{k.push(lt(c)),o(E.id,{activity:[...k]})}});o(E.id,{content:W.say||"Done.",activity:k,pending:!1})}else{const k=await Ge({userMessage:C,draft:t,history:I,catalog:x,model:d,capabilities:h,signal:A.signal});let W;try{k.patches.length>0&&a(k.patches)}catch(v){W=v instanceof Error?v.message:"Failed to apply patches"}const c=k.invalidPatches>0?` (${k.invalidPatches} invalid patch${k.invalidPatches===1?"":"es"} ignored)`:"",j=k.patches.length===0&&!k.say?"The agent returned an unparseable response. Try a different model from the picker above, or simplify the request.":k.say||(k.patches.length>0?"Updated the workflow.":"");o(E.id,{content:j+c,patches:k.patches,error:W,pending:!1})}}catch(T){if(A.signal.aborted)o(E.id,{content:"",error:"Cancelled",pending:!1});else{const k=T instanceof Error?T.message:"Agent request failed";o(E.id,{content:"",error:k,pending:!1})}}finally{i(!1),g.current=null}},_=()=>{g.current?.abort()};return r.jsxs("div",{className:"flex flex-col h-full bg-[#0c0c10]",children:[r.jsx("div",{ref:u,className:"flex-1 overflow-y-auto px-4 py-4",children:e.length===0?r.jsxs("div",{className:"flex flex-col gap-3 pt-8",children:[r.jsx("div",{className:"text-[15px] text-white/85 font-semibold mb-1",children:"What should I build?"}),r.jsx("div",{className:"text-[13px] text-white/45 mb-4",children:"Describe a workflow in plain language. I'll assemble it on the canvas in real time."}),r.jsx("div",{className:"flex flex-col gap-2",children:at.map(f=>r.jsx("button",{onClick:()=>N(f),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.16] hover:bg-white/[0.04] transition-all text-[13px] text-white/65 hover:text-white/85 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)] focus-visible:outline-offset-2",children:f},f))})]}):r.jsx("div",{className:"flex flex-col gap-3",children:e.map(f=>r.jsxs("div",{className:R("flex flex-col gap-1.5",f.role==="user"?"items-end":"items-start"),children:[r.jsx("div",{className:R("max-w-[88%] px-3.5 py-2 rounded-xl text-[13.5px] leading-relaxed whitespace-pre-wrap",f.role==="user"?"bg-white/[0.09] text-white border border-white/[0.05]":"bg-white/[0.04] border border-white/[0.07] text-white/85"),children:f.pending&&(!f.activity||f.activity.length===0)?r.jsxs("span",{className:"text-white/45 inline-flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block w-3 h-3 border-2 border-white/20 border-t-[var(--color-accent)] rounded-full animate-spin"}),"Thinking…"]}):f.error?r.jsx("span",{className:"text-red-300/95",children:f.error}):f.content||r.jsx("span",{className:"text-white/35 italic",children:"(no message)"})}),f.activity&&f.activity.length>0&&r.jsxs("div",{className:"max-w-[88%] flex flex-col gap-px text-[11.5px] font-mono text-white/45 px-1",children:[f.activity.map((C,P)=>r.jsxs("div",{className:R("flex items-center gap-1.5",!C.ok&&"text-rose-300/85"),children:[r.jsx("span",{className:"text-white/30",children:"·"}),r.jsx("span",{children:C.summary})]},P)),f.pending&&r.jsxs("div",{className:"flex items-center gap-1.5 text-white/35",children:[r.jsx("span",{className:"inline-block w-2 h-2 border border-white/20 border-t-[var(--color-accent)] rounded-full animate-spin"}),r.jsx("span",{children:"Working…"})]})]}),f.patches&&f.patches.length>0&&!f.activity?.length&&r.jsxs("div",{className:"max-w-[88%] px-3 py-1 text-[11px] text-white/40 font-mono tracking-wide",children:[f.patches.length," patch",f.patches.length===1?"":"es"," applied"]})]},f.id))})}),r.jsxs("div",{className:"shrink-0 border-t border-white/[0.06] p-3",children:[$&&r.jsx("div",{className:"mb-2 text-[13px] text-red-300/95",children:$}),r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("textarea",{value:w,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),N(w))},placeholder:n?"Agent is working…":"Describe a workflow or change…",rows:2,disabled:n,className:"flex-1 bg-white/[0.03] border border-white/[0.08] rounded-lg px-3 py-2 text-[13.5px] text-white/90 outline-none resize-none placeholder:text-white/30 focus:border-white/[0.2] disabled:opacity-60"}),n?r.jsx("button",{onClick:_,className:"shrink-0 px-3 py-2 text-[13px] text-white/85 hover:text-white border border-white/[0.12] hover:bg-white/[0.05] rounded-lg transition-colors",children:"Stop"}):r.jsx("button",{onClick:()=>N(w),disabled:!w.trim(),className:"shrink-0 px-4 py-2 text-[13px] font-medium bg-white text-black rounded-lg hover:bg-white/90 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]})]})}const dt={textInput:"border-blue-500/30",chat:"border-purple-500/30",imageGen:"border-pink-500/30",tts:"border-green-500/30",music:"border-yellow-500/30",video:"border-orange-500/30",compose:"border-cyan-500/30",step:"border-white/20",output:"border-white/20"};function ut({id:e,data:t}){const n=O[t.nodeType],s=dt[t.nodeType]??"border-white/20",o=n?.input!=="none",i=n?.output!=="none",a=S(u=>u.runResults[e]),l=(()=>{if(t.nodeType==="textInput")return t.inputText?.trim()||void 0;if(t.nodeType!=="output")return t.prompt?.trim()||void 0})(),d=[];t.model&&d.push(t.model),t.nodeType==="chat"&&t.webSearch&&t.webSearch!=="off"&&d.push(`web:${t.webSearch}`),t.nodeType==="imageGen"&&(t.width&&t.height&&d.push(`${t.width}×${t.height}`),t.steps&&d.push(`${t.steps} steps`)),t.nodeType==="music"&&t.duration&&d.push(`${t.duration}s`),t.nodeType==="video"&&t.videoAspectRatio&&d.push(t.videoAspectRatio),t.nodeType==="tts"&&t.voice&&d.push(t.voice);const x=a?.status==="running"?"ring-2 ring-white/20 animate-pulse":a?.status==="done"?"ring-2 ring-green-500/30":a?.status==="error"?"ring-2 ring-red-500/30":"",p=a?.output,h=a?.outputKind,w=h==="image"||p?.startsWith("[image:"),y=h==="audio"||p?.startsWith("[audio:"),$=h==="video"||p?.startsWith("[video:"),m=(()=>{if(p)return p.startsWith("[image:")||p.startsWith("[audio:")||p.startsWith("[video:")?p.slice(7,-1):p})();return r.jsxs("div",{className:R("rounded-xl border-2 bg-[#111] shadow-xl min-w-[240px] max-w-[280px]",s,x),children:[o&&r.jsx(J,{type:"target",position:z.Top,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"}),r.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-white/[0.06]",children:[r.jsx("span",{className:"text-[13.5px] font-medium text-white/60",children:n?.label??t.nodeType}),a?.status==="running"&&r.jsx("span",{className:"ml-auto text-[11px] text-white/30",children:"Running…"}),a?.status==="done"&&r.jsx("span",{className:"ml-auto text-[11px] text-green-400/50",children:"Done"}),a?.status==="error"&&r.jsx("span",{className:"ml-auto text-[11px] text-red-400/60",children:"Error"}),!a?.status&&d.length>0&&r.jsx("span",{className:"ml-auto text-[11px] text-white/25 truncate max-w-[140px]",title:d.join(" · "),children:d.join(" · ")})]}),l&&!a?.status&&r.jsx("div",{className:"px-3.5 py-2.5",children:r.jsx("p",{className:"text-[12.5px] text-white/50 leading-relaxed line-clamp-3 whitespace-pre-wrap",children:l})}),a?.status==="error"&&r.jsx("div",{className:"px-3.5 py-2.5",children:r.jsx("p",{className:"text-[12.5px] text-red-400/70 leading-relaxed whitespace-pre-wrap",children:a.error})}),a?.status==="done"&&m&&r.jsx("div",{className:"px-3.5 py-2.5",children:w?r.jsx("img",{src:m,alt:"",className:"w-full rounded border border-white/[0.06]"}):y?r.jsx("audio",{src:m,controls:!0,className:"w-full h-8"}):$?r.jsx("video",{src:m,controls:!0,className:"w-full rounded border border-white/[0.06]"}):r.jsx("p",{className:"text-[12.5px] text-white/55 leading-relaxed line-clamp-6 whitespace-pre-wrap",children:m})}),i&&r.jsx(J,{type:"source",position:z.Bottom,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"})]})}const pt=b.memo(ut),ht={venice:pt};function mt({nodes:e,edges:t}){const[n,s]=Ne(e),[o,i]=Se(t),{fitView:a}=_e();b.useEffect(()=>{s(e)},[e,s]),b.useEffect(()=>{i(t)},[t,i]),b.useEffect(()=>{const d=setTimeout(()=>a({duration:300,padding:.2}),50);return()=>clearTimeout(d)},[e.length,t.length,a]);const l=b.useMemo(()=>ht,[]);return r.jsxs(Re,{nodes:n,edges:o,nodeTypes:l,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},className:"bg-[#080808]",defaultEdgeOptions:{animated:!0,style:{stroke:"rgba(255,255,255,0.1)",strokeWidth:2}},children:[r.jsx($e,{variant:Te.Dots,gap:20,size:1,color:"rgba(255,255,255,0.03)"}),r.jsx(Ce,{showInteractive:!1,className:"!bg-[#111] !border-white/[0.06] !shadow-xl [&>button]:!bg-[#111] [&>button]:!border-white/[0.06] [&>button]:!text-white/30 [&>button:hover]:!bg-white/[0.06]"})]})}function ft({nodes:e,edges:t}){return e.length===0?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center max-w-sm",children:[r.jsx("p",{className:"text-[14px] text-white/20 mb-2",children:"No workflow yet"}),r.jsx("p",{className:"text-[13px] text-white/10",children:"Tell the agent what you want to build — it will assemble the pipeline here in real time."})]})}):r.jsx(je,{children:r.jsx(mt,{nodes:e,edges:t})})}function gt({value:e,onChange:t}){const{models:n,isLoading:s}=ee(),[o,i]=b.useState(!1),[a,l]=b.useState(""),[d,x]=b.useState(!1),p=b.useRef(null);b.useEffect(()=>{const m=u=>{p.current&&!p.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const h=b.useMemo(()=>{const m=d?n:n.filter(g=>g.tier<=2);if(!a)return m;const u=a.toLowerCase();return m.filter(g=>g.id.toLowerCase().includes(u)||g.name.toLowerCase().includes(u))},[n,a,d]),w=b.useMemo(()=>{const m=[{label:"Recommended for agents",items:[]},{label:"Capable",items:[]},{label:"Other",items:[]}];for(const u of h)u.tier===0?m[0].items.push(u):u.tier===1||u.tier===2?m[1].items.push(u):m[2].items.push(u);return m.filter(u=>u.items.length>0)},[h]),y=n.find(m=>m.id===e),$=s?"Loading…":y?.name||e||"Pick agent model";return r.jsxs("div",{ref:p,className:"relative w-56 shrink-0",children:[r.jsxs("button",{type:"button",onClick:()=>i(!o),className:R("w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] rounded-md px-2.5 py-1.5 text-[13px] hover:border-white/[0.18] transition-colors text-left",o&&"border-white/[0.25]"),"aria-haspopup":"listbox","aria-expanded":o,children:[r.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[r.jsx("span",{className:"truncate text-white/85",children:$}),y?.recommended&&r.jsx("span",{className:"shrink-0 text-[10px] px-1 py-px rounded bg-emerald-400/15 text-emerald-300 font-medium uppercase tracking-wider",children:"Rec"})]}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:R("shrink-0 text-white/40 transition-transform duration-150",o&&"rotate-180"),children:r.jsx("path",{d:"M2.5 3.75L5 6.25L7.5 3.75"})})]}),o&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 w-[340px] z-50 bg-[#101015] border border-white/[0.1] rounded-lg shadow-2xl shadow-black/70 animate-scale-in overflow-hidden",children:[r.jsxs("div",{className:"px-2 py-2 border-b border-white/[0.06] flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,value:a,onChange:m=>l(m.target.value),placeholder:"Search models…",className:"flex-1 bg-white/[0.03] border border-white/[0.06] rounded px-2 py-1 text-[13px] text-white/85 outline-none focus:border-white/[0.2] placeholder:text-white/30"}),r.jsx("button",{onClick:()=>x(!d),className:R("text-[11px] px-1.5 py-1 rounded border transition-colors",d?"bg-white/[0.08] border-white/[0.15] text-white/85":"border-white/[0.08] text-white/45 hover:text-white/70"),title:d?"Showing all models":"Showing only schema-capable models",children:d?"All":"Capable"})]}),r.jsxs("div",{className:"max-h-[380px] overflow-y-auto py-1",children:[w.length===0&&r.jsx("div",{className:"px-3 py-6 text-center text-[13px] text-white/30",children:"No matches"}),w.map(m=>r.jsxs("div",{children:[r.jsx("div",{className:"px-3 pt-2 pb-1 text-[10.5px] uppercase tracking-[0.08em] text-white/30 font-medium",children:m.label}),m.items.map(u=>r.jsxs("button",{onClick:()=>{t(u.id),i(!1),l("")},className:R("w-full text-left px-3 py-2 hover:bg-white/[0.04] transition-colors",u.id===e&&"bg-white/[0.06]"),children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] text-white/90 font-medium truncate flex-1",children:u.name}),u.id===e&&r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"text-emerald-400 shrink-0",children:r.jsx("path",{d:"M20 6L9 17l-5-5"})})]}),r.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[u.recommended&&r.jsx(M,{tone:"emerald",children:"Recommended"}),u.capabilities.supportsResponseSchema&&r.jsx(M,{tone:"sky",children:"JSON"}),u.capabilities.supportsFunctionCalling&&r.jsx(M,{tone:"violet",children:"Tools"}),u.reasoning&&r.jsx(M,{tone:"amber",children:"Reasoning"}),u.capabilities.supportsVision&&r.jsx(M,{tone:"pink",children:"Vision"}),u.capabilities.supportsWebSearch&&r.jsx(M,{tone:"slate",children:"Web"}),u.uncensored&&r.jsx(M,{tone:"rose",children:"Uncensored"})]}),r.jsxs("div",{className:"text-[11px] text-white/35 mt-1 font-mono truncate",children:[u.id,u.contextTokens?` · ${xt(u.contextTokens)} ctx`:""]})]},u.id))]},m.label))]})]})]})}const X={emerald:"bg-emerald-400/15 text-emerald-300",sky:"bg-sky-400/15 text-sky-300",violet:"bg-violet-400/15 text-violet-300",amber:"bg-amber-400/15 text-amber-300",pink:"bg-pink-400/15 text-pink-300",slate:"bg-white/[0.06] text-white/55",rose:"bg-rose-400/15 text-rose-300"};function M({children:e,tone:t="slate"}){return r.jsx("span",{className:R("text-[10px] px-1.5 py-px rounded font-medium uppercase tracking-wider",X[t]??X.slate),children:e})}function xt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function yt(){const e=S(c=>c.draft),t=S(c=>c.isRunning),n=S(c=>c.linkedWorkflowId),s=S(c=>c.loadWorkflow),o=S(c=>c.unlinkWorkflow),i=S(c=>c.clearConversation),a=S(c=>c.resetDraft),l=L(c=>c.workflows),d=L(c=>c.createWorkflow),x=L(c=>c.updateWorkflow),p=L(c=>c.setActiveWorkflow),h=V(c=>c.setActiveTab),w=V(c=>c.playgroundAgentModel),y=V(c=>c.setPlaygroundAgentModel),$=w||te,[m,u]=b.useState(null),g=l.find(c=>c.id===n),N=Oe(e),_=e.nodes.length>0,f=_&&N.errors.length===0&&!t,C=async()=>{if(!f)return;const c=S.getState();c.clearResults(),c.setIsRunning(!0);const j={};for(const v of e.nodes)j[v.id]={nodeId:v.id,status:"pending",output:void 0,error:void 0};c.setRunResults(j);try{await Ee(e.nodes,e.edges,{onUpdate:(v,se)=>c.updateRunNode(v,se)}),Q.success("Workflow completed")}catch(v){Q.fromError(v,"Workflow failed")}finally{S.getState().setIsRunning(!1)}},P=c=>{const j=`Playground — ${new Date().toLocaleString()}`,v=d(j);return x(v,{nodes:e.nodes,edges:e.edges}),v},E=()=>{_&&(g?(x(g.id,{nodes:e.nodes,edges:e.edges}),u(`Updated "${g.name}"`)):(P(),u("Saved to Workflows")),setTimeout(()=>u(null),2e3))},A=()=>{if(!_)return;const c=P();u("Saved as new workflow"),setTimeout(()=>u(null),2e3),s(c,e.nodes,e.edges)},I=()=>{if(!_)return;let c=g?.id;g?x(g.id,{nodes:e.nodes,edges:e.edges}):c=P(),c&&p(c),h("workflows")},T=c=>{const j=l.find(v=>v.id===c);j&&s(j.id,j.nodes,j.edges)},k=()=>{o()},W=()=>{confirm("Clear the current conversation and canvas?")&&i()};return r.jsxs("div",{className:"flex h-full",children:[r.jsxs("div",{className:"w-[420px] shrink-0 border-r border-white/[0.06] flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 h-11 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:"text-[14px] font-medium text-white/65 shrink-0",children:"Playground"}),r.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-white/[0.06] text-white/45 uppercase tracking-wider shrink-0",children:"Agent"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 min-w-0",children:[r.jsx(gt,{value:$,onChange:y}),r.jsx("button",{onClick:W,className:"text-[12px] text-white/45 hover:text-white/80 transition-colors px-1.5 py-1 rounded focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",title:"Clear conversation",children:"Clear"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ct,{})})]}),r.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 h-11 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[g?r.jsxs("div",{className:"flex items-center gap-1 min-w-0 px-2 py-0.5 rounded bg-white/[0.04] border border-white/[0.06]",children:[r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"text-white/35 shrink-0",children:r.jsx("path",{d:"M12 20h9M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4 12.5-12.5z"})}),r.jsx("span",{className:"text-[12.5px] text-white/65 truncate max-w-[180px]",title:g.name,children:g.name}),r.jsx("button",{onClick:k,className:"text-white/25 hover:text-white/60 transition-colors p-0.5 -mr-1 shrink-0",title:"Unlink",children:r.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):l.length>0?r.jsxs("select",{value:"",onChange:c=>c.target.value&&T(c.target.value),className:"bg-white/[0.03] border border-white/[0.06] rounded px-2 py-1 text-[12px] text-white/45 outline-none hover:border-white/[0.12] max-w-[200px]",children:[r.jsx("option",{value:"",children:"Edit saved workflow…"}),l.map(c=>r.jsx("option",{value:c.id,children:c.name},c.id))]}):null,r.jsxs("span",{className:"text-[12px] text-white/30 font-mono shrink-0",children:[e.nodes.length,"n · ",e.edges.length,"e"]}),N.errors.length>0&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-400/80 shrink-0",title:N.errors.map(c=>c.message).join(` +`)}),N.errors.length===0&&N.warnings.length>0&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-yellow-400/70 shrink-0",title:N.warnings.map(c=>c.message).join(` +`)}),m&&r.jsx("span",{className:"text-[12px] text-green-400/70 truncate",children:m})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx("button",{onClick:a,disabled:!_||t,className:"text-white/25 hover:text-white/55 transition-colors p-1.5 disabled:opacity-30 disabled:cursor-not-allowed",title:"Reset canvas",children:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"})})}),r.jsx("button",{onClick:C,disabled:!f,className:R("flex items-center gap-1.5 text-[13px] font-medium px-2.5 py-1 rounded-md transition-colors",f?"bg-green-500/20 text-green-300 border border-green-500/30 hover:bg-green-500/30":"bg-white/[0.05] text-white/25 border border-white/[0.06] cursor-not-allowed"),title:N.errors.length>0?N.errors.map(c=>c.message).join(` +`):"Run the workflow inline",children:t?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"w-2.5 h-2.5 border-2 border-green-300/60 border-t-transparent rounded-full animate-spin"}),r.jsx("span",{className:"hidden sm:inline",children:"Running…"})]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"currentColor",children:r.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Run"]})}),r.jsx("button",{onClick:E,disabled:!_||t,className:R("text-[13px] px-2.5 py-1 rounded-md border border-white/[0.08] transition-colors",_&&!t?"text-white/60 hover:border-white/[0.15] hover:text-white/85":"text-white/20 opacity-40 cursor-not-allowed"),title:g?`Update "${g.name}"`:"Save as new workflow",children:g?"Update":"Save"}),g&&r.jsx("button",{onClick:A,disabled:!_||t,className:"text-white/35 hover:text-white/65 transition-colors p-1.5 disabled:opacity-30 disabled:cursor-not-allowed",title:"Save as a new workflow",children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"}),r.jsx("path",{d:"M7 21h12a2 2 0 002-2V9"})]})}),r.jsxs("button",{onClick:I,disabled:!_||t,className:R("flex items-center gap-1.5 text-[13px] font-medium px-2.5 py-1 rounded-md transition-colors",_&&!t?"bg-white text-black hover:bg-white/90":"bg-white/[0.05] text-white/30 cursor-not-allowed"),title:"Open in Workflows tab",children:[r.jsx("span",{className:"hidden md:inline",children:"Open in Workflows"}),r.jsx("span",{className:"md:hidden",children:"Open"}),r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r.jsx("path",{d:"M7 17L17 7M7 7h10v10"})})]})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ft,{nodes:e.nodes,edges:e.edges})})]})]})}export{yt as PlaygroundView}; diff --git a/ventures/havre/open/assets/playground-view-BLUXm2C6.js b/ventures/havre/open/assets/playground-view-BLUXm2C6.js deleted file mode 100644 index da0142e..0000000 --- a/ventures/havre/open/assets/playground-view-BLUXm2C6.js +++ /dev/null @@ -1,84 +0,0 @@ -import{a as ne,n as V,s as re,b as oe,Q as Z,d as ie,e as ae,f as le,r as b,h as ce,i as de,k as ue,l as pe,m as B,o as he,p as me,q as fe,v as ge,w as xe,x as we,y as F,u as be,g as U,z as ye,A as D,j as r,c as R,t as Q}from"./index-BK6OjN4-.js";import{g as ve,N as C,h as ke,H as J,P as z,R as je,b as Ne,c as Se,a as _e,i as Re,B as $e,e as Oe,C as Te,u as L,v as Ce,f as Ee}from"./workflow-engine-BHZwbSiT.js";function H(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function Pe(e,t,n){const s=e.slice(0);return s[t]=n,s}var Me=class extends ne{#n;#e;#r;#o;#t;#s;#i;#a;#l;#c=[];constructor(e,t,n){super(),this.#n=e,this.#o=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#o=t,V.batch(()=>{const n=this.#t,s=this.#p(this.#r);s.forEach(p=>p.observer.setOptions(p.defaultedQueryOptions));const o=s.map(p=>p.observer),i=o.map(p=>p.getCurrentResult()),a=n.length!==o.length,l=o.some((p,h)=>p!==n[h]),d=a||l,x=d?!0:i.some((p,h)=>{const w=this.#e[h];return!w||!re(p,w)});!d&&!x||(d&&(this.#c=s,this.#t=o),this.#e=i,this.hasListeners()&&(d&&(H(n,o).forEach(p=>{p.destroy()}),H(o,n).forEach(p=>{p.subscribe(h=>{this.#h(p,h)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#p(e),s=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[s,i=>this.#u(i??s,t,o),()=>this.#d(s,n)]}#d(e,t){return t.map((n,s)=>{const o=e[s];return n.defaultedQueryOptions.notifyOnChangeProps?o:n.observer.trackResult(o,i=>{t.forEach(a=>{a.observer.trackProp(i)})})})}#u(e,t,n){if(t){const s=this.#l,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((i,a)=>i!==s[a]));return(!this.#s||this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,n!==void 0&&(this.#l=n),this.#s=oe(this.#s,t(e))),this.#s}return e}#p(e){const t=new Map;this.#t.forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#n.defaultQueryOptions(s),a=t.get(o.queryHash)?.shift()??new Z(this.#n,o);n.push({defaultedQueryOptions:o,observer:a})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Pe(this.#e,n,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),n=this.#u(t,this.#o?.combine);e!==n&&V.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function Ae({queries:e,...t},n){const s=ie(),o=ae(),i=le(),a=b.useMemo(()=>e.map(m=>{const u=s.defaultQueryOptions(m);return u._optimisticResults=o?"isRestoring":"optimistic",u}),[e,s,o]);a.forEach(m=>{ce(m);const u=s.getQueryCache().get(m.queryHash);de(m,i,u)}),ue(i);const[l]=b.useState(()=>new Me(s,a,t)),[d,x,p]=l.getOptimisticResult(a,t.combine),h=!o&&t.subscribed!==!1;b.useSyncExternalStore(b.useCallback(m=>h?l.subscribe(V.batchCalls(m)):pe,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),b.useEffect(()=>{l.setQueries(a,t)},[a,t,l]);const y=d.some((m,u)=>B(a[u],m))?d.flatMap((m,u)=>{const g=a[u];if(g&&B(g,m)){const N=new Z(s,g);return he(g,N,i)}return[]}):[];if(y.length>0)throw Promise.all(y);const $=d.find((m,u)=>{const g=a[u];return g&&me({result:m,errorResetBoundary:i,throwOnError:g.throwOnError,query:s.getQueryCache().get(g.queryHash),suspense:g.suspense})});if($?.error)throw $.error;return x(p())}const S=fe()(ge((e,t)=>({messages:[],draft:{nodes:[],edges:[]},linkedWorkflowId:null,isThinking:!1,runResults:{},isRunning:!1,addMessage:n=>e(s=>({messages:[...s.messages,n]})),updateMessage:(n,s)=>e(o=>({messages:o.messages.map(i=>i.id===n?{...i,...s}:i)})),setThinking:n=>e({isThinking:n}),applyAgentPatches:n=>{const{nodes:s,edges:o}=t().draft,i=ve({nodes:s,edges:o},n);return e({draft:{nodes:i.nodes,edges:i.edges},runResults:{}}),i},resetDraft:()=>e({draft:{nodes:[],edges:[]},runResults:{},linkedWorkflowId:null}),clearConversation:()=>e({messages:[],draft:{nodes:[],edges:[]},runResults:{},linkedWorkflowId:null}),setRunResults:n=>e({runResults:n}),updateRunNode:(n,s)=>e(o=>({runResults:{...o.runResults,[n]:{...o.runResults[n],...s}}})),setIsRunning:n=>e({isRunning:n}),clearResults:()=>e({runResults:{}}),loadWorkflow:(n,s,o)=>e({draft:{nodes:s,edges:o},linkedWorkflowId:n,runResults:{},messages:[]}),unlinkWorkflow:()=>e({linkedWorkflowId:null})}),{name:"venice-playground",version:1,storage:xe(()=>we()),partialize:e=>({messages:e.messages.slice(-40),draft:e.draft,linkedWorkflowId:e.linkedWorkflowId})})),We=["text","image","tts","music","video"];function q(e){return e?e.data.filter(t=>!t.model_spec?.offline).map(t=>t.id).sort():[]}function qe(){const e=Ae({queries:We.map(s=>({queryKey:["models",s],queryFn:()=>F(`/models?type=${s}`,{noAuth:!0}),staleTime:3e5}))}),t={text:q(e[0].data),image:q(e[1].data),tts:q(e[2].data),music:q(e[3].data),video:q(e[4].data)},n=e.some(s=>s.isLoading);return{catalog:t,isLoading:n}}const Ie=["function_calling_default","most_intelligent","default"],Le=new Set(["qwen3-next-80b","zai-org-glm-4.7","mistral-small-3-2-24b-instruct"]);function De(e){if((e.model_spec?.traits??[]).some(s=>Ie.includes(s))||Le.has(e.id))return 0;const n=e.model_spec?.capabilities??{};return n.supportsResponseSchema&&n.supportsFunctionCalling?n.supportsReasoning?2:1:n.supportsResponseSchema||n.supportsFunctionCalling?2:3}function ee(){const{data:e,isLoading:t}=be("text");return{models:b.useMemo(()=>e?e.filter(s=>!s.model_spec?.offline).map(s=>{const o=s.model_spec?.capabilities??{},i=s.model_spec?.traits??[],a=De(s);return{id:s.id,name:s.model_spec?.name||s.id,capabilities:o,traits:i,contextTokens:s.model_spec?.availableContextTokens,recommended:a===0,tier:a,reasoning:o.supportsReasoning===!0,uncensored:i.includes("most_uncensored")}}).sort((s,o)=>s.tier!==o.tier?s.tier-o.tier:s.name.localeCompare(o.name)):[],[e]),isLoading:t}}const Ve=new Set(["add_node","remove_node","set_params","move_node","connect","disconnect","clear"]),te="qwen3-next-80b";function Ue(){return Object.values(C).map(e=>{const t=e.params.map(n=>{const s=[`${n.name}: ${n.type}${n.required?" (required)":""}`];return n.default!==void 0&&n.default!==""&&s.push(`default=${JSON.stringify(n.default)}`),n.enumValues&&s.push(`one of [${n.enumValues.filter(Boolean).join(", ")}]`),(n.min!==void 0||n.max!==void 0)&&s.push(`range ${n.min??"-"}..${n.max??"-"}`),` - ${s.join(" — ")}`}).join(` -`);return`- ${e.type} (${e.label}) | input=${e.input} output=${e.output} - ${e.description}${t?` - params: -${t}`:""}`}).join(` - -`)}function Fe(e){if(!e)return"";const t=[];return e.text.length&&t.push(`chat: ${e.text.join(", ")}`),e.image.length&&t.push(`imageGen: ${e.image.join(", ")}`),e.tts.length&&t.push(`tts: ${e.tts.join(", ")}`),e.music.length&&t.push(`music: ${e.music.join(", ")}`),e.video.length&&t.push(`video: ${e.video.join(", ")}`),t.length===0?"":` - -Available models per node type (use ONLY these ids; pick the one that best matches the user's intent or use the default if no preference): -${t.map(n=>`- ${n}`).join(` -`)}`}const Be=`You are a workflow designer for OpenVenice. You help the user author visual workflows that chain Venice AI models. - -You have these node types available: - -${Ue()} - -You respond by emitting patches to mutate the current draft workflow. Each patch is one of: -- {"op":"add_node","nodeType":"","id":"optional_id","params":{...}} — add a new node -- {"op":"set_params","id":"","params":{...}} — update a node's params -- {"op":"connect","source":"","target":""} — connect two nodes -- {"op":"disconnect","id":""} — remove an edge -- {"op":"remove_node","id":""} — remove a node -- {"op":"clear"} — remove all nodes and edges - -RULES: -1. Every response MUST be a single valid JSON object, nothing before or after. Do not wrap in markdown fences. -2. Schema: {"say": string, "patches": Array}. -3. "say" is a short (1–3 sentences) narration of what you just did or a question to the user. -4. When building a new workflow from scratch, start with {"op":"clear"} then add nodes top-to-bottom and connect them. -5. Always assign explicit ids when adding multiple nodes in one turn so you can reference them in connect patches. -6. Workflows need at least one textInput (or a generation node with a self-contained prompt) and an output node at the end. -7. Use {{input}} inside a node's prompt to place upstream text precisely, or leave prompt empty to append input after. -8. Keep to the param names and enum values listed above. Omit params to accept defaults. -9. If the user just asks a question, respond with a "say" and an empty "patches" array. -10. Do not narrate patches you aren't emitting. Do not produce commentary outside the JSON. - -Example response: -{"say":"I built a pipeline that researches a topic, summarizes it, and narrates the summary.","patches":[{"op":"clear"},{"op":"add_node","nodeType":"textInput","id":"in","params":{"inputText":"Quantum computing progress in 2025"}},{"op":"add_node","nodeType":"chat","id":"research","params":{"prompt":"Research this topic thoroughly.","webSearch":"on"}},{"op":"add_node","nodeType":"chat","id":"summary","params":{"prompt":"Summarize into 5 bullet points.","temperature":0.3}},{"op":"add_node","nodeType":"tts","id":"narrate","params":{"voice":"af_sky"}},{"op":"add_node","nodeType":"output","id":"out"},{"op":"connect","source":"in","target":"research"},{"op":"connect","source":"research","target":"summary"},{"op":"connect","source":"summary","target":"narrate"},{"op":"connect","source":"narrate","target":"out"}]}`;function Qe(e){return Be+Fe(e)}function Je(e){if(e.nodes.length===0)return"Current draft is empty.";const t=e.nodes.map(s=>{const o=[],i=s.data;for(const a of C[s.data.nodeType]?.params??[]){const l=i[a.name];if(l!==void 0&&l!==""&&l!==null){const d=typeof l=="string"?l.length>60?l.slice(0,60)+"…":l:JSON.stringify(l);o.push(`${a.name}=${d}`)}}return` - ${s.id} [${s.data.nodeType}] ${o.join(" ")}`}),n=e.edges.map(s=>` - ${s.id}: ${s.source} → ${s.target}`);return`Current draft: -Nodes: -${t.join(` -`)} -Edges: -${n.join(` -`)||" (none)"}`}function ze(e){const t=e.trim(),n=t.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)return n[1].trim();const s=t.indexOf("{"),o=t.lastIndexOf("}");return s!==-1&&o!==-1&&o>s?t.slice(s,o+1):t}function He(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.op!="string"||!Ve.has(t.op))return!1;switch(t.op){case"clear":return!0;case"add_node":return typeof t.nodeType=="string"&&t.nodeType in C;case"remove_node":case"disconnect":return typeof t.id=="string"&&t.id.length>0;case"set_params":return typeof t.id=="string"&&t.id.length>0&&typeof t.params=="object"&&t.params!==null;case"move_node":return typeof t.id=="string"&&typeof t.position=="object"&&t.position!==null;case"connect":return typeof t.source=="string"&&typeof t.target=="string"&&t.source!==t.target}return!1}function Ye(e,t){const n=C[e];if(!n)return{};const s=new Set(["model","prompt",...n.params.map(i=>i.name)]),o={};for(const[i,a]of Object.entries(t))s.has(i)&&(o[i]=a);return o}function Y(e){const t=ze(e);let n;try{n=JSON.parse(t)}catch{return{say:"",patches:[],invalidPatches:0}}const s=typeof n.say=="string"?n.say:"",o=Array.isArray(n.patches)?n.patches:[],i=[];let a=0;for(const l of o){if(!He(l)){a++;continue}l.op==="add_node"&&l.params?i.push({...l,params:Ye(l.nodeType,l.params)}):(l.op,i.push(l))}return{say:s,patches:i,invalidPatches:a}}async function K(e){const t={model:e.model,messages:e.messages,temperature:e.temperature,max_tokens:4096};return e.useResponseFormat&&(t.response_format={type:"json_object"}),(await F("/chat/completions",{method:"POST",body:JSON.stringify(t),signal:e.signal})).choices[0]?.message?.content??""}async function Ke({userMessage:e,draft:t,history:n,catalog:s,model:o,capabilities:i,signal:a}){const l=o,d=i?.supportsResponseSchema===!0,x=[{role:"system",content:Qe(s)},...n.map(w=>({role:w.role,content:w.content})),{role:"user",content:`${Je(t)} - -User: ${e} - -Reply with a single JSON object: {"say": "...", "patches": [...]}. No prose, no markdown fences.`}],p=await K({model:l,messages:x,temperature:.3,useResponseFormat:d,signal:a}),h=Y(p);if(h.patches.length===0&&!h.say&&p.length>0){const w=[...x,{role:"assistant",content:p},{role:"user",content:'That was not valid JSON. Reply again with ONLY a single JSON object matching {"say": string, "patches": Patch[]}. No commentary, no fences.'}];try{const y=await K({model:l,messages:w,temperature:0,useResponseFormat:d,signal:a});return Y(y)}catch{}}return h}const Ge=Object.keys(C),Xe=[{type:"function",function:{name:"clear",description:"Remove all nodes and edges. Use when starting a fresh workflow.",parameters:{type:"object",properties:{},additionalProperties:!1}}},{type:"function",function:{name:"add_node",description:'Add a node to the canvas. Returns the assigned id (use it for connect calls). For "params": include only the fields you want to set; defaults apply otherwise. Use {{input}} inside any prompt field to inject upstream text.',parameters:{type:"object",properties:{node_type:{type:"string",enum:Ge,description:"The kind of node to add."},id:{type:"string",description:"Optional explicit id. If omitted, a uuid is generated. Use this id in subsequent connect/set_params calls."},params:{type:"object",description:"Node-specific params (model, prompt, temperature, etc). See system prompt for the full schema per node type.",additionalProperties:!0}},required:["node_type"],additionalProperties:!1}}},{type:"function",function:{name:"connect",description:"Connect two nodes (data flows from source to target).",parameters:{type:"object",properties:{source:{type:"string",description:"Source node id."},target:{type:"string",description:"Target node id."}},required:["source","target"],additionalProperties:!1}}},{type:"function",function:{name:"set_params",description:"Update params on an existing node. Merged with current params.",parameters:{type:"object",properties:{id:{type:"string"},params:{type:"object",additionalProperties:!0}},required:["id","params"],additionalProperties:!1}}},{type:"function",function:{name:"remove_node",description:"Remove a node and all its connected edges.",parameters:{type:"object",properties:{id:{type:"string"}},required:["id"],additionalProperties:!1}}},{type:"function",function:{name:"pick_model",description:"Get a recommended model id for a node type, optionally biased by preference. Use this BEFORE add_node if unsure which id to use — you will get back an id you can pass directly.",parameters:{type:"object",properties:{node_type:{type:"string",enum:["chat","imageGen","tts","music","video"]},prefer:{type:"string",enum:["fast","best","web","reasoning","uncensored"],description:"'fast' = cheap & quick (default), 'best' = highest quality, 'web' = native web search, 'reasoning' = chain-of-thought, 'uncensored' = no refusals."}},required:["node_type"],additionalProperties:!1}}},{type:"function",function:{name:"ask_user",description:'Pause the build to ask the user a clarifying question (e.g., "Vertical (9:16) or square (1:1)?"). The build will resume on their reply.',parameters:{type:"object",properties:{question:{type:"string"}},required:["question"],additionalProperties:!1}}},{type:"function",function:{name:"done",description:"Signal the workflow is complete. Provide a one-sentence summary of what you built for the user.",parameters:{type:"object",properties:{summary:{type:"string"}},required:["summary"],additionalProperties:!1}}}];function Ze(){return Object.values(C).map(e=>{const t=e.params.map(n=>{const s=[`${n.name}: ${n.type}${n.required?" (required)":""}`];return n.default!==void 0&&n.default!==""&&s.push(`default=${JSON.stringify(n.default)}`),n.enumValues&&s.push(`one of [${n.enumValues.filter(Boolean).join(", ")}]`),(n.min!==void 0||n.max!==void 0)&&s.push(`range ${n.min??"-"}..${n.max??"-"}`),` - ${s.join(" — ")}`}).join(` -`);return`- ${e.type} (${e.label}) | input=${e.input} output=${e.output} - ${e.description}${t?` - params: -${t}`:""}`}).join(` - -`)}const et=`You are a workflow designer for OpenVenice. You build visual workflows that chain Venice AI models by calling tools. - -Available node types: - -${Ze()} - -How you work: -1. Use the provided tools — never reply with prose-only when actions are needed. -2. For a fresh build, call clear() first, then add_node(...) for each step, then connect(source, target) edges, then done(summary). -3. Always assign explicit ids when adding nodes (e.g., id="research", "script", "video"), so you can reference them in connect/set_params calls. -4. **Templates**: Inside any prompt/inputText field, use {{input}} to inject the concatenated text from upstream parents. There is no {{node_id}} syntax — referencing other nodes by name does NOT work. Each node only sees {{input}} = its parents' outputs joined. -5. **No placeholder content**: write inputText fields with realistic example content the user will likely keep, not "Enter the topic here". -6. **Model ids must come from the live Venice catalog** — DO NOT guess names like "suno-v3" or "runway-gen-2". When in doubt, call pick_model({node_type, prefer}) FIRST and use its returned id. add_node will reject unknown model ids and tell you to call pick_model. -7. **Cost & speed**: prefer fast cheap chat models (qwen3-next-80b, mistral-small-3-2-24b-instruct, zai-org-glm-4.7). Only escalate to claude-opus or qwen-thinking when the task explicitly demands top reasoning. Use pick_model with prefer="fast" by default, "best" for premium quality, "web" for native search, "reasoning" for analysis-heavy tasks. -8. **Web search**: only useful on chat nodes whose model has supportsWebSearch. pick_model({node_type:"chat", prefer:"web"}) returns a good one. -9. **For social-video / reel requests**: canonical shape is textInput → chat(research, web) → chat(script) → video (9:16, 1080p, 5-10s) → output. For music: add a SEPARATE branch (textInput → music → output) — DO NOT connect music nodes to video nodes; they can't compose into a single AV file from this engine. Each modality gets its own output. -10. If the request is ambiguous (which platform? which style?), call ask_user with one specific question. -11. End every successful build with done(summary). - -Workflows must terminate at an output node (or the user won't see results). Multiple branches with their own outputs are fine and encouraged for multi-modal results.`,G=16;function tt(e){if(e.nodes.length===0)return"Current draft is empty.";const t=e.nodes.map(s=>` - ${s.id} [${s.data.nodeType}]`).join(` -`),n=e.edges.map(s=>` - ${s.source} → ${s.target}`).join(` -`)||" (none)";return`Current draft: -Nodes: -${t} -Edges: -${n}`}function st(e,t,n){const s=n.catalog;return s?e==="chat"?s.text.includes(t):e==="imageGen"?s.image.includes(t):e==="tts"?s.tts.includes(t):e==="music"?s.music.includes(t):e==="video"?s.video.includes(t):!0:!0}function nt(e,t,n){const s=n.catalog;if(!s)return;if(e==="chat"){const i=n.agentModels??[];if(i.length===0)return s.text[0];const a=i.map(l=>{let d=0;const x=l.capabilities;return t==="web"&&(d+=x.supportsWebSearch?100:0),t==="reasoning"&&(d+=x.supportsReasoning?100:0),t==="uncensored"&&(d+=l.uncensored?100:0),t==="best"&&(l.traits.includes("most_intelligent")&&(d+=80),l.contextTokens&&l.contextTokens>=2e5&&(d+=20)),(t==="fast"||!t)&&(x.supportsReasoning&&(d-=30),l.traits.includes("function_calling_default")&&(d+=50),l.recommended&&(d+=30)),x.supportsResponseSchema&&(d+=10),d-=l.tier*5,{id:l.id,score:d}});return a.sort((l,d)=>d.score-l.score),a[0]?.id}return(e==="imageGen"?s.image:e==="tts"?s.tts:e==="music"?s.music:e==="video"?s.video:[])[0]}function rt(e){if(!e)return{};try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function ot(e,t,n){try{switch(e){case"clear":return n.applyPatch({op:"clear"}),{ok:!0};case"add_node":{const s=t.node_type;if(!s||!(s in C))return{error:`Unknown node_type: ${String(s)}`};const o=typeof t.id=="string"&&t.id||U(),i=typeof t.params=="object"&&t.params!==null?t.params:{},a=i.model;if(typeof a=="string"&&a.length>0&&!st(s,a,n))return{error:`Unknown model '${a}' for ${s}. Call pick_model({node_type:'${s==="chat"?"chat":s}'}) to get a valid id, then retry add_node with that id.`};const l=C[s],d=new Set(["model","prompt",...l.params.map(h=>h.name)]),x={};for(const[h,w]of Object.entries(i))d.has(h)&&(x[h]=w);for(const h of l.params)if(h.enumValues&&x[h.name]!==void 0){const w=x[h.name];if(typeof w=="boolean"){x[h.name]=w?h.enumValues.includes("on")?"on":h.enumValues[0]:h.enumValues.includes("off")?"off":"";continue}if(typeof w!="string"||!h.enumValues.includes(w))return{error:`Invalid value for ${s}.${h.name}: ${JSON.stringify(w)}. Must be one of [${h.enumValues.filter(Boolean).join(", ")}].`}}const p=n.applyPatch({op:"add_node",nodeType:s,id:o,params:x});return"error"in p?{error:p.error}:{ok:!0,id:p.id??o}}case"connect":{const s=String(t.source??""),o=String(t.target??"");if(!s||!o)return{error:"Both source and target are required."};const i=n.applyPatch({op:"connect",source:s,target:o});return"error"in i?{error:i.error}:{ok:!0,edge_id:i.edge_id}}case"set_params":{const s=String(t.id??""),o=typeof t.params=="object"&&t.params!==null?t.params:{},i=n.applyPatch({op:"set_params",id:s,params:o});return"error"in i?{error:i.error}:{ok:!0}}case"remove_node":{const s=String(t.id??""),o=n.applyPatch({op:"remove_node",id:s});return"error"in o?{error:o.error}:{ok:!0}}case"pick_model":{const s=String(t.node_type??""),o=typeof t.prefer=="string"?t.prefer:void 0,i=nt(s,o,n);return i?{ok:!0,model:i}:{error:`No model available for ${s}`}}case"ask_user":return{ok:!0,message:String(t.question??"")};case"done":return{ok:!0,message:String(t.summary??"Done.")}}return{error:`Unknown tool: ${e}`}}catch(s){return{error:s instanceof Error?s.message:"Tool failed"}}}async function it(e){const t=[{role:"system",content:et},...e.history.map(o=>o.role==="user"?{role:"user",content:o.content}:{role:"assistant",content:o.content}),{role:"user",content:`${tt(e.draft)} - -User request: ${e.userMessage}`}];let n=0,s=!1;for(let o=0;of.apiKey!==null),d=D(f=>f.playgroundAgentModel)||te,{catalog:x}=qe(),{models:p}=ee(),h=p.find(f=>f.id===d)?.capabilities,[w,y]=b.useState(""),[$,m]=b.useState(null),u=b.useRef(null),g=b.useRef(null);b.useEffect(()=>{u.current?.scrollTo({top:u.current.scrollHeight,behavior:"smooth"})},[e,n]);const N=async f=>{const T=f.trim();if(!T||n)return;if(!l){m("Connect your Venice API key first.");return}m(null),y("");const P={id:U(),role:"user",content:T},E={id:U(),role:"assistant",content:"",pending:!0,activity:[]};s(P),s(E),i(!0),g.current?.abort();const A=new AbortController;g.current=A;const I=e.filter(O=>!O.pending&&!O.error).slice(-10).map(O=>({role:O.role,content:O.content}));try{if(h?.supportsFunctionCalling===!0){const k=[],W=await it({userMessage:T,draft:t,history:I,catalog:x,agentModels:p,model:d,capabilities:h,signal:A.signal,applyPatch:c=>{try{const j=S.getState().draft,v=ke({nodes:j.nodes,edges:j.edges},c);return S.setState({draft:{nodes:v.nodes,edges:v.edges}}),{ok:!0,id:v.addedNodeId,edge_id:v.addedEdgeId}}catch(j){return{error:j instanceof Error?j.message:"Patch failed"}}},onStep:c=>{k.push(lt(c)),o(E.id,{activity:[...k]})}});o(E.id,{content:W.say||"Done.",activity:k,pending:!1})}else{const k=await Ke({userMessage:T,draft:t,history:I,catalog:x,model:d,capabilities:h,signal:A.signal});let W;try{k.patches.length>0&&a(k.patches)}catch(v){W=v instanceof Error?v.message:"Failed to apply patches"}const c=k.invalidPatches>0?` (${k.invalidPatches} invalid patch${k.invalidPatches===1?"":"es"} ignored)`:"",j=k.patches.length===0&&!k.say?"The agent returned an unparseable response. Try a different model from the picker above, or simplify the request.":k.say||(k.patches.length>0?"Updated the workflow.":"");o(E.id,{content:j+c,patches:k.patches,error:W,pending:!1})}}catch(O){if(A.signal.aborted)o(E.id,{content:"",error:"Cancelled",pending:!1});else{const k=O instanceof Error?O.message:"Agent request failed";o(E.id,{content:"",error:k,pending:!1})}}finally{i(!1),g.current=null}},_=()=>{g.current?.abort()};return r.jsxs("div",{className:"flex flex-col h-full bg-[#0c0c10]",children:[r.jsx("div",{ref:u,className:"flex-1 overflow-y-auto px-4 py-4",children:e.length===0?r.jsxs("div",{className:"flex flex-col gap-3 pt-8",children:[r.jsx("div",{className:"text-[15px] text-white/85 font-semibold mb-1",children:"What should I build?"}),r.jsx("div",{className:"text-[13px] text-white/45 mb-4",children:"Describe a workflow in plain language. I'll assemble it on the canvas in real time."}),r.jsx("div",{className:"flex flex-col gap-2",children:at.map(f=>r.jsx("button",{onClick:()=>N(f),className:"text-left px-3 py-2.5 rounded-lg border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.16] hover:bg-white/[0.04] transition-all text-[13px] text-white/65 hover:text-white/85 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-accent)] focus-visible:outline-offset-2",children:f},f))})]}):r.jsx("div",{className:"flex flex-col gap-3",children:e.map(f=>r.jsxs("div",{className:R("flex flex-col gap-1.5",f.role==="user"?"items-end":"items-start"),children:[r.jsx("div",{className:R("max-w-[88%] px-3.5 py-2 rounded-xl text-[13.5px] leading-relaxed whitespace-pre-wrap",f.role==="user"?"bg-white/[0.09] text-white border border-white/[0.05]":"bg-white/[0.04] border border-white/[0.07] text-white/85"),children:f.pending&&(!f.activity||f.activity.length===0)?r.jsxs("span",{className:"text-white/45 inline-flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block w-3 h-3 border-2 border-white/20 border-t-[var(--color-accent)] rounded-full animate-spin"}),"Thinking…"]}):f.error?r.jsx("span",{className:"text-red-300/95",children:f.error}):f.content||r.jsx("span",{className:"text-white/35 italic",children:"(no message)"})}),f.activity&&f.activity.length>0&&r.jsxs("div",{className:"max-w-[88%] flex flex-col gap-px text-[11.5px] font-mono text-white/45 px-1",children:[f.activity.map((T,P)=>r.jsxs("div",{className:R("flex items-center gap-1.5",!T.ok&&"text-rose-300/85"),children:[r.jsx("span",{className:"text-white/30",children:"·"}),r.jsx("span",{children:T.summary})]},P)),f.pending&&r.jsxs("div",{className:"flex items-center gap-1.5 text-white/35",children:[r.jsx("span",{className:"inline-block w-2 h-2 border border-white/20 border-t-[var(--color-accent)] rounded-full animate-spin"}),r.jsx("span",{children:"Working…"})]})]}),f.patches&&f.patches.length>0&&!f.activity?.length&&r.jsxs("div",{className:"max-w-[88%] px-3 py-1 text-[11px] text-white/40 font-mono tracking-wide",children:[f.patches.length," patch",f.patches.length===1?"":"es"," applied"]})]},f.id))})}),r.jsxs("div",{className:"shrink-0 border-t border-white/[0.06] p-3",children:[$&&r.jsx("div",{className:"mb-2 text-[13px] text-red-300/95",children:$}),r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("textarea",{value:w,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),N(w))},placeholder:n?"Agent is working…":"Describe a workflow or change…",rows:2,disabled:n,className:"flex-1 bg-white/[0.03] border border-white/[0.08] rounded-lg px-3 py-2 text-[13.5px] text-white/90 outline-none resize-none placeholder:text-white/30 focus:border-white/[0.2] disabled:opacity-60"}),n?r.jsx("button",{onClick:_,className:"shrink-0 px-3 py-2 text-[13px] text-white/85 hover:text-white border border-white/[0.12] hover:bg-white/[0.05] rounded-lg transition-colors",children:"Stop"}):r.jsx("button",{onClick:()=>N(w),disabled:!w.trim(),className:"shrink-0 px-4 py-2 text-[13px] font-medium bg-white text-black rounded-lg hover:bg-white/90 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]})]})}const dt={textInput:"border-blue-500/30",chat:"border-purple-500/30",imageGen:"border-pink-500/30",tts:"border-green-500/30",music:"border-yellow-500/30",video:"border-orange-500/30",output:"border-white/20"};function ut({id:e,data:t}){const n=C[t.nodeType],s=dt[t.nodeType]??"border-white/20",o=n?.input!=="none",i=n?.output!=="none",a=S(u=>u.runResults[e]),l=(()=>{if(t.nodeType==="textInput")return t.inputText?.trim()||void 0;if(t.nodeType!=="output")return t.prompt?.trim()||void 0})(),d=[];t.model&&d.push(t.model),t.nodeType==="chat"&&t.webSearch&&t.webSearch!=="off"&&d.push(`web:${t.webSearch}`),t.nodeType==="imageGen"&&(t.width&&t.height&&d.push(`${t.width}×${t.height}`),t.steps&&d.push(`${t.steps} steps`)),t.nodeType==="music"&&t.duration&&d.push(`${t.duration}s`),t.nodeType==="video"&&t.videoAspectRatio&&d.push(t.videoAspectRatio),t.nodeType==="tts"&&t.voice&&d.push(t.voice);const x=a?.status==="running"?"ring-2 ring-white/20 animate-pulse":a?.status==="done"?"ring-2 ring-green-500/30":a?.status==="error"?"ring-2 ring-red-500/30":"",p=a?.output,h=a?.outputKind,w=h==="image"||p?.startsWith("[image:"),y=h==="audio"||p?.startsWith("[audio:"),$=h==="video"||p?.startsWith("[video:"),m=(()=>{if(p)return p.startsWith("[image:")||p.startsWith("[audio:")||p.startsWith("[video:")?p.slice(7,-1):p})();return r.jsxs("div",{className:R("rounded-xl border-2 bg-[#111] shadow-xl min-w-[240px] max-w-[280px]",s,x),children:[o&&r.jsx(J,{type:"target",position:z.Top,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"}),r.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-white/[0.06]",children:[r.jsx("span",{className:"text-[13.5px] font-medium text-white/60",children:n?.label??t.nodeType}),a?.status==="running"&&r.jsx("span",{className:"ml-auto text-[11px] text-white/30",children:"Running…"}),a?.status==="done"&&r.jsx("span",{className:"ml-auto text-[11px] text-green-400/50",children:"Done"}),a?.status==="error"&&r.jsx("span",{className:"ml-auto text-[11px] text-red-400/60",children:"Error"}),!a?.status&&d.length>0&&r.jsx("span",{className:"ml-auto text-[11px] text-white/25 truncate max-w-[140px]",title:d.join(" · "),children:d.join(" · ")})]}),l&&!a?.status&&r.jsx("div",{className:"px-3.5 py-2.5",children:r.jsx("p",{className:"text-[12.5px] text-white/50 leading-relaxed line-clamp-3 whitespace-pre-wrap",children:l})}),a?.status==="error"&&r.jsx("div",{className:"px-3.5 py-2.5",children:r.jsx("p",{className:"text-[12.5px] text-red-400/70 leading-relaxed whitespace-pre-wrap",children:a.error})}),a?.status==="done"&&m&&r.jsx("div",{className:"px-3.5 py-2.5",children:w?r.jsx("img",{src:m,alt:"",className:"w-full rounded border border-white/[0.06]"}):y?r.jsx("audio",{src:m,controls:!0,className:"w-full h-8"}):$?r.jsx("video",{src:m,controls:!0,className:"w-full rounded border border-white/[0.06]"}):r.jsx("p",{className:"text-[12.5px] text-white/55 leading-relaxed line-clamp-6 whitespace-pre-wrap",children:m})}),i&&r.jsx(J,{type:"source",position:z.Bottom,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"})]})}const pt=b.memo(ut),ht={venice:pt};function mt({nodes:e,edges:t}){const[n,s]=Ne(e),[o,i]=Se(t),{fitView:a}=_e();b.useEffect(()=>{s(e)},[e,s]),b.useEffect(()=>{i(t)},[t,i]),b.useEffect(()=>{const d=setTimeout(()=>a({duration:300,padding:.2}),50);return()=>clearTimeout(d)},[e.length,t.length,a]);const l=b.useMemo(()=>ht,[]);return r.jsxs(Re,{nodes:n,edges:o,nodeTypes:l,fitView:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},className:"bg-[#080808]",defaultEdgeOptions:{animated:!0,style:{stroke:"rgba(255,255,255,0.1)",strokeWidth:2}},children:[r.jsx($e,{variant:Oe.Dots,gap:20,size:1,color:"rgba(255,255,255,0.03)"}),r.jsx(Te,{showInteractive:!1,className:"!bg-[#111] !border-white/[0.06] !shadow-xl [&>button]:!bg-[#111] [&>button]:!border-white/[0.06] [&>button]:!text-white/30 [&>button:hover]:!bg-white/[0.06]"})]})}function ft({nodes:e,edges:t}){return e.length===0?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center max-w-sm",children:[r.jsx("p",{className:"text-[14px] text-white/20 mb-2",children:"No workflow yet"}),r.jsx("p",{className:"text-[13px] text-white/10",children:"Tell the agent what you want to build — it will assemble the pipeline here in real time."})]})}):r.jsx(je,{children:r.jsx(mt,{nodes:e,edges:t})})}function gt({value:e,onChange:t}){const{models:n,isLoading:s}=ee(),[o,i]=b.useState(!1),[a,l]=b.useState(""),[d,x]=b.useState(!1),p=b.useRef(null);b.useEffect(()=>{const m=u=>{p.current&&!p.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const h=b.useMemo(()=>{const m=d?n:n.filter(g=>g.tier<=2);if(!a)return m;const u=a.toLowerCase();return m.filter(g=>g.id.toLowerCase().includes(u)||g.name.toLowerCase().includes(u))},[n,a,d]),w=b.useMemo(()=>{const m=[{label:"Recommended for agents",items:[]},{label:"Capable",items:[]},{label:"Other",items:[]}];for(const u of h)u.tier===0?m[0].items.push(u):u.tier===1||u.tier===2?m[1].items.push(u):m[2].items.push(u);return m.filter(u=>u.items.length>0)},[h]),y=n.find(m=>m.id===e),$=s?"Loading…":y?.name||e||"Pick agent model";return r.jsxs("div",{ref:p,className:"relative w-56 shrink-0",children:[r.jsxs("button",{type:"button",onClick:()=>i(!o),className:R("w-full flex items-center justify-between gap-2 bg-white/[0.03] border border-white/[0.08] rounded-md px-2.5 py-1.5 text-[13px] hover:border-white/[0.18] transition-colors text-left",o&&"border-white/[0.25]"),"aria-haspopup":"listbox","aria-expanded":o,children:[r.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[r.jsx("span",{className:"truncate text-white/85",children:$}),y?.recommended&&r.jsx("span",{className:"shrink-0 text-[10px] px-1 py-px rounded bg-emerald-400/15 text-emerald-300 font-medium uppercase tracking-wider",children:"Rec"})]}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:R("shrink-0 text-white/40 transition-transform duration-150",o&&"rotate-180"),children:r.jsx("path",{d:"M2.5 3.75L5 6.25L7.5 3.75"})})]}),o&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 w-[340px] z-50 bg-[#101015] border border-white/[0.1] rounded-lg shadow-2xl shadow-black/70 animate-scale-in overflow-hidden",children:[r.jsxs("div",{className:"px-2 py-2 border-b border-white/[0.06] flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,value:a,onChange:m=>l(m.target.value),placeholder:"Search models…",className:"flex-1 bg-white/[0.03] border border-white/[0.06] rounded px-2 py-1 text-[13px] text-white/85 outline-none focus:border-white/[0.2] placeholder:text-white/30"}),r.jsx("button",{onClick:()=>x(!d),className:R("text-[11px] px-1.5 py-1 rounded border transition-colors",d?"bg-white/[0.08] border-white/[0.15] text-white/85":"border-white/[0.08] text-white/45 hover:text-white/70"),title:d?"Showing all models":"Showing only schema-capable models",children:d?"All":"Capable"})]}),r.jsxs("div",{className:"max-h-[380px] overflow-y-auto py-1",children:[w.length===0&&r.jsx("div",{className:"px-3 py-6 text-center text-[13px] text-white/30",children:"No matches"}),w.map(m=>r.jsxs("div",{children:[r.jsx("div",{className:"px-3 pt-2 pb-1 text-[10.5px] uppercase tracking-[0.08em] text-white/30 font-medium",children:m.label}),m.items.map(u=>r.jsxs("button",{onClick:()=>{t(u.id),i(!1),l("")},className:R("w-full text-left px-3 py-2 hover:bg-white/[0.04] transition-colors",u.id===e&&"bg-white/[0.06]"),children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[13px] text-white/90 font-medium truncate flex-1",children:u.name}),u.id===e&&r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"text-emerald-400 shrink-0",children:r.jsx("path",{d:"M20 6L9 17l-5-5"})})]}),r.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[u.recommended&&r.jsx(M,{tone:"emerald",children:"Recommended"}),u.capabilities.supportsResponseSchema&&r.jsx(M,{tone:"sky",children:"JSON"}),u.capabilities.supportsFunctionCalling&&r.jsx(M,{tone:"violet",children:"Tools"}),u.reasoning&&r.jsx(M,{tone:"amber",children:"Reasoning"}),u.capabilities.supportsVision&&r.jsx(M,{tone:"pink",children:"Vision"}),u.capabilities.supportsWebSearch&&r.jsx(M,{tone:"slate",children:"Web"}),u.uncensored&&r.jsx(M,{tone:"rose",children:"Uncensored"})]}),r.jsxs("div",{className:"text-[11px] text-white/35 mt-1 font-mono truncate",children:[u.id,u.contextTokens?` · ${xt(u.contextTokens)} ctx`:""]})]},u.id))]},m.label))]})]})]})}const X={emerald:"bg-emerald-400/15 text-emerald-300",sky:"bg-sky-400/15 text-sky-300",violet:"bg-violet-400/15 text-violet-300",amber:"bg-amber-400/15 text-amber-300",pink:"bg-pink-400/15 text-pink-300",slate:"bg-white/[0.06] text-white/55",rose:"bg-rose-400/15 text-rose-300"};function M({children:e,tone:t="slate"}){return r.jsx("span",{className:R("text-[10px] px-1.5 py-px rounded font-medium uppercase tracking-wider",X[t]??X.slate),children:e})}function xt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function yt(){const e=S(c=>c.draft),t=S(c=>c.isRunning),n=S(c=>c.linkedWorkflowId),s=S(c=>c.loadWorkflow),o=S(c=>c.unlinkWorkflow),i=S(c=>c.clearConversation),a=S(c=>c.resetDraft),l=L(c=>c.workflows),d=L(c=>c.createWorkflow),x=L(c=>c.updateWorkflow),p=L(c=>c.setActiveWorkflow),h=D(c=>c.setActiveTab),w=D(c=>c.playgroundAgentModel),y=D(c=>c.setPlaygroundAgentModel),$=w||te,[m,u]=b.useState(null),g=l.find(c=>c.id===n),N=Ce(e),_=e.nodes.length>0,f=_&&N.errors.length===0&&!t,T=async()=>{if(!f)return;const c=S.getState();c.clearResults(),c.setIsRunning(!0);const j={};for(const v of e.nodes)j[v.id]={nodeId:v.id,status:"pending",output:void 0,error:void 0};c.setRunResults(j);try{await Ee(e.nodes,e.edges,{onUpdate:(v,se)=>c.updateRunNode(v,se)}),Q.success("Workflow completed")}catch(v){Q.fromError(v,"Workflow failed")}finally{S.getState().setIsRunning(!1)}},P=c=>{const j=`Playground — ${new Date().toLocaleString()}`,v=d(j);return x(v,{nodes:e.nodes,edges:e.edges}),v},E=()=>{_&&(g?(x(g.id,{nodes:e.nodes,edges:e.edges}),u(`Updated "${g.name}"`)):(P(),u("Saved to Workflows")),setTimeout(()=>u(null),2e3))},A=()=>{if(!_)return;const c=P();u("Saved as new workflow"),setTimeout(()=>u(null),2e3),s(c,e.nodes,e.edges)},I=()=>{if(!_)return;let c=g?.id;g?x(g.id,{nodes:e.nodes,edges:e.edges}):c=P(),c&&p(c),h("workflows")},O=c=>{const j=l.find(v=>v.id===c);j&&s(j.id,j.nodes,j.edges)},k=()=>{o()},W=()=>{confirm("Clear the current conversation and canvas?")&&i()};return r.jsxs("div",{className:"flex h-full",children:[r.jsxs("div",{className:"w-[420px] shrink-0 border-r border-white/[0.06] flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 h-11 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:"text-[14px] font-medium text-white/65 shrink-0",children:"Playground"}),r.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-white/[0.06] text-white/45 uppercase tracking-wider shrink-0",children:"Agent"})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 min-w-0",children:[r.jsx(gt,{value:$,onChange:y}),r.jsx("button",{onClick:W,className:"text-[12px] text-white/45 hover:text-white/80 transition-colors px-1.5 py-1 rounded focus-visible:outline focus-visible:outline-1 focus-visible:outline-white/40",title:"Clear conversation",children:"Clear"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ct,{})})]}),r.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 h-11 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[g?r.jsxs("div",{className:"flex items-center gap-1 min-w-0 px-2 py-0.5 rounded bg-white/[0.04] border border-white/[0.06]",children:[r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"text-white/35 shrink-0",children:r.jsx("path",{d:"M12 20h9M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4 12.5-12.5z"})}),r.jsx("span",{className:"text-[12.5px] text-white/65 truncate max-w-[180px]",title:g.name,children:g.name}),r.jsx("button",{onClick:k,className:"text-white/25 hover:text-white/60 transition-colors p-0.5 -mr-1 shrink-0",title:"Unlink",children:r.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):l.length>0?r.jsxs("select",{value:"",onChange:c=>c.target.value&&O(c.target.value),className:"bg-white/[0.03] border border-white/[0.06] rounded px-2 py-1 text-[12px] text-white/45 outline-none hover:border-white/[0.12] max-w-[200px]",children:[r.jsx("option",{value:"",children:"Edit saved workflow…"}),l.map(c=>r.jsx("option",{value:c.id,children:c.name},c.id))]}):null,r.jsxs("span",{className:"text-[12px] text-white/30 font-mono shrink-0",children:[e.nodes.length,"n · ",e.edges.length,"e"]}),N.errors.length>0&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-400/80 shrink-0",title:N.errors.map(c=>c.message).join(` -`)}),N.errors.length===0&&N.warnings.length>0&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-yellow-400/70 shrink-0",title:N.warnings.map(c=>c.message).join(` -`)}),m&&r.jsx("span",{className:"text-[12px] text-green-400/70 truncate",children:m})]}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx("button",{onClick:a,disabled:!_||t,className:"text-white/25 hover:text-white/55 transition-colors p-1.5 disabled:opacity-30 disabled:cursor-not-allowed",title:"Reset canvas",children:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"})})}),r.jsx("button",{onClick:T,disabled:!f,className:R("flex items-center gap-1.5 text-[13px] font-medium px-2.5 py-1 rounded-md transition-colors",f?"bg-green-500/20 text-green-300 border border-green-500/30 hover:bg-green-500/30":"bg-white/[0.05] text-white/25 border border-white/[0.06] cursor-not-allowed"),title:N.errors.length>0?N.errors.map(c=>c.message).join(` -`):"Run the workflow inline",children:t?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"w-2.5 h-2.5 border-2 border-green-300/60 border-t-transparent rounded-full animate-spin"}),r.jsx("span",{className:"hidden sm:inline",children:"Running…"})]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"currentColor",children:r.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Run"]})}),r.jsx("button",{onClick:E,disabled:!_||t,className:R("text-[13px] px-2.5 py-1 rounded-md border border-white/[0.08] transition-colors",_&&!t?"text-white/60 hover:border-white/[0.15] hover:text-white/85":"text-white/20 opacity-40 cursor-not-allowed"),title:g?`Update "${g.name}"`:"Save as new workflow",children:g?"Update":"Save"}),g&&r.jsx("button",{onClick:A,disabled:!_||t,className:"text-white/35 hover:text-white/65 transition-colors p-1.5 disabled:opacity-30 disabled:cursor-not-allowed",title:"Save as a new workflow",children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"}),r.jsx("path",{d:"M7 21h12a2 2 0 002-2V9"})]})}),r.jsxs("button",{onClick:I,disabled:!_||t,className:R("flex items-center gap-1.5 text-[13px] font-medium px-2.5 py-1 rounded-md transition-colors",_&&!t?"bg-white text-black hover:bg-white/90":"bg-white/[0.05] text-white/30 cursor-not-allowed"),title:"Open in Workflows tab",children:[r.jsx("span",{className:"hidden md:inline",children:"Open in Workflows"}),r.jsx("span",{className:"md:hidden",children:"Open"}),r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:r.jsx("path",{d:"M7 17L17 7M7 7h10v10"})})]})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ft,{nodes:e.nodes,edges:e.edges})})]})]})}export{yt as PlaygroundView}; diff --git a/ventures/havre/open/assets/workflow-engine-BHZwbSiT.js b/ventures/havre/open/assets/workflow-engine-BHZwbSiT.js deleted file mode 100644 index d8ab333..0000000 --- a/ventures/havre/open/assets/workflow-engine-BHZwbSiT.js +++ /dev/null @@ -1,11 +0,0 @@ -import{B as Ir,C as ba,R as _a,D as Ea,r as D,j as A,g as An,q as Sa,v as Na,w as Ca,x as Ma,y as Nt,E as ka,F as Ia}from"./index-BK6OjN4-.js";function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n{}};function Jt(){for(var e=0,t=arguments.length,n={},o;e=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}zt.prototype=Jt.prototype={constructor:zt,on:function(e,t){var n=this._,o=$a(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i0)for(var n=new Array(r),o=0,r,i;o=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),vo.hasOwnProperty(t)?{space:vo[t],local:e}:e}function Ta(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===$n&&t.documentElement.namespaceURI===$n?t.createElement(e):t.createElementNS(n,e)}}function Da(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ar(e){var t=en(e);return(t.local?Da:Ta)(t)}function Ra(){}function Xn(e){return e==null?Ra:function(){return this.querySelector(e)}}function za(e){typeof e!="function"&&(e=Xn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r=p&&(p=b+1);!(S=w[p])&&++p=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function ac(e){e||(e=cc);function t(l,f){return l&&f?e(l.__data__,f.__data__):!l-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;it?1:e>=t?0:NaN}function uc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function lc(){return Array.from(this)}function dc(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?_c:typeof t=="function"?Sc:Ec)(e,t,n??"")):Xe(this.node(),e)}function Xe(e,t){return e.style.getPropertyValue(t)||Rr(e).getComputedStyle(e,null).getPropertyValue(t)}function Cc(e){return function(){delete this[e]}}function Mc(e,t){return function(){this[e]=t}}function kc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ic(e,t){return arguments.length>1?this.each((t==null?Cc:typeof t=="function"?kc:Mc)(e,t)):this.node()[e]}function zr(e){return e.trim().split(/^|\s+/)}function Yn(e){return e.classList||new Hr(e)}function Hr(e){this._node=e,this._names=zr(e.getAttribute("class")||"")}Hr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Lr(e,t){for(var n=Yn(e),o=-1,r=t.length;++o=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function ou(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n()=>e;function Pn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Pn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hu(e){return!e.ctrlKey&&!e.button}function pu(){return this.parentNode}function gu(e,t){return t??{x:e.x,y:e.y}}function mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wr(){var e=hu,t=pu,n=gu,o=mu,r={},i=Jt("start","drag","end"),s=0,a,c,u,d,l=0;function f(x){x.on("mousedown.drag",h).filter(o).on("touchstart.drag",w).on("touchmove.drag",y,fu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,S){if(!(d||!e.call(this,x,S))){var _=p(this,t.call(this,x,S),x,S,"mouse");_&&(ce(x.view).on("mousemove.drag",g,ut).on("mouseup.drag",m,ut),Fr(x.view),gn(x),u=!1,a=x.clientX,c=x.clientY,_("start",x))}}function g(x){if(Fe(x),!u){var S=x.clientX-a,_=x.clientY-c;u=S*S+_*_>l}r.mouse("drag",x)}function m(x){ce(x.view).on("mousemove.drag mouseup.drag",null),jr(x.view,u),Fe(x),r.mouse("end",x)}function w(x,S){if(e.call(this,x,S)){var _=x.changedTouches,N=t.call(this,x,S),P=_.length,T,O;for(T=0;T>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=xu.exec(e))?new ae(t[1],t[2],t[3],1):(t=wu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vu.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=bu.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_u.exec(e))?Mo(t[1],t[2]/100,t[3]/100,1):(t=Eu.exec(e))?Mo(t[1],t[2]/100,t[3]/100,t[4]):bo.hasOwnProperty(e)?So(bo[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function So(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ae(e,t,n,o)}function Cu(e){return e instanceof wt||(e=De(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Tn(e,t,n,o){return arguments.length===1?Cu(e):new ae(e,t,n,o??1)}function ae(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Zn(ae,Tn,Xr(wt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?lt:Math.pow(lt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Pe(this.r),Pe(this.g),Pe(this.b),jt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:No,formatHex:No,formatHex8:Mu,formatRgb:Co,toString:Co}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function Mu(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function Co(){const e=jt(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function jt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function Mo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new de(e,t,n,o)}function Yr(e){if(e instanceof de)return new de(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=De(e)),!e)return new de;if(e instanceof de)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n0&&c<1?0:s,new de(s,a,c,e.opacity)}function ku(e,t,n,o){return arguments.length===1?Yr(e):new de(e,t,n,o??1)}function de(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Zn(de,ku,Xr(wt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new de(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?lt:Math.pow(lt,e),new de(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ae(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new de(ko(this.h),kt(this.s),kt(this.l),jt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=jt(this.opacity);return`${e===1?"hsl(":"hsla("}${ko(this.h)}, ${kt(this.s)*100}%, ${kt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ko(e){return e=(e||0)%360,e<0?e+360:e}function kt(e){return Math.max(0,Math.min(1,e||0))}function mn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const qn=e=>()=>e;function Iu(e,t){return function(n){return e+n*t}}function Au(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function $u(e){return(e=+e)==1?Zr:function(t,n){return n-t?Au(t,n,e):qn(isNaN(t)?n:t)}}function Zr(e,t){var n=t-e;return n?Iu(e,n):qn(isNaN(e)?t:e)}const Wt=(function e(t){var n=$u(t);function o(r,i){var s=n((r=Tn(r)).r,(i=Tn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),u=Zr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=c(d),r.opacity=u(d),r+""}}return o.gamma=e,o})(1);function Pu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;rn&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:ge(o,r)})),n=yn.lastIndex;return n180?d+=360:d-u>180&&(u+=360),f.push({i:l.push(r(l)+"rotate(",null,o)-2,x:ge(u,d)})):d&&l.push(r(l)+"rotate("+d+o)}function a(u,d,l,f){u!==d?f.push({i:l.push(r(l)+"skewX(",null,o)-2,x:ge(u,d)}):d&&l.push(r(l)+"skewX("+d+o)}function c(u,d,l,f,h,g){if(u!==l||d!==f){var m=h.push(r(h)+"scale(",null,",",null,")");g.push({i:m-4,x:ge(u,l)},{i:m-2,x:ge(d,f)})}else(l!==1||f!==1)&&h.push(r(h)+"scale("+l+","+f+")")}return function(u,d){var l=[],f=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,l,f),s(u.rotate,d.rotate,l,f),a(u.skewX,d.skewX,l,f),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,l,f),u=d=null,function(h){for(var g=-1,m=f.length,w;++g=0&&e._call.call(void 0,t),e=e._next;--Ye}function $o(){Re=(Yt=ft.now())+tn,Ye=it=0;try{Zu()}finally{Ye=0,Gu(),Re=0}}function qu(){var e=ft.now(),t=e-Yt;t>Kr&&(tn-=t,Yt=e)}function Gu(){for(var e,t=Xt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Xt=n);st=e,zn(o)}function zn(e){if(!Ye){it&&(it=clearTimeout(it));var t=e-Re;t>24?(e<1/0&&(it=setTimeout($o,e-ft.now()-tn)),nt&&(nt=clearInterval(nt))):(nt||(Yt=ft.now(),nt=setInterval(qu,Kr)),Ye=1,Qr($o))}}function Po(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Uu=Jt("start","end","cancel","interrupt"),Ku=[],ei=0,To=1,Hn=2,Lt=3,Do=4,Ln=5,Vt=6;function nn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Qu(e,n,{name:t,index:o,group:r,on:Uu,tween:Ku,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ei})}function Un(e,t){var n=pe(e,t);if(n.state>ei)throw new Error("too late; already scheduled");return n}function xe(e,t){var n=pe(e,t);if(n.state>Lt)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Qu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Jr(i,0,n.time);function i(u){n.state=To,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var d,l,f,h;if(n.state!==To)return c();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Lt)return Po(s);h.state===Do?(h.state=Vt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+dHn&&o.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function kl(e,t,n){var o,r,i=Ml(t)?Un:xe;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Il(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(kl(n,e,t))}function Al(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function $l(){return this.on("end.remove",Al(this._id))}function Pl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s()=>e;function od(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var on=new be(1,0,0);ri.prototype=be.prototype;function ri(e){for(;!e.__zoom;)if(!(e=e.parentNode))return on;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function ot(e){e.preventDefault(),e.stopImmediatePropagation()}function rd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function id(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ro(){return this.__zoom||on}function sd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ad(){return navigator.maxTouchPoints||"ontouchstart"in this}function cd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ii(){var e=rd,t=id,n=cd,o=sd,r=ad,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ht,u=Jt("start","zoom","end"),d,l,f,h=500,g=150,m=0,w=10;function y(v){v.property("__zoom",Ro).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",I).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(v,C,E,k){var M=v.selection?v.selection():v;M.property("__zoom",Ro),v!==M?S(v,C,E,k):M.interrupt().each(function(){_(this,arguments).event(k).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},y.scaleBy=function(v,C,E,k){y.scaleTo(v,function(){var M=this.__zoom.k,$=typeof C=="function"?C.apply(this,arguments):C;return M*$},E,k)},y.scaleTo=function(v,C,E,k){y.transform(v,function(){var M=t.apply(this,arguments),$=this.__zoom,z=E==null?x(M):typeof E=="function"?E.apply(this,arguments):E,V=$.invert(z),L=typeof C=="function"?C.apply(this,arguments):C;return n(p(b($,L),z,V),M,s)},E,k)},y.translateBy=function(v,C,E,k){y.transform(v,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),s)},null,k)},y.translateTo=function(v,C,E,k,M){y.transform(v,function(){var $=t.apply(this,arguments),z=this.__zoom,V=k==null?x($):typeof k=="function"?k.apply(this,arguments):k;return n(on.translate(V[0],V[1]).scale(z.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof E=="function"?-E.apply(this,arguments):-E),$,s)},k,M)};function b(v,C){return C=Math.max(i[0],Math.min(i[1],C)),C===v.k?v:new be(C,v.x,v.y)}function p(v,C,E){var k=C[0]-E[0]*v.k,M=C[1]-E[1]*v.k;return k===v.x&&M===v.y?v:new be(v.k,k,M)}function x(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,C,E,k){v.on("start.zoom",function(){_(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(k).end()}).tween("zoom",function(){var M=this,$=arguments,z=_(M,$).event(k),V=t.apply(M,$),L=E==null?x(V):typeof E=="function"?E.apply(M,$):E,j=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),F=M.__zoom,Z=typeof C=="function"?C.apply(M,$):C,U=c(F.invert(L).concat(j/F.k),Z.invert(L).concat(j/Z.k));return function(Y){if(Y===1)Y=Z;else{var B=U(Y),W=j/B[2];Y=new be(W,L[0]-B[0]*W,L[1]-B[1]*W)}z.zoom(null,Y)}})}function _(v,C,E){return!E&&v.__zooming||new N(v,C)}function N(v,C){this.that=v,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,C),this.taps=0}N.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,C){return this.mouse&&v!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var C=ce(this.that).datum();u.call(v,this.that,new od(v,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),C)}};function P(v,...C){if(!e.apply(this,arguments))return;var E=_(this,C).event(v),k=this.__zoom,M=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,o.apply(this,arguments)))),$=le(v);if(E.wheel)(E.mouse[0][0]!==$[0]||E.mouse[0][1]!==$[1])&&(E.mouse[1]=k.invert(E.mouse[0]=$)),clearTimeout(E.wheel);else{if(k.k===M)return;E.mouse=[$,k.invert($)],Ot(this),E.start()}ot(v),E.wheel=setTimeout(z,g),E.zoom("mouse",n(p(b(k,M),E.mouse[0],E.mouse[1]),E.extent,s));function z(){E.wheel=null,E.end()}}function T(v,...C){if(f||!e.apply(this,arguments))return;var E=v.currentTarget,k=_(this,C,!0).event(v),M=ce(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",j,!0),$=le(v,E),z=v.clientX,V=v.clientY;Fr(v.view),xn(v),k.mouse=[$,this.__zoom.invert($)],Ot(this),k.start();function L(F){if(ot(F),!k.moved){var Z=F.clientX-z,U=F.clientY-V;k.moved=Z*Z+U*U>m}k.event(F).zoom("mouse",n(p(k.that.__zoom,k.mouse[0]=le(F,E),k.mouse[1]),k.extent,s))}function j(F){M.on("mousemove.zoom mouseup.zoom",null),jr(F.view,k.moved),ot(F),k.event(F).end()}}function O(v,...C){if(e.apply(this,arguments)){var E=this.__zoom,k=le(v.changedTouches?v.changedTouches[0]:v,this),M=E.invert(k),$=E.k*(v.shiftKey?.5:2),z=n(p(b(E,$),k,M),t.apply(this,C),s);ot(v),a>0?ce(this).transition().duration(a).call(S,z,k,v):ce(this).call(y.transform,z,k,v)}}function I(v,...C){if(e.apply(this,arguments)){var E=v.touches,k=E.length,M=_(this,C,v.changedTouches.length===k).event(v),$,z,V,L;for(xn(v),z=0;z"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],si=["Enter"," ","Escape"],ai={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const ci={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Me;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Me||(Me={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const zo={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ui(e){return e===null?null:e?"valid":"invalid"}const li=e=>"id"in e&&"source"in e&&"target"in e,ud=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=Ee(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},ld=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Qn(r)?r:t.nodeLookup.get(r.id));const a=s?Gt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return rn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return sn(n)},bt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=rn(n,Gt(r)),o=!0)}),o?sn(n):{x:0,y:0,width:0,height:0}},Jn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:d,selectable:l=!0,hidden:f=!1}=u;if(s&&!l||f)continue;const h=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,m=gt(a,Ge(u)),w=(h??0)*(g??0),y=i&&m>0;(!u.internals.handleBounds||y||m>=w||u.dragging)&&c.push(u)}return c},dd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function fd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function hd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=fd(e,s),c=bt(a),u=eo(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(u,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function di({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let l=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(l=[[c,u],[c+h,u+g]])}else a&&Ue(s.extent)&&(l=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const f=Ue(l)?ze(t,l,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:f.x-c+(s.measured.width??0)*d[0],y:f.y-u+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function pd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(m=>m.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=o.filter(f=>f.deletable!==!1),d=dd(s,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const l=await r({nodes:s,edges:d});return typeof l=="boolean"?l?{edges:d,nodes:s}:{edges:[],nodes:[]}:l}const qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ze=(e={x:0,y:0},t,n)=>({x:qe(e.x,t[0][0],t[1][0]-(n?.width??0)),y:qe(e.y,t[0][1],t[1][1]-(n?.height??0))});function fi(e,t,n){const{width:o,height:r}=Ee(n),{x:i,y:s}=n.internals.positionAbsolute;return ze(e,[[i,s],[i+o,s+r]],t)}const Ho=(e,t,n)=>en?-qe(Math.abs(e-n),1,t)/t:0,hi=(e,t,n=15,o=40)=>{const r=Ho(e.x,o,t.width-o)*n,i=Ho(e.y,o,t.height-o)*n;return[r,i]},rn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Vn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),sn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ge=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Gt=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},pi=(e,t)=>sn(rn(Vn(e),Vn(t))),gt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Lo=e=>fe(e.width)&&fe(e.height)&&fe(e.x)&&fe(e.y),fe=e=>!isNaN(e)&&isFinite(e),gd=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?_t(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Ve(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function md(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Ve(e,n),r=Ve(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Ve(e.top??e.y??0,n),r=Ve(e.bottom??e.y??0,n),i=Ve(e.left??e.x??0,t),s=Ve(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function yd(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:c,y:u}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-c,l=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(l)}}const eo=(e,t,n,o,r,i)=>{const s=md(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),d=qe(u,o,r),l=e.x+e.width/2,f=e.y+e.height/2,h=t/2-l*d,g=n/2-f*d,m=yd(e,h,g,d,t,n),w={left:Math.min(m.left-s.left,0),top:Math.min(m.top-s.top,0),right:Math.min(m.right-s.right,0),bottom:Math.min(m.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function Ee(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gi(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function mi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Vo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function wd(e){return{...ai,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=he(e),a=Et({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:u}=n?_t(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const to=e=>({width:e.offsetWidth,height:e.offsetHeight}),yi=e=>e?.getRootNode?.()||window?.document,vd=["INPUT","SELECT","TEXTAREA"];function xi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:vd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const wi=e=>"clientX"in e,he=(e,t)=>{const n=wi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Oo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...to(s)}})};function vi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+o*.125,d=Math.abs(c-e),l=Math.abs(u-t);return[c,u,d,l]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Bo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-$t(t-o,i),n];case X.Right:return[t+$t(o-t,i),n];case X.Top:return[t,n-$t(n-r,i)];case X.Bottom:return[t,n+$t(r-n,i)]}}function bi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Bo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[u,d]=Bo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[l,f,h,g]=vi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${c} ${u},${d} ${o},${r}`,l,f,h,g]}function _i({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n0}const Ed=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Sd=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Nd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Ed;let r;return li(e)?r={...e}:r={...e,id:o(e)},Sd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Ei({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=_i({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Fo={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},Cd=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Md({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Fo[t],c=Fo[o],u={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},l=Cd({source:u,sourcePosition:t,target:d}),f=l.x!==0?"x":"y",h=l[f];let g=[],m,w;const y={x:0,y:0},b={x:0,y:0},[,,p,x]=_i({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(m=r.x??u.x+(d.x-u.x)*s,w=r.y??(u.y+d.y)/2):(m=r.x??(u.x+d.x)/2,w=r.y??u.y+(d.y-u.y)*s);const _=[{x:m,y:u.y},{x:m,y:d.y}],N=[{x:u.x,y:w},{x:d.x,y:w}];a[f]===h?g=f==="x"?_:N:g=f==="x"?N:_}else{const _=[{x:u.x,y:d.y}],N=[{x:d.x,y:u.y}];if(f==="x"?g=a.x===h?N:_:g=a.y===h?_:N,t===o){const R=Math.abs(e[f]-n[f]);if(R<=i){const H=Math.min(i-1,i-R);a[f]===h?y[f]=(u[f]>e[f]?-1:1)*H:b[f]=(d[f]>n[f]?-1:1)*H}}if(t!==o){const R=f==="x"?"y":"x",H=a[f]===c[R],v=u[R]>d[R],C=u[R]=I?(m=(P.x+T.x)/2,w=g[0].y):(m=g[0].x,w=(P.y+T.y)/2)}return[[e,{x:u.x+y.x,y:u.y+y.y},...g,{x:d.x+b.x,y:d.y+b.y},n],m,w,p,x]}function kd(e,t,n,o){const r=Math.min(jo(e,t)/2,jo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x{let x="";return p>0&&pn.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Ad(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Bn(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Si=1e3,$d=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Pd={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Td(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=ze(i,s,Ee(r));r.internals.positionAbsolute=a}}function Dd(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function ro(e){return e==="manual"}function Fn(e,t,n,o={}){const r=oo(Pd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?Si:0;let c=e.length>0;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===d?.internals.userNode)t.set(u.id,d);else{const l=vt(u,r.nodeOrigin),f=Ue(u.extent)?u.extent:r.nodeExtent,h=ze(l,f,Ee(u));d={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:h,handleBounds:Dd(u,d),z:Ni(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&io(d,t,n,o,i)}return c}function Rd(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=oo(no,o),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Rd(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*$d),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const l=i&&!ro(c)?Si:0,{x:f,y:h,z:g}=zd(e,d,s,a,l,c),{positionAbsolute:m}=e.internals,w=f!==m.x||h!==m.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:m,z:g}})}function Ni(e,t,n){const o=fe(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function zd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Ee(e),u=vt(e,n),d=Ue(e.extent)?ze(u,e.extent,c):u;let l=ze({x:s+d.x,y:a+d.y},o,c);e.extent==="parent"&&(l=fi(l,c,t));const f=Ni(e,r,i),h=t.internals.z??0;return{x:l.x,y:l.y,z:h>=f?h+1:f}}function so(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??Ge(a),u=pi(c,s.rect);i.set(s.parentId,{expandedRect:u,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const u=a.internals.positionAbsolute,d=Ee(a),l=a.origin??o,f=s.x0||h>0||w||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-f+w,y:a.position.y-h+y}}),n.get(c)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width0){const h=so(f,t,n,r);u.push(...h)}return{changes:u,updatedInternals:c}}async function Ld({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Zo(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const u=o.get(s)||new Map;o.set(s,u.set(n,t))}}function Ci(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Zo("source",c,d,e,r,s),Zo("target",c,u,e,i,a),t.set(o.id,o)}}function Mi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Mi(n,t):!1}function qo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Vd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Mi(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Od({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=_t(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Bd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},d=null,l=!1,f=null,h=!1,g=!1,m=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:S,nodeId:_,nodeClickDistance:N=0}){f=ce(x);function P({x:R,y:H}){const{nodeLookup:v,nodeExtent:C,snapGrid:E,snapToGrid:k,nodeOrigin:M,onNodeDrag:$,onSelectionDrag:z,onError:V,updateNodePositions:L}=t();i={x:R,y:H};let j=!1;const F=a.size>1,Z=F&&C?Vn(bt(a)):null,U=F&&k?Od({dragItems:a,snapGrid:E,x:R,y:H}):null;for(const[Y,B]of a){if(!v.has(Y))continue;let W={x:R-B.distance.x,y:H-B.distance.y};k&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:_t(W,E));let Q=null;if(F&&C&&!B.extent&&Z){const{positionAbsolute:G}=B.internals,ee=G.x-Z.x+C[0][0],ne=G.x+B.measured.width-Z.x2+C[1][0],te=G.y-Z.y+C[0][1],se=G.y+B.measured.height-Z.y2+C[1][1];Q=[[ee,te],[ne,se]]}const{position:K,positionAbsolute:q}=di({nodeId:Y,nextPosition:W,nodeLookup:v,nodeExtent:Q||C,nodeOrigin:M,onError:V});j=j||B.position.x!==K.x||B.position.y!==K.y,B.position=K,B.internals.positionAbsolute=q}if(g=g||j,!!j&&(L(a,!0),m&&(o||$||!_&&z))){const[Y,B]=wn({nodeId:_,dragItems:a,nodeLookup:v});o?.(m,a,Y,B),$?.(m,Y,B),_||z?.(m,B)}}async function T(){if(!d)return;const{transform:R,panBy:H,autoPanSpeed:v,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(s);return}const[E,k]=hi(u,d,v);(E!==0||k!==0)&&(i.x=(i.x??0)-E/R[2],i.y=(i.y??0)-k/R[2],await H({x:E,y:k})&&P(i)),s=requestAnimationFrame(T)}function O(R){const{nodeLookup:H,multiSelectionActive:v,nodesDraggable:C,transform:E,snapGrid:k,snapToGrid:M,selectNodesOnDrag:$,onNodeDragStart:z,onSelectionDragStart:V,unselectNodesAndEdges:L}=t();l=!0,(!$||!S)&&!v&&_&&(H.get(_)?.selected||L()),S&&$&&_&&e?.(_);const j=ct(R.sourceEvent,{transform:E,snapGrid:k,snapToGrid:M,containerBounds:d});if(i=j,a=Vd(H,C,j,_),a.size>0&&(n||z||!_&&V)){const[F,Z]=wn({nodeId:_,dragItems:a,nodeLookup:H});n?.(R.sourceEvent,a,F,Z),z?.(R.sourceEvent,F,Z),_||V?.(R.sourceEvent,Z)}}const I=Wr().clickDistance(N).on("start",R=>{const{domNode:H,nodeDragThreshold:v,transform:C,snapGrid:E,snapToGrid:k}=t();d=H?.getBoundingClientRect()||null,h=!1,g=!1,m=R.sourceEvent,v===0&&O(R),i=ct(R.sourceEvent,{transform:C,snapGrid:E,snapToGrid:k,containerBounds:d}),u=he(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:H,transform:v,snapGrid:C,snapToGrid:E,nodeDragThreshold:k,nodeLookup:M}=t(),$=ct(R.sourceEvent,{transform:v,snapGrid:C,snapToGrid:E,containerBounds:d});if(m=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||_&&!M.has(_))&&(h=!0),!h){if(!c&&H&&l&&(c=!0,T()),!l){const z=he(R.sourceEvent,d),V=z.x-u.x,L=z.y-u.y;Math.sqrt(V*V+L*L)>k&&O(R)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&a&&l&&(u=he(R.sourceEvent,d),P($))}}).on("end",R=>{if(!(!l||h)&&(c=!1,l=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:H,updateNodePositions:v,onNodeDragStop:C,onSelectionDragStop:E}=t();if(g&&(v(a,!1),g=!1),r||C||!_&&E){const[k,M]=wn({nodeId:_,dragItems:a,nodeLookup:H,dragging:!1});r?.(R.sourceEvent,a,k,M),C?.(R.sourceEvent,k,M),_||E?.(R.sourceEvent,M)}}}).filter(R=>{const H=R.target;return!R.button&&(!b||!qo(H,`.${b}`,x))&&(!p||qo(H,p,x))});f.call(I)}function y(){f?.on(".drag",null)}return{update:w,destroy:y}}function Fd(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())gt(r,Ge(i))>0&&o.push(i);return o}const jd=250;function Wd(e,t,n,o){let r=[],i=1/0;const s=Fd(e,n,t+jd);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const u of c){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:d,y:l}=He(a,u,u.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(l-e.y,2));f>t||(f1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function ki(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(u=>u.id===n):a?.[0])??null;return c&&i?{...c,...He(s,c,c.position,!0)}:c}function Ii(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Xd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ai=()=>!0;function Yd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:l,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:m,onConnectEnd:w,isValidConnection:y=Ai,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:S,autoPanSpeed:_,dragThreshold:N=1,handleDomNode:P}){const T=yi(e.target);let O=0,I;const{x:R,y:H}=he(e),v=Ii(i,P),C=a?.getBoundingClientRect();let E=!1;if(!C||!v)return;const k=ki(r,v,o,c,t);if(!k)return;let M=he(e,C),$=!1,z=null,V=!1,L=null;function j(){if(!d||!C)return;const[K,q]=hi(M,C,_);f({x:K,y:q}),O=requestAnimationFrame(j)}const F={...k,nodeId:r,type:v,position:k.position},Z=c.get(r);let Y={inProgress:!0,isValid:null,from:He(Z,F,X.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:Z,to:M,toHandle:null,toPosition:zo[F.position],toNode:null,pointer:M};function B(){E=!0,p(Y),g?.(e,{nodeId:r,handleId:o,handleType:v})}N===0&&B();function W(K){if(!E){const{x:se,y:Se}=he(K),we=se-R,Ie=Se-H;if(!(we*we+Ie*Ie>N*N))return;B()}if(!S()||!F){Q(K);return}const q=x();M=he(K,C),I=Wd(Et(M,q,!1,[1,1]),n,c,F),$||(j(),$=!0);const G=$i(K,{handle:I,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:T,lib:u,flowId:l,nodeLookup:c});L=G.handleDomNode,z=G.connection,V=Xd(!!I,G.isValid);const ee=c.get(r),ne=ee?He(ee,F,X.Left,!0):Y.from,te={...Y,from:ne,isValid:V,to:G.toHandle&&V?Ut({x:G.toHandle.x,y:G.toHandle.y},q):M,toHandle:G.toHandle,toPosition:V&&G.toHandle?G.toHandle.position:zo[F.position],toNode:G.toHandle?c.get(G.toHandle.nodeId):null,pointer:M};p(te),Y=te}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(E){(I||L)&&z&&V&&m?.(z);const{inProgress:q,...G}=Y,ee={...G,toPosition:Y.toHandle?Y.toPosition:null};w?.(K,ee),i&&b?.(K,ee)}h(),cancelAnimationFrame(O),$=!1,V=!1,z=null,L=null,T.removeEventListener("mousemove",W),T.removeEventListener("mouseup",Q),T.removeEventListener("touchmove",W),T.removeEventListener("touchend",Q)}}T.addEventListener("mousemove",W),T.addEventListener("mouseup",Q),T.addEventListener("touchmove",W),T.addEventListener("touchend",Q)}function $i(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=Ai,nodeLookup:d}){const l=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=he(e),m=s.elementFromPoint(h,g),w=m?.classList.contains(`${a}-flow__handle`)?m:f,y={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=Ii(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),_=w.classList.contains("connectableend");if(!p||!b)return y;const N={source:l?p:o,sourceHandle:l?x:r,target:l?o:p,targetHandle:l?r:x};y.connection=N;const T=S&&_&&(n===Ze.Strict?l&&b==="source"||!l&&b==="target":p!==o||x!==r);y.isValid=T&&u(N),y.toHandle=ki(p,b,x,d,n,!0)}return y}const jn={onPointerDown:Yd,isValid:$i};function Zd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:d=1,pannable:l=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,N=x[2]*Math.pow(2,_*S);t.scaleTo(N)};let m=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(m=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},y=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],_=[S[0]-m[0],S[1]-m[1]];m=S;const N=o()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),P={x:x[0]-_[0]*N,y:x[1]-_[1]*N},T=[[0,0],[c,u]];t.setViewportConstrained({x:P.x,y:P.y,zoom:x[2]},T,a)},b=ii().on("start",w).on("zoom",l?y:null).on("zoom.wheel",f?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:le}}const an=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>on.translate(e,t).scale(n),Oe=(e,t)=>e.target.closest(`.${t}`),Pi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=qd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Ti=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Gd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Oe(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const l=n.property("__zoom").k||1;if(d.ctrlKey&&s){const w=le(d),y=Ti(d),b=l*Math.pow(2,y);o.scaleTo(n,b,w,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,g=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,g=0),o.translateBy(n,-(h/l)*i,-(g/l)*i,{internal:!0});const m=an(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,m),e.panScrollTimeout=setTimeout(()=>{u?.(d,m),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,m))}}function Ud({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Oe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Kd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=an(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Qd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Pi(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,an(i.transform))}}function Jd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Pi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=an(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function ef({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:d}){return l=>{const f=e||t,h=n&&l.ctrlKey,g=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Oe(l,`${u}-flow__node`)||Oe(l,`${u}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!g||Oe(l,a)&&g||Oe(l,c)&&(!g||r&&g&&!e)||!n&&l.ctrlKey&&g)return!1;if(!n&&l.type==="touchstart"&&l.touches?.length>1)return l.preventDefault(),!1;if(!f&&!r&&!h&&g||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const m=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||g)&&m}}function tf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),l=ii().scaleExtent([t,n]).translateExtent(o),f=ce(e).call(l);b({x:r.x,y:r.y,zoom:qe(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");l.wheelDelta(Ti);function m(I,R){return f?new Promise(H=>{l?.interpolate(R?.interpolate==="linear"?at:Ht).transform(bn(f,R?.duration,R?.ease,()=>H(!0)),I)}):Promise.resolve(!1)}function w({noWheelClassName:I,noPanClassName:R,onPaneContextMenu:H,userSelectionActive:v,panOnScroll:C,panOnDrag:E,panOnScrollMode:k,panOnScrollSpeed:M,preventScrolling:$,zoomOnPinch:z,zoomOnScroll:V,zoomOnDoubleClick:L,zoomActivationKeyPressed:j,lib:F,onTransformChange:Z,connectionInProgress:U,paneClickDistance:Y,selectionOnDrag:B}){v&&!u.isZoomingOrPanning&&y();const W=C&&!j&&!v;l.clickDistance(B?1/0:!fe(Y)||Y<0?0:Y);const Q=W?Gd({zoomPanValues:u,noWheelClassName:I,d3Selection:f,d3Zoom:l,panOnScrollMode:k,panOnScrollSpeed:M,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Ud({noWheelClassName:I,preventScrolling:$,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Kd({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});l.on("start",q);const G=Qd({zoomPanValues:u,panOnDrag:E,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:Z});l.on("zoom",G);const ee=Jd({zoomPanValues:u,panOnDrag:E,panOnScroll:C,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:c});l.on("end",ee)}const K=ef({zoomActivationKeyPressed:j,panOnDrag:E,zoomOnScroll:V,panOnScroll:C,zoomOnDoubleClick:L,zoomOnPinch:z,userSelectionActive:v,noPanClassName:R,noWheelClassName:I,lib:F,connectionInProgress:U});l.filter(K),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){l.on("zoom",null)}async function b(I,R,H){const v=vn(I),C=l?.constrain()(v,R,H);return C&&await m(C),new Promise(E=>E(C))}async function p(I,R){const H=vn(I);return await m(H,R),new Promise(v=>v(H))}function x(I){if(f){const R=vn(I),H=f.property("__zoom");(H.k!==I.zoom||H.x!==I.x||H.y!==I.y)&&l?.transform(f,R,null,{sync:!0})}}function S(){const I=f?ri(f.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}function _(I,R){return f?new Promise(H=>{l?.interpolate(R?.interpolate==="linear"?at:Ht).scaleTo(bn(f,R?.duration,R?.ease,()=>H(!0)),I)}):Promise.resolve(!1)}function N(I,R){return f?new Promise(H=>{l?.interpolate(R?.interpolate==="linear"?at:Ht).scaleBy(bn(f,R?.duration,R?.ease,()=>H(!0)),I)}):Promise.resolve(!1)}function P(I){l?.scaleExtent(I)}function T(I){l?.translateExtent(I)}function O(I){const R=!fe(I)||I<0?0:I;l?.clickDistance(R)}return{update:w,destroy:y,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:_,scaleBy:N,setScaleExtent:P,setTranslateExtent:T,syncViewport:x,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function nf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function Go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Ne(e,t){return Math.max(0,t-e)}function Ce(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function Uo(e,t){return e?!t:t}function of(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:l}=t,f=d&&l,{xSnapped:h,ySnapped:g}=n,{minWidth:m,maxWidth:w,minHeight:y,maxHeight:b}=o,{x:p,y:x,width:S,height:_,aspectRatio:N}=e;let P=Math.floor(d?h-e.pointerX:0),T=Math.floor(l?g-e.pointerY:0);const O=S+(c?-P:P),I=_+(u?-T:T),R=-i[0]*S,H=-i[1]*_;let v=Pt(O,m,w),C=Pt(I,y,b);if(s){let M=0,$=0;c&&P<0?M=Ne(p+P+R,s[0][0]):!c&&P>0&&(M=Ce(p+O+R,s[1][0])),u&&T<0?$=Ne(x+T+H,s[0][1]):!u&&T>0&&($=Ce(x+I+H,s[1][1])),v=Math.max(v,M),C=Math.max(C,$)}if(a){let M=0,$=0;c&&P>0?M=Ce(p+P,a[0][0]):!c&&P<0&&(M=Ne(p+O,a[1][0])),u&&T>0?$=Ce(x+T,a[0][1]):!u&&T<0&&($=Ne(x+I,a[1][1])),v=Math.max(v,M),C=Math.max(C,$)}if(r){if(d){const M=Pt(O/N,y,b)*N;if(v=Math.max(v,M),s){let $=0;!c&&!u||c&&!u&&f?$=Ce(x+H+O/N,s[1][1])*N:$=Ne(x+H+(c?P:-P)/N,s[0][1])*N,v=Math.max(v,$)}if(a){let $=0;!c&&!u||c&&!u&&f?$=Ne(x+O/N,a[1][1])*N:$=Ce(x+(c?P:-P)/N,a[0][1])*N,v=Math.max(v,$)}}if(l){const M=Pt(I*N,m,w)/N;if(C=Math.max(C,M),s){let $=0;!c&&!u||u&&!c&&f?$=Ce(p+I*N+R,s[1][0])/N:$=Ne(p+(u?T:-T)*N+R,s[0][0])/N,C=Math.max(C,$)}if(a){let $=0;!c&&!u||u&&!c&&f?$=Ne(p+I*N,a[1][0])/N:$=Ce(p+(u?T:-T)*N,a[0][0])/N,C=Math.max(C,$)}}}T=T+(T<0?C:-C),P=P+(P<0?v:-v),r&&(f?O>I*N?T=(Uo(c,u)?-P:P)/N:P=(Uo(c,u)?-T:T)*N:d?(T=P/N,u=c):(P=T*N,c=u));const E=c?p+P:p,k=u?x+T:x;return{width:S+(c?-P:P),height:_+(u?-T:T),x:i[0]*P*(c?-1:1)+E,y:i[1]*T*(u?-1:1)+k}}const Di={width:0,height:0,x:0,y:0},rf={...Di,pointerX:0,pointerY:0,aspectRatio:1};function sf(e){return[[0,0],[e.measured.width,e.measured.height]]}function af(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function cf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ce(e);let s={controlDirection:Go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:d,keepAspectRatio:l,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:m,shouldResize:w}){let y={...Di},b={...rf};s={boundaries:d,resizeDirection:f,keepAspectRatio:l,controlDirection:Go(u)};let p,x=null,S=[],_,N,P,T=!1;const O=Wr().on("start",I=>{const{nodeLookup:R,transform:H,snapGrid:v,snapToGrid:C,nodeOrigin:E,paneDomNode:k}=n();if(p=R.get(t),!p)return;x=k?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:$}=ct(I.sourceEvent,{transform:H,snapGrid:v,snapToGrid:C,containerBounds:x});y={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...y,pointerX:M,pointerY:$,aspectRatio:y.width/y.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=R.get(p.parentId),N=_&&p.extent==="parent"?sf(_):void 0),S=[],P=void 0;for(const[z,V]of R)if(V.parentId===t&&(S.push({id:z,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const L=af(V,p,V.origin??E);P?P=[[Math.min(L[0][0],P[0][0]),Math.min(L[0][1],P[0][1])],[Math.max(L[1][0],P[1][0]),Math.max(L[1][1],P[1][1])]]:P=L}h?.(I,{...y})}).on("drag",I=>{const{transform:R,snapGrid:H,snapToGrid:v,nodeOrigin:C}=n(),E=ct(I.sourceEvent,{transform:R,snapGrid:H,snapToGrid:v,containerBounds:x}),k=[];if(!p)return;const{x:M,y:$,width:z,height:V}=y,L={},j=p.origin??C,{width:F,height:Z,x:U,y:Y}=of(b,s.controlDirection,E,s.boundaries,s.keepAspectRatio,j,N,P),B=F!==z,W=Z!==V,Q=U!==M&&B,K=Y!==$&&W;if(!Q&&!K&&!B&&!W)return;if((Q||K||j[0]===1||j[1]===1)&&(L.x=Q?U:y.x,L.y=K?Y:y.y,y.x=L.x,y.y=L.y,S.length>0)){const ne=U-M,te=Y-$;for(const se of S)se.position={x:se.position.x-ne+j[0]*(F-z),y:se.position.y-te+j[1]*(Z-V)},k.push(se)}if((B||W)&&(L.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:y.width,L.height=W&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:y.height,y.width=L.width,y.height=L.height),_&&p.expandParent){const ne=j[0]*(L.width??0);L.x&&L.x{T&&(m?.(I,{...y}),r?.({...y}),T=!1)});i.call(O)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var _n={exports:{}},En={},Sn={exports:{}},Nn={};var Ko;function uf(){if(Ko)return Nn;Ko=1;var e=Ir();function t(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(l,f){var h=f(),g=o({inst:{value:h,getSnapshot:f}}),m=g[0].inst,w=g[1];return i(function(){m.value=h,m.getSnapshot=f,c(m)&&w({inst:m})},[l,h,f]),r(function(){return c(m)&&w({inst:m}),l(function(){c(m)&&w({inst:m})})},[l]),s(h),h}function c(l){var f=l.getSnapshot;l=l.value;try{var h=f();return!n(l,h)}catch{return!0}}function u(l,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Nn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Nn}var Qo;function lf(){return Qo||(Qo=1,Sn.exports=uf()),Sn.exports}var Jo;function df(){if(Jo)return En;Jo=1;var e=Ir(),t=lf();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return En.useSyncExternalStoreWithSelector=function(u,d,l,f,h){var g=i(null);if(g.current===null){var m={hasValue:!1,value:null};g.current=m}else m=g.current;g=a(function(){function y(_){if(!b){if(b=!0,p=_,_=f(_),h!==void 0&&m.hasValue){var N=m.value;if(h(N,_))return x=N}return x=_}if(N=x,o(p,_))return N;var P=f(_);return h!==void 0&&h(N,P)?(p=_,N):(p=_,x=P)}var b=!1,p,x,S=l===void 0?null:l;return[function(){return y(d())},S===null?void 0:function(){return y(S())}]},[d,l,f,h]);var w=r(u,g[0],g[1]);return s(function(){m.hasValue=!0,m.value=w},[w]),c(w),w},En}var er;function ff(){return er||(er=1,_n.exports=df()),_n.exports}var hf=ff();const pf=ba(hf),gf={},tr=e=>{let t;const n=new Set,o=(d,l)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(gf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(o,r,c);return c},mf=e=>e?tr(e):tr,{useDebugValue:yf}=_a,{useSyncExternalStoreWithSelector:xf}=pf,wf=e=>e;function Ri(e,t=wf,n){const o=xf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yf(o),o}const nr=(e,t)=>{const n=mf(e),o=(r,i=t)=>Ri(n,r,i);return Object.assign(o,n),o},vf=(e,t)=>e?nr(e,t):nr;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}Ea();const cn=D.createContext(null),bf=cn.Provider,zi=ye.error001();function J(e,t){const n=D.useContext(cn);if(n===null)throw new Error(zi);return Ri(n,e,t)}function re(){const e=D.useContext(cn);if(e===null)throw new Error(zi);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const or={display:"none"},_f={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Hi="react-flow__node-desc",Li="react-flow__edge-desc",Ef="react-flow__aria-live",Sf=e=>e.ariaLiveMessage,Nf=e=>e.ariaLabelConfig;function Cf({rfId:e}){const t=J(Sf);return A.jsx("div",{id:`${Ef}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:_f,children:t})}function Mf({rfId:e,disableKeyboardA11y:t}){const n=J(Nf);return A.jsxs(A.Fragment,{children:[A.jsx("div",{id:`${Hi}-${e}`,style:or,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),A.jsx("div",{id:`${Li}-${e}`,style:or,children:n["edge.a11yDescription.default"]}),!t&&A.jsx(Cf,{rfId:e})]})}const un=D.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return A.jsx("div",{className:ie(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});un.displayName="Panel";function kf({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:A.jsx(un,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:A.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const If=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Tt=e=>e.id;function Af(e,t){return oe(e.selectedNodes.map(Tt),t.selectedNodes.map(Tt))&&oe(e.selectedEdges.map(Tt),t.selectedEdges.map(Tt))}function $f({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=J(If,Af);return D.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Pf=e=>!!e.onSelectionChangeHandlers;function Tf({onSelectionChange:e}){const t=J(Pf);return e||t?A.jsx($f,{onSelectionChange:e}):null}const Vi=[0,0],Df={x:0,y:0,zoom:1},Rf=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],rr=[...Rf,"rfId"],zf=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),ir={translateExtent:ht,nodeOrigin:Vi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Hf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(zf,oe),u=re();D.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=ir,a()}),[]);const d=D.useRef(ir);return D.useEffect(()=>{for(const l of rr){const f=e[l],h=d.current[l];f!==h&&(typeof e[l]>"u"||(l==="nodes"?t(f):l==="edges"?n(f):l==="minZoom"?o(f):l==="maxZoom"?r(f):l==="translateExtent"?i(f):l==="nodeExtent"?s(f):l==="ariaLabelConfig"?u.setState({ariaLabelConfig:wd(f)}):l==="fitView"?u.setState({fitViewQueued:f}):l==="fitViewOptions"?u.setState({fitViewOptions:f}):u.setState({[l]:f})))}d.current=e},rr.map(l=>e[l])),null}function sr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lf(e){const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const o=sr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:sr()?.matches?"dark":"light"}const ar=typeof document<"u"?document:null;function yt(e=null,t={target:ar,actInsideInputWithModifier:!0}){const[n,o]=D.useState(!1),r=D.useRef(!1),i=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(l=>typeof l=="string").map(l=>l.replace("+",` -`).replace(` - -`,` -+`).split(` -`)),d=u.reduce((l,f)=>l.concat(...f),[]);return[u,d]}return[[],[]]},[e]);return D.useEffect(()=>{const c=t?.target??ar,u=t?.actInsideInputWithModifier??!0;if(e!==null){const d=h=>{if(r.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!r.current||r.current&&!u)&&xi(h))return!1;const m=ur(h.code,a);if(i.current.add(h[m]),cr(s,i.current,!1)){const w=h.composedPath?.()?.[0]||h.target,y=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&h.preventDefault(),o(!0)}},l=h=>{const g=ur(h.code,a);cr(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),r.current=!1},f=()=>{i.current.clear(),o(!1)};return c?.addEventListener("keydown",d),c?.addEventListener("keyup",l),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c?.removeEventListener("keydown",d),c?.removeEventListener("keyup",l),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function cr(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ur(e,t){return t.includes(e)?"code":"key"}const Vf=()=>{const e=re();return D.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=eo(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c},d=n.snapGrid??r,l=n.snapToGrid??i;return Et(u,o,l,d)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Ut(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Oi(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const c of s)Of(c,a);n.push(a)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Of(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Bi(e,t){return Oi(e,t)}function Fi(e,t){return Oi(e,t)}function Ae(e,t){return{id:e,type:"select",selected:t}}function Be(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(Ae(i.id,s)))}return o}function lr({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),a=s?.internals?.userNode??s;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:"replace"}),a===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function dr(e){return{id:e.id,type:"remove"}}const fr=e=>ud(e),Bf=e=>li(e);function ji(e){return D.forwardRef(e)}const Ff=typeof window<"u"?D.useLayoutEffect:D.useEffect;function hr(e){const[t,n]=D.useState(BigInt(0)),[o]=D.useState(()=>jf(()=>n(r=>r+BigInt(1))));return Ff(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function jf(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Wi=D.createContext(null);function Wf({children:e}){const t=re(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:l,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let m=c;for(const y of a)m=typeof y=="function"?y(m):y;let w=lr({items:m,lookup:f});for(const y of g.values())w=y(w);d&&u(m),w.length>0?l?.(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:b,setNodes:p}=t.getState();y&&p(b)})},[]),o=hr(n),r=D.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:l,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;d?u(h):l&&l(lr({items:h,lookup:f}))},[]),i=hr(r),s=D.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return A.jsx(Wi.Provider,{value:s,children:e})}function Xf(){const e=D.useContext(Wi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Yf=e=>!!e.panZoom;function ao(){const e=Vf(),t=re(),n=Xf(),o=J(Yf),r=D.useMemo(()=>{const i=l=>t.getState().nodeLookup.get(l),s=l=>{n.nodeQueue.push(l)},a=l=>{n.edgeQueue.push(l)},c=l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=fr(l)?l:f.get(l.id),m=g.parentId?mi(g.position,g.measured,g.parentId,f,h):g.position,w={...g,position:m,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return Ge(w)},u=(l,f,h={replace:!1})=>{s(g=>g.map(m=>{if(m.id===l){const w=typeof f=="function"?f(m):f;return h.replace&&fr(w)?w:{...m,...w}}return m}))},d=(l,f,h={replace:!1})=>{a(g=>g.map(m=>{if(m.id===l){const w=typeof f=="function"?f(m):f;return h.replace&&Bf(w)?w:{...m,...w}}return m}))};return{getNodes:()=>t.getState().nodes.map(l=>({...l})),getNode:l=>i(l)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:l=[]}=t.getState();return l.map(f=>({...f}))},getEdge:l=>t.getState().edgeLookup.get(l),setNodes:s,setEdges:a,addNodes:l=>{const f=Array.isArray(l)?l:[l];n.nodeQueue.push(h=>[...h,...f])},addEdges:l=>{const f=Array.isArray(l)?l:[l];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:l=[],edges:f=[],transform:h}=t.getState(),[g,m,w]=h;return{nodes:l.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:g,y:m,zoom:w}}},deleteElements:async({nodes:l=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:m,onEdgesDelete:w,triggerNodeChanges:y,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:S,edges:_}=await pd({nodesToRemove:l,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:x}),N=_.length>0,P=S.length>0;if(N){const T=_.map(dr);w?.(_),b(T)}if(P){const T=S.map(dr);m?.(S),y(T)}return(P||N)&&p?.({nodes:S,edges:_}),{deletedNodes:S,deletedEdges:_}},getIntersectingNodes:(l,f=!0,h)=>{const g=Lo(l),m=g?l:c(l),w=h!==void 0;return m?(h||t.getState().nodes).filter(y=>{const b=t.getState().nodeLookup.get(y.id);if(b&&!g&&(y.id===l.id||!b.internals.positionAbsolute))return!1;const p=Ge(w?y:b),x=gt(p,m);return f&&x>0||x>=p.width*p.height||x>=m.width*m.height}):[]},isNodeIntersecting:(l,f,h=!0)=>{const m=Lo(l)?l:c(l);if(!m)return!1;const w=gt(m,f);return h&&w>0||w>=f.width*f.height||w>=m.width*m.height},updateNode:u,updateNodeData:(l,f,h={replace:!1})=>{u(l,g=>{const m=typeof f=="function"?f(g):f;return h.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},h)},updateEdge:d,updateEdgeData:(l,f,h={replace:!1})=>{d(l,g=>{const m=typeof f=="function"?f(g):f;return h.replace?{...g,data:m}:{...g,data:{...g.data,...m}}},h)},getNodesBounds:l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return ld(l,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:l,id:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${l}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:l,handleId:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${l?f?`-${l}-${f}`:`-${l}`:""}`)?.values()??[]),fitView:async l=>{const f=t.getState().fitViewResolver??xd();return t.setState({fitViewQueued:!0,fitViewOptions:l,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return D.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const pr=e=>e.selected,Zf=typeof window<"u"?window:void 0;function qf({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:o}=ao(),r=yt(e,{actInsideInputWithModifier:!1}),i=yt(t,{target:Zf});D.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(pr),edges:s.filter(pr)}),n.setState({nodesSelectionActive:!1})}},[r]),D.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Gf(e){const t=re();D.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=to(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",ye.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const ln={position:"absolute",width:"100%",height:"100%",top:0,left:0},Uf=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Kf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=Te.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:l,zoomActivationKeyCode:f,preventScrolling:h=!0,children:g,noWheelClassName:m,noPanClassName:w,onViewportChange:y,isControlledViewport:b,paneClickDistance:p,selectionOnDrag:x}){const S=re(),_=D.useRef(null),{userSelectionActive:N,lib:P,connectionInProgress:T}=J(Uf,oe),O=yt(f),I=D.useRef();Gf(_);const R=D.useCallback(H=>{y?.({x:H[0],y:H[1],zoom:H[2]}),b||S.setState({transform:H})},[y,b]);return D.useEffect(()=>{if(_.current){I.current=tf({domNode:_.current,minZoom:d,maxZoom:l,translateExtent:u,viewport:c,onDraggingChange:E=>S.setState(k=>k.paneDragging===E?k:{paneDragging:E}),onPanZoomStart:(E,k)=>{const{onViewportChangeStart:M,onMoveStart:$}=S.getState();$?.(E,k),M?.(k)},onPanZoom:(E,k)=>{const{onViewportChange:M,onMove:$}=S.getState();$?.(E,k),M?.(k)},onPanZoomEnd:(E,k)=>{const{onViewportChangeEnd:M,onMoveEnd:$}=S.getState();$?.(E,k),M?.(k)}});const{x:H,y:v,zoom:C}=I.current.getViewport();return S.setState({panZoom:I.current,transform:[H,v,C],domNode:_.current.closest(".react-flow")}),()=>{I.current?.destroy()}}},[]),D.useEffect(()=>{I.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:O,preventScrolling:h,noPanClassName:w,userSelectionActive:N,noWheelClassName:m,lib:P,onTransformChange:R,connectionInProgress:T,selectionOnDrag:x,paneClickDistance:p})},[e,t,n,o,r,i,s,a,O,h,w,N,m,P,R,T,x,p]),A.jsx("div",{className:"react-flow__renderer",ref:_,style:ln,children:g})}const Qf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Jf(){const{userSelectionActive:e,userSelectionRect:t}=J(Qf,oe);return e&&t?A.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Cn=(e,t)=>n=>{n.target===t.current&&e?.(n)},eh=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function th({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pt.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:l,onPaneMouseMove:f,onPaneMouseLeave:h,children:g}){const m=re(),{userSelectionActive:w,elementsSelectable:y,dragging:b,connectionInProgress:p}=J(eh,oe),x=y&&(e||w),S=D.useRef(null),_=D.useRef(),N=D.useRef(new Set),P=D.useRef(new Set),T=D.useRef(!1),O=M=>{if(T.current||p){T.current=!1;return}c?.(M),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},I=M=>{if(Array.isArray(o)&&o?.includes(2)){M.preventDefault();return}u?.(M)},R=d?M=>d(M):void 0,H=M=>{T.current&&(M.stopPropagation(),T.current=!1)},v=M=>{const{domNode:$}=m.getState();if(_.current=$?.getBoundingClientRect(),!_.current)return;const z=M.target===S.current;if(!z&&!!M.target.closest(".nokey")||!e||!(i&&z||t)||M.button!==0||!M.isPrimary)return;M.target?.setPointerCapture?.(M.pointerId),T.current=!1;const{x:j,y:F}=he(M.nativeEvent,_.current);m.setState({userSelectionRect:{width:0,height:0,startX:j,startY:F,x:j,y:F}}),z||(M.stopPropagation(),M.preventDefault())},C=M=>{const{userSelectionRect:$,transform:z,nodeLookup:V,edgeLookup:L,connectionLookup:j,triggerNodeChanges:F,triggerEdgeChanges:Z,defaultEdgeOptions:U,resetSelectedElements:Y}=m.getState();if(!_.current||!$)return;const{x:B,y:W}=he(M.nativeEvent,_.current),{startX:Q,startY:K}=$;if(!T.current){const te=t?0:r;if(Math.hypot(B-Q,W-K)<=te)return;Y(),s?.(M)}T.current=!0;const q={startX:Q,startY:K,x:Bte.id)),P.current=new Set;const ne=U?.selectable??!0;for(const te of N.current){const se=j.get(te);if(se)for(const{edgeId:Se}of se.values()){const we=L.get(Se);we&&(we.selectable??ne)&&P.current.add(Se)}}if(!Vo(G,N.current)){const te=Be(V,N.current,!0);F(te)}if(!Vo(ee,P.current)){const te=Be(L,P.current);Z(te)}m.setState({userSelectionRect:q,userSelectionActive:!0,nodesSelectionActive:!1})},E=M=>{M.button===0&&(M.target?.releasePointerCapture?.(M.pointerId),!w&&M.target===S.current&&m.getState().userSelectionRect&&O?.(M),m.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(a?.(M),m.setState({nodesSelectionActive:N.current.size>0})))},k=o===!0||Array.isArray(o)&&o.includes(0);return A.jsxs("div",{className:ie(["react-flow__pane",{draggable:k,dragging:b,selection:e}]),onClick:x?void 0:Cn(O,S),onContextMenu:Cn(I,S),onWheel:Cn(R,S),onPointerEnter:x?void 0:l,onPointerMove:x?C:f,onPointerUp:x?E:void 0,onPointerDownCapture:x?v:void 0,onClickCapture:x?H:void 0,onPointerLeave:h,ref:S,style:ln,children:[g,A.jsx(Jf,{})]})}function Wn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c?.("012",ye.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Xi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=re(),[c,u]=D.useState(!1),d=D.useRef();return D.useEffect(()=>{d.current=Bd({getStoreItems:()=>a.getState(),onNodeMouseDown:l=>{Wn({id:l,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),D.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{d.current?.destroy()}},[n,o,t,i,e,r,s]),c}const nh=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Yi(){const e=re();return D.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),l=new Map,f=nh(s),h=r?i[0]:5,g=r?i[1]:5,m=n.direction.x*h*n.factor,w=n.direction.y*g*n.factor;for(const[,y]of u){if(!f(y))continue;let b={x:y.internals.positionAbsolute.x+m,y:y.internals.positionAbsolute.y+w};r&&(b=_t(b,i));const{position:p,positionAbsolute:x}=di({nodeId:y.id,nextPosition:b,nodeLookup:u,nodeExtent:o,nodeOrigin:d,onError:a});y.position=p,y.internals.positionAbsolute=x,l.set(y.id,y)}c(l)},[])}const co=D.createContext(null),oh=co.Provider;co.Consumer;const Zi=()=>D.useContext(co),rh=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ih=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:c,isValid:u}=s,d=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:d,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===Ze.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:d&&u}};function sh({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:d,onTouchStart:l,...f},h){const g=s||null,m=e==="target",w=re(),y=Zi(),{connectOnClick:b,noPanClassName:p,rfId:x}=J(rh,oe),{connectingFrom:S,connectingTo:_,clickConnecting:N,isPossibleEndHandle:P,connectionInProcess:T,clickConnectionInProcess:O,valid:I}=J(ih(y,g,e),oe);y||w.getState().onError?.("010",ye.error010());const R=C=>{const{defaultEdgeOptions:E,onConnect:k,hasDefaultEdges:M}=w.getState(),$={...E,...C};if(M){const{edges:z,setEdges:V}=w.getState();V(Nd($,z))}k?.($),a?.($)},H=C=>{if(!y)return;const E=wi(C.nativeEvent);if(r&&(E&&C.button===0||!E)){const k=w.getState();jn.onPointerDown(C.nativeEvent,{handleDomNode:C.currentTarget,autoPanOnConnect:k.autoPanOnConnect,connectionMode:k.connectionMode,connectionRadius:k.connectionRadius,domNode:k.domNode,nodeLookup:k.nodeLookup,lib:k.lib,isTarget:m,handleId:g,nodeId:y,flowId:k.rfId,panBy:k.panBy,cancelConnection:k.cancelConnection,onConnectStart:k.onConnectStart,onConnectEnd:(...M)=>w.getState().onConnectEnd?.(...M),updateConnection:k.updateConnection,onConnect:R,isValidConnection:n||((...M)=>w.getState().isValidConnection?.(...M)??!0),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:k.autoPanSpeed,dragThreshold:k.connectionDragThreshold})}E?d?.(C):l?.(C)},v=C=>{const{onClickConnectStart:E,onClickConnectEnd:k,connectionClickStartHandle:M,connectionMode:$,isValidConnection:z,lib:V,rfId:L,nodeLookup:j,connection:F}=w.getState();if(!y||!M&&!r)return;if(!M){E?.(C.nativeEvent,{nodeId:y,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Z=yi(C.target),U=n||z,{connection:Y,isValid:B}=jn.isValid(C.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:$,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:U,flowId:L,doc:Z,lib:V,nodeLookup:j});B&&Y&&R(Y);const W=structuredClone(F);delete W.inProgress,W.toPosition=W.toHandle?W.toHandle.position:null,k?.(C,W),w.setState({connectionClickStartHandle:null})};return A.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${x}-${y}-${g}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!m,target:m,connectable:o,connectablestart:r,connectableend:i,clickconnecting:N,connectingfrom:S,connectingto:_,valid:I,connectionindicator:o&&(!T||P)&&(T||O?i:r)}]),onMouseDown:H,onTouchStart:H,onClick:b?v:void 0,ref:h,...f,children:c})}const Kt=D.memo(ji(sh));function ah({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return A.jsxs(A.Fragment,{children:[e?.label,A.jsx(Kt,{type:"source",position:n,isConnectable:t})]})}function ch({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:o=X.Bottom}){return A.jsxs(A.Fragment,{children:[A.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label,A.jsx(Kt,{type:"source",position:o,isConnectable:t})]})}function uh(){return null}function lh({data:e,isConnectable:t,targetPosition:n=X.Top}){return A.jsxs(A.Fragment,{children:[A.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label]})}const Qt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gr={input:ah,default:ch,output:lh,group:uh};function dh(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const fh=e=>{const{width:t,height:n,x:o,y:r}=bt(e.nodeLookup,{filter:i=>!!i.selected});return{width:fe(t)?t:null,height:fe(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function hh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=re(),{width:r,height:i,transformString:s,userSelectionActive:a}=J(fh,oe),c=Yi(),u=D.useRef(null);D.useEffect(()=>{n||u.current?.focus({preventScroll:!0})},[n]);const d=!a&&r!==null&&i!==null;if(Xi({nodeRef:u,disabled:!d}),!d)return null;const l=e?h=>{const g=o.getState().nodes.filter(m=>m.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Qt,h.key)&&(h.preventDefault(),c({direction:Qt[h.key],factor:h.shiftKey?4:1}))};return A.jsx("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:A.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:l,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:i}})})}const mr=typeof window<"u"?window:void 0,ph=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function qi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:l,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:m,zoomActivationKeyCode:w,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:S,panOnScrollMode:_,zoomOnDoubleClick:N,panOnDrag:P,defaultViewport:T,translateExtent:O,minZoom:I,maxZoom:R,preventScrolling:H,onSelectionContextMenu:v,noWheelClassName:C,noPanClassName:E,disableKeyboardA11y:k,onViewportChange:M,isControlledViewport:$}){const{nodesSelectionActive:z,userSelectionActive:V}=J(ph,oe),L=yt(u,{target:mr}),j=yt(m,{target:mr}),F=j||P,Z=j||x,U=d&&F!==!0,Y=L||V||U;return qf({deleteKeyCode:c,multiSelectionKeyCode:g}),A.jsx(Kf,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:Z,panOnScrollSpeed:S,panOnScrollMode:_,zoomOnDoubleClick:N,panOnDrag:!L&&F,defaultViewport:T,translateExtent:O,minZoom:I,maxZoom:R,zoomActivationKeyCode:w,preventScrolling:H,noWheelClassName:C,noPanClassName:E,onViewportChange:M,isControlledViewport:$,paneClickDistance:a,selectionOnDrag:U,children:A.jsxs(th,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:F,isSelecting:!!Y,selectionMode:l,selectionKeyPressed:L,paneClickDistance:a,selectionOnDrag:U,children:[e,z&&A.jsx(hh,{onSelectionContextMenu:v,noPanClassName:E,disableKeyboardA11y:k})]})})}qi.displayName="FlowRenderer";const gh=D.memo(qi),mh=e=>t=>e?Jn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function yh(e){return J(D.useCallback(mh(e),[e]),oe)}const xh=e=>e.updateNodeInternals;function wh(){const e=J(xh),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return D.useEffect(()=>()=>{t?.disconnect()},[t]),t}function vh({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=re(),i=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),u=D.useRef(t),d=n&&!!e.internals.handleBounds;return D.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[d,e.hidden]),D.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(i.current){const l=u.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(l||f||h)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function bh({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:l,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:m,nodeTypes:w,nodeClickDistance:y,onError:b}){const{node:p,internals:x,isParent:S}=J(B=>{const W=B.nodeLookup.get(e),Q=B.parentLookup.has(e);return{node:W,internals:W.internals,isParent:Q}},oe);let _=p.type||"default",N=w?.[_]||gr[_];N===void 0&&(b?.("003",ye.error003(_)),_="default",N=w?.default||gr.default);const P=!!(p.draggable||a&&typeof p.draggable>"u"),T=!!(p.selectable||c&&typeof p.selectable>"u"),O=!!(p.connectable||u&&typeof p.connectable>"u"),I=!!(p.focusable||d&&typeof p.focusable>"u"),R=re(),H=gi(p),v=vh({node:p,nodeType:_,hasDimensions:H,resizeObserver:l}),C=Xi({nodeRef:v,disabled:p.hidden||!P,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:y}),E=Yi();if(p.hidden)return null;const k=Ee(p),M=dh(p),$=T||P||t||n||o||r,z=n?B=>n(B,{...x.userNode}):void 0,V=o?B=>o(B,{...x.userNode}):void 0,L=r?B=>r(B,{...x.userNode}):void 0,j=i?B=>i(B,{...x.userNode}):void 0,F=s?B=>s(B,{...x.userNode}):void 0,Z=B=>{const{selectNodesOnDrag:W,nodeDragThreshold:Q}=R.getState();T&&(!W||!P||Q>0)&&Wn({id:e,store:R,nodeRef:v}),t&&t(B,{...x.userNode})},U=B=>{if(!(xi(B.nativeEvent)||g)){if(si.includes(B.key)&&T){const W=B.key==="Escape";Wn({id:e,store:R,unselect:W,nodeRef:v})}else if(P&&p.selected&&Object.prototype.hasOwnProperty.call(Qt,B.key)){B.preventDefault();const{ariaLabelConfig:W}=R.getState();R.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),E({direction:Qt[B.key],factor:B.shiftKey?4:1})}}},Y=()=>{if(g||!v.current?.matches(":focus-visible"))return;const{transform:B,width:W,height:Q,autoPanOnNodeFocus:K,setCenter:q}=R.getState();if(!K)return;Jn(new Map([[e,p]]),{x:0,y:0,width:W,height:Q},B,!0).length>0||q(p.position.x+k.width/2,p.position.y+k.height/2,{zoom:B[2]})};return A.jsx("div",{className:ie(["react-flow__node",`react-flow__node-${_}`,{[h]:P},p.className,{selected:p.selected,selectable:T,parent:S,draggable:P,dragging:C}]),ref:v,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:H?"visible":"hidden",...p.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:V,onMouseLeave:L,onContextMenu:j,onClick:Z,onDoubleClick:F,onKeyDown:I?U:void 0,tabIndex:I?0:void 0,onFocus:I?Y:void 0,role:p.ariaRole??(I?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Hi}-${m}`,"aria-label":p.ariaLabel,...p.domAttributes,children:A.jsx(oh,{value:e,children:A.jsx(N,{id:e,data:p.data,type:_,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:T,draggable:P,deletable:p.deletable??!0,isConnectable:O,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:C,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...k})})})}var _h=D.memo(bh);const Eh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Gi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=J(Eh,oe),s=yh(e.onlyRenderVisibleElements),a=wh();return A.jsx("div",{className:"react-flow__nodes",style:ln,children:s.map(c=>A.jsx(_h,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}Gi.displayName="NodeRenderer";const Sh=D.memo(Gi);function Nh(e){return J(D.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&_d({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),oe)}const Ch=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return A.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Mh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return A.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},yr={[qt.Arrow]:Ch,[qt.ArrowClosed]:Mh};function kh(e){const t=re();return D.useMemo(()=>Object.prototype.hasOwnProperty.call(yr,e)?yr[e]:(t.getState().onError?.("009",ye.error009(e)),null),[e])}const Ih=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=kh(t);return c?A.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:A.jsx(c,{color:n,strokeWidth:s})}):null},Ui=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),o=J(i=>i.defaultEdgeOptions),r=D.useMemo(()=>Ad(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?A.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:A.jsx("defs",{children:r.map(i=>A.jsx(Ih,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Ui.displayName="MarkerDefinitions";var Ah=D.memo(Ui);function Ki({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...d}){const[l,f]=D.useState({x:1,y:0,width:0,height:0}),h=ie(["react-flow__edge-textwrapper",u]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const m=g.current.getBBox();f({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),n?A.jsxs("g",{transform:`translate(${e-l.width/2} ${t-l.height/2})`,className:h,visibility:l.width?"visible":"hidden",...d,children:[r&&A.jsx("rect",{width:l.width+2*s[0],x:-s[0],y:-s[1],height:l.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),A.jsx("text",{className:"react-flow__edge-text",y:l.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}Ki.displayName="EdgeText";const $h=D.memo(Ki);function dn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return A.jsxs(A.Fragment,{children:[A.jsx("path",{...d,d:e,fill:"none",className:ie(["react-flow__edge-path",d.className])}),u?A.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,o&&fe(t)&&fe(n)?A.jsx($h,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function xr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===X.Left||e===X.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function Qi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top}){const[s,a]=xr({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,u]=xr({pos:i,x1:o,y1:r,x2:e,y2:t}),[d,l,f,h]=vi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${o},${r}`,d,l,f,h]}function Ji(e){return D.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:m,markerStart:w,interactionWidth:y})=>{const[b,p,x]=Qi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),S=e.isInternal?void 0:t;return A.jsx(dn,{id:S,path:b,labelX:p,labelY:x,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:m,markerStart:w,interactionWidth:y})})}const Ph=Ji({isInternal:!1}),es=Ji({isInternal:!0});Ph.displayName="SimpleBezierEdge";es.displayName="SimpleBezierEdgeInternal";function ts(e){return D.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,sourcePosition:h=X.Bottom,targetPosition:g=X.Top,markerEnd:m,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[p,x,S]=On({sourceX:n,sourceY:o,sourcePosition:h,targetX:r,targetY:i,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),_=e.isInternal?void 0:t;return A.jsx(dn,{id:_,path:p,labelX:x,labelY:S,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:m,markerStart:w,interactionWidth:b})})}const ns=ts({isInternal:!1}),os=ts({isInternal:!0});ns.displayName="SmoothStepEdge";os.displayName="SmoothStepEdgeInternal";function rs(e){return D.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return A.jsx(ns,{...n,id:o,pathOptions:D.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Th=rs({isInternal:!1}),is=rs({isInternal:!0});Th.displayName="StepEdge";is.displayName="StepEdgeInternal";function ss(e){return D.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:g,interactionWidth:m})=>{const[w,y,b]=Ei({sourceX:n,sourceY:o,targetX:r,targetY:i}),p=e.isInternal?void 0:t;return A.jsx(dn,{id:p,path:w,labelX:y,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:g,interactionWidth:m})})}const Dh=ss({isInternal:!1}),as=ss({isInternal:!0});Dh.displayName="StraightEdge";as.displayName="StraightEdgeInternal";function cs(e){return D.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:m,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[p,x,S]=bi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:y?.curvature}),_=e.isInternal?void 0:t;return A.jsx(dn,{id:_,path:p,labelX:x,labelY:S,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:m,markerStart:w,interactionWidth:b})})}const Rh=cs({isInternal:!1}),us=cs({isInternal:!0});Rh.displayName="BezierEdge";us.displayName="BezierEdgeInternal";const wr={default:us,straight:as,step:is,smoothstep:os,simplebezier:es},vr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},zh=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,Hh=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,br="react-flow__edgeupdater";function _r({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return A.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:ie([br,`${br}-${a}`]),cx:zh(t,o,e),cy:Hh(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Lh({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:l,setReconnecting:f,setUpdateHover:h}){const g=re(),m=(x,S)=>{if(x.button!==0)return;const{autoPanOnConnect:_,domNode:N,connectionMode:P,connectionRadius:T,lib:O,onConnectStart:I,cancelConnection:R,nodeLookup:H,rfId:v,panBy:C,updateConnection:E}=g.getState(),k=S.type==="target",M=(V,L)=>{f(!1),l?.(V,n,S.type,L)},$=V=>u?.(n,V),z=(V,L)=>{f(!0),d?.(x,n,S.type),I?.(V,L)};jn.onPointerDown(x.nativeEvent,{autoPanOnConnect:_,connectionMode:P,connectionRadius:T,domNode:N,handleId:S.id,nodeId:S.nodeId,nodeLookup:H,isTarget:k,edgeUpdaterType:S.type,lib:O,flowId:v,cancelConnection:R,panBy:C,isValidConnection:(...V)=>g.getState().isValidConnection?.(...V)??!0,onConnect:$,onConnectStart:z,onConnectEnd:(...V)=>g.getState().onConnectEnd?.(...V),onReconnectEnd:M,updateConnection:E,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>m(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=x=>m(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return A.jsxs(A.Fragment,{children:[(e===!0||e==="source")&&A.jsx(_r,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&A.jsx(_r,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function Vh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:m,noPanClassName:w,onError:y,disableKeyboardA11y:b}){let p=J(q=>q.edgeLookup.get(e));const x=J(q=>q.defaultEdgeOptions);p=x?{...x,...p}:p;let S=p.type||"default",_=m?.[S]||wr[S];_===void 0&&(y?.("011",ye.error011(S)),S="default",_=m?.default||wr.default);const N=!!(p.focusable||t&&typeof p.focusable>"u"),P=typeof l<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),T=!!(p.selectable||o&&typeof p.selectable>"u"),O=D.useRef(null),[I,R]=D.useState(!1),[H,v]=D.useState(!1),C=re(),{zIndex:E,sourceX:k,sourceY:M,targetX:$,targetY:z,sourcePosition:V,targetPosition:L}=J(D.useCallback(q=>{const G=q.nodeLookup.get(p.source),ee=q.nodeLookup.get(p.target);if(!G||!ee)return{zIndex:p.zIndex,...vr};const ne=Id({id:e,sourceNode:G,targetNode:ee,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:q.connectionMode,onError:y});return{zIndex:bd({selected:p.selected,zIndex:p.zIndex,sourceNode:G,targetNode:ee,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...ne||vr}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),oe),j=D.useMemo(()=>p.markerStart?`url('#${Bn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),F=D.useMemo(()=>p.markerEnd?`url('#${Bn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||k===null||M===null||$===null||z===null)return null;const Z=q=>{const{addSelectedEdges:G,unselectNodesAndEdges:ee,multiSelectionActive:ne}=C.getState();T&&(C.setState({nodesSelectionActive:!1}),p.selected&&ne?(ee({nodes:[],edges:[p]}),O.current?.blur()):G([e])),r&&r(q,p)},U=i?q=>{i(q,{...p})}:void 0,Y=s?q=>{s(q,{...p})}:void 0,B=a?q=>{a(q,{...p})}:void 0,W=c?q=>{c(q,{...p})}:void 0,Q=u?q=>{u(q,{...p})}:void 0,K=q=>{if(!b&&si.includes(q.key)&&T){const{unselectNodesAndEdges:G,addSelectedEdges:ee}=C.getState();q.key==="Escape"?(O.current?.blur(),G({edges:[p]})):ee([e])}};return A.jsx("svg",{style:{zIndex:E},children:A.jsxs("g",{className:ie(["react-flow__edge",`react-flow__edge-${S}`,p.className,w,{selected:p.selected,animated:p.animated,inactive:!T&&!r,updating:I,selectable:T}]),onClick:Z,onDoubleClick:U,onContextMenu:Y,onMouseEnter:B,onMouseMove:W,onMouseLeave:Q,onKeyDown:N?K:void 0,tabIndex:N?0:void 0,role:p.ariaRole??(N?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":N?`${Li}-${g}`:void 0,ref:O,...p.domAttributes,children:[!H&&A.jsx(_,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:T,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:k,sourceY:M,targetX:$,targetY:z,sourcePosition:V,targetPosition:L,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:j,markerEnd:F,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),P&&A.jsx(Lh,{edge:p,isReconnectable:P,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,sourceX:k,sourceY:M,targetX:$,targetY:z,sourcePosition:V,targetPosition:L,setUpdateHover:R,setReconnecting:v})]})})}var Oh=D.memo(Vh);const Bh=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ls({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:l,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:m}){const{edgesFocusable:w,edgesReconnectable:y,elementsSelectable:b,onError:p}=J(Bh,oe),x=Nh(t);return A.jsxs("div",{className:"react-flow__edges",children:[A.jsx(Ah,{defaultColor:e,rfId:n}),x.map(S=>A.jsx(Oh,{id:S,edgesFocusable:w,edgesReconnectable:y,elementsSelectable:b,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:l,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:o,disableKeyboardA11y:m},S))]})}ls.displayName="EdgeRenderer";const Fh=D.memo(ls),jh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Wh({children:e}){const t=J(jh);return A.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Xh(e){const t=ao(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Yh=e=>e.panZoom?.syncViewport;function Zh(e){const t=J(Yh),n=re();return D.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function qh(e){return e.connection.inProgress?{...e.connection,to:Et(e.connection.to,e.transform)}:{...e.connection}}function Gh(e){return qh}function Uh(e){const t=Gh();return J(t,oe)}const Kh=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Qh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:c}=J(Kh,oe);return!(i&&r&&c)?null:A.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:A.jsx("g",{className:ie(["react-flow__connection",ui(a)]),children:A.jsx(ds,{style:t,type:n,CustomComponent:o,isValid:a})})})}const ds=({style:e,type:t=Me.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:d,toHandle:l,toPosition:f,pointer:h}=Uh();if(!r)return;if(n)return A.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:ui(o),toNode:d,toHandle:l,pointer:h});let g="";const m={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Me.Bezier:[g]=bi(m);break;case Me.SimpleBezier:[g]=Qi(m);break;case Me.Step:[g]=On({...m,borderRadius:0});break;case Me.SmoothStep:[g]=On(m);break;default:[g]=Ei(m)}return A.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};ds.displayName="ConnectionLine";const Jh={};function Er(e=Jh){D.useRef(e),re(),D.useEffect(()=>{},[e])}function ep(){re(),D.useRef(!1),D.useEffect(()=>{},[])}function fs({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:l,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:m,connectionLineComponent:w,connectionLineContainerStyle:y,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:S,panActivationKeyCode:_,zoomActivationKeyCode:N,deleteKeyCode:P,onlyRenderVisibleElements:T,elementsSelectable:O,defaultViewport:I,translateExtent:R,minZoom:H,maxZoom:v,preventScrolling:C,defaultMarkerColor:E,zoomOnScroll:k,zoomOnPinch:M,panOnScroll:$,panOnScrollSpeed:z,panOnScrollMode:V,zoomOnDoubleClick:L,panOnDrag:j,onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:U,onPaneMouseLeave:Y,onPaneScroll:B,onPaneContextMenu:W,paneClickDistance:Q,nodeClickDistance:K,onEdgeContextMenu:q,onEdgeMouseEnter:G,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,noDragClassName:Ie,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,nodeExtent:fn,rfId:St,viewport:Le,onViewportChange:tt}){return Er(e),Er(t),ep(),Xh(n),Zh(Le),A.jsx(gh,{onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:U,onPaneMouseLeave:Y,onPaneContextMenu:W,onPaneScroll:B,paneClickDistance:Q,deleteKeyCode:P,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:_,zoomActivationKeyCode:N,elementsSelectable:O,zoomOnScroll:k,zoomOnPinch:M,zoomOnDoubleClick:L,panOnScroll:$,panOnScrollSpeed:z,panOnScrollMode:V,panOnDrag:j,defaultViewport:I,translateExtent:R,minZoom:H,maxZoom:v,onSelectionContextMenu:l,preventScrolling:C,noDragClassName:Ie,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,onViewportChange:tt,isControlledViewport:!!Le,children:A.jsxs(Wh,{children:[A.jsx(Fh,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,onlyRenderVisibleElements:T,onEdgeContextMenu:q,onEdgeMouseEnter:G,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:E,noPanClassName:Je,disableKeyboardA11y:et,rfId:St}),A.jsx(Qh,{style:m,type:g,component:w,containerStyle:y}),A.jsx("div",{className:"react-flow__edgelabel-renderer"}),A.jsx(Sh,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:K,onlyRenderVisibleElements:T,noPanClassName:Je,noDragClassName:Ie,disableKeyboardA11y:et,nodeExtent:fn,rfId:St}),A.jsx("div",{className:"react-flow__viewport-portal"})]})})}fs.displayName="GraphView";const tp=D.memo(fs),Sr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:l,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,m=new Map,w=new Map,y=o??t??[],b=n??e??[],p=d??[0,0],x=l??ht;Ci(m,w,y);const S=Fn(b,h,g,{nodeOrigin:p,nodeExtent:x,zIndexMode:f});let _=[0,0,1];if(s&&r&&i){const N=bt(h,{filter:I=>!!((I.width||I.initialWidth)&&(I.height||I.initialHeight))}),{x:P,y:T,zoom:O}=eo(N,r,i,c,u,a?.padding??.1);_=[P,T,O]}return{rfId:"1",width:r??0,height:i??0,transform:_,nodes:b,nodesInitialized:S,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:w,connectionLookup:m,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ht,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ci},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:gd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ai,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},np=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f})=>vf((h,g)=>{async function m(){const{nodeLookup:w,panZoom:y,fitViewOptions:b,fitViewResolver:p,width:x,height:S,minZoom:_,maxZoom:N}=g();y&&(await hd({nodes:w,width:x,height:S,panZoom:y,minZoom:_,maxZoom:N},b),p?.resolve(!0),h({fitViewResolver:null}))}return{...Sr({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:w=>{const{nodeLookup:y,parentLookup:b,nodeOrigin:p,elevateNodesOnSelect:x,fitViewQueued:S,zIndexMode:_}=g(),N=Fn(w,y,b,{nodeOrigin:p,nodeExtent:l,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:_});S&&N?(m(),h({nodes:w,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:w,nodesInitialized:N})},setEdges:w=>{const{connectionLookup:y,edgeLookup:b}=g();Ci(y,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,y)=>{if(w){const{setNodes:b}=g();b(w),h({hasDefaultNodes:!0})}if(y){const{setEdges:b}=g();b(y),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:y,nodeLookup:b,parentLookup:p,domNode:x,nodeOrigin:S,nodeExtent:_,debug:N,fitViewQueued:P,zIndexMode:T}=g(),{changes:O,updatedInternals:I}=Hd(w,b,p,x,S,_,T);I&&(Td(b,p,{nodeOrigin:S,nodeExtent:_,zIndexMode:T}),P?(m(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),O?.length>0&&(N&&console.log("React Flow: trigger node changes",O),y?.(O)))},updateNodePositions:(w,y=!1)=>{const b=[];let p=[];const{nodeLookup:x,triggerNodeChanges:S,connection:_,updateConnection:N,onNodesChangeMiddlewareMap:P}=g();for(const[T,O]of w){const I=x.get(T),R=!!(I?.expandParent&&I?.parentId&&O?.position),H={id:T,type:"position",position:R?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:y};if(I&&_.inProgress&&_.fromNode.id===I.id){const v=He(I,_.fromHandle,X.Left,!0);N({..._,from:v})}R&&I.parentId&&b.push({id:T,parentId:I.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),p.push(H)}if(b.length>0){const{parentLookup:T,nodeOrigin:O}=g(),I=so(b,x,T,O);p.push(...I)}for(const T of P.values())p=T(p);S(p)},triggerNodeChanges:w=>{const{onNodesChange:y,setNodes:b,nodes:p,hasDefaultNodes:x,debug:S}=g();if(w?.length){if(x){const _=Bi(w,p);b(_)}S&&console.log("React Flow: trigger node changes",w),y?.(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:y,setEdges:b,edges:p,hasDefaultEdges:x,debug:S}=g();if(w?.length){if(x){const _=Fi(w,p);b(_)}S&&console.log("React Flow: trigger edge changes",w),y?.(w)}},addSelectedNodes:w=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:S}=g();if(y){const _=w.map(N=>Ae(N,!0));x(_);return}x(Be(p,new Set([...w]),!0)),S(Be(b))},addSelectedEdges:w=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:S}=g();if(y){const _=w.map(N=>Ae(N,!0));S(_);return}S(Be(b,new Set([...w]))),x(Be(p,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:y}={})=>{const{edges:b,nodes:p,nodeLookup:x,triggerNodeChanges:S,triggerEdgeChanges:_}=g(),N=w||p,P=y||b,T=[];for(const I of N){if(!I.selected)continue;const R=x.get(I.id);R&&(R.selected=!1),T.push(Ae(I.id,!1))}const O=[];for(const I of P)I.selected&&O.push(Ae(I.id,!1));S(T),_(O)},setMinZoom:w=>{const{panZoom:y,maxZoom:b}=g();y?.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:y,minZoom:b}=g();y?.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{g().panZoom?.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:y,triggerNodeChanges:b,triggerEdgeChanges:p,elementsSelectable:x}=g();if(!x)return;const S=y.reduce((N,P)=>P.selected?[...N,Ae(P.id,!1)]:N,[]),_=w.reduce((N,P)=>P.selected?[...N,Ae(P.id,!1)]:N,[]);b(S),p(_)},setNodeExtent:w=>{const{nodes:y,nodeLookup:b,parentLookup:p,nodeOrigin:x,elevateNodesOnSelect:S,nodeExtent:_,zIndexMode:N}=g();w[0][0]===_[0][0]&&w[0][1]===_[0][1]&&w[1][0]===_[1][0]&&w[1][1]===_[1][1]||(Fn(y,b,p,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:N}),h({nodeExtent:w}))},panBy:w=>{const{transform:y,width:b,height:p,panZoom:x,translateExtent:S}=g();return Ld({delta:w,panZoom:x,transform:y,translateExtent:S,width:b,height:p})},setCenter:async(w,y,b)=>{const{width:p,height:x,maxZoom:S,panZoom:_}=g();if(!_)return Promise.resolve(!1);const N=typeof b?.zoom<"u"?b.zoom:S;return await _.setViewport({x:p/2-w*N,y:x/2-y*N,zoom:N},{duration:b?.duration,ease:b?.ease,interpolate:b?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...ci}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Sr()})}},Object.is);function op({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f,children:h}){const[g]=D.useState(()=>np({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:d,nodeExtent:l,zIndexMode:f}));return A.jsx(bf,{value:g,children:A.jsx(Wf,{children:h})})}function rp({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h}){return D.useContext(cn)?A.jsx(A.Fragment,{children:e}):A.jsx(op,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h,children:e})}const ip={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function sp({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:l,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:m,onClickConnectStart:w,onClickConnectEnd:y,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:_,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:T,onNodesDelete:O,onEdgesDelete:I,onDelete:R,onSelectionChange:H,onSelectionDragStart:v,onSelectionDrag:C,onSelectionDragStop:E,onSelectionContextMenu:k,onSelectionStart:M,onSelectionEnd:$,onBeforeDelete:z,connectionMode:V,connectionLineType:L=Me.Bezier,connectionLineStyle:j,connectionLineComponent:F,connectionLineContainerStyle:Z,deleteKeyCode:U="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:B=!1,selectionMode:W=pt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:K=mt()?"Meta":"Control",zoomActivationKeyCode:q=mt()?"Meta":"Control",snapToGrid:G,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:Ie,nodeOrigin:Qe=Vi,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:fn=!0,defaultViewport:St=Df,minZoom:Le=.5,maxZoom:tt=2,translateExtent:uo=ht,preventScrolling:xs=!0,nodeExtent:hn,defaultMarkerColor:ws="#b1b1b7",zoomOnScroll:vs=!0,zoomOnPinch:bs=!0,panOnScroll:_s=!1,panOnScrollSpeed:Es=.5,panOnScrollMode:Ss=Te.Free,zoomOnDoubleClick:Ns=!0,panOnDrag:Cs=!0,onPaneClick:Ms,onPaneMouseEnter:ks,onPaneMouseMove:Is,onPaneMouseLeave:As,onPaneScroll:$s,onPaneContextMenu:Ps,paneClickDistance:Ts=1,nodeClickDistance:Ds=0,children:Rs,onReconnect:zs,onReconnectStart:Hs,onReconnectEnd:Ls,onEdgeContextMenu:Vs,onEdgeDoubleClick:Os,onEdgeMouseEnter:Bs,onEdgeMouseMove:Fs,onEdgeMouseLeave:js,reconnectRadius:Ws=10,onNodesChange:Xs,onEdgesChange:Ys,noDragClassName:Zs="nodrag",noWheelClassName:qs="nowheel",noPanClassName:lo="nopan",fitView:fo,fitViewOptions:ho,connectOnClick:Gs,attributionPosition:Us,proOptions:Ks,defaultEdgeOptions:Qs,elevateNodesOnSelect:Js=!0,elevateEdgesOnSelect:ea=!1,disableKeyboardA11y:po=!1,autoPanOnConnect:ta,autoPanOnNodeDrag:na,autoPanSpeed:oa,connectionRadius:ra,isValidConnection:ia,onError:sa,style:aa,id:go,nodeDragThreshold:ca,connectionDragThreshold:ua,viewport:la,onViewportChange:da,width:fa,height:ha,colorMode:pa="light",debug:ga,onScroll:mo,ariaLabelConfig:ma,zIndexMode:yo="basic",...ya},xa){const pn=go||"1",wa=Lf(pa),va=D.useCallback(xo=>{xo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),mo?.(xo)},[mo]);return A.jsx("div",{"data-testid":"rf__wrapper",...ya,onScroll:va,style:{...aa,...ip},ref:xa,className:ie(["react-flow",r,wa]),id:go,role:"application",children:A.jsxs(rp,{nodes:e,edges:t,width:fa,height:ha,fitView:fo,fitViewOptions:ho,minZoom:Le,maxZoom:tt,nodeOrigin:Qe,nodeExtent:hn,zIndexMode:yo,children:[A.jsx(tp,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:s,connectionLineType:L,connectionLineStyle:j,connectionLineComponent:F,connectionLineContainerStyle:Z,selectionKeyCode:Y,selectionOnDrag:B,selectionMode:W,deleteKeyCode:U,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:q,onlyRenderVisibleElements:ne,defaultViewport:St,translateExtent:uo,minZoom:Le,maxZoom:tt,preventScrolling:xs,zoomOnScroll:vs,zoomOnPinch:bs,zoomOnDoubleClick:Ns,panOnScroll:_s,panOnScrollSpeed:Es,panOnScrollMode:Ss,panOnDrag:Cs,onPaneClick:Ms,onPaneMouseEnter:ks,onPaneMouseMove:Is,onPaneMouseLeave:As,onPaneScroll:$s,onPaneContextMenu:Ps,paneClickDistance:Ts,nodeClickDistance:Ds,onSelectionContextMenu:k,onSelectionStart:M,onSelectionEnd:$,onReconnect:zs,onReconnectStart:Hs,onReconnectEnd:Ls,onEdgeContextMenu:Vs,onEdgeDoubleClick:Os,onEdgeMouseEnter:Bs,onEdgeMouseMove:Fs,onEdgeMouseLeave:js,reconnectRadius:Ws,defaultMarkerColor:ws,noDragClassName:Zs,noWheelClassName:qs,noPanClassName:lo,rfId:pn,disableKeyboardA11y:po,nodeExtent:hn,viewport:la,onViewportChange:da}),A.jsx(Hf,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:g,onConnectEnd:m,onClickConnectStart:w,onClickConnectEnd:y,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:Ie,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:fn,elevateNodesOnSelect:Js,elevateEdgesOnSelect:ea,minZoom:Le,maxZoom:tt,nodeExtent:hn,onNodesChange:Xs,onEdgesChange:Ys,snapToGrid:G,snapGrid:ee,connectionMode:V,translateExtent:uo,connectOnClick:Gs,defaultEdgeOptions:Qs,fitView:fo,fitViewOptions:ho,onNodesDelete:O,onEdgesDelete:I,onDelete:R,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:T,onSelectionDrag:C,onSelectionDragStart:v,onSelectionDragStop:E,onMove:d,onMoveStart:l,onMoveEnd:f,noPanClassName:lo,nodeOrigin:Qe,rfId:pn,autoPanOnConnect:ta,autoPanOnNodeDrag:na,autoPanSpeed:oa,onError:sa,connectionRadius:ra,isValidConnection:ia,selectNodesOnDrag:te,nodeDragThreshold:ca,connectionDragThreshold:ua,onBeforeDelete:z,debug:ga,ariaLabelConfig:ma,zIndexMode:yo}),A.jsx(Tf,{onSelectionChange:H}),Rs,A.jsx(kf,{proOptions:Ks,position:Us}),A.jsx(Mf,{rfId:pn,disableKeyboardA11y:po})]})})}var Up=ji(sp);function Kp(e){const[t,n]=D.useState(e),o=D.useCallback(r=>n(i=>Bi(r,i)),[]);return[t,n,o]}function Qp(e){const[t,n]=D.useState(e),o=D.useCallback(r=>n(i=>Fi(r,i)),[]);return[t,n,o]}function ap({dimensions:e,lineWidth:t,variant:n,className:o}){return A.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ie(["react-flow__background-pattern",n,o])})}function cp({radius:e,className:t}){return A.jsx("circle",{cx:e,cy:e,r:e,className:ie(["react-flow__background-pattern","dots",t])})}var ke;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ke||(ke={}));const up={[ke.Dots]:1,[ke.Lines]:1,[ke.Cross]:6},lp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hs({id:e,variant:t=ke.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:c,className:u,patternClassName:d}){const l=D.useRef(null),{transform:f,patternId:h}=J(lp,oe),g=o||up[t],m=t===ke.Dots,w=t===ke.Cross,y=Array.isArray(n)?n:[n,n],b=[y[0]*f[2]||1,y[1]*f[2]||1],p=g*f[2],x=Array.isArray(i)?i:[i,i],S=w?[p,p]:b,_=[x[0]*f[2]||1+S[0]/2,x[1]*f[2]||1+S[1]/2],N=`${h}${e||""}`;return A.jsxs("svg",{className:ie(["react-flow__background",u]),style:{...c,...ln,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:l,"data-testid":"rf__background",children:[A.jsx("pattern",{id:N,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:m?A.jsx(cp,{radius:p/2,className:d}):A.jsx(ap,{dimensions:S,lineWidth:r,variant:t,className:d})}),A.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${N})`})]})}hs.displayName="Background";const Jp=D.memo(hs);function dp(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:A.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function fp(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:A.jsx("path",{d:"M0 0h32v4.2H0z"})})}function hp(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:A.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function pp(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function gp(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Dt({children:e,className:t,...n}){return A.jsx("button",{type:"button",className:ie(["react-flow__controls-button",t]),...n,children:e})}const mp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ps({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:d,position:l="bottom-left",orientation:f="vertical","aria-label":h}){const g=re(),{isInteractive:m,minZoomReached:w,maxZoomReached:y,ariaLabelConfig:b}=J(mp,oe),{zoomIn:p,zoomOut:x,fitView:S}=ao(),_=()=>{p(),i?.()},N=()=>{x(),s?.()},P=()=>{S(r),a?.()},T=()=>{g.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),c?.(!m)},O=f==="horizontal"?"horizontal":"vertical";return A.jsxs(un,{className:ie(["react-flow__controls",O,u]),position:l,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&A.jsxs(A.Fragment,{children:[A.jsx(Dt,{onClick:_,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:y,children:A.jsx(dp,{})}),A.jsx(Dt,{onClick:N,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:A.jsx(fp,{})})]}),n&&A.jsx(Dt,{className:"react-flow__controls-fitview",onClick:P,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:A.jsx(hp,{})}),o&&A.jsx(Dt,{className:"react-flow__controls-interactive",onClick:T,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:m?A.jsx(gp,{}):A.jsx(pp,{})}),d]})}ps.displayName="Controls";const eg=D.memo(ps);function yp({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:d,shapeRendering:l,selected:f,onClick:h}){const{background:g,backgroundColor:m}=i||{},w=s||g||m;return A.jsx("rect",{className:ie(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:d,ry:d,width:o,height:r,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:l,onClick:h?y=>h(y,e):void 0})}const xp=D.memo(yp),wp=e=>e.nodes.map(t=>t.id),Mn=e=>e instanceof Function?e:()=>e;function vp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=xp,onClick:s}){const a=J(wp,oe),c=Mn(t),u=Mn(e),d=Mn(n),l=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return A.jsx(A.Fragment,{children:a.map(f=>A.jsx(_p,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:l},f))})}function bp({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:d,y:l,width:f,height:h}=J(g=>{const m=g.nodeLookup.get(e);if(!m)return{node:void 0,x:0,y:0,width:0,height:0};const w=m.internals.userNode,{x:y,y:b}=m.internals.positionAbsolute,{width:p,height:x}=Ee(w);return{node:w,x:y,y:b,width:p,height:x}},oe);return!u||u.hidden||!gi(u)?null:A.jsx(a,{x:d,y:l,width:f,height:h,style:u.style,selected:!!u.selected,className:o(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:c,id:u.id})}const _p=D.memo(bp);var Ep=D.memo(vp);const Sp=200,Np=150,Cp=e=>!e.hidden,Mp=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?pi(bt(e.nodeLookup,{filter:Cp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},kp="react-flow__minimap-desc";function gs({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:l,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:m=!1,zoomable:w=!1,ariaLabel:y,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const S=re(),_=D.useRef(null),{boundingRect:N,viewBB:P,rfId:T,panZoom:O,translateExtent:I,flowWidth:R,flowHeight:H,ariaLabelConfig:v}=J(Mp,oe),C=e?.width??Sp,E=e?.height??Np,k=N.width/C,M=N.height/E,$=Math.max(k,M),z=$*C,V=$*E,L=x*$,j=N.x-(z-N.width)/2-L,F=N.y-(V-N.height)/2-L,Z=z+L*2,U=V+L*2,Y=`${kp}-${T}`,B=D.useRef(0),W=D.useRef();B.current=$,D.useEffect(()=>{if(_.current&&O)return W.current=Zd({domNode:_.current,panZoom:O,getTransform:()=>S.getState().transform,getViewScale:()=>B.current}),()=>{W.current?.destroy()}},[O]),D.useEffect(()=>{W.current?.update({translateExtent:I,width:R,height:H,inversePan:b,pannable:m,zoomStep:p,zoomable:w})},[m,w,b,p,I,R,H]);const Q=h?G=>{const[ee,ne]=W.current?.pointer(G)||[0,0];h(G,{x:ee,y:ne})}:void 0,K=g?D.useCallback((G,ee)=>{const ne=S.getState().nodeLookup.get(ee).internals.userNode;g(G,ne)},[]):void 0,q=y??v["minimap.ariaLabel"];return A.jsx(un,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof l=="number"?l*$:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:ie(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:A.jsxs("svg",{width:C,height:E,viewBox:`${j} ${F} ${Z} ${U}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:_,onClick:Q,children:[q&&A.jsx("title",{id:Y,children:q}),A.jsx(Ep,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),A.jsx("path",{className:"react-flow__minimap-mask",d:`M${j-L},${F-L}h${Z+L*2}v${U+L*2}h${-Z-L*2}z - M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}gs.displayName="MiniMap";const tg=D.memo(gs),Ip=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Ap={[Ke.Line]:"right",[Ke.Handle]:"bottom-right"};function $p({nodeId:e,position:t,variant:n=Ke.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:m,onResize:w,onResizeEnd:y}){const b=Zi(),p=typeof e=="string"?e:b,x=re(),S=D.useRef(null),_=n===Ke.Handle,N=J(D.useCallback(Ip(_&&h),[_,h]),oe),P=D.useRef(null),T=t??Ap[n];D.useEffect(()=>{if(!(!S.current||!p))return P.current||(P.current=cf({domNode:S.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:I,transform:R,snapGrid:H,snapToGrid:v,nodeOrigin:C,domNode:E}=x.getState();return{nodeLookup:I,transform:R,snapGrid:H,snapToGrid:v,nodeOrigin:C,paneDomNode:E}},onChange:(I,R)=>{const{triggerNodeChanges:H,nodeLookup:v,parentLookup:C,nodeOrigin:E}=x.getState(),k=[],M={x:I.x,y:I.y},$=v.get(p);if($&&$.expandParent&&$.parentId){const z=$.origin??E,V=I.width??$.measured.width??0,L=I.height??$.measured.height??0,j={id:$.id,parentId:$.parentId,rect:{width:V,height:L,...mi({x:I.x??$.position.x,y:I.y??$.position.y},{width:V,height:L},$.parentId,v,z)}},F=so([j],v,C,E);k.push(...F),M.x=I.x?Math.max(z[0]*V,I.x):void 0,M.y=I.y?Math.max(z[1]*L,I.y):void 0}if(M.x!==void 0&&M.y!==void 0){const z={id:p,type:"position",position:{...M}};k.push(z)}if(I.width!==void 0&&I.height!==void 0){const V={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:I.width,height:I.height}};k.push(V)}for(const z of R){const V={...z,type:"position"};k.push(V)}H(k)},onEnd:({width:I,height:R})=>{const H={id:p,type:"dimensions",resizing:!1,dimensions:{width:I,height:R}};x.getState().triggerNodeChanges([H])}})),P.current.update({controlPosition:T,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:l,resizeDirection:f,onResizeStart:m,onResize:w,onResizeEnd:y,shouldResize:g}),()=>{P.current?.destroy()}},[T,a,c,u,d,l,m,w,y,g]);const O=T.split("-");return A.jsx("div",{className:ie(["react-flow__resize-control","nodrag",...O,n,o]),ref:S,style:{...r,scale:N,...s&&{[_?"backgroundColor":"borderColor"]:s}},children:i})}D.memo($p);const Pp=["off","on","auto"],Tp=["16:9","9:16","1:1","4:3","3:4"],Dp=["","5s","10s"],Rp=["","720p","1080p"],zp=["mp3","opus","aac","flac","wav"],We={textInput:{type:"textInput",label:"Input",description:"Static text provided by the user. Starting point of a workflow.",input:"none",output:"text",params:[{name:"inputText",type:"text",description:"The text value.",required:!0,default:""}]},output:{type:"output",label:"Output",description:"Displays whatever its upstream node produced. Accepts any kind.",input:"text",output:"none",params:[]},chat:{type:"chat",label:"LLM",description:"Run a Venice chat completion. Accepts upstream text as context.",input:"text",output:"text",params:[{name:"model",type:"string",description:"Venice chat model id.",required:!0,default:"llama-3.3-70b"},{name:"prompt",type:"text",description:"Instruction. Use {{input}} to position upstream text, or leave empty to append.",required:!0,default:""},{name:"temperature",type:"number",description:"Sampling temperature.",default:.7,min:0,max:2},{name:"maxTokens",type:"number",description:"Max output tokens.",default:4096,min:64,max:32768},{name:"webSearch",type:"enum",description:"Enable Venice web search.",default:"off",enumValues:Pp}]},imageGen:{type:"imageGen",label:"Image Gen",description:"Generate an image from a text prompt.",input:"text",output:"image",params:[{name:"model",type:"string",description:"Venice image model id.",required:!0,default:"z-image-turbo"},{name:"prompt",type:"text",description:"Image prompt. Use {{input}} to position upstream text.",required:!0,default:""},{name:"negativePrompt",type:"string",description:"What to avoid.",default:""},{name:"steps",type:"number",description:"Denoising steps.",default:20,min:1,max:50},{name:"width",type:"number",description:"Image width in pixels.",default:1024,min:256,max:2048},{name:"height",type:"number",description:"Image height in pixels.",default:1024,min:256,max:2048},{name:"style",type:"string",description:"Style preset name.",default:""},{name:"hideWatermark",type:"boolean",description:"Omit watermark if allowed.",default:!0}]},tts:{type:"tts",label:"Text to Speech",description:"Narrate text into speech audio.",input:"text",output:"audio",params:[{name:"model",type:"string",description:"TTS model id.",required:!0,default:"tts-kokoro"},{name:"prompt",type:"text",description:"Text to speak. Use {{input}} to position upstream text.",default:""},{name:"voice",type:"string",description:"Voice id.",default:"af_sky"},{name:"speed",type:"number",description:"Playback speed.",default:1,min:.25,max:4},{name:"responseFormat",type:"enum",description:"Audio format.",default:"mp3",enumValues:zp}]},music:{type:"music",label:"Music Gen",description:"Generate a music clip from a text prompt.",input:"text",output:"audio",params:[{name:"model",type:"string",description:"Music model id.",required:!0,default:"stable-audio"},{name:"prompt",type:"text",description:"Music prompt.",required:!0,default:""},{name:"duration",type:"number",description:"Duration in seconds.",default:30,min:5,max:120},{name:"instrumental",type:"boolean",description:"Force instrumental.",default:!1},{name:"lyrics",type:"text",description:"Optional lyrics.",default:""}]},video:{type:"video",label:"Video Gen",description:"Generate a short video from a text prompt.",input:"text",output:"video",params:[{name:"model",type:"string",description:"Video model id.",required:!0,default:"wan-2.1"},{name:"prompt",type:"text",description:"Video prompt.",required:!0,default:""},{name:"videoAspectRatio",type:"enum",description:"Aspect ratio.",default:"16:9",enumValues:Tp},{name:"videoDuration",type:"enum",description:"Clip duration. Empty means model default.",default:"",enumValues:Dp},{name:"videoResolution",type:"enum",description:"Resolution. Empty means model default.",default:"",enumValues:Rp}]}};function Hp(e,t){return e!=="none"&&t!=="none"}function Lp(e,t){return e==="none"||t==="none"?!1:t==="text"?!0:e===t}const kn=280,ms=180,Rt=60,ys=60;function Vp(e){const t=We[e],n={label:t?.label??e,nodeType:e,model:"",prompt:""};for(const o of t?.params??[])o.default!==void 0&&(n[o.name]=o.default);return n}function Op(e,t){if(e.length===0)return e;const n=new Map,o=new Map;for(const l of e)n.set(l.id,0),o.set(l.id,[]);for(const l of t)!n.has(l.source)||!n.has(l.target)||(o.get(l.source).push(l.target),n.set(l.target,(n.get(l.target)??0)+1));const r=new Map,i=e.filter(l=>(n.get(l.id)??0)===0).map(l=>l.id);for(const l of i)r.set(l,0);const s=new Map(n);for(;i.length>0;){const l=i.shift(),f=r.get(l)??0;for(const h of o.get(l)??[]){r.set(h,Math.max(r.get(h)??0,f+1));const g=(s.get(h)??1)-1;s.set(h,g),g===0&&i.push(h)}}for(const l of e)r.has(l.id)||r.set(l.id,0);const a=new Map;for(const l of e){const f=r.get(l.id)??0;a.has(f)||a.set(f,[]),a.get(f).push(l.id)}const u=Math.max(...Array.from(a.values()).map(l=>l.length))*(kn+Rt),d=new Map;for(const[l,f]of a){const h=f.length*(kn+Rt)-Rt,g=(u-h)/2;f.forEach((m,w)=>{d.set(m,{x:g+w*(kn+Rt),y:40+l*(ms+ys)})})}return e.map(l=>({...l,position:d.get(l.id)??l.position}))}function Bp(e){return{x:280,y:40+e.length*(ms+ys)}}function Fp(e,t){const{nodes:n,edges:o}=e;switch(t.op){case"add_node":{if(!We[t.nodeType])throw new Error(`Unknown node type: ${t.nodeType}`);const r=t.id??An();if(n.some(c=>c.id===r))throw new Error(`Node id already exists: ${r}`);const i=t.position??Bp(n),s={...Vp(t.nodeType),...t.params??{}},a={id:r,type:"venice",position:i,data:s};return{nodes:[...n,a],edges:o,addedNodeId:r}}case"remove_node":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.filter(r=>r.id!==t.id),edges:o.filter(r=>r.source!==t.id&&r.target!==t.id)}}case"set_params":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.map(r=>r.id===t.id?{...r,data:{...r.data,...t.params}}:r),edges:o}}case"move_node":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.map(r=>r.id===t.id?{...r,position:t.position}:r),edges:o}}case"connect":{if(!n.some(s=>s.id===t.source))throw new Error(`Source node not found: ${t.source}`);if(!n.some(s=>s.id===t.target))throw new Error(`Target node not found: ${t.target}`);if(t.source===t.target)throw new Error("Cannot connect a node to itself.");const r=t.id??`e-${t.source}-${t.target}-${An().slice(0,6)}`;if(o.some(s=>s.id===r))throw new Error(`Edge id already exists: ${r}`);const i={id:r,source:t.source,target:t.target,animated:!0};return{nodes:n,edges:[...o,i],addedEdgeId:r}}case"disconnect":{if(!o.some(r=>r.id===t.id))throw new Error(`Edge not found: ${t.id}`);return{nodes:n,edges:o.filter(r=>r.id!==t.id)}}case"clear":return{nodes:[],edges:[]}}}function jp(e,t){let n=e,o,r;for(const s of t){const a=Fp(n,s);n={nodes:a.nodes,edges:a.edges},a.addedNodeId&&(o=a.addedNodeId),a.addedEdgeId&&(r=a.addedEdgeId)}return{nodes:Op(n.nodes,n.edges),edges:n.edges,addedNodeId:o,addedEdgeId:r}}const ng=Sa()(Na((e,t)=>({workflows:[],activeWorkflowId:null,runResults:{},isRunning:!1,createWorkflow:n=>{const o=An(),r={id:o,name:n,nodes:[],edges:[],createdAt:Date.now()};return e(i=>({workflows:[r,...i.workflows],activeWorkflowId:o})),o},updateWorkflow:(n,o)=>e(r=>({workflows:r.workflows.map(i=>i.id===n?{...i,...o}:i)})),deleteWorkflow:n=>e(o=>({workflows:o.workflows.filter(r=>r.id!==n),activeWorkflowId:o.activeWorkflowId===n?null:o.activeWorkflowId})),setActiveWorkflow:n=>e({activeWorkflowId:n}),setRunResults:n=>e({runResults:n}),updateNodeResult:(n,o)=>e(r=>({runResults:{...r.runResults,[n]:{...r.runResults[n],...o}}})),setIsRunning:n=>e({isRunning:n}),clearResults:()=>e({runResults:{}}),applyPatches:(n,o)=>{const r=t().workflows.find(s=>s.id===n);if(!r)throw new Error(`Workflow not found: ${n}`);const i=jp({nodes:r.nodes,edges:r.edges},o);return e(s=>({workflows:s.workflows.map(a=>a.id===n?{...a,nodes:i.nodes,edges:i.edges}:a)})),i}}),{name:"venice-workflows",version:1,storage:Ca(()=>Ma()),partialize:e=>({workflows:e.workflows.slice(0,20),activeWorkflowId:e.activeWorkflowId})}));function Wp(e,t){const n=new Map;for(const c of e)n.set(c.id,[]);for(const c of t)n.get(c.source)?.push(c.target);const o=0,r=1,i=2,s=new Map;for(const c of e)s.set(c.id,o);const a=c=>{s.set(c,r);for(const u of n.get(c)??[]){const d=s.get(u);if(d===r||d===o&&a(u))return!0}return s.set(c,i),!1};for(const c of e)if(s.get(c.id)===o&&a(c.id))return!0;return!1}function Nr(e,t){const n=e[t];return n==null?!0:typeof n=="string"?n.trim()==="":!1}function Xp({nodes:e,edges:t}){const n=[],o=[],r=new Set(e.map(i=>i.id));e.length===0&&o.push({severity:"warning",message:"Workflow is empty."});for(const i of e){const s=We[i.data?.nodeType];if(!s){n.push({severity:"error",nodeId:i.id,message:`Unknown node type: ${String(i.data?.nodeType)}`});continue}for(const a of s.params)if(a.required&&Nr(i.data,a.name)){const c=s.input!=="none"&&t.some(d=>d.target===i.id);(a.name==="prompt"||a.name==="inputText")&&c||n.push({severity:"error",nodeId:i.id,message:`${s.label}: missing required "${a.name}".`})}if(s.input==="none"){const a=t.filter(c=>c.target===i.id);for(const c of a)n.push({severity:"error",edgeId:c.id,message:`${s.label} does not accept inputs.`})}else t.filter(c=>c.target===i.id).length===0&&s.type!=="output"&&(!s.params.some(u=>u.name==="prompt"&&u.required)||Nr(i.data,"prompt"))&&o.push({severity:"warning",nodeId:i.id,message:`${s.label}: no upstream input connected.`});if(s.output==="none"){const a=t.filter(c=>c.source===i.id);for(const c of a)n.push({severity:"error",edgeId:c.id,message:`${s.label} has no output and cannot feed another node.`})}}for(const i of t){if(!r.has(i.source)){n.push({severity:"error",edgeId:i.id,message:`Edge source ${i.source} does not exist.`});continue}if(!r.has(i.target)){n.push({severity:"error",edgeId:i.id,message:`Edge target ${i.target} does not exist.`});continue}if(i.source===i.target){n.push({severity:"error",edgeId:i.id,message:"Self-loops are not allowed."});continue}const s=e.find(d=>d.id===i.source),a=e.find(d=>d.id===i.target);if(!s||!a)continue;const c=We[s.data.nodeType],u=We[a.data.nodeType];!c||!u||(Hp(c.output,u.input)?Lp(c.output,u.input)||o.push({severity:"warning",edgeId:i.id,message:`${c.label} outputs ${c.output}; ${u.label} expects ${u.input}. Conversion may be lossy.`}):n.push({severity:"error",edgeId:i.id,message:`${c.label} (${c.output}) cannot connect to ${u.label} (${u.input}).`}))}return Wp(e,t)&&n.push({severity:"error",message:"Workflow contains a cycle."}),{ok:n.length===0,errors:n,warnings:o}}const Cr=3e3,Mr=200;class In extends Error{nodeId;constructor(t,n){super(t),this.name="WorkflowExecutionError",this.nodeId=n}}function Yp(e,t){const n=new Map,o=new Map;for(const a of e)n.set(a.id,0),o.set(a.id,[]);for(const a of t)!n.has(a.source)||!n.has(a.target)||(o.get(a.source).push(a.target),n.set(a.target,(n.get(a.target)??0)+1));const r=[];let i=e.filter(a=>(n.get(a.id)??0)===0).map(a=>a.id),s=0;for(;i.length>0;){r.push(i),s+=i.length;const a=[];for(const c of i)for(const u of o.get(c)??[]){const d=(n.get(u)??1)-1;n.set(u,d),d===0&&a.push(u)}i=a}return s===e.length?r:null}function Zp(e,t,n){return t.filter(i=>i.target===e).map(i=>n.get(i.source)??"").filter(Boolean).join(` - -`)}function rt(e,t){return e?e.includes("{{input}}")?e.replace(/\{\{input\}\}/g,t):t?`${e} - -${t}`:e:t}async function kr(e,t,n,o,r){for(let i=0;i{const u=setTimeout(a,Cr);r?.addEventListener("abort",()=>{clearTimeout(u),c(new DOMException("Aborted","AbortError"))},{once:!0})});const s=await Ia(e,t,n,{downloadUrl:o,signal:r});if(s.state==="done")return s.url;if(s.state==="failed")throw new Error(s.error)}throw new Error(`Generation timed out after ${Mr*Cr/1e3}s`)}async function qp(e,t,n){const o=e.data;switch(o.nodeType){case"textInput":return o.inputText??"";case"output":return t;case"chat":{const r=rt(o.prompt,t);return(await Nt("/chat/completions",{method:"POST",body:JSON.stringify({model:o.model||"llama-3.3-70b",messages:[{role:"user",content:r}],temperature:o.temperature??.7,max_tokens:o.maxTokens??4096,venice_parameters:{enable_web_search:o.webSearch??"off"}}),signal:n})).choices[0]?.message?.content??""}case"imageGen":{const r=rt(o.prompt,t),i={model:o.model||"z-image-turbo",prompt:r,negative_prompt:o.negativePrompt||void 0,steps:o.steps??20,style_preset:o.style||void 0,width:o.width??1024,height:o.height??1024,hide_watermark:o.hideWatermark??!0};o.aspectRatio&&(i.aspect_ratio=o.aspectRatio);const a=(await Nt("/image/generate",{method:"POST",body:JSON.stringify(i),signal:n})).images[0],c=typeof a=="string"?a:a.b64_json;return`[image:data:${c.startsWith("/9j/")?"image/jpeg":c.startsWith("iVBOR")?"image/png":c.startsWith("UklGR")?"image/webp":"image/png"};base64,${c}]`}case"tts":{const r=rt(o.prompt,t),i=await ka("/audio/speech",{model:o.model||"tts-kokoro",input:r,voice:o.voice||"af_sky",speed:o.speed??1,response_format:o.responseFormat||"mp3"},{signal:n});return`[audio:${URL.createObjectURL(i)}]`}case"music":{const r=rt(o.prompt,t),i={model:o.model||"stable-audio-25",prompt:r,duration_seconds:o.duration??30,force_instrumental:o.instrumental??!1};o.lyrics&&(i.lyrics_prompt=o.lyrics);const s=await Nt("/audio/queue",{method:"POST",body:JSON.stringify(i),signal:n});return`[audio:${await kr("audio",s.model||String(i.model),s.queue_id,s.download_url,n)}]`}case"video":{const r=rt(o.prompt,t),i={model:o.model||"wan-3-0-text-to-video",prompt:r,aspect_ratio:o.videoAspectRatio||"16:9"};o.videoDuration&&(i.duration=o.videoDuration),o.videoResolution&&(i.resolution=o.videoResolution);const s=await Nt("/video/queue",{method:"POST",body:JSON.stringify(i),signal:n});return`[video:${await kr("video",s.model||String(i.model),s.queue_id||s.id||"",s.download_url,n)}]`}}}async function og(e,t,n){const o=typeof n=="function"?{onUpdate:n}:n,{signal:r,onUpdate:i}=o,s=Xp({nodes:e,edges:t});if(!s.ok){const d=s.errors[0];throw new In(d?.message??"Workflow has validation errors.",d?.nodeId)}const a=Yp(e,t);if(!a)throw new In("Workflow contains a cycle.");const c=new Map,u=new Map(e.map(d=>[d.id,d]));for(const d of a){if(r?.aborted)return;await Promise.all(d.map(async l=>{const f=u.get(l);if(f){i(l,{status:"running",output:void 0,error:void 0});try{const h=Zp(l,t,c),g=await qp(f,h,r);c.set(l,g);const m=We[f.data.nodeType]?.output;i(l,{status:"done",output:g,outputKind:m&&m!=="none"?m:void 0})}catch(h){if(h instanceof DOMException&&h.name==="AbortError")throw i(l,{status:"error",error:"Cancelled"}),h;const g=h instanceof Error?h.message:"Unknown error";throw i(l,{status:"error",error:g}),new In(g,l)}}}))}}export{Jp as B,eg as C,Kt as H,tg as M,We as N,X as P,op as R,ao as a,Kp as b,Qp as c,Nd as d,ke as e,og as f,jp as g,Fp as h,Up as i,ng as u,Xp as v}; diff --git a/ventures/havre/open/assets/workflow-engine-BuXGtBGn.js b/ventures/havre/open/assets/workflow-engine-BuXGtBGn.js new file mode 100644 index 0000000..e6e5eab --- /dev/null +++ b/ventures/havre/open/assets/workflow-engine-BuXGtBGn.js @@ -0,0 +1,11 @@ +import{B as Ar,C as Ea,R as _a,D as Sa,r as R,j as $,g as An,q as Na,v as Ca,w as Ma,x as ka,y as Nt,E as Ia,F as Aa}from"./index-fmJ2VqHZ.js";function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n{}};function Jt(){for(var e=0,t=arguments.length,n={},o;e=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}zt.prototype=Jt.prototype={constructor:zt,on:function(e,t){var n=this._,o=Pa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i0)for(var n=new Array(r),o=0,r,i;o=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),vo.hasOwnProperty(t)?{space:vo[t],local:e}:e}function Da(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===$n&&t.documentElement.namespaceURI===$n?t.createElement(e):t.createElementNS(n,e)}}function Ra(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $r(e){var t=en(e);return(t.local?Ra:Da)(t)}function za(){}function Xn(e){return e==null?za:function(){return this.querySelector(e)}}function Ha(e){typeof e!="function"&&(e=Xn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r=g&&(g=b+1);!(S=w[g])&&++g=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function cc(e){e||(e=uc);function t(l,f){return l&&f?e(l.__data__,f.__data__):!l-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;it?1:e>=t?0:NaN}function lc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function dc(){return Array.from(this)}function fc(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?_c:typeof t=="function"?Nc:Sc)(e,t,n??"")):Xe(this.node(),e)}function Xe(e,t){return e.style.getPropertyValue(t)||zr(e).getComputedStyle(e,null).getPropertyValue(t)}function Mc(e){return function(){delete this[e]}}function kc(e,t){return function(){this[e]=t}}function Ic(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ac(e,t){return arguments.length>1?this.each((t==null?Mc:typeof t=="function"?Ic:kc)(e,t)):this.node()[e]}function Hr(e){return e.trim().split(/^|\s+/)}function Yn(e){return e.classList||new Lr(e)}function Lr(e){this._node=e,this._names=Hr(e.getAttribute("class")||"")}Lr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Or(e,t){for(var n=Yn(e),o=-1,r=t.length;++o=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function ru(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n()=>e;function Pn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Pn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pu(e){return!e.ctrlKey&&!e.button}function gu(){return this.parentNode}function mu(e,t){return t??{x:e.x,y:e.y}}function yu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xr(){var e=pu,t=gu,n=mu,o=yu,r={},i=Jt("start","drag","end"),s=0,a,c,u,d,l=0;function f(m){m.on("mousedown.drag",h).filter(o).on("touchstart.drag",w).on("touchmove.drag",x,hu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(m,S){if(!(d||!e.call(this,m,S))){var E=g(this,t.call(this,m,S),m,S,"mouse");E&&(ce(m.view).on("mousemove.drag",p,ut).on("mouseup.drag",y,ut),Wr(m.view),gn(m),u=!1,a=m.clientX,c=m.clientY,E("start",m))}}function p(m){if(Fe(m),!u){var S=m.clientX-a,E=m.clientY-c;u=S*S+E*E>l}r.mouse("drag",m)}function y(m){ce(m.view).on("mousemove.drag mouseup.drag",null),jr(m.view,u),Fe(m),r.mouse("end",m)}function w(m,S){if(e.call(this,m,S)){var E=m.changedTouches,N=t.call(this,m,S),P=E.length,A,V;for(A=0;A>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=wu.exec(e))?new ae(t[1],t[2],t[3],1):(t=vu.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bu.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=Eu.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_u.exec(e))?Mo(t[1],t[2]/100,t[3]/100,1):(t=Su.exec(e))?Mo(t[1],t[2]/100,t[3]/100,t[4]):bo.hasOwnProperty(e)?So(bo[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function So(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ae(e,t,n,o)}function Mu(e){return e instanceof wt||(e=De(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function Tn(e,t,n,o){return arguments.length===1?Mu(e):new ae(e,t,n,o??1)}function ae(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Zn(ae,Tn,Yr(wt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?lt:Math.pow(lt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Pe(this.r),Pe(this.g),Pe(this.b),Wt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:No,formatHex:No,formatHex8:ku,formatRgb:Co,toString:Co}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function ku(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function Co(){const e=Wt(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function Wt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function Mo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new de(e,t,n,o)}function Zr(e){if(e instanceof de)return new de(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=De(e)),!e)return new de;if(e instanceof de)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n0&&c<1?0:s,new de(s,a,c,e.opacity)}function Iu(e,t,n,o){return arguments.length===1?Zr(e):new de(e,t,n,o??1)}function de(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Zn(de,Iu,Yr(wt,{brighter(e){return e=e==null?Ft:Math.pow(Ft,e),new de(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?lt:Math.pow(lt,e),new de(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ae(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new de(ko(this.h),kt(this.s),kt(this.l),Wt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Wt(this.opacity);return`${e===1?"hsl(":"hsla("}${ko(this.h)}, ${kt(this.s)*100}%, ${kt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ko(e){return e=(e||0)%360,e<0?e+360:e}function kt(e){return Math.max(0,Math.min(1,e||0))}function mn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const qn=e=>()=>e;function Au(e,t){return function(n){return e+n*t}}function $u(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Pu(e){return(e=+e)==1?qr:function(t,n){return n-t?$u(t,n,e):qn(isNaN(t)?n:t)}}function qr(e,t){var n=t-e;return n?Au(e,n):qn(isNaN(e)?t:e)}const jt=(function e(t){var n=Pu(t);function o(r,i){var s=n((r=Tn(r)).r,(i=Tn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),u=qr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=c(d),r.opacity=u(d),r+""}}return o.gamma=e,o})(1);function Tu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;rn&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:ge(o,r)})),n=yn.lastIndex;return n180?d+=360:d-u>180&&(u+=360),f.push({i:l.push(r(l)+"rotate(",null,o)-2,x:ge(u,d)})):d&&l.push(r(l)+"rotate("+d+o)}function a(u,d,l,f){u!==d?f.push({i:l.push(r(l)+"skewX(",null,o)-2,x:ge(u,d)}):d&&l.push(r(l)+"skewX("+d+o)}function c(u,d,l,f,h,p){if(u!==l||d!==f){var y=h.push(r(h)+"scale(",null,",",null,")");p.push({i:y-4,x:ge(u,l)},{i:y-2,x:ge(d,f)})}else(l!==1||f!==1)&&h.push(r(h)+"scale("+l+","+f+")")}return function(u,d){var l=[],f=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,l,f),s(u.rotate,d.rotate,l,f),a(u.skewX,d.skewX,l,f),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,l,f),u=d=null,function(h){for(var p=-1,y=f.length,w;++p=0&&e._call.call(void 0,t),e=e._next;--Ye}function $o(){Re=(Yt=ft.now())+tn,Ye=it=0;try{qu()}finally{Ye=0,Uu(),Re=0}}function Gu(){var e=ft.now(),t=e-Yt;t>Qr&&(tn-=t,Yt=e)}function Uu(){for(var e,t=Xt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Xt=n);st=e,zn(o)}function zn(e){if(!Ye){it&&(it=clearTimeout(it));var t=e-Re;t>24?(e<1/0&&(it=setTimeout($o,e-ft.now()-tn)),nt&&(nt=clearInterval(nt))):(nt||(Yt=ft.now(),nt=setInterval(Gu,Qr)),Ye=1,Jr($o))}}function Po(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Ku=Jt("start","end","cancel","interrupt"),Qu=[],ti=0,To=1,Hn=2,Lt=3,Do=4,Ln=5,Ot=6;function nn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Ju(e,n,{name:t,index:o,group:r,on:Ku,tween:Qu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ti})}function Un(e,t){var n=pe(e,t);if(n.state>ti)throw new Error("too late; already scheduled");return n}function xe(e,t){var n=pe(e,t);if(n.state>Lt)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ju(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=ei(i,0,n.time);function i(u){n.state=To,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var d,l,f,h;if(n.state!==To)return c();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Lt)return Po(s);h.state===Do?(h.state=Ot,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+dHn&&o.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Il(e,t,n){var o,r,i=kl(t)?Un:xe;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Al(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(Il(n,e,t))}function $l(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Pl(){return this.on("end.remove",$l(this._id))}function Tl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s()=>e;function rd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var on=new be(1,0,0);ii.prototype=be.prototype;function ii(e){for(;!e.__zoom;)if(!(e=e.parentNode))return on;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function ot(e){e.preventDefault(),e.stopImmediatePropagation()}function id(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ro(){return this.__zoom||on}function ad(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cd(){return navigator.maxTouchPoints||"ontouchstart"in this}function ud(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function si(){var e=id,t=sd,n=ud,o=ad,r=cd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ht,u=Jt("start","zoom","end"),d,l,f,h=500,p=150,y=0,w=10;function x(v){v.property("__zoom",Ro).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",V).filter(r).on("touchstart.zoom",k).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(v,C,_,I){var M=v.selection?v.selection():v;M.property("__zoom",Ro),v!==M?S(v,C,_,I):M.interrupt().each(function(){E(this,arguments).event(I).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},x.scaleBy=function(v,C,_,I){x.scaleTo(v,function(){var M=this.__zoom.k,T=typeof C=="function"?C.apply(this,arguments):C;return M*T},_,I)},x.scaleTo=function(v,C,_,I){x.transform(v,function(){var M=t.apply(this,arguments),T=this.__zoom,H=_==null?m(M):typeof _=="function"?_.apply(this,arguments):_,O=T.invert(H),L=typeof C=="function"?C.apply(this,arguments):C;return n(g(b(T,L),H,O),M,s)},_,I)},x.translateBy=function(v,C,_,I){x.transform(v,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof _=="function"?_.apply(this,arguments):_),t.apply(this,arguments),s)},null,I)},x.translateTo=function(v,C,_,I,M){x.transform(v,function(){var T=t.apply(this,arguments),H=this.__zoom,O=I==null?m(T):typeof I=="function"?I.apply(this,arguments):I;return n(on.translate(O[0],O[1]).scale(H.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof _=="function"?-_.apply(this,arguments):-_),T,s)},I,M)};function b(v,C){return C=Math.max(i[0],Math.min(i[1],C)),C===v.k?v:new be(C,v.x,v.y)}function g(v,C,_){var I=C[0]-_[0]*v.k,M=C[1]-_[1]*v.k;return I===v.x&&M===v.y?v:new be(v.k,I,M)}function m(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,C,_,I){v.on("start.zoom",function(){E(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(I).end()}).tween("zoom",function(){var M=this,T=arguments,H=E(M,T).event(I),O=t.apply(M,T),L=_==null?m(O):typeof _=="function"?_.apply(M,T):_,W=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),F=M.__zoom,Z=typeof C=="function"?C.apply(M,T):C,U=c(F.invert(L).concat(W/F.k),Z.invert(L).concat(W/Z.k));return function(Y){if(Y===1)Y=Z;else{var B=U(Y),j=W/B[2];Y=new be(j,L[0]-B[0]*j,L[1]-B[1]*j)}H.zoom(null,Y)}})}function E(v,C,_){return!_&&v.__zooming||new N(v,C)}function N(v,C){this.that=v,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,C),this.taps=0}N.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,C){return this.mouse&&v!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var C=ce(this.that).datum();u.call(v,this.that,new rd(v,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:u}),C)}};function P(v,...C){if(!e.apply(this,arguments))return;var _=E(this,C).event(v),I=this.__zoom,M=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,o.apply(this,arguments)))),T=le(v);if(_.wheel)(_.mouse[0][0]!==T[0]||_.mouse[0][1]!==T[1])&&(_.mouse[1]=I.invert(_.mouse[0]=T)),clearTimeout(_.wheel);else{if(I.k===M)return;_.mouse=[T,I.invert(T)],Vt(this),_.start()}ot(v),_.wheel=setTimeout(H,p),_.zoom("mouse",n(g(b(I,M),_.mouse[0],_.mouse[1]),_.extent,s));function H(){_.wheel=null,_.end()}}function A(v,...C){if(f||!e.apply(this,arguments))return;var _=v.currentTarget,I=E(this,C,!0).event(v),M=ce(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",W,!0),T=le(v,_),H=v.clientX,O=v.clientY;Wr(v.view),xn(v),I.mouse=[T,this.__zoom.invert(T)],Vt(this),I.start();function L(F){if(ot(F),!I.moved){var Z=F.clientX-H,U=F.clientY-O;I.moved=Z*Z+U*U>y}I.event(F).zoom("mouse",n(g(I.that.__zoom,I.mouse[0]=le(F,_),I.mouse[1]),I.extent,s))}function W(F){M.on("mousemove.zoom mouseup.zoom",null),jr(F.view,I.moved),ot(F),I.event(F).end()}}function V(v,...C){if(e.apply(this,arguments)){var _=this.__zoom,I=le(v.changedTouches?v.changedTouches[0]:v,this),M=_.invert(I),T=_.k*(v.shiftKey?.5:2),H=n(g(b(_,T),I,M),t.apply(this,C),s);ot(v),a>0?ce(this).transition().duration(a).call(S,H,I,v):ce(this).call(x.transform,H,I,v)}}function k(v,...C){if(e.apply(this,arguments)){var _=v.touches,I=_.length,M=E(this,C,v.changedTouches.length===I).event(v),T,H,O,L;for(xn(v),H=0;H"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ai=["Enter"," ","Escape"],ci={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const ui={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Me;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Me||(Me={}));var qt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qt||(qt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const zo={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function li(e){return e===null?null:e?"valid":"invalid"}const di=e=>"id"in e&&"source"in e&&"target"in e,ld=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=_e(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},dd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Qn(r)?r:t.nodeLookup.get(r.id));const a=s?Gt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return rn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return sn(n)},bt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=rn(n,Gt(r)),o=!0)}),o?sn(n):{x:0,y:0,width:0,height:0}},Jn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={..._t(t,[n,o,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:d,selectable:l=!0,hidden:f=!1}=u;if(s&&!l||f)continue;const h=d.width??u.width??u.initialWidth??null,p=d.height??u.height??u.initialHeight??null,y=gt(a,Ge(u)),w=(h??0)*(p??0),x=i&&y>0;(!u.internals.handleBounds||x||y>=w||u.dragging)&&c.push(u)}return c},fd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function hd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function pd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=hd(e,s),c=bt(a),u=eo(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(u,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function fi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let l=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const h=a.measured.width,p=a.measured.height;h&&p&&(l=[[c,u],[c+h,u+p]])}else a&&Ue(s.extent)&&(l=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const f=Ue(l)?ze(t,l,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:f.x-c+(s.measured.width??0)*d[0],y:f.y-u+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function gd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),p=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||p)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=o.filter(f=>f.deletable!==!1),d=fd(s,c);for(const f of c)a.has(f.id)&&!d.find(p=>p.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const l=await r({nodes:s,edges:d});return typeof l=="boolean"?l?{edges:d,nodes:s}:{edges:[],nodes:[]}:l}const qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ze=(e={x:0,y:0},t,n)=>({x:qe(e.x,t[0][0],t[1][0]-(n?.width??0)),y:qe(e.y,t[0][1],t[1][1]-(n?.height??0))});function hi(e,t,n){const{width:o,height:r}=_e(n),{x:i,y:s}=n.internals.positionAbsolute;return ze(e,[[i,s],[i+o,s+r]],t)}const Ho=(e,t,n)=>en?-qe(Math.abs(e-n),1,t)/t:0,pi=(e,t,n=15,o=40)=>{const r=Ho(e.x,o,t.width-o)*n,i=Ho(e.y,o,t.height-o)*n;return[r,i]},rn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),On=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),sn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ge=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Gt=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:vt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},gi=(e,t)=>sn(rn(On(e),On(t))),gt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Lo=e=>fe(e.width)&&fe(e.height)&&fe(e.x)&&fe(e.y),fe=e=>!isNaN(e)&&isFinite(e),md=(e,t)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_t=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?Et(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Oe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function yd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Oe(e,n),r=Oe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Oe(e.top??e.y??0,n),r=Oe(e.bottom??e.y??0,n),i=Oe(e.left??e.x??0,t),s=Oe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xd(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:c,y:u}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-c,l=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(l)}}const eo=(e,t,n,o,r,i)=>{const s=yd(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),d=qe(u,o,r),l=e.x+e.width/2,f=e.y+e.height/2,h=t/2-l*d,p=n/2-f*d,y=xd(e,h,p,d,t,n),w={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:p-w.top+w.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function _e(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function mi(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function yi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Oo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function wd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function vd(e){return{...ci,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=he(e),a=_t({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:u}=n?Et(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const to=e=>({width:e.offsetWidth,height:e.offsetHeight}),xi=e=>e?.getRootNode?.()||window?.document,bd=["INPUT","SELECT","TEXTAREA"];function wi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:bd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const vi=e=>"clientX"in e,he=(e,t)=>{const n=vi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Vo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...to(s)}})};function bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+o*.125,d=Math.abs(c-e),l=Math.abs(u-t);return[c,u,d,l]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Bo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-$t(t-o,i),n];case X.Right:return[t+$t(o-t,i),n];case X.Top:return[t,n-$t(n-r,i)];case X.Bottom:return[t,n+$t(r-n,i)]}}function Ei({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Bo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[u,d]=Bo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[l,f,h,p]=bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${c} ${u},${d} ${o},${r}`,l,f,h,p]}function _i({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n0}const Sd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Nd=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Cd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Sd;let r;return di(e)?r={...e}:r={...e,id:o(e)},Nd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Si({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=_i({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Fo={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},Md=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function kd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Fo[t],c=Fo[o],u={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},l=Md({source:u,sourcePosition:t,target:d}),f=l.x!==0?"x":"y",h=l[f];let p=[],y,w;const x={x:0,y:0},b={x:0,y:0},[,,g,m]=_i({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(y=r.x??u.x+(d.x-u.x)*s,w=r.y??(u.y+d.y)/2):(y=r.x??(u.x+d.x)/2,w=r.y??u.y+(d.y-u.y)*s);const E=[{x:y,y:u.y},{x:y,y:d.y}],N=[{x:u.x,y:w},{x:d.x,y:w}];a[f]===h?p=f==="x"?E:N:p=f==="x"?N:E}else{const E=[{x:u.x,y:d.y}],N=[{x:d.x,y:u.y}];if(f==="x"?p=a.x===h?N:E:p=a.y===h?E:N,t===o){const D=Math.abs(e[f]-n[f]);if(D<=i){const z=Math.min(i-1,i-D);a[f]===h?x[f]=(u[f]>e[f]?-1:1)*z:b[f]=(d[f]>n[f]?-1:1)*z}}if(t!==o){const D=f==="x"?"y":"x",z=a[f]===c[D],v=u[D]>d[D],C=u[D]=k?(y=(P.x+A.x)/2,w=p[0].y):(y=p[0].x,w=(P.y+A.y)/2)}return[[e,{x:u.x+x.x,y:u.y+x.y},...p,{x:d.x+b.x,y:d.y+b.y},n],y,w,g,m]}function Id(e,t,n,o){const r=Math.min(Wo(e,t)/2,Wo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x{let m="";return g>0&&gn.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function $d(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Bn(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Ni=1e3,Pd=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Td={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Dd(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=ze(i,s,_e(r));r.internals.positionAbsolute=a}}function Rd(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function ro(e){return e==="manual"}function Fn(e,t,n,o={}){const r=oo(Td,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?Ni:0;let c=e.length>0;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===d?.internals.userNode)t.set(u.id,d);else{const l=vt(u,r.nodeOrigin),f=Ue(u.extent)?u.extent:r.nodeExtent,h=ze(l,f,_e(u));d={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:h,handleBounds:Rd(u,d),z:Ci(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&io(d,t,n,o,i)}return c}function zd(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=oo(no,o),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}zd(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*Pd),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const l=i&&!ro(c)?Ni:0,{x:f,y:h,z:p}=Hd(e,d,s,a,l,c),{positionAbsolute:y}=e.internals,w=f!==y.x||h!==y.y;(w||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:y,z:p}})}function Ci(e,t,n){const o=fe(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function Hd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=_e(e),u=vt(e,n),d=Ue(e.extent)?ze(u,e.extent,c):u;let l=ze({x:s+d.x,y:a+d.y},o,c);e.extent==="parent"&&(l=hi(l,c,t));const f=Ci(e,r,i),h=t.internals.z??0;return{x:l.x,y:l.y,z:h>=f?h+1:f}}function so(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??Ge(a),u=gi(c,s.rect);i.set(s.parentId,{expandedRect:u,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const u=a.internals.positionAbsolute,d=_e(a),l=a.origin??o,f=s.x0||h>0||w||x)&&(r.push({id:c,type:"position",position:{x:a.position.x-f+w,y:a.position.y-h+x}}),n.get(c)?.forEach(b=>{e.some(g=>g.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width0){const h=so(f,t,n,r);u.push(...h)}return{changes:u,updatedInternals:c}}async function Od({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Zo(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const u=o.get(s)||new Map;o.set(s,u.set(n,t))}}function Mi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Zo("source",c,d,e,r,s),Zo("target",c,u,e,i,a),t.set(o.id,o)}}function ki(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ki(n,t):!1}function qo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Vd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!ki(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function wn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Bd({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=Et(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Fd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},d=null,l=!1,f=null,h=!1,p=!1,y=null;function w({noDragClassName:b,handleSelector:g,domNode:m,isSelectable:S,nodeId:E,nodeClickDistance:N=0}){f=ce(m);function P({x:D,y:z}){const{nodeLookup:v,nodeExtent:C,snapGrid:_,snapToGrid:I,nodeOrigin:M,onNodeDrag:T,onSelectionDrag:H,onError:O,updateNodePositions:L}=t();i={x:D,y:z};let W=!1;const F=a.size>1,Z=F&&C?On(bt(a)):null,U=F&&I?Bd({dragItems:a,snapGrid:_,x:D,y:z}):null;for(const[Y,B]of a){if(!v.has(Y))continue;let j={x:D-B.distance.x,y:z-B.distance.y};I&&(j=U?{x:Math.round(j.x+U.x),y:Math.round(j.y+U.y)}:Et(j,_));let Q=null;if(F&&C&&!B.extent&&Z){const{positionAbsolute:G}=B.internals,ee=G.x-Z.x+C[0][0],ne=G.x+B.measured.width-Z.x2+C[1][0],te=G.y-Z.y+C[0][1],se=G.y+B.measured.height-Z.y2+C[1][1];Q=[[ee,te],[ne,se]]}const{position:K,positionAbsolute:q}=fi({nodeId:Y,nextPosition:j,nodeLookup:v,nodeExtent:Q||C,nodeOrigin:M,onError:O});W=W||B.position.x!==K.x||B.position.y!==K.y,B.position=K,B.internals.positionAbsolute=q}if(p=p||W,!!W&&(L(a,!0),y&&(o||T||!E&&H))){const[Y,B]=wn({nodeId:E,dragItems:a,nodeLookup:v});o?.(y,a,Y,B),T?.(y,Y,B),E||H?.(y,B)}}async function A(){if(!d)return;const{transform:D,panBy:z,autoPanSpeed:v,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(s);return}const[_,I]=pi(u,d,v);(_!==0||I!==0)&&(i.x=(i.x??0)-_/D[2],i.y=(i.y??0)-I/D[2],await z({x:_,y:I})&&P(i)),s=requestAnimationFrame(A)}function V(D){const{nodeLookup:z,multiSelectionActive:v,nodesDraggable:C,transform:_,snapGrid:I,snapToGrid:M,selectNodesOnDrag:T,onNodeDragStart:H,onSelectionDragStart:O,unselectNodesAndEdges:L}=t();l=!0,(!T||!S)&&!v&&E&&(z.get(E)?.selected||L()),S&&T&&E&&e?.(E);const W=ct(D.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:d});if(i=W,a=Vd(z,C,W,E),a.size>0&&(n||H||!E&&O)){const[F,Z]=wn({nodeId:E,dragItems:a,nodeLookup:z});n?.(D.sourceEvent,a,F,Z),H?.(D.sourceEvent,F,Z),E||O?.(D.sourceEvent,Z)}}const k=Xr().clickDistance(N).on("start",D=>{const{domNode:z,nodeDragThreshold:v,transform:C,snapGrid:_,snapToGrid:I}=t();d=z?.getBoundingClientRect()||null,h=!1,p=!1,y=D.sourceEvent,v===0&&V(D),i=ct(D.sourceEvent,{transform:C,snapGrid:_,snapToGrid:I,containerBounds:d}),u=he(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:z,transform:v,snapGrid:C,snapToGrid:_,nodeDragThreshold:I,nodeLookup:M}=t(),T=ct(D.sourceEvent,{transform:v,snapGrid:C,snapToGrid:_,containerBounds:d});if(y=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||E&&!M.has(E))&&(h=!0),!h){if(!c&&z&&l&&(c=!0,A()),!l){const H=he(D.sourceEvent,d),O=H.x-u.x,L=H.y-u.y;Math.sqrt(O*O+L*L)>I&&V(D)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&a&&l&&(u=he(D.sourceEvent,d),P(T))}}).on("end",D=>{if(!(!l||h)&&(c=!1,l=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:z,updateNodePositions:v,onNodeDragStop:C,onSelectionDragStop:_}=t();if(p&&(v(a,!1),p=!1),r||C||!E&&_){const[I,M]=wn({nodeId:E,dragItems:a,nodeLookup:z,dragging:!1});r?.(D.sourceEvent,a,I,M),C?.(D.sourceEvent,I,M),E||_?.(D.sourceEvent,M)}}}).filter(D=>{const z=D.target;return!D.button&&(!b||!qo(z,`.${b}`,m))&&(!g||qo(z,g,m))});f.call(k)}function x(){f?.on(".drag",null)}return{update:w,destroy:x}}function Wd(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())gt(r,Ge(i))>0&&o.push(i);return o}const jd=250;function Xd(e,t,n,o){let r=[],i=1/0;const s=Wd(e,n,t+jd);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const u of c){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;const{x:d,y:l}=He(a,u,u.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(l-e.y,2));f>t||(f1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function Ii(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(u=>u.id===n):a?.[0])??null;return c&&i?{...c,...He(s,c,c.position,!0)}:c}function Ai(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Yd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const $i=()=>!0;function Zd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:l,panBy:f,cancelConnection:h,onConnectStart:p,onConnect:y,onConnectEnd:w,isValidConnection:x=$i,onReconnectEnd:b,updateConnection:g,getTransform:m,getFromHandle:S,autoPanSpeed:E,dragThreshold:N=1,handleDomNode:P}){const A=xi(e.target);let V=0,k;const{x:D,y:z}=he(e),v=Ai(i,P),C=a?.getBoundingClientRect();let _=!1;if(!C||!v)return;const I=Ii(r,v,o,c,t);if(!I)return;let M=he(e,C),T=!1,H=null,O=!1,L=null;function W(){if(!d||!C)return;const[K,q]=pi(M,C,E);f({x:K,y:q}),V=requestAnimationFrame(W)}const F={...I,nodeId:r,type:v,position:I.position},Z=c.get(r);let Y={inProgress:!0,isValid:null,from:He(Z,F,X.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:Z,to:M,toHandle:null,toPosition:zo[F.position],toNode:null,pointer:M};function B(){_=!0,g(Y),p?.(e,{nodeId:r,handleId:o,handleType:v})}N===0&&B();function j(K){if(!_){const{x:se,y:Se}=he(K),we=se-D,Ie=Se-z;if(!(we*we+Ie*Ie>N*N))return;B()}if(!S()||!F){Q(K);return}const q=m();M=he(K,C),k=Xd(_t(M,q,!1,[1,1]),n,c,F),T||(W(),T=!0);const G=Pi(K,{handle:k,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:x,doc:A,lib:u,flowId:l,nodeLookup:c});L=G.handleDomNode,H=G.connection,O=Yd(!!k,G.isValid);const ee=c.get(r),ne=ee?He(ee,F,X.Left,!0):Y.from,te={...Y,from:ne,isValid:O,to:G.toHandle&&O?Ut({x:G.toHandle.x,y:G.toHandle.y},q):M,toHandle:G.toHandle,toPosition:O&&G.toHandle?G.toHandle.position:zo[F.position],toNode:G.toHandle?c.get(G.toHandle.nodeId):null,pointer:M};g(te),Y=te}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(_){(k||L)&&H&&O&&y?.(H);const{inProgress:q,...G}=Y,ee={...G,toPosition:Y.toHandle?Y.toPosition:null};w?.(K,ee),i&&b?.(K,ee)}h(),cancelAnimationFrame(V),T=!1,O=!1,H=null,L=null,A.removeEventListener("mousemove",j),A.removeEventListener("mouseup",Q),A.removeEventListener("touchmove",j),A.removeEventListener("touchend",Q)}}A.addEventListener("mousemove",j),A.addEventListener("mouseup",Q),A.addEventListener("touchmove",j),A.addEventListener("touchend",Q)}function Pi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=$i,nodeLookup:d}){const l=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:p}=he(e),y=s.elementFromPoint(h,p),w=y?.classList.contains(`${a}-flow__handle`)?y:f,x={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=Ai(void 0,w),g=w.getAttribute("data-nodeid"),m=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),E=w.classList.contains("connectableend");if(!g||!b)return x;const N={source:l?g:o,sourceHandle:l?m:r,target:l?o:g,targetHandle:l?r:m};x.connection=N;const A=S&&E&&(n===Ze.Strict?l&&b==="source"||!l&&b==="target":g!==o||m!==r);x.isValid=A&&u(N),x.toHandle=Ii(g,b,m,d,n,!0)}return x}const Wn={onPointerDown:Zd,isValid:Pi};function qd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:d=1,pannable:l=!0,zoomable:f=!0,inversePan:h=!1}){const p=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const m=n(),S=g.sourceEvent.ctrlKey&&mt()?10:1,E=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*d,N=m[2]*Math.pow(2,E*S);t.scaleTo(N)};let y=[0,0];const w=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(y=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const m=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const S=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],E=[S[0]-y[0],S[1]-y[1]];y=S;const N=o()*Math.max(m[2],Math.log(m[2]))*(h?-1:1),P={x:m[0]-E[0]*N,y:m[1]-E[1]*N},A=[[0,0],[c,u]];t.setViewportConstrained({x:P.x,y:P.y,zoom:m[2]},A,a)},b=si().on("start",w).on("zoom",l?x:null).on("zoom.wheel",f?p:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:le}}const an=e=>({x:e.x,y:e.y,zoom:e.k}),vn=({x:e,y:t,zoom:n})=>on.translate(e,t).scale(n),Ve=(e,t)=>e.target.closest(`.${t}`),Ti=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Gd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=Gd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Di=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Ud({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Ve(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const l=n.property("__zoom").k||1;if(d.ctrlKey&&s){const w=le(d),x=Di(d),b=l*Math.pow(2,x);o.scaleTo(n,b,w,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,p=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,p=0),o.translateBy(n,-(h/l)*i,-(p/l)*i,{internal:!0});const y=an(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,y),e.panScrollTimeout=setTimeout(()=>{u?.(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,y))}}function Kd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Ve(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Qd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=an(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Jd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ti(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,an(i.transform))}}function ef({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ti(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=an(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function tf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:d}){return l=>{const f=e||t,h=n&&l.ctrlKey,p=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Ve(l,`${u}-flow__node`)||Ve(l,`${u}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!p||Ve(l,a)&&p||Ve(l,c)&&(!p||r&&p&&!e)||!n&&l.ctrlKey&&p)return!1;if(!n&&l.type==="touchstart"&&l.touches?.length>1)return l.preventDefault(),!1;if(!f&&!r&&!h&&p||!o&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(o)&&!o.includes(l.button)&&l.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||p)&&y}}function nf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),l=si().scaleExtent([t,n]).translateExtent(o),f=ce(e).call(l);b({x:r.x,y:r.y,zoom:qe(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),p=f.on("dblclick.zoom");l.wheelDelta(Di);function y(k,D){return f?new Promise(z=>{l?.interpolate(D?.interpolate==="linear"?at:Ht).transform(bn(f,D?.duration,D?.ease,()=>z(!0)),k)}):Promise.resolve(!1)}function w({noWheelClassName:k,noPanClassName:D,onPaneContextMenu:z,userSelectionActive:v,panOnScroll:C,panOnDrag:_,panOnScrollMode:I,panOnScrollSpeed:M,preventScrolling:T,zoomOnPinch:H,zoomOnScroll:O,zoomOnDoubleClick:L,zoomActivationKeyPressed:W,lib:F,onTransformChange:Z,connectionInProgress:U,paneClickDistance:Y,selectionOnDrag:B}){v&&!u.isZoomingOrPanning&&x();const j=C&&!W&&!v;l.clickDistance(B?1/0:!fe(Y)||Y<0?0:Y);const Q=j?Ud({zoomPanValues:u,noWheelClassName:k,d3Selection:f,d3Zoom:l,panOnScrollMode:I,panOnScrollSpeed:M,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Kd({noWheelClassName:k,preventScrolling:T,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Qd({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});l.on("start",q);const G=Jd({zoomPanValues:u,panOnDrag:_,onPaneContextMenu:!!z,onPanZoom:i,onTransformChange:Z});l.on("zoom",G);const ee=ef({zoomPanValues:u,panOnDrag:_,panOnScroll:C,onPaneContextMenu:z,onPanZoomEnd:a,onDraggingChange:c});l.on("end",ee)}const K=tf({zoomActivationKeyPressed:W,panOnDrag:_,zoomOnScroll:O,panOnScroll:C,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:D,noWheelClassName:k,lib:F,connectionInProgress:U});l.filter(K),L?f.on("dblclick.zoom",p):f.on("dblclick.zoom",null)}function x(){l.on("zoom",null)}async function b(k,D,z){const v=vn(k),C=l?.constrain()(v,D,z);return C&&await y(C),new Promise(_=>_(C))}async function g(k,D){const z=vn(k);return await y(z,D),new Promise(v=>v(z))}function m(k){if(f){const D=vn(k),z=f.property("__zoom");(z.k!==k.zoom||z.x!==k.x||z.y!==k.y)&&l?.transform(f,D,null,{sync:!0})}}function S(){const k=f?ii(f.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function E(k,D){return f?new Promise(z=>{l?.interpolate(D?.interpolate==="linear"?at:Ht).scaleTo(bn(f,D?.duration,D?.ease,()=>z(!0)),k)}):Promise.resolve(!1)}function N(k,D){return f?new Promise(z=>{l?.interpolate(D?.interpolate==="linear"?at:Ht).scaleBy(bn(f,D?.duration,D?.ease,()=>z(!0)),k)}):Promise.resolve(!1)}function P(k){l?.scaleExtent(k)}function A(k){l?.translateExtent(k)}function V(k){const D=!fe(k)||k<0?0:k;l?.clickDistance(D)}return{update:w,destroy:x,setViewport:g,setViewportConstrained:b,getViewport:S,scaleTo:E,scaleBy:N,setScaleExtent:P,setTranslateExtent:A,syncViewport:m,setClickDistance:V}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function of({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function Go(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Ne(e,t){return Math.max(0,t-e)}function Ce(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function Uo(e,t){return e?!t:t}function rf(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:l}=t,f=d&&l,{xSnapped:h,ySnapped:p}=n,{minWidth:y,maxWidth:w,minHeight:x,maxHeight:b}=o,{x:g,y:m,width:S,height:E,aspectRatio:N}=e;let P=Math.floor(d?h-e.pointerX:0),A=Math.floor(l?p-e.pointerY:0);const V=S+(c?-P:P),k=E+(u?-A:A),D=-i[0]*S,z=-i[1]*E;let v=Pt(V,y,w),C=Pt(k,x,b);if(s){let M=0,T=0;c&&P<0?M=Ne(g+P+D,s[0][0]):!c&&P>0&&(M=Ce(g+V+D,s[1][0])),u&&A<0?T=Ne(m+A+z,s[0][1]):!u&&A>0&&(T=Ce(m+k+z,s[1][1])),v=Math.max(v,M),C=Math.max(C,T)}if(a){let M=0,T=0;c&&P>0?M=Ce(g+P,a[0][0]):!c&&P<0&&(M=Ne(g+V,a[1][0])),u&&A>0?T=Ce(m+A,a[0][1]):!u&&A<0&&(T=Ne(m+k,a[1][1])),v=Math.max(v,M),C=Math.max(C,T)}if(r){if(d){const M=Pt(V/N,x,b)*N;if(v=Math.max(v,M),s){let T=0;!c&&!u||c&&!u&&f?T=Ce(m+z+V/N,s[1][1])*N:T=Ne(m+z+(c?P:-P)/N,s[0][1])*N,v=Math.max(v,T)}if(a){let T=0;!c&&!u||c&&!u&&f?T=Ne(m+V/N,a[1][1])*N:T=Ce(m+(c?P:-P)/N,a[0][1])*N,v=Math.max(v,T)}}if(l){const M=Pt(k*N,y,w)/N;if(C=Math.max(C,M),s){let T=0;!c&&!u||u&&!c&&f?T=Ce(g+k*N+D,s[1][0])/N:T=Ne(g+(u?A:-A)*N+D,s[0][0])/N,C=Math.max(C,T)}if(a){let T=0;!c&&!u||u&&!c&&f?T=Ne(g+k*N,a[1][0])/N:T=Ce(g+(u?A:-A)*N,a[0][0])/N,C=Math.max(C,T)}}}A=A+(A<0?C:-C),P=P+(P<0?v:-v),r&&(f?V>k*N?A=(Uo(c,u)?-P:P)/N:P=(Uo(c,u)?-A:A)*N:d?(A=P/N,u=c):(P=A*N,c=u));const _=c?g+P:g,I=u?m+A:m;return{width:S+(c?-P:P),height:E+(u?-A:A),x:i[0]*P*(c?-1:1)+_,y:i[1]*A*(u?-1:1)+I}}const Ri={width:0,height:0,x:0,y:0},sf={...Ri,pointerX:0,pointerY:0,aspectRatio:1};function af(e){return[[0,0],[e.measured.width,e.measured.height]]}function cf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function uf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ce(e);let s={controlDirection:Go("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:d,keepAspectRatio:l,resizeDirection:f,onResizeStart:h,onResize:p,onResizeEnd:y,shouldResize:w}){let x={...Ri},b={...sf};s={boundaries:d,resizeDirection:f,keepAspectRatio:l,controlDirection:Go(u)};let g,m=null,S=[],E,N,P,A=!1;const V=Xr().on("start",k=>{const{nodeLookup:D,transform:z,snapGrid:v,snapToGrid:C,nodeOrigin:_,paneDomNode:I}=n();if(g=D.get(t),!g)return;m=I?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:T}=ct(k.sourceEvent,{transform:z,snapGrid:v,snapToGrid:C,containerBounds:m});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},b={...x,pointerX:M,pointerY:T,aspectRatio:x.width/x.height},E=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(E=D.get(g.parentId),N=E&&g.extent==="parent"?af(E):void 0),S=[],P=void 0;for(const[H,O]of D)if(O.parentId===t&&(S.push({id:H,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const L=cf(O,g,O.origin??_);P?P=[[Math.min(L[0][0],P[0][0]),Math.min(L[0][1],P[0][1])],[Math.max(L[1][0],P[1][0]),Math.max(L[1][1],P[1][1])]]:P=L}h?.(k,{...x})}).on("drag",k=>{const{transform:D,snapGrid:z,snapToGrid:v,nodeOrigin:C}=n(),_=ct(k.sourceEvent,{transform:D,snapGrid:z,snapToGrid:v,containerBounds:m}),I=[];if(!g)return;const{x:M,y:T,width:H,height:O}=x,L={},W=g.origin??C,{width:F,height:Z,x:U,y:Y}=rf(b,s.controlDirection,_,s.boundaries,s.keepAspectRatio,W,N,P),B=F!==H,j=Z!==O,Q=U!==M&&B,K=Y!==T&&j;if(!Q&&!K&&!B&&!j)return;if((Q||K||W[0]===1||W[1]===1)&&(L.x=Q?U:x.x,L.y=K?Y:x.y,x.x=L.x,x.y=L.y,S.length>0)){const ne=U-M,te=Y-T;for(const se of S)se.position={x:se.position.x-ne+W[0]*(F-H),y:se.position.y-te+W[1]*(Z-O)},I.push(se)}if((B||j)&&(L.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:x.width,L.height=j&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:x.height,x.width=L.width,x.height=L.height),E&&g.expandParent){const ne=W[0]*(L.width??0);L.x&&L.x{A&&(y?.(k,{...x}),r?.({...x}),A=!1)});i.call(V)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var En={exports:{}},_n={},Sn={exports:{}},Nn={};var Ko;function lf(){if(Ko)return Nn;Ko=1;var e=Ar();function t(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(l,f){var h=f(),p=o({inst:{value:h,getSnapshot:f}}),y=p[0].inst,w=p[1];return i(function(){y.value=h,y.getSnapshot=f,c(y)&&w({inst:y})},[l,h,f]),r(function(){return c(y)&&w({inst:y}),l(function(){c(y)&&w({inst:y})})},[l]),s(h),h}function c(l){var f=l.getSnapshot;l=l.value;try{var h=f();return!n(l,h)}catch{return!0}}function u(l,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Nn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Nn}var Qo;function df(){return Qo||(Qo=1,Sn.exports=lf()),Sn.exports}var Jo;function ff(){if(Jo)return _n;Jo=1;var e=Ar(),t=df();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return _n.useSyncExternalStoreWithSelector=function(u,d,l,f,h){var p=i(null);if(p.current===null){var y={hasValue:!1,value:null};p.current=y}else y=p.current;p=a(function(){function x(E){if(!b){if(b=!0,g=E,E=f(E),h!==void 0&&y.hasValue){var N=y.value;if(h(N,E))return m=N}return m=E}if(N=m,o(g,E))return N;var P=f(E);return h!==void 0&&h(N,P)?(g=E,N):(g=E,m=P)}var b=!1,g,m,S=l===void 0?null:l;return[function(){return x(d())},S===null?void 0:function(){return x(S())}]},[d,l,f,h]);var w=r(u,p[0],p[1]);return s(function(){y.hasValue=!0,y.value=w},[w]),c(w),w},_n}var er;function hf(){return er||(er=1,En.exports=ff()),En.exports}var pf=hf();const gf=Ea(pf),mf={},tr=e=>{let t;const n=new Set,o=(d,l)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(mf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(o,r,c);return c},yf=e=>e?tr(e):tr,{useDebugValue:xf}=_a,{useSyncExternalStoreWithSelector:wf}=gf,vf=e=>e;function zi(e,t=vf,n){const o=wf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return xf(o),o}const nr=(e,t)=>{const n=yf(e),o=(r,i=t)=>zi(n,r,i);return Object.assign(o,n),o},bf=(e,t)=>e?nr(e,t):nr;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}Sa();const cn=R.createContext(null),Ef=cn.Provider,Hi=ye.error001();function J(e,t){const n=R.useContext(cn);if(n===null)throw new Error(Hi);return zi(n,e,t)}function re(){const e=R.useContext(cn);if(e===null)throw new Error(Hi);return R.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const or={display:"none"},_f={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Li="react-flow__node-desc",Oi="react-flow__edge-desc",Sf="react-flow__aria-live",Nf=e=>e.ariaLiveMessage,Cf=e=>e.ariaLabelConfig;function Mf({rfId:e}){const t=J(Nf);return $.jsx("div",{id:`${Sf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:_f,children:t})}function kf({rfId:e,disableKeyboardA11y:t}){const n=J(Cf);return $.jsxs($.Fragment,{children:[$.jsx("div",{id:`${Li}-${e}`,style:or,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),$.jsx("div",{id:`${Oi}-${e}`,style:or,children:n["edge.a11yDescription.default"]}),!t&&$.jsx(Mf,{rfId:e})]})}const un=R.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return $.jsx("div",{className:ie(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});un.displayName="Panel";function If({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:$.jsx(un,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:$.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Af=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Tt=e=>e.id;function $f(e,t){return oe(e.selectedNodes.map(Tt),t.selectedNodes.map(Tt))&&oe(e.selectedEdges.map(Tt),t.selectedEdges.map(Tt))}function Pf({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=J(Af,$f);return R.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Tf=e=>!!e.onSelectionChangeHandlers;function Df({onSelectionChange:e}){const t=J(Tf);return e||t?$.jsx(Pf,{onSelectionChange:e}):null}const Vi=[0,0],Rf={x:0,y:0,zoom:1},zf=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],rr=[...zf,"rfId"],Hf=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),ir={translateExtent:ht,nodeOrigin:Vi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Lf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=J(Hf,oe),u=re();R.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=ir,a()}),[]);const d=R.useRef(ir);return R.useEffect(()=>{for(const l of rr){const f=e[l],h=d.current[l];f!==h&&(typeof e[l]>"u"||(l==="nodes"?t(f):l==="edges"?n(f):l==="minZoom"?o(f):l==="maxZoom"?r(f):l==="translateExtent"?i(f):l==="nodeExtent"?s(f):l==="ariaLabelConfig"?u.setState({ariaLabelConfig:vd(f)}):l==="fitView"?u.setState({fitViewQueued:f}):l==="fitViewOptions"?u.setState({fitViewOptions:f}):u.setState({[l]:f})))}d.current=e},rr.map(l=>e[l])),null}function sr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Of(e){const[t,n]=R.useState(e==="system"?null:e);return R.useEffect(()=>{if(e!=="system"){n(e);return}const o=sr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:sr()?.matches?"dark":"light"}const ar=typeof document<"u"?document:null;function yt(e=null,t={target:ar,actInsideInputWithModifier:!0}){const[n,o]=R.useState(!1),r=R.useRef(!1),i=R.useRef(new Set([])),[s,a]=R.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(l=>typeof l=="string").map(l=>l.replace("+",` +`).replace(` + +`,` ++`).split(` +`)),d=u.reduce((l,f)=>l.concat(...f),[]);return[u,d]}return[[],[]]},[e]);return R.useEffect(()=>{const c=t?.target??ar,u=t?.actInsideInputWithModifier??!0;if(e!==null){const d=h=>{if(r.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!r.current||r.current&&!u)&&wi(h))return!1;const y=ur(h.code,a);if(i.current.add(h[y]),cr(s,i.current,!1)){const w=h.composedPath?.()?.[0]||h.target,x=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(r.current||!x)&&h.preventDefault(),o(!0)}},l=h=>{const p=ur(h.code,a);cr(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(h[p]),h.key==="Meta"&&i.current.clear(),r.current=!1},f=()=>{i.current.clear(),o(!1)};return c?.addEventListener("keydown",d),c?.addEventListener("keyup",l),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c?.removeEventListener("keydown",d),c?.removeEventListener("keyup",l),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function cr(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ur(e,t){return t.includes(e)?"code":"key"}const Vf=()=>{const e=re();return R.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=eo(t,o,r,i,s,n?.padding??.1);return a?(await a.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c},d=n.snapGrid??r,l=n.snapToGrid??i;return _t(u,o,l,d)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Ut(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Bi(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const c of s)Bf(c,a);n.push(a)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Bf(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Fi(e,t){return Bi(e,t)}function Wi(e,t){return Bi(e,t)}function Ae(e,t){return{id:e,type:"select",selected:t}}function Be(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(Ae(i.id,s)))}return o}function lr({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),a=s?.internals?.userNode??s;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:"replace"}),a===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function dr(e){return{id:e.id,type:"remove"}}const fr=e=>ld(e),Ff=e=>di(e);function ji(e){return R.forwardRef(e)}const Wf=typeof window<"u"?R.useLayoutEffect:R.useEffect;function hr(e){const[t,n]=R.useState(BigInt(0)),[o]=R.useState(()=>jf(()=>n(r=>r+BigInt(1))));return Wf(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function jf(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Xi=R.createContext(null);function Xf({children:e}){const t=re(),n=R.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:l,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:p}=t.getState();let y=c;for(const x of a)y=typeof x=="function"?x(y):x;let w=lr({items:y,lookup:f});for(const x of p.values())w=x(w);d&&u(y),w.length>0?l?.(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:x,nodes:b,setNodes:g}=t.getState();x&&g(b)})},[]),o=hr(n),r=R.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:l,edgeLookup:f}=t.getState();let h=c;for(const p of a)h=typeof p=="function"?p(h):p;d?u(h):l&&l(lr({items:h,lookup:f}))},[]),i=hr(r),s=R.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return $.jsx(Xi.Provider,{value:s,children:e})}function Yf(){const e=R.useContext(Xi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Zf=e=>!!e.panZoom;function ao(){const e=Vf(),t=re(),n=Yf(),o=J(Zf),r=R.useMemo(()=>{const i=l=>t.getState().nodeLookup.get(l),s=l=>{n.nodeQueue.push(l)},a=l=>{n.edgeQueue.push(l)},c=l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState(),p=fr(l)?l:f.get(l.id),y=p.parentId?yi(p.position,p.measured,p.parentId,f,h):p.position,w={...p,position:y,width:p.measured?.width??p.width,height:p.measured?.height??p.height};return Ge(w)},u=(l,f,h={replace:!1})=>{s(p=>p.map(y=>{if(y.id===l){const w=typeof f=="function"?f(y):f;return h.replace&&fr(w)?w:{...y,...w}}return y}))},d=(l,f,h={replace:!1})=>{a(p=>p.map(y=>{if(y.id===l){const w=typeof f=="function"?f(y):f;return h.replace&&Ff(w)?w:{...y,...w}}return y}))};return{getNodes:()=>t.getState().nodes.map(l=>({...l})),getNode:l=>i(l)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:l=[]}=t.getState();return l.map(f=>({...f}))},getEdge:l=>t.getState().edgeLookup.get(l),setNodes:s,setEdges:a,addNodes:l=>{const f=Array.isArray(l)?l:[l];n.nodeQueue.push(h=>[...h,...f])},addEdges:l=>{const f=Array.isArray(l)?l:[l];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:l=[],edges:f=[],transform:h}=t.getState(),[p,y,w]=h;return{nodes:l.map(x=>({...x})),edges:f.map(x=>({...x})),viewport:{x:p,y,zoom:w}}},deleteElements:async({nodes:l=[],edges:f=[]})=>{const{nodes:h,edges:p,onNodesDelete:y,onEdgesDelete:w,triggerNodeChanges:x,triggerEdgeChanges:b,onDelete:g,onBeforeDelete:m}=t.getState(),{nodes:S,edges:E}=await gd({nodesToRemove:l,edgesToRemove:f,nodes:h,edges:p,onBeforeDelete:m}),N=E.length>0,P=S.length>0;if(N){const A=E.map(dr);w?.(E),b(A)}if(P){const A=S.map(dr);y?.(S),x(A)}return(P||N)&&g?.({nodes:S,edges:E}),{deletedNodes:S,deletedEdges:E}},getIntersectingNodes:(l,f=!0,h)=>{const p=Lo(l),y=p?l:c(l),w=h!==void 0;return y?(h||t.getState().nodes).filter(x=>{const b=t.getState().nodeLookup.get(x.id);if(b&&!p&&(x.id===l.id||!b.internals.positionAbsolute))return!1;const g=Ge(w?x:b),m=gt(g,y);return f&&m>0||m>=g.width*g.height||m>=y.width*y.height}):[]},isNodeIntersecting:(l,f,h=!0)=>{const y=Lo(l)?l:c(l);if(!y)return!1;const w=gt(y,f);return h&&w>0||w>=f.width*f.height||w>=y.width*y.height},updateNode:u,updateNodeData:(l,f,h={replace:!1})=>{u(l,p=>{const y=typeof f=="function"?f(p):f;return h.replace?{...p,data:y}:{...p,data:{...p.data,...y}}},h)},updateEdge:d,updateEdgeData:(l,f,h={replace:!1})=>{d(l,p=>{const y=typeof f=="function"?f(p):f;return h.replace?{...p,data:y}:{...p,data:{...p.data,...y}}},h)},getNodesBounds:l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return dd(l,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:l,id:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${l}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:l,handleId:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${l?f?`-${l}-${f}`:`-${l}`:""}`)?.values()??[]),fitView:async l=>{const f=t.getState().fitViewResolver??wd();return t.setState({fitViewQueued:!0,fitViewOptions:l,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return R.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const pr=e=>e.selected,qf=typeof window<"u"?window:void 0;function Gf({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:o}=ao(),r=yt(e,{actInsideInputWithModifier:!1}),i=yt(t,{target:qf});R.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();o({nodes:a.filter(pr),edges:s.filter(pr)}),n.setState({nodesSelectionActive:!1})}},[r]),R.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Uf(e){const t=re();R.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=to(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",ye.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const ln={position:"absolute",width:"100%",height:"100%",top:0,left:0},Kf=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Qf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=Te.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:l,zoomActivationKeyCode:f,preventScrolling:h=!0,children:p,noWheelClassName:y,noPanClassName:w,onViewportChange:x,isControlledViewport:b,paneClickDistance:g,selectionOnDrag:m}){const S=re(),E=R.useRef(null),{userSelectionActive:N,lib:P,connectionInProgress:A}=J(Kf,oe),V=yt(f),k=R.useRef();Uf(E);const D=R.useCallback(z=>{x?.({x:z[0],y:z[1],zoom:z[2]}),b||S.setState({transform:z})},[x,b]);return R.useEffect(()=>{if(E.current){k.current=nf({domNode:E.current,minZoom:d,maxZoom:l,translateExtent:u,viewport:c,onDraggingChange:_=>S.setState(I=>I.paneDragging===_?I:{paneDragging:_}),onPanZoomStart:(_,I)=>{const{onViewportChangeStart:M,onMoveStart:T}=S.getState();T?.(_,I),M?.(I)},onPanZoom:(_,I)=>{const{onViewportChange:M,onMove:T}=S.getState();T?.(_,I),M?.(I)},onPanZoomEnd:(_,I)=>{const{onViewportChangeEnd:M,onMoveEnd:T}=S.getState();T?.(_,I),M?.(I)}});const{x:z,y:v,zoom:C}=k.current.getViewport();return S.setState({panZoom:k.current,transform:[z,v,C],domNode:E.current.closest(".react-flow")}),()=>{k.current?.destroy()}}},[]),R.useEffect(()=>{k.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:V,preventScrolling:h,noPanClassName:w,userSelectionActive:N,noWheelClassName:y,lib:P,onTransformChange:D,connectionInProgress:A,selectionOnDrag:m,paneClickDistance:g})},[e,t,n,o,r,i,s,a,V,h,w,N,y,P,D,A,m,g]),$.jsx("div",{className:"react-flow__renderer",ref:E,style:ln,children:p})}const Jf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function eh(){const{userSelectionActive:e,userSelectionRect:t}=J(Jf,oe);return e&&t?$.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Cn=(e,t)=>n=>{n.target===t.current&&e?.(n)},th=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function nh({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pt.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:l,onPaneMouseMove:f,onPaneMouseLeave:h,children:p}){const y=re(),{userSelectionActive:w,elementsSelectable:x,dragging:b,connectionInProgress:g}=J(th,oe),m=x&&(e||w),S=R.useRef(null),E=R.useRef(),N=R.useRef(new Set),P=R.useRef(new Set),A=R.useRef(!1),V=M=>{if(A.current||g){A.current=!1;return}c?.(M),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},k=M=>{if(Array.isArray(o)&&o?.includes(2)){M.preventDefault();return}u?.(M)},D=d?M=>d(M):void 0,z=M=>{A.current&&(M.stopPropagation(),A.current=!1)},v=M=>{const{domNode:T}=y.getState();if(E.current=T?.getBoundingClientRect(),!E.current)return;const H=M.target===S.current;if(!H&&!!M.target.closest(".nokey")||!e||!(i&&H||t)||M.button!==0||!M.isPrimary)return;M.target?.setPointerCapture?.(M.pointerId),A.current=!1;const{x:W,y:F}=he(M.nativeEvent,E.current);y.setState({userSelectionRect:{width:0,height:0,startX:W,startY:F,x:W,y:F}}),H||(M.stopPropagation(),M.preventDefault())},C=M=>{const{userSelectionRect:T,transform:H,nodeLookup:O,edgeLookup:L,connectionLookup:W,triggerNodeChanges:F,triggerEdgeChanges:Z,defaultEdgeOptions:U,resetSelectedElements:Y}=y.getState();if(!E.current||!T)return;const{x:B,y:j}=he(M.nativeEvent,E.current),{startX:Q,startY:K}=T;if(!A.current){const te=t?0:r;if(Math.hypot(B-Q,j-K)<=te)return;Y(),s?.(M)}A.current=!0;const q={startX:Q,startY:K,x:Bte.id)),P.current=new Set;const ne=U?.selectable??!0;for(const te of N.current){const se=W.get(te);if(se)for(const{edgeId:Se}of se.values()){const we=L.get(Se);we&&(we.selectable??ne)&&P.current.add(Se)}}if(!Oo(G,N.current)){const te=Be(O,N.current,!0);F(te)}if(!Oo(ee,P.current)){const te=Be(L,P.current);Z(te)}y.setState({userSelectionRect:q,userSelectionActive:!0,nodesSelectionActive:!1})},_=M=>{M.button===0&&(M.target?.releasePointerCapture?.(M.pointerId),!w&&M.target===S.current&&y.getState().userSelectionRect&&V?.(M),y.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(a?.(M),y.setState({nodesSelectionActive:N.current.size>0})))},I=o===!0||Array.isArray(o)&&o.includes(0);return $.jsxs("div",{className:ie(["react-flow__pane",{draggable:I,dragging:b,selection:e}]),onClick:m?void 0:Cn(V,S),onContextMenu:Cn(k,S),onWheel:Cn(D,S),onPointerEnter:m?void 0:l,onPointerMove:m?C:f,onPointerUp:m?_:void 0,onPointerDownCapture:m?v:void 0,onClickCapture:m?z:void 0,onPointerLeave:h,ref:S,style:ln,children:[p,$.jsx(eh,{})]})}function jn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c?.("012",ye.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Yi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const a=re(),[c,u]=R.useState(!1),d=R.useRef();return R.useEffect(()=>{d.current=Fd({getStoreItems:()=>a.getState(),onNodeMouseDown:l=>{jn({id:l,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),R.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{d.current?.destroy()}},[n,o,t,i,e,r,s]),c}const oh=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Zi(){const e=re();return R.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),l=new Map,f=oh(s),h=r?i[0]:5,p=r?i[1]:5,y=n.direction.x*h*n.factor,w=n.direction.y*p*n.factor;for(const[,x]of u){if(!f(x))continue;let b={x:x.internals.positionAbsolute.x+y,y:x.internals.positionAbsolute.y+w};r&&(b=Et(b,i));const{position:g,positionAbsolute:m}=fi({nodeId:x.id,nextPosition:b,nodeLookup:u,nodeExtent:o,nodeOrigin:d,onError:a});x.position=g,x.internals.positionAbsolute=m,l.set(x.id,x)}c(l)},[])}const co=R.createContext(null),rh=co.Provider;co.Consumer;const qi=()=>R.useContext(co),ih=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),sh=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:a,toHandle:c,isValid:u}=s,d=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:d,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===Ze.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:d&&u}};function ah({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:d,onTouchStart:l,...f},h){const p=s||null,y=e==="target",w=re(),x=qi(),{connectOnClick:b,noPanClassName:g,rfId:m}=J(ih,oe),{connectingFrom:S,connectingTo:E,clickConnecting:N,isPossibleEndHandle:P,connectionInProcess:A,clickConnectionInProcess:V,valid:k}=J(sh(x,p,e),oe);x||w.getState().onError?.("010",ye.error010());const D=C=>{const{defaultEdgeOptions:_,onConnect:I,hasDefaultEdges:M}=w.getState(),T={..._,...C};if(M){const{edges:H,setEdges:O}=w.getState();O(Cd(T,H))}I?.(T),a?.(T)},z=C=>{if(!x)return;const _=vi(C.nativeEvent);if(r&&(_&&C.button===0||!_)){const I=w.getState();Wn.onPointerDown(C.nativeEvent,{handleDomNode:C.currentTarget,autoPanOnConnect:I.autoPanOnConnect,connectionMode:I.connectionMode,connectionRadius:I.connectionRadius,domNode:I.domNode,nodeLookup:I.nodeLookup,lib:I.lib,isTarget:y,handleId:p,nodeId:x,flowId:I.rfId,panBy:I.panBy,cancelConnection:I.cancelConnection,onConnectStart:I.onConnectStart,onConnectEnd:(...M)=>w.getState().onConnectEnd?.(...M),updateConnection:I.updateConnection,onConnect:D,isValidConnection:n||((...M)=>w.getState().isValidConnection?.(...M)??!0),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:I.autoPanSpeed,dragThreshold:I.connectionDragThreshold})}_?d?.(C):l?.(C)},v=C=>{const{onClickConnectStart:_,onClickConnectEnd:I,connectionClickStartHandle:M,connectionMode:T,isValidConnection:H,lib:O,rfId:L,nodeLookup:W,connection:F}=w.getState();if(!x||!M&&!r)return;if(!M){_?.(C.nativeEvent,{nodeId:x,handleId:p,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:x,type:e,id:p}});return}const Z=xi(C.target),U=n||H,{connection:Y,isValid:B}=Wn.isValid(C.nativeEvent,{handle:{nodeId:x,id:p,type:e},connectionMode:T,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:U,flowId:L,doc:Z,lib:O,nodeLookup:W});B&&Y&&D(Y);const j=structuredClone(F);delete j.inProgress,j.toPosition=j.toHandle?j.toHandle.position:null,I?.(C,j),w.setState({connectionClickStartHandle:null})};return $.jsx("div",{"data-handleid":p,"data-nodeid":x,"data-handlepos":t,"data-id":`${m}-${x}-${p}-${e}`,className:ie(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,u,{source:!y,target:y,connectable:o,connectablestart:r,connectableend:i,clickconnecting:N,connectingfrom:S,connectingto:E,valid:k,connectionindicator:o&&(!A||P)&&(A||V?i:r)}]),onMouseDown:z,onTouchStart:z,onClick:b?v:void 0,ref:h,...f,children:c})}const Kt=R.memo(ji(ah));function ch({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return $.jsxs($.Fragment,{children:[e?.label,$.jsx(Kt,{type:"source",position:n,isConnectable:t})]})}function uh({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:o=X.Bottom}){return $.jsxs($.Fragment,{children:[$.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label,$.jsx(Kt,{type:"source",position:o,isConnectable:t})]})}function lh(){return null}function dh({data:e,isConnectable:t,targetPosition:n=X.Top}){return $.jsxs($.Fragment,{children:[$.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label]})}const Qt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gr={input:ch,default:uh,output:dh,group:lh};function fh(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const hh=e=>{const{width:t,height:n,x:o,y:r}=bt(e.nodeLookup,{filter:i=>!!i.selected});return{width:fe(t)?t:null,height:fe(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function ph({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=re(),{width:r,height:i,transformString:s,userSelectionActive:a}=J(hh,oe),c=Zi(),u=R.useRef(null);R.useEffect(()=>{n||u.current?.focus({preventScroll:!0})},[n]);const d=!a&&r!==null&&i!==null;if(Yi({nodeRef:u,disabled:!d}),!d)return null;const l=e?h=>{const p=o.getState().nodes.filter(y=>y.selected);e(h,p)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Qt,h.key)&&(h.preventDefault(),c({direction:Qt[h.key],factor:h.shiftKey?4:1}))};return $.jsx("div",{className:ie(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:$.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:l,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:i}})})}const mr=typeof window<"u"?window:void 0,gh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:l,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:p,panActivationKeyCode:y,zoomActivationKeyCode:w,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:m,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:N,panOnDrag:P,defaultViewport:A,translateExtent:V,minZoom:k,maxZoom:D,preventScrolling:z,onSelectionContextMenu:v,noWheelClassName:C,noPanClassName:_,disableKeyboardA11y:I,onViewportChange:M,isControlledViewport:T}){const{nodesSelectionActive:H,userSelectionActive:O}=J(gh,oe),L=yt(u,{target:mr}),W=yt(y,{target:mr}),F=W||P,Z=W||m,U=d&&F!==!0,Y=L||O||U;return Gf({deleteKeyCode:c,multiSelectionKeyCode:p}),$.jsx(Qf,{onPaneContextMenu:i,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:Z,panOnScrollSpeed:S,panOnScrollMode:E,zoomOnDoubleClick:N,panOnDrag:!L&&F,defaultViewport:A,translateExtent:V,minZoom:k,maxZoom:D,zoomActivationKeyCode:w,preventScrolling:z,noWheelClassName:C,noPanClassName:_,onViewportChange:M,isControlledViewport:T,paneClickDistance:a,selectionOnDrag:U,children:$.jsxs(nh,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:F,isSelecting:!!Y,selectionMode:l,selectionKeyPressed:L,paneClickDistance:a,selectionOnDrag:U,children:[e,H&&$.jsx(ph,{onSelectionContextMenu:v,noPanClassName:_,disableKeyboardA11y:I})]})})}Gi.displayName="FlowRenderer";const mh=R.memo(Gi),yh=e=>t=>e?Jn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function xh(e){return J(R.useCallback(yh(e),[e]),oe)}const wh=e=>e.updateNodeInternals;function vh(){const e=J(wh),[t]=R.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return R.useEffect(()=>()=>{t?.disconnect()},[t]),t}function bh({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=re(),i=R.useRef(null),s=R.useRef(null),a=R.useRef(e.sourcePosition),c=R.useRef(e.targetPosition),u=R.useRef(t),d=n&&!!e.internals.handleBounds;return R.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[d,e.hidden]),R.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),R.useEffect(()=>{if(i.current){const l=u.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(l||f||h)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Eh({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:l,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:p,rfId:y,nodeTypes:w,nodeClickDistance:x,onError:b}){const{node:g,internals:m,isParent:S}=J(B=>{const j=B.nodeLookup.get(e),Q=B.parentLookup.has(e);return{node:j,internals:j.internals,isParent:Q}},oe);let E=g.type||"default",N=w?.[E]||gr[E];N===void 0&&(b?.("003",ye.error003(E)),E="default",N=w?.default||gr.default);const P=!!(g.draggable||a&&typeof g.draggable>"u"),A=!!(g.selectable||c&&typeof g.selectable>"u"),V=!!(g.connectable||u&&typeof g.connectable>"u"),k=!!(g.focusable||d&&typeof g.focusable>"u"),D=re(),z=mi(g),v=bh({node:g,nodeType:E,hasDimensions:z,resizeObserver:l}),C=Yi({nodeRef:v,disabled:g.hidden||!P,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:x}),_=Zi();if(g.hidden)return null;const I=_e(g),M=fh(g),T=A||P||t||n||o||r,H=n?B=>n(B,{...m.userNode}):void 0,O=o?B=>o(B,{...m.userNode}):void 0,L=r?B=>r(B,{...m.userNode}):void 0,W=i?B=>i(B,{...m.userNode}):void 0,F=s?B=>s(B,{...m.userNode}):void 0,Z=B=>{const{selectNodesOnDrag:j,nodeDragThreshold:Q}=D.getState();A&&(!j||!P||Q>0)&&jn({id:e,store:D,nodeRef:v}),t&&t(B,{...m.userNode})},U=B=>{if(!(wi(B.nativeEvent)||p)){if(ai.includes(B.key)&&A){const j=B.key==="Escape";jn({id:e,store:D,unselect:j,nodeRef:v})}else if(P&&g.selected&&Object.prototype.hasOwnProperty.call(Qt,B.key)){B.preventDefault();const{ariaLabelConfig:j}=D.getState();D.setState({ariaLiveMessage:j["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~m.positionAbsolute.x,y:~~m.positionAbsolute.y})}),_({direction:Qt[B.key],factor:B.shiftKey?4:1})}}},Y=()=>{if(p||!v.current?.matches(":focus-visible"))return;const{transform:B,width:j,height:Q,autoPanOnNodeFocus:K,setCenter:q}=D.getState();if(!K)return;Jn(new Map([[e,g]]),{x:0,y:0,width:j,height:Q},B,!0).length>0||q(g.position.x+I.width/2,g.position.y+I.height/2,{zoom:B[2]})};return $.jsx("div",{className:ie(["react-flow__node",`react-flow__node-${E}`,{[h]:P},g.className,{selected:g.selected,selectable:A,parent:S,draggable:P,dragging:C}]),ref:v,style:{zIndex:m.z,transform:`translate(${m.positionAbsolute.x}px,${m.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:z?"visible":"hidden",...g.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:O,onMouseLeave:L,onContextMenu:W,onClick:Z,onDoubleClick:F,onKeyDown:k?U:void 0,tabIndex:k?0:void 0,onFocus:k?Y:void 0,role:g.ariaRole??(k?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${Li}-${y}`,"aria-label":g.ariaLabel,...g.domAttributes,children:$.jsx(rh,{value:e,children:$.jsx(N,{id:e,data:g.data,type:E,positionAbsoluteX:m.positionAbsolute.x,positionAbsoluteY:m.positionAbsolute.y,selected:g.selected??!1,selectable:A,draggable:P,deletable:g.deletable??!0,isConnectable:V,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:C,dragHandle:g.dragHandle,zIndex:m.z,parentId:g.parentId,...I})})})}var _h=R.memo(Eh);const Sh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ui(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=J(Sh,oe),s=xh(e.onlyRenderVisibleElements),a=vh();return $.jsx("div",{className:"react-flow__nodes",style:ln,children:s.map(c=>$.jsx(_h,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}Ui.displayName="NodeRenderer";const Nh=R.memo(Ui);function Ch(e){return J(R.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&_d({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),oe)}const Mh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return $.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},kh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return $.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},yr={[qt.Arrow]:Mh,[qt.ArrowClosed]:kh};function Ih(e){const t=re();return R.useMemo(()=>Object.prototype.hasOwnProperty.call(yr,e)?yr[e]:(t.getState().onError?.("009",ye.error009(e)),null),[e])}const Ah=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Ih(t);return c?$.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:$.jsx(c,{color:n,strokeWidth:s})}):null},Ki=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),o=J(i=>i.defaultEdgeOptions),r=R.useMemo(()=>$d(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?$.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:$.jsx("defs",{children:r.map(i=>$.jsx(Ah,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Ki.displayName="MarkerDefinitions";var $h=R.memo(Ki);function Qi({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...d}){const[l,f]=R.useState({x:1,y:0,width:0,height:0}),h=ie(["react-flow__edge-textwrapper",u]),p=R.useRef(null);return R.useEffect(()=>{if(p.current){const y=p.current.getBBox();f({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?$.jsxs("g",{transform:`translate(${e-l.width/2} ${t-l.height/2})`,className:h,visibility:l.width?"visible":"hidden",...d,children:[r&&$.jsx("rect",{width:l.width+2*s[0],x:-s[0],y:-s[1],height:l.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),$.jsx("text",{className:"react-flow__edge-text",y:l.height/2,dy:"0.3em",ref:p,style:o,children:n}),c]}):null}Qi.displayName="EdgeText";const Ph=R.memo(Qi);function dn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return $.jsxs($.Fragment,{children:[$.jsx("path",{...d,d:e,fill:"none",className:ie(["react-flow__edge-path",d.className])}),u?$.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,o&&fe(t)&&fe(n)?$.jsx(Ph,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function xr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===X.Left||e===X.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function Ji({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top}){const[s,a]=xr({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,u]=xr({pos:i,x1:o,y1:r,x2:e,y2:t}),[d,l,f,h]=bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${o},${r}`,d,l,f,h]}function es(e){return R.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:y,markerStart:w,interactionWidth:x})=>{const[b,g,m]=Ji({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a}),S=e.isInternal?void 0:t;return $.jsx(dn,{id:S,path:b,labelX:g,labelY:m,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:y,markerStart:w,interactionWidth:x})})}const Th=es({isInternal:!1}),ts=es({isInternal:!0});Th.displayName="SimpleBezierEdge";ts.displayName="SimpleBezierEdgeInternal";function ns(e){return R.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,sourcePosition:h=X.Bottom,targetPosition:p=X.Top,markerEnd:y,markerStart:w,pathOptions:x,interactionWidth:b})=>{const[g,m,S]=Vn({sourceX:n,sourceY:o,sourcePosition:h,targetX:r,targetY:i,targetPosition:p,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),E=e.isInternal?void 0:t;return $.jsx(dn,{id:E,path:g,labelX:m,labelY:S,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:y,markerStart:w,interactionWidth:b})})}const os=ns({isInternal:!1}),rs=ns({isInternal:!0});os.displayName="SmoothStepEdge";rs.displayName="SmoothStepEdgeInternal";function is(e){return R.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return $.jsx(os,{...n,id:o,pathOptions:R.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Dh=is({isInternal:!1}),ss=is({isInternal:!0});Dh.displayName="StepEdge";ss.displayName="StepEdgeInternal";function as(e){return R.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:p,interactionWidth:y})=>{const[w,x,b]=Si({sourceX:n,sourceY:o,targetX:r,targetY:i}),g=e.isInternal?void 0:t;return $.jsx(dn,{id:g,path:w,labelX:x,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:p,interactionWidth:y})})}const Rh=as({isInternal:!1}),cs=as({isInternal:!0});Rh.displayName="StraightEdge";cs.displayName="StraightEdgeInternal";function us(e){return R.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=X.Bottom,targetPosition:a=X.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:y,markerStart:w,pathOptions:x,interactionWidth:b})=>{const[g,m,S]=Ei({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:a,curvature:x?.curvature}),E=e.isInternal?void 0:t;return $.jsx(dn,{id:E,path:g,labelX:m,labelY:S,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:y,markerStart:w,interactionWidth:b})})}const zh=us({isInternal:!1}),ls=us({isInternal:!0});zh.displayName="BezierEdge";ls.displayName="BezierEdgeInternal";const wr={default:ls,straight:cs,step:ss,smoothstep:rs,simplebezier:ts},vr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Hh=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,Lh=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,br="react-flow__edgeupdater";function Er({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:a}){return $.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:ie([br,`${br}-${a}`]),cx:Hh(t,o,e),cy:Lh(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Oh({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:l,setReconnecting:f,setUpdateHover:h}){const p=re(),y=(m,S)=>{if(m.button!==0)return;const{autoPanOnConnect:E,domNode:N,connectionMode:P,connectionRadius:A,lib:V,onConnectStart:k,cancelConnection:D,nodeLookup:z,rfId:v,panBy:C,updateConnection:_}=p.getState(),I=S.type==="target",M=(O,L)=>{f(!1),l?.(O,n,S.type,L)},T=O=>u?.(n,O),H=(O,L)=>{f(!0),d?.(m,n,S.type),k?.(O,L)};Wn.onPointerDown(m.nativeEvent,{autoPanOnConnect:E,connectionMode:P,connectionRadius:A,domNode:N,handleId:S.id,nodeId:S.nodeId,nodeLookup:z,isTarget:I,edgeUpdaterType:S.type,lib:V,flowId:v,cancelConnection:D,panBy:C,isValidConnection:(...O)=>p.getState().isValidConnection?.(...O)??!0,onConnect:T,onConnectStart:H,onConnectEnd:(...O)=>p.getState().onConnectEnd?.(...O),onReconnectEnd:M,updateConnection:_,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.getState().connectionDragThreshold,handleDomNode:m.currentTarget})},w=m=>y(m,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=m=>y(m,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),g=()=>h(!1);return $.jsxs($.Fragment,{children:[(e===!0||e==="source")&&$.jsx(Er,{position:a,centerX:o,centerY:r,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&$.jsx(Er,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:g,type:"target"})]})}function Vh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,rfId:p,edgeTypes:y,noPanClassName:w,onError:x,disableKeyboardA11y:b}){let g=J(q=>q.edgeLookup.get(e));const m=J(q=>q.defaultEdgeOptions);g=m?{...m,...g}:g;let S=g.type||"default",E=y?.[S]||wr[S];E===void 0&&(x?.("011",ye.error011(S)),S="default",E=y?.default||wr.default);const N=!!(g.focusable||t&&typeof g.focusable>"u"),P=typeof l<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),A=!!(g.selectable||o&&typeof g.selectable>"u"),V=R.useRef(null),[k,D]=R.useState(!1),[z,v]=R.useState(!1),C=re(),{zIndex:_,sourceX:I,sourceY:M,targetX:T,targetY:H,sourcePosition:O,targetPosition:L}=J(R.useCallback(q=>{const G=q.nodeLookup.get(g.source),ee=q.nodeLookup.get(g.target);if(!G||!ee)return{zIndex:g.zIndex,...vr};const ne=Ad({id:e,sourceNode:G,targetNode:ee,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:q.connectionMode,onError:x});return{zIndex:Ed({selected:g.selected,zIndex:g.zIndex,sourceNode:G,targetNode:ee,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...ne||vr}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),oe),W=R.useMemo(()=>g.markerStart?`url('#${Bn(g.markerStart,p)}')`:void 0,[g.markerStart,p]),F=R.useMemo(()=>g.markerEnd?`url('#${Bn(g.markerEnd,p)}')`:void 0,[g.markerEnd,p]);if(g.hidden||I===null||M===null||T===null||H===null)return null;const Z=q=>{const{addSelectedEdges:G,unselectNodesAndEdges:ee,multiSelectionActive:ne}=C.getState();A&&(C.setState({nodesSelectionActive:!1}),g.selected&&ne?(ee({nodes:[],edges:[g]}),V.current?.blur()):G([e])),r&&r(q,g)},U=i?q=>{i(q,{...g})}:void 0,Y=s?q=>{s(q,{...g})}:void 0,B=a?q=>{a(q,{...g})}:void 0,j=c?q=>{c(q,{...g})}:void 0,Q=u?q=>{u(q,{...g})}:void 0,K=q=>{if(!b&&ai.includes(q.key)&&A){const{unselectNodesAndEdges:G,addSelectedEdges:ee}=C.getState();q.key==="Escape"?(V.current?.blur(),G({edges:[g]})):ee([e])}};return $.jsx("svg",{style:{zIndex:_},children:$.jsxs("g",{className:ie(["react-flow__edge",`react-flow__edge-${S}`,g.className,w,{selected:g.selected,animated:g.animated,inactive:!A&&!r,updating:k,selectable:A}]),onClick:Z,onDoubleClick:U,onContextMenu:Y,onMouseEnter:B,onMouseMove:j,onMouseLeave:Q,onKeyDown:N?K:void 0,tabIndex:N?0:void 0,role:g.ariaRole??(N?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":N?`${Oi}-${p}`:void 0,ref:V,...g.domAttributes,children:[!z&&$.jsx(E,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:A,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:I,sourceY:M,targetX:T,targetY:H,sourcePosition:O,targetPosition:L,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:W,markerEnd:F,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),P&&$.jsx(Oh,{edge:g,isReconnectable:P,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,sourceX:I,sourceY:M,targetX:T,targetY:H,sourcePosition:O,targetPosition:L,setUpdateHover:D,setReconnecting:v})]})})}var Bh=R.memo(Vh);const Fh=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ds({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:l,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,disableKeyboardA11y:y}){const{edgesFocusable:w,edgesReconnectable:x,elementsSelectable:b,onError:g}=J(Fh,oe),m=Ch(t);return $.jsxs("div",{className:"react-flow__edges",children:[$.jsx($h,{defaultColor:e,rfId:n}),m.map(S=>$.jsx(Bh,{id:S,edgesFocusable:w,edgesReconnectable:x,elementsSelectable:b,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:l,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,rfId:n,onError:g,edgeTypes:o,disableKeyboardA11y:y},S))]})}ds.displayName="EdgeRenderer";const Wh=R.memo(ds),jh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Xh({children:e}){const t=J(jh);return $.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Yh(e){const t=ao(),n=R.useRef(!1);R.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Zh=e=>e.panZoom?.syncViewport;function qh(e){const t=J(Zh),n=re();return R.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Gh(e){return e.connection.inProgress?{...e.connection,to:_t(e.connection.to,e.transform)}:{...e.connection}}function Uh(e){return Gh}function Kh(e){const t=Uh();return J(t,oe)}const Qh=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Jh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:a,inProgress:c}=J(Qh,oe);return!(i&&r&&c)?null:$.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:$.jsx("g",{className:ie(["react-flow__connection",li(a)]),children:$.jsx(fs,{style:t,type:n,CustomComponent:o,isValid:a})})})}const fs=({style:e,type:t=Me.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:d,toHandle:l,toPosition:f,pointer:h}=Kh();if(!r)return;if(n)return $.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:li(o),toNode:d,toHandle:l,pointer:h});let p="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Me.Bezier:[p]=Ei(y);break;case Me.SimpleBezier:[p]=Ji(y);break;case Me.Step:[p]=Vn({...y,borderRadius:0});break;case Me.SmoothStep:[p]=Vn(y);break;default:[p]=Si(y)}return $.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};fs.displayName="ConnectionLine";const ep={};function _r(e=ep){R.useRef(e),re(),R.useEffect(()=>{},[e])}function tp(){re(),R.useRef(!1),R.useEffect(()=>{},[])}function hs({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:l,onSelectionStart:f,onSelectionEnd:h,connectionLineType:p,connectionLineStyle:y,connectionLineComponent:w,connectionLineContainerStyle:x,selectionKeyCode:b,selectionOnDrag:g,selectionMode:m,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:N,deleteKeyCode:P,onlyRenderVisibleElements:A,elementsSelectable:V,defaultViewport:k,translateExtent:D,minZoom:z,maxZoom:v,preventScrolling:C,defaultMarkerColor:_,zoomOnScroll:I,zoomOnPinch:M,panOnScroll:T,panOnScrollSpeed:H,panOnScrollMode:O,zoomOnDoubleClick:L,panOnDrag:W,onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:U,onPaneMouseLeave:Y,onPaneScroll:B,onPaneContextMenu:j,paneClickDistance:Q,nodeClickDistance:K,onEdgeContextMenu:q,onEdgeMouseEnter:G,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,noDragClassName:Ie,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,nodeExtent:fn,rfId:St,viewport:Le,onViewportChange:tt}){return _r(e),_r(t),tp(),Yh(n),qh(Le),$.jsx(mh,{onPaneClick:F,onPaneMouseEnter:Z,onPaneMouseMove:U,onPaneMouseLeave:Y,onPaneContextMenu:j,onPaneScroll:B,paneClickDistance:Q,deleteKeyCode:P,selectionKeyCode:b,selectionOnDrag:g,selectionMode:m,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:N,elementsSelectable:V,zoomOnScroll:I,zoomOnPinch:M,zoomOnDoubleClick:L,panOnScroll:T,panOnScrollSpeed:H,panOnScrollMode:O,panOnDrag:W,defaultViewport:k,translateExtent:D,minZoom:z,maxZoom:v,onSelectionContextMenu:l,preventScrolling:C,noDragClassName:Ie,noWheelClassName:Qe,noPanClassName:Je,disableKeyboardA11y:et,onViewportChange:tt,isControlledViewport:!!Le,children:$.jsxs(Xh,{children:[$.jsx(Wh,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:se,onReconnectStart:Se,onReconnectEnd:we,onlyRenderVisibleElements:A,onEdgeContextMenu:q,onEdgeMouseEnter:G,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:_,noPanClassName:Je,disableKeyboardA11y:et,rfId:St}),$.jsx(Jh,{style:y,type:p,component:w,containerStyle:x}),$.jsx("div",{className:"react-flow__edgelabel-renderer"}),$.jsx(Nh,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:K,onlyRenderVisibleElements:A,noPanClassName:Je,noDragClassName:Ie,disableKeyboardA11y:et,nodeExtent:fn,rfId:St}),$.jsx("div",{className:"react-flow__viewport-portal"})]})})}hs.displayName="GraphView";const np=R.memo(hs),Sr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:l,zIndexMode:f="basic"}={})=>{const h=new Map,p=new Map,y=new Map,w=new Map,x=o??t??[],b=n??e??[],g=d??[0,0],m=l??ht;Mi(y,w,x);const S=Fn(b,h,p,{nodeOrigin:g,nodeExtent:m,zIndexMode:f});let E=[0,0,1];if(s&&r&&i){const N=bt(h,{filter:k=>!!((k.width||k.initialWidth)&&(k.height||k.initialHeight))}),{x:P,y:A,zoom:V}=eo(N,r,i,c,u,a?.padding??.1);E=[P,A,V]}return{rfId:"1",width:r??0,height:i??0,transform:E,nodes:b,nodesInitialized:S,nodeLookup:h,parentLookup:p,edges:x,edgeLookup:w,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ht,nodeExtent:m,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ze.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ui},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:md,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ci,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},op=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f})=>bf((h,p)=>{async function y(){const{nodeLookup:w,panZoom:x,fitViewOptions:b,fitViewResolver:g,width:m,height:S,minZoom:E,maxZoom:N}=p();x&&(await pd({nodes:w,width:m,height:S,panZoom:x,minZoom:E,maxZoom:N},b),g?.resolve(!0),h({fitViewResolver:null}))}return{...Sr({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:w=>{const{nodeLookup:x,parentLookup:b,nodeOrigin:g,elevateNodesOnSelect:m,fitViewQueued:S,zIndexMode:E}=p(),N=Fn(w,x,b,{nodeOrigin:g,nodeExtent:l,elevateNodesOnSelect:m,checkEquality:!0,zIndexMode:E});S&&N?(y(),h({nodes:w,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0})):h({nodes:w,nodesInitialized:N})},setEdges:w=>{const{connectionLookup:x,edgeLookup:b}=p();Mi(x,b,w),h({edges:w})},setDefaultNodesAndEdges:(w,x)=>{if(w){const{setNodes:b}=p();b(w),h({hasDefaultNodes:!0})}if(x){const{setEdges:b}=p();b(x),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:x,nodeLookup:b,parentLookup:g,domNode:m,nodeOrigin:S,nodeExtent:E,debug:N,fitViewQueued:P,zIndexMode:A}=p(),{changes:V,updatedInternals:k}=Ld(w,b,g,m,S,E,A);k&&(Dd(b,g,{nodeOrigin:S,nodeExtent:E,zIndexMode:A}),P?(y(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),V?.length>0&&(N&&console.log("React Flow: trigger node changes",V),x?.(V)))},updateNodePositions:(w,x=!1)=>{const b=[];let g=[];const{nodeLookup:m,triggerNodeChanges:S,connection:E,updateConnection:N,onNodesChangeMiddlewareMap:P}=p();for(const[A,V]of w){const k=m.get(A),D=!!(k?.expandParent&&k?.parentId&&V?.position),z={id:A,type:"position",position:D?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:x};if(k&&E.inProgress&&E.fromNode.id===k.id){const v=He(k,E.fromHandle,X.Left,!0);N({...E,from:v})}D&&k.parentId&&b.push({id:A,parentId:k.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),g.push(z)}if(b.length>0){const{parentLookup:A,nodeOrigin:V}=p(),k=so(b,m,A,V);g.push(...k)}for(const A of P.values())g=A(g);S(g)},triggerNodeChanges:w=>{const{onNodesChange:x,setNodes:b,nodes:g,hasDefaultNodes:m,debug:S}=p();if(w?.length){if(m){const E=Fi(w,g);b(E)}S&&console.log("React Flow: trigger node changes",w),x?.(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:x,setEdges:b,edges:g,hasDefaultEdges:m,debug:S}=p();if(w?.length){if(m){const E=Wi(w,g);b(E)}S&&console.log("React Flow: trigger edge changes",w),x?.(w)}},addSelectedNodes:w=>{const{multiSelectionActive:x,edgeLookup:b,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:S}=p();if(x){const E=w.map(N=>Ae(N,!0));m(E);return}m(Be(g,new Set([...w]),!0)),S(Be(b))},addSelectedEdges:w=>{const{multiSelectionActive:x,edgeLookup:b,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:S}=p();if(x){const E=w.map(N=>Ae(N,!0));S(E);return}S(Be(b,new Set([...w]))),m(Be(g,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:x}={})=>{const{edges:b,nodes:g,nodeLookup:m,triggerNodeChanges:S,triggerEdgeChanges:E}=p(),N=w||g,P=x||b,A=[];for(const k of N){if(!k.selected)continue;const D=m.get(k.id);D&&(D.selected=!1),A.push(Ae(k.id,!1))}const V=[];for(const k of P)k.selected&&V.push(Ae(k.id,!1));S(A),E(V)},setMinZoom:w=>{const{panZoom:x,maxZoom:b}=p();x?.setScaleExtent([w,b]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:x,minZoom:b}=p();x?.setScaleExtent([b,w]),h({maxZoom:w})},setTranslateExtent:w=>{p().panZoom?.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:x,triggerNodeChanges:b,triggerEdgeChanges:g,elementsSelectable:m}=p();if(!m)return;const S=x.reduce((N,P)=>P.selected?[...N,Ae(P.id,!1)]:N,[]),E=w.reduce((N,P)=>P.selected?[...N,Ae(P.id,!1)]:N,[]);b(S),g(E)},setNodeExtent:w=>{const{nodes:x,nodeLookup:b,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:S,nodeExtent:E,zIndexMode:N}=p();w[0][0]===E[0][0]&&w[0][1]===E[0][1]&&w[1][0]===E[1][0]&&w[1][1]===E[1][1]||(Fn(x,b,g,{nodeOrigin:m,nodeExtent:w,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:N}),h({nodeExtent:w}))},panBy:w=>{const{transform:x,width:b,height:g,panZoom:m,translateExtent:S}=p();return Od({delta:w,panZoom:m,transform:x,translateExtent:S,width:b,height:g})},setCenter:async(w,x,b)=>{const{width:g,height:m,maxZoom:S,panZoom:E}=p();if(!E)return Promise.resolve(!1);const N=typeof b?.zoom<"u"?b.zoom:S;return await E.setViewport({x:g/2-w*N,y:m/2-x*N,zoom:N},{duration:b?.duration,ease:b?.ease,interpolate:b?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...ui}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...Sr()})}},Object.is);function rp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f,children:h}){const[p]=R.useState(()=>op({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:d,nodeExtent:l,zIndexMode:f}));return $.jsx(Ef,{value:p,children:$.jsx(Xf,{children:h})})}function ip({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h}){return R.useContext(cn)?$.jsx($.Fragment,{children:e}):$.jsx(rp,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h,children:e})}const sp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ap({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:l,onMoveEnd:f,onConnect:h,onConnectStart:p,onConnectEnd:y,onClickConnectStart:w,onClickConnectEnd:x,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:S,onNodeDoubleClick:E,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:A,onNodesDelete:V,onEdgesDelete:k,onDelete:D,onSelectionChange:z,onSelectionDragStart:v,onSelectionDrag:C,onSelectionDragStop:_,onSelectionContextMenu:I,onSelectionStart:M,onSelectionEnd:T,onBeforeDelete:H,connectionMode:O,connectionLineType:L=Me.Bezier,connectionLineStyle:W,connectionLineComponent:F,connectionLineContainerStyle:Z,deleteKeyCode:U="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:B=!1,selectionMode:j=pt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:K=mt()?"Meta":"Control",zoomActivationKeyCode:q=mt()?"Meta":"Control",snapToGrid:G,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:Ie,nodeOrigin:Qe=Vi,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:fn=!0,defaultViewport:St=Rf,minZoom:Le=.5,maxZoom:tt=2,translateExtent:uo=ht,preventScrolling:ws=!0,nodeExtent:hn,defaultMarkerColor:vs="#b1b1b7",zoomOnScroll:bs=!0,zoomOnPinch:Es=!0,panOnScroll:_s=!1,panOnScrollSpeed:Ss=.5,panOnScrollMode:Ns=Te.Free,zoomOnDoubleClick:Cs=!0,panOnDrag:Ms=!0,onPaneClick:ks,onPaneMouseEnter:Is,onPaneMouseMove:As,onPaneMouseLeave:$s,onPaneScroll:Ps,onPaneContextMenu:Ts,paneClickDistance:Ds=1,nodeClickDistance:Rs=0,children:zs,onReconnect:Hs,onReconnectStart:Ls,onReconnectEnd:Os,onEdgeContextMenu:Vs,onEdgeDoubleClick:Bs,onEdgeMouseEnter:Fs,onEdgeMouseMove:Ws,onEdgeMouseLeave:js,reconnectRadius:Xs=10,onNodesChange:Ys,onEdgesChange:Zs,noDragClassName:qs="nodrag",noWheelClassName:Gs="nowheel",noPanClassName:lo="nopan",fitView:fo,fitViewOptions:ho,connectOnClick:Us,attributionPosition:Ks,proOptions:Qs,defaultEdgeOptions:Js,elevateNodesOnSelect:ea=!0,elevateEdgesOnSelect:ta=!1,disableKeyboardA11y:po=!1,autoPanOnConnect:na,autoPanOnNodeDrag:oa,autoPanSpeed:ra,connectionRadius:ia,isValidConnection:sa,onError:aa,style:ca,id:go,nodeDragThreshold:ua,connectionDragThreshold:la,viewport:da,onViewportChange:fa,width:ha,height:pa,colorMode:ga="light",debug:ma,onScroll:mo,ariaLabelConfig:ya,zIndexMode:yo="basic",...xa},wa){const pn=go||"1",va=Of(ga),ba=R.useCallback(xo=>{xo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),mo?.(xo)},[mo]);return $.jsx("div",{"data-testid":"rf__wrapper",...xa,onScroll:ba,style:{...ca,...sp},ref:wa,className:ie(["react-flow",r,va]),id:go,role:"application",children:$.jsxs(ip,{nodes:e,edges:t,width:ha,height:pa,fitView:fo,fitViewOptions:ho,minZoom:Le,maxZoom:tt,nodeOrigin:Qe,nodeExtent:hn,zIndexMode:yo,children:[$.jsx(np,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:S,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:s,connectionLineType:L,connectionLineStyle:W,connectionLineComponent:F,connectionLineContainerStyle:Z,selectionKeyCode:Y,selectionOnDrag:B,selectionMode:j,deleteKeyCode:U,multiSelectionKeyCode:K,panActivationKeyCode:Q,zoomActivationKeyCode:q,onlyRenderVisibleElements:ne,defaultViewport:St,translateExtent:uo,minZoom:Le,maxZoom:tt,preventScrolling:ws,zoomOnScroll:bs,zoomOnPinch:Es,zoomOnDoubleClick:Cs,panOnScroll:_s,panOnScrollSpeed:Ss,panOnScrollMode:Ns,panOnDrag:Ms,onPaneClick:ks,onPaneMouseEnter:Is,onPaneMouseMove:As,onPaneMouseLeave:$s,onPaneScroll:Ps,onPaneContextMenu:Ts,paneClickDistance:Ds,nodeClickDistance:Rs,onSelectionContextMenu:I,onSelectionStart:M,onSelectionEnd:T,onReconnect:Hs,onReconnectStart:Ls,onReconnectEnd:Os,onEdgeContextMenu:Vs,onEdgeDoubleClick:Bs,onEdgeMouseEnter:Fs,onEdgeMouseMove:Ws,onEdgeMouseLeave:js,reconnectRadius:Xs,defaultMarkerColor:vs,noDragClassName:qs,noWheelClassName:Gs,noPanClassName:lo,rfId:pn,disableKeyboardA11y:po,nodeExtent:hn,viewport:da,onViewportChange:fa}),$.jsx(Lf,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:h,onConnectStart:p,onConnectEnd:y,onClickConnectStart:w,onClickConnectEnd:x,nodesDraggable:se,autoPanOnNodeFocus:Se,nodesConnectable:we,nodesFocusable:Ie,edgesFocusable:Je,edgesReconnectable:et,elementsSelectable:fn,elevateNodesOnSelect:ea,elevateEdgesOnSelect:ta,minZoom:Le,maxZoom:tt,nodeExtent:hn,onNodesChange:Ys,onEdgesChange:Zs,snapToGrid:G,snapGrid:ee,connectionMode:O,translateExtent:uo,connectOnClick:Us,defaultEdgeOptions:Js,fitView:fo,fitViewOptions:ho,onNodesDelete:V,onEdgesDelete:k,onDelete:D,onNodeDragStart:N,onNodeDrag:P,onNodeDragStop:A,onSelectionDrag:C,onSelectionDragStart:v,onSelectionDragStop:_,onMove:d,onMoveStart:l,onMoveEnd:f,noPanClassName:lo,nodeOrigin:Qe,rfId:pn,autoPanOnConnect:na,autoPanOnNodeDrag:oa,autoPanSpeed:ra,onError:aa,connectionRadius:ia,isValidConnection:sa,selectNodesOnDrag:te,nodeDragThreshold:ua,connectionDragThreshold:la,onBeforeDelete:H,debug:ma,ariaLabelConfig:ya,zIndexMode:yo}),$.jsx(Df,{onSelectionChange:z}),zs,$.jsx(If,{proOptions:Qs,position:Ks}),$.jsx(kf,{rfId:pn,disableKeyboardA11y:po})]})})}var tg=ji(ap);function ng(e){const[t,n]=R.useState(e),o=R.useCallback(r=>n(i=>Fi(r,i)),[]);return[t,n,o]}function og(e){const[t,n]=R.useState(e),o=R.useCallback(r=>n(i=>Wi(r,i)),[]);return[t,n,o]}function cp({dimensions:e,lineWidth:t,variant:n,className:o}){return $.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ie(["react-flow__background-pattern",n,o])})}function up({radius:e,className:t}){return $.jsx("circle",{cx:e,cy:e,r:e,className:ie(["react-flow__background-pattern","dots",t])})}var ke;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ke||(ke={}));const lp={[ke.Dots]:1,[ke.Lines]:1,[ke.Cross]:6},dp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ps({id:e,variant:t=ke.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:a,style:c,className:u,patternClassName:d}){const l=R.useRef(null),{transform:f,patternId:h}=J(dp,oe),p=o||lp[t],y=t===ke.Dots,w=t===ke.Cross,x=Array.isArray(n)?n:[n,n],b=[x[0]*f[2]||1,x[1]*f[2]||1],g=p*f[2],m=Array.isArray(i)?i:[i,i],S=w?[g,g]:b,E=[m[0]*f[2]||1+S[0]/2,m[1]*f[2]||1+S[1]/2],N=`${h}${e||""}`;return $.jsxs("svg",{className:ie(["react-flow__background",u]),style:{...c,...ln,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:l,"data-testid":"rf__background",children:[$.jsx("pattern",{id:N,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:y?$.jsx(up,{radius:g/2,className:d}):$.jsx(cp,{dimensions:S,lineWidth:r,variant:t,className:d})}),$.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${N})`})]})}ps.displayName="Background";const rg=R.memo(ps);function fp(){return $.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:$.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function hp(){return $.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:$.jsx("path",{d:"M0 0h32v4.2H0z"})})}function pp(){return $.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:$.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function gp(){return $.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:$.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function mp(){return $.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:$.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Dt({children:e,className:t,...n}){return $.jsx("button",{type:"button",className:ie(["react-flow__controls-button",t]),...n,children:e})}const yp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function gs({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:d,position:l="bottom-left",orientation:f="vertical","aria-label":h}){const p=re(),{isInteractive:y,minZoomReached:w,maxZoomReached:x,ariaLabelConfig:b}=J(yp,oe),{zoomIn:g,zoomOut:m,fitView:S}=ao(),E=()=>{g(),i?.()},N=()=>{m(),s?.()},P=()=>{S(r),a?.()},A=()=>{p.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c?.(!y)},V=f==="horizontal"?"horizontal":"vertical";return $.jsxs(un,{className:ie(["react-flow__controls",V,u]),position:l,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&$.jsxs($.Fragment,{children:[$.jsx(Dt,{onClick:E,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:x,children:$.jsx(fp,{})}),$.jsx(Dt,{onClick:N,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:$.jsx(hp,{})})]}),n&&$.jsx(Dt,{className:"react-flow__controls-fitview",onClick:P,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:$.jsx(pp,{})}),o&&$.jsx(Dt,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:y?$.jsx(mp,{}):$.jsx(gp,{})}),d]})}gs.displayName="Controls";const ig=R.memo(gs);function xp({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:d,shapeRendering:l,selected:f,onClick:h}){const{background:p,backgroundColor:y}=i||{},w=s||p||y;return $.jsx("rect",{className:ie(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:d,ry:d,width:o,height:r,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:l,onClick:h?x=>h(x,e):void 0})}const wp=R.memo(xp),vp=e=>e.nodes.map(t=>t.id),Mn=e=>e instanceof Function?e:()=>e;function bp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=wp,onClick:s}){const a=J(vp,oe),c=Mn(t),u=Mn(e),d=Mn(n),l=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return $.jsx($.Fragment,{children:a.map(f=>$.jsx(_p,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:l},f))})}function Ep({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:d,y:l,width:f,height:h}=J(p=>{const y=p.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const w=y.internals.userNode,{x,y:b}=y.internals.positionAbsolute,{width:g,height:m}=_e(w);return{node:w,x,y:b,width:g,height:m}},oe);return!u||u.hidden||!mi(u)?null:$.jsx(a,{x:d,y:l,width:f,height:h,style:u.style,selected:!!u.selected,className:o(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:c,id:u.id})}const _p=R.memo(Ep);var Sp=R.memo(bp);const Np=200,Cp=150,Mp=e=>!e.hidden,kp=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?gi(bt(e.nodeLookup,{filter:Mp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Ip="react-flow__minimap-desc";function ms({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:l,position:f="bottom-right",onClick:h,onNodeClick:p,pannable:y=!1,zoomable:w=!1,ariaLabel:x,inversePan:b,zoomStep:g=1,offsetScale:m=5}){const S=re(),E=R.useRef(null),{boundingRect:N,viewBB:P,rfId:A,panZoom:V,translateExtent:k,flowWidth:D,flowHeight:z,ariaLabelConfig:v}=J(kp,oe),C=e?.width??Np,_=e?.height??Cp,I=N.width/C,M=N.height/_,T=Math.max(I,M),H=T*C,O=T*_,L=m*T,W=N.x-(H-N.width)/2-L,F=N.y-(O-N.height)/2-L,Z=H+L*2,U=O+L*2,Y=`${Ip}-${A}`,B=R.useRef(0),j=R.useRef();B.current=T,R.useEffect(()=>{if(E.current&&V)return j.current=qd({domNode:E.current,panZoom:V,getTransform:()=>S.getState().transform,getViewScale:()=>B.current}),()=>{j.current?.destroy()}},[V]),R.useEffect(()=>{j.current?.update({translateExtent:k,width:D,height:z,inversePan:b,pannable:y,zoomStep:g,zoomable:w})},[y,w,b,g,k,D,z]);const Q=h?G=>{const[ee,ne]=j.current?.pointer(G)||[0,0];h(G,{x:ee,y:ne})}:void 0,K=p?R.useCallback((G,ee)=>{const ne=S.getState().nodeLookup.get(ee).internals.userNode;p(G,ne)},[]):void 0,q=x??v["minimap.ariaLabel"];return $.jsx(un,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof l=="number"?l*T:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:ie(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:$.jsxs("svg",{width:C,height:_,viewBox:`${W} ${F} ${Z} ${U}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:E,onClick:Q,children:[q&&$.jsx("title",{id:Y,children:q}),$.jsx(Sp,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),$.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-L},${F-L}h${Z+L*2}v${U+L*2}h${-Z-L*2}z + M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ms.displayName="MiniMap";const sg=R.memo(ms),Ap=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,$p={[Ke.Line]:"right",[Ke.Handle]:"bottom-right"};function Pp({nodeId:e,position:t,variant:n=Ke.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:f,autoScale:h=!0,shouldResize:p,onResizeStart:y,onResize:w,onResizeEnd:x}){const b=qi(),g=typeof e=="string"?e:b,m=re(),S=R.useRef(null),E=n===Ke.Handle,N=J(R.useCallback(Ap(E&&h),[E,h]),oe),P=R.useRef(null),A=t??$p[n];R.useEffect(()=>{if(!(!S.current||!g))return P.current||(P.current=uf({domNode:S.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:k,transform:D,snapGrid:z,snapToGrid:v,nodeOrigin:C,domNode:_}=m.getState();return{nodeLookup:k,transform:D,snapGrid:z,snapToGrid:v,nodeOrigin:C,paneDomNode:_}},onChange:(k,D)=>{const{triggerNodeChanges:z,nodeLookup:v,parentLookup:C,nodeOrigin:_}=m.getState(),I=[],M={x:k.x,y:k.y},T=v.get(g);if(T&&T.expandParent&&T.parentId){const H=T.origin??_,O=k.width??T.measured.width??0,L=k.height??T.measured.height??0,W={id:T.id,parentId:T.parentId,rect:{width:O,height:L,...yi({x:k.x??T.position.x,y:k.y??T.position.y},{width:O,height:L},T.parentId,v,H)}},F=so([W],v,C,_);I.push(...F),M.x=k.x?Math.max(H[0]*O,k.x):void 0,M.y=k.y?Math.max(H[1]*L,k.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:g,type:"position",position:{...M}};I.push(H)}if(k.width!==void 0&&k.height!==void 0){const O={id:g,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:k.width,height:k.height}};I.push(O)}for(const H of D){const O={...H,type:"position"};I.push(O)}z(I)},onEnd:({width:k,height:D})=>{const z={id:g,type:"dimensions",resizing:!1,dimensions:{width:k,height:D}};m.getState().triggerNodeChanges([z])}})),P.current.update({controlPosition:A,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:l,resizeDirection:f,onResizeStart:y,onResize:w,onResizeEnd:x,shouldResize:p}),()=>{P.current?.destroy()}},[A,a,c,u,d,l,y,w,x,p]);const V=A.split("-");return $.jsx("div",{className:ie(["react-flow__resize-control","nodrag",...V,n,o]),ref:S,style:{...r,scale:N,...s&&{[E?"backgroundColor":"borderColor"]:s}},children:i})}R.memo(Pp);const Tp=["off","on","auto"],Dp=["16:9","9:16","1:1","4:3","3:4"],Rp=["","5s","10s"],zp=["","720p","1080p"],Hp=["mp3","opus","aac","flac","wav"],je={textInput:{type:"textInput",label:"Input",description:"Static text provided by the user. Starting point of a workflow.",input:"none",output:"text",params:[{name:"inputText",type:"text",description:"The text value.",required:!0,default:""}]},output:{type:"output",label:"Output",description:"Displays whatever its upstream node produced. Accepts any kind.",input:"text",output:"none",params:[]},chat:{type:"chat",label:"LLM",description:"Run a Venice chat completion. Accepts upstream text as context.",input:"text",output:"text",params:[{name:"model",type:"string",description:"Venice chat model id.",required:!0,default:"llama-3.3-70b"},{name:"prompt",type:"text",description:"Instruction. Use {{input}} to position upstream text, or leave empty to append.",required:!0,default:""},{name:"temperature",type:"number",description:"Sampling temperature.",default:.7,min:0,max:2},{name:"maxTokens",type:"number",description:"Max output tokens.",default:4096,min:64,max:32768},{name:"webSearch",type:"enum",description:"Enable Venice web search.",default:"off",enumValues:Tp}]},imageGen:{type:"imageGen",label:"Image Gen",description:"Generate an image from a text prompt.",input:"text",output:"image",params:[{name:"model",type:"string",description:"Venice image model id.",required:!0,default:"z-image-turbo"},{name:"prompt",type:"text",description:"Image prompt. Use {{input}} to position upstream text.",required:!0,default:""},{name:"negativePrompt",type:"string",description:"What to avoid.",default:""},{name:"steps",type:"number",description:"Denoising steps.",default:20,min:1,max:50},{name:"width",type:"number",description:"Image width in pixels.",default:1024,min:256,max:2048},{name:"height",type:"number",description:"Image height in pixels.",default:1024,min:256,max:2048},{name:"style",type:"string",description:"Style preset name.",default:""},{name:"hideWatermark",type:"boolean",description:"Omit watermark if allowed.",default:!0}]},tts:{type:"tts",label:"Text to Speech",description:"Narrate text into speech audio.",input:"text",output:"audio",params:[{name:"model",type:"string",description:"TTS model id.",required:!0,default:"tts-kokoro"},{name:"prompt",type:"text",description:"Text to speak. Use {{input}} to position upstream text.",default:""},{name:"voice",type:"string",description:"Voice id.",default:"af_sky"},{name:"speed",type:"number",description:"Playback speed.",default:1,min:.25,max:4},{name:"responseFormat",type:"enum",description:"Audio format.",default:"mp3",enumValues:Hp}]},music:{type:"music",label:"Music Gen",description:"Generate a music clip from a text prompt.",input:"text",output:"audio",params:[{name:"model",type:"string",description:"Music model id.",required:!0,default:"stable-audio"},{name:"prompt",type:"text",description:"Music prompt.",required:!0,default:""},{name:"duration",type:"number",description:"Duration in seconds.",default:30,min:5,max:120},{name:"instrumental",type:"boolean",description:"Force instrumental.",default:!1},{name:"lyrics",type:"text",description:"Optional lyrics.",default:""}]},video:{type:"video",label:"Video Gen",description:"Generate a short video from a text prompt.",input:"text",output:"video",params:[{name:"model",type:"string",description:"Video model id.",required:!0,default:"wan-2.1"},{name:"prompt",type:"text",description:"Video prompt.",required:!0,default:""},{name:"videoAspectRatio",type:"enum",description:"Aspect ratio.",default:"16:9",enumValues:Dp},{name:"videoDuration",type:"enum",description:"Clip duration. Empty means model default.",default:"",enumValues:Rp},{name:"videoResolution",type:"enum",description:"Resolution. Empty means model default.",default:"",enumValues:zp}]},step:{type:"step",label:"Step",description:"A Gitea Actions step as it is (run, uses, with, env). Does nothing in the browser: it passes upstream text through. On export it is this step, verbatim, in the workflow file.",input:"text",output:"text",params:[{name:"run",type:"text",description:"Shell to run on the runner.",default:""},{name:"uses",type:"string",description:"An action to use instead of run, e.g. actions/checkout@v5.",default:""}]},compose:{type:"compose",label:"Cover + Track",description:"Combines an upstream image and an upstream audio clip into one video file: the image stays on screen while the audio plays. Connect exactly one image node (imageGen) and one audio node (music or tts) to it. Recorded in the browser in real time (a 60s track takes 60s). No model, no prompt.",input:"text",output:"video",params:[{name:"maxSide",type:"number",description:"Longest side of the video in pixels; the cover keeps its aspect ratio.",default:1080,min:256,max:2048}]}};function Lp(e,t){return e!=="none"&&t!=="none"}function Op(e,t){return e==="none"||t==="none"?!1:t==="text"?!0:e===t}const kn=280,ys=180,Rt=60,xs=60;function Vp(e){const t=je[e],n={label:t?.label??e,nodeType:e,model:"",prompt:""};for(const o of t?.params??[])o.default!==void 0&&(n[o.name]=o.default);return n}function Bp(e,t){if(e.length===0)return e;const n=new Map,o=new Map;for(const l of e)n.set(l.id,0),o.set(l.id,[]);for(const l of t)!n.has(l.source)||!n.has(l.target)||(o.get(l.source).push(l.target),n.set(l.target,(n.get(l.target)??0)+1));const r=new Map,i=e.filter(l=>(n.get(l.id)??0)===0).map(l=>l.id);for(const l of i)r.set(l,0);const s=new Map(n);for(;i.length>0;){const l=i.shift(),f=r.get(l)??0;for(const h of o.get(l)??[]){r.set(h,Math.max(r.get(h)??0,f+1));const p=(s.get(h)??1)-1;s.set(h,p),p===0&&i.push(h)}}for(const l of e)r.has(l.id)||r.set(l.id,0);const a=new Map;for(const l of e){const f=r.get(l.id)??0;a.has(f)||a.set(f,[]),a.get(f).push(l.id)}const u=Math.max(...Array.from(a.values()).map(l=>l.length))*(kn+Rt),d=new Map;for(const[l,f]of a){const h=f.length*(kn+Rt)-Rt,p=(u-h)/2;f.forEach((y,w)=>{d.set(y,{x:p+w*(kn+Rt),y:40+l*(ys+xs)})})}return e.map(l=>({...l,position:d.get(l.id)??l.position}))}function Fp(e){return{x:280,y:40+e.length*(ys+xs)}}function Wp(e,t){const{nodes:n,edges:o}=e;switch(t.op){case"add_node":{if(!je[t.nodeType])throw new Error(`Unknown node type: ${t.nodeType}`);const r=t.id??An();if(n.some(c=>c.id===r))throw new Error(`Node id already exists: ${r}`);const i=t.position??Fp(n),s={...Vp(t.nodeType),...t.params??{}},a={id:r,type:"venice",position:i,data:s};return{nodes:[...n,a],edges:o,addedNodeId:r}}case"remove_node":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.filter(r=>r.id!==t.id),edges:o.filter(r=>r.source!==t.id&&r.target!==t.id)}}case"set_params":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.map(r=>r.id===t.id?{...r,data:{...r.data,...t.params}}:r),edges:o}}case"move_node":{if(!n.some(r=>r.id===t.id))throw new Error(`Node not found: ${t.id}`);return{nodes:n.map(r=>r.id===t.id?{...r,position:t.position}:r),edges:o}}case"connect":{if(!n.some(s=>s.id===t.source))throw new Error(`Source node not found: ${t.source}`);if(!n.some(s=>s.id===t.target))throw new Error(`Target node not found: ${t.target}`);if(t.source===t.target)throw new Error("Cannot connect a node to itself.");const r=t.id??`e-${t.source}-${t.target}-${An().slice(0,6)}`;if(o.some(s=>s.id===r))throw new Error(`Edge id already exists: ${r}`);const i={id:r,source:t.source,target:t.target,animated:!0};return{nodes:n,edges:[...o,i],addedEdgeId:r}}case"disconnect":{if(!o.some(r=>r.id===t.id))throw new Error(`Edge not found: ${t.id}`);return{nodes:n,edges:o.filter(r=>r.id!==t.id)}}case"clear":return{nodes:[],edges:[]}}}function jp(e,t){let n=e,o,r;for(const s of t){const a=Wp(n,s);n={nodes:a.nodes,edges:a.edges},a.addedNodeId&&(o=a.addedNodeId),a.addedEdgeId&&(r=a.addedEdgeId)}return{nodes:Bp(n.nodes,n.edges),edges:n.edges,addedNodeId:o,addedEdgeId:r}}const ag=Na()(Ca((e,t)=>({workflows:[],activeWorkflowId:null,runResults:{},isRunning:!1,createWorkflow:n=>{const o=An(),r={id:o,name:n,nodes:[],edges:[],createdAt:Date.now()};return e(i=>({workflows:[r,...i.workflows],activeWorkflowId:o})),o},updateWorkflow:(n,o)=>e(r=>({workflows:r.workflows.map(i=>i.id===n?{...i,...o}:i)})),deleteWorkflow:n=>e(o=>({workflows:o.workflows.filter(r=>r.id!==n),activeWorkflowId:o.activeWorkflowId===n?null:o.activeWorkflowId})),setActiveWorkflow:n=>e({activeWorkflowId:n}),setRunResults:n=>e({runResults:n}),updateNodeResult:(n,o)=>e(r=>({runResults:{...r.runResults,[n]:{...r.runResults[n],...o}}})),setIsRunning:n=>e({isRunning:n}),clearResults:()=>e({runResults:{}}),applyPatches:(n,o)=>{const r=t().workflows.find(s=>s.id===n);if(!r)throw new Error(`Workflow not found: ${n}`);const i=jp({nodes:r.nodes,edges:r.edges},o);return e(s=>({workflows:s.workflows.map(a=>a.id===n?{...a,nodes:i.nodes,edges:i.edges}:a)})),i}}),{name:"venice-workflows",version:1,storage:Ma(()=>ka()),partialize:e=>({workflows:e.workflows.slice(0,20),activeWorkflowId:e.activeWorkflowId})}));function Xp(e,t){const n=new Map;for(const c of e)n.set(c.id,[]);for(const c of t)n.get(c.source)?.push(c.target);const o=0,r=1,i=2,s=new Map;for(const c of e)s.set(c.id,o);const a=c=>{s.set(c,r);for(const u of n.get(c)??[]){const d=s.get(u);if(d===r||d===o&&a(u))return!0}return s.set(c,i),!1};for(const c of e)if(s.get(c.id)===o&&a(c.id))return!0;return!1}function Nr(e,t){const n=e[t];return n==null?!0:typeof n=="string"?n.trim()==="":!1}function Yp({nodes:e,edges:t}){const n=[],o=[],r=new Set(e.map(i=>i.id));e.length===0&&o.push({severity:"warning",message:"Workflow is empty."});for(const i of e){const s=je[i.data?.nodeType];if(!s){n.push({severity:"error",nodeId:i.id,message:`Unknown node type: ${String(i.data?.nodeType)}`});continue}for(const a of s.params)if(a.required&&Nr(i.data,a.name)){const c=s.input!=="none"&&t.some(d=>d.target===i.id);(a.name==="prompt"||a.name==="inputText")&&c||n.push({severity:"error",nodeId:i.id,message:`${s.label}: missing required "${a.name}".`})}if(s.input==="none"){const a=t.filter(c=>c.target===i.id);for(const c of a)n.push({severity:"error",edgeId:c.id,message:`${s.label} does not accept inputs.`})}else t.filter(c=>c.target===i.id).length===0&&s.type!=="output"&&(!s.params.some(u=>u.name==="prompt"&&u.required)||Nr(i.data,"prompt"))&&o.push({severity:"warning",nodeId:i.id,message:`${s.label}: no upstream input connected.`});if(s.output==="none"){const a=t.filter(c=>c.source===i.id);for(const c of a)n.push({severity:"error",edgeId:c.id,message:`${s.label} has no output and cannot feed another node.`})}}for(const i of t){if(!r.has(i.source)){n.push({severity:"error",edgeId:i.id,message:`Edge source ${i.source} does not exist.`});continue}if(!r.has(i.target)){n.push({severity:"error",edgeId:i.id,message:`Edge target ${i.target} does not exist.`});continue}if(i.source===i.target){n.push({severity:"error",edgeId:i.id,message:"Self-loops are not allowed."});continue}const s=e.find(d=>d.id===i.source),a=e.find(d=>d.id===i.target);if(!s||!a)continue;const c=je[s.data.nodeType],u=je[a.data.nodeType];!c||!u||(Lp(c.output,u.input)?Op(c.output,u.input)||o.push({severity:"warning",edgeId:i.id,message:`${c.label} outputs ${c.output}; ${u.label} expects ${u.input}. Conversion may be lossy.`}):n.push({severity:"error",edgeId:i.id,message:`${c.label} (${c.output}) cannot connect to ${u.label} (${u.input}).`}))}return Xp(e,t)&&n.push({severity:"error",message:"Workflow contains a cycle."}),{ok:n.length===0,errors:n,warnings:o}}const Zp=['video/mp4;codecs="avc1.42E01E,mp4a.40.2"',"video/mp4;codecs=avc1,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"];function qp(){if(typeof MediaRecorder>"u")return"";for(const e of Zp)try{if(MediaRecorder.isTypeSupported(e))return e}catch{}return""}function Gp(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>n(new Error("Could not load the cover image")),o.src=e})}function Cr(e){return Math.max(2,Math.round(e/2)*2)}async function Up(e,t,n={}){if(typeof MediaRecorder>"u"||!("captureStream"in HTMLCanvasElement.prototype))throw new Error("This browser cannot record video (no MediaRecorder)");const o=qp();if(!o)throw new Error("This browser has no video format MediaRecorder can write");const{signal:r,onProgress:i}=n,s=n.fps??24,a=n.maxSide??1080,[c,u]=await Promise.all([Gp(e),fetch(t,{signal:r}).then(V=>{if(!V.ok)throw new Error(`Could not fetch the track (${V.status})`);return V.arrayBuffer()})]);if(r?.aborted)throw new DOMException("Aborted","AbortError");const d=Math.min(1,a/Math.max(c.naturalWidth,c.naturalHeight)),l=document.createElement("canvas");l.width=Cr(c.naturalWidth*d),l.height=Cr(c.naturalHeight*d);const f=l.getContext("2d");if(!f)throw new Error("No 2d canvas");const h=()=>f.drawImage(c,0,0,l.width,l.height);h();const p=new AudioContext;try{await p.resume()}catch{}const y=await p.decodeAudioData(u),w=y.duration,x=p.createMediaStreamDestination(),b=p.createBufferSource();b.buffer=y,b.connect(x);const g=new MediaStream([...l.captureStream(s).getVideoTracks(),...x.stream.getAudioTracks()]),m=new MediaRecorder(g,{mimeType:o,videoBitsPerSecond:25e5,audioBitsPerSecond:16e4}),S=[];m.ondataavailable=V=>{V.data.size>0&&S.push(V.data)};const E=window.setInterval(h,1e3/Math.min(s,10)),N=performance.now(),P=window.setInterval(()=>i?.(Math.min(w,(performance.now()-N)/1e3),w),1e3),A=()=>{window.clearInterval(E),window.clearInterval(P),g.getTracks().forEach(V=>V.stop()),p.close().catch(()=>{})};return new Promise((V,k)=>{let D=!1;const z=()=>{if(D)return;if(D=!0,A(),r?.aborted){k(new DOMException("Aborted","AbortError"));return}const v=new Blob(S,{type:o.split(";")[0]});if(v.size===0){k(new Error("Recording produced no data"));return}V(URL.createObjectURL(v))};m.onstop=z,m.onerror=()=>{A(),k(new Error("Recording failed"))},b.onended=()=>{window.setTimeout(()=>{m.state!=="inactive"&&m.stop()},250)},r?.addEventListener("abort",()=>{try{b.stop()}catch{}m.state!=="inactive"?m.stop():z()},{once:!0}),m.start(1e3),b.start()})}const Mr=3e3,kr=200;class In extends Error{nodeId;constructor(t,n){super(t),this.name="WorkflowExecutionError",this.nodeId=n}}function Kp(e,t){const n=new Map,o=new Map;for(const a of e)n.set(a.id,0),o.set(a.id,[]);for(const a of t)!n.has(a.source)||!n.has(a.target)||(o.get(a.source).push(a.target),n.set(a.target,(n.get(a.target)??0)+1));const r=[];let i=e.filter(a=>(n.get(a.id)??0)===0).map(a=>a.id),s=0;for(;i.length>0;){r.push(i),s+=i.length;const a=[];for(const c of i)for(const u of o.get(c)??[]){const d=(n.get(u)??1)-1;n.set(u,d),d===0&&a.push(u)}i=a}return s===e.length?r:null}function Qp(e,t,n){return t.filter(i=>i.target===e).map(i=>n.get(i.source)??"").filter(Boolean).join(` + +`)}function rt(e,t){return e?e.includes("{{input}}")?e.replace(/\{\{input\}\}/g,t):t?`${e} + +${t}`:e:t}async function Ir(e,t,n,o,r){for(let i=0;i{const u=setTimeout(a,Mr);r?.addEventListener("abort",()=>{clearTimeout(u),c(new DOMException("Aborted","AbortError"))},{once:!0})});const s=await Aa(e,t,n,{downloadUrl:o,signal:r});if(s.state==="done")return s.url;if(s.state==="failed")throw new Error(s.error)}throw new Error(`Generation timed out after ${kr*Mr/1e3}s`)}async function Jp(e,t,n){const o=e.data;switch(o.nodeType){case"textInput":return o.inputText??"";case"compose":{const r=/\[image:([^\]]+)\]/.exec(t)?.[1],i=/\[audio:([^\]]+)\]/.exec(t)?.[1];if(!r||!i){const a=[r&&"an image",i&&"audio"].filter(Boolean).join(" and ")||"neither";throw new Error(`Cover + Track needs one image node and one audio node connected to it (got ${a})`)}return`[video:${await Up(r,i,{maxSide:o.maxSide??1080,signal:n})}]`}case"output":return t;case"step":return t;case"chat":{const r=rt(o.prompt,t);return(await Nt("/chat/completions",{method:"POST",body:JSON.stringify({model:o.model||"llama-3.3-70b",messages:[{role:"user",content:r}],temperature:o.temperature??.7,max_tokens:o.maxTokens??4096,venice_parameters:{enable_web_search:o.webSearch??"off"}}),signal:n})).choices[0]?.message?.content??""}case"imageGen":{const r=rt(o.prompt,t),i={model:o.model||"z-image-turbo",prompt:r,negative_prompt:o.negativePrompt||void 0,steps:o.steps??20,style_preset:o.style||void 0,width:o.width??1024,height:o.height??1024,hide_watermark:o.hideWatermark??!0};o.aspectRatio&&(i.aspect_ratio=o.aspectRatio);const a=(await Nt("/image/generate",{method:"POST",body:JSON.stringify(i),signal:n})).images[0],c=typeof a=="string"?a:a.b64_json;return`[image:data:${c.startsWith("/9j/")?"image/jpeg":c.startsWith("iVBOR")?"image/png":c.startsWith("UklGR")?"image/webp":"image/png"};base64,${c}]`}case"tts":{const r=rt(o.prompt,t),i=await Ia("/audio/speech",{model:o.model||"tts-kokoro",input:r,voice:o.voice||"af_sky",speed:o.speed??1,response_format:o.responseFormat||"mp3"},{signal:n});return`[audio:${URL.createObjectURL(i)}]`}case"music":{const r=rt(o.prompt,t),i={model:o.model||"stable-audio-25",prompt:r,duration_seconds:o.duration??30,force_instrumental:o.instrumental??!1};o.lyrics&&(i.lyrics_prompt=o.lyrics);const s=await Nt("/audio/queue",{method:"POST",body:JSON.stringify(i),signal:n});return`[audio:${await Ir("audio",s.model||String(i.model),s.queue_id,s.download_url,n)}]`}case"video":{const r=rt(o.prompt,t),i={model:o.model||"wan-3-0-text-to-video",prompt:r,aspect_ratio:o.videoAspectRatio||"16:9"};o.videoDuration&&(i.duration=o.videoDuration),o.videoResolution&&(i.resolution=o.videoResolution);const s=await Nt("/video/queue",{method:"POST",body:JSON.stringify(i),signal:n});return`[video:${await Ir("video",s.model||String(i.model),s.queue_id||s.id||"",s.download_url,n)}]`}}}async function cg(e,t,n){const o=typeof n=="function"?{onUpdate:n}:n,{signal:r,onUpdate:i}=o,s=Yp({nodes:e,edges:t});if(!s.ok){const d=s.errors[0];throw new In(d?.message??"Workflow has validation errors.",d?.nodeId)}const a=Kp(e,t);if(!a)throw new In("Workflow contains a cycle.");const c=new Map,u=new Map(e.map(d=>[d.id,d]));for(const d of a){if(r?.aborted)return;await Promise.all(d.map(async l=>{const f=u.get(l);if(f){i(l,{status:"running",output:void 0,error:void 0});try{const h=Qp(l,t,c),p=await Jp(f,h,r);c.set(l,p);const y=je[f.data.nodeType]?.output;i(l,{status:"done",output:p,outputKind:y&&y!=="none"?y:void 0})}catch(h){if(h instanceof DOMException&&h.name==="AbortError")throw i(l,{status:"error",error:"Cancelled"}),h;const p=h instanceof Error?h.message:"Unknown error";throw i(l,{status:"error",error:p}),new In(p,l)}}}))}}export{rg as B,ig as C,Kt as H,sg as M,je as N,X as P,rp as R,ao as a,ng as b,og as c,Cd as d,ke as e,cg as f,jp as g,Wp as h,tg as i,ag as u,Yp as v}; diff --git a/ventures/havre/open/assets/workflows-view-C9DNDVch.js b/ventures/havre/open/assets/workflows-view-C9DNDVch.js new file mode 100644 index 0000000..86a5de3 --- /dev/null +++ b/ventures/havre/open/assets/workflows-view-C9DNDVch.js @@ -0,0 +1,38 @@ +import{r as w,j as e,c as v,u as Q,S as X,t as $,g as V}from"./index-fmJ2VqHZ.js";import{u as C,a as Y,H as M,P as A,N as F,R as Z,b as ee,c as te,d as oe,i as ne,B as se,e as re,C as ie,M as ae,f as le}from"./workflow-engine-BuXGtBGn.js";function ce(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"22 12 16 12 14 15 10 9 8 12 2 12"})})}function de(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})})}function pe(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}function ue(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})}function he(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function xe(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"23 7 16 12 23 17 23 7"}),e.jsx("rect",{x:"1",y:"5",width:"15",height:"14",rx:"2"})]})}function me(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 15l5-5 4 4"}),e.jsx("path",{d:"M14 17v-5l4-1v5"}),e.jsx("circle",{cx:"12.5",cy:"17.5",r:"1.5"}),e.jsx("circle",{cx:"16.5",cy:"16.5",r:"1.5"})]})}function ge(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function fe(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]})}const we={textInput:void 0,output:void 0,chat:"text",imageGen:"image",tts:"tts",music:"music",video:"video",compose:void 0,step:void 0},be={textInput:{label:"Input",Icon:ce,color:"border-blue-500/30",hasInput:!1,hasOutput:!0},chat:{label:"LLM",Icon:de,color:"border-purple-500/30",hasInput:!0,hasOutput:!0},imageGen:{label:"Image Gen",Icon:pe,color:"border-pink-500/30",hasInput:!0,hasOutput:!0},tts:{label:"Text to Speech",Icon:ue,color:"border-green-500/30",hasInput:!0,hasOutput:!0},music:{label:"Music Gen",Icon:he,color:"border-yellow-500/30",hasInput:!0,hasOutput:!0},video:{label:"Video Gen",Icon:xe,color:"border-orange-500/30",hasInput:!0,hasOutput:!0},compose:{label:"Cover + Track",Icon:me,color:"border-cyan-500/30",hasInput:!0,hasOutput:!0},step:{label:"Step",Icon:ge,color:"border-white/20",hasInput:!0,hasOutput:!0},output:{label:"Output",Icon:fe,color:"border-white/20",hasInput:!0,hasOutput:!1}},f="nodrag bg-white/[0.03] border border-white/[0.06] rounded px-1.5 py-0.5 text-[12px] text-white/40 outline-none",N="nodrag w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1 text-[13px] text-white/60 outline-none placeholder:text-white/15";function ve({nodeType:n,value:t,onChange:r}){const s=we[n],{data:c}=Q(s),a=c?.map(i=>({value:i.id,label:i.model_spec?.name||i.id}))??[];return e.jsx("div",{className:"nodrag",children:e.jsx(X,{value:t,onChange:r,options:a,searchable:!0,placeholder:"Select model...",className:"w-full [&_button]:!py-1 [&_button]:!text-[13px] [&_button]:!px-2"})})}function je({id:n,data:t}){const r=be[t.nodeType],s=C(o=>o.runResults[n]),{setNodes:c}=Y(),[a,i]=w.useState(!1),l=w.useCallback(o=>{c(p=>p.map(h=>h.id===n?{...h,data:{...h.data,...o}}:h))},[n,c]),d=w.useCallback(()=>{c(o=>o.filter(p=>p.id!==n))},[n,c]);return e.jsxs("div",{className:v("rounded-xl border-2 bg-[#111] shadow-xl min-w-[300px] max-w-[340px]",r.color,s?.status==="running"&&"ring-2 ring-white/20 animate-pulse",s?.status==="done"&&"ring-2 ring-green-500/30",s?.status==="error"&&"ring-2 ring-red-500/30"),children:[r.hasInput&&e.jsx(M,{type:"target",position:A.Top,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/[0.06]",children:[e.jsx("span",{className:"text-white/30",children:e.jsx(r.Icon,{})}),e.jsx("span",{className:"text-[14px] font-medium text-white/60",children:t.nodeType==="step"&&t.label&&t.label!=="Step"?t.label:r.label}),s?.status==="running"&&e.jsx("span",{className:"text-[12px] text-white/30 ml-auto mr-1",children:"Running..."}),s?.status==="done"&&e.jsx("span",{className:"text-[12px] text-green-400/60 ml-auto mr-1",children:"Done"}),s?.status==="error"&&e.jsx("span",{className:"text-[12px] text-red-400/60 ml-auto mr-1",children:"Error"}),!s?.status&&e.jsx("span",{className:"ml-auto"}),e.jsx("button",{onClick:d,className:"nodrag text-white/10 hover:text-red-400/60 transition-colors p-0.5",title:"Delete node",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-1.5",children:[t.nodeType==="output"?s?.status==="done"&&s.output?e.jsx("div",{className:"min-h-[60px]",children:s.output.startsWith("[audio:")?e.jsx("audio",{src:s.output.slice(7,-1),controls:!0,className:"w-full h-8"}):s.output.startsWith("[video:")?e.jsx("video",{src:s.output.slice(7,-1),controls:!0,playsInline:!0,className:"nodrag w-full rounded-lg border border-white/[0.06]",onClick:o=>o.stopPropagation()}):s.output.startsWith("[image:")?e.jsx("img",{src:s.output.slice(7,-1),alt:"Generated",className:"w-full rounded-lg border border-white/[0.06]"}):e.jsx("p",{className:v("text-[14px] text-white/60 leading-relaxed whitespace-pre-wrap",!a&&"line-clamp-8"),onClick:()=>i(!a),children:s.output})}):s?.status==="running"?e.jsx("div",{className:"min-h-[40px] flex items-center justify-center",children:e.jsx("span",{className:"text-[13px] text-white/20",children:"Waiting for input..."})}):s?.status==="error"?e.jsx("p",{className:"text-[13px] text-red-400/60",children:s.error}):e.jsx("div",{className:"min-h-[40px] flex items-center justify-center",children:e.jsx("span",{className:"text-[13px] text-white/10",children:"Run workflow to see output"})}):t.nodeType==="step"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("input",{value:t.label==="Step"?"":t.label,onChange:o=>l({label:o.target.value||"Step",stepYaml:""}),placeholder:"name (optional)",className:N}),e.jsx("input",{value:t.uses??"",onChange:o=>l({uses:o.target.value,stepYaml:""}),placeholder:"uses: owner/action@v1 (optional)",className:N}),e.jsx("textarea",{value:t.run??"",onChange:o=>l({run:o.target.value,stepYaml:""}),placeholder:"run: shell for the runner",rows:3,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[13px] font-mono text-white/70 outline-none resize-none placeholder:text-white/15"}),(t.with||t.stepEnv)&&e.jsx("pre",{className:"nodrag nowheel text-[12px] font-mono text-white/40 whitespace-pre-wrap max-h-24 overflow-auto",children:[t.with&&`with: +`+t.with,t.stepEnv&&`env: +`+t.stepEnv].filter(Boolean).join(` +`)}),e.jsx("p",{className:"text-[12px] text-white/30 leading-snug",children:"Runs on the factory, not here: on export this is the step as written."})]}):t.nodeType==="compose"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-[13px] text-white/40 leading-snug",children:"Shows the connected image while the connected audio plays, recorded here in your browser into one video (takes as long as the track)."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[12px] text-white/30",children:"max side"}),e.jsx("input",{type:"number",min:256,max:2048,step:2,value:t.maxSide??1080,onChange:o=>l({maxSide:Number(o.target.value)||1080}),className:v(N,"w-24")}),e.jsx("span",{className:"text-[12px] text-white/30",children:"px"})]})]}):t.nodeType==="textInput"?e.jsx("textarea",{value:t.inputText??"",onChange:o=>l({inputText:o.target.value}),placeholder:"Enter starting text...",rows:3,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{nodeType:t.nodeType,value:t.model,onChange:o=>l({model:o})}),e.jsx("textarea",{value:t.prompt,onChange:o=>l({prompt:o.target.value}),placeholder:"Instructions for this step...",rows:2,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}),t.nodeType==="chat"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("select",{value:t.webSearch??"off",onChange:o=>l({webSearch:o.target.value}),className:f,children:[e.jsx("option",{value:"off",children:"Search off"}),e.jsx("option",{value:"on",children:"Search on"}),e.jsx("option",{value:"auto",children:"Search auto"})]}),e.jsx("input",{type:"number",value:t.temperature??.7,onChange:o=>l({temperature:parseFloat(o.target.value)}),step:.1,min:0,max:2,className:v(f,"w-14"),title:"Temperature"}),e.jsx("input",{type:"number",value:t.maxTokens??4096,onChange:o=>l({maxTokens:parseInt(o.target.value)}),step:256,min:64,max:32768,className:v(f,"w-[72px]"),title:"Max tokens"})]}),t.nodeType==="imageGen"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:t.negativePrompt??"",onChange:o=>l({negativePrompt:o.target.value}),placeholder:"Negative prompt...",className:N}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Steps"}),e.jsx("input",{type:"number",value:t.steps??20,onChange:o=>l({steps:parseInt(o.target.value)}),min:1,max:50,className:f+" w-full"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Size"}),e.jsxs("select",{value:`${t.width??1024}x${t.height??1024}`,onChange:o=>{const[p,h]=o.target.value.split("x").map(Number);l({width:p,height:h})},className:f+" w-full",children:[e.jsx("option",{value:"512x512",children:"512"}),e.jsx("option",{value:"768x768",children:"768"}),e.jsx("option",{value:"1024x1024",children:"1024"}),e.jsx("option",{value:"1280x1280",children:"1280"})]})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{value:t.style??"",onChange:o=>l({style:o.target.value}),placeholder:"Style preset...",className:v(N,"flex-1")}),e.jsxs("label",{className:"nodrag flex items-center gap-1 text-[12px] text-white/30 cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.hideWatermark??!0,onChange:o=>l({hideWatermark:o.target.checked}),className:"nodrag w-3 h-3 accent-white/50"}),"No WM"]})]})]}),t.nodeType==="tts"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-[80px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Voice"}),e.jsx("input",{value:t.voice??"af_sky",onChange:o=>l({voice:o.target.value}),placeholder:"Voice ID",className:N})]}),e.jsxs("div",{className:"w-14",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Speed"}),e.jsx("input",{type:"number",value:t.speed??1,onChange:o=>l({speed:parseFloat(o.target.value)}),step:.25,min:.25,max:4,className:f+" w-full"})]}),e.jsxs("div",{className:"w-16",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Format"}),e.jsxs("select",{value:t.responseFormat??"mp3",onChange:o=>l({responseFormat:o.target.value}),className:f+" w-full",children:[e.jsx("option",{value:"mp3",children:"MP3"}),e.jsx("option",{value:"opus",children:"Opus"}),e.jsx("option",{value:"aac",children:"AAC"}),e.jsx("option",{value:"flac",children:"FLAC"}),e.jsx("option",{value:"wav",children:"WAV"})]})]})]}),t.nodeType==="music"&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:t.lyrics??"",onChange:o=>l({lyrics:o.target.value}),placeholder:"Lyrics (optional)...",rows:2,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}),e.jsxs("div",{className:"flex gap-1.5 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Duration (s)"}),e.jsx("input",{type:"number",value:t.duration??30,onChange:o=>l({duration:parseInt(o.target.value)}),min:5,max:120,step:5,className:f+" w-full"})]}),e.jsxs("label",{className:"nodrag flex items-center gap-1 text-[12px] text-white/30 cursor-pointer pb-0.5",children:[e.jsx("input",{type:"checkbox",checked:t.instrumental??!1,onChange:o=>l({instrumental:o.target.checked}),className:"nodrag w-3 h-3 accent-white/50"}),"Instrumental"]})]})]}),t.nodeType==="video"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Aspect"}),e.jsxs("select",{value:t.videoAspectRatio??"16:9",onChange:o=>l({videoAspectRatio:o.target.value}),className:f+" w-full",children:[e.jsx("option",{value:"16:9",children:"16:9"}),e.jsx("option",{value:"9:16",children:"9:16"}),e.jsx("option",{value:"1:1",children:"1:1"}),e.jsx("option",{value:"4:3",children:"4:3"}),e.jsx("option",{value:"3:4",children:"3:4"})]})]}),e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Duration"}),e.jsxs("select",{value:t.videoDuration??"",onChange:o=>l({videoDuration:o.target.value}),className:f+" w-full",children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"5s",children:"5s"}),e.jsx("option",{value:"10s",children:"10s"})]})]}),e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Resolution"}),e.jsxs("select",{value:t.videoResolution??"",onChange:o=>l({videoResolution:o.target.value}),className:f+" w-full",children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"720p",children:"720p"}),e.jsx("option",{value:"1080p",children:"1080p"})]})]})]})]}),t.nodeType!=="output"&&s?.status==="done"&&s.output&&e.jsxs("div",{className:"mt-1 p-2 rounded-lg bg-green-500/[0.04] border border-green-500/[0.08] cursor-pointer",onClick:()=>i(!a),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",className:"text-green-400/40",children:e.jsx("polyline",{points:a?"18 15 12 9 6 15":"6 9 12 15 18 9"})}),e.jsx("span",{className:"text-[11px] text-green-400/40 uppercase tracking-wider font-medium",children:"Output"})]}),s.output.startsWith("[audio:")?e.jsx("audio",{src:s.output.slice(7,-1),controls:!0,className:"w-full h-7",onClick:o=>o.stopPropagation()}):s.output.startsWith("[video:")?e.jsx("video",{src:s.output.slice(7,-1),controls:!0,playsInline:!0,className:"nodrag w-full rounded border border-white/[0.06]",onClick:o=>o.stopPropagation()}):s.output.startsWith("[image:")?e.jsx("img",{src:s.output.slice(7,-1),alt:"Generated",className:"w-full rounded border border-white/[0.06]"}):e.jsx("p",{className:v("text-[13px] text-white/50 leading-relaxed whitespace-pre-wrap",!a&&"line-clamp-3"),children:s.output})]}),t.nodeType!=="output"&&s?.status==="error"&&e.jsxs("div",{className:"mt-1 p-2 rounded-lg bg-red-500/[0.04] border border-red-500/[0.08]",children:[e.jsx("span",{className:"text-[11px] text-red-400/40 uppercase tracking-wider font-medium",children:"Error"}),e.jsx("p",{className:"text-[13px] text-red-400/60 mt-0.5",children:s.error})]})]}),r.hasOutput&&e.jsx(M,{type:"source",position:A.Bottom,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"})]})}const ye=w.memo(je),ke="https://havre.yolopreneur.lol/open/run.mjs",R="801d8b48a8fb046cf7de5c19cc190557011f8afc8a1af4f17d56ddef04ebd958",E="OV_WORKFLOW",b=n=>JSON.stringify(String(n)),D=n=>(n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"workflow").slice(0,60);function Ne(n){return{name:n.name,nodes:n.nodes.map(t=>({id:t.id,type:t.type,position:t.position,data:t.data})),edges:n.edges.map(t=>({id:t.id,source:t.source,target:t.target})),...n.frame?{frame:n.frame}:{}}}function Ie(n){const t=new Map(n.nodes.map(a=>[a.id,0])),r=new Map(n.nodes.map(a=>[a.id,[]]));for(const a of n.edges)!t.has(a.source)||!t.has(a.target)||(r.get(a.source).push(a.target),t.set(a.target,(t.get(a.target)??0)+1));const s=[];let c=n.nodes.filter(a=>t.get(a.id)===0).map(a=>a.id);for(;c.length;){s.push(...c);const a=[];for(const i of c)for(const l of r.get(i)??[])t.set(l,t.get(l)-1),t.get(l)===0&&a.push(l);c=a}return s.map(a=>n.nodes.find(i=>i.id===a))}const Ce=n=>btoa(String.fromCharCode(...new TextEncoder().encode(n))),Te=n=>new TextDecoder().decode(Uint8Array.from(atob(n.replace(/\s+/g,"")),t=>t.charCodeAt(0))),P=(n,t)=>n.split(` +`).map(r=>r.trim()?" ".repeat(t)+r:r).join(` +`);function _(n){if(n.stepYaml&&n.stepYaml.trim())return n.stepYaml.replace(/\s+$/,"");const t=[];n.label&&n.label!=="Step"&&t.push(`- name: ${b(n.label)}`);const r=t.length?" ":"- ";let s=!t.length;const c=()=>{const i=s?r:" ";return s=!1,i};n.uses&&t.push(`${c()}uses: ${n.uses}`);const a=(n.run??"").replace(/\s+$/,"");a&&(a.includes(` +`)?t.push(`${c()}run: |`,...a.split(` +`).map(i=>i?" "+i:"")):t.push(`${c()}run: ${a}`));for(const[i,l]of[["with",n.with],["env",n.stepEnv]]){const d=(l??"").replace(/\s+$/,"");d&&t.push(`${c()}${i}:`,...d.split(` +`).map(o=>o?" "+o:""))}return t.length||t.push(`- run: ${b(n.label||"step")}`),t.join(` +`)}function W(n){const t=n.split(` +`),r={},s=p=>{const h=new RegExp(`^(?:- | )${p}:\\s*(.*?)\\s*$`,"m").exec(n);if(!h)return;const u=h[1];return/^".*"$/.test(u)?JSON.parse(u):/^'.*'$/.test(u)?u.slice(1,-1).replace(/''/g,"'"):u},c=p=>{const h=t.findIndex(g=>new RegExp(`^(?:- | )${p}:\\s*(\\|[-+]?|>[-+]?)?\\s*$`).test(g));if(h<0)return;const u=[];for(let g=h+1;g/^\s+steps:\s*(#.*)?$/.test(u));if(r<0)return null;let s=r+1;for(;s!/^\s*OV_WORKFLOW:/.test(u)).join(` +`),o=t.slice(l).join(` +`).replace(/\s+$/,""),p=/^name:\s*(.*?)\s*$/m.exec(d),h=p?/^".*"$/.test(p[1])?JSON.parse(p[1]):p[1].replace(/^'|'$/g,""):"";return{frame:{pre:d.replace(/^env:\s*\n(?=\S)/m,""),post:o,indent:a},items:i.map(u=>u.join(` +`).replace(/\s+$/,"")),name:h}}function B(n){const t=["- uses: actions/setup-node@v4"," with:"," node-version: 22"];return n&&t.push("- name: ffmpeg, for Cover + Track"," run: |"," command -v ffmpeg >/dev/null || sudo apt-get install -y -qq ffmpeg >/dev/null || apt-get install -y -qq ffmpeg >/dev/null"),t.push("- name: the runner"," run: |",` curl -fsSLo run.mjs ${b(ke)}`),R.startsWith("__")||t.push(` echo "${R} run.mjs" | sha256sum -c -`),t.push(" mkdir -p out"),t}function G(n,t){const r=F[n.data.nodeType],s=[`- name: ${b(`${n.id} (${r?.label??n.data.nodeType})`)}`];return n.data.nodeType==="textInput"?s.push(" run: |",` printf '%s' "$INPUT" > out/${n.id}.txt && echo "${n.id} = $INPUT"`," env:",` INPUT: \${{ inputs.${n.id} }}`):(s.push(` run: node run.mjs --node ${b(n.id)}`),t&&s.push(" env:"," VENICE_API_KEY: ${{ secrets.VENICE_API_KEY }}")),s}function Le(n){const t=Ie(n),r=t.some(o=>o.data.nodeType==="compose"),s=t.filter(o=>o.data.nodeType==="output"),c=`${E}: ${b(Ce(JSON.stringify(Ne(n))))}`;if(n.frame){let o=n.frame.pre.replace(/\s+$/,"");o=/^env:\s*$/m.test(o)?o.replace(/^env:\s*$/m,`env: + ${c}`):o.replace(/^(jobs:\s*)$/m,`env: + ${c} +$1`),o.includes(E)||(o+=` +env: + ${c}`);const p=[];let h=!1;for(const g of t){if(g.data.nodeType==="step"){p.push(_(g.data));continue}h||(p.push(B(r).join(` +`)),h=!0),p.push(G(g,!0).join(` +`))}s.length&&p.push(["- name: outputs"," run: |",...s.map(g=>` echo "== ${g.id} =="; cat out/${g.id}.txt; echo`)].join(` +`));const u=p.map(g=>P(g,n.frame.indent)).join(` +`);return o+` +`+u+(n.frame.post?` +`+n.frame.post:"")+` +`}const a=t.filter(o=>o.data.nodeType==="textInput"),i=[];if(i.push(`name: ${b(n.name)}`),i.push("# An openvenice workflow, exported from https://havre.yolopreneur.lol/open/ (Workflows → Export)."),i.push(`# Import the file there to edit it on the canvas; the graph rides in env.${E} below.`),i.push("# Runs on the Venice API with the secret VENICE_API_KEY. Outputs land in out/ (and an artifact, where the runner keeps them)."),i.push("on:"),i.push(" workflow_dispatch:"),a.length){i.push(" inputs:");for(const o of a)i.push(` ${o.id}:`),i.push(` description: ${b(`Input "${o.data.label||o.id}"`)}`),i.push(" required: false"),i.push(` default: ${b(o.data.inputText??"")}`)}i.push(" # schedule: # uncomment to run on a timer, e.g. every morning at 8:"),i.push(' # - cron: "0 8 * * *"'),i.push("env:"),i.push(` ${c}`),i.push("jobs:"),i.push(" run:"),i.push(" runs-on: ubuntu-latest"),i.push(" timeout-minutes: 60"),i.push(" env:"),i.push(" VENICE_API_KEY: ${{ secrets.VENICE_API_KEY }}"),i.push(" steps:");const l=[],d=t.some(o=>o.data.nodeType!=="step");d&&l.push(B(r).join(` +`));for(const o of t)l.push(o.data.nodeType==="step"?_(o.data):G(o,!1).join(` +`));return s.length&&l.push(["- name: outputs"," run: |",...s.map(o=>` echo "== ${o.id} =="; cat out/${o.id}.txt; echo`)].join(` +`)),d&&l.push(["- uses: actions/upload-artifact@v4"," if: always()"," continue-on-error: true"," with:",` name: ${b(D(n.name))}`," path: out/"].join(` +`)),i.push(P(l.join(` +`),6)),i.join(` +`)+` +`}function Ee(n){const t=n.trim();let r=null;const s=t.startsWith("{")?null:$e(t);if(t.startsWith("{"))try{r=JSON.parse(t)}catch{return null}else{const o=new RegExp(`^\\s*${E}:\\s*(?:"([^"]+)"|'([^']+)'|(\\S+))\\s*$`,"m").exec(t);if(o)try{r=JSON.parse(Te(o[1]??o[2]??o[3]))}catch{r=null}}if(!r&&s){const o=s.items.map((h,u)=>({id:`step${u+1}`,type:"venice",position:{x:280,y:40+u*180},data:{label:"Step",nodeType:"step",model:"",prompt:"",...W(h),stepYaml:h}})),p=o.slice(1).map((h,u)=>({id:`e${u}-${o[u].id}-${h.id}`,source:o[u].id,target:h.id,animated:!0}));return o.length?{name:s.name||"Imported workflow",nodes:o,edges:p,frame:s.frame}:null}if(!r||typeof r!="object")return null;const c=r;if(!Array.isArray(c.nodes)||!Array.isArray(c.edges))return null;const a=c.nodes.filter(o=>o&&typeof o.id=="string"&&o.data&&typeof o.data=="object"&&typeof o.data.nodeType=="string"&&o.data.nodeType in F).map((o,p)=>({id:o.id,type:"venice",position:o.position&&typeof o.position=="object"?o.position:{x:280,y:40+p*200},data:{...o.data}})),i=new Set(a.map(o=>o.id)),l=c.edges.filter(o=>o&&typeof o.source=="string"&&typeof o.target=="string"&&i.has(o.source)&&i.has(o.target)).map((o,p)=>({id:typeof o.id=="string"?o.id:`e${p}-${o.source}-${o.target}`,source:o.source,target:o.target,animated:!0}));if(!a.length)return null;let d=c.frame&&typeof c.frame=="object"&&typeof c.frame.pre=="string"?c.frame:void 0;if(s&&d){d=s.frame;const o=new Map(s.items.map(p=>[W(p).label??"",p]));for(const p of a){if(p.data.nodeType!=="step")continue;const h=o.get(p.data.label)??(p.data.stepYaml?s.items.find(u=>u.split(` +`)[0]===p.data.stepYaml.split(` +`)[0]):void 0);h&&Object.assign(p.data,W(h),{stepYaml:h})}}return{name:typeof c.name=="string"&&c.name.trim()?c.name.trim():"Imported workflow",nodes:a,edges:l,...d?{frame:d}:{}}}function Se(n,t,r="text/yaml"){const s=document.createElement("a");s.href=URL.createObjectURL(new Blob([t],{type:r})),s.download=n,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),2e3)}const We={venice:ye};function Oe(){return e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"22 12 16 12 14 15 10 9 8 12 2 12"})})}function Me(){return e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})})}function Ae(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}function Re(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 010 7.07"})]})}function Pe(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function _e(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"23 7 16 12 23 17 23 7"}),e.jsx("rect",{x:"1",y:"5",width:"15",height:"14",rx:"2"})]})}function Be(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 15l5-5 4 4"}),e.jsx("path",{d:"M14 17v-5l4-1v5"}),e.jsx("circle",{cx:"12.5",cy:"17.5",r:"1.5"}),e.jsx("circle",{cx:"16.5",cy:"16.5",r:"1.5"})]})}function Ge(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ve(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]})}const Ye=[{type:"textInput",label:"Input",Icon:Oe,color:"text-blue-400/50"},{type:"chat",label:"LLM",Icon:Me,color:"text-purple-400/50"},{type:"imageGen",label:"Image Gen",Icon:Ae,color:"text-pink-400/50"},{type:"tts",label:"Text to Speech",Icon:Re,color:"text-green-400/50"},{type:"music",label:"Music Gen",Icon:Pe,color:"text-yellow-400/50"},{type:"video",label:"Video Gen",Icon:_e,color:"text-orange-400/50"},{type:"compose",label:"Cover + Track",Icon:Be,color:"text-cyan-400/50"},{type:"step",label:"Step",Icon:Ge,color:"text-white/40"},{type:"output",label:"Output",Icon:Ve,color:"text-white/40"}],Fe={textInput:"",output:"",chat:"llama-3.3-70b",imageGen:"z-image-turbo",tts:"tts-kokoro",music:"stable-audio",video:"wan-2.1",compose:"",step:""},I=n=>Array.from({length:n},()=>V()),m=(n,t)=>({id:`e-${n}-${t}`,source:n,target:t,animated:!0}),De=[{name:"Album Cover",desc:"A song concept → visual art direction → cover artwork",build:()=>{const[n,t,r,s]=I(4);return{nodes:[{id:n,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A melancholic indie-folk album about leaving a small coastal town"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"You are an art director. Given this album concept, write a vivid, specific image-generation prompt for the cover art — mood, color palette, composition, subject, style. Output only the prompt.",temperature:.9}},{id:r,type:"venice",position:{x:280,y:440},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"",steps:30,width:1024,height:1024}},{id:s,type:"venice",position:{x:280,y:680},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(r,s)]}}},{name:"Podcast Episode",desc:"Topic → web research → tight 90-second script → narrated audio",build:()=>{const[n,t,r,s,c]=I(5);return{nodes:[{id:n,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"How CRISPR gene editing actually works"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Research this topic. Provide specific facts, mechanisms, and current developments. Cite sources.",webSearch:"on",temperature:.5}},{id:r,type:"venice",position:{x:280,y:460},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Rewrite this research as a conversational ~90-second podcast monologue. Start with a hook. No headings, no bullet points — just flowing spoken English.",temperature:.7}},{id:s,type:"venice",position:{x:280,y:700},data:{label:"Text to Speech",nodeType:"tts",model:"tts-kokoro",prompt:"",voice:"af_sky"}},{id:c,type:"venice",position:{x:280,y:900},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(r,s),m(s,c)]}}},{name:"Music Video Mood",desc:"One vibe → parallel image, music, and video generation",build:()=>{const[n,t,r,s,c,a,i,l]=I(8);return{nodes:[{id:n,type:"venice",position:{x:340,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"Neon-lit Tokyo alley at 3am, light rain, reflective puddles, lonely synthwave"}},{id:t,type:"venice",position:{x:340,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"You are a music-video director. Expand this mood into a single paragraph that captures visual style, camera, and sonic atmosphere. One tight paragraph, no lists.",temperature:.9}},{id:r,type:"venice",position:{x:40,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Cinematic still frame of: {{input}}",steps:30,width:1024,height:1024}},{id:s,type:"venice",position:{x:340,y:460},data:{label:"Music Gen",nodeType:"music",model:"stable-audio",prompt:"Atmospheric score matching: {{input}}",duration:30,instrumental:!0}},{id:c,type:"venice",position:{x:640,y:460},data:{label:"Video Gen",nodeType:"video",model:"wan-2.1",prompt:"{{input}}",videoAspectRatio:"16:9"}},{id:a,type:"venice",position:{x:40,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}},{id:i,type:"venice",position:{x:340,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}},{id:l,type:"venice",position:{x:640,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(t,s),m(t,c),m(r,a),m(s,i),m(c,l)]}}},{name:"Song Writer",desc:"Theme → lyrics → music generation with vocals",build:()=>{const[n,t,r,s]=I(4);return{nodes:[{id:n,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A bittersweet goodbye between two old friends at a train station"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Write a short song (verse, chorus, verse) about this theme. Keep it under 100 words. Output only the lyrics — no headers or commentary.",temperature:.9}},{id:r,type:"venice",position:{x:280,y:460},data:{label:"Music Gen",nodeType:"music",model:"stable-audio",prompt:"Melancholic indie-folk, acoustic guitar, soft male vocals, slow tempo",duration:45,instrumental:!1}},{id:s,type:"venice",position:{x:280,y:680},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(r,s)]}}},{name:"Character Portrait",desc:"Character concept → rich visual design brief → portrait",build:()=>{const[n,t,r,s]=I(4);return{nodes:[{id:n,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A disillusioned space-station botanist in her 50s, caretaker of the last Earth plants"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Write a detailed character portrait brief: physical description, clothing, posture, lighting, background, art style. Aim for concrete visual detail, not personality. Output as a single dense prompt paragraph.",temperature:.85}},{id:r,type:"venice",position:{x:280,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Portrait, 50mm lens, cinematic: {{input}}",steps:35,width:832,height:1216}},{id:s,type:"venice",position:{x:280,y:700},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(r,s)]}}},{name:"Story Scene",desc:"One-line premise → cinematic scene description → illustration",build:()=>{const[n,t,r,s]=I(4);return{nodes:[{id:n,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A lighthouse keeper finds a message in a bottle from her younger self"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Expand this premise into a single cinematic scene description: setting, time of day, weather, key visual detail, subject pose, mood. 3-4 sentences, no narrative — purely visual.",temperature:.9}},{id:r,type:"venice",position:{x:280,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Cinematic wide shot, film still, moody lighting: {{input}}",steps:30,width:1216,height:832}},{id:s,type:"venice",position:{x:280,y:700},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[m(n,t),m(t,r),m(r,s)]}}}];function ze(){const{activeWorkflowId:n,workflows:t,updateWorkflow:r,updateNodeResult:s,setIsRunning:c,isRunning:a,clearResults:i}=C(),l=t.find(x=>x.id===n),[d,o,p]=ee(l?.nodes??[]),[h,u,g]=te(l?.edges??[]),{getNodes:j,getEdges:S}=Y(),O=w.useRef(void 0),y=w.useCallback(()=>{clearTimeout(O.current),O.current=setTimeout(()=>{n&&r(n,{nodes:j(),edges:S()})},200)},[n,r,j,S]),z=w.useCallback(x=>{u(T=>oe({...x,animated:!0},T)),y()},[u,y]),U=x=>{const L={id:V(),type:"venice",position:{x:250+Math.random()*100,y:100+d.length*180},data:{label:x,nodeType:x,model:Fe[x],prompt:"",inputText:x==="textInput"?"":void 0}};o(k=>[...k,L]),y()},K=async()=>{if(a)return;const x=j(),T=S();if(x.length===0)return;n&&r(n,{nodes:x,edges:T}),i(),c(!0);const L={};for(const k of x)L[k.id]={nodeId:k.id,status:"pending",output:void 0,error:void 0};C.getState().setRunResults(L);try{await le(x,T,{onUpdate:s}),$.success("Workflow completed")}catch(k){$.fromError(k,"Workflow failed")}finally{c(!1)}},H=w.useCallback(x=>{p(x),y()},[p,y]),J=w.useCallback(x=>{g(x),y()},[g,y]),q=w.useMemo(()=>We,[]);return l?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"w-56 border-r border-white/[0.06] bg-[#0a0a0a] flex flex-col shrink-0",children:[e.jsx("div",{className:"p-3 border-b border-white/[0.06]",children:e.jsx("span",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em]",children:"Add Node"})}),e.jsx("div",{className:"p-2 flex flex-col gap-1",children:Ye.map(x=>e.jsxs("button",{onClick:()=>U(x.type),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-[14px] text-white/40 hover:text-white/60 hover:bg-white/[0.04] transition-colors text-left",children:[e.jsx("span",{className:x.color,children:e.jsx(x.Icon,{})}),x.label]},x.type))}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"p-3 border-t border-white/[0.06]",children:e.jsx("button",{onClick:K,disabled:a||d.length===0,className:v("w-full flex items-center justify-center gap-1.5 py-2 rounded-lg text-[14px] font-medium transition-all",a?"bg-white/[0.06] text-white/30 cursor-wait":"bg-white text-black hover:bg-white/90 disabled:opacity-30 disabled:cursor-not-allowed"),children:a?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-3 h-3 border-2 border-white/30 border-t-transparent rounded-full animate-spin"}),"Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Run Workflow"]})})})]}),e.jsx("div",{className:"flex-1",children:e.jsxs(ne,{nodes:d,edges:h,onNodesChange:H,onEdgesChange:J,onConnect:z,nodeTypes:q,fitView:!0,proOptions:{hideAttribution:!0},className:"bg-[#080808]",defaultEdgeOptions:{animated:!0,style:{stroke:"rgba(255,255,255,0.1)",strokeWidth:2}},children:[e.jsx(se,{variant:re.Dots,gap:20,size:1,color:"rgba(255,255,255,0.03)"}),e.jsx(ie,{className:"!bg-[#111] !border-white/[0.06] !shadow-xl [&>button]:!bg-[#111] [&>button]:!border-white/[0.06] [&>button]:!text-white/30 [&>button:hover]:!bg-white/[0.06]"}),e.jsx(ae,{nodeColor:"rgba(255,255,255,0.1)",maskColor:"rgba(0,0,0,0.8)",className:"!bg-[#0a0a0a] !border-white/[0.06]"})]})})]}):null}function He(){const{workflows:n,activeWorkflowId:t,createWorkflow:r,deleteWorkflow:s,setActiveWorkflow:c}=C(),[a,i]=w.useState(""),l=(d,o)=>{const p=d?.trim()||"Untitled Workflow",h=r(p);if(o){const{nodes:u,edges:g}=o.build();C.getState().updateWorkflow(h,{nodes:u,edges:g})}i("")};return t&&n.find(d=>d.id===t)?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[e.jsxs("button",{onClick:()=>c(null),className:"text-[13px] text-white/25 hover:text-white/50 transition-colors flex items-center gap-1",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"Back"]}),e.jsx("div",{className:"w-px h-3.5 bg-white/[0.06]"}),e.jsx("span",{className:"text-[14px] text-white/50 font-medium",children:n.find(d=>d.id===t)?.name}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",title:"This workflow as a Gitea Actions workflow file: run it on the factory, on a timer, or import it back here",onClick:()=>{const d=n.find(o=>o.id===t);d&&(Se(D(d.name)+".yml",Le(d)),$.success("Exported","Commit it under .gitea/workflows/ or .github/workflows/ in a repo with the secret VENICE_API_KEY."))},className:"text-[13px] text-white/35 hover:text-white/70 transition-colors px-2 py-1 border border-white/[0.08]",children:"Export"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Z,{children:e.jsx(ze,{},t)})})]}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8",children:[e.jsx("h2",{className:"text-[16px] text-white/60 font-medium mb-1",children:"Workflows"}),e.jsx("p",{className:"text-[13px] text-white/20 mb-6",children:"Chain Venice models together visually"}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx("input",{value:a,onChange:d=>i(d.target.value),onKeyDown:d=>d.key==="Enter"&&l(a),placeholder:"Workflow name...",className:"flex-1 bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-2 text-[15px] text-white/70 outline-none placeholder:text-white/15 focus:border-white/[0.12]"}),e.jsx("button",{onClick:()=>l(a),className:"text-[14px] font-medium px-4 py-2 rounded-lg bg-white text-black hover:bg-white/90 transition-colors",children:"New Workflow"}),e.jsxs("label",{title:"Any Gitea Actions workflow (.yml): one exported from here comes back as it was; any other becomes a chain of Step nodes. Or a graph as JSON",className:"text-[14px] font-medium px-4 py-2 rounded-lg border border-white/[0.12] text-white/60 hover:text-white/90 transition-colors cursor-pointer",children:["Import",e.jsx("input",{type:"file",accept:".yml,.yaml,.json,text/yaml,application/json",className:"hidden",onChange:async d=>{const o=d.target.files?.[0];if(d.target.value="",!o)return;const p=Ee(await o.text());if(!p){$.error("No workflow in that file","Import an Actions workflow (.yml) or a graph as JSON.");return}const h=r(p.name);C.getState().updateWorkflow(h,{nodes:p.nodes,edges:p.edges,frame:p.frame}),$.success(`Imported ${p.name}`,`${p.nodes.length} nodes`)}})]})]}),e.jsx("h3",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em] mb-3",children:"Templates"}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-8",children:De.map(d=>e.jsxs("button",{onClick:()=>l(d.name,d),className:"p-3.5 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.12] transition-all text-left",children:[e.jsx("div",{className:"text-[15px] text-white/60 font-medium mb-1",children:d.name}),e.jsx("div",{className:"text-[13px] text-white/20",children:d.desc})]},d.name))}),n.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em] mb-3",children:"Saved Workflows"}),e.jsx("div",{className:"flex flex-col gap-2",children:n.map(d=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.1] transition-all cursor-pointer",onClick:()=>c(d.id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[15px] text-white/60 font-medium truncate",children:d.name}),e.jsxs("div",{className:"text-[13px] text-white/15",children:[d.nodes.length," nodes"]})]}),e.jsx("button",{onClick:o=>{o.stopPropagation(),s(d.id)},className:"text-[13px] text-white/15 hover:text-red-400/60 transition-colors px-2 py-1",children:"Delete"})]},d.id))})]})]})})}export{He as WorkflowsView}; diff --git a/ventures/havre/open/assets/workflows-view-CqSB6AnK.js b/ventures/havre/open/assets/workflows-view-CqSB6AnK.js deleted file mode 100644 index 2f48a0a..0000000 --- a/ventures/havre/open/assets/workflows-view-CqSB6AnK.js +++ /dev/null @@ -1 +0,0 @@ -import{r as h,j as e,c as w,u as F,S as _,g as E,t as M}from"./index-BK6OjN4-.js";import{u as y,a as R,H as O,P as S,R as z,b as H,c as $,d as U,i as Y,B as K,e as q,C as J,M as Q,f as X}from"./workflow-engine-BHZwbSiT.js";function Z(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"22 12 16 12 14 15 10 9 8 12 2 12"})})}function ee(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})})}function te(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}function oe(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})}function ne(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function se(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"23 7 16 12 23 17 23 7"}),e.jsx("rect",{x:"1",y:"5",width:"15",height:"14",rx:"2"})]})}function ie(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]})}const re={textInput:void 0,output:void 0,chat:"text",imageGen:"image",tts:"tts",music:"music",video:"video"},ae={textInput:{label:"Input",Icon:Z,color:"border-blue-500/30",hasInput:!1,hasOutput:!0},chat:{label:"LLM",Icon:ee,color:"border-purple-500/30",hasInput:!0,hasOutput:!0},imageGen:{label:"Image Gen",Icon:te,color:"border-pink-500/30",hasInput:!0,hasOutput:!0},tts:{label:"Text to Speech",Icon:oe,color:"border-green-500/30",hasInput:!0,hasOutput:!0},music:{label:"Music Gen",Icon:ne,color:"border-yellow-500/30",hasInput:!0,hasOutput:!0},video:{label:"Video Gen",Icon:se,color:"border-orange-500/30",hasInput:!0,hasOutput:!0},output:{label:"Output",Icon:ie,color:"border-white/20",hasInput:!0,hasOutput:!1}},x="nodrag bg-white/[0.03] border border-white/[0.06] rounded px-1.5 py-0.5 text-[12px] text-white/40 outline-none",L="nodrag w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1 text-[13px] text-white/60 outline-none placeholder:text-white/15";function le({nodeType:s,value:t,onChange:i}){const o=re[s],{data:c}=F(o),p=c?.map(u=>({value:u.id,label:u.model_spec?.name||u.id}))??[];return e.jsx("div",{className:"nodrag",children:e.jsx(_,{value:t,onChange:i,options:p,searchable:!0,placeholder:"Select model...",className:"w-full [&_button]:!py-1 [&_button]:!text-[13px] [&_button]:!px-2"})})}function de({id:s,data:t}){const i=ae[t.nodeType],o=y(n=>n.runResults[s]),{setNodes:c}=R(),[p,u]=h.useState(!1),r=h.useCallback(n=>{c(m=>m.map(g=>g.id===s?{...g,data:{...g.data,...n}}:g))},[s,c]),a=h.useCallback(()=>{c(n=>n.filter(m=>m.id!==s))},[s,c]);return e.jsxs("div",{className:w("rounded-xl border-2 bg-[#111] shadow-xl min-w-[300px] max-w-[340px]",i.color,o?.status==="running"&&"ring-2 ring-white/20 animate-pulse",o?.status==="done"&&"ring-2 ring-green-500/30",o?.status==="error"&&"ring-2 ring-red-500/30"),children:[i.hasInput&&e.jsx(O,{type:"target",position:S.Top,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/[0.06]",children:[e.jsx("span",{className:"text-white/30",children:e.jsx(i.Icon,{})}),e.jsx("span",{className:"text-[14px] font-medium text-white/60",children:i.label}),o?.status==="running"&&e.jsx("span",{className:"text-[12px] text-white/30 ml-auto mr-1",children:"Running..."}),o?.status==="done"&&e.jsx("span",{className:"text-[12px] text-green-400/60 ml-auto mr-1",children:"Done"}),o?.status==="error"&&e.jsx("span",{className:"text-[12px] text-red-400/60 ml-auto mr-1",children:"Error"}),!o?.status&&e.jsx("span",{className:"ml-auto"}),e.jsx("button",{onClick:a,className:"nodrag text-white/10 hover:text-red-400/60 transition-colors p-0.5",title:"Delete node",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-1.5",children:[t.nodeType==="output"?o?.status==="done"&&o.output?e.jsx("div",{className:"min-h-[60px]",children:o.output.startsWith("[audio:")?e.jsx("audio",{src:o.output.slice(7,-1),controls:!0,className:"w-full h-8"}):o.output.startsWith("[video:")?e.jsx("a",{href:o.output.slice(7,-1),target:"_blank",rel:"noreferrer",className:"text-[14px] text-blue-400 underline",children:"Open video"}):o.output.startsWith("[image:")?e.jsx("img",{src:o.output.slice(7,-1),alt:"Generated",className:"w-full rounded-lg border border-white/[0.06]"}):e.jsx("p",{className:w("text-[14px] text-white/60 leading-relaxed whitespace-pre-wrap",!p&&"line-clamp-8"),onClick:()=>u(!p),children:o.output})}):o?.status==="running"?e.jsx("div",{className:"min-h-[40px] flex items-center justify-center",children:e.jsx("span",{className:"text-[13px] text-white/20",children:"Waiting for input..."})}):o?.status==="error"?e.jsx("p",{className:"text-[13px] text-red-400/60",children:o.error}):e.jsx("div",{className:"min-h-[40px] flex items-center justify-center",children:e.jsx("span",{className:"text-[13px] text-white/10",children:"Run workflow to see output"})}):t.nodeType==="textInput"?e.jsx("textarea",{value:t.inputText??"",onChange:n=>r({inputText:n.target.value}),placeholder:"Enter starting text...",rows:3,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}):e.jsxs(e.Fragment,{children:[e.jsx(le,{nodeType:t.nodeType,value:t.model,onChange:n=>r({model:n})}),e.jsx("textarea",{value:t.prompt,onChange:n=>r({prompt:n.target.value}),placeholder:"Instructions for this step...",rows:2,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}),t.nodeType==="chat"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("select",{value:t.webSearch??"off",onChange:n=>r({webSearch:n.target.value}),className:x,children:[e.jsx("option",{value:"off",children:"Search off"}),e.jsx("option",{value:"on",children:"Search on"}),e.jsx("option",{value:"auto",children:"Search auto"})]}),e.jsx("input",{type:"number",value:t.temperature??.7,onChange:n=>r({temperature:parseFloat(n.target.value)}),step:.1,min:0,max:2,className:w(x,"w-14"),title:"Temperature"}),e.jsx("input",{type:"number",value:t.maxTokens??4096,onChange:n=>r({maxTokens:parseInt(n.target.value)}),step:256,min:64,max:32768,className:w(x,"w-[72px]"),title:"Max tokens"})]}),t.nodeType==="imageGen"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:t.negativePrompt??"",onChange:n=>r({negativePrompt:n.target.value}),placeholder:"Negative prompt...",className:L}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Steps"}),e.jsx("input",{type:"number",value:t.steps??20,onChange:n=>r({steps:parseInt(n.target.value)}),min:1,max:50,className:x+" w-full"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Size"}),e.jsxs("select",{value:`${t.width??1024}x${t.height??1024}`,onChange:n=>{const[m,g]=n.target.value.split("x").map(Number);r({width:m,height:g})},className:x+" w-full",children:[e.jsx("option",{value:"512x512",children:"512"}),e.jsx("option",{value:"768x768",children:"768"}),e.jsx("option",{value:"1024x1024",children:"1024"}),e.jsx("option",{value:"1280x1280",children:"1280"})]})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{value:t.style??"",onChange:n=>r({style:n.target.value}),placeholder:"Style preset...",className:w(L,"flex-1")}),e.jsxs("label",{className:"nodrag flex items-center gap-1 text-[12px] text-white/30 cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.hideWatermark??!0,onChange:n=>r({hideWatermark:n.target.checked}),className:"nodrag w-3 h-3 accent-white/50"}),"No WM"]})]})]}),t.nodeType==="tts"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-[80px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Voice"}),e.jsx("input",{value:t.voice??"af_sky",onChange:n=>r({voice:n.target.value}),placeholder:"Voice ID",className:L})]}),e.jsxs("div",{className:"w-14",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Speed"}),e.jsx("input",{type:"number",value:t.speed??1,onChange:n=>r({speed:parseFloat(n.target.value)}),step:.25,min:.25,max:4,className:x+" w-full"})]}),e.jsxs("div",{className:"w-16",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Format"}),e.jsxs("select",{value:t.responseFormat??"mp3",onChange:n=>r({responseFormat:n.target.value}),className:x+" w-full",children:[e.jsx("option",{value:"mp3",children:"MP3"}),e.jsx("option",{value:"opus",children:"Opus"}),e.jsx("option",{value:"aac",children:"AAC"}),e.jsx("option",{value:"flac",children:"FLAC"}),e.jsx("option",{value:"wav",children:"WAV"})]})]})]}),t.nodeType==="music"&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:t.lyrics??"",onChange:n=>r({lyrics:n.target.value}),placeholder:"Lyrics (optional)...",rows:2,className:"nodrag nowheel w-full bg-white/[0.03] border border-white/[0.06] rounded-md px-2 py-1.5 text-[14px] text-white/70 outline-none resize-none placeholder:text-white/15"}),e.jsxs("div",{className:"flex gap-1.5 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Duration (s)"}),e.jsx("input",{type:"number",value:t.duration??30,onChange:n=>r({duration:parseInt(n.target.value)}),min:5,max:120,step:5,className:x+" w-full"})]}),e.jsxs("label",{className:"nodrag flex items-center gap-1 text-[12px] text-white/30 cursor-pointer pb-0.5",children:[e.jsx("input",{type:"checkbox",checked:t.instrumental??!1,onChange:n=>r({instrumental:n.target.checked}),className:"nodrag w-3 h-3 accent-white/50"}),"Instrumental"]})]})]}),t.nodeType==="video"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Aspect"}),e.jsxs("select",{value:t.videoAspectRatio??"16:9",onChange:n=>r({videoAspectRatio:n.target.value}),className:x+" w-full",children:[e.jsx("option",{value:"16:9",children:"16:9"}),e.jsx("option",{value:"9:16",children:"9:16"}),e.jsx("option",{value:"1:1",children:"1:1"}),e.jsx("option",{value:"4:3",children:"4:3"}),e.jsx("option",{value:"3:4",children:"3:4"})]})]}),e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Duration"}),e.jsxs("select",{value:t.videoDuration??"",onChange:n=>r({videoDuration:n.target.value}),className:x+" w-full",children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"5s",children:"5s"}),e.jsx("option",{value:"10s",children:"10s"})]})]}),e.jsxs("div",{className:"flex-1 min-w-[60px]",children:[e.jsx("label",{className:"text-[11px] text-white/20 mb-0.5 block",children:"Resolution"}),e.jsxs("select",{value:t.videoResolution??"",onChange:n=>r({videoResolution:n.target.value}),className:x+" w-full",children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"720p",children:"720p"}),e.jsx("option",{value:"1080p",children:"1080p"})]})]})]})]}),t.nodeType!=="output"&&o?.status==="done"&&o.output&&e.jsxs("div",{className:"mt-1 p-2 rounded-lg bg-green-500/[0.04] border border-green-500/[0.08] cursor-pointer",onClick:()=>u(!p),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",className:"text-green-400/40",children:e.jsx("polyline",{points:p?"18 15 12 9 6 15":"6 9 12 15 18 9"})}),e.jsx("span",{className:"text-[11px] text-green-400/40 uppercase tracking-wider font-medium",children:"Output"})]}),o.output.startsWith("[audio:")?e.jsx("audio",{src:o.output.slice(7,-1),controls:!0,className:"w-full h-7",onClick:n=>n.stopPropagation()}):o.output.startsWith("[video:")?e.jsx("a",{href:o.output.slice(7,-1),target:"_blank",rel:"noreferrer",className:"text-[13px] text-blue-400 underline",onClick:n=>n.stopPropagation(),children:"Open video"}):o.output.startsWith("[image:")?e.jsx("img",{src:o.output.slice(7,-1),alt:"Generated",className:"w-full rounded border border-white/[0.06]"}):e.jsx("p",{className:w("text-[13px] text-white/50 leading-relaxed whitespace-pre-wrap",!p&&"line-clamp-3"),children:o.output})]}),t.nodeType!=="output"&&o?.status==="error"&&e.jsxs("div",{className:"mt-1 p-2 rounded-lg bg-red-500/[0.04] border border-red-500/[0.08]",children:[e.jsx("span",{className:"text-[11px] text-red-400/40 uppercase tracking-wider font-medium",children:"Error"}),e.jsx("p",{className:"text-[13px] text-red-400/60 mt-0.5",children:o.error})]})]}),i.hasOutput&&e.jsx(O,{type:"source",position:S.Bottom,className:"!w-3 !h-3 !bg-white/30 !border-2 !border-[#111]"})]})}const ce=h.memo(de),pe={venice:ce};function ue(){return e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"22 12 16 12 14 15 10 9 8 12 2 12"})})}function xe(){return e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})})}function he(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]})}function me(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e.jsx("path",{d:"M15.54 8.46a5 5 0 010 7.07"})]})}function ge(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}function be(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"23 7 16 12 23 17 23 7"}),e.jsx("rect",{x:"1",y:"5",width:"15",height:"14",rx:"2"})]})}function we(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]})}const ve=[{type:"textInput",label:"Input",Icon:ue,color:"text-blue-400/50"},{type:"chat",label:"LLM",Icon:xe,color:"text-purple-400/50"},{type:"imageGen",label:"Image Gen",Icon:he,color:"text-pink-400/50"},{type:"tts",label:"Text to Speech",Icon:me,color:"text-green-400/50"},{type:"music",label:"Music Gen",Icon:ge,color:"text-yellow-400/50"},{type:"video",label:"Video Gen",Icon:be,color:"text-orange-400/50"},{type:"output",label:"Output",Icon:we,color:"text-white/40"}],je={textInput:"",output:"",chat:"llama-3.3-70b",imageGen:"z-image-turbo",tts:"tts-kokoro",music:"stable-audio",video:"wan-2.1"},j=s=>Array.from({length:s},()=>E()),d=(s,t)=>({id:`e-${s}-${t}`,source:s,target:t,animated:!0}),fe=[{name:"Album Cover",desc:"A song concept → visual art direction → cover artwork",build:()=>{const[s,t,i,o]=j(4);return{nodes:[{id:s,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A melancholic indie-folk album about leaving a small coastal town"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"You are an art director. Given this album concept, write a vivid, specific image-generation prompt for the cover art — mood, color palette, composition, subject, style. Output only the prompt.",temperature:.9}},{id:i,type:"venice",position:{x:280,y:440},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"",steps:30,width:1024,height:1024}},{id:o,type:"venice",position:{x:280,y:680},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(i,o)]}}},{name:"Podcast Episode",desc:"Topic → web research → tight 90-second script → narrated audio",build:()=>{const[s,t,i,o,c]=j(5);return{nodes:[{id:s,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"How CRISPR gene editing actually works"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Research this topic. Provide specific facts, mechanisms, and current developments. Cite sources.",webSearch:"on",temperature:.5}},{id:i,type:"venice",position:{x:280,y:460},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Rewrite this research as a conversational ~90-second podcast monologue. Start with a hook. No headings, no bullet points — just flowing spoken English.",temperature:.7}},{id:o,type:"venice",position:{x:280,y:700},data:{label:"Text to Speech",nodeType:"tts",model:"tts-kokoro",prompt:"",voice:"af_sky"}},{id:c,type:"venice",position:{x:280,y:900},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(i,o),d(o,c)]}}},{name:"Music Video Mood",desc:"One vibe → parallel image, music, and video generation",build:()=>{const[s,t,i,o,c,p,u,r]=j(8);return{nodes:[{id:s,type:"venice",position:{x:340,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"Neon-lit Tokyo alley at 3am, light rain, reflective puddles, lonely synthwave"}},{id:t,type:"venice",position:{x:340,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"You are a music-video director. Expand this mood into a single paragraph that captures visual style, camera, and sonic atmosphere. One tight paragraph, no lists.",temperature:.9}},{id:i,type:"venice",position:{x:40,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Cinematic still frame of: {{input}}",steps:30,width:1024,height:1024}},{id:o,type:"venice",position:{x:340,y:460},data:{label:"Music Gen",nodeType:"music",model:"stable-audio",prompt:"Atmospheric score matching: {{input}}",duration:30,instrumental:!0}},{id:c,type:"venice",position:{x:640,y:460},data:{label:"Video Gen",nodeType:"video",model:"wan-2.1",prompt:"{{input}}",videoAspectRatio:"16:9"}},{id:p,type:"venice",position:{x:40,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}},{id:u,type:"venice",position:{x:340,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}},{id:r,type:"venice",position:{x:640,y:740},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(t,o),d(t,c),d(i,p),d(o,u),d(c,r)]}}},{name:"Song Writer",desc:"Theme → lyrics → music generation with vocals",build:()=>{const[s,t,i,o]=j(4);return{nodes:[{id:s,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A bittersweet goodbye between two old friends at a train station"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Write a short song (verse, chorus, verse) about this theme. Keep it under 100 words. Output only the lyrics — no headers or commentary.",temperature:.9}},{id:i,type:"venice",position:{x:280,y:460},data:{label:"Music Gen",nodeType:"music",model:"stable-audio",prompt:"Melancholic indie-folk, acoustic guitar, soft male vocals, slow tempo",duration:45,instrumental:!1}},{id:o,type:"venice",position:{x:280,y:680},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(i,o)]}}},{name:"Character Portrait",desc:"Character concept → rich visual design brief → portrait",build:()=>{const[s,t,i,o]=j(4);return{nodes:[{id:s,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A disillusioned space-station botanist in her 50s, caretaker of the last Earth plants"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Write a detailed character portrait brief: physical description, clothing, posture, lighting, background, art style. Aim for concrete visual detail, not personality. Output as a single dense prompt paragraph.",temperature:.85}},{id:i,type:"venice",position:{x:280,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Portrait, 50mm lens, cinematic: {{input}}",steps:35,width:832,height:1216}},{id:o,type:"venice",position:{x:280,y:700},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(i,o)]}}},{name:"Story Scene",desc:"One-line premise → cinematic scene description → illustration",build:()=>{const[s,t,i,o]=j(4);return{nodes:[{id:s,type:"venice",position:{x:280,y:40},data:{label:"Input",nodeType:"textInput",model:"",prompt:"",inputText:"A lighthouse keeper finds a message in a bottle from her younger self"}},{id:t,type:"venice",position:{x:280,y:220},data:{label:"LLM",nodeType:"chat",model:"llama-3.3-70b",prompt:"Expand this premise into a single cinematic scene description: setting, time of day, weather, key visual detail, subject pose, mood. 3-4 sentences, no narrative — purely visual.",temperature:.9}},{id:i,type:"venice",position:{x:280,y:460},data:{label:"Image Gen",nodeType:"imageGen",model:"z-image-turbo",prompt:"Cinematic wide shot, film still, moody lighting: {{input}}",steps:30,width:1216,height:832}},{id:o,type:"venice",position:{x:280,y:700},data:{label:"Output",nodeType:"output",model:"",prompt:""}}],edges:[d(s,t),d(t,i),d(i,o)]}}}];function ye(){const{activeWorkflowId:s,workflows:t,updateWorkflow:i,updateNodeResult:o,setIsRunning:c,isRunning:p,clearResults:u}=y(),r=t.find(l=>l.id===s),[a,n,m]=H(r?.nodes??[]),[g,k,N]=$(r?.edges??[]),{getNodes:I,getEdges:T}=R(),W=h.useRef(void 0),b=h.useCallback(()=>{clearTimeout(W.current),W.current=setTimeout(()=>{s&&i(s,{nodes:I(),edges:T()})},200)},[s,i,I,T]),G=h.useCallback(l=>{k(f=>U({...l,animated:!0},f)),b()},[k,b]),P=l=>{const C={id:E(),type:"venice",position:{x:250+Math.random()*100,y:100+a.length*180},data:{label:l,nodeType:l,model:je[l],prompt:"",inputText:l==="textInput"?"":void 0}};n(v=>[...v,C]),b()},A=async()=>{if(p)return;const l=I(),f=T();if(l.length===0)return;s&&i(s,{nodes:l,edges:f}),u(),c(!0);const C={};for(const v of l)C[v.id]={nodeId:v.id,status:"pending",output:void 0,error:void 0};y.getState().setRunResults(C);try{await X(l,f,{onUpdate:o}),M.success("Workflow completed")}catch(v){M.fromError(v,"Workflow failed")}finally{c(!1)}},B=h.useCallback(l=>{m(l),b()},[m,b]),D=h.useCallback(l=>{N(l),b()},[N,b]),V=h.useMemo(()=>pe,[]);return r?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"w-56 border-r border-white/[0.06] bg-[#0a0a0a] flex flex-col shrink-0",children:[e.jsx("div",{className:"p-3 border-b border-white/[0.06]",children:e.jsx("span",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em]",children:"Add Node"})}),e.jsx("div",{className:"p-2 flex flex-col gap-1",children:ve.map(l=>e.jsxs("button",{onClick:()=>P(l.type),className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-[14px] text-white/40 hover:text-white/60 hover:bg-white/[0.04] transition-colors text-left",children:[e.jsx("span",{className:l.color,children:e.jsx(l.Icon,{})}),l.label]},l.type))}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"p-3 border-t border-white/[0.06]",children:e.jsx("button",{onClick:A,disabled:p||a.length===0,className:w("w-full flex items-center justify-center gap-1.5 py-2 rounded-lg text-[14px] font-medium transition-all",p?"bg-white/[0.06] text-white/30 cursor-wait":"bg-white text-black hover:bg-white/90 disabled:opacity-30 disabled:cursor-not-allowed"),children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-3 h-3 border-2 border-white/30 border-t-transparent rounded-full animate-spin"}),"Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Run Workflow"]})})})]}),e.jsx("div",{className:"flex-1",children:e.jsxs(Y,{nodes:a,edges:g,onNodesChange:B,onEdgesChange:D,onConnect:G,nodeTypes:V,fitView:!0,proOptions:{hideAttribution:!0},className:"bg-[#080808]",defaultEdgeOptions:{animated:!0,style:{stroke:"rgba(255,255,255,0.1)",strokeWidth:2}},children:[e.jsx(K,{variant:q.Dots,gap:20,size:1,color:"rgba(255,255,255,0.03)"}),e.jsx(J,{className:"!bg-[#111] !border-white/[0.06] !shadow-xl [&>button]:!bg-[#111] [&>button]:!border-white/[0.06] [&>button]:!text-white/30 [&>button:hover]:!bg-white/[0.06]"}),e.jsx(Q,{nodeColor:"rgba(255,255,255,0.1)",maskColor:"rgba(0,0,0,0.8)",className:"!bg-[#0a0a0a] !border-white/[0.06]"})]})})]}):null}function Ce(){const{workflows:s,activeWorkflowId:t,createWorkflow:i,deleteWorkflow:o,setActiveWorkflow:c}=y(),[p,u]=h.useState(""),r=(a,n)=>{const m=a?.trim()||"Untitled Workflow",g=i(m);if(n){const{nodes:k,edges:N}=n.build();y.getState().updateWorkflow(g,{nodes:k,edges:N})}u("")};return t&&s.find(a=>a.id===t)?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5 border-b border-white/[0.06] bg-[#0a0a0a] shrink-0",children:[e.jsxs("button",{onClick:()=>c(null),className:"text-[13px] text-white/25 hover:text-white/50 transition-colors flex items-center gap-1",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"Back"]}),e.jsx("div",{className:"w-px h-3.5 bg-white/[0.06]"}),e.jsx("span",{className:"text-[14px] text-white/50 font-medium",children:s.find(a=>a.id===t)?.name})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(z,{children:e.jsx(ye,{},t)})})]}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8",children:[e.jsx("h2",{className:"text-[16px] text-white/60 font-medium mb-1",children:"Workflows"}),e.jsx("p",{className:"text-[13px] text-white/20 mb-6",children:"Chain Venice models together visually"}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx("input",{value:p,onChange:a=>u(a.target.value),onKeyDown:a=>a.key==="Enter"&&r(p),placeholder:"Workflow name...",className:"flex-1 bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-2 text-[15px] text-white/70 outline-none placeholder:text-white/15 focus:border-white/[0.12]"}),e.jsx("button",{onClick:()=>r(p),className:"text-[14px] font-medium px-4 py-2 rounded-lg bg-white text-black hover:bg-white/90 transition-colors",children:"New Workflow"})]}),e.jsx("h3",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em] mb-3",children:"Templates"}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-8",children:fe.map(a=>e.jsxs("button",{onClick:()=>r(a.name,a),className:"p-3.5 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.12] transition-all text-left",children:[e.jsx("div",{className:"text-[15px] text-white/60 font-medium mb-1",children:a.name}),e.jsx("div",{className:"text-[13px] text-white/20",children:a.desc})]},a.name))}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-[13px] font-medium text-white/15 uppercase tracking-[0.08em] mb-3",children:"Saved Workflows"}),e.jsx("div",{className:"flex flex-col gap-2",children:s.map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border border-white/[0.06] bg-white/[0.02] hover:border-white/[0.1] transition-all cursor-pointer",onClick:()=>c(a.id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[15px] text-white/60 font-medium truncate",children:a.name}),e.jsxs("div",{className:"text-[13px] text-white/15",children:[a.nodes.length," nodes"]})]}),e.jsx("button",{onClick:n=>{n.stopPropagation(),o(a.id)},className:"text-[13px] text-white/15 hover:text-red-400/60 transition-colors px-2 py-1",children:"Delete"})]},a.id))})]})]})})}export{Ce as WorkflowsView}; diff --git a/ventures/havre/open/index.html b/ventures/havre/open/index.html index 63d33a6..7b909fa 100644 --- a/ventures/havre/open/index.html +++ b/ventures/havre/open/index.html @@ -17,8 +17,8 @@ /> OpenVenice — clean UI for the Venice AI API - - + +
    diff --git a/ventures/havre/open/run.mjs b/ventures/havre/open/run.mjs new file mode 100644 index 0000000..cdb6ad1 --- /dev/null +++ b/ventures/havre/open/run.mjs @@ -0,0 +1,186 @@ +#!/usr/bin/env node +// run.mjs: an openvenice workflow, one node at a time, headless. The same graph the canvas at /open runs in a +// browser, run on a machine: a Gitea Actions runner, your laptop, a cron. Node 20+, no dependencies; ffmpeg for a +// Cover + Track node. +// +// node run.mjs --graph graph.json --node [--out out] one node: reads its parents' outputs from out/, +// writes out/.txt (and a file for media) +// node run.mjs --graph graph.json --all [--out out] every node, in dependency order +// OV_WORKFLOW= node run.mjs --node the graph as the exported workflow carries it +// +// Needs VENICE_API_KEY. A node's output is one string, exactly as in the browser engine: text, or [image:], +// [audio:], [video:] for media; a node with several parents gets their outputs joined with blank lines. + +import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs"; +import { join } from "node:path"; +import { spawnSync } from "node:child_process"; + +const BASE = process.env.VENICE_BASE_URL || "https://api.venice.ai/api/v1"; +const KEY = process.env.VENICE_API_KEY || ""; +const POLL_MS = Number(process.env.OV_POLL_MS || 3000), POLL_MAX = Number(process.env.OV_POLL_MAX || 200); + +const args = process.argv.slice(2); +const flag = (name, dflt = "") => { const i = args.indexOf("--" + name); return i >= 0 && args[i + 1] && !args[i + 1].startsWith("--") ? args[i + 1] : dflt; }; +const has = (name) => args.includes("--" + name); +const OUT = flag("out", "out"); + +function loadGraph() { + const path = flag("graph"); + const raw = path ? readFileSync(path, "utf8") : process.env.OV_WORKFLOW ? Buffer.from(process.env.OV_WORKFLOW, "base64").toString("utf8") : ""; + if (!raw) fail("no graph: --graph graph.json, or OV_WORKFLOW in the environment"); + const g = JSON.parse(raw); + const nodes = Array.isArray(g.nodes) ? g.nodes : [], edges = Array.isArray(g.edges) ? g.edges : []; + if (!nodes.length) fail("the graph has no nodes"); + return { name: g.name || "workflow", nodes, edges }; +} + +function fail(msg) { console.error("run.mjs: " + msg); process.exit(1); } + +async function venice(path, body, { binary = false } = {}) { + if (!KEY) fail("VENICE_API_KEY is not set"); + for (let attempt = 0; ; attempt++) { + const res = await fetch(BASE + path, { method: "POST", headers: { Authorization: "Bearer " + KEY, "Content-Type": "application/json" }, body: JSON.stringify(body) }); + if ([408, 425, 429, 500, 502, 503, 504].includes(res.status) && attempt < 2) { await sleep(1500 * (attempt + 1)); continue; } + if (!res.ok) { + let detail = ""; + try { detail = (await res.text()).slice(0, 400); } catch { /* none */ } + throw new Error(`Venice ${res.status} on ${path}${detail ? ": " + detail : ""}`); + } + const type = res.headers.get("content-type") || ""; + if (binary || !/json/i.test(type)) return { binary: Buffer.from(await res.arrayBuffer()), type }; + return { json: await res.json(), type }; + } +} +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); + +/** a queued music or video job, asked about until it's done; the file, however Venice sends it */ +async function retrieve(kind, model, queueId, downloadUrl) { + for (let i = 0; i < POLL_MAX; i++) { + await sleep(POLL_MS); + const r = await venice(`/${kind}/retrieve`, { model, queue_id: queueId }); + if (r.binary) return { bytes: r.binary, type: r.type }; + const d = r.json || {}, status = String(d.status || "").toUpperCase(), ready = d.audio_url || d.video_url || d.url; + if (status === "COMPLETED") { + const url = ready || downloadUrl; + if (!url) throw new Error("completed, but Venice sent no file"); + const f = await fetch(url); + if (!f.ok) throw new Error(`download failed (${f.status})`); + return { bytes: Buffer.from(await f.arrayBuffer()), type: f.headers.get("content-type") || "" }; + } + if (/FAIL|ERROR|CANCEL|REJECT|EXPIRE/.test(status)) throw new Error(d.error || `generation ${status.toLowerCase()}`); + } + throw new Error(`timed out after ${(POLL_MS * POLL_MAX) / 1000}s`); +} + +const ext = (type, dflt) => (/mp4/.test(type) ? "mp4" : /webm/.test(type) ? "webm" : /mpeg|mp3/.test(type) ? "mp3" : /wav/.test(type) ? "wav" : /ogg|opus/.test(type) ? "ogg" : /flac/.test(type) ? "flac" : /png/.test(type) ? "png" : /jpe?g/.test(type) ? "jpg" : /webp/.test(type) ? "webp" : dflt); + +function resolvePrompt(template, input) { + if (!template) return input; + if (template.includes("{{input}}")) return template.replace(/\{\{input\}\}/g, input); + return input ? `${template}\n\n${input}` : template; +} + +function inputsOf(node, graph) { + return graph.edges.filter((e) => e.target === node.id).map((e) => { + const p = join(OUT, e.source + ".txt"); + return existsSync(p) ? readFileSync(p, "utf8") : ""; + }).filter(Boolean).join("\n\n"); +} + +const mediaPath = (s, tag) => { const m = new RegExp(`\\[${tag}:([^\\]]+)\\]`).exec(s); return m ? m[1] : ""; }; + +async function runNode(node, graph) { + const d = node.data || {}, input = inputsOf(node, graph), file = (e) => join(OUT, `${node.id}.${e}`); + switch (d.nodeType) { + case "textInput": return d.inputText ?? ""; + case "output": return input; + case "step": return input; // a runner's own step: the workflow file runs it, not this + case "chat": { + const r = await venice("/chat/completions", { model: d.model || "llama-3.3-70b", messages: [{ role: "user", content: resolvePrompt(d.prompt, input) }], + temperature: d.temperature ?? 0.7, max_tokens: d.maxTokens ?? 4096, venice_parameters: { enable_web_search: d.webSearch ?? "off" } }); + return r.json?.choices?.[0]?.message?.content ?? ""; + } + case "imageGen": { + const body = { model: d.model || "z-image-turbo", prompt: resolvePrompt(d.prompt, input), negative_prompt: d.negativePrompt || undefined, steps: d.steps ?? 20, + style_preset: d.style || undefined, width: d.width ?? 1024, height: d.height ?? 1024, hide_watermark: d.hideWatermark ?? true }; + if (d.aspectRatio) body.aspect_ratio = d.aspectRatio; + const r = await venice("/image/generate", body); + const img = r.json?.images?.[0], b64 = typeof img === "string" ? img : img?.b64_json; + if (!b64) throw new Error("no image came back"); + const e = b64.startsWith("/9j/") ? "jpg" : b64.startsWith("UklGR") ? "webp" : "png"; + writeFileSync(file(e), Buffer.from(b64, "base64")); + return `[image:${file(e)}]`; + } + case "tts": { + const r = await venice("/audio/speech", { model: d.model || "tts-kokoro", input: resolvePrompt(d.prompt, input), voice: d.voice || "af_sky", speed: d.speed ?? 1, + response_format: d.responseFormat || "mp3" }, { binary: true }); + const e = d.responseFormat || ext(r.type, "mp3"); + writeFileSync(file(e), r.binary); + return `[audio:${file(e)}]`; + } + case "music": { + const body = { model: d.model || "stable-audio-25", prompt: resolvePrompt(d.prompt, input), duration_seconds: d.duration ?? 30, force_instrumental: d.instrumental ?? false }; + if (d.lyrics) body.lyrics_prompt = d.lyrics; + const q = (await venice("/audio/queue", body)).json || {}; + const { bytes, type } = await retrieve("audio", q.model || body.model, q.queue_id, q.download_url); + const e = ext(type, "mp3"); + writeFileSync(file(e), bytes); + return `[audio:${file(e)}]`; + } + case "video": { + const body = { model: d.model || "wan-3-0-text-to-video", prompt: resolvePrompt(d.prompt, input), aspect_ratio: d.videoAspectRatio || "16:9" }; + if (d.videoDuration) body.duration = d.videoDuration; + if (d.videoResolution) body.resolution = d.videoResolution; + const q = (await venice("/video/queue", body)).json || {}; + const { bytes, type } = await retrieve("video", q.model || body.model, q.queue_id || q.id, q.download_url); + const e = ext(type, "mp4"); + writeFileSync(file(e), bytes); + return `[video:${file(e)}]`; + } + case "compose": { + const image = mediaPath(input, "image"), audio = mediaPath(input, "audio"); + if (!image || !audio) throw new Error("Cover + Track needs one image node and one audio node connected to it"); + const side = Math.max(256, Math.min(2048, Number(d.maxSide) || 1080)); + const r = spawnSync("ffmpeg", ["-y", "-loglevel", "error", "-loop", "1", "-i", image, "-i", audio, "-c:v", "libx264", "-tune", "stillimage", "-preset", "medium", + "-vf", `scale='if(gt(iw,ih),${side},-2)':'if(gt(iw,ih),-2,${side})',pad=ceil(iw/2)*2:ceil(ih/2)*2`, "-c:a", "aac", "-b:a", "160k", "-pix_fmt", "yuv420p", "-shortest", "-movflags", "+faststart", file("mp4")], { encoding: "utf8" }); + if (r.error) throw new Error("ffmpeg is not installed (a Cover + Track node needs it)"); + if (r.status !== 0) throw new Error("ffmpeg: " + (r.stderr || "").trim().slice(-400)); + return `[video:${file("mp4")}]`; + } + default: throw new Error(`unknown node type ${d.nodeType}`); + } +} + +/** nodes in dependency order (a cycle is an error) */ +function order(graph) { + const indeg = new Map(graph.nodes.map((n) => [n.id, 0])), adj = new Map(graph.nodes.map((n) => [n.id, []])); + for (const e of graph.edges) { if (!indeg.has(e.source) || !indeg.has(e.target)) continue; adj.get(e.source).push(e.target); indeg.set(e.target, indeg.get(e.target) + 1); } + const out = []; + let frontier = graph.nodes.filter((n) => indeg.get(n.id) === 0).map((n) => n.id); + while (frontier.length) { + out.push(...frontier); + const next = []; + for (const id of frontier) for (const c of adj.get(id)) { indeg.set(c, indeg.get(c) - 1); if (indeg.get(c) === 0) next.push(c); } + frontier = next; + } + if (out.length !== graph.nodes.length) fail("the graph has a cycle"); + return out.map((id) => graph.nodes.find((n) => n.id === id)); +} + +async function main() { + const graph = loadGraph(); + mkdirSync(OUT, { recursive: true }); + const which = has("all") ? order(graph) : [graph.nodes.find((n) => n.id === flag("node"))].filter(Boolean); + if (!which.length) fail(`no such node: ${flag("node")} (nodes: ${graph.nodes.map((n) => n.id).join(", ")})`); + for (const node of which) { + const label = `${node.id} [${node.data?.nodeType}]`; + process.stdout.write(`${label}… `); + const started = Date.now(); + const result = await runNode(node, graph); + writeFileSync(join(OUT, node.id + ".txt"), result); + const shown = result.startsWith("[") ? result : result.replace(/\s+/g, " ").slice(0, 120) + (result.length > 120 ? "…" : ""); + console.log(`${((Date.now() - started) / 1000).toFixed(1)}s ${shown}`); + } +} + +main().catch((e) => fail(e.message || String(e))); diff --git a/ventures/havre/openvenice/README.md b/ventures/havre/openvenice/README.md index 6de2c61..81e34cd 100644 --- a/ventures/havre/openvenice/README.md +++ b/ventures/havre/openvenice/README.md @@ -24,6 +24,15 @@ has changed, so a newer upstream shows exactly which change needs redoing. - **Light and dark**, with Havre's look: Times and Courier, square corners, Havre's blue. The choice is `havre.theme` in localStorage, shared with Havre's own page ("light", "dark", or absent to follow the system). - **Phones**: a labeled "New chat" button, and no ⌘ shortcut hints. +- **Workflows and Gitea Actions are two views of one thing.** Export (the active workflow's header) writes a + workflow file that walks the graph on a runner with `public/run.mjs` (served at /open/run.mjs); the graph rides in + `env.OV_WORKFLOW`. Import (the list view) takes any Actions workflow: one exported from here comes back as it was; + any other becomes a chain of **Step** nodes, one per step, and the rest of the file (`on`, permissions, + concurrency, the job's `runs-on` and `env`) is kept as the workflow's frame, so it exports back identical, with + any Venice nodes spliced in as runner steps. A Step node is one Actions step as it is (run, uses, with, env): + inert in the browser, verbatim on export. A **Cover + Track** node records an image over an audio track into one + video (in the browser; ffmpeg on a runner). The first real workflow is the factory's venture loop, + `.github/workflows/venture-loop.yml` on teahubxyz/time: one step per stage, each `venture.py stage `. ## Changing it diff --git a/ventures/havre/openvenice/havre.py b/ventures/havre/openvenice/havre.py index 0ec35fe..dc2aaec 100644 --- a/ventures/havre/openvenice/havre.py +++ b/ventures/havre/openvenice/havre.py @@ -478,6 +478,895 @@ css += lift(':root[data-theme="light"]') + "\n@media (prefers-color-scheme: ligh with open(P, "w", encoding="utf-8") as f: f.write(css) +COMPOSE_TS = r"""/** + * Cover + Track: play a still image over an audio track and record the two into one video file, in the + * browser. No server and no ffmpeg: the image is drawn on a canvas, the audio is decoded by the Web Audio + * API, the canvas stream and the audio stream are recorded together by MediaRecorder. Recording runs in + * real time, so a 60-second track takes 60 seconds. The result is a blob: URL of an mp4 where the browser + * records mp4 (Safari, newer Chrome), otherwise webm. + */ + +const MIME_CANDIDATES = [ + 'video/mp4;codecs="avc1.42E01E,mp4a.40.2"', + 'video/mp4;codecs=avc1,mp4a.40.2', + 'video/mp4', + 'video/webm;codecs=vp9,opus', + 'video/webm;codecs=vp8,opus', + 'video/webm', +] + +export function pickRecorderMime(): string { + if (typeof MediaRecorder === 'undefined') return '' + for (const m of MIME_CANDIDATES) { + try { if (MediaRecorder.isTypeSupported(m)) return m } catch { /* next */ } + } + return '' +} + +function loadImage(src: string): Promise { + return new Promise((resolve, reject) => { + const img = new Image() + img.onload = () => resolve(img) + img.onerror = () => reject(new Error('Could not load the cover image')) + img.src = src + }) +} + +function even(n: number): number { + return Math.max(2, Math.round(n / 2) * 2) +} + +export interface ComposeOptions { + /** longest side of the video, px (the cover keeps its own aspect ratio) */ + maxSide?: number + fps?: number + signal?: AbortSignal + onProgress?: (seconds: number, total: number) => void +} + +export async function composeCoverTrack(imageSrc: string, audioSrc: string, opts: ComposeOptions = {}): Promise { + if (typeof MediaRecorder === 'undefined' || !('captureStream' in HTMLCanvasElement.prototype)) { + throw new Error('This browser cannot record video (no MediaRecorder)') + } + const mime = pickRecorderMime() + if (!mime) throw new Error('This browser has no video format MediaRecorder can write') + const { signal, onProgress } = opts + const fps = opts.fps ?? 24 + const maxSide = opts.maxSide ?? 1080 + + const [img, audioBuf] = await Promise.all([ + loadImage(imageSrc), + fetch(audioSrc, { signal }).then((r) => { + if (!r.ok) throw new Error(`Could not fetch the track (${r.status})`) + return r.arrayBuffer() + }), + ]) + if (signal?.aborted) throw new DOMException('Aborted', 'AbortError') + + const scale = Math.min(1, maxSide / Math.max(img.naturalWidth, img.naturalHeight)) + const canvas = document.createElement('canvas') + canvas.width = even(img.naturalWidth * scale) + canvas.height = even(img.naturalHeight * scale) + const ctx2d = canvas.getContext('2d') + if (!ctx2d) throw new Error('No 2d canvas') + const draw = () => ctx2d.drawImage(img, 0, 0, canvas.width, canvas.height) + draw() + + const ac = new AudioContext() + try { await ac.resume() } catch { /* runs anyway */ } + const buffer = await ac.decodeAudioData(audioBuf) + const total = buffer.duration + const dest = ac.createMediaStreamDestination() + const source = ac.createBufferSource() + source.buffer = buffer + source.connect(dest) + + const stream = new MediaStream([ + ...canvas.captureStream(fps).getVideoTracks(), + ...dest.stream.getAudioTracks(), + ]) + const recorder = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 2_500_000, audioBitsPerSecond: 160_000 }) + const chunks: Blob[] = [] + recorder.ondataavailable = (e) => { if (e.data.size > 0) chunks.push(e.data) } + + // keep frames flowing: captureStream only emits when the canvas changes + const ticker = window.setInterval(draw, 1000 / Math.min(fps, 10)) + const started = performance.now() + const progress = window.setInterval(() => onProgress?.(Math.min(total, (performance.now() - started) / 1000), total), 1000) + + const cleanup = () => { + window.clearInterval(ticker) + window.clearInterval(progress) + stream.getTracks().forEach((t) => t.stop()) + void ac.close().catch(() => undefined) + } + + return new Promise((resolve, reject) => { + let finished = false + const finish = () => { + if (finished) return + finished = true + cleanup() + if (signal?.aborted) { reject(new DOMException('Aborted', 'AbortError')); return } + const blob = new Blob(chunks, { type: mime.split(';')[0] }) + if (blob.size === 0) { reject(new Error('Recording produced no data')); return } + resolve(URL.createObjectURL(blob)) + } + recorder.onstop = finish + recorder.onerror = () => { cleanup(); reject(new Error('Recording failed')) } + source.onended = () => { window.setTimeout(() => { if (recorder.state !== 'inactive') recorder.stop() }, 250) } + signal?.addEventListener('abort', () => { + try { source.stop() } catch { /* already stopped */ } + if (recorder.state !== 'inactive') recorder.stop(); else finish() + }, { once: true }) + recorder.start(1000) + source.start() + }) +} + +export function recorderFileExtension(): string { + return pickRecorderMime().startsWith('video/mp4') ? 'mp4' : 'webm' +} +""" + +# ---------- workflows: a Cover + Track node, so a cover image and a music track come out as one video ---------- +# Venice has no compositing endpoint, so the node records the still over the track in the browser (canvas + +# Web Audio + MediaRecorder; real time, mp4 where the browser can write it, else webm). The playground agent +# used to be told music and video can't be combined; now it's told to use this node. +write(S + "lib/compose.ts", COMPOSE_TS) + +edit(S + "stores/workflow-store.ts", + ("export type VeniceNodeType = 'chat' | 'imageGen' | 'tts' | 'music' | 'video' | 'textInput' | 'output'", + "export type VeniceNodeType = 'chat' | 'imageGen' | 'tts' | 'music' | 'video' | 'compose' | 'textInput' | 'output'"), + (" // Text input\n inputText?: string\n", + " // Text input\n inputText?: string\n // Compose (cover + track)\n maxSide?: number\n")) + +edit(S + "lib/workflow-schema.ts", + (""" { name: 'videoResolution', type: 'enum', description: 'Resolution. Empty means model default.', default: '', enumValues: VIDEO_RESOLUTION_VALUES }, + ], + }, +}""", """ { name: 'videoResolution', type: 'enum', description: 'Resolution. Empty means model default.', default: '', enumValues: VIDEO_RESOLUTION_VALUES }, + ], + }, + compose: { + type: 'compose', + label: 'Cover + Track', + description: 'Combines an upstream image and an upstream audio clip into one video file: the image stays on screen while the audio plays. Connect exactly one image node (imageGen) and one audio node (music or tts) to it. Recorded in the browser in real time (a 60s track takes 60s). No model, no prompt.', + input: 'text', + output: 'video', + params: [ + { name: 'maxSide', type: 'number', description: 'Longest side of the video in pixels; the cover keeps its aspect ratio.', default: 1080, min: 256, max: 2048 }, + ], + }, +}""")) + +edit(S + "lib/workflow-engine.ts", + ("import { validateWorkflow } from './workflow-validator'\n", + "import { validateWorkflow } from './workflow-validator'\nimport { composeCoverTrack } from './compose'\n"), + (""" case 'textInput': + return data.inputText ?? '' +""", """ case 'textInput': + return data.inputText ?? '' + + case 'compose': { + const image = /\\[image:([^\\]]+)\\]/.exec(input)?.[1] + const audio = /\\[audio:([^\\]]+)\\]/.exec(input)?.[1] + if (!image || !audio) { + const has = [image && 'an image', audio && 'audio'].filter(Boolean).join(' and ') || 'neither' + throw new Error(`Cover + Track needs one image node and one audio node connected to it (got ${has})`) + } + const url = await composeCoverTrack(image, audio, { maxSide: data.maxSide ?? 1080, signal }) + return `[video:${url}]` + } +""")) + +# the playground agent: compose is a node type it may add (no model), and the old "can't combine" rule is gone +P = S + "lib/playground-agent-tools.ts" +edit(P, + (" enum: ['chat', 'imageGen', 'tts', 'music', 'video'],", + " enum: ['chat', 'imageGen', 'tts', 'music', 'video', 'compose'],"), + ("""9. **For social-video / reel requests**: canonical shape is textInput → chat(research, web) → chat(script) → video (9:16, 1080p, 5-10s) → output. For music: add a SEPARATE branch (textInput → music → output) — DO NOT connect music nodes to video nodes; they can't compose into a single AV file from this engine. Each modality gets its own output.""", + """9. **For social-video / reel requests**: canonical shape is textInput → chat(research, web) → chat(script) → video (9:16, 1080p, 5-10s) → output. Video models cannot take an audio track, so never connect music or tts to a video node. +9b. **To combine a picture with a sound** (a cover that shows while a track plays, a slideshow still with narration, a music video from a still): use a compose node ("Cover + Track"). Connect one imageGen node and one music (or tts) node into it, and connect it to an output. It has no model and no prompt. Shape: textInput → imageGen (cover) and textInput → music (track), both → compose → output. The output is one video file the user can preview and download."""), + (" if (nodeType === 'video') return c.video.includes(modelId)\n return true // textInput / output don't have models", + " if (nodeType === 'video') return c.video.includes(modelId)\n return true // textInput / output / compose don't have models")) + +edit(S + "lib/playground-agent.ts", + ("""7. Use {{input}} inside a node's prompt to place upstream text precisely, or leave prompt empty to append input after.""", + """7. Use {{input}} inside a node's prompt to place upstream text precisely, or leave prompt empty to append input after. +7b. To show a picture while a sound plays (cover + track, still + narration), add a "compose" node with one imageGen and one music/tts node connected into it, then connect it to an output. It has no model or prompt. Video models cannot take audio, so never connect music or tts to a video node.""")) + +# the canvas: a palette entry, a node card without model or prompt, and videos that play in place +P = S + "components/workflows/workflows-view.tsx" +edit(P, + (" { type: 'video', label: 'Video Gen', Icon: PaletteVideoIcon, color: 'text-orange-400/50' },\n", + " { type: 'video', label: 'Video Gen', Icon: PaletteVideoIcon, color: 'text-orange-400/50' },\n { type: 'compose', label: 'Cover + Track', Icon: PaletteComposeIcon, color: 'text-cyan-400/50' },\n"), + ("function PaletteOutputIcon() {", + """function PaletteComposeIcon() { + return +} +function PaletteOutputIcon() {"""), + (" video: 'wan-2.1',\n}", " video: 'wan-2.1',\n compose: '',\n}")) + +P = S + "components/workflows/workflow-node.tsx" +edit(P, + (" video: 'video',\n}", " video: 'video',\n compose: undefined,\n}"), + (" video: { label: 'Video Gen', Icon: VideoIcon, color: 'border-orange-500/30', hasInput: true, hasOutput: true },\n", + " video: { label: 'Video Gen', Icon: VideoIcon, color: 'border-orange-500/30', hasInput: true, hasOutput: true },\n compose: { label: 'Cover + Track', Icon: ComposeIcon, color: 'border-cyan-500/30', hasInput: true, hasOutput: true },\n"), + ("\nfunction OutputIcon() {", """ +function ComposeIcon() { + return +} + +function OutputIcon() {"""), + (""" ) : data.nodeType === 'textInput' ? ( + +

    Shows the connected image while the connected audio plays, recorded here in your browser into one video (takes as long as the track).

    +
    + max side + updateNode({ maxSide: Number(e.target.value) || 1080 })} + className={cn(inputCls, 'w-24')} + /> + px +
    + + ) : data.nodeType === 'textInput' ? ( + Open video""", + """