From 795fe2ddcd7ff38a74e925945c63447e606c05ae Mon Sep 17 00:00:00 2001 From: Cristian Pufu Date: Sat, 21 Feb 2026 16:33:29 +0200 Subject: [PATCH] feat: add Events tab in conversation mode Show a separate Events tab alongside Chat when running in conversational mode, so users can monitor state events without leaving the chat view. Bump version to 0.0.56. Co-Authored-By: Claude Opus 4.6 --- pyproject.toml | 2 +- .../src/components/runs/RunDetailsPanel.tsx | 27 ++++++++++++------- ...anel-CllakF8w.js => ChatPanel-DvMLkYmo.js} | 2 +- .../{index-DMrhDX0F.js => index-AXT426N7.js} | 16 +++++------ src/uipath/dev/server/static/index.html | 2 +- uv.lock | 2 +- 6 files changed, 29 insertions(+), 22 deletions(-) rename src/uipath/dev/server/static/assets/{ChatPanel-CllakF8w.js => ChatPanel-DvMLkYmo.js} (99%) rename src/uipath/dev/server/static/assets/{index-DMrhDX0F.js => index-AXT426N7.js} (56%) diff --git a/pyproject.toml b/pyproject.toml index de376cb..3ee1904 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-dev" -version = "0.0.55" +version = "0.0.56" description = "UiPath Developer Console" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/dev/server/frontend/src/components/runs/RunDetailsPanel.tsx b/src/uipath/dev/server/frontend/src/components/runs/RunDetailsPanel.tsx index c2425c2..e2b9fbb 100644 --- a/src/uipath/dev/server/frontend/src/components/runs/RunDetailsPanel.tsx +++ b/src/uipath/dev/server/frontend/src/components/runs/RunDetailsPanel.tsx @@ -10,8 +10,8 @@ import RunEventsPanel from "./RunEventsPanel"; import JsonHighlight from "../shared/JsonHighlight"; import DebugControls from "../debug/DebugControls"; -type SidebarTab = "primary" | "io" | "logs"; -type MobileTab = "traces" | "primary" | "io" | "logs"; +type SidebarTab = "primary" | "events" | "io" | "logs"; +type MobileTab = "traces" | "primary" | "events" | "io" | "logs"; interface Props { run: RunSummary; @@ -131,6 +131,9 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { const primaryLabel = isChatMode ? "Chat" : "Events"; const primaryColor = isChatMode ? "var(--accent)" : "var(--success)"; + const tabColor = (id: string) => + id === "primary" ? primaryColor : id === "events" ? "var(--success)" : "var(--accent)"; + const interrupt = useRunStore((s) => s.activeInterrupt[run.id] ?? null); // Status indicator for the tab bar @@ -162,6 +165,7 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { const mobileTabs: { id: MobileTab; label: string; count?: number }[] = [ { id: "traces", label: "Traces", count: traces.length }, { id: "primary", label: primaryLabel }, + ...(isChatMode ? [{ id: "events" as const, label: "Events", count: stateEvents.length }] : []), { id: "io", label: "I/O" }, { id: "logs", label: "Logs", count: logs.length }, ]; @@ -189,13 +193,11 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { style={{ color: mobileTab === tab.id - ? tab.id === "primary" - ? primaryColor - : "var(--accent)" + ? tabColor(tab.id) : "var(--text-muted)", background: mobileTab === tab.id - ? `color-mix(in srgb, ${tab.id === "primary" ? primaryColor : "var(--accent)"} 10%, transparent)` + ? `color-mix(in srgb, ${tabColor(tab.id)} 10%, transparent)` : "transparent", }} > @@ -228,6 +230,9 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { ) )} + {mobileTab === "events" && ( + + )} {mobileTab === "io" && ( )} @@ -242,6 +247,7 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { // Desktop layout (unchanged) const sidebarTabs: { id: SidebarTab; label: string; count?: number }[] = [ { id: "primary", label: primaryLabel }, + ...(isChatMode ? [{ id: "events" as const, label: "Events", count: stateEvents.length }] : []), { id: "io", label: "I/O" }, { id: "logs", label: "Logs", count: logs.length }, ]; @@ -299,13 +305,11 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { style={{ color: sidebarTab === tab.id - ? tab.id === "primary" - ? primaryColor - : "var(--accent)" + ? tabColor(tab.id) : "var(--text-muted)", background: sidebarTab === tab.id - ? `color-mix(in srgb, ${tab.id === "primary" ? primaryColor : "var(--accent)"} 10%, transparent)` + ? `color-mix(in srgb, ${tabColor(tab.id)} 10%, transparent)` : "transparent", }} onMouseEnter={(e) => { @@ -342,6 +346,9 @@ export default function RunDetailsPanel({ run, ws, isMobile }: Props) { ) )} + {sidebarTab === "events" && ( + + )} {sidebarTab === "io" && ( )} diff --git a/src/uipath/dev/server/static/assets/ChatPanel-CllakF8w.js b/src/uipath/dev/server/static/assets/ChatPanel-DvMLkYmo.js similarity index 99% rename from src/uipath/dev/server/static/assets/ChatPanel-CllakF8w.js rename to src/uipath/dev/server/static/assets/ChatPanel-DvMLkYmo.js index fda3c96..11d0f40 100644 --- a/src/uipath/dev/server/static/assets/ChatPanel-CllakF8w.js +++ b/src/uipath/dev/server/static/assets/ChatPanel-DvMLkYmo.js @@ -1,4 +1,4 @@ -import{g as hr,j as P,a as $e}from"./vendor-react-BVoutfaX.js";import{u as sn}from"./index-DMrhDX0F.js";import"./vendor-reactflow-mU21rT8r.js";function zo(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Uo=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$o=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ho={};function Vr(e,t){return(Ho.jsx?$o:Uo).test(e)}const Go=/[ \t\n\f\r]/g;function Ko(e){return typeof e=="object"?e.type==="text"?Yr(e.value):!1:Yr(e)}function Yr(e){return e.replace(Go,"")===""}class jt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}jt.prototype.normal={};jt.prototype.property={};jt.prototype.space=void 0;function Yi(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new jt(n,r,t)}function ir(e){return e.toLowerCase()}class De{constructor(t,n){this.attribute=n,this.property=t}}De.prototype.attribute="";De.prototype.booleanish=!1;De.prototype.boolean=!1;De.prototype.commaOrSpaceSeparated=!1;De.prototype.commaSeparated=!1;De.prototype.defined=!1;De.prototype.mustUseProperty=!1;De.prototype.number=!1;De.prototype.overloadedBoolean=!1;De.prototype.property="";De.prototype.spaceSeparated=!1;De.prototype.space=void 0;let qo=0;const ee=Et(),ke=Et(),ar=Et(),C=Et(),be=Et(),Ct=Et(),Ue=Et();function Et(){return 2**++qo}const or=Object.freeze(Object.defineProperty({__proto__:null,boolean:ee,booleanish:ke,commaOrSpaceSeparated:Ue,commaSeparated:Ct,number:C,overloadedBoolean:ar,spaceSeparated:be},Symbol.toStringTag,{value:"Module"})),Fn=Object.keys(or);class br extends De{constructor(t,n,r,i){let o=-1;if(super(t,n),jr(this,"space",i),typeof r=="number")for(;++o4&&n.slice(0,4)==="data"&&Zo.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Zr,Jo);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Zr.test(o)){let a=o.replace(jo,Qo);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=br}return new i(r,t)}function Qo(e){return"-"+e.toLowerCase()}function Jo(e){return e.charAt(1).toUpperCase()}const es=Yi([ji,Wo,Qi,Ji,ea],"html"),Er=Yi([ji,Vo,Qi,Ji,ea],"svg");function ts(e){return e.join(" ").trim()}var wt={},zn,Xr;function ns(){if(Xr)return zn;Xr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` +import{g as hr,j as P,a as $e}from"./vendor-react-BVoutfaX.js";import{u as sn}from"./index-AXT426N7.js";import"./vendor-reactflow-mU21rT8r.js";function zo(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Uo=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$o=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ho={};function Vr(e,t){return(Ho.jsx?$o:Uo).test(e)}const Go=/[ \t\n\f\r]/g;function Ko(e){return typeof e=="object"?e.type==="text"?Yr(e.value):!1:Yr(e)}function Yr(e){return e.replace(Go,"")===""}class jt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}jt.prototype.normal={};jt.prototype.property={};jt.prototype.space=void 0;function Yi(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new jt(n,r,t)}function ir(e){return e.toLowerCase()}class De{constructor(t,n){this.attribute=n,this.property=t}}De.prototype.attribute="";De.prototype.booleanish=!1;De.prototype.boolean=!1;De.prototype.commaOrSpaceSeparated=!1;De.prototype.commaSeparated=!1;De.prototype.defined=!1;De.prototype.mustUseProperty=!1;De.prototype.number=!1;De.prototype.overloadedBoolean=!1;De.prototype.property="";De.prototype.spaceSeparated=!1;De.prototype.space=void 0;let qo=0;const ee=Et(),ke=Et(),ar=Et(),C=Et(),be=Et(),Ct=Et(),Ue=Et();function Et(){return 2**++qo}const or=Object.freeze(Object.defineProperty({__proto__:null,boolean:ee,booleanish:ke,commaOrSpaceSeparated:Ue,commaSeparated:Ct,number:C,overloadedBoolean:ar,spaceSeparated:be},Symbol.toStringTag,{value:"Module"})),Fn=Object.keys(or);class br extends De{constructor(t,n,r,i){let o=-1;if(super(t,n),jr(this,"space",i),typeof r=="number")for(;++o4&&n.slice(0,4)==="data"&&Zo.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Zr,Jo);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Zr.test(o)){let a=o.replace(jo,Qo);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=br}return new i(r,t)}function Qo(e){return"-"+e.toLowerCase()}function Jo(e){return e.charAt(1).toUpperCase()}const es=Yi([ji,Wo,Qi,Ji,ea],"html"),Er=Yi([ji,Vo,Qi,Ji,ea],"svg");function ts(e){return e.join(" ").trim()}var wt={},zn,Xr;function ns(){if(Xr)return zn;Xr=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,l=` `,c="/",d="*",u="",f="comment",p="declaration";function g(x,m){if(typeof x!="string")throw new TypeError("First argument must be a string");if(!x)return[];m=m||{};var k=1,w=1;function T(D){var O=D.match(t);O&&(k+=O.length);var j=D.lastIndexOf(l);w=~j?D.length-j:w+D.length}function A(){var D={line:k,column:w};return function(O){return O.position=new _(D),G(),O}}function _(D){this.start=D,this.end={line:k,column:w},this.source=m.source}_.prototype.content=x;function $(D){var O=new Error(m.source+":"+k+":"+w+": "+D);if(O.reason=D,O.filename=m.source,O.line=k,O.column=w,O.source=x,!m.silent)throw O}function H(D){var O=D.exec(x);if(O){var j=O[0];return T(j),x=x.slice(j.length),O}}function G(){H(n)}function S(D){var O;for(D=D||[];O=B();)O!==!1&&D.push(O);return D}function B(){var D=A();if(!(c!=x.charAt(0)||d!=x.charAt(1))){for(var O=2;u!=x.charAt(O)&&(d!=x.charAt(O)||c!=x.charAt(O+1));)++O;if(O+=2,u===x.charAt(O-1))return $("End of comment missing");var j=x.slice(2,O-2);return w+=2,T(j),x=x.slice(O),w+=2,D({type:f,comment:j})}}function F(){var D=A(),O=H(r);if(O){if(B(),!H(i))return $("property missing ':'");var j=H(o),se=D({type:p,property:y(O[0].replace(e,u)),value:j?y(j[0].replace(e,u)):u});return H(a),se}}function J(){var D=[];S(D);for(var O;O=F();)O!==!1&&(D.push(O),S(D));return D}return G(),J()}function y(x){return x?x.replace(s,u):u}return zn=g,zn}var Qr;function rs(){if(Qr)return wt;Qr=1;var e=wt&&wt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(wt,"__esModule",{value:!0}),wt.default=n;const t=e(ns());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),s=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:d}=l;s?i(c,d,l):d&&(o=o||{},o[c]=d)}),o}return wt}var Ft={},Jr;function is(){if(Jr)return Ft;Jr=1,Object.defineProperty(Ft,"__esModule",{value:!0}),Ft.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(c){return!c||n.test(c)||e.test(c)},a=function(c,d){return d.toUpperCase()},s=function(c,d){return"".concat(d,"-")},l=function(c,d){return d===void 0&&(d={}),o(c)?c:(c=c.toLowerCase(),d.reactCompat?c=c.replace(i,s):c=c.replace(r,s),c.replace(t,a))};return Ft.camelCase=l,Ft}var zt,ei;function as(){if(ei)return zt;ei=1;var e=zt&&zt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(rs()),n=is();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(s,l){s&&l&&(a[(0,n.camelCase)(s,o)]=l)}),a}return r.default=r,zt=r,zt}var os=as();const ss=hr(os),ta=na("end"),yr=na("start");function na(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function ls(e){const t=yr(e),n=ta(e);if(t&&n)return{start:t,end:n}}function Kt(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ti(e.position):"start"in e||"end"in e?ti(e):"line"in e||"column"in e?sr(e):""}function sr(e){return ni(e&&e.line)+":"+ni(e&&e.column)}function ti(e){return sr(e&&e.start)+"-"+sr(e&&e.end)}function ni(e){return e&&typeof e=="number"?e:1}class Ae extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=Kt(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ae.prototype.file="";Ae.prototype.name="";Ae.prototype.reason="";Ae.prototype.message="";Ae.prototype.stack="";Ae.prototype.column=void 0;Ae.prototype.line=void 0;Ae.prototype.ancestors=void 0;Ae.prototype.cause=void 0;Ae.prototype.fatal=void 0;Ae.prototype.place=void 0;Ae.prototype.ruleId=void 0;Ae.prototype.source=void 0;const _r={}.hasOwnProperty,cs=new Map,us=/[A-Z]/g,ds=new Set(["table","tbody","thead","tfoot","tr"]),ps=new Set(["td","th"]),ra="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function fs(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=xs(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=_s(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Er:es,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=ia(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function ia(e,t,n){if(t.type==="element")return gs(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ms(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return bs(e,t,n);if(t.type==="mdxjsEsm")return hs(e,t);if(t.type==="root")return Es(e,t,n);if(t.type==="text")return ys(e,t)}function gs(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Er,e.schema=i),e.ancestors.push(t);const o=oa(e,t.tagName,!1),a=ks(e,t);let s=kr(e,t);return ds.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!Ko(l):!0})),aa(e,a,o,t),xr(a,s),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function ms(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Vt(e,t.position)}function hs(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Vt(e,t.position)}function bs(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Er,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:oa(e,t.name,!0),a=ws(e,t),s=kr(e,t);return aa(e,a,o,t),xr(a,s),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function Es(e,t,n){const r={};return xr(r,kr(e,t)),e.create(t,e.Fragment,r,n)}function ys(e,t){return t.value}function aa(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function xr(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function _s(e,t,n){return r;function r(i,o,a,s){const c=Array.isArray(a.children)?n:t;return s?c(o,a,s):c(o,a)}}function xs(e,t){return n;function n(r,i,o,a){const s=Array.isArray(o.children),l=yr(r);return t(i,o,a,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function ks(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&_r.call(t.properties,i)){const o=Ss(e,i,t.properties[i]);if(o){const[a,s]=o;e.tableCellAlignToStyle&&a==="align"&&typeof s=="string"&&ps.has(t.tagName)?r=s:n[a]=s}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ws(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const s=a.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else Vt(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,o=e.evaluater.evaluateExpression(s.expression)}else Vt(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function kr(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:cs;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o0?(He(e,e.length,0,t),e):t}const ai={}.hasOwnProperty;function la(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ve(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Re=ft(/[A-Za-z]/),Te=ft(/[\dA-Za-z]/),Ms=ft(/[#-'*+\--9=?A-Z^-~]/);function yn(e){return e!==null&&(e<32||e===127)}const lr=ft(/\d/),Ds=ft(/[\dA-Fa-f]/),Ls=ft(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function ge(e){return e!==null&&(e<0||e===32)}function re(e){return e===-2||e===-1||e===32}const Nn=ft(new RegExp("\\p{P}|\\p{S}","u")),bt=ft(/\s/);function ft(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Rt(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&o<57344){const s=e.charCodeAt(n+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ae(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(l){return re(l)?(e.enter(n),s(l)):t(l)}function s(l){return re(l)&&o++a))return;const $=t.events.length;let H=$,G,S;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(G){S=t.events[H][1].end;break}G=!0}for(m(r),_=$;_w;){const A=n[T];t.containerState=A[1],A[0].exit.call(t,e)}n.length=w}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Us(e,t,n){return ae(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ot(e){if(e===null||ge(e)||bt(e))return 1;if(Nn(e))return 2}function vn(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const u={...e[r][1].end},f={...e[n][1].start};si(u,-l),si(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},o={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[n][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=Ke(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=Ke(c,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),c=Ke(c,vn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=Ke(c,[["exit",o,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,c=Ke(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,He(e,r-1,n-r+3,c),n=r+c.length-d-2;break}}for(n=-1;++n0&&re(_)?ae(e,k,"linePrefix",o+1)(_):k(_)}function k(_){return _===null||W(_)?e.check(li,y,T)(_):(e.enter("codeFlowValue"),w(_))}function w(_){return _===null||W(_)?(e.exit("codeFlowValue"),k(_)):(e.consume(_),w)}function T(_){return e.exit("codeFenced"),t(_)}function A(_,$,H){let G=0;return S;function S(O){return _.enter("lineEnding"),_.consume(O),_.exit("lineEnding"),B}function B(O){return _.enter("codeFencedFence"),re(O)?ae(_,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):F(O)}function F(O){return O===s?(_.enter("codeFencedFenceSequence"),J(O)):H(O)}function J(O){return O===s?(G++,_.consume(O),J):G>=a?(_.exit("codeFencedFenceSequence"),re(O)?ae(_,D,"whitespace")(O):D(O)):H(O)}function D(O){return O===null||W(O)?(_.exit("codeFencedFence"),$(O)):H(O)}}}function Qs(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const $n={name:"codeIndented",tokenize:el},Js={partial:!0,tokenize:tl};function el(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),ae(e,o,"linePrefix",5)(c)}function o(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):W(c)?e.attempt(Js,a,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||W(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),t(c)}}function tl(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):W(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ae(e,o,"linePrefix",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):W(a)?i(a):n(a)}}const nl={name:"codeText",previous:il,resolve:rl,tokenize:al};function rl(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ut(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ut(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ut(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function ga(e,t,n,r,i,o,a,s,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return u;function u(m){return m===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(m),e.exit(o),f):m===null||m===32||m===41||yn(m)?n(m):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),y(m))}function f(m){return m===62?(e.enter(o),e.consume(m),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===62?(e.exit("chunkString"),e.exit(s),f(m)):m===null||m===60||W(m)?n(m):(e.consume(m),m===92?g:p)}function g(m){return m===60||m===62||m===92?(e.consume(m),p):p(m)}function y(m){return!d&&(m===null||m===41||ge(m))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),t(m)):d999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(o),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):W(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===null||p===91||p===93||W(p)||s++>999?(e.exit("chunkString"),d(p)):(e.consume(p),l||(l=!re(p)),p===92?f:u)}function f(p){return p===91||p===92||p===93?(e.consume(p),s++,u):u(p)}}function ha(e,t,n,r,i,o){let a;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),a=f===40?41:f,l):n(f)}function l(f){return f===a?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(o),c(f))}function c(f){return f===a?(e.exit(o),l(a)):f===null?n(f):W(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),ae(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===a||f===null||W(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?u:d)}function u(f){return f===a||f===92?(e.consume(f),d):d(f)}}function qt(e,t){let n;return r;function r(i){return W(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):re(i)?ae(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const fl={name:"definition",tokenize:ml},gl={partial:!0,tokenize:hl};function ml(e,t,n){const r=this;let i;return o;function o(p){return e.enter("definition"),a(p)}function a(p){return ma.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return i=Ve(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ge(p)?qt(e,c)(p):c(p)}function c(p){return ga(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(gl,u,u)(p)}function u(p){return re(p)?ae(e,f,"whitespace")(p):f(p)}function f(p){return p===null||W(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function hl(e,t,n){return r;function r(s){return ge(s)?qt(e,i)(s):n(s)}function i(s){return ha(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function o(s){return re(s)?ae(e,a,"whitespace")(s):a(s)}function a(s){return s===null||W(s)?t(s):n(s)}}const bl={name:"hardBreakEscape",tokenize:El};function El(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return W(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const yl={name:"headingAtx",resolve:_l,tokenize:xl};function _l(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},He(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function xl(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||ge(d)?(e.exit("atxHeadingSequence"),s(d)):n(d)}function s(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||W(d)?(e.exit("atxHeading"),t(d)):re(d)?ae(e,s,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),s(d))}function c(d){return d===null||d===35||ge(d)?(e.exit("atxHeadingText"),s(d)):(e.consume(d),c)}}const kl=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ui=["pre","script","style","textarea"],wl={concrete:!0,name:"htmlFlow",resolveTo:vl,tokenize:Tl},Sl={partial:!0,tokenize:Cl},Nl={partial:!0,tokenize:Al};function vl(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Tl(e,t,n){const r=this;let i,o,a,s,l;return c;function c(E){return d(E)}function d(E){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(E),u}function u(E){return E===33?(e.consume(E),f):E===47?(e.consume(E),o=!0,y):E===63?(e.consume(E),i=3,r.interrupt?t:h):Re(E)?(e.consume(E),a=String.fromCharCode(E),x):n(E)}function f(E){return E===45?(e.consume(E),i=2,p):E===91?(e.consume(E),i=5,s=0,g):Re(E)?(e.consume(E),i=4,r.interrupt?t:h):n(E)}function p(E){return E===45?(e.consume(E),r.interrupt?t:h):n(E)}function g(E){const Ce="CDATA[";return E===Ce.charCodeAt(s++)?(e.consume(E),s===Ce.length?r.interrupt?t:F:g):n(E)}function y(E){return Re(E)?(e.consume(E),a=String.fromCharCode(E),x):n(E)}function x(E){if(E===null||E===47||E===62||ge(E)){const Ce=E===47,Ge=a.toLowerCase();return!Ce&&!o&&ui.includes(Ge)?(i=1,r.interrupt?t(E):F(E)):kl.includes(a.toLowerCase())?(i=6,Ce?(e.consume(E),m):r.interrupt?t(E):F(E)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(E):o?k(E):w(E))}return E===45||Te(E)?(e.consume(E),a+=String.fromCharCode(E),x):n(E)}function m(E){return E===62?(e.consume(E),r.interrupt?t:F):n(E)}function k(E){return re(E)?(e.consume(E),k):S(E)}function w(E){return E===47?(e.consume(E),S):E===58||E===95||Re(E)?(e.consume(E),T):re(E)?(e.consume(E),w):S(E)}function T(E){return E===45||E===46||E===58||E===95||Te(E)?(e.consume(E),T):A(E)}function A(E){return E===61?(e.consume(E),_):re(E)?(e.consume(E),A):w(E)}function _(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),l=E,$):re(E)?(e.consume(E),_):H(E)}function $(E){return E===l?(e.consume(E),l=null,G):E===null||W(E)?n(E):(e.consume(E),$)}function H(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||ge(E)?A(E):(e.consume(E),H)}function G(E){return E===47||E===62||re(E)?w(E):n(E)}function S(E){return E===62?(e.consume(E),B):n(E)}function B(E){return E===null||W(E)?F(E):re(E)?(e.consume(E),B):n(E)}function F(E){return E===45&&i===2?(e.consume(E),j):E===60&&i===1?(e.consume(E),se):E===62&&i===4?(e.consume(E),ue):E===63&&i===3?(e.consume(E),h):E===93&&i===5?(e.consume(E),pe):W(E)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Sl,fe,J)(E)):E===null||W(E)?(e.exit("htmlFlowData"),J(E)):(e.consume(E),F)}function J(E){return e.check(Nl,D,fe)(E)}function D(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),O}function O(E){return E===null||W(E)?J(E):(e.enter("htmlFlowData"),F(E))}function j(E){return E===45?(e.consume(E),h):F(E)}function se(E){return E===47?(e.consume(E),a="",Z):F(E)}function Z(E){if(E===62){const Ce=a.toLowerCase();return ui.includes(Ce)?(e.consume(E),ue):F(E)}return Re(E)&&a.length<8?(e.consume(E),a+=String.fromCharCode(E),Z):F(E)}function pe(E){return E===93?(e.consume(E),h):F(E)}function h(E){return E===62?(e.consume(E),ue):E===45&&i===2?(e.consume(E),h):F(E)}function ue(E){return E===null||W(E)?(e.exit("htmlFlowData"),fe(E)):(e.consume(E),ue)}function fe(E){return e.exit("htmlFlow"),t(E)}}function Al(e,t,n){const r=this;return i;function i(a){return W(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Cl(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Zt,t,n)}}const Ol={name:"htmlText",tokenize:Il};function Il(e,t,n){const r=this;let i,o,a;return s;function s(h){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(h),l}function l(h){return h===33?(e.consume(h),c):h===47?(e.consume(h),A):h===63?(e.consume(h),w):Re(h)?(e.consume(h),H):n(h)}function c(h){return h===45?(e.consume(h),d):h===91?(e.consume(h),o=0,g):Re(h)?(e.consume(h),k):n(h)}function d(h){return h===45?(e.consume(h),p):n(h)}function u(h){return h===null?n(h):h===45?(e.consume(h),f):W(h)?(a=u,se(h)):(e.consume(h),u)}function f(h){return h===45?(e.consume(h),p):u(h)}function p(h){return h===62?j(h):h===45?f(h):u(h)}function g(h){const ue="CDATA[";return h===ue.charCodeAt(o++)?(e.consume(h),o===ue.length?y:g):n(h)}function y(h){return h===null?n(h):h===93?(e.consume(h),x):W(h)?(a=y,se(h)):(e.consume(h),y)}function x(h){return h===93?(e.consume(h),m):y(h)}function m(h){return h===62?j(h):h===93?(e.consume(h),m):y(h)}function k(h){return h===null||h===62?j(h):W(h)?(a=k,se(h)):(e.consume(h),k)}function w(h){return h===null?n(h):h===63?(e.consume(h),T):W(h)?(a=w,se(h)):(e.consume(h),w)}function T(h){return h===62?j(h):w(h)}function A(h){return Re(h)?(e.consume(h),_):n(h)}function _(h){return h===45||Te(h)?(e.consume(h),_):$(h)}function $(h){return W(h)?(a=$,se(h)):re(h)?(e.consume(h),$):j(h)}function H(h){return h===45||Te(h)?(e.consume(h),H):h===47||h===62||ge(h)?G(h):n(h)}function G(h){return h===47?(e.consume(h),j):h===58||h===95||Re(h)?(e.consume(h),S):W(h)?(a=G,se(h)):re(h)?(e.consume(h),G):j(h)}function S(h){return h===45||h===46||h===58||h===95||Te(h)?(e.consume(h),S):B(h)}function B(h){return h===61?(e.consume(h),F):W(h)?(a=B,se(h)):re(h)?(e.consume(h),B):G(h)}function F(h){return h===null||h===60||h===61||h===62||h===96?n(h):h===34||h===39?(e.consume(h),i=h,J):W(h)?(a=F,se(h)):re(h)?(e.consume(h),F):(e.consume(h),D)}function J(h){return h===i?(e.consume(h),i=void 0,O):h===null?n(h):W(h)?(a=J,se(h)):(e.consume(h),J)}function D(h){return h===null||h===34||h===39||h===60||h===61||h===96?n(h):h===47||h===62||ge(h)?G(h):(e.consume(h),D)}function O(h){return h===47||h===62||ge(h)?G(h):n(h)}function j(h){return h===62?(e.consume(h),e.exit("htmlTextData"),e.exit("htmlText"),t):n(h)}function se(h){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Z}function Z(h){return re(h)?ae(e,pe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h):pe(h)}function pe(h){return e.enter("htmlTextData"),a(h)}}const Nr={name:"labelEnd",resolveAll:Ll,resolveTo:Pl,tokenize:Bl},Rl={tokenize:Fl},Ml={tokenize:zl},Dl={tokenize:Ul};function Ll(e){let t=-1;const n=[];for(;++t=3&&(c===null||W(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),re(c)?ae(e,s,"whitespace")(c):s(c))}}const Me={continuation:{tokenize:Zl},exit:Ql,name:"list",tokenize:jl},Vl={partial:!0,tokenize:Jl},Yl={partial:!0,tokenize:Xl};function jl(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:lr(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(En,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return lr(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Zt,r.interrupt?n:d,e.attempt(Vl,f,u))}function d(p){return r.containerState.initialBlankLine=!0,o++,f(p)}function u(p){return re(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Zl(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Zt,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ae(e,t,"listItemIndent",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!re(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Yl,t,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,ae(e,e.attempt(Me,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Xl(e,t,n){const r=this;return ae(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function Ql(e){e.exit(this.containerState.type)}function Jl(e,t,n){const r=this;return ae(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!re(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const di={name:"setextUnderline",resolveTo:ec,tokenize:tc};function ec(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function tc(e,t,n){const r=this;let i;return o;function o(c){let d=r.events.length,u;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){u=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||u)?(e.enter("setextHeadingLine"),i=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===i?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),re(c)?ae(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||W(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const nc={tokenize:rc};function rc(e){const t=this,n=e.attempt(Zt,r,e.attempt(this.parser.constructs.flowInitial,i,ae(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ll,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const ic={resolveAll:Ea()},ac=ba("string"),oc=ba("text");function ba(e){return{resolveAll:Ea(e==="text"?sc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,s);return a;function a(d){return c(d)?o(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return c(d)?(n.exit("data"),o(d)):(n.consume(d),l)}function c(d){if(d===null)return!0;const u=i[d];let f=-1;if(u)for(;++f-1){const s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function _c(e,t){let n=-1;const r=[];let i;for(;++n0){const Be=V.tokenStack[V.tokenStack.length-1];(Be[1]||fi).call(V,void 0,Be[0])}for(R.position={start:pt(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:pt(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++lei.map(i=>d[i]); -var ze=Object.defineProperty;var Ve=(t,s,r)=>s in t?ze(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var K=(t,s,r)=>Ve(t,typeof s!="symbol"?s+"":s,r);import{R as re,a as h,j as e,b as Fe}from"./vendor-react-BVoutfaX.js";import{H as Y,P as X,B as Ue,M as Je,u as Ge,a as qe,R as Ye,b as Xe,C as Ke,c as Ze,d as Qe}from"./vendor-reactflow-mU21rT8r.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function r(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(n){if(n.ep)return;n.ep=!0;const i=r(n);fetch(n.href,i)}})();const de=t=>{let s;const r=new Set,o=(d,l)=>{const x=typeof d=="function"?d(s):d;if(!Object.is(x,s)){const j=s;s=l??(typeof x!="object"||x===null)?x:Object.assign({},s,x),r.forEach(y=>y(s,j))}},n=()=>s,c={setState:o,getState:n,getInitialState:()=>m,subscribe:d=>(r.add(d),()=>r.delete(d))},m=s=t(o,n,c);return c},et=(t=>t?de(t):de),tt=t=>t;function st(t,s=tt){const r=re.useSyncExternalStore(t.subscribe,re.useCallback(()=>s(t.getState()),[t,s]),re.useCallback(()=>s(t.getInitialState()),[t,s]));return re.useDebugValue(r),r}const ue=t=>{const s=et(t),r=o=>st(s,o);return Object.assign(r,s),r},$e=(t=>t?ue(t):ue),W=$e(t=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:s=>t(r=>{var i;let o=r.breakpoints;for(const a of s)(i=a.breakpoints)!=null&&i.length&&!o[a.id]&&(o={...o,[a.id]:Object.fromEntries(a.breakpoints.map(c=>[c,!0]))});const n={runs:Object.fromEntries(s.map(a=>[a.id,a]))};return o!==r.breakpoints&&(n.breakpoints=o),n}),upsertRun:s=>t(r=>{var n;const o={runs:{...r.runs,[s.id]:s}};if((n=s.breakpoints)!=null&&n.length&&!r.breakpoints[s.id]&&(o.breakpoints={...r.breakpoints,[s.id]:Object.fromEntries(s.breakpoints.map(i=>[i,!0]))}),(s.status==="completed"||s.status==="failed")&&r.activeNodes[s.id]){const{[s.id]:i,...a}=r.activeNodes;o.activeNodes=a}if(s.status!=="suspended"&&r.activeInterrupt[s.id]){const{[s.id]:i,...a}=r.activeInterrupt;o.activeInterrupt=a}return o}),selectRun:s=>t({selectedRunId:s}),addTrace:s=>t(r=>{const o=r.traces[s.run_id]??[],n=o.findIndex(a=>a.span_id===s.span_id),i=n>=0?o.map((a,c)=>c===n?s:a):[...o,s];return{traces:{...r.traces,[s.run_id]:i}}}),setTraces:(s,r)=>t(o=>({traces:{...o.traces,[s]:r}})),addLog:s=>t(r=>{const o=r.logs[s.run_id]??[];return{logs:{...r.logs,[s.run_id]:[...o,s]}}}),setLogs:(s,r)=>t(o=>({logs:{...o.logs,[s]:r}})),addChatEvent:(s,r)=>t(o=>{const n=o.chatMessages[s]??[],i=r.message;if(!i)return o;const a=i.messageId??i.message_id,c=i.role??"assistant",l=(i.contentParts??i.content_parts??[]).filter(k=>{const w=k.mimeType??k.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(k=>{const w=k.data;return(w==null?void 0:w.inline)??""}).join(` -`).trim(),x=(i.toolCalls??i.tool_calls??[]).map(k=>({name:k.name??"",has_result:!!k.result})),j={message_id:a,role:c,content:l,tool_calls:x.length>0?x:void 0},y=n.findIndex(k=>k.message_id===a);if(y>=0)return{chatMessages:{...o.chatMessages,[s]:n.map((k,w)=>w===y?j:k)}};if(c==="user"){const k=n.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===l);if(k>=0)return{chatMessages:{...o.chatMessages,[s]:n.map((w,$)=>$===k?j:w)}}}const E=[...n,j];return{chatMessages:{...o.chatMessages,[s]:E}}}),addLocalChatMessage:(s,r)=>t(o=>{const n=o.chatMessages[s]??[];return{chatMessages:{...o.chatMessages,[s]:[...n,r]}}}),setChatMessages:(s,r)=>t(o=>({chatMessages:{...o.chatMessages,[s]:r}})),setEntrypoints:s=>t({entrypoints:s}),breakpoints:{},toggleBreakpoint:(s,r)=>t(o=>{const n={...o.breakpoints[s]??{}};return n[r]?delete n[r]:n[r]=!0,{breakpoints:{...o.breakpoints,[s]:n}}}),clearBreakpoints:s=>t(r=>{const{[s]:o,...n}=r.breakpoints;return{breakpoints:n}}),activeNodes:{},setActiveNode:(s,r,o)=>t(n=>{const i=n.activeNodes[s]??{executing:{},prev:null};return{activeNodes:{...n.activeNodes,[s]:{executing:{...i.executing,[r]:o??null},prev:i.prev}}}}),removeActiveNode:(s,r)=>t(o=>{const n=o.activeNodes[s];if(!n)return o;const{[r]:i,...a}=n.executing;return{activeNodes:{...o.activeNodes,[s]:{executing:a,prev:r}}}}),resetRunGraphState:s=>t(r=>({stateEvents:{...r.stateEvents,[s]:[]},activeNodes:{...r.activeNodes,[s]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(s,r,o,n,i)=>t(a=>{const c=a.stateEvents[s]??[];return{stateEvents:{...a.stateEvents,[s]:[...c,{node_name:r,qualified_node_name:n,phase:i,timestamp:Date.now(),payload:o}]}}}),setStateEvents:(s,r)=>t(o=>({stateEvents:{...o.stateEvents,[s]:r}})),focusedSpan:null,setFocusedSpan:s=>t({focusedSpan:s}),activeInterrupt:{},setActiveInterrupt:(s,r)=>t(o=>({activeInterrupt:{...o.activeInterrupt,[s]:r}})),reloadPending:!1,setReloadPending:s=>t({reloadPending:s}),graphCache:{},setGraphCache:(s,r)=>t(o=>({graphCache:{...o.graphCache,[s]:r}}))}));class rt{constructor(s){K(this,"ws",null);K(this,"url");K(this,"handlers",new Set);K(this,"reconnectTimer",null);K(this,"shouldReconnect",!0);K(this,"pendingMessages",[]);K(this,"activeSubscriptions",new Set);const r=window.location.protocol==="https:"?"wss:":"ws:";this.url=s??`${r}//${window.location.host}/ws`}connect(){var s;((s=this.ws)==null?void 0:s.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const r of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:r}}));for(const r of this.pendingMessages)this.sendRaw(r);this.pendingMessages=[]},this.ws.onmessage=r=>{let o;try{o=JSON.parse(r.data)}catch{console.warn("[ws] failed to parse message",r.data);return}this.handlers.forEach(n=>{try{n(o)}catch(i){console.error("[ws] handler error",i)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}disconnect(){var s;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(s=this.ws)==null||s.close(),this.ws=null}onMessage(s){return this.handlers.add(s),()=>this.handlers.delete(s)}sendRaw(s){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(s)}send(s,r){var n;const o=JSON.stringify({type:s,payload:r});((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?this.ws.send(o):this.pendingMessages.push(o)}subscribe(s){this.activeSubscriptions.add(s),this.send("subscribe",{run_id:s})}unsubscribe(s){this.activeSubscriptions.delete(s),this.send("unsubscribe",{run_id:s})}sendChatMessage(s,r){this.send("chat.message",{run_id:s,text:r})}sendInterruptResponse(s,r){this.send("chat.interrupt_response",{run_id:s,data:r})}debugStep(s){this.send("debug.step",{run_id:s})}debugContinue(s){this.send("debug.continue",{run_id:s})}debugStop(s){this.send("debug.stop",{run_id:s})}setBreakpoints(s,r){this.send("debug.set_breakpoints",{run_id:s,breakpoints:r})}}let oe=null;function ot(){return oe||(oe=new rt,oe.connect()),oe}function nt(){const t=h.useRef(ot()),{upsertRun:s,addTrace:r,addLog:o,addChatEvent:n,setActiveInterrupt:i,setActiveNode:a,removeActiveNode:c,resetRunGraphState:m,addStateEvent:d,setReloadPending:l}=W();return h.useEffect(()=>t.current.onMessage(y=>{switch(y.type){case"run.updated":s(y.payload);break;case"trace":r(y.payload);break;case"log":o(y.payload);break;case"chat":{const E=y.payload.run_id;n(E,y.payload);break}case"chat.interrupt":{const E=y.payload.run_id;i(E,y.payload);break}case"state":{const E=y.payload.run_id,k=y.payload.node_name,w=y.payload.qualified_node_name??null,$=y.payload.phase??null,B=y.payload.payload;k==="__start__"&&$==="started"&&m(E),$==="started"?a(E,k,w):$==="completed"&&c(E,k),d(E,k,B,w,$);break}case"reload":l(!0);break}}),[s,r,o,n,i,a,c,m,d,l]),t.current}const Z="/api";async function Q(t,s){const r=await fetch(t,s);if(!r.ok){let o;try{o=(await r.json()).detail||r.statusText}catch{o=r.statusText}const n=new Error(`HTTP ${r.status}`);throw n.detail=o,n.status=r.status,n}return r.json()}async function Ie(){return Q(`${Z}/entrypoints`)}async function at(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/schema`)}async function it(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/mock-input`)}async function ct(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/graph`)}async function pe(t,s,r="run",o=[]){return Q(`${Z}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:t,input_data:s,mode:r,breakpoints:o})})}async function lt(){return Q(`${Z}/runs`)}async function ae(t){return Q(`${Z}/runs/${t}`)}async function dt(){return Q(`${Z}/reload`,{method:"POST"})}function ut(t){const s=t.replace(/^#\/?/,"");if(!s||s==="new")return{view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null};const r=s.match(/^setup\/([^/]+)\/(run|chat)$/);if(r)return{view:"setup",runId:null,tab:"traces",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const o=s.match(/^runs\/([^/]+)(?:\/(traces|output))?$/);return o?{view:"details",runId:o[1],tab:o[2]??"traces",setupEntrypoint:null,setupMode:null}:{view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null}}function pt(){return window.location.hash}function ht(t){return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function Pe(){const t=h.useSyncExternalStore(ht,pt),s=ut(t),r=h.useCallback(o=>{window.location.hash=o},[]);return{...s,navigate:r}}const he="(max-width: 767px)";function xt(){const[t,s]=h.useState(()=>window.matchMedia(he).matches);return h.useEffect(()=>{const r=window.matchMedia(he),o=n=>s(n.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),t}function We(){const t=localStorage.getItem("uipath-dev-theme");return t==="light"||t==="dark"?t:"dark"}function Oe(t){document.documentElement.setAttribute("data-theme",t),localStorage.setItem("uipath-dev-theme",t)}Oe(We());const mt=$e(t=>({theme:We(),toggleTheme:()=>t(s=>{const r=s.theme==="dark"?"light":"dark";return Oe(r),{theme:r}})})),gt={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function xe({run:t,isSelected:s,onClick:r}){var a;const o=gt[t.status]??"var(--text-muted)",n=((a=t.entrypoint.split("/").pop())==null?void 0:a.slice(0,16))??t.entrypoint,i=t.start_time?new Date(t.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("button",{onClick:r,className:"w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:s?"color-mix(in srgb, var(--accent) 8%, var(--bg-primary))":void 0,borderLeft:s?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:c=>{s||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{s||(c.currentTarget.style.background="")},children:[e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full",style:{background:o}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs truncate",style:{color:s?"var(--text-primary)":"var(--text-secondary)"},children:n}),e.jsxs("div",{className:"text-[10px] tabular-nums",style:{color:"var(--text-muted)"},children:[i,t.duration?` · ${t.duration}`:""]})]})]})}function ft({runs:t,selectedRunId:s,onSelectRun:r,onNewRun:o,isMobile:n,isOpen:i,onClose:a}){const{theme:c,toggleTheme:m}=mt(),d=[...t].sort((l,x)=>new Date(x.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n?i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:a}),e.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[e.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-80",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"4",fill:"var(--accent)"}),e.jsx("text",{x:"12",y:"17",textAnchor:"middle",fill:"white",fontSize:"14",fontWeight:"700",fontFamily:"Arial, sans-serif",children:"U"})]}),e.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Dev Console"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:m,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},title:`Switch to ${c==="dark"?"light":"dark"} theme`,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c==="dark"?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),e.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),e.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),e.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),e.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),e.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),e.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),e.jsx("button",{onClick:a,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",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.jsx("button",{onClick:o,className:"mx-3 mt-2.5 mb-1 px-2 py-1.5 text-[10px] uppercase tracking-wider font-semibold rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-muted)"},children:"+ New Run"}),e.jsx("div",{className:"px-3 pt-3 pb-1 text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d.map(l=>e.jsx(xe,{run:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id)),d.length===0&&e.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]}),e.jsx("div",{className:"px-3 h-10 border-t border-[var(--border)] flex items-center justify-center",children:e.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[11px] uppercase tracking-widest font-semibold transition-opacity hover:opacity-80",style:{color:"var(--text-muted)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),"GitHub"]})})]})]}):null:e.jsxs("aside",{className:"w-44 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[e.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-80",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"4",fill:"var(--accent)"}),e.jsx("text",{x:"12",y:"17",textAnchor:"middle",fill:"white",fontSize:"14",fontWeight:"700",fontFamily:"Arial, sans-serif",children:"U"})]}),e.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Dev Console"})]}),e.jsx("button",{onClick:m,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-muted)"},title:`Switch to ${c==="dark"?"light":"dark"} theme`,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c==="dark"?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),e.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),e.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),e.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),e.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),e.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),e.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})})]}),e.jsx("button",{onClick:o,className:"mx-3 mt-2.5 mb-1 px-2 py-1 text-[10px] uppercase tracking-wider font-semibold rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-muted)",l.currentTarget.style.borderColor="var(--border)"},children:"+ New Run"}),e.jsx("div",{className:"px-3 pt-3 pb-1 text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d.map(l=>e.jsx(xe,{run:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id)),d.length===0&&e.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]}),e.jsx("div",{className:"px-3 h-10 border-t border-[var(--border)] flex items-center justify-center",children:e.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[11px] uppercase tracking-widest font-semibold transition-opacity hover:opacity-80",style:{color:"var(--text-muted)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),"GitHub"]})})]})}function vt(){const{navigate:t}=Pe(),s=W(d=>d.entrypoints),[r,o]=h.useState(""),[n,i]=h.useState(!0),[a,c]=h.useState(null);h.useEffect(()=>{!r&&s.length>0&&o(s[0])},[s,r]),h.useEffect(()=>{r&&(i(!0),c(null),at(r).then(d=>{var x;const l=(x=d.input)==null?void 0:x.properties;i(!!(l!=null&&l.messages))}).catch(d=>{const l=d.detail||{};c(l.error||l.message||`Failed to load entrypoint "${r}"`)}))},[r]);const m=d=>{r&&t(`#/setup/${encodeURIComponent(r)}/${d}`)};return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"w-full max-w-xl px-6",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),e.jsx("span",{className:"text-xs uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:s.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),s.length>1&&e.jsxs("div",{className:"mb-8",children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-wider font-semibold mb-2",style:{color:"var(--text-muted)"},children:"Entrypoint"}),e.jsx("select",{value:r,onChange:d=>o(d.target.value),className:"w-full rounded-md px-3 py-1.5 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:s.map(d=>e.jsx("option",{value:d,children:d},d))})]}),a?e.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:e.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),e.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),e.jsx("div",{className:"overflow-auto max-h-48 p-3",children:e.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(me,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:e.jsx(yt,{}),color:"var(--success)",onClick:()=>m("run"),disabled:!r}),e.jsx(me,{title:"Conversational",description:n?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:e.jsx(bt,{}),color:"var(--accent)",onClick:()=>m("chat"),disabled:!r||!n})]})]})})}function me({title:t,description:s,icon:r,color:o,onClick:n,disabled:i}){return e.jsxs("button",{onClick:n,disabled:i,className:"group flex flex-col items-center text-center p-6 rounded-lg border transition-all cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{i||(a.currentTarget.style.borderColor=o,a.currentTarget.style.background=`color-mix(in srgb, ${o} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[e.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${o} 10%, var(--bg-primary))`,color:o},children:r}),e.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:t}),e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:s})]})}function yt(){return e.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function bt(){return e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),e.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),e.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),e.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),e.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),e.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),e.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),e.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const jt="modulepreload",wt=function(t){return"/"+t},ge={},He=function(s,r,o){let n=Promise.resolve();if(r&&r.length>0){let a=function(d){return Promise.all(d.map(l=>Promise.resolve(l).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),m=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));n=a(r.map(d=>{if(d=wt(d),d in ge)return;ge[d]=!0;const l=d.endsWith(".css"),x=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${x}`))return;const j=document.createElement("link");if(j.rel=l?"stylesheet":jt,l||(j.as="script"),j.crossOrigin="",j.href=d,m&&j.setAttribute("nonce",m),document.head.appendChild(j),l)return new Promise((y,E)=>{j.addEventListener("load",y),j.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return n.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return s().catch(i)})},kt={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Nt({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"Start",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,m=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":"var(--node-border)",d=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${m}`,boxShadow:i||a||c?`0 0 4px ${d}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),o,e.jsx(Y,{type:"source",position:X.Bottom,style:kt})]})}const St={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Et({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"End",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,m=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="failed"?"var(--error)":"var(--node-border)",d=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${m}`,boxShadow:i||a||c?`0 0 4px ${d}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:St}),o]})}const fe={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ct({data:t}){const s=t.status,r=t.nodeWidth,o=t.model_name,n=t.label??"Model",i=t.hasBreakpoint,a=t.isPausedHere,c=t.isActiveNode,m=t.isExecutingNode,d=a?"var(--error)":m?"var(--success)":c?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",l=a?"var(--error)":m?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${d}`,boxShadow:a||c||m?`0 0 4px ${l}`:void 0,animation:a||c||m?`node-pulse-${a?"red":m?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o?`${n} -${o}`:n,children:[i&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:fe}),e.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:n}),o&&e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:o,children:o}),e.jsx(Y,{type:"source",position:X.Bottom,style:fe})]})}const ve={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},_t=3;function Lt({data:t}){const s=t.status,r=t.nodeWidth,o=t.tool_names,n=t.tool_count,i=t.label??"Tool",a=t.hasBreakpoint,c=t.isPausedHere,m=t.isActiveNode,d=t.isExecutingNode,l=c?"var(--error)":d?"var(--success)":m?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",x=c?"var(--error)":d?"var(--success)":"var(--accent)",j=(o==null?void 0:o.slice(0,_t))??[],y=(n??(o==null?void 0:o.length)??0)-j.length;return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${l}`,boxShadow:c||m||d?`0 0 4px ${x}`:void 0,animation:c||m||d?`node-pulse-${c?"red":d?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o!=null&&o.length?`${i} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-elk-CTNP4r_q.js","assets/vendor-react-BVoutfaX.js","assets/ChatPanel-DvMLkYmo.js","assets/vendor-reactflow-mU21rT8r.js","assets/vendor-reactflow-B5DZHykP.css"])))=>i.map(i=>d[i]); +var ze=Object.defineProperty;var Ve=(t,s,r)=>s in t?ze(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var K=(t,s,r)=>Ve(t,typeof s!="symbol"?s+"":s,r);import{R as re,a as p,j as e,b as Fe}from"./vendor-react-BVoutfaX.js";import{H as Y,P as X,B as Ue,M as Je,u as Ge,a as qe,R as Ye,b as Xe,C as Ke,c as Ze,d as Qe}from"./vendor-reactflow-mU21rT8r.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function r(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(n){if(n.ep)return;n.ep=!0;const i=r(n);fetch(n.href,i)}})();const ue=t=>{let s;const r=new Set,o=(u,l)=>{const h=typeof u=="function"?u(s):u;if(!Object.is(h,s)){const j=s;s=l??(typeof h!="object"||h===null)?h:Object.assign({},s,h),r.forEach(b=>b(s,j))}},n=()=>s,c={setState:o,getState:n,getInitialState:()=>x,subscribe:u=>(r.add(u),()=>r.delete(u))},x=s=t(o,n,c);return c},et=(t=>t?ue(t):ue),tt=t=>t;function st(t,s=tt){const r=re.useSyncExternalStore(t.subscribe,re.useCallback(()=>s(t.getState()),[t,s]),re.useCallback(()=>s(t.getInitialState()),[t,s]));return re.useDebugValue(r),r}const pe=t=>{const s=et(t),r=o=>st(s,o);return Object.assign(r,s),r},$e=(t=>t?pe(t):pe),H=$e(t=>({runs:{},selectedRunId:null,traces:{},logs:{},chatMessages:{},entrypoints:[],setRuns:s=>t(r=>{var i;let o=r.breakpoints;for(const a of s)(i=a.breakpoints)!=null&&i.length&&!o[a.id]&&(o={...o,[a.id]:Object.fromEntries(a.breakpoints.map(c=>[c,!0]))});const n={runs:Object.fromEntries(s.map(a=>[a.id,a]))};return o!==r.breakpoints&&(n.breakpoints=o),n}),upsertRun:s=>t(r=>{var n;const o={runs:{...r.runs,[s.id]:s}};if((n=s.breakpoints)!=null&&n.length&&!r.breakpoints[s.id]&&(o.breakpoints={...r.breakpoints,[s.id]:Object.fromEntries(s.breakpoints.map(i=>[i,!0]))}),(s.status==="completed"||s.status==="failed")&&r.activeNodes[s.id]){const{[s.id]:i,...a}=r.activeNodes;o.activeNodes=a}if(s.status!=="suspended"&&r.activeInterrupt[s.id]){const{[s.id]:i,...a}=r.activeInterrupt;o.activeInterrupt=a}return o}),selectRun:s=>t({selectedRunId:s}),addTrace:s=>t(r=>{const o=r.traces[s.run_id]??[],n=o.findIndex(a=>a.span_id===s.span_id),i=n>=0?o.map((a,c)=>c===n?s:a):[...o,s];return{traces:{...r.traces,[s.run_id]:i}}}),setTraces:(s,r)=>t(o=>({traces:{...o.traces,[s]:r}})),addLog:s=>t(r=>{const o=r.logs[s.run_id]??[];return{logs:{...r.logs,[s.run_id]:[...o,s]}}}),setLogs:(s,r)=>t(o=>({logs:{...o.logs,[s]:r}})),addChatEvent:(s,r)=>t(o=>{const n=o.chatMessages[s]??[],i=r.message;if(!i)return o;const a=i.messageId??i.message_id,c=i.role??"assistant",l=(i.contentParts??i.content_parts??[]).filter(k=>{const w=k.mimeType??k.mime_type??"";return w.startsWith("text/")||w==="application/json"}).map(k=>{const w=k.data;return(w==null?void 0:w.inline)??""}).join(` +`).trim(),h=(i.toolCalls??i.tool_calls??[]).map(k=>({name:k.name??"",has_result:!!k.result})),j={message_id:a,role:c,content:l,tool_calls:h.length>0?h:void 0},b=n.findIndex(k=>k.message_id===a);if(b>=0)return{chatMessages:{...o.chatMessages,[s]:n.map((k,w)=>w===b?j:k)}};if(c==="user"){const k=n.findIndex(w=>w.message_id.startsWith("local-")&&w.role==="user"&&w.content===l);if(k>=0)return{chatMessages:{...o.chatMessages,[s]:n.map((w,R)=>R===k?j:w)}}}const E=[...n,j];return{chatMessages:{...o.chatMessages,[s]:E}}}),addLocalChatMessage:(s,r)=>t(o=>{const n=o.chatMessages[s]??[];return{chatMessages:{...o.chatMessages,[s]:[...n,r]}}}),setChatMessages:(s,r)=>t(o=>({chatMessages:{...o.chatMessages,[s]:r}})),setEntrypoints:s=>t({entrypoints:s}),breakpoints:{},toggleBreakpoint:(s,r)=>t(o=>{const n={...o.breakpoints[s]??{}};return n[r]?delete n[r]:n[r]=!0,{breakpoints:{...o.breakpoints,[s]:n}}}),clearBreakpoints:s=>t(r=>{const{[s]:o,...n}=r.breakpoints;return{breakpoints:n}}),activeNodes:{},setActiveNode:(s,r,o)=>t(n=>{const i=n.activeNodes[s]??{executing:{},prev:null};return{activeNodes:{...n.activeNodes,[s]:{executing:{...i.executing,[r]:o??null},prev:i.prev}}}}),removeActiveNode:(s,r)=>t(o=>{const n=o.activeNodes[s];if(!n)return o;const{[r]:i,...a}=n.executing;return{activeNodes:{...o.activeNodes,[s]:{executing:a,prev:r}}}}),resetRunGraphState:s=>t(r=>({stateEvents:{...r.stateEvents,[s]:[]},activeNodes:{...r.activeNodes,[s]:{executing:{},prev:null}}})),stateEvents:{},addStateEvent:(s,r,o,n,i)=>t(a=>{const c=a.stateEvents[s]??[];return{stateEvents:{...a.stateEvents,[s]:[...c,{node_name:r,qualified_node_name:n,phase:i,timestamp:Date.now(),payload:o}]}}}),setStateEvents:(s,r)=>t(o=>({stateEvents:{...o.stateEvents,[s]:r}})),focusedSpan:null,setFocusedSpan:s=>t({focusedSpan:s}),activeInterrupt:{},setActiveInterrupt:(s,r)=>t(o=>({activeInterrupt:{...o.activeInterrupt,[s]:r}})),reloadPending:!1,setReloadPending:s=>t({reloadPending:s}),graphCache:{},setGraphCache:(s,r)=>t(o=>({graphCache:{...o.graphCache,[s]:r}}))}));class rt{constructor(s){K(this,"ws",null);K(this,"url");K(this,"handlers",new Set);K(this,"reconnectTimer",null);K(this,"shouldReconnect",!0);K(this,"pendingMessages",[]);K(this,"activeSubscriptions",new Set);const r=window.location.protocol==="https:"?"wss:":"ws:";this.url=s??`${r}//${window.location.host}/ws`}connect(){var s;((s=this.ws)==null?void 0:s.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{console.log("[ws] connected");for(const r of this.activeSubscriptions)this.sendRaw(JSON.stringify({type:"subscribe",payload:{run_id:r}}));for(const r of this.pendingMessages)this.sendRaw(r);this.pendingMessages=[]},this.ws.onmessage=r=>{let o;try{o=JSON.parse(r.data)}catch{console.warn("[ws] failed to parse message",r.data);return}this.handlers.forEach(n=>{try{n(o)}catch(i){console.error("[ws] handler error",i)}})},this.ws.onclose=()=>{console.log("[ws] disconnected"),this.shouldReconnect&&(this.reconnectTimer=setTimeout(()=>this.connect(),2e3))},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}disconnect(){var s;this.shouldReconnect=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(s=this.ws)==null||s.close(),this.ws=null}onMessage(s){return this.handlers.add(s),()=>this.handlers.delete(s)}sendRaw(s){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(s)}send(s,r){var n;const o=JSON.stringify({type:s,payload:r});((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN?this.ws.send(o):this.pendingMessages.push(o)}subscribe(s){this.activeSubscriptions.add(s),this.send("subscribe",{run_id:s})}unsubscribe(s){this.activeSubscriptions.delete(s),this.send("unsubscribe",{run_id:s})}sendChatMessage(s,r){this.send("chat.message",{run_id:s,text:r})}sendInterruptResponse(s,r){this.send("chat.interrupt_response",{run_id:s,data:r})}debugStep(s){this.send("debug.step",{run_id:s})}debugContinue(s){this.send("debug.continue",{run_id:s})}debugStop(s){this.send("debug.stop",{run_id:s})}setBreakpoints(s,r){this.send("debug.set_breakpoints",{run_id:s,breakpoints:r})}}let oe=null;function ot(){return oe||(oe=new rt,oe.connect()),oe}function nt(){const t=p.useRef(ot()),{upsertRun:s,addTrace:r,addLog:o,addChatEvent:n,setActiveInterrupt:i,setActiveNode:a,removeActiveNode:c,resetRunGraphState:x,addStateEvent:u,setReloadPending:l}=H();return p.useEffect(()=>t.current.onMessage(b=>{switch(b.type){case"run.updated":s(b.payload);break;case"trace":r(b.payload);break;case"log":o(b.payload);break;case"chat":{const E=b.payload.run_id;n(E,b.payload);break}case"chat.interrupt":{const E=b.payload.run_id;i(E,b.payload);break}case"state":{const E=b.payload.run_id,k=b.payload.node_name,w=b.payload.qualified_node_name??null,R=b.payload.phase??null,B=b.payload.payload;k==="__start__"&&R==="started"&&x(E),R==="started"?a(E,k,w):R==="completed"&&c(E,k),u(E,k,B,w,R);break}case"reload":l(!0);break}}),[s,r,o,n,i,a,c,x,u,l]),t.current}const Z="/api";async function Q(t,s){const r=await fetch(t,s);if(!r.ok){let o;try{o=(await r.json()).detail||r.statusText}catch{o=r.statusText}const n=new Error(`HTTP ${r.status}`);throw n.detail=o,n.status=r.status,n}return r.json()}async function Ie(){return Q(`${Z}/entrypoints`)}async function at(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/schema`)}async function it(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/mock-input`)}async function ct(t){return Q(`${Z}/entrypoints/${encodeURIComponent(t)}/graph`)}async function he(t,s,r="run",o=[]){return Q(`${Z}/runs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrypoint:t,input_data:s,mode:r,breakpoints:o})})}async function lt(){return Q(`${Z}/runs`)}async function ie(t){return Q(`${Z}/runs/${t}`)}async function dt(){return Q(`${Z}/reload`,{method:"POST"})}function ut(t){const s=t.replace(/^#\/?/,"");if(!s||s==="new")return{view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null};const r=s.match(/^setup\/([^/]+)\/(run|chat)$/);if(r)return{view:"setup",runId:null,tab:"traces",setupEntrypoint:decodeURIComponent(r[1]),setupMode:r[2]};const o=s.match(/^runs\/([^/]+)(?:\/(traces|output))?$/);return o?{view:"details",runId:o[1],tab:o[2]??"traces",setupEntrypoint:null,setupMode:null}:{view:"new",runId:null,tab:"traces",setupEntrypoint:null,setupMode:null}}function pt(){return window.location.hash}function ht(t){return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function Pe(){const t=p.useSyncExternalStore(ht,pt),s=ut(t),r=p.useCallback(o=>{window.location.hash=o},[]);return{...s,navigate:r}}const xe="(max-width: 767px)";function xt(){const[t,s]=p.useState(()=>window.matchMedia(xe).matches);return p.useEffect(()=>{const r=window.matchMedia(xe),o=n=>s(n.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[]),t}function We(){const t=localStorage.getItem("uipath-dev-theme");return t==="light"||t==="dark"?t:"dark"}function Oe(t){document.documentElement.setAttribute("data-theme",t),localStorage.setItem("uipath-dev-theme",t)}Oe(We());const mt=$e(t=>({theme:We(),toggleTheme:()=>t(s=>{const r=s.theme==="dark"?"light":"dark";return Oe(r),{theme:r}})})),gt={pending:"var(--text-muted)",running:"var(--warning)",suspended:"var(--info)",completed:"var(--success)",failed:"var(--error)"};function me({run:t,isSelected:s,onClick:r}){var a;const o=gt[t.status]??"var(--text-muted)",n=((a=t.entrypoint.split("/").pop())==null?void 0:a.slice(0,16))??t.entrypoint,i=t.start_time?new Date(t.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("button",{onClick:r,className:"w-full text-left px-3 py-1.5 flex items-center gap-2 transition-colors cursor-pointer",style:{background:s?"color-mix(in srgb, var(--accent) 8%, var(--bg-primary))":void 0,borderLeft:s?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:c=>{s||(c.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:c=>{s||(c.currentTarget.style.background="")},children:[e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full",style:{background:o}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs truncate",style:{color:s?"var(--text-primary)":"var(--text-secondary)"},children:n}),e.jsxs("div",{className:"text-[10px] tabular-nums",style:{color:"var(--text-muted)"},children:[i,t.duration?` · ${t.duration}`:""]})]})]})}function ft({runs:t,selectedRunId:s,onSelectRun:r,onNewRun:o,isMobile:n,isOpen:i,onClose:a}){const{theme:c,toggleTheme:x}=mt(),u=[...t].sort((l,h)=>new Date(h.start_time??0).getTime()-new Date(l.start_time??0).getTime());return n?i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-50",style:{background:"rgba(0,0,0,0.5)"},onClick:a}),e.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[e.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-80",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"4",fill:"var(--accent)"}),e.jsx("text",{x:"12",y:"17",textAnchor:"middle",fill:"white",fontSize:"14",fontWeight:"700",fontFamily:"Arial, sans-serif",children:"U"})]}),e.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Dev Console"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:x,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},title:`Switch to ${c==="dark"?"light":"dark"} theme`,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c==="dark"?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),e.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),e.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),e.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),e.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),e.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),e.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),e.jsx("button",{onClick:a,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",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.jsx("button",{onClick:o,className:"mx-3 mt-2.5 mb-1 px-2 py-1.5 text-[10px] uppercase tracking-wider font-semibold rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-muted)"},children:"+ New Run"}),e.jsx("div",{className:"px-3 pt-3 pb-1 text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[u.map(l=>e.jsx(me,{run:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id)),u.length===0&&e.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]}),e.jsx("div",{className:"px-3 h-10 border-t border-[var(--border)] flex items-center justify-center",children:e.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[11px] uppercase tracking-widest font-semibold transition-opacity hover:opacity-80",style:{color:"var(--text-muted)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),"GitHub"]})})]})]}):null:e.jsxs("aside",{className:"w-44 bg-[var(--sidebar-bg)] border-r border-[var(--border)] flex flex-col",children:[e.jsxs("div",{className:"px-3 h-10 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-80",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("rect",{width:"24",height:"24",rx:"4",fill:"var(--accent)"}),e.jsx("text",{x:"12",y:"17",textAnchor:"middle",fill:"white",fontSize:"14",fontWeight:"700",fontFamily:"Arial, sans-serif",children:"U"})]}),e.jsx("span",{className:"text-[11px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"Dev Console"})]}),e.jsx("button",{onClick:x,className:"w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-colors",style:{color:"var(--text-muted)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-muted)"},title:`Switch to ${c==="dark"?"light":"dark"} theme`,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c==="dark"?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),e.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),e.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),e.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),e.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),e.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),e.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})})]}),e.jsx("button",{onClick:o,className:"mx-3 mt-2.5 mb-1 px-2 py-1 text-[10px] uppercase tracking-wider font-semibold rounded border border-[var(--border)] bg-transparent transition-colors cursor-pointer",style:{color:"var(--text-muted)"},onMouseEnter:l=>{l.currentTarget.style.color="var(--text-primary)",l.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:l=>{l.currentTarget.style.color="var(--text-muted)",l.currentTarget.style.borderColor="var(--border)"},children:"+ New Run"}),e.jsx("div",{className:"px-3 pt-3 pb-1 text-[10px] uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"History"}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[u.map(l=>e.jsx(me,{run:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id)),u.length===0&&e.jsx("p",{className:"text-xs px-3 py-4 text-center",style:{color:"var(--text-muted)"},children:"No runs yet"})]}),e.jsx("div",{className:"px-3 h-10 border-t border-[var(--border)] flex items-center justify-center",children:e.jsxs("a",{href:"https://github.com/UiPath/uipath-dev-python",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-[11px] uppercase tracking-widest font-semibold transition-opacity hover:opacity-80",style:{color:"var(--text-muted)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z"})}),"GitHub"]})})]})}function vt(){const{navigate:t}=Pe(),s=H(u=>u.entrypoints),[r,o]=p.useState(""),[n,i]=p.useState(!0),[a,c]=p.useState(null);p.useEffect(()=>{!r&&s.length>0&&o(s[0])},[s,r]),p.useEffect(()=>{r&&(i(!0),c(null),at(r).then(u=>{var h;const l=(h=u.input)==null?void 0:h.properties;i(!!(l!=null&&l.messages))}).catch(u=>{const l=u.detail||{};c(l.error||l.message||`Failed to load entrypoint "${r}"`)}))},[r]);const x=u=>{r&&t(`#/setup/${encodeURIComponent(r)}/${u}`)};return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"w-full max-w-xl px-6",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{background:a?"var(--error)":"var(--accent)"}}),e.jsx("span",{className:"text-xs uppercase tracking-widest font-semibold",style:{color:"var(--text-muted)"},children:"New Run"})]}),!a&&e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:s.length>1?"Select an entrypoint and choose a mode":"Choose a mode"})]}),s.length>1&&e.jsxs("div",{className:"mb-8",children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-wider font-semibold mb-2",style:{color:"var(--text-muted)"},children:"Entrypoint"}),e.jsx("select",{value:r,onChange:u=>o(u.target.value),className:"w-full rounded-md px-3 py-1.5 text-xs font-mono cursor-pointer appearance-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)",color:"var(--text-primary)"},children:s.map(u=>e.jsx("option",{value:u,children:u},u))})]}),a?e.jsxs("div",{className:"rounded-md border overflow-hidden",style:{borderColor:"color-mix(in srgb, var(--error) 25%, var(--border))",background:"var(--bg-secondary)"},children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2",style:{borderBottom:"1px solid color-mix(in srgb, var(--error) 15%, var(--border))",background:"color-mix(in srgb, var(--error) 4%, var(--bg-secondary))"},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:e.jsx("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7.25 4.75h1.5v4h-1.5v-4zm.75 6.75a.75.75 0 110-1.5.75.75 0 010 1.5z",fill:"var(--error)"})}),e.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--error)"},children:"Failed to load entrypoint"})]}),e.jsx("div",{className:"overflow-auto max-h-48 p-3",children:e.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words leading-relaxed m-0",style:{color:"var(--text-muted)"},children:a})})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ge,{title:"Autonomous",description:"Run the agent end-to-end. Set breakpoints to pause and inspect execution.",icon:e.jsx(yt,{}),color:"var(--success)",onClick:()=>x("run"),disabled:!r}),e.jsx(ge,{title:"Conversational",description:n?"Interactive chat session. Send messages and receive responses in real time.":'Requires a "messages" property in the input schema.',icon:e.jsx(bt,{}),color:"var(--accent)",onClick:()=>x("chat"),disabled:!r||!n})]})]})})}function ge({title:t,description:s,icon:r,color:o,onClick:n,disabled:i}){return e.jsxs("button",{onClick:n,disabled:i,className:"group flex flex-col items-center text-center p-6 rounded-lg border transition-all cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},onMouseEnter:a=>{i||(a.currentTarget.style.borderColor=o,a.currentTarget.style.background=`color-mix(in srgb, ${o} 5%, var(--bg-secondary))`)},onMouseLeave:a=>{a.currentTarget.style.borderColor="var(--border)",a.currentTarget.style.background="var(--bg-secondary)"},children:[e.jsx("div",{className:"mb-4 p-3 rounded-xl transition-colors",style:{background:`color-mix(in srgb, ${o} 10%, var(--bg-primary))`,color:o},children:r}),e.jsx("h3",{className:"text-sm font-semibold mb-1.5",style:{color:"var(--text-primary)"},children:t}),e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:s})]})}function yt(){return e.jsx("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M23.832 15.166H22.7487C22.7487 10.9735 19.3579 7.58268 15.1654 7.58268H14.082V6.20685C14.732 5.83852 15.1654 5.13435 15.1654 4.33268C15.1654 3.14102 14.2012 2.16602 12.9987 2.16602C11.7962 2.16602 10.832 3.14102 10.832 4.33268C10.832 5.13435 11.2654 5.83852 11.9154 6.20685V7.58268H10.832C6.63953 7.58268 3.2487 10.9735 3.2487 15.166H2.16536C1.56953 15.166 1.08203 15.6535 1.08203 16.2493V19.4993C1.08203 20.0952 1.56953 20.5827 2.16536 20.5827H3.2487V21.666C3.2487 22.8685 4.2237 23.8327 5.41536 23.8327H20.582C21.7845 23.8327 22.7487 22.8685 22.7487 21.666V20.5827H23.832C24.4279 20.5827 24.9154 20.0952 24.9154 19.4993V16.2493C24.9154 15.6535 24.4279 15.166 23.832 15.166ZM22.7487 18.416H20.582V21.666H5.41536V18.416H3.2487V17.3327H5.41536V15.166C5.41536 12.176 7.84203 9.74935 10.832 9.74935H15.1654C18.1554 9.74935 20.582 12.176 20.582 15.166V17.3327H22.7487V18.416ZM9.20703 14.6243L11.7637 17.181L10.4854 18.4594L9.20703 17.181L7.9287 18.4594L6.65036 17.181L9.20703 14.6243ZM16.7904 14.6243L19.347 17.181L18.0687 18.4594L16.7904 17.181L15.512 18.4594L14.2337 17.181L16.7904 14.6243Z",fill:"currentColor"})})}function bt(){return e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M9.20901 13.541L11.7657 16.0977L10.4873 17.376L9.20901 16.0977L7.93068 17.376L6.65234 16.0977L9.20901 13.541ZM16.7923 13.541L19.349 16.0977L18.0707 17.376L16.7923 16.0977L15.514 17.376L14.2357 16.0977L16.7923 13.541Z",fill:"currentColor"}),e.jsx("path",{d:"M5.25 8.58398H20.75C21.3023 8.58398 21.75 9.0317 21.75 9.58398V23.5293L16.874 21.9043C16.5683 21.8024 16.248 21.751 15.9258 21.751H5.25C4.69782 21.751 4.25018 21.3031 4.25 20.751V9.58398C4.25 9.0317 4.69772 8.58398 5.25 8.58398Z",stroke:"currentColor",strokeWidth:"2"}),e.jsx("ellipse",{cx:"12.9987",cy:"4.33268",rx:"2.16667",ry:"2.16667",fill:"currentColor"}),e.jsx("rect",{x:"11.918",y:"5.41602",width:"2.16667",height:"2.16667",fill:"currentColor"}),e.jsx("path",{d:"M1.08203 14C1.08203 13.4477 1.52975 13 2.08203 13H3.2487V18.4167H2.08203C1.52975 18.4167 1.08203 17.969 1.08203 17.4167V14Z",fill:"currentColor"}),e.jsx("rect",{x:"3.25",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"}),e.jsx("path",{d:"M22.75 13H23.9167C24.4689 13 24.9167 13.4477 24.9167 14V17.4167C24.9167 17.969 24.469 18.4167 23.9167 18.4167H22.75V13Z",fill:"currentColor"}),e.jsx("rect",{x:"20.582",y:"15.166",width:"2.16667",height:"1.08333",fill:"currentColor"})]})}const jt="modulepreload",wt=function(t){return"/"+t},fe={},He=function(s,r,o){let n=Promise.resolve();if(r&&r.length>0){let a=function(u){return Promise.all(u.map(l=>Promise.resolve(l).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),x=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));n=a(r.map(u=>{if(u=wt(u),u in fe)return;fe[u]=!0;const l=u.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const j=document.createElement("link");if(j.rel=l?"stylesheet":jt,l||(j.as="script"),j.crossOrigin="",j.href=u,x&&j.setAttribute("nonce",x),document.head.appendChild(j),l)return new Promise((b,E)=>{j.addEventListener("load",b),j.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return n.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return s().catch(i)})},kt={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Nt({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"Start",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,x=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":"var(--node-border)",u=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${x}`,boxShadow:i||a||c?`0 0 4px ${u}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),o,e.jsx(Y,{type:"source",position:X.Bottom,style:kt})]})}const St={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Et({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"End",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,x=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="failed"?"var(--error)":"var(--node-border)",u=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-full text-center text-xs overflow-hidden text-ellipsis whitespace-nowrap cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${x}`,boxShadow:i||a||c?`0 0 4px ${u}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:St}),o]})}const ve={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Ct({data:t}){const s=t.status,r=t.nodeWidth,o=t.model_name,n=t.label??"Model",i=t.hasBreakpoint,a=t.isPausedHere,c=t.isActiveNode,x=t.isExecutingNode,u=a?"var(--error)":x?"var(--success)":c?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",l=a?"var(--error)":x?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${u}`,boxShadow:a||c||x?`0 0 4px ${l}`:void 0,animation:a||c||x?`node-pulse-${a?"red":x?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o?`${n} +${o}`:n,children:[i&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:ve}),e.jsx("div",{style:{color:"var(--info)",fontSize:9,marginBottom:1},children:"model"}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:n}),o&&e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",style:{color:"var(--text-muted)",fontSize:9,marginTop:1},title:o,children:o}),e.jsx(Y,{type:"source",position:X.Bottom,style:ve})]})}const ye={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0},_t=3;function Lt({data:t}){const s=t.status,r=t.nodeWidth,o=t.tool_names,n=t.tool_count,i=t.label??"Tool",a=t.hasBreakpoint,c=t.isPausedHere,x=t.isActiveNode,u=t.isExecutingNode,l=c?"var(--error)":u?"var(--success)":x?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",h=c?"var(--error)":u?"var(--success)":"var(--accent)",j=(o==null?void 0:o.slice(0,_t))??[],b=(n??(o==null?void 0:o.length)??0)-j.length;return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${l}`,boxShadow:c||x||u?`0 0 4px ${h}`:void 0,animation:c||x||u?`node-pulse-${c?"red":u?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o!=null&&o.length?`${i} ${o.join(` -`)}`:i,children:[a&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:ve}),e.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",n?` (${n})`:""]}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),j.length>0&&e.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[j.map(E=>e.jsx("div",{className:"truncate",children:E},E)),y>0&&e.jsxs("div",{style:{fontStyle:"italic"},children:["+",y," more"]})]}),e.jsx(Y,{type:"source",position:X.Bottom,style:ve})]})}const ye={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Tt({data:t}){const s=t.label??"",r=t.status,o=t.hasBreakpoint,n=t.isPausedHere,i=t.isActiveNode,a=t.isExecutingNode,c=n?"var(--error)":a?"var(--success)":i?"var(--accent)":r==="completed"?"var(--success)":r==="running"?"var(--warning)":r==="failed"?"var(--error)":"var(--bg-tertiary)",m=n?"var(--error)":a?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${n||i||a?"solid":"dashed"} ${c}`,borderRadius:8,boxShadow:n||i||a?`0 0 4px ${m}`:void 0,animation:n||i||a?`node-pulse-${n?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[o&&e.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),e.jsx(Y,{type:"target",position:X.Top,style:ye}),e.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${c}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:s}),e.jsx(Y,{type:"source",position:X.Bottom,style:ye})]})}function Mt({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,m=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",d=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${m}`,boxShadow:i||a||c?`0 0 4px ${d}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),e.jsx(Y,{type:"source",position:X.Bottom})]})}function Rt(t,s=8){if(t.length<2)return"";if(t.length===2)return`M ${t[0].x} ${t[0].y} L ${t[1].x} ${t[1].y}`;let r=`M ${t[0].x} ${t[0].y}`;for(let n=1;n0&&(r+=Math.min(o.length,3)*12+(o.length>3?12:0)+4),t!=null&&t.model_name&&(r+=14),r}let ie=null;async function At(){if(!ie){const{default:t}=await He(async()=>{const{default:s}=await import("./vendor-elk-CTNP4r_q.js").then(r=>r.e);return{default:s}},__vite__mapDeps([0,1]));ie=new t}return ie}const we={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},Bt="[top=35,left=15,bottom=15,right=15]";function Dt(t){const s=[],r=[];for(const o of t.nodes){const n=o.data,i={id:o.id,width:be(n),height:je(n,o.type)};if(o.data.subgraph){const a=o.data.subgraph;delete i.width,delete i.height,i.layoutOptions={...we,"elk.padding":Bt},i.children=a.nodes.map(c=>({id:`${o.id}/${c.id}`,width:be(c.data),height:je(c.data,c.type)})),i.edges=a.edges.map(c=>({id:`${o.id}/${c.id}`,sources:[`${o.id}/${c.source}`],targets:[`${o.id}/${c.target}`]}))}s.push(i)}for(const o of t.edges)r.push({id:o.id,sources:[o.source],targets:[o.target]});return{id:"root",layoutOptions:we,children:s,edges:r}}const le={type:Je.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function Ae(t){return{stroke:"var(--node-border)",strokeWidth:1.5,...t?{strokeDasharray:"6 3"}:{}}}function ke(t,s,r,o,n){var d;const i=(d=t.sections)==null?void 0:d[0],a=(n==null?void 0:n.x)??0,c=(n==null?void 0:n.y)??0;let m;if(i)m={sourcePoint:{x:i.startPoint.x+a,y:i.startPoint.y+c},targetPoint:{x:i.endPoint.x+a,y:i.endPoint.y+c},bendPoints:(i.bendPoints??[]).map(l=>({x:l.x+a,y:l.y+c}))};else{const l=s.get(t.sources[0]),x=s.get(t.targets[0]);l&&x&&(m={sourcePoint:{x:l.x+l.width/2,y:l.y+l.height},targetPoint:{x:x.x+x.width/2,y:x.y},bendPoints:[]})}return{id:t.id,source:t.sources[0],target:t.targets[0],type:"elk",data:m,style:Ae(o),markerEnd:le,...r?{label:r,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function zt(t){var m,d;const s=Dt(t),o=await(await At()).layout(s),n=new Map;for(const l of t.nodes)if(n.set(l.id,{type:l.type,data:l.data}),l.data.subgraph)for(const x of l.data.subgraph.nodes)n.set(`${l.id}/${x.id}`,{type:x.type,data:x.data});const i=[],a=[],c=new Map;for(const l of o.children??[]){const x=l.x??0,j=l.y??0;c.set(l.id,{x,y:j,width:l.width??0,height:l.height??0});for(const y of l.children??[])c.set(y.id,{x:x+(y.x??0),y:j+(y.y??0),width:y.width??0,height:y.height??0})}for(const l of o.children??[]){const x=n.get(l.id);if((((m=l.children)==null?void 0:m.length)??0)>0){i.push({id:l.id,type:"groupNode",data:{...(x==null?void 0:x.data)??{},nodeWidth:l.width,nodeHeight:l.height},position:{x:l.x??0,y:l.y??0},style:{width:l.width,height:l.height}});for(const k of l.children??[]){const w=n.get(k.id);i.push({id:k.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:k.width},position:{x:k.x??0,y:k.y??0},parentNode:l.id,extent:"parent"})}const y=l.x??0,E=l.y??0;for(const k of l.edges??[]){const w=t.nodes.find(B=>B.id===l.id),$=(d=w==null?void 0:w.data.subgraph)==null?void 0:d.edges.find(B=>`${l.id}/${B.id}`===k.id);a.push(ke(k,c,$==null?void 0:$.label,$==null?void 0:$.conditional,{x:y,y:E}))}}else i.push({id:l.id,type:(x==null?void 0:x.type)??"defaultNode",data:{...(x==null?void 0:x.data)??{},nodeWidth:l.width},position:{x:l.x??0,y:l.y??0}})}for(const l of o.edges??[]){const x=t.edges.find(j=>j.id===l.id);a.push(ke(l,c,x==null?void 0:x.label,x==null?void 0:x.conditional))}return{nodes:i,edges:a}}function ne({entrypoint:t,runId:s,breakpointNode:r,breakpointNextNodes:o,onBreakpointChange:n,fitViewTrigger:i}){const[a,c,m]=Ge([]),[d,l,x]=qe([]),[j,y]=h.useState(!0),[E,k]=h.useState(!1),[w,$]=h.useState(0),B=h.useRef(0),J=h.useRef(null),F=W(u=>u.breakpoints[s]),N=W(u=>u.toggleBreakpoint),L=W(u=>u.clearBreakpoints),I=W(u=>u.activeNodes[s]),D=W(u=>{var p;return(p=u.runs[s])==null?void 0:p.status}),G=h.useCallback((u,p)=>{if(p.type==="startNode"||p.type==="endNode")return;const b=p.type==="groupNode"?p.id:p.id.includes("/")?p.id.split("/").pop():p.id;N(s,b);const T=W.getState().breakpoints[s]??{};n==null||n(Object.keys(T))},[s,N,n]),z=F&&Object.keys(F).length>0,q=h.useCallback(()=>{if(z)L(s),n==null||n([]);else{const u=[];for(const b of a){if(b.type==="startNode"||b.type==="endNode"||b.parentNode)continue;const T=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id;u.push(T)}for(const b of u)F!=null&&F[b]||N(s,b);const p=W.getState().breakpoints[s]??{};n==null||n(Object.keys(p))}},[s,z,F,a,L,N,n]);h.useEffect(()=>{c(u=>u.map(p=>{var g;if(p.type==="startNode"||p.type==="endNode")return p;const b=p.type==="groupNode"?p.id:p.id.includes("/")?p.id.split("/").pop():p.id,T=!!(F&&F[b]);return T!==!!((g=p.data)!=null&&g.hasBreakpoint)?{...p,data:{...p.data,hasBreakpoint:T}}:p}))},[F,c]),h.useEffect(()=>{const u=r?new Set(r.split(",").map(p=>p.trim()).filter(Boolean)):null;c(p=>p.map(b=>{var H,f;if(b.type==="startNode"||b.type==="endNode")return b;const T=b.type==="groupNode"?b.id:b.id.includes("/")?b.id.split("/").pop():b.id,g=(H=b.data)==null?void 0:H.label,S=u!=null&&(u.has(T)||g!=null&&u.has(g));return S!==!!((f=b.data)!=null&&f.isPausedHere)?{...b,data:{...b.data,isPausedHere:S}}:b}))},[r,w,c]);const R=W(u=>u.stateEvents[s]);h.useEffect(()=>{const u=!!r;let p=new Set;const b=new Set,T=new Set,g=new Set,S=new Map,H=new Map;if(R)for(const f of R)f.phase==="started"?H.set(f.node_name,f.qualified_node_name??null):f.phase==="completed"&&H.delete(f.node_name);c(f=>{var C;for(const A of f)A.type&&S.set(A.id,A.type);const _=A=>{var v;const O=[];for(const M of f){const V=M.type==="groupNode"?M.id:M.id.includes("/")?M.id.split("/").pop():M.id,U=(v=M.data)==null?void 0:v.label;(V===A||U!=null&&U===A)&&O.push(M.id)}return O};if(u&&r){const A=r.split(",").map(O=>O.trim()).filter(Boolean);for(const O of A)_(O).forEach(v=>p.add(v));if(o!=null&&o.length)for(const O of o)_(O).forEach(v=>T.add(v));I!=null&&I.prev&&_(I.prev).forEach(O=>b.add(O))}else if(H.size>0){const A=new Map;for(const O of f){const v=(C=O.data)==null?void 0:C.label;if(!v)continue;const M=O.id.includes("/")?O.id.split("/").pop():O.id;for(const V of[M,v]){let U=A.get(V);U||(U=new Set,A.set(V,U)),U.add(O.id)}}for(const[O,v]of H){let M=!1;if(v){const V=v.replace(/:/g,"/");for(const U of f)U.id===V&&(p.add(U.id),M=!0)}if(!M){const V=A.get(O);V&&V.forEach(U=>p.add(U))}}}return f}),l(f=>{const _=b.size===0||f.some(C=>p.has(C.target)&&b.has(C.source));return f.map(C=>{var O,v;let A;return u?A=p.has(C.target)&&(b.size===0||!_||b.has(C.source))||p.has(C.source)&&T.has(C.target):(A=p.has(C.source),!A&&S.get(C.target)==="endNode"&&p.has(C.target)&&(A=!0)),A?(u||g.add(C.target),{...C,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...le,color:"var(--accent)"},data:{...C.data,highlighted:!0},animated:!0}):(O=C.data)!=null&&O.highlighted?{...C,style:Ae((v=C.data)==null?void 0:v.conditional),markerEnd:le,data:{...C.data,highlighted:!1},animated:!1}:C})}),c(f=>f.map(_=>{var O,v,M,V;const C=!u&&p.has(_.id);if(_.type==="startNode"||_.type==="endNode"){const U=g.has(_.id)||!u&&p.has(_.id);return U!==!!((O=_.data)!=null&&O.isActiveNode)||C!==!!((v=_.data)!=null&&v.isExecutingNode)?{..._,data:{..._.data,isActiveNode:U,isExecutingNode:C}}:_}const A=u?T.has(_.id):g.has(_.id);return A!==!!((M=_.data)!=null&&M.isActiveNode)||C!==!!((V=_.data)!=null&&V.isExecutingNode)?{..._,data:{..._.data,isActiveNode:A,isExecutingNode:C}}:_}))},[R,I,r,o,D,w,c,l]);const P=W(u=>u.graphCache[s]);return h.useEffect(()=>{if(!P&&s!=="__setup__")return;const u=P?Promise.resolve(P):ct(t),p=++B.current;y(!0),k(!1),u.then(async b=>{if(B.current!==p)return;if(!b.nodes.length){k(!0);return}const{nodes:T,edges:g}=await zt(b);if(B.current!==p)return;const S=W.getState().breakpoints[s],H=S?T.map(f=>{if(f.type==="startNode"||f.type==="endNode")return f;const _=f.type==="groupNode"?f.id:f.id.includes("/")?f.id.split("/").pop():f.id;return S[_]?{...f,data:{...f.data,hasBreakpoint:!0}}:f}):T;c(H),l(g),$(f=>f+1),setTimeout(()=>{var f;(f=J.current)==null||f.fitView({padding:.1,duration:200})},100)}).catch(()=>{B.current===p&&k(!0)}).finally(()=>{B.current===p&&y(!1)})},[t,s,P,c,l]),h.useEffect(()=>{const u=setTimeout(()=>{var p;(p=J.current)==null||p.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(u)},[s]),h.useEffect(()=>{var u;i&&((u=J.current)==null||u.fitView({padding:.1,duration:200}))},[i]),h.useEffect(()=>{c(u=>{var C,A,O;const p=!!(R!=null&&R.length),b=D==="completed"||D==="failed",T=new Set,g=new Set(u.map(v=>v.id)),S=new Map;for(const v of u){const M=(C=v.data)==null?void 0:C.label;if(!M)continue;const V=v.id.includes("/")?v.id.split("/").pop():v.id;for(const U of[V,M]){let se=S.get(U);se||(se=new Set,S.set(U,se)),se.add(v.id)}}if(p)for(const v of R){let M=!1;if(v.qualified_node_name){const V=v.qualified_node_name.replace(/:/g,"/");g.has(V)&&(T.add(V),M=!0)}if(!M){const V=S.get(v.node_name);V&&V.forEach(U=>T.add(U))}}const H=new Set;for(const v of u)v.parentNode&&T.has(v.id)&&H.add(v.parentNode);let f;D==="failed"&&T.size===0&&(f=(A=u.find(v=>!v.parentNode&&v.type!=="startNode"&&v.type!=="endNode"&&v.type!=="groupNode"))==null?void 0:A.id);let _;if(D==="completed"){const v=(O=u.find(M=>!M.parentNode&&M.type!=="startNode"&&M.type!=="endNode"&&M.type!=="groupNode"))==null?void 0:O.id;v&&!T.has(v)&&(_=v)}return u.map(v=>{var V;let M;return v.id===f?M="failed":v.id===_||T.has(v.id)?M="completed":v.type==="startNode"?(!v.parentNode&&p||v.parentNode&&H.has(v.parentNode))&&(M="completed"):v.type==="endNode"?!v.parentNode&&b?M=D==="failed"?"failed":"completed":v.parentNode&&H.has(v.parentNode)&&(M="completed"):v.type==="groupNode"&&H.has(v.id)&&(M="completed"),M!==((V=v.data)==null?void 0:V.status)?{...v,data:{...v.data,status:M}}:v})})},[R,D,w,c]),j?e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):E?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[e.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),e.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),e.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):e.jsxs("div",{className:"h-full graph-panel",children:[e.jsx("style",{children:` +`)}`:i,children:[a&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top,style:ye}),e.jsxs("div",{style:{color:"var(--warning)",fontSize:9,marginBottom:1},children:["tools",n?` (${n})`:""]}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:i}),j.length>0&&e.jsxs("div",{style:{marginTop:3,fontSize:9,color:"var(--text-muted)",textAlign:"left"},children:[j.map(E=>e.jsx("div",{className:"truncate",children:E},E)),b>0&&e.jsxs("div",{style:{fontStyle:"italic"},children:["+",b," more"]})]}),e.jsx(Y,{type:"source",position:X.Bottom,style:ye})]})}const be={opacity:0,width:1,height:1,minWidth:0,minHeight:0,border:"none",padding:0};function Tt({data:t}){const s=t.label??"",r=t.status,o=t.hasBreakpoint,n=t.isPausedHere,i=t.isActiveNode,a=t.isExecutingNode,c=n?"var(--error)":a?"var(--success)":i?"var(--accent)":r==="completed"?"var(--success)":r==="running"?"var(--warning)":r==="failed"?"var(--error)":"var(--bg-tertiary)",x=n?"var(--error)":a?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"relative cursor-pointer",style:{width:"100%",height:"100%",background:"var(--bg-secondary)",border:`1.5px ${n||i||a?"solid":"dashed"} ${c}`,borderRadius:8,boxShadow:n||i||a?`0 0 4px ${x}`:void 0,animation:n||i||a?`node-pulse-${n?"red":a?"green":"accent"} 1.5s ease-in-out infinite`:void 0},children:[o&&e.jsx("div",{className:"absolute",style:{top:4,left:4,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--bg-tertiary)",boxShadow:"0 0 4px var(--error)",zIndex:1}}),e.jsx(Y,{type:"target",position:X.Top,style:be}),e.jsx("div",{style:{padding:"4px 10px",fontSize:10,color:"var(--text-muted)",fontWeight:600,textAlign:"center",borderBottom:`1px solid ${c}`,background:"var(--bg-tertiary)",borderRadius:"8px 8px 0 0"},children:s}),e.jsx(Y,{type:"source",position:X.Bottom,style:be})]})}function Mt({data:t}){const s=t.status,r=t.nodeWidth,o=t.label??"",n=t.hasBreakpoint,i=t.isPausedHere,a=t.isActiveNode,c=t.isExecutingNode,x=i?"var(--error)":c?"var(--success)":a?"var(--accent)":s==="completed"?"var(--success)":s==="running"?"var(--warning)":s==="failed"?"var(--error)":"var(--node-border)",u=i?"var(--error)":c?"var(--success)":"var(--accent)";return e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center text-xs overflow-hidden cursor-pointer relative",style:{width:r,background:"var(--node-bg)",color:"var(--text-primary)",border:`2px solid ${x}`,boxShadow:i||a||c?`0 0 4px ${u}`:void 0,animation:i||a||c?`node-pulse-${i?"red":c?"green":"accent"} 1.5s ease-in-out infinite`:void 0},title:o,children:[n&&e.jsx("div",{className:"absolute",style:{top:2,left:2,width:12,height:12,borderRadius:"50%",background:"var(--error)",border:"2px solid var(--node-bg)",boxShadow:"0 0 4px var(--error)"}}),e.jsx(Y,{type:"target",position:X.Top}),e.jsx("div",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:o}),e.jsx(Y,{type:"source",position:X.Bottom})]})}function Rt(t,s=8){if(t.length<2)return"";if(t.length===2)return`M ${t[0].x} ${t[0].y} L ${t[1].x} ${t[1].y}`;let r=`M ${t[0].x} ${t[0].y}`;for(let n=1;n0&&(r+=Math.min(o.length,3)*12+(o.length>3?12:0)+4),t!=null&&t.model_name&&(r+=14),r}let ce=null;async function At(){if(!ce){const{default:t}=await He(async()=>{const{default:s}=await import("./vendor-elk-CTNP4r_q.js").then(r=>r.e);return{default:s}},__vite__mapDeps([0,1]));ce=new t}return ce}const ke={"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.spacing.nodeNode":"25","elk.layered.spacing.nodeNodeBetweenLayers":"50","elk.spacing.edgeNode":"30","elk.spacing.edgeEdge":"15","elk.layered.spacing.edgeNodeBetweenLayers":"25","elk.layered.spacing.edgeEdgeBetweenLayers":"15","elk.portAlignment.default":"CENTER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},Bt="[top=35,left=15,bottom=15,right=15]";function Dt(t){const s=[],r=[];for(const o of t.nodes){const n=o.data,i={id:o.id,width:je(n),height:we(n,o.type)};if(o.data.subgraph){const a=o.data.subgraph;delete i.width,delete i.height,i.layoutOptions={...ke,"elk.padding":Bt},i.children=a.nodes.map(c=>({id:`${o.id}/${c.id}`,width:je(c.data),height:we(c.data,c.type)})),i.edges=a.edges.map(c=>({id:`${o.id}/${c.id}`,sources:[`${o.id}/${c.source}`],targets:[`${o.id}/${c.target}`]}))}s.push(i)}for(const o of t.edges)r.push({id:o.id,sources:[o.source],targets:[o.target]});return{id:"root",layoutOptions:ke,children:s,edges:r}}const de={type:Je.ArrowClosed,width:12,height:12,color:"var(--node-border)"};function Ae(t){return{stroke:"var(--node-border)",strokeWidth:1.5,...t?{strokeDasharray:"6 3"}:{}}}function Ne(t,s,r,o,n){var u;const i=(u=t.sections)==null?void 0:u[0],a=(n==null?void 0:n.x)??0,c=(n==null?void 0:n.y)??0;let x;if(i)x={sourcePoint:{x:i.startPoint.x+a,y:i.startPoint.y+c},targetPoint:{x:i.endPoint.x+a,y:i.endPoint.y+c},bendPoints:(i.bendPoints??[]).map(l=>({x:l.x+a,y:l.y+c}))};else{const l=s.get(t.sources[0]),h=s.get(t.targets[0]);l&&h&&(x={sourcePoint:{x:l.x+l.width/2,y:l.y+l.height},targetPoint:{x:h.x+h.width/2,y:h.y},bendPoints:[]})}return{id:t.id,source:t.sources[0],target:t.targets[0],type:"elk",data:x,style:Ae(o),markerEnd:de,...r?{label:r,labelStyle:{fill:"var(--text-muted)",fontSize:10},labelBgStyle:{fill:"var(--bg-primary)",fillOpacity:.8}}:{}}}async function zt(t){var x,u;const s=Dt(t),o=await(await At()).layout(s),n=new Map;for(const l of t.nodes)if(n.set(l.id,{type:l.type,data:l.data}),l.data.subgraph)for(const h of l.data.subgraph.nodes)n.set(`${l.id}/${h.id}`,{type:h.type,data:h.data});const i=[],a=[],c=new Map;for(const l of o.children??[]){const h=l.x??0,j=l.y??0;c.set(l.id,{x:h,y:j,width:l.width??0,height:l.height??0});for(const b of l.children??[])c.set(b.id,{x:h+(b.x??0),y:j+(b.y??0),width:b.width??0,height:b.height??0})}for(const l of o.children??[]){const h=n.get(l.id);if((((x=l.children)==null?void 0:x.length)??0)>0){i.push({id:l.id,type:"groupNode",data:{...(h==null?void 0:h.data)??{},nodeWidth:l.width,nodeHeight:l.height},position:{x:l.x??0,y:l.y??0},style:{width:l.width,height:l.height}});for(const k of l.children??[]){const w=n.get(k.id);i.push({id:k.id,type:(w==null?void 0:w.type)??"defaultNode",data:{...(w==null?void 0:w.data)??{},nodeWidth:k.width},position:{x:k.x??0,y:k.y??0},parentNode:l.id,extent:"parent"})}const b=l.x??0,E=l.y??0;for(const k of l.edges??[]){const w=t.nodes.find(B=>B.id===l.id),R=(u=w==null?void 0:w.data.subgraph)==null?void 0:u.edges.find(B=>`${l.id}/${B.id}`===k.id);a.push(Ne(k,c,R==null?void 0:R.label,R==null?void 0:R.conditional,{x:b,y:E}))}}else i.push({id:l.id,type:(h==null?void 0:h.type)??"defaultNode",data:{...(h==null?void 0:h.data)??{},nodeWidth:l.width},position:{x:l.x??0,y:l.y??0}})}for(const l of o.edges??[]){const h=t.edges.find(j=>j.id===l.id);a.push(Ne(l,c,h==null?void 0:h.label,h==null?void 0:h.conditional))}return{nodes:i,edges:a}}function ae({entrypoint:t,runId:s,breakpointNode:r,breakpointNextNodes:o,onBreakpointChange:n,fitViewTrigger:i}){const[a,c,x]=Ge([]),[u,l,h]=qe([]),[j,b]=p.useState(!0),[E,k]=p.useState(!1),[w,R]=p.useState(0),B=p.useRef(0),J=p.useRef(null),V=H(y=>y.breakpoints[s]),N=H(y=>y.toggleBreakpoint),L=H(y=>y.clearBreakpoints),W=H(y=>y.activeNodes[s]),D=H(y=>{var d;return(d=y.runs[s])==null?void 0:d.status}),G=p.useCallback((y,d)=>{if(d.type==="startNode"||d.type==="endNode")return;const g=d.type==="groupNode"?d.id:d.id.includes("/")?d.id.split("/").pop():d.id;N(s,g);const P=H.getState().breakpoints[s]??{};n==null||n(Object.keys(P))},[s,N,n]),z=V&&Object.keys(V).length>0,q=p.useCallback(()=>{if(z)L(s),n==null||n([]);else{const y=[];for(const g of a){if(g.type==="startNode"||g.type==="endNode"||g.parentNode)continue;const P=g.type==="groupNode"?g.id:g.id.includes("/")?g.id.split("/").pop():g.id;y.push(P)}for(const g of y)V!=null&&V[g]||N(s,g);const d=H.getState().breakpoints[s]??{};n==null||n(Object.keys(d))}},[s,z,V,a,L,N,n]);p.useEffect(()=>{c(y=>y.map(d=>{var m;if(d.type==="startNode"||d.type==="endNode")return d;const g=d.type==="groupNode"?d.id:d.id.includes("/")?d.id.split("/").pop():d.id,P=!!(V&&V[g]);return P!==!!((m=d.data)!=null&&m.hasBreakpoint)?{...d,data:{...d.data,hasBreakpoint:P}}:d}))},[V,c]),p.useEffect(()=>{const y=r?new Set(r.split(",").map(d=>d.trim()).filter(Boolean)):null;c(d=>d.map(g=>{var $,f;if(g.type==="startNode"||g.type==="endNode")return g;const P=g.type==="groupNode"?g.id:g.id.includes("/")?g.id.split("/").pop():g.id,m=($=g.data)==null?void 0:$.label,S=y!=null&&(y.has(P)||m!=null&&y.has(m));return S!==!!((f=g.data)!=null&&f.isPausedHere)?{...g,data:{...g.data,isPausedHere:S}}:g}))},[r,w,c]);const M=H(y=>y.stateEvents[s]);p.useEffect(()=>{const y=!!r;let d=new Set;const g=new Set,P=new Set,m=new Set,S=new Map,$=new Map;if(M)for(const f of M)f.phase==="started"?$.set(f.node_name,f.qualified_node_name??null):f.phase==="completed"&&$.delete(f.node_name);c(f=>{var C;for(const O of f)O.type&&S.set(O.id,O.type);const _=O=>{var v;const A=[];for(const T of f){const F=T.type==="groupNode"?T.id:T.id.includes("/")?T.id.split("/").pop():T.id,U=(v=T.data)==null?void 0:v.label;(F===O||U!=null&&U===O)&&A.push(T.id)}return A};if(y&&r){const O=r.split(",").map(A=>A.trim()).filter(Boolean);for(const A of O)_(A).forEach(v=>d.add(v));if(o!=null&&o.length)for(const A of o)_(A).forEach(v=>P.add(v));W!=null&&W.prev&&_(W.prev).forEach(A=>g.add(A))}else if($.size>0){const O=new Map;for(const A of f){const v=(C=A.data)==null?void 0:C.label;if(!v)continue;const T=A.id.includes("/")?A.id.split("/").pop():A.id;for(const F of[T,v]){let U=O.get(F);U||(U=new Set,O.set(F,U)),U.add(A.id)}}for(const[A,v]of $){let T=!1;if(v){const F=v.replace(/:/g,"/");for(const U of f)U.id===F&&(d.add(U.id),T=!0)}if(!T){const F=O.get(A);F&&F.forEach(U=>d.add(U))}}}return f}),l(f=>{const _=g.size===0||f.some(C=>d.has(C.target)&&g.has(C.source));return f.map(C=>{var A,v;let O;return y?O=d.has(C.target)&&(g.size===0||!_||g.has(C.source))||d.has(C.source)&&P.has(C.target):(O=d.has(C.source),!O&&S.get(C.target)==="endNode"&&d.has(C.target)&&(O=!0)),O?(y||m.add(C.target),{...C,style:{stroke:"var(--accent)",strokeWidth:2.5},markerEnd:{...de,color:"var(--accent)"},data:{...C.data,highlighted:!0},animated:!0}):(A=C.data)!=null&&A.highlighted?{...C,style:Ae((v=C.data)==null?void 0:v.conditional),markerEnd:de,data:{...C.data,highlighted:!1},animated:!1}:C})}),c(f=>f.map(_=>{var A,v,T,F;const C=!y&&d.has(_.id);if(_.type==="startNode"||_.type==="endNode"){const U=m.has(_.id)||!y&&d.has(_.id);return U!==!!((A=_.data)!=null&&A.isActiveNode)||C!==!!((v=_.data)!=null&&v.isExecutingNode)?{..._,data:{..._.data,isActiveNode:U,isExecutingNode:C}}:_}const O=y?P.has(_.id):m.has(_.id);return O!==!!((T=_.data)!=null&&T.isActiveNode)||C!==!!((F=_.data)!=null&&F.isExecutingNode)?{..._,data:{..._.data,isActiveNode:O,isExecutingNode:C}}:_}))},[M,W,r,o,D,w,c,l]);const I=H(y=>y.graphCache[s]);return p.useEffect(()=>{if(!I&&s!=="__setup__")return;const y=I?Promise.resolve(I):ct(t),d=++B.current;b(!0),k(!1),y.then(async g=>{if(B.current!==d)return;if(!g.nodes.length){k(!0);return}const{nodes:P,edges:m}=await zt(g);if(B.current!==d)return;const S=H.getState().breakpoints[s],$=S?P.map(f=>{if(f.type==="startNode"||f.type==="endNode")return f;const _=f.type==="groupNode"?f.id:f.id.includes("/")?f.id.split("/").pop():f.id;return S[_]?{...f,data:{...f.data,hasBreakpoint:!0}}:f}):P;c($),l(m),R(f=>f+1),setTimeout(()=>{var f;(f=J.current)==null||f.fitView({padding:.1,duration:200})},100)}).catch(()=>{B.current===d&&k(!0)}).finally(()=>{B.current===d&&b(!1)})},[t,s,I,c,l]),p.useEffect(()=>{const y=setTimeout(()=>{var d;(d=J.current)==null||d.fitView({padding:.1,duration:200})},100);return()=>clearTimeout(y)},[s]),p.useEffect(()=>{var y;i&&((y=J.current)==null||y.fitView({padding:.1,duration:200}))},[i]),p.useEffect(()=>{c(y=>{var C,O,A;const d=!!(M!=null&&M.length),g=D==="completed"||D==="failed",P=new Set,m=new Set(y.map(v=>v.id)),S=new Map;for(const v of y){const T=(C=v.data)==null?void 0:C.label;if(!T)continue;const F=v.id.includes("/")?v.id.split("/").pop():v.id;for(const U of[F,T]){let se=S.get(U);se||(se=new Set,S.set(U,se)),se.add(v.id)}}if(d)for(const v of M){let T=!1;if(v.qualified_node_name){const F=v.qualified_node_name.replace(/:/g,"/");m.has(F)&&(P.add(F),T=!0)}if(!T){const F=S.get(v.node_name);F&&F.forEach(U=>P.add(U))}}const $=new Set;for(const v of y)v.parentNode&&P.has(v.id)&&$.add(v.parentNode);let f;D==="failed"&&P.size===0&&(f=(O=y.find(v=>!v.parentNode&&v.type!=="startNode"&&v.type!=="endNode"&&v.type!=="groupNode"))==null?void 0:O.id);let _;if(D==="completed"){const v=(A=y.find(T=>!T.parentNode&&T.type!=="startNode"&&T.type!=="endNode"&&T.type!=="groupNode"))==null?void 0:A.id;v&&!P.has(v)&&(_=v)}return y.map(v=>{var F;let T;return v.id===f?T="failed":v.id===_||P.has(v.id)?T="completed":v.type==="startNode"?(!v.parentNode&&d||v.parentNode&&$.has(v.parentNode))&&(T="completed"):v.type==="endNode"?!v.parentNode&&g?T=D==="failed"?"failed":"completed":v.parentNode&&$.has(v.parentNode)&&(T="completed"):v.type==="groupNode"&&$.has(v.id)&&(T="completed"),T!==((F=v.data)==null?void 0:F.status)?{...v,data:{...v.data,status:T}}:v})})},[M,D,w,c]),j?e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:"Loading graph..."}):E?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",style:{color:"var(--text-muted)"},children:[e.jsxs("svg",{width:"120",height:"120",viewBox:"0 0 120 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"38",y:"10",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"}),e.jsx("line",{x1:"60",y1:"34",x2:"60",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"12",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"64",y:"46",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"46",x2:"34",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"46",x2:"86",y2:"46",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"34",y1:"70",x2:"34",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"86",y1:"70",x2:"86",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"34",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"86",y1:"82",x2:"60",y2:"82",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("line",{x1:"60",y1:"82",x2:"60",y2:"86",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.3"}),e.jsx("rect",{x:"38",y:"86",width:"44",height:"24",rx:"6",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"4 3",opacity:"0.4"})]}),e.jsx("span",{className:"text-xs",children:"No graph schema available"})]}):e.jsxs("div",{className:"h-full graph-panel",children:[e.jsx("style",{children:` .graph-panel .react-flow__handle { opacity: 0 !important; width: 0 !important; @@ -37,6 +37,6 @@ ${o.join(` 0%, 100% { box-shadow: 0 0 4px var(--error); } 50% { box-shadow: 0 0 10px var(--error); } } - `}),e.jsxs(Ye,{nodes:a,edges:d,onNodesChange:m,onEdgesChange:x,nodeTypes:It,edgeTypes:Pt,onInit:u=>{J.current=u},onNodeClick:G,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[e.jsx(Xe,{color:"var(--bg-tertiary)",gap:16}),e.jsx(Ke,{showInteractive:!1}),e.jsx(Ze,{position:"top-right",children:e.jsxs("button",{onClick:q,title:z?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:z?"var(--error)":"var(--text-muted)",border:`1px solid ${z?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:z?"var(--error)":"var(--node-border)"}}),z?"Clear all":"Break all"]})}),e.jsx(Qe,{nodeColor:u=>{var b;if(u.type==="groupNode")return"var(--bg-tertiary)";const p=(b=u.data)==null?void 0:b.status;return p==="completed"?"var(--success)":p==="running"?"var(--warning)":p==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ee="__setup__";function Vt({entrypoint:t,mode:s,ws:r,onRunCreated:o,isMobile:n}){const[i,a]=h.useState("{}"),[c,m]=h.useState({}),[d,l]=h.useState(!1),[x,j]=h.useState(!0),[y,E]=h.useState(null),[k,w]=h.useState(""),[$,B]=h.useState(0),[J,F]=h.useState(!0),[N,L]=h.useState(()=>{const g=localStorage.getItem("setupTextareaHeight");return g?parseInt(g,10):140}),I=h.useRef(null),[D,G]=h.useState(()=>{const g=localStorage.getItem("setupPanelWidth");return g?parseInt(g,10):380}),z=s==="run";h.useEffect(()=>{j(!0),E(null),it(t).then(g=>{m(g.mock_input),a(JSON.stringify(g.mock_input,null,2))}).catch(g=>{console.error("Failed to load mock input:",g);const S=g.detail||{};E(S.message||`Failed to load schema for "${t}"`),a("{}")}).finally(()=>j(!1))},[t]),h.useEffect(()=>{W.getState().clearBreakpoints(ee)},[]);const q=async()=>{let g;try{g=JSON.parse(i)}catch{alert("Invalid JSON input");return}l(!0);try{const S=W.getState().breakpoints[ee]??{},H=Object.keys(S),f=await pe(t,g,s,H);W.getState().clearBreakpoints(ee),W.getState().upsertRun(f),o(f.id)}catch(S){console.error("Failed to create run:",S)}finally{l(!1)}},R=async()=>{const g=k.trim();if(g){l(!0);try{const S=W.getState().breakpoints[ee]??{},H=Object.keys(S),f=await pe(t,c,"chat",H);W.getState().clearBreakpoints(ee),W.getState().upsertRun(f),W.getState().addLocalChatMessage(f.id,{message_id:`local-${Date.now()}`,role:"user",content:g}),r.sendChatMessage(f.id,g),o(f.id)}catch(S){console.error("Failed to create chat run:",S)}finally{l(!1)}}};h.useEffect(()=>{try{JSON.parse(i),F(!0)}catch{F(!1)}},[i]);const P=h.useCallback(g=>{g.preventDefault();const S="touches"in g?g.touches[0].clientY:g.clientY,H=N,f=C=>{const A="touches"in C?C.touches[0].clientY:C.clientY,O=Math.max(60,H+(S-A));L(O)},_=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",_),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(N))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",f),document.addEventListener("mouseup",_),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",_)},[N]),u=h.useCallback(g=>{g.preventDefault();const S="touches"in g?g.touches[0].clientX:g.clientX,H=D,f=C=>{const A=I.current;if(!A)return;const O="touches"in C?C.touches[0].clientX:C.clientX,v=A.clientWidth-300,M=Math.max(280,Math.min(v,H+(S-O)));G(M)},_=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",_),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(D)),B(C=>C+1)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",f),document.addEventListener("mouseup",_),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",_)},[D]),p=z?"Autonomous":"Conversational",b=z?"var(--success)":"var(--accent)",T=e.jsxs("div",{className:"shrink-0 flex flex-col",style:n?{background:"var(--bg-primary)"}:{width:D,background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"px-4 text-xs font-semibold uppercase tracking-wider border-b flex items-center gap-2 h-[33px]",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{style:{color:b},children:"●"}),p]}),e.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[e.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:z?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}):e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsxs("div",{className:"text-center space-y-1.5",children:[e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:z?"Ready to execute":"Ready to chat"}),e.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",z?e.jsxs(e.Fragment,{children:[",",e.jsx("br",{}),"configure input below, then run"]}):e.jsxs(e.Fragment,{children:[",",e.jsx("br",{}),"then send your first message"]})]})]})]}),z?e.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!n&&e.jsx("div",{onMouseDown:P,onTouchStart:P,className:"shrink-0 h-1.5 cursor-row-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors"}),e.jsxs("div",{className:"px-4 py-3",children:[y?e.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:y}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block text-[10px] uppercase tracking-wider font-semibold mb-2",style:{color:"var(--text-muted)"},children:["Input",x&&e.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),e.jsx("textarea",{value:i,onChange:g=>a(g.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none focus:outline-none mb-3",style:{height:n?120:N,background:"var(--bg-secondary)",border:`1px solid ${J?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),e.jsx("button",{onClick:q,disabled:d||x||!!y,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:b,color:b},onMouseEnter:g=>{d||(g.currentTarget.style.background=`color-mix(in srgb, ${b} 10%, transparent)`)},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:d?"Starting...":e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:e.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[e.jsx("input",{value:k,onChange:g=>w(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),R())},disabled:d||x,placeholder:d?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 focus:outline-none disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),e.jsx("button",{onClick:R,disabled:d||x||!k.trim(),className:"text-[11px] uppercase tracking-wider font-semibold px-2 py-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!d&&k.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:g=>{!d&&k.trim()&&(g.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Send"})]})]});return n?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:e.jsx(ne,{entrypoint:t,traces:[],runId:ee,fitViewTrigger:$})}),e.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:T})]}):e.jsxs("div",{ref:I,className:"flex h-full",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ne,{entrypoint:t,traces:[],runId:ee,fitViewTrigger:$})}),e.jsx("div",{onMouseDown:u,onTouchStart:u,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),T]})}const Ft={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function Ut(t){const s=[],r=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let o=0,n;for(;(n=r.exec(t))!==null;){if(n.index>o&&s.push({type:"punctuation",text:t.slice(o,n.index)}),n[1]!==void 0){s.push({type:"key",text:n[1]});const i=t.indexOf(":",n.index+n[1].length);i!==-1&&(i>n.index+n[1].length&&s.push({type:"punctuation",text:t.slice(n.index+n[1].length,i)}),s.push({type:"punctuation",text:":"}),r.lastIndex=i+1)}else n[2]!==void 0?s.push({type:"string",text:n[2]}):n[3]!==void 0?s.push({type:"number",text:n[3]}):n[4]!==void 0?s.push({type:"boolean",text:n[4]}):n[5]!==void 0?s.push({type:"null",text:n[5]}):n[6]!==void 0&&s.push({type:"punctuation",text:n[6]});o=r.lastIndex}return oUt(t),[t]);return e.jsx("pre",{className:s,style:r,children:o.map((n,i)=>e.jsx("span",{style:{color:Ft[n.type]},children:n.text},i))})}const Jt={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},Gt={color:"var(--text-muted)",label:"Unknown"};function qt(t){if(typeof t!="string")return null;const s=t.trim();if(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]"))try{return JSON.stringify(JSON.parse(s),null,2)}catch{return null}return null}function Yt(t){if(t<1)return`${(t*1e3).toFixed(0)}us`;if(t<1e3)return`${t.toFixed(2)}ms`;if(t<6e4)return`${(t/1e3).toFixed(2)}s`;const s=Math.floor(t/6e4),r=(t%6e4/1e3).toFixed(1);return`${s}m ${r}s`}const Ne=200;function Xt(t){if(typeof t=="string")return t;if(t==null)return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Kt({value:t}){const[s,r]=h.useState(!1),o=Xt(t),n=h.useMemo(()=>qt(t),[t]),i=n!==null,a=n??o,c=a.length>Ne||a.includes(` -`),m=h.useCallback(()=>r(d=>!d),[]);return c?e.jsxs("div",{children:[s?i?e.jsx(te,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):e.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):e.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,Ne),"..."]}),e.jsx("button",{onClick:m,className:"text-[10px] cursor-pointer ml-1",style:{color:"var(--info)"},children:s?"[less]":"[more]"})]}):i?e.jsx(te,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):e.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function Zt({span:t}){const[s,r]=h.useState(!0),[o,n]=h.useState(!1),i=Jt[t.status.toLowerCase()]??{...Gt,label:t.status},a=new Date(t.timestamp).toLocaleTimeString(void 0,{hour12:!1,fractionalSecondDigits:3}),c=Object.entries(t.attributes),m=[{label:"Span",value:t.span_id},...t.trace_id?[{label:"Trace",value:t.trace_id}]:[],{label:"Run",value:t.run_id},...t.parent_span_id?[{label:"Parent",value:t.parent_span_id}]:[]];return e.jsxs("div",{className:"overflow-y-auto h-full text-xs leading-normal",children:[e.jsxs("div",{className:"px-2 py-1.5 border-b flex items-center gap-2 flex-wrap",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-xs font-semibold mr-auto",style:{color:"var(--text-primary)"},children:t.span_name}),e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${i.color} 15%, var(--bg-secondary))`,color:i.color},children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:i.color}}),i.label]}),t.duration_ms!=null&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] font-semibold",style:{color:"var(--warning)"},children:Yt(t.duration_ms)}),e.jsx("span",{className:"shrink-0 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:a})]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--accent)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>r(d=>!d),children:[e.jsxs("span",{className:"flex-1",children:["Attributes (",c.length,")"]}),e.jsx("span",{style:{color:"var(--text-muted)",transform:s?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),s&&c.map(([d,l],x)=>e.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:x%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:d,children:d}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx(Kt,{value:l})})]},d))]}),e.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--accent)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>n(d=>!d),children:[e.jsxs("span",{className:"flex-1",children:["Identifiers (",m.length,")"]}),e.jsx("span",{style:{color:"var(--text-muted)",transform:o?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),o&&m.map((d,l)=>e.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:l%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:d.label,children:d.label}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:d.value})})]},d.label))]})}const Qt={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function es({kind:t,statusColor:s}){const r=s,o=14,n={width:o,height:o,viewBox:"0 0 16 16",fill:"none",stroke:r,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(t){case"LLM":return e.jsx("svg",{...n,children:e.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:r,stroke:"none"})});case"TOOL":return e.jsx("svg",{...n,children:e.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),e.jsx("circle",{cx:"6",cy:"9",r:"1",fill:r,stroke:"none"}),e.jsx("circle",{cx:"10",cy:"9",r:"1",fill:r,stroke:"none"}),e.jsx("path",{d:"M8 2v3"}),e.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return e.jsxs("svg",{...n,children:[e.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),e.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),e.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return e.jsxs("svg",{...n,children:[e.jsx("circle",{cx:"7",cy:"7",r:"4"}),e.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return e.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:s}})}}function ts(t){const s=new Map(t.map(a=>[a.span_id,a])),r=new Map;for(const a of t)if(a.parent_span_id){const c=r.get(a.parent_span_id)??[];c.push(a),r.set(a.parent_span_id,c)}const o=t.filter(a=>a.parent_span_id===null||!s.has(a.parent_span_id));function n(a){const c=(r.get(a.span_id)??[]).sort((m,d)=>m.timestamp.localeCompare(d.timestamp));return{span:a,children:c.map(n)}}return o.sort((a,c)=>a.timestamp.localeCompare(c.timestamp)).map(n).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function ss(t){return t==null?"":t<1e3?`${t.toFixed(0)}ms`:`${(t/1e3).toFixed(2)}s`}function Be(t){return t.map(s=>{const{span:r}=s;return s.children.length>0?{name:r.span_name,children:Be(s.children)}:{name:r.span_name}})}function Se({traces:t}){const[s,r]=h.useState(null),[o,n]=h.useState(new Set),[i,a]=h.useState(()=>{const N=localStorage.getItem("traceTreeSplitWidth");return N?parseFloat(N):50}),[c,m]=h.useState(!1),[d,l]=h.useState(!1),x=ts(t),j=h.useMemo(()=>JSON.stringify(Be(x),null,2),[t]),y=h.useCallback(()=>{navigator.clipboard.writeText(j).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},[j]),E=W(N=>N.focusedSpan),k=W(N=>N.setFocusedSpan),[w,$]=h.useState(null),B=h.useRef(null),J=h.useCallback(N=>{n(L=>{const I=new Set(L);return I.has(N)?I.delete(N):I.add(N),I})},[]);h.useEffect(()=>{if(s===null)x.length>0&&r(x[0].span);else{const N=t.find(L=>L.span_id===s.span_id);N&&N!==s&&r(N)}},[t]),h.useEffect(()=>{if(!E)return;const L=t.filter(I=>I.span_name===E.name).sort((I,D)=>I.timestamp.localeCompare(D.timestamp))[E.index];if(L){r(L),$(L.span_id);const I=new Map(t.map(D=>[D.span_id,D.parent_span_id]));n(D=>{const G=new Set(D);let z=L.parent_span_id;for(;z;)G.delete(z),z=I.get(z)??null;return G})}k(null)},[E,t,k]),h.useEffect(()=>{if(!w)return;const N=w;$(null),requestAnimationFrame(()=>{const L=B.current,I=L==null?void 0:L.querySelector(`[data-span-id="${N}"]`);L&&I&&I.scrollIntoView({block:"center",behavior:"smooth"})})},[w]),h.useEffect(()=>{if(!c)return;const N=I=>{const D=document.querySelector(".trace-tree-container");if(!D)return;const G=D.getBoundingClientRect(),z=(I.clientX-G.left)/G.width*100,q=Math.max(20,Math.min(80,z));a(q),localStorage.setItem("traceTreeSplitWidth",String(q))},L=()=>{m(!1)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",L)}},[c]);const F=N=>{N.preventDefault(),m(!0)};return e.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:c?"col-resize":void 0},children:[e.jsxs("div",{className:"pr-0.5 pt-0.5 relative",style:{width:`${i}%`},children:[t.length>0&&e.jsx("button",{onClick:y,className:"absolute top-2 left-2 z-20 text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-opacity",style:{opacity:d?1:.3,color:d?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:N=>{N.currentTarget.style.opacity="1"},onMouseLeave:N=>{d||(N.currentTarget.style.opacity="0.3")},children:d?"Copied!":"Copy JSON"}),e.jsx("div",{ref:B,className:"overflow-y-auto h-full p-0.5",children:x.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):x.map((N,L)=>e.jsx(De,{node:N,depth:0,selectedId:(s==null?void 0:s.span_id)??null,onSelect:r,isLast:L===x.length-1,collapsedIds:o,toggleExpanded:J},N.span.span_id))})]}),e.jsx("div",{onMouseDown:F,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",style:c?{background:"var(--accent)"}:void 0,children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),e.jsx("div",{className:"flex-1 overflow-hidden p-0.5",children:s?e.jsx(Zt,{span:s}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function De({node:t,depth:s,selectedId:r,onSelect:o,isLast:n,collapsedIds:i,toggleExpanded:a}){var k;const{span:c}=t,m=!i.has(c.span_id),d=Qt[c.status.toLowerCase()]??"var(--text-muted)",l=ss(c.duration_ms),x=c.span_id===r,j=t.children.length>0,y=s*20,E=(k=c.attributes)==null?void 0:k["openinference.span.kind"];return e.jsxs("div",{className:"relative",children:[s>0&&e.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${y-10}px`,width:"1px",height:n?"16px":"100%",background:"var(--border)"}}),e.jsxs("button",{"data-span-id":c.span_id,onClick:()=>o(c),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${y+4}px`,background:x?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:x?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{x||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{x||(w.currentTarget.style.background="")},children:[s>0&&e.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${y-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),j?e.jsx("span",{onClick:w=>{w.stopPropagation(),a(c.span_id)},className:"shrink-0 w-4 h-4 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:m?"rotate(90deg)":"rotate(0deg)"},children:e.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("span",{className:"shrink-0 w-4"}),e.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:e.jsx(es,{kind:E,statusColor:d})}),e.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:c.span_name}),l&&e.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:l})]}),m&&t.children.map((w,$)=>e.jsx(De,{node:w,depth:s+1,selectedId:r,onSelect:o,isLast:$===t.children.length-1,collapsedIds:i,toggleExpanded:a},w.span.span_id))]})}const rs={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},os={color:"var(--text-muted)",bg:"transparent"};function Ee({logs:t}){const s=h.useRef(null),r=h.useRef(null),[o,n]=h.useState(!1);h.useEffect(()=>{var a;(a=r.current)==null||a.scrollIntoView({behavior:"smooth"})},[t.length]);const i=()=>{const a=s.current;a&&n(a.scrollTop>100)};return t.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):e.jsxs("div",{className:"h-full relative",children:[e.jsxs("div",{ref:s,onScroll:i,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[t.map((a,c)=>{const m=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),d=a.level.toUpperCase(),l=d.slice(0,4),x=rs[d]??os,j=c%2===0;return e.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:j?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:m}),e.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:x.color,background:x.bg},children:l}),e.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},c)}),e.jsx("div",{ref:r})]}),o&&e.jsx("button",{onClick:()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const ns={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},Ce={color:"var(--text-muted)",label:""};function _e({events:t,runStatus:s}){const r=h.useRef(null),o=h.useRef(!0),[n,i]=h.useState(null),a=()=>{const c=r.current;c&&(o.current=c.scrollHeight-c.scrollTop-c.clientHeight<40)};return h.useEffect(()=>{o.current&&r.current&&(r.current.scrollTop=r.current.scrollHeight)}),t.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:s==="running"?"Waiting for events...":"No events yet"})}):e.jsx("div",{ref:r,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:t.map((c,m)=>{const d=new Date(c.timestamp).toLocaleTimeString(void 0,{hour12:!1}),l=c.payload&&Object.keys(c.payload).length>0,x=n===m,j=c.phase?ns[c.phase]??Ce:Ce;return e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{l&&i(x?null:m)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:m%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:l?"pointer":"default"},children:[e.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:d}),e.jsx("span",{className:"shrink-0",style:{color:j.color},children:"●"}),e.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:c.node_name}),j.label&&e.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:j.label}),l&&e.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:x?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),x&&l&&e.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:e.jsx(te,{json:JSON.stringify(c.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},m)})})}function Le({runId:t,status:s,ws:r,breakpointNode:o}){const n=s==="suspended",i=a=>{const c=W.getState().breakpoints[t]??{};r.setBreakpoints(t,Object.keys(c)),a==="step"?r.debugStep(t):a==="continue"?r.debugContinue(t):r.debugStop(t)};return e.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),e.jsx(ce,{label:"Step",onClick:()=>i("step"),disabled:!n,color:"var(--info)",active:n}),e.jsx(ce,{label:"Continue",onClick:()=>i("continue"),disabled:!n,color:"var(--success)",active:n}),e.jsx(ce,{label:"Stop",onClick:()=>i("stop"),disabled:!n,color:"var(--error)",active:n}),e.jsx("span",{className:"text-[10px] ml-auto truncate",style:{color:n?"var(--accent)":"var(--text-muted)"},children:n?o?`Paused at ${o}`:"Paused":s})]})}function ce({label:t,onClick:s,disabled:r,color:o,active:n}){return e.jsx("button",{onClick:s,disabled:r,className:"px-2.5 py-0.5 h-5 text-[10px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:n?o:"var(--text-muted)",background:n?`color-mix(in srgb, ${o} 10%, transparent)`:"transparent"},onMouseEnter:i=>{r||(i.currentTarget.style.background=`color-mix(in srgb, ${o} 20%, transparent)`)},onMouseLeave:i=>{i.currentTarget.style.background=n?`color-mix(in srgb, ${o} 10%, transparent)`:"transparent"},children:t})}const Te=h.lazy(()=>He(()=>import("./ChatPanel-CllakF8w.js"),__vite__mapDeps([2,1,3,4]))),as=[],is=[],cs=[],ls=[];function ds({run:t,ws:s,isMobile:r}){const o=t.mode==="chat",[n,i]=h.useState(280),[a,c]=h.useState(()=>{const u=localStorage.getItem("chatPanelWidth");return u?parseInt(u,10):380}),[m,d]=h.useState("primary"),[l,x]=h.useState(o?"primary":"traces"),[j,y]=h.useState(0),E=h.useRef(null),k=h.useRef(null),w=h.useRef(!1),$=W(u=>u.traces[t.id]||as),B=W(u=>u.logs[t.id]||is),J=W(u=>u.chatMessages[t.id]||cs),F=W(u=>u.stateEvents[t.id]||ls),N=W(u=>u.breakpoints[t.id]);h.useEffect(()=>{s.setBreakpoints(t.id,N?Object.keys(N):[])},[t.id]);const L=h.useCallback(u=>{s.setBreakpoints(t.id,u)},[t.id,s]),I=h.useCallback(u=>{u.preventDefault(),w.current=!0;const p="touches"in u?u.touches[0].clientY:u.clientY,b=n,T=S=>{if(!w.current)return;const H=E.current;if(!H)return;const f="touches"in S?S.touches[0].clientY:S.clientY,_=H.clientHeight-100,C=Math.max(80,Math.min(_,b+(f-p)));i(C)},g=()=>{w.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",T),document.removeEventListener("touchend",g),document.body.style.cursor="",document.body.style.userSelect="",y(S=>S+1)};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",T),document.addEventListener("mouseup",g),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("touchend",g)},[n]),D=h.useCallback(u=>{u.preventDefault();const p="touches"in u?u.touches[0].clientX:u.clientX,b=a,T=S=>{const H=k.current;if(!H)return;const f="touches"in S?S.touches[0].clientX:S.clientX,_=H.clientWidth-300,C=Math.max(280,Math.min(_,b+(p-f)));c(C)},g=()=>{document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",T),document.removeEventListener("touchend",g),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a)),y(S=>S+1)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",T),document.addEventListener("mouseup",g),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("touchend",g)},[a]),G=o?"Chat":"Events",z=o?"var(--accent)":"var(--success)",q=W(u=>u.activeInterrupt[t.id]??null),R=t.status==="running"?e.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:o?"Thinking...":"Running..."}):o&&t.status==="suspended"&&q?e.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(r){const u=[{id:"traces",label:"Traces",count:$.length},{id:"primary",label:G},{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:B.length}];return e.jsxs("div",{className:"flex flex-col h-full",children:[(t.mode==="debug"||t.status==="suspended"&&!q||N&&Object.keys(N).length>0)&&e.jsx(Le,{runId:t.id,status:t.status,ws:s,breakpointNode:t.breakpoint_node}),e.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:e.jsx(ne,{entrypoint:t.entrypoint,traces:$,runId:t.id,breakpointNode:t.breakpoint_node,breakpointNextNodes:t.breakpoint_next_nodes,onBreakpointChange:L,fitViewTrigger:j})}),e.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[u.map(p=>e.jsxs("button",{onClick:()=>x(p.id),className:"px-2 py-0.5 h-5 text-[11px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer",style:{color:l===p.id?p.id==="primary"?z:"var(--accent)":"var(--text-muted)",background:l===p.id?`color-mix(in srgb, ${p.id==="primary"?z:"var(--accent)"} 10%, transparent)`:"transparent"},children:[p.label,p.count!==void 0&&p.count>0&&e.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:p.count})]},p.id)),R]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[l==="traces"&&e.jsx(Se,{traces:$}),l==="primary"&&(o?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:e.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:e.jsx(Te,{messages:J,runId:t.id,runStatus:t.status,ws:s})}):e.jsx(_e,{events:F,runStatus:t.status})),l==="io"&&e.jsx(Me,{run:t}),l==="logs"&&e.jsx(Ee,{logs:B})]})]})}const P=[{id:"primary",label:G},{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:B.length}];return e.jsxs("div",{ref:k,className:"flex h-full",children:[e.jsxs("div",{ref:E,className:"flex flex-col flex-1 min-w-0",children:[(t.mode==="debug"||t.status==="suspended"&&!q||N&&Object.keys(N).length>0)&&e.jsx(Le,{runId:t.id,status:t.status,ws:s,breakpointNode:t.breakpoint_node}),e.jsx("div",{className:"shrink-0",style:{height:n},children:e.jsx(ne,{entrypoint:t.entrypoint,traces:$,runId:t.id,breakpointNode:t.breakpoint_node,breakpointNextNodes:t.breakpoint_next_nodes,onBreakpointChange:L,fitViewTrigger:j})}),e.jsx("div",{onMouseDown:I,onTouchStart:I,className:"shrink-0 h-1.5 cursor-row-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -top-1 -bottom-1"})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Se,{traces:$})})]}),e.jsx("div",{onMouseDown:D,onTouchStart:D,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),e.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[P.map(u=>e.jsxs("button",{onClick:()=>d(u.id),className:"px-2 py-0.5 h-5 text-[11px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer",style:{color:m===u.id?u.id==="primary"?z:"var(--accent)":"var(--text-muted)",background:m===u.id?`color-mix(in srgb, ${u.id==="primary"?z:"var(--accent)"} 10%, transparent)`:"transparent"},onMouseEnter:p=>{m!==u.id&&(p.currentTarget.style.color="var(--text-primary)")},onMouseLeave:p=>{m!==u.id&&(p.currentTarget.style.color="var(--text-muted)")},children:[u.label,u.count!==void 0&&u.count>0&&e.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:u.count})]},u.id)),R]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[m==="primary"&&(o?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:e.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:e.jsx(Te,{messages:J,runId:t.id,runStatus:t.status,ws:s})}):e.jsx(_e,{events:F,runStatus:t.status})),m==="io"&&e.jsx(Me,{run:t}),m==="logs"&&e.jsx(Ee,{logs:B})]})]})]})}function Me({run:t}){return e.jsxs("div",{className:"p-4 overflow-y-auto h-full space-y-4",children:[e.jsx(Re,{title:"Input",color:"var(--success)",copyText:JSON.stringify(t.input_data,null,2),children:e.jsx(te,{json:JSON.stringify(t.input_data,null,2),className:"p-3 rounded-lg text-xs font-mono whitespace-pre-wrap break-words",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})}),t.output_data&&e.jsx(Re,{title:"Output",color:"var(--accent)",copyText:typeof t.output_data=="string"?t.output_data:JSON.stringify(t.output_data,null,2),children:e.jsx(te,{json:typeof t.output_data=="string"?t.output_data:JSON.stringify(t.output_data,null,2),className:"p-3 rounded-lg text-xs font-mono whitespace-pre-wrap break-words",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})}),t.error&&e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[e.jsxs("div",{className:"px-4 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[e.jsx("span",{children:"Error"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:t.error.code}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:t.error.category})]}),e.jsxs("div",{className:"p-4 text-xs leading-normal",style:{background:"var(--bg-secondary)"},children:[e.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:t.error.title}),e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:t.error.detail})]})]})]})}function Re({title:t,color:s,copyText:r,children:o}){const[n,i]=h.useState(!1),a=h.useCallback(()=>{r&&navigator.clipboard.writeText(r).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[r]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-1 h-4 rounded-full",style:{background:s}}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:s},children:t}),r&&e.jsx("button",{onClick:a,className:"ml-auto text-[10px] cursor-pointer px-1.5 py-0.5 rounded",style:{color:n?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n?"Copied":"Copy"})]}),o]})}function us(){const{reloadPending:t,setReloadPending:s,setEntrypoints:r}=W(),[o,n]=h.useState(!1);if(!t)return null;const i=async()=>{n(!0);try{await dt();const a=await Ie();r(a.map(c=>c.name)),s(!1)}catch(a){console.error("Reload failed:",a)}finally{n(!1)}};return e.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center justify-between px-5 py-2.5 rounded-lg shadow-lg min-w-[400px]",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[e.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Files changed — reload to apply"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:i,disabled:o,className:"px-3 py-1 text-sm font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:o?.6:1},children:o?"Reloading...":"Reload"}),e.jsx("button",{onClick:()=>s(!1),className:"text-sm cursor-pointer px-1",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})]})}function ps(){const t=nt(),s=xt(),[r,o]=h.useState(!1),{runs:n,selectedRunId:i,setRuns:a,upsertRun:c,selectRun:m,setTraces:d,setLogs:l,setChatMessages:x,setEntrypoints:j,setStateEvents:y,setGraphCache:E,setActiveNode:k,removeActiveNode:w}=W(),{view:$,runId:B,setupEntrypoint:J,setupMode:F,navigate:N}=Pe();h.useEffect(()=>{$==="details"&&B&&B!==i&&m(B)},[$,B,i,m]),h.useEffect(()=>{lt().then(a).catch(console.error),Ie().then(R=>j(R.map(P=>P.name))).catch(console.error)},[a,j]);const L=i?n[i]:null,I=h.useCallback((R,P)=>{c(P),d(R,P.traces),l(R,P.logs);const u=P.messages.map(p=>{const b=p.contentParts??p.content_parts??[],T=p.toolCalls??p.tool_calls??[];return{message_id:p.messageId??p.message_id,role:p.role??"assistant",content:b.filter(g=>{const S=g.mimeType??g.mime_type??"";return S.startsWith("text/")||S==="application/json"}).map(g=>{const S=g.data;return(S==null?void 0:S.inline)??""}).join(` -`).trim()??"",tool_calls:T.length>0?T.map(g=>({name:g.name??"",has_result:!!g.result})):void 0}});if(x(R,u),P.graph&&P.graph.nodes.length>0&&E(R,P.graph),P.states&&P.states.length>0&&(y(R,P.states.map(p=>({node_name:p.node_name,qualified_node_name:p.qualified_node_name,phase:p.phase,timestamp:new Date(p.timestamp).getTime(),payload:p.payload}))),P.status!=="completed"&&P.status!=="failed"))for(const p of P.states)p.phase==="started"?k(R,p.node_name,p.qualified_node_name):p.phase==="completed"&&w(R,p.node_name)},[c,d,l,x,y,E,k,w]);h.useEffect(()=>{if(!i)return;t.subscribe(i),ae(i).then(P=>I(i,P)).catch(console.error);const R=setTimeout(()=>{const P=W.getState().runs[i];P&&(P.status==="pending"||P.status==="running")&&ae(i).then(u=>I(i,u)).catch(console.error)},2e3);return()=>{clearTimeout(R),t.unsubscribe(i)}},[i,t,I]);const D=h.useRef(null);h.useEffect(()=>{var u,p;if(!i)return;const R=L==null?void 0:L.status,P=D.current;if(D.current=R??null,R&&(R==="completed"||R==="failed")&&P!==R){const b=W.getState(),T=((u=b.traces[i])==null?void 0:u.length)??0,g=((p=b.logs[i])==null?void 0:p.length)??0,S=(L==null?void 0:L.trace_count)??0,H=(L==null?void 0:L.log_count)??0;(TI(i,f)).catch(console.error)}},[i,L==null?void 0:L.status,I]);const G=R=>{N(`#/runs/${R}/traces`),m(R),o(!1)},z=R=>{N(`#/runs/${R}/traces`),m(R),o(!1)},q=()=>{N("#/new"),o(!1)};return e.jsxs("div",{className:"flex h-screen w-screen relative",children:[s&&!r&&e.jsx("button",{onClick:()=>o(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),e.jsx(ft,{runs:Object.values(n),selectedRunId:i,onSelectRun:z,onNewRun:q,isMobile:s,isOpen:r,onClose:()=>o(!1)}),e.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:$==="new"?e.jsx(vt,{}):$==="setup"&&J&&F?e.jsx(Vt,{entrypoint:J,mode:F,ws:t,onRunCreated:G,isMobile:s}):L?e.jsx(ds,{run:L,ws:t,isMobile:s}):e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"})}),e.jsx(us,{})]})}Fe.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(ps,{})}));export{W as u}; + `}),e.jsxs(Ye,{nodes:a,edges:u,onNodesChange:x,onEdgesChange:h,nodeTypes:It,edgeTypes:Pt,onInit:y=>{J.current=y},onNodeClick:G,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:[e.jsx(Xe,{color:"var(--bg-tertiary)",gap:16}),e.jsx(Ke,{showInteractive:!1}),e.jsx(Ze,{position:"top-right",children:e.jsxs("button",{onClick:q,title:z?"Remove all breakpoints":"Set breakpoints on all nodes",style:{background:"var(--bg-secondary)",color:z?"var(--error)":"var(--text-muted)",border:`1px solid ${z?"var(--error)":"var(--node-border)"}`,borderRadius:6,padding:"4px 10px",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:z?"var(--error)":"var(--node-border)"}}),z?"Clear all":"Break all"]})}),e.jsx(Qe,{nodeColor:y=>{var g;if(y.type==="groupNode")return"var(--bg-tertiary)";const d=(g=y.data)==null?void 0:g.status;return d==="completed"?"var(--success)":d==="running"?"var(--warning)":d==="failed"?"var(--error)":"var(--node-border)"},nodeStrokeWidth:0,style:{background:"var(--bg-secondary)",width:120,height:80}})]})]})}const ee="__setup__";function Vt({entrypoint:t,mode:s,ws:r,onRunCreated:o,isMobile:n}){const[i,a]=p.useState("{}"),[c,x]=p.useState({}),[u,l]=p.useState(!1),[h,j]=p.useState(!0),[b,E]=p.useState(null),[k,w]=p.useState(""),[R,B]=p.useState(0),[J,V]=p.useState(!0),[N,L]=p.useState(()=>{const m=localStorage.getItem("setupTextareaHeight");return m?parseInt(m,10):140}),W=p.useRef(null),[D,G]=p.useState(()=>{const m=localStorage.getItem("setupPanelWidth");return m?parseInt(m,10):380}),z=s==="run";p.useEffect(()=>{j(!0),E(null),it(t).then(m=>{x(m.mock_input),a(JSON.stringify(m.mock_input,null,2))}).catch(m=>{console.error("Failed to load mock input:",m);const S=m.detail||{};E(S.message||`Failed to load schema for "${t}"`),a("{}")}).finally(()=>j(!1))},[t]),p.useEffect(()=>{H.getState().clearBreakpoints(ee)},[]);const q=async()=>{let m;try{m=JSON.parse(i)}catch{alert("Invalid JSON input");return}l(!0);try{const S=H.getState().breakpoints[ee]??{},$=Object.keys(S),f=await he(t,m,s,$);H.getState().clearBreakpoints(ee),H.getState().upsertRun(f),o(f.id)}catch(S){console.error("Failed to create run:",S)}finally{l(!1)}},M=async()=>{const m=k.trim();if(m){l(!0);try{const S=H.getState().breakpoints[ee]??{},$=Object.keys(S),f=await he(t,c,"chat",$);H.getState().clearBreakpoints(ee),H.getState().upsertRun(f),H.getState().addLocalChatMessage(f.id,{message_id:`local-${Date.now()}`,role:"user",content:m}),r.sendChatMessage(f.id,m),o(f.id)}catch(S){console.error("Failed to create chat run:",S)}finally{l(!1)}}};p.useEffect(()=>{try{JSON.parse(i),V(!0)}catch{V(!1)}},[i]);const I=p.useCallback(m=>{m.preventDefault();const S="touches"in m?m.touches[0].clientY:m.clientY,$=N,f=C=>{const O="touches"in C?C.touches[0].clientY:C.clientY,A=Math.max(60,$+(S-O));L(A)},_=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",_),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupTextareaHeight",String(N))};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",f),document.addEventListener("mouseup",_),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",_)},[N]),y=p.useCallback(m=>{m.preventDefault();const S="touches"in m?m.touches[0].clientX:m.clientX,$=D,f=C=>{const O=W.current;if(!O)return;const A="touches"in C?C.touches[0].clientX:C.clientX,v=O.clientWidth-300,T=Math.max(280,Math.min(v,$+(S-A)));G(T)},_=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",_),document.removeEventListener("touchmove",f),document.removeEventListener("touchend",_),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("setupPanelWidth",String(D)),B(C=>C+1)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",f),document.addEventListener("mouseup",_),document.addEventListener("touchmove",f,{passive:!1}),document.addEventListener("touchend",_)},[D]),d=z?"Autonomous":"Conversational",g=z?"var(--success)":"var(--accent)",P=e.jsxs("div",{className:"shrink-0 flex flex-col",style:n?{background:"var(--bg-primary)"}:{width:D,background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"px-4 text-xs font-semibold uppercase tracking-wider border-b flex items-center gap-2 h-[33px]",style:{color:"var(--text-muted)",borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{style:{color:g},children:"●"}),d]}),e.jsxs("div",{className:"flex-1 overflow-y-auto flex flex-col items-center justify-center gap-4 px-6",children:[e.jsx("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{color:"var(--text-muted)",opacity:.5},children:z?e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}):e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsxs("div",{className:"text-center space-y-1.5",children:[e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-secondary)"},children:z?"Ready to execute":"Ready to chat"}),e.jsxs("p",{className:"text-xs leading-relaxed",style:{color:"var(--text-muted)"},children:["Click nodes to set breakpoints",z?e.jsxs(e.Fragment,{children:[",",e.jsx("br",{}),"configure input below, then run"]}):e.jsxs(e.Fragment,{children:[",",e.jsx("br",{}),"then send your first message"]})]})]})]}),z?e.jsxs("div",{className:"flex flex-col",style:{background:"var(--bg-primary)"},children:[!n&&e.jsx("div",{onMouseDown:I,onTouchStart:I,className:"shrink-0 h-1.5 cursor-row-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors"}),e.jsxs("div",{className:"px-4 py-3",children:[b?e.jsx("div",{className:"text-xs mb-3 px-3 py-2 rounded",style:{color:"var(--error)",background:"color-mix(in srgb, var(--error) 10%, var(--bg-secondary))"},children:b}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block text-[10px] uppercase tracking-wider font-semibold mb-2",style:{color:"var(--text-muted)"},children:["Input",h&&e.jsx("span",{className:"ml-2 font-normal",children:"Loading..."})]}),e.jsx("textarea",{value:i,onChange:m=>a(m.target.value),spellCheck:!1,className:"w-full rounded-md px-3 py-2 text-xs font-mono leading-relaxed resize-none focus:outline-none mb-3",style:{height:n?120:N,background:"var(--bg-secondary)",border:`1px solid ${J?"var(--border)":"#b91c1c"}`,color:"var(--text-primary)"}})]}),e.jsx("button",{onClick:q,disabled:u||h||!!b,className:"w-full py-2 text-sm font-semibold rounded-md border cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",style:{background:"transparent",borderColor:g,color:g},onMouseEnter:m=>{u||(m.currentTarget.style.background=`color-mix(in srgb, ${g} 10%, transparent)`)},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:u?"Starting...":e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:e.jsx("polygon",{points:"5,3 19,12 5,21"})}),"Execute"]})})]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-t",style:{borderColor:"var(--border)"},children:[e.jsx("input",{value:k,onChange:m=>w(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),M())},disabled:u||h,placeholder:u?"Starting...":"Message...",className:"flex-1 bg-transparent text-sm py-1 focus:outline-none disabled:opacity-40 placeholder:text-[var(--text-muted)]",style:{color:"var(--text-primary)"}}),e.jsx("button",{onClick:M,disabled:u||h||!k.trim(),className:"text-[11px] uppercase tracking-wider font-semibold px-2 py-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:!u&&k.trim()?"var(--accent)":"var(--text-muted)",background:"transparent"},onMouseEnter:m=>{!u&&k.trim()&&(m.currentTarget.style.background="color-mix(in srgb, var(--accent) 10%, transparent)")},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},children:"Send"})]})]});return n?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:e.jsx(ae,{entrypoint:t,traces:[],runId:ee,fitViewTrigger:R})}),e.jsx("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:P})]}):e.jsxs("div",{ref:W,className:"flex h-full",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ae,{entrypoint:t,traces:[],runId:ee,fitViewTrigger:R})}),e.jsx("div",{onMouseDown:y,onTouchStart:y,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),P]})}const Ft={key:"var(--info)",string:"var(--success)",number:"var(--warning)",boolean:"var(--accent)",null:"var(--accent)",punctuation:"var(--text-muted)"};function Ut(t){const s=[],r=/("(?:[^"\\]|\\.)*")\s*:|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b|(true|false)\b|(null)\b|([{}[\]:,])/g;let o=0,n;for(;(n=r.exec(t))!==null;){if(n.index>o&&s.push({type:"punctuation",text:t.slice(o,n.index)}),n[1]!==void 0){s.push({type:"key",text:n[1]});const i=t.indexOf(":",n.index+n[1].length);i!==-1&&(i>n.index+n[1].length&&s.push({type:"punctuation",text:t.slice(n.index+n[1].length,i)}),s.push({type:"punctuation",text:":"}),r.lastIndex=i+1)}else n[2]!==void 0?s.push({type:"string",text:n[2]}):n[3]!==void 0?s.push({type:"number",text:n[3]}):n[4]!==void 0?s.push({type:"boolean",text:n[4]}):n[5]!==void 0?s.push({type:"null",text:n[5]}):n[6]!==void 0&&s.push({type:"punctuation",text:n[6]});o=r.lastIndex}return oUt(t),[t]);return e.jsx("pre",{className:s,style:r,children:o.map((n,i)=>e.jsx("span",{style:{color:Ft[n.type]},children:n.text},i))})}const Jt={started:{color:"var(--info)",label:"Started"},running:{color:"var(--warning)",label:"Running"},completed:{color:"var(--success)",label:"Completed"},failed:{color:"var(--error)",label:"Failed"},error:{color:"var(--error)",label:"Error"}},Gt={color:"var(--text-muted)",label:"Unknown"};function qt(t){if(typeof t!="string")return null;const s=t.trim();if(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]"))try{return JSON.stringify(JSON.parse(s),null,2)}catch{return null}return null}function Yt(t){if(t<1)return`${(t*1e3).toFixed(0)}us`;if(t<1e3)return`${t.toFixed(2)}ms`;if(t<6e4)return`${(t/1e3).toFixed(2)}s`;const s=Math.floor(t/6e4),r=(t%6e4/1e3).toFixed(1);return`${s}m ${r}s`}const Se=200;function Xt(t){if(typeof t=="string")return t;if(t==null)return String(t);try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Kt({value:t}){const[s,r]=p.useState(!1),o=Xt(t),n=p.useMemo(()=>qt(t),[t]),i=n!==null,a=n??o,c=a.length>Se||a.includes(` +`),x=p.useCallback(()=>r(u=>!u),[]);return c?e.jsxs("div",{children:[s?i?e.jsx(te,{json:a,className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{}}):e.jsx("pre",{className:"font-mono text-[11px] whitespace-pre-wrap break-all",style:{color:"var(--text-primary)"},children:a}):e.jsxs("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:[a.slice(0,Se),"..."]}),e.jsx("button",{onClick:x,className:"text-[10px] cursor-pointer ml-1",style:{color:"var(--info)"},children:s?"[less]":"[more]"})]}):i?e.jsx(te,{json:a,className:"font-mono text-[11px] break-all whitespace-pre-wrap",style:{}}):e.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:a})}function Zt({span:t}){const[s,r]=p.useState(!0),[o,n]=p.useState(!1),i=Jt[t.status.toLowerCase()]??{...Gt,label:t.status},a=new Date(t.timestamp).toLocaleTimeString(void 0,{hour12:!1,fractionalSecondDigits:3}),c=Object.entries(t.attributes),x=[{label:"Span",value:t.span_id},...t.trace_id?[{label:"Trace",value:t.trace_id}]:[],{label:"Run",value:t.run_id},...t.parent_span_id?[{label:"Parent",value:t.parent_span_id}]:[]];return e.jsxs("div",{className:"overflow-y-auto h-full text-xs leading-normal",children:[e.jsxs("div",{className:"px-2 py-1.5 border-b flex items-center gap-2 flex-wrap",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-xs font-semibold mr-auto",style:{color:"var(--text-primary)"},children:t.span_name}),e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:`color-mix(in srgb, ${i.color} 15%, var(--bg-secondary))`,color:i.color},children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:i.color}}),i.label]}),t.duration_ms!=null&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] font-semibold",style:{color:"var(--warning)"},children:Yt(t.duration_ms)}),e.jsx("span",{className:"shrink-0 font-mono text-[11px]",style:{color:"var(--text-muted)"},children:a})]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--accent)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>r(u=>!u),children:[e.jsxs("span",{className:"flex-1",children:["Attributes (",c.length,")"]}),e.jsx("span",{style:{color:"var(--text-muted)",transform:s?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),s&&c.map(([u,l],h)=>e.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:h%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:u,children:u}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx(Kt,{value:l})})]},u))]}),e.jsxs("div",{className:"px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center",style:{color:"var(--accent)",borderColor:"var(--border)",background:"var(--bg-secondary)"},onClick:()=>n(u=>!u),children:[e.jsxs("span",{className:"flex-1",children:["Identifiers (",x.length,")"]}),e.jsx("span",{style:{color:"var(--text-muted)",transform:o?"rotate(0deg)":"rotate(-90deg)"},children:"▾"})]}),o&&x.map((u,l)=>e.jsxs("div",{className:"flex gap-2 px-2 py-1 items-start border-b",style:{borderColor:"var(--border)",background:l%2===0?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"font-mono font-semibold shrink-0 pt-px truncate text-[11px]",style:{color:"var(--info)",width:"35%"},title:u.label,children:u.label}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"font-mono text-[11px] break-all",style:{color:"var(--text-primary)"},children:u.value})})]},u.label))]})}const Qt={started:"var(--info)",running:"var(--warning)",completed:"var(--success)",failed:"var(--error)",error:"var(--error)"};function es({kind:t,statusColor:s}){const r=s,o=14,n={width:o,height:o,viewBox:"0 0 16 16",fill:"none",stroke:r,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(t){case"LLM":return e.jsx("svg",{...n,children:e.jsx("path",{d:"M8 2L9 5L12 4L10 7L14 8L10 9L12 12L9 11L8 14L7 11L4 12L6 9L2 8L6 7L4 4L7 5Z",fill:r,stroke:"none"})});case"TOOL":return e.jsx("svg",{...n,children:e.jsx("path",{d:"M10.5 2.5a3.5 3.5 0 0 0-3.17 4.93L3.5 11.27a1 1 0 0 0 0 1.41l.82.82a1 1 0 0 0 1.41 0l3.84-3.83A3.5 3.5 0 1 0 10.5 2.5z"})});case"AGENT":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"3",y:"5",width:"10",height:"8",rx:"2"}),e.jsx("circle",{cx:"6",cy:"9",r:"1",fill:r,stroke:"none"}),e.jsx("circle",{cx:"10",cy:"9",r:"1",fill:r,stroke:"none"}),e.jsx("path",{d:"M8 2v3"}),e.jsx("path",{d:"M6 2h4"})]});case"CHAIN":return e.jsxs("svg",{...n,children:[e.jsx("path",{d:"M6.5 9.5L9.5 6.5"}),e.jsx("path",{d:"M4.5 8.5l-1 1a2 2 0 0 0 2.83 2.83l1-1"}),e.jsx("path",{d:"M11.5 7.5l1-1a2 2 0 0 0-2.83-2.83l-1 1"})]});case"RETRIEVER":return e.jsxs("svg",{...n,children:[e.jsx("circle",{cx:"7",cy:"7",r:"4"}),e.jsx("path",{d:"M10 10l3.5 3.5"})]});case"EMBEDDING":return e.jsxs("svg",{...n,children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"2",y:"10",width:"4",height:"4",rx:"0.5"}),e.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"0.5"})]});default:return e.jsx("span",{className:"shrink-0 w-2 h-2 rounded-full",style:{background:s}})}}function ts(t){const s=new Map(t.map(a=>[a.span_id,a])),r=new Map;for(const a of t)if(a.parent_span_id){const c=r.get(a.parent_span_id)??[];c.push(a),r.set(a.parent_span_id,c)}const o=t.filter(a=>a.parent_span_id===null||!s.has(a.parent_span_id));function n(a){const c=(r.get(a.span_id)??[]).sort((x,u)=>x.timestamp.localeCompare(u.timestamp));return{span:a,children:c.map(n)}}return o.sort((a,c)=>a.timestamp.localeCompare(c.timestamp)).map(n).flatMap(a=>a.span.span_name==="root"?a.children:[a])}function ss(t){return t==null?"":t<1e3?`${t.toFixed(0)}ms`:`${(t/1e3).toFixed(2)}s`}function Be(t){return t.map(s=>{const{span:r}=s;return s.children.length>0?{name:r.span_name,children:Be(s.children)}:{name:r.span_name}})}function Ee({traces:t}){const[s,r]=p.useState(null),[o,n]=p.useState(new Set),[i,a]=p.useState(()=>{const N=localStorage.getItem("traceTreeSplitWidth");return N?parseFloat(N):50}),[c,x]=p.useState(!1),[u,l]=p.useState(!1),h=ts(t),j=p.useMemo(()=>JSON.stringify(Be(h),null,2),[t]),b=p.useCallback(()=>{navigator.clipboard.writeText(j).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},[j]),E=H(N=>N.focusedSpan),k=H(N=>N.setFocusedSpan),[w,R]=p.useState(null),B=p.useRef(null),J=p.useCallback(N=>{n(L=>{const W=new Set(L);return W.has(N)?W.delete(N):W.add(N),W})},[]);p.useEffect(()=>{if(s===null)h.length>0&&r(h[0].span);else{const N=t.find(L=>L.span_id===s.span_id);N&&N!==s&&r(N)}},[t]),p.useEffect(()=>{if(!E)return;const L=t.filter(W=>W.span_name===E.name).sort((W,D)=>W.timestamp.localeCompare(D.timestamp))[E.index];if(L){r(L),R(L.span_id);const W=new Map(t.map(D=>[D.span_id,D.parent_span_id]));n(D=>{const G=new Set(D);let z=L.parent_span_id;for(;z;)G.delete(z),z=W.get(z)??null;return G})}k(null)},[E,t,k]),p.useEffect(()=>{if(!w)return;const N=w;R(null),requestAnimationFrame(()=>{const L=B.current,W=L==null?void 0:L.querySelector(`[data-span-id="${N}"]`);L&&W&&W.scrollIntoView({block:"center",behavior:"smooth"})})},[w]),p.useEffect(()=>{if(!c)return;const N=W=>{const D=document.querySelector(".trace-tree-container");if(!D)return;const G=D.getBoundingClientRect(),z=(W.clientX-G.left)/G.width*100,q=Math.max(20,Math.min(80,z));a(q),localStorage.setItem("traceTreeSplitWidth",String(q))},L=()=>{x(!1)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",L)}},[c]);const V=N=>{N.preventDefault(),x(!0)};return e.jsxs("div",{className:"flex h-full trace-tree-container",style:{cursor:c?"col-resize":void 0},children:[e.jsxs("div",{className:"pr-0.5 pt-0.5 relative",style:{width:`${i}%`},children:[t.length>0&&e.jsx("button",{onClick:b,className:"absolute top-2 left-2 z-20 text-[10px] cursor-pointer px-1.5 py-0.5 rounded transition-opacity",style:{opacity:u?1:.3,color:u?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},onMouseEnter:N=>{N.currentTarget.style.opacity="1"},onMouseLeave:N=>{u||(N.currentTarget.style.opacity="0.3")},children:u?"Copied!":"Copy JSON"}),e.jsx("div",{ref:B,className:"overflow-y-auto h-full p-0.5",children:h.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No traces yet"})}):h.map((N,L)=>e.jsx(De,{node:N,depth:0,selectedId:(s==null?void 0:s.span_id)??null,onSelect:r,isLast:L===h.length-1,collapsedIds:o,toggleExpanded:J},N.span.span_id))})]}),e.jsx("div",{onMouseDown:V,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",style:c?{background:"var(--accent)"}:void 0,children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),e.jsx("div",{className:"flex-1 overflow-hidden p-0.5",children:s?e.jsx(Zt,{span:s}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"Select a span to view details"})})})]})}function De({node:t,depth:s,selectedId:r,onSelect:o,isLast:n,collapsedIds:i,toggleExpanded:a}){var k;const{span:c}=t,x=!i.has(c.span_id),u=Qt[c.status.toLowerCase()]??"var(--text-muted)",l=ss(c.duration_ms),h=c.span_id===r,j=t.children.length>0,b=s*20,E=(k=c.attributes)==null?void 0:k["openinference.span.kind"];return e.jsxs("div",{className:"relative",children:[s>0&&e.jsx("div",{className:"absolute top-0 z-10 pointer-events-none",style:{left:`${b-10}px`,width:"1px",height:n?"16px":"100%",background:"var(--border)"}}),e.jsxs("button",{"data-span-id":c.span_id,onClick:()=>o(c),className:"w-full text-left text-xs leading-normal py-1.5 pr-2 flex items-center gap-1.5 transition-colors relative",style:{paddingLeft:`${b+4}px`,background:h?"color-mix(in srgb, var(--accent) 10%, var(--bg-primary))":void 0,borderLeft:h?"2px solid var(--accent)":"2px solid transparent"},onMouseEnter:w=>{h||(w.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:w=>{h||(w.currentTarget.style.background="")},children:[s>0&&e.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:`${b-10}px`,top:"50%",width:"10px",height:"1px",background:"var(--border)"}}),j?e.jsx("span",{onClick:w=>{w.stopPropagation(),a(c.span_id)},className:"shrink-0 w-4 h-4 flex items-center justify-center cursor-pointer rounded hover:bg-[var(--bg-hover)]",style:{color:"var(--text-muted)"},children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",style:{transform:x?"rotate(90deg)":"rotate(0deg)"},children:e.jsx("path",{d:"M3 1.5L7 5L3 8.5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("span",{className:"shrink-0 w-4"}),e.jsx("span",{className:"shrink-0 flex items-center justify-center w-4 h-4",children:e.jsx(es,{kind:E,statusColor:u})}),e.jsx("span",{className:"text-[var(--text-primary)] truncate min-w-0 flex-1",children:c.span_name}),l&&e.jsx("span",{className:"text-[var(--text-muted)] shrink-0 ml-auto pl-2 tabular-nums",children:l})]}),x&&t.children.map((w,R)=>e.jsx(De,{node:w,depth:s+1,selectedId:r,onSelect:o,isLast:R===t.children.length-1,collapsedIds:i,toggleExpanded:a},w.span.span_id))]})}const rs={DEBUG:{color:"var(--text-muted)",bg:"color-mix(in srgb, var(--text-muted) 15%, var(--bg-secondary))",border:"var(--text-muted)"},INFO:{color:"var(--info)",bg:"color-mix(in srgb, var(--info) 15%, var(--bg-secondary))",border:"var(--info)"},WARN:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},WARNING:{color:"var(--warning)",bg:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",border:"var(--warning)"},ERROR:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"},CRITICAL:{color:"var(--error)",bg:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",border:"var(--error)"}},os={color:"var(--text-muted)",bg:"transparent"};function Ce({logs:t}){const s=p.useRef(null),r=p.useRef(null),[o,n]=p.useState(!1);p.useEffect(()=>{var a;(a=r.current)==null||a.scrollIntoView({behavior:"smooth"})},[t.length]);const i=()=>{const a=s.current;a&&n(a.scrollTop>100)};return t.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("p",{className:"text-[var(--text-muted)] text-sm",children:"No logs yet"})}):e.jsxs("div",{className:"h-full relative",children:[e.jsxs("div",{ref:s,onScroll:i,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:[t.map((a,c)=>{const x=new Date(a.timestamp).toLocaleTimeString(void 0,{hour12:!1}),u=a.level.toUpperCase(),l=u.slice(0,4),h=rs[u]??os,j=c%2===0;return e.jsxs("div",{className:"flex gap-3 px-3 py-1.5",style:{background:j?"var(--bg-primary)":"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-[var(--text-muted)] shrink-0",children:x}),e.jsx("span",{className:"shrink-0 self-start px-1.5 py-0.5 rounded text-[10px] font-semibold leading-none inline-flex items-center",style:{color:h.color,background:h.bg},children:l}),e.jsx("span",{className:"text-[var(--text-primary)] whitespace-pre-wrap break-all",children:a.message})]},c)}),e.jsx("div",{ref:r})]}),o&&e.jsx("button",{onClick:()=>{var a;return(a=s.current)==null?void 0:a.scrollTo({top:0,behavior:"smooth"})},className:"absolute top-2 right-3 w-6 h-6 flex items-center justify-center rounded-full cursor-pointer transition-opacity opacity-70 hover:opacity-100",style:{background:"var(--bg-tertiary)",color:"var(--text-primary)"},title:"Scroll to top",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"18 15 12 9 6 15"})})})]})}const ns={started:{color:"var(--accent)",label:"started"},updated:{color:"var(--info)",label:"updated"},completed:{color:"var(--success)",label:"completed"},faulted:{color:"var(--error)",label:"faulted"}},_e={color:"var(--text-muted)",label:""};function ne({events:t,runStatus:s}){const r=p.useRef(null),o=p.useRef(!0),[n,i]=p.useState(null),a=()=>{const c=r.current;c&&(o.current=c.scrollHeight-c.scrollTop-c.clientHeight<40)};return p.useEffect(()=>{o.current&&r.current&&(r.current.scrollTop=r.current.scrollHeight)}),t.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsx("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:s==="running"?"Waiting for events...":"No events yet"})}):e.jsx("div",{ref:r,onScroll:a,className:"h-full overflow-y-auto font-mono text-xs leading-normal",children:t.map((c,x)=>{const u=new Date(c.timestamp).toLocaleTimeString(void 0,{hour12:!1}),l=c.payload&&Object.keys(c.payload).length>0,h=n===x,j=c.phase?ns[c.phase]??_e:_e;return e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{l&&i(h?null:x)},className:"flex items-center gap-2 px-3 py-1.5",style:{background:x%2===0?"var(--bg-primary)":"var(--bg-secondary)",cursor:l?"pointer":"default"},children:[e.jsx("span",{className:"shrink-0",style:{color:"var(--text-muted)"},children:u}),e.jsx("span",{className:"shrink-0",style:{color:j.color},children:"●"}),e.jsx("span",{className:"flex-1 truncate",style:{color:"var(--text-primary)"},children:c.node_name}),j.label&&e.jsx("span",{className:"shrink-0 text-[10px]",style:{color:"var(--text-muted)"},children:j.label}),l&&e.jsx("span",{className:"shrink-0 text-[9px] transition-transform",style:{color:"var(--text-muted)",transform:h?"rotate(90deg)":"rotate(0deg)"},children:"▸"})]}),h&&l&&e.jsx("div",{className:"px-3 py-2 border-t border-b",style:{borderColor:"var(--border)",background:"color-mix(in srgb, var(--bg-secondary) 80%, var(--bg-primary))"},children:e.jsx(te,{json:JSON.stringify(c.payload,null,2),className:"text-[11px] font-mono whitespace-pre-wrap break-words"})})]},x)})})}function Le({runId:t,status:s,ws:r,breakpointNode:o}){const n=s==="suspended",i=a=>{const c=H.getState().breakpoints[t]??{};r.setBreakpoints(t,Object.keys(c)),a==="step"?r.debugStep(t):a==="continue"?r.debugContinue(t):r.debugStop(t)};return e.jsxs("div",{className:"flex items-center gap-1 px-4 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold mr-1",style:{color:"var(--text-muted)"},children:"Debug"}),e.jsx(le,{label:"Step",onClick:()=>i("step"),disabled:!n,color:"var(--info)",active:n}),e.jsx(le,{label:"Continue",onClick:()=>i("continue"),disabled:!n,color:"var(--success)",active:n}),e.jsx(le,{label:"Stop",onClick:()=>i("stop"),disabled:!n,color:"var(--error)",active:n}),e.jsx("span",{className:"text-[10px] ml-auto truncate",style:{color:n?"var(--accent)":"var(--text-muted)"},children:n?o?`Paused at ${o}`:"Paused":s})]})}function le({label:t,onClick:s,disabled:r,color:o,active:n}){return e.jsx("button",{onClick:s,disabled:r,className:"px-2.5 py-0.5 h-5 text-[10px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",style:{color:n?o:"var(--text-muted)",background:n?`color-mix(in srgb, ${o} 10%, transparent)`:"transparent"},onMouseEnter:i=>{r||(i.currentTarget.style.background=`color-mix(in srgb, ${o} 20%, transparent)`)},onMouseLeave:i=>{i.currentTarget.style.background=n?`color-mix(in srgb, ${o} 10%, transparent)`:"transparent"},children:t})}const Te=p.lazy(()=>He(()=>import("./ChatPanel-DvMLkYmo.js"),__vite__mapDeps([2,1,3,4]))),as=[],is=[],cs=[],ls=[];function ds({run:t,ws:s,isMobile:r}){const o=t.mode==="chat",[n,i]=p.useState(280),[a,c]=p.useState(()=>{const d=localStorage.getItem("chatPanelWidth");return d?parseInt(d,10):380}),[x,u]=p.useState("primary"),[l,h]=p.useState(o?"primary":"traces"),[j,b]=p.useState(0),E=p.useRef(null),k=p.useRef(null),w=p.useRef(!1),R=H(d=>d.traces[t.id]||as),B=H(d=>d.logs[t.id]||is),J=H(d=>d.chatMessages[t.id]||cs),V=H(d=>d.stateEvents[t.id]||ls),N=H(d=>d.breakpoints[t.id]);p.useEffect(()=>{s.setBreakpoints(t.id,N?Object.keys(N):[])},[t.id]);const L=p.useCallback(d=>{s.setBreakpoints(t.id,d)},[t.id,s]),W=p.useCallback(d=>{d.preventDefault(),w.current=!0;const g="touches"in d?d.touches[0].clientY:d.clientY,P=n,m=$=>{if(!w.current)return;const f=E.current;if(!f)return;const _="touches"in $?$.touches[0].clientY:$.clientY,C=f.clientHeight-100,O=Math.max(80,Math.min(C,P+(_-g)));i(O)},S=()=>{w.current=!1,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",S),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",S),document.body.style.cursor="",document.body.style.userSelect="",b($=>$+1)};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",m),document.addEventListener("mouseup",S),document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",S)},[n]),D=p.useCallback(d=>{d.preventDefault();const g="touches"in d?d.touches[0].clientX:d.clientX,P=a,m=$=>{const f=k.current;if(!f)return;const _="touches"in $?$.touches[0].clientX:$.clientX,C=f.clientWidth-300,O=Math.max(280,Math.min(C,P+(g-_)));c(O)},S=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",S),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",S),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem("chatPanelWidth",String(a)),b($=>$+1)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",m),document.addEventListener("mouseup",S),document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",S)},[a]),G=o?"Chat":"Events",z=o?"var(--accent)":"var(--success)",q=d=>d==="primary"?z:d==="events"?"var(--success)":"var(--accent)",M=H(d=>d.activeInterrupt[t.id]??null),I=t.status==="running"?e.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:o?"Thinking...":"Running..."}):o&&t.status==="suspended"&&M?e.jsx("span",{className:"ml-auto text-[10px] px-2 py-0.5 rounded-full shrink-0",style:{background:"color-mix(in srgb, var(--warning) 15%, var(--bg-secondary))",color:"var(--warning)"},children:"Action Required"}):null;if(r){const d=[{id:"traces",label:"Traces",count:R.length},{id:"primary",label:G},...o?[{id:"events",label:"Events",count:V.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:B.length}];return e.jsxs("div",{className:"flex flex-col h-full",children:[(t.mode==="debug"||t.status==="suspended"&&!M||N&&Object.keys(N).length>0)&&e.jsx(Le,{runId:t.id,status:t.status,ws:s,breakpointNode:t.breakpoint_node}),e.jsx("div",{className:"shrink-0",style:{height:"40vh"},children:e.jsx(ae,{entrypoint:t.entrypoint,traces:R,runId:t.id,breakpointNode:t.breakpoint_node,breakpointNextNodes:t.breakpoint_next_nodes,onBreakpointChange:L,fitViewTrigger:j})}),e.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-y shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[d.map(g=>e.jsxs("button",{onClick:()=>h(g.id),className:"px-2 py-0.5 h-5 text-[11px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer",style:{color:l===g.id?q(g.id):"var(--text-muted)",background:l===g.id?`color-mix(in srgb, ${q(g.id)} 10%, transparent)`:"transparent"},children:[g.label,g.count!==void 0&&g.count>0&&e.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:g.count})]},g.id)),I]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[l==="traces"&&e.jsx(Ee,{traces:R}),l==="primary"&&(o?e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:e.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:e.jsx(Te,{messages:J,runId:t.id,runStatus:t.status,ws:s})}):e.jsx(ne,{events:V,runStatus:t.status})),l==="events"&&e.jsx(ne,{events:V,runStatus:t.status}),l==="io"&&e.jsx(Me,{run:t}),l==="logs"&&e.jsx(Ce,{logs:B})]})]})}const y=[{id:"primary",label:G},...o?[{id:"events",label:"Events",count:V.length}]:[],{id:"io",label:"I/O"},{id:"logs",label:"Logs",count:B.length}];return e.jsxs("div",{ref:k,className:"flex h-full",children:[e.jsxs("div",{ref:E,className:"flex flex-col flex-1 min-w-0",children:[(t.mode==="debug"||t.status==="suspended"&&!M||N&&Object.keys(N).length>0)&&e.jsx(Le,{runId:t.id,status:t.status,ws:s,breakpointNode:t.breakpoint_node}),e.jsx("div",{className:"shrink-0",style:{height:n},children:e.jsx(ae,{entrypoint:t.entrypoint,traces:R,runId:t.id,breakpointNode:t.breakpoint_node,breakpointNextNodes:t.breakpoint_next_nodes,onBreakpointChange:L,fitViewTrigger:j})}),e.jsx("div",{onMouseDown:W,onTouchStart:W,className:"shrink-0 h-1.5 cursor-row-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -top-1 -bottom-1"})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ee,{traces:R})})]}),e.jsx("div",{onMouseDown:D,onTouchStart:D,className:"shrink-0 w-1.5 cursor-col-resize bg-[var(--border)] hover:bg-[var(--accent)] transition-colors relative",children:e.jsx("div",{className:"absolute inset-0 -left-1 -right-1"})}),e.jsxs("div",{className:"shrink-0 flex flex-col",style:{width:a,background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-10 border-b shrink-0",style:{borderColor:"var(--border)",background:"var(--bg-secondary)"},children:[y.map(d=>e.jsxs("button",{onClick:()=>u(d.id),className:"px-2 py-0.5 h-5 text-[11px] uppercase tracking-wider font-semibold rounded transition-colors cursor-pointer",style:{color:x===d.id?q(d.id):"var(--text-muted)",background:x===d.id?`color-mix(in srgb, ${q(d.id)} 10%, transparent)`:"transparent"},onMouseEnter:g=>{x!==d.id&&(g.currentTarget.style.color="var(--text-primary)")},onMouseLeave:g=>{x!==d.id&&(g.currentTarget.style.color="var(--text-muted)")},children:[d.label,d.count!==void 0&&d.count>0&&e.jsx("span",{className:"ml-1 font-normal",style:{color:"var(--text-muted)"},children:d.count})]},d.id)),I]}),e.jsxs("div",{className:"flex-1 overflow-hidden",children:[x==="primary"&&(o?e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-muted)"},children:e.jsx("span",{className:"text-xs",children:"Loading chat..."})}),children:e.jsx(Te,{messages:J,runId:t.id,runStatus:t.status,ws:s})}):e.jsx(ne,{events:V,runStatus:t.status})),x==="events"&&e.jsx(ne,{events:V,runStatus:t.status}),x==="io"&&e.jsx(Me,{run:t}),x==="logs"&&e.jsx(Ce,{logs:B})]})]})]})}function Me({run:t}){return e.jsxs("div",{className:"p-4 overflow-y-auto h-full space-y-4",children:[e.jsx(Re,{title:"Input",color:"var(--success)",copyText:JSON.stringify(t.input_data,null,2),children:e.jsx(te,{json:JSON.stringify(t.input_data,null,2),className:"p-3 rounded-lg text-xs font-mono whitespace-pre-wrap break-words",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})}),t.output_data&&e.jsx(Re,{title:"Output",color:"var(--accent)",copyText:typeof t.output_data=="string"?t.output_data:JSON.stringify(t.output_data,null,2),children:e.jsx(te,{json:typeof t.output_data=="string"?t.output_data:JSON.stringify(t.output_data,null,2),className:"p-3 rounded-lg text-xs font-mono whitespace-pre-wrap break-words",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"}})}),t.error&&e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid color-mix(in srgb, var(--error) 40%, var(--border))"},children:[e.jsxs("div",{className:"px-4 py-2 text-xs font-semibold flex items-center gap-2",style:{background:"color-mix(in srgb, var(--error) 15%, var(--bg-secondary))",color:"var(--error)"},children:[e.jsx("span",{children:"Error"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:t.error.code}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono",style:{background:"color-mix(in srgb, var(--error) 20%, var(--bg-secondary))"},children:t.error.category})]}),e.jsxs("div",{className:"p-4 text-xs leading-normal",style:{background:"var(--bg-secondary)"},children:[e.jsx("div",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:t.error.title}),e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] max-w-prose",style:{color:"var(--text-secondary)"},children:t.error.detail})]})]})]})}function Re({title:t,color:s,copyText:r,children:o}){const[n,i]=p.useState(!1),a=p.useCallback(()=>{r&&navigator.clipboard.writeText(r).then(()=>{i(!0),setTimeout(()=>i(!1),1500)})},[r]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-1 h-4 rounded-full",style:{background:s}}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:s},children:t}),r&&e.jsx("button",{onClick:a,className:"ml-auto text-[10px] cursor-pointer px-1.5 py-0.5 rounded",style:{color:n?"var(--success)":"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:n?"Copied":"Copy"})]}),o]})}function us(){const{reloadPending:t,setReloadPending:s,setEntrypoints:r}=H(),[o,n]=p.useState(!1);if(!t)return null;const i=async()=>{n(!0);try{await dt();const a=await Ie();r(a.map(c=>c.name)),s(!1)}catch(a){console.error("Reload failed:",a)}finally{n(!1)}};return e.jsxs("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 flex items-center justify-between px-5 py-2.5 rounded-lg shadow-lg min-w-[400px]",style:{background:"var(--bg-secondary)",border:"1px solid var(--bg-tertiary)"},children:[e.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Files changed — reload to apply"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:i,disabled:o,className:"px-3 py-1 text-sm font-medium rounded cursor-pointer",style:{background:"var(--accent)",color:"#fff",opacity:o?.6:1},children:o?"Reloading...":"Reload"}),e.jsx("button",{onClick:()=>s(!1),className:"text-sm cursor-pointer px-1",style:{color:"var(--text-muted)",background:"none",border:"none"},children:"✕"})]})]})}function ps(){const t=nt(),s=xt(),[r,o]=p.useState(!1),{runs:n,selectedRunId:i,setRuns:a,upsertRun:c,selectRun:x,setTraces:u,setLogs:l,setChatMessages:h,setEntrypoints:j,setStateEvents:b,setGraphCache:E,setActiveNode:k,removeActiveNode:w}=H(),{view:R,runId:B,setupEntrypoint:J,setupMode:V,navigate:N}=Pe();p.useEffect(()=>{R==="details"&&B&&B!==i&&x(B)},[R,B,i,x]),p.useEffect(()=>{lt().then(a).catch(console.error),Ie().then(M=>j(M.map(I=>I.name))).catch(console.error)},[a,j]);const L=i?n[i]:null,W=p.useCallback((M,I)=>{c(I),u(M,I.traces),l(M,I.logs);const y=I.messages.map(d=>{const g=d.contentParts??d.content_parts??[],P=d.toolCalls??d.tool_calls??[];return{message_id:d.messageId??d.message_id,role:d.role??"assistant",content:g.filter(m=>{const S=m.mimeType??m.mime_type??"";return S.startsWith("text/")||S==="application/json"}).map(m=>{const S=m.data;return(S==null?void 0:S.inline)??""}).join(` +`).trim()??"",tool_calls:P.length>0?P.map(m=>({name:m.name??"",has_result:!!m.result})):void 0}});if(h(M,y),I.graph&&I.graph.nodes.length>0&&E(M,I.graph),I.states&&I.states.length>0&&(b(M,I.states.map(d=>({node_name:d.node_name,qualified_node_name:d.qualified_node_name,phase:d.phase,timestamp:new Date(d.timestamp).getTime(),payload:d.payload}))),I.status!=="completed"&&I.status!=="failed"))for(const d of I.states)d.phase==="started"?k(M,d.node_name,d.qualified_node_name):d.phase==="completed"&&w(M,d.node_name)},[c,u,l,h,b,E,k,w]);p.useEffect(()=>{if(!i)return;t.subscribe(i),ie(i).then(I=>W(i,I)).catch(console.error);const M=setTimeout(()=>{const I=H.getState().runs[i];I&&(I.status==="pending"||I.status==="running")&&ie(i).then(y=>W(i,y)).catch(console.error)},2e3);return()=>{clearTimeout(M),t.unsubscribe(i)}},[i,t,W]);const D=p.useRef(null);p.useEffect(()=>{var y,d;if(!i)return;const M=L==null?void 0:L.status,I=D.current;if(D.current=M??null,M&&(M==="completed"||M==="failed")&&I!==M){const g=H.getState(),P=((y=g.traces[i])==null?void 0:y.length)??0,m=((d=g.logs[i])==null?void 0:d.length)??0,S=(L==null?void 0:L.trace_count)??0,$=(L==null?void 0:L.log_count)??0;(PW(i,f)).catch(console.error)}},[i,L==null?void 0:L.status,W]);const G=M=>{N(`#/runs/${M}/traces`),x(M),o(!1)},z=M=>{N(`#/runs/${M}/traces`),x(M),o(!1)},q=()=>{N("#/new"),o(!1)};return e.jsxs("div",{className:"flex h-screen w-screen relative",children:[s&&!r&&e.jsx("button",{onClick:()=>o(!0),className:"fixed top-2 left-2 z-40 w-9 h-9 flex items-center justify-center rounded-lg cursor-pointer",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}),e.jsx(ft,{runs:Object.values(n),selectedRunId:i,onSelectRun:z,onNewRun:q,isMobile:s,isOpen:r,onClose:()=>o(!1)}),e.jsx("main",{className:"flex-1 overflow-hidden bg-[var(--bg-primary)]",children:R==="new"?e.jsx(vt,{}):R==="setup"&&J&&V?e.jsx(Vt,{entrypoint:J,mode:V,ws:t,onRunCreated:G,isMobile:s}):L?e.jsx(ds,{run:L,ws:t,isMobile:s}):e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-muted)]",children:"Select a run or create a new one"})}),e.jsx(us,{})]})}Fe.createRoot(document.getElementById("root")).render(e.jsx(p.StrictMode,{children:e.jsx(ps,{})}));export{H as u}; diff --git a/src/uipath/dev/server/static/index.html b/src/uipath/dev/server/static/index.html index 2b4d46b..7b8e4d7 100644 --- a/src/uipath/dev/server/static/index.html +++ b/src/uipath/dev/server/static/index.html @@ -5,7 +5,7 @@ UiPath Developer Console - + diff --git a/uv.lock b/uv.lock index f69d626..469b62f 100644 --- a/uv.lock +++ b/uv.lock @@ -1400,7 +1400,7 @@ wheels = [ [[package]] name = "uipath-dev" -version = "0.0.55" +version = "0.0.56" source = { editable = "." } dependencies = [ { name = "fastapi" },