@anvia/studio 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,7 @@ Error generating stack: `+e.message+`
74
74
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
75
75
  `,...a.current()});return/^[\t ]/.test(l)&&(l=W_(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}X_.peek=Z_;function X_(e){return e.value||``}function Z_(){return`<`}Q_.peek=$_;function Q_(e,t,n,r){let i=V_(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function $_(){return`!`}ev.peek=tv;function ev(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function tv(){return`!`}nv.peek=rv;function nv(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function rv(){return"`"}function iv(e,t){let n=jd(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}av.peek=ov;function av(e,t,n,r){let i=V_(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(iv(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function ov(e,t,n){return iv(e,n)?`<`:`[`}sv.peek=cv;function sv(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function cv(){return`[`}function lv(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function uv(e){let t=lv(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function dv(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function fv(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function pv(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?dv(n):lv(n),s=e.ordered?o===`.`?`)`:`.`:uv(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),fv(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function mv(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function hv(e,t,n,r){let i=mv(n),a=n.bulletCurrent||lv(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function gv(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var _v=wh([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function vv(e,t,n,r){return(e.children.some(function(e){return _v(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function yv(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bv.peek=xv;function bv(e,t,n,r){let i=yv(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=G_(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=W_(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=G_(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+W_(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function xv(e,t,n){return n.options.strong||`*`}function Sv(e,t,n,r){return n.safe(e.value,r)}function Cv(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function wv(e,t,n){let r=(fv(n)+(n.options.ruleSpaces?` `:``)).repeat(Cv(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Tv={blockquote:j_,break:F_,code:z_,definition:H_,emphasis:K_,hardBreak:F_,heading:Y_,html:X_,image:Q_,imageReference:ev,inlineCode:nv,link:av,linkReference:sv,list:pv,listItem:hv,paragraph:gv,root:vv,strong:bv,text:Sv,thematicBreak:wv};function Ev(){return{enter:{table:Dv,tableData:jv,tableHeader:jv,tableRow:kv},exit:{codeText:Mv,table:Ov,tableData:Av,tableHeader:Av,tableRow:Av}}}function Dv(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Ov(e){this.exit(e),this.data.inTable=void 0}function kv(e){this.enter({type:`tableRow`,children:[]},e)}function Av(e){this.exit(e)}function jv(e){this.enter({type:`tableCell`,children:[]},e)}function Mv(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Nv));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Nv(e,t){return t===`|`?t:e}function Pv(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
76
76
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
77
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return O_(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Tv.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Fv(){return{exit:{taskListCheckValueChecked:Lv,taskListCheckValueUnchecked:Lv,paragraph:Rv}}}function Iv(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:zv}}}function Lv(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Rv(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function zv(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Tv.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Bv(){return[Kg(),g_(),x_(),Ev(),Fv()]}function Vv(e){return{extensions:[qg(),__(e),S_(),Pv(e),Iv()]}}var Hv={tokenize:ny,partial:!0},Uv={tokenize:ry,partial:!0},Wv={tokenize:iy,partial:!0},Gv={tokenize:ay,partial:!0},Kv={tokenize:oy,partial:!0},qv={name:`wwwAutolink`,tokenize:ey,previous:sy},Jv={name:`protocolAutolink`,tokenize:ty,previous:cy},Yv={name:`emailAutolink`,tokenize:$v,previous:ly},Xv={};function Zv(){return{text:Xv}}for(var Qv=48;Qv<123;)Xv[Qv]=Yv,Qv++,Qv===58?Qv=65:Qv===91&&(Qv=97);Xv[43]=Yv,Xv[45]=Yv,Xv[46]=Yv,Xv[95]=Yv,Xv[72]=[Yv,Jv],Xv[104]=[Yv,Jv],Xv[87]=[Yv,qv],Xv[119]=[Yv,qv];function $v(e,t,n){let r=this,i,a;return o;function o(t){return!uy(t)||!ly.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return uy(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Kv,u,l)(t):t===45||t===95||Kd(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Gd(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function ey(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!sy.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Hv,e.attempt(Uv,e.attempt(Wv,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function ty(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&cy.call(r,r.previous)&&!dy(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Gd(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Jd(t)||Qd(t)||tf(t)||ef(t)?n(t):e.attempt(Uv,e.attempt(Wv,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function ny(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function ry(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Gv,c,s)(t):t===null||Qd(t)||tf(t)||t!==45&&ef(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function iy(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Gv,t,a)(o):o===null||Qd(o)||tf(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function ay(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Qd(o)||tf(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Qd(e)||tf(e)?t(e):r(e)}function a(e){return Gd(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Gd(t)?(e.consume(t),o):n(t)}}function oy(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Kd(e)?n(e):t(e)}}function sy(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Qd(e)}function cy(e){return!Gd(e)}function ly(e){return!(e===47||uy(e))}function uy(e){return e===43||e===45||e===46||e===95||Kd(e)}function dy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var fy={tokenize:by,partial:!0};function py(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:_y,continuation:{tokenize:vy},exit:yy}},text:{91:{name:`gfmFootnoteCall`,tokenize:gy},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:my,resolveTo:hy}}}}function my(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Wd(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function hy(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function gy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Qd(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Wd(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Qd(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function _y(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Qd(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Wd(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Qd(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),af(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function vy(e,t,n){return e.check(bf,t,e.attempt(fy,t,n))}function yy(e){e.exit(`gfmFootnoteDefinition`)}function by(e,t,n){let r=this;return af(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function xy(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ld(o,o.length,0,pf(s,e.slice(r+1,n),t)),Ld(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ld(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ff(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ff(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Sy=class{constructor(){this.map=[]}add(e,t,n){Cy(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Cy(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function wy(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Ty(){return{flow:{null:{name:`table`,tokenize:Ey,resolveAll:Dy}}}}function Ey(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):$d(t)?af(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Qd(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,$d(t)?af(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return $d(t)?af(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return $d(t)?af(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Q(n)?(e.exit(`tableRow`),t(n)):$d(n)?af(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Qd(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Dy(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Sy;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ky(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Oy(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Oy(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Oy(f,t,o,i,n,d)):(o[0]=o[1],d=Oy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ky(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=wy(t.events,n))}return e}function Oy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ay(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ay(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ay(t.events,n[2]),a=Ay(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ay(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ky(e,t,n,r,i){let a=[],o=Ay(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ay(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var jy={name:`tasklistCheck`,tokenize:Ny};function My(){return{text:{91:jy}}}function Ny(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Qd(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Q(r)?t(r):$d(r)?e.check({tokenize:Py},t,n)(r):n(r)}}function Py(e,t,n){return af(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Fy(e){return Bd([Zv(),py(),xy(e),Ty(),My()])}var Iy={};function Ly(e){let t=this,n=e||Iy,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Fy(n)),a.push(Bv()),o.push(Vv(n))}function Ry(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zy(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Math.max(0,Math.floor((Date.now()-t.getTime())/1e3));if(n<60)return`now`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);if(a<7)return`${a}d`;let o=Math.floor(a/7);return o<5?`${o}w`:`${Math.floor(a/30)}mo`}function By(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Vy(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Hy(e){return e===void 0?``:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Uy(e){return e===void 0?`-`:`${e.totalTokens} tok`}function Wy(e,t){return e.find(e=>e.id===t)?.name??t}function Gy(e,t){if(Ry(t.metadata)&&typeof t.metadata.agentName==`string`)return t.metadata.agentName;let n=Ky(t);return n===void 0?`-`:Wy(e,n)}function Ky(e){if(Ry(e.metadata)){if(typeof e.metadata.agentId==`string`)return e.metadata.agentId;if(Ry(e.metadata.metadata)&&typeof e.metadata.metadata.agentId==`string`)return e.metadata.metadata.agentId}}function qy(e){return e.length===0?`-`:e}function Jy(e){switch(e.status){case`pending`:return`Waiting for your decision`;case`approved`:return`Approved`;case`rejected`:return`Rejected`;case`timed_out`:return`Timed out`;default:return e.status}}function Yy(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xy(e){let t=e.trim();if(t.length===0)return{kind:`text`,value:e};try{return{kind:`json`,value:JSON.parse(t)}}catch{return{kind:`text`,value:e}}}function Zy(e){let t=e.replace(/s+/g,` `).trim();return t.length>72?`${t.slice(0,69)}...`:t}function Qy(e){return e instanceof Error?e.message:String(e)}function $y(e){return(0,U.jsx)(`div`,{className:`prose prose-sm max-w-none text-current [overflow-wrap:anywhere] prose-headings:text-current prose-headings:font-semibold prose-p:text-current prose-p:leading-7 prose-a:text-current prose-a:decoration-muted-foreground prose-a:underline-offset-2 prose-strong:text-current prose-code:rounded-lg prose-code:border prose-code:border-border/80 prose-code:bg-muted/80 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.92em] prose-code:font-semibold prose-code:text-current prose-code:before:content-none prose-code:after:content-none prose-pre:overflow-auto prose-pre:rounded-lg prose-pre:border prose-pre:border-border/80 prose-pre:bg-card/90 prose-pre:text-current prose-blockquote:border-border prose-blockquote:text-muted-foreground prose-li:marker:text-muted-foreground prose-hr:border-border prose-table:m-0 prose-thead:border-0 prose-tr:border-0 prose-th:p-0 prose-td:p-0 dark:prose-invert dark:prose-headings:text-current dark:prose-p:text-current dark:prose-strong:text-current dark:prose-code:text-current dark:prose-pre:bg-card dark:prose-pre:text-current`,children:(0,U.jsx)(Ng,{components:{table({children:e}){return(0,U.jsx)(`div`,{className:`my-4 w-full min-w-0 overflow-hidden rounded-lg border border-border/80 bg-card/90 shadow-sm`,children:(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`m-0 w-full min-w-full border-separate border-spacing-0 text-left text-sm`,children:e})})})},thead({children:e}){return(0,U.jsx)(`thead`,{className:`bg-muted/45`,children:e})},tbody({children:e}){return(0,U.jsx)(`tbody`,{children:e})},tr({children:e}){return(0,U.jsx)(`tr`,{className:`group/row align-top`,children:e})},th({children:e}){return(0,U.jsx)(`th`,{className:`border-b border-border px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.2em] text-muted-foreground first:pl-5 last:pr-5`,style:{paddingBottom:`0.625rem`,paddingTop:`0.625rem`},children:e})},td({children:e}){return(0,U.jsx)(`td`,{className:`border-b border-border/70 px-4 text-sm leading-6 text-foreground [overflow-wrap:anywhere] first:pl-5 last:pr-5 group-last/row:border-b-0`,style:{paddingBottom:`0.75rem`,paddingTop:`0.75rem`},children:e})}},remarkPlugins:[Ly],children:e.text})})}function eb(e){let t=tb(e.value);return(0,U.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border/80 bg-background/70`,children:[(0,U.jsx)(`div`,{className:`flex min-h-9 items-center gap-3 border-b border-border/80 bg-muted/20 px-3`,children:(0,U.jsx)(`div`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.title})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 min-w-max p-3 font-mono text-[13px] leading-6 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:t})})})})]})}function tb(e){let t=Xy(e),n=t.kind===`json`?t.value:e;try{return JSON.stringify(n,null,2)}catch{return JSON.stringify(String(n),null,2)}}function nb(e){let t=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\btrue\b|\bfalse\b|\bnull\b|[{}[\],:]/g,n=[],r=0,i=t.exec(e.text);for(;i!==null;){i.index>r&&n.push(e.text.slice(r,i.index));let a=i[0],o=e.text.slice(t.lastIndex).match(/\S/)?.[0],s=rb(a,o);n.push((0,U.jsx)(`span`,{className:ib(s),children:a},`${i.index}:${a}`)),r=t.lastIndex,i=t.exec(e.text)}return r<e.text.length&&n.push(e.text.slice(r)),(0,U.jsx)(U.Fragment,{children:n})}function rb(e,t){return e.startsWith(`"`)?t===`:`?`key`:`string`:e===`true`||e===`false`?`boolean`:e===`null`?`null`:/^-?\d/.test(e)?`number`:`punctuation`}function ib(e){switch(e){case`key`:return`text-primary`;case`string`:return`text-foreground dark:text-zinc-100`;case`number`:return`text-chart-2 dark:text-sky-300`;case`boolean`:return`text-chart-5 dark:text-fuchsia-300`;case`null`:return`text-muted-foreground`;case`punctuation`:return`text-muted-foreground`}}function ab(e){if(Array.isArray(e.value))return e.value.length===0?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`Empty array`}):(0,U.jsx)(`div`,{className:`grid gap-1.5`,children:Object.entries(e.value).map(([e,t])=>(0,U.jsx)(ob,{label:e,value:t},e))});if(Ry(e.value)){let t=Object.entries(e.value);return t.length===0?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`Empty object`}):(0,U.jsx)(`div`,{className:`grid gap-1.5`,children:t.map(([e,t])=>(0,U.jsx)(ob,{label:e,value:t},e))})}return(0,U.jsx)(sb,{value:e.value})}function ob(e){let t=Array.isArray(e.value)||Ry(e.value);return(0,U.jsxs)(`div`,{className:tr(`grid min-w-0 grid-cols-[minmax(92px,max-content)_minmax(0,1fr)] items-baseline gap-2.5`,t&&`items-start`),children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground [overflow-wrap:anywhere]`,children:e.label}),(0,U.jsx)(`div`,{className:`min-w-0 text-[13px] leading-5 text-foreground [overflow-wrap:anywhere] [&_.grid]:mt-2 [&_.grid]:border-l [&_.grid]:border-border [&_.grid]:pl-3`,children:t?(0,U.jsx)(ab,{value:e.value}):(0,U.jsx)(sb,{value:e.value})})]})}function sb(e){return e.value===null?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`null`}):typeof e.value==`string`||typeof e.value==`number`?(0,U.jsx)(`span`,{children:e.value}):(e.value,(0,U.jsx)(`span`,{children:String(e.value)}))}function cb(e){let t=e.evals.find(t=>t.id===e.selectedEvalId)??e.evals[0];return e.enabled?(0,U.jsx)(`section`,{className:`grid min-h-0 overflow-auto bg-background/45`,children:(0,U.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl content-start gap-5 p-6`,children:[(0,U.jsxs)(`header`,{className:`flex min-w-0 items-start justify-between gap-4 border-b border-border/80 pb-5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evals`}),(0,U.jsx)(`h1`,{className:`m-0 mt-2 text-2xl font-semibold tracking-tight text-foreground`,children:t?.name??`Eval suite`}),t?.description===void 0?null:(0,U.jsx)(`p`,{className:`m-0 mt-2 max-w-2xl text-sm leading-6 text-muted-foreground`,children:t.description})]}),(0,U.jsxs)(K,{className:`h-9 shrink-0 rounded-lg px-3 text-sm font-semibold`,disabled:t===void 0||e.runState===`running`,onClick:e.onRun,children:[(0,U.jsx)(Ge,{className:`mr-1.5 h-3.5 w-3.5`}),e.runState===`running`?`Running`:`Run`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,U.jsxs)(`label`,{className:`grid gap-2`,htmlFor:`eval-suite-select`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Suite`}),(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectEval,children:[(0,U.jsx)(zl,{id:`eval-suite-select`,className:`h-9 w-full rounded-lg border-primary/55 bg-background font-mono text-[11px]`,children:(0,U.jsx)(Y,{placeholder:`Select eval`})}),(0,U.jsx)(Bl,{children:e.evals.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name},e.id))})]})]}),t===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsx)(lb,{label:`Cases`,value:String(t.caseCount)}),(0,U.jsx)(lb,{label:`Metrics`,value:String(t.metricNames.length)}),(0,U.jsx)(lb,{label:`Concurrency`,value:String(t.concurrency??1)})]})]}),(0,U.jsx)(`main`,{className:`min-w-0`,children:e.result===void 0?(0,U.jsx)(`div`,{className:`rounded-lg border border-border/80 bg-card/25 p-5 text-sm font-medium text-muted-foreground`,children:`Run a suite to inspect pass, fail, invalid, and per-case metric results.`}):(0,U.jsx)(ub,{result:e.result})})]})]})}):(0,U.jsx)(`section`,{className:`grid min-h-0 place-items-center p-8 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-lg gap-3`,children:[(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold text-foreground`,children:`Evals unavailable`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:`Register eval suites with Studio to run them from this workspace.`})]})})}function lb(e){return(0,U.jsxs)(`div`,{className:`rounded-lg bg-card/35 px-3 py-3`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-1 font-mono text-base font-semibold tabular-nums text-foreground`,children:e.value})]})}function ub(e){let t=e.result.result;return(0,U.jsxs)(`article`,{className:`grid gap-4 rounded-lg border border-border/80 bg-card/25 p-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,U.jsx)(lb,{label:`Passed`,value:String(t.passed??0)}),(0,U.jsx)(lb,{label:`Failed`,value:String(t.failed??0)}),(0,U.jsx)(lb,{label:`Invalid`,value:String(t.invalid??0)}),(0,U.jsx)(lb,{label:`Duration`,value:`${t.durationMs??e.result.durationMs}ms`})]}),(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Result`}),(0,U.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border/80 bg-background/55 p-3 font-mono text-xs leading-5 text-foreground`,children:(0,U.jsx)(nb,{text:JSON.stringify(e.result.result,null,2)})})]})]})}var db=50;function fb(e){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(),a=e.summary?.agents??[],o=e.summary?.evidence??[],s=(0,v.useMemo)(()=>xb(a),[a]),c=Ob(e.activeTab),l=(0,v.useMemo)(()=>c===void 0?[]:s.filter(e=>e.source.kind===c),[c,s]),u=l.find(e=>e.key===t)??l[0];(0,v.useEffect)(()=>{if(l.length===0){n(``);return}l.some(e=>e.key===t)||n((l.find(e=>e.source.inspectable===!0&&(e.source.itemCount??0)>0)??l.find(e=>e.source.inspectable===!0)??l[0])?.key??``)},[t,l]);let d=(0,v.useCallback)(async(e,t)=>{i(n=>({key:e.key,loading:!0,inspectable:n?.key===e.key?n.inspectable:e.source.inspectable===!0,items:t.append&&n?.key===e.key?n.items:[],...t.append&&n?.key===e.key&&n.nextCursor!==void 0?{nextCursor:n.nextCursor}:{},...n?.key===e.key&&n.totalCount!==void 0?{totalCount:n.totalCount}:{}}));try{let n=new URLSearchParams({agentId:e.agentId,sourceId:wb(e.source),limit:String(db)});t.cursor!==void 0&&n.set(`cursor`,t.cursor);let r=await fetch(`/knowledge/items?${n.toString()}`);if(!r.ok)throw Error(`Knowledge items failed with HTTP ${r.status}`);let a=await r.json();i(n=>({key:e.key,loading:!1,inspectable:a.inspectable,items:t.append&&n?.key===e.key?[...n.items,...a.items]:a.items,...a.nextCursor===void 0?{}:{nextCursor:a.nextCursor},...a.totalCount===void 0?{}:{totalCount:a.totalCount},...a.message===void 0?{}:{message:a.message}}))}catch(t){i(n=>({key:e.key,loading:!1,inspectable:n?.inspectable??!1,items:n?.items??[],error:t instanceof Error?t.message:String(t)}))}},[]);return(0,v.useEffect)(()=>{if(u===void 0){i(void 0);return}d(u,{append:!1})},[d,u]),e.enabled?(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Agent context`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Knowledge`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Browse configured context, dynamic chunks, and retrieval evidence.`})]}),(0,U.jsxs)(K,{className:`h-8 min-h-8 gap-2`,type:`button`,variant:`secondary`,onClick:e.onRefresh,children:[(0,U.jsx)(fe,{"aria-hidden":`true`}),`Refresh`]})]})}),(0,U.jsxs)(`div`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] gap-4 overflow-hidden pb-6 pl-0 pr-6 pt-0`,children:[(0,U.jsx)(pb,{activeTab:e.activeTab,sources:s,evidenceCount:o.length,onSelectTab:e.onSelectTab}),e.activeTab===`retrieval-log`?(0,U.jsx)(_b,{evidence:o,onOpenTrace:e.onOpenTrace}):(0,U.jsx)(mb,{sources:l,selectedKey:u?.key??``,loading:e.loading,activeTab:e.activeTab,onSelect:n,children:(0,U.jsx)(hb,{source:u,state:r,onLoadMore:()=>{u!==void 0&&d(u,r?.nextCursor===void 0?{append:!0}:{append:!0,cursor:r.nextCursor})}})})]})]}):(0,U.jsx)(yb,{title:`Knowledge unavailable`,text:`No registered agent exposes inspectable context.`})}function pb(e){return(0,U.jsx)(`nav`,{className:`flex min-w-0 gap-7 overflow-x-auto border-b border-border/80`,"aria-label":`Knowledge sections`,children:Sb.map(t=>{let n=e.activeTab===t.id;return(0,U.jsxs)(`button`,{className:[`flex min-h-10 shrink-0 items-center gap-2 border-b px-0 pb-2 pt-1 text-left transition duration-200 hover:text-foreground focus-visible:outline-none`,n?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:border-border`].join(` `),type:`button`,"aria-current":n?`page`:void 0,onClick:()=>e.onSelectTab(t.id),children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold`,children:t.label}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Ab(t.id,e.sources,e.evidenceCount)})]},t.id)})})}function mb(e){let t=e.sources.length!==1||e.loading;return(0,U.jsxs)(`div`,{className:[`grid min-h-0 gap-3 overflow-hidden`,t?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[minmax(0,1fr)]`].join(` `),children:[t?(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto rounded-xl border border-border/80 bg-card/55`,children:(0,U.jsxs)(`div`,{className:`flex min-h-11 min-w-max items-center gap-2 px-3`,children:[(0,U.jsx)(`span`,{className:`mr-2 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:kb(e.activeTab)}),e.loading&&e.sources.length===0?(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`Loading sources`}):null,!e.loading&&e.sources.length===0?(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`No knowledge sources`}):null,e.sources.map(t=>(0,U.jsxs)(`button`,{className:[`flex h-7 items-center gap-2 rounded-lg border border-border/80 bg-background/45 px-2.5 font-mono text-[11px] font-semibold text-muted-foreground transition duration-200 hover:border-primary/45 hover:bg-primary/10 hover:text-foreground focus-visible:border-ring focus-visible:outline-none`,e.selectedKey===t.key?`border-primary/45 bg-primary/10 text-primary`:``].join(` `),type:`button`,onClick:()=>e.onSelect(t.key),children:[(0,U.jsx)(`span`,{children:t.source.label??Db(t.source.kind)}),t.source.itemCount===void 0?null:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:t.source.itemCount})]},t.key))]})}):null,e.children]})}function hb(e){let t=e.state;return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden rounded-xl border border-border/80 bg-card/55`,children:[(0,U.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate text-sm font-semibold text-foreground`,children:e.source?.source.label??`Knowledge items`}),(0,U.jsx)(`p`,{className:`m-0 mt-1 truncate font-mono text-xs text-muted-foreground`,children:e.source===void 0?`No source selected`:`${e.source.agentId} / ${wb(e.source.source)}`})]}),t?.totalCount===void 0?null:(0,U.jsxs)(Wl,{children:[t.totalCount,` total`]})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto`,children:(0,U.jsxs)(`div`,{className:`p-4`,children:[e.source===void 0?(0,U.jsx)(bb,{text:`No knowledge source selected`}):null,t?.loading===!0&&t.items.length===0?(0,U.jsx)(bb,{text:`Loading items`}):null,t?.error===void 0?null:(0,U.jsx)(bb,{text:t.error}),t?.inspectable===!1?(0,U.jsx)(bb,{text:t.message??`This source does not expose browseable chunks.`}):null,t?.inspectable!==!1&&t?.loading===!1&&t.items.length===0?(0,U.jsx)(bb,{text:`No items in this source`}):null,(0,U.jsx)(`div`,{className:`grid gap-3`,children:t?.items.map(e=>(0,U.jsx)(gb,{item:e},`${e.kind}:${e.id}`))})]})}),(0,U.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 bg-muted/10 px-4 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t===void 0?`0 loaded`:`${t.items.length} loaded`}),(0,U.jsx)(K,{className:`h-8 min-h-8`,type:`button`,variant:`secondary`,disabled:t?.loading===!0||t?.nextCursor===void 0,onClick:e.onLoadMore,children:`Load more`})]})]})}function gb(e){return(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-background/55 p-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold text-primary`,children:e.item.toolName??e.item.id}),(0,U.jsx)(`div`,{className:`mt-1 font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:jb(e.item.kind)})]}),e.item.parameterKeys===void 0||e.item.parameterKeys.length===0?null:(0,U.jsxs)(Wl,{children:[e.item.parameterKeys.length,` params`]})]}),e.item.description===void 0||e.item.description.length===0?null:(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:e.item.description}),e.item.text===void 0?null:(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-sm leading-6 text-foreground [overflow-wrap:anywhere]`,children:e.item.text}),e.item.document===void 0?null:(0,U.jsx)(vb,{title:`Document`,value:e.item.document}),e.item.metadata===void 0?null:(0,U.jsx)(vb,{title:`Metadata`,value:e.item.metadata}),e.item.parameterKeys===void 0||e.item.parameterKeys.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.item.parameterKeys.map(e=>(0,U.jsx)(Wl,{children:e},e))})]})}function _b(e){return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-xl border border-border/80 bg-card/55`,children:[(0,U.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate text-sm font-semibold text-foreground`,children:`Retrieval log`}),(0,U.jsx)(`p`,{className:`m-0 mt-1 truncate font-mono text-xs text-muted-foreground`,children:`traces / retrieval-evidence`})]}),(0,U.jsxs)(Wl,{children:[e.evidence.length,` entries`]})]})}),(0,U.jsxs)(`div`,{className:`min-h-0 overflow-auto p-4`,children:[e.evidence.length===0?(0,U.jsx)(bb,{text:`No retrieval evidence captured yet`}):null,(0,U.jsx)(`div`,{className:`grid gap-3`,children:e.evidence.map(t=>(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-background/45 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:t.observationName}),(0,U.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[`Turn `,t.turn]})]}),(0,U.jsx)(K,{className:`h-auto min-h-0 rounded-lg border border-border bg-muted px-2 py-1 font-mono text-[10px] text-muted-foreground`,type:`button`,variant:`ghost`,onClick:()=>e.onOpenTrace(t.traceId),children:`Trace`})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(Wl,{children:[t.documentCount,` docs`]}),(0,U.jsxs)(Wl,{children:[t.toolCount,` tools`]})]}),t.query===void 0?null:(0,U.jsxs)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-semibold uppercase tracking-[0.14em] text-foreground`,children:`Query`}),` `,t.query]}),t.documents.slice(0,2).map(e=>(0,U.jsxs)(`p`,{className:`m-0 text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-foreground`,children:e.id??`document`}),` `,e.text??``]},`${e.id??`doc`}:${e.text??``}`)),t.tools.length===0?null:(0,U.jsxs)(`p`,{className:`m-0 text-xs leading-5 text-muted-foreground`,children:[`Tools: `,t.tools.join(`, `)]})]},`${t.traceId}:${t.observationId}`))})]})]})}function vb(e){return(0,U.jsxs)(`div`,{className:`grid gap-2 border-t border-border/70 pt-3`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.title}),(0,U.jsx)(ab,{value:e.value})]})}function yb(e){return(0,U.jsx)(`section`,{className:`grid h-full place-items-center p-8`,children:(0,U.jsxs)(`div`,{className:`grid max-w-sm gap-2 text-center`,children:[(0,U.jsx)(`h1`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm font-medium leading-6 text-muted-foreground`,children:e.text})]})})}function bb(e){return(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm font-medium text-muted-foreground`,children:e.text})}function xb(e){return e.flatMap(e=>e.sources.map((t,n)=>({key:`${e.agentId}:${wb(t,n)}`,agentId:e.agentId,agentName:e.agentName??e.agentId,source:Cb(t,n)})))}var Sb=[{id:`static-context`,label:`Static Context`},{id:`dynamic-context`,label:`Dynamic Context`},{id:`retrieval-log`,label:`Retrieval Log`}];function Cb(e,t){return e.sourceId===void 0?{...e,sourceId:Tb(e,t)}:e}function wb(e,t=0){return e.sourceId??Tb(e,t)}function Tb(e,t){switch(e.kind){case`static_context`:return`static-context`;case`dynamic_context`:return`dynamic-context-${e.registrationIndex??t}`;case`dynamic_tools`:return`dynamic-tools-${e.registrationIndex??t}`}}function Eb(e,t){return e.filter(e=>e.kind===t).reduce((e,t)=>e+(t.itemCount??t.count),0)}function Db(e){switch(e){case`static_context`:return`Static context`;case`dynamic_context`:return`Dynamic context`;case`dynamic_tools`:return`Dynamic tools`}}function Ob(e){switch(e){case`static-context`:return`static_context`;case`dynamic-context`:return`dynamic_context`;case`retrieval-log`:return}}function kb(e){return Sb.find(t=>t.id===e)?.label??`Knowledge`}function Ab(e,t,n){let r=Ob(e);if(r===void 0)return`${n} entries`;let i=t.filter(e=>e.source.kind===r),a=Eb(i.map(e=>e.source),r);return`${i.length} sources / ${a} items`}function jb(e){switch(e){case`static_context`:return`Static context`;case`dynamic_context`:return`Dynamic context`;case`dynamic_tool`:return`Dynamic tool`}}function Mb(e){let t=e.agents.find(t=>t.id===e.selectedAgentId)??e.agents[0],n=e.summary?.servers??[],r=n.reduce((e,t)=>e+t.toolCount,0);return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`MCPs`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`External context`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`MCPs`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`MCP servers and remote tools registered on Studio agents, grouped by server.`})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 max-md:grid max-md:grid-cols-1`,children:[(0,U.jsxs)(Wl,{className:`h-9 justify-center border-border/80 bg-card/70 text-muted-foreground`,children:[n.length,` servers / `,r,` tools`]}),e.agents.length>1?(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectAgent,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 w-64 rounded-lg border-border bg-card/80 font-mono text-xs max-md:w-full`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:e.agents.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):null]})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:(0,U.jsx)(`div`,{className:`grid w-full gap-5`,children:e.enabled?e.loading?(0,U.jsx)(Ib,{title:`Loading MCPs`,message:`Reading registered MCP metadata.`}):n.length===0?(0,U.jsx)(Ib,{title:`No MCPs`,message:`The selected agent has no registered MCP tools.`}):n.map(e=>(0,U.jsx)(Nb,{server:e},e.name)):(0,U.jsx)(Ib,{title:`MCPs unavailable`,message:`No registered Studio agent exposes MCP tools.`})})})]})}function Nb(e){return(0,U.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border/80 bg-card/55 p-2 shadow-sm`,children:[(0,U.jsxs)(`header`,{className:`grid min-h-14 grid-cols-[minmax(0,1fr)_auto] items-center gap-4 rounded-lg border border-border/60 bg-muted/20 px-4`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.server.name}),(0,U.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium text-muted-foreground`,children:e.server.agentId})]}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-background/50 text-muted-foreground`,children:[e.server.toolCount,` tools`]})]}),(0,U.jsx)(`div`,{className:`mt-1 grid gap-1`,children:e.server.tools.map(e=>(0,U.jsx)(Pb,{tool:e},`${e.source}:${e.name}`))})]})}function Pb(e){return(0,U.jsxs)(`article`,{className:`grid grid-cols-[minmax(300px,0.75fr)_minmax(0,1fr)] gap-2 rounded-lg border border-transparent bg-background/25 p-2 transition duration-200 hover:border-border/70 hover:bg-background/35 max-lg:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-4 rounded-lg bg-card/25 p-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h3`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.tool.name}),(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:e.tool.source})]}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:e.tool.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:Lb(e.tool.source),children:e.tool.source}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-transparent text-muted-foreground`,children:[zb(e.tool.parameters),` fields`]})]})]}),(0,U.jsx)(Fb,{value:e.tool.parameters})]})}function Fb(e){return(0,U.jsxs)(`section`,{className:`grid min-w-0 content-start overflow-hidden rounded-lg bg-background/45`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-3 bg-muted/20 px-4`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Parameter schema`}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Rb(e.value)})]}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-80 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:Bb(e.value)})})})})]})}function Ib(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.message})]})})}function Lb(e){return e===`dynamic`?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`}function Rb(e){if(typeof e!=`object`||!e||Array.isArray(e))return`value`;let t=e.type;return typeof t==`string`?t:`object`}function zb(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e.properties;return typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length:0}function Bb(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Vb(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(),[d,f]=(0,v.useState)(),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=(0,v.useCallback)(async()=>{if(!e.enabled){n([]),i([]),u(void 0),f(void 0);return}m(!0),y(``);try{let[e,t]=await Promise.all([fetch(`/memory/users?limit=50`),fetch(`/memory/conversations?limit=100`)]);if(!e.ok)throw Error(`Memory users failed with HTTP ${e.status}`);if(!t.ok)throw Error(`Memory conversations failed with HTTP ${t.status}`);let r=await e.json(),a=await t.json();n(r.users),i(a.conversations),c(e=>e||a.conversations[0]?.id||``)}catch(e){y(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.enabled]);(0,v.useEffect)(()=>{b()},[b]),(0,v.useEffect)(()=>{if(!e.enabled||s.length===0){u(void 0),f(void 0);return}let t=!1;async function n(){g(!0);try{let[e,n]=await Promise.all([fetch(`/memory/conversations/${encodeURIComponent(s)}/messages`),fetch(`/memory/conversations/${encodeURIComponent(s)}/steps`)]);if(!e.ok)throw Error(`Conversation messages failed with HTTP ${e.status}`);if(!n.ok)throw Error(`Conversation steps failed with HTTP ${n.status}`);t||(u(await e.json()),f(await n.json()))}catch(e){t||(y(e instanceof Error?e.message:String(e)),u(void 0),f(void 0))}finally{t||g(!1)}}return n(),()=>{t=!0}},[e.enabled,s]);let x=a.length===0?r:r.filter(e=>e.userId===a),S=r.find(e=>e.id===s)??x[0];return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Memory`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Conversation store`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Memory`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Stored users, conversations, raw messages, and transcript steps from the Studio session store.`})]}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-3 font-mono text-xs`,type:`button`,variant:`secondary`,disabled:p,onClick:()=>void b(),children:`Refresh`})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:e.enabled?p&&r.length===0?(0,U.jsx)(Kb,{title:`Loading memory`,text:`Reading users and conversations.`}):_.length>0&&r.length===0?(0,U.jsx)(Kb,{title:`Memory error`,text:_}):(0,U.jsxs)(`div`,{className:`grid min-h-0 gap-4 xl:grid-cols-[280px_minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,U.jsxs)(`section`,{className:`grid content-start gap-2 rounded-xl border border-border/80 bg-card/45 p-3`,children:[(0,U.jsx)(Wb,{title:`Users`,value:t.length}),(0,U.jsx)(K,{className:`h-auto min-h-9 justify-start rounded-lg px-3 py-2 text-left font-mono text-xs`,type:`button`,variant:a.length===0?`secondary`:`ghost`,onClick:()=>o(``),children:`All users`}),t.map(e=>(0,U.jsxs)(K,{className:`grid h-auto min-h-14 justify-start rounded-lg px-3 py-2 text-left`,type:`button`,variant:a===e.userId?`secondary`:`ghost`,onClick:()=>o(e.userId),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-semibold`,children:e.userId}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[e.conversationCount,` conversations ·`,` `,zy(e.lastInteractionAt)]})]},e.userId))]}),(0,U.jsxs)(`section`,{className:`grid content-start gap-2 rounded-xl border border-border/80 bg-card/45 p-3`,children:[(0,U.jsx)(Wb,{title:`Conversations`,value:x.length}),x.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/80 bg-background/45 px-3 py-8 text-center text-sm text-muted-foreground`,children:`No conversations.`}):x.map(t=>(0,U.jsx)(Hb,{conversation:t,agentName:qb(e.agents,t.agentId),active:t.id===s,onSelect:()=>c(t.id)},t.id))]}),(0,U.jsx)(`section`,{className:`grid min-h-0 content-start gap-4`,children:S===void 0?(0,U.jsx)(Kb,{title:`No conversation selected`,text:`Choose a conversation to inspect.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 min-w-0 truncate text-lg font-semibold text-foreground`,children:S.title??`Untitled conversation`}),(0,U.jsx)(`span`,{className:`min-w-0 break-all font-mono text-xs text-muted-foreground`,children:S.id})]}),(0,U.jsx)(Wl,{className:`border-primary/35 bg-primary/10 text-primary`,children:qb(e.agents,S.agentId)})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,U.jsx)(Gb,{label:`user`,value:S.userId}),(0,U.jsx)(Gb,{label:`messages`,value:S.messageCount}),(0,U.jsx)(Gb,{label:`updated`,value:zy(S.updatedAt)})]})]}),h?(0,U.jsx)(Kb,{title:`Loading detail`,text:`Reading message and transcript data.`}):(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsx)(Ub,{title:`messages`,value:l?.messages??[]}),(0,U.jsx)(Ub,{title:`steps`,value:d?.steps??[]})]})]})})]}):(0,U.jsx)(Kb,{title:`Memory unavailable`,text:`This Studio runtime has no session store.`})})]})}function Hb(e){return(0,U.jsxs)(K,{className:`grid h-auto min-h-20 justify-start gap-2 rounded-lg px-3 py-3 text-left`,type:`button`,variant:e.active?`secondary`:`ghost`,onClick:e.onSelect,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold text-foreground`,children:e.conversation.title??`Untitled conversation`}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,children:[e.agentName,` · `,e.conversation.userId]})]}),(0,U.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[e.conversation.messageCount,` messages ·`,` `,zy(e.conversation.updatedAt)]})]})}function Ub(e){let t=Array.isArray(e.value)?e.value.length:void 0;return(0,U.jsxs)(`section`,{className:`grid min-w-0 overflow-hidden rounded-xl border border-border/80 bg-card/45`,children:[(0,U.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/80 bg-muted/20 px-4`,children:(0,U.jsx)(Wb,{title:e.title,...t===void 0?{}:{value:t}})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-96 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:JSON.stringify(e.value,null,2)})})})})]})}function Wb(e){return(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,U.jsx)(`h2`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.title}),e.value===void 0?null:(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground`,children:e.value})]})}function Gb(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-background/45 px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,title:String(e.value),children:e.value})]})}function Kb(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.text})]})})}function qb(e,t){return e.find(e=>e.id===t)?.name??t}function Jb(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Jb(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Yb={value:()=>{}};function Xb(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Zb(n)}function Zb(e){this._=e}function Qb(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Zb.prototype=Xb.prototype={constructor:Zb,on:function(e,t){var n=this._,r=Qb(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=$b(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=ex(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ex(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Zb(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function $b(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ex(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Yb,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var tx={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function nx(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),tx.hasOwnProperty(t)?{space:tx[t],local:e}:e}function rx(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function ix(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ax(e){var t=nx(e);return(t.local?ix:rx)(t)}function ox(){}function sx(e){return e==null?ox:function(){return this.querySelector(e)}}function cx(e){typeof e!=`function`&&(e=sx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new XS(r,this._parents)}function lx(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ux(){return[]}function dx(e){return e==null?ux:function(){return this.querySelectorAll(e)}}function fx(e){return function(){return lx(e.apply(this,arguments))}}function px(e){e=typeof e==`function`?fx(e):dx(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new XS(r,i)}function mx(e){return function(){return this.matches(e)}}function hx(e){return function(t){return t.matches(e)}}var gx=Array.prototype.find;function _x(e){return function(){return gx.call(this.children,e)}}function vx(){return this.firstElementChild}function yx(e){return this.select(e==null?vx:_x(typeof e==`function`?e:hx(e)))}var bx=Array.prototype.filter;function xx(){return Array.from(this.children)}function Sx(e){return function(){return bx.call(this.children,e)}}function Cx(e){return this.selectAll(e==null?xx:Sx(typeof e==`function`?e:hx(e)))}function wx(e){typeof e!=`function`&&(e=mx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new XS(r,this._parents)}function Tx(e){return Array(e.length)}function Ex(){return new XS(this._enter||this._groups.map(Tx),this._parents)}function Dx(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dx.prototype={constructor:Dx,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ox(e){return function(){return e}}function kx(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Dx(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Ax(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Dx(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function jx(e){return e.__data__}function Mx(e,t){if(!arguments.length)return Array.from(this,jx);var n=t?Ax:kx,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Ox(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Nx(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new XS(o,r),o._enter=s,o._exit=c,o}function Nx(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Px(){return new XS(this._exit||this._groups.map(Tx),this._parents)}function Fx(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function Ix(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new XS(s,this._parents)}function Lx(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Rx(e){e||=zx;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new XS(i,this._parents).order()}function zx(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Bx(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Vx(){return Array.from(this)}function Hx(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Ux(){let e=0;for(let t of this)++e;return e}function Wx(){return!this.node()}function Gx(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Kx(e){return function(){this.removeAttribute(e)}}function qx(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jx(e,t){return function(){this.setAttribute(e,t)}}function Yx(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xx(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Zx(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Qx(e,t){var n=nx(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?qx:Kx:typeof t==`function`?n.local?Zx:Xx:n.local?Yx:Jx)(n,t))}function $x(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function eS(e){return function(){this.style.removeProperty(e)}}function tS(e,t,n){return function(){this.style.setProperty(e,t,n)}}function nS(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function rS(e,t,n){return arguments.length>1?this.each((t==null?eS:typeof t==`function`?nS:tS)(e,t,n??``)):iS(this.node(),e)}function iS(e,t){return e.style.getPropertyValue(t)||$x(e).getComputedStyle(e,null).getPropertyValue(t)}function aS(e){return function(){delete this[e]}}function oS(e,t){return function(){this[e]=t}}function sS(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function cS(e,t){return arguments.length>1?this.each((t==null?aS:typeof t==`function`?sS:oS)(e,t)):this.node()[e]}function lS(e){return e.trim().split(/^|\s+/)}function uS(e){return e.classList||new dS(e)}function dS(e){this._node=e,this._names=lS(e.getAttribute(`class`)||``)}dS.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function fS(e,t){for(var n=uS(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function pS(e,t){for(var n=uS(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mS(e){return function(){fS(this,e)}}function hS(e){return function(){pS(this,e)}}function gS(e,t){return function(){(t.apply(this,arguments)?fS:pS)(this,e)}}function _S(e,t){var n=lS(e+``);if(arguments.length<2){for(var r=uS(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?gS:t?mS:hS)(n,t))}function vS(){this.textContent=``}function yS(e){return function(){this.textContent=e}}function bS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function xS(e){return arguments.length?this.each(e==null?vS:(typeof e==`function`?bS:yS)(e)):this.node().textContent}function SS(){this.innerHTML=``}function CS(e){return function(){this.innerHTML=e}}function wS(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function TS(e){return arguments.length?this.each(e==null?SS:(typeof e==`function`?wS:CS)(e)):this.node().innerHTML}function ES(){this.nextSibling&&this.parentNode.appendChild(this)}function DS(){return this.each(ES)}function OS(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kS(){return this.each(OS)}function AS(e){var t=typeof e==`function`?e:ax(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function jS(){return null}function MS(e,t){var n=typeof e==`function`?e:ax(e),r=t==null?jS:typeof t==`function`?t:sx(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function NS(){var e=this.parentNode;e&&e.removeChild(this)}function PS(){return this.each(NS)}function FS(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function IS(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function LS(e){return this.select(e?IS:FS)}function RS(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function zS(e){return function(t){e.call(this,t,this.__data__)}}function BS(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function VS(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function HS(e,t,n){return function(){var r=this.__on,i,a=zS(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function US(e,t,n){var r=BS(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?HS:VS,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function WS(e,t,n){var r=$x(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function GS(e,t){return function(){return WS(this,e,t)}}function KS(e,t){return function(){return WS(this,e,t.apply(this,arguments))}}function qS(e,t){return this.each((typeof t==`function`?KS:GS)(e,t))}function*JS(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var YS=[null];function XS(e,t){this._groups=e,this._parents=t}function ZS(){return new XS([[document.documentElement]],YS)}function QS(){return this}XS.prototype=ZS.prototype={constructor:XS,select:cx,selectAll:px,selectChild:yx,selectChildren:Cx,filter:wx,data:Mx,enter:Ex,exit:Px,join:Fx,merge:Ix,selection:QS,order:Lx,sort:Rx,call:Bx,nodes:Vx,node:Hx,size:Ux,empty:Wx,each:Gx,attr:Qx,style:rS,property:cS,classed:_S,text:xS,html:TS,raise:DS,lower:kS,append:AS,insert:MS,remove:PS,clone:LS,datum:RS,on:US,dispatch:qS,[Symbol.iterator]:JS};function $S(e){return typeof e==`string`?new XS([[document.querySelector(e)]],[document.documentElement]):new XS([[e]],YS)}function eC(e){let t;for(;t=e.sourceEvent;)e=t;return e}function tC(e,t){if(e=eC(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var nC={passive:!1},rC={capture:!0,passive:!1};function iC(e){e.stopImmediatePropagation()}function aC(e){e.preventDefault(),e.stopImmediatePropagation()}function oC(e){var t=e.document.documentElement,n=$S(e).on(`dragstart.drag`,aC,rC);`onselectstart`in t?n.on(`selectstart.drag`,aC,rC):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function sC(e,t){var n=e.document.documentElement,r=$S(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,aC,rC),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var cC=e=>()=>e;function lC(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}lC.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uC(e){return!e.ctrlKey&&!e.button}function dC(){return this.parentNode}function fC(e,t){return t??{x:e.x,y:e.y}}function pC(){return navigator.maxTouchPoints||`ontouchstart`in this}function mC(){var e=uC,t=dC,n=fC,r=pC,i={},a=Xb(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,nC).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&($S(n.view).on(`mousemove.drag`,m,rC).on(`mouseup.drag`,h,rC),oC(n.view),iC(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(aC(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){$S(e.view).on(`mousemove.drag mouseup.drag`,null),sC(e.view,l),aC(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(iC(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(aC(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(iC(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=tC(l||r,t),p,m,h;if((h=n.call(e,new lC(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=tC(l||a,t),_=o;break}u.call(r,e,new lC(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:cC(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:cC(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:cC(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:cC(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function hC(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gC(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _C(){}var vC=.7,yC=1/vC,bC=`\\s*([+-]?\\d+)\\s*`,xC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,SC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,CC=/^#([0-9a-f]{3,8})$/,wC=RegExp(`^rgb\\(${bC},${bC},${bC}\\)$`),TC=RegExp(`^rgb\\(${SC},${SC},${SC}\\)$`),EC=RegExp(`^rgba\\(${bC},${bC},${bC},${xC}\\)$`),DC=RegExp(`^rgba\\(${SC},${SC},${SC},${xC}\\)$`),OC=RegExp(`^hsl\\(${xC},${SC},${SC}\\)$`),kC=RegExp(`^hsla\\(${xC},${SC},${SC},${xC}\\)$`),AC={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};hC(_C,FC,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jC,formatHex:jC,formatHex8:MC,formatHsl:NC,formatRgb:PC,toString:PC});function jC(){return this.rgb().formatHex()}function MC(){return this.rgb().formatHex8()}function NC(){return JC(this).formatHsl()}function PC(){return this.rgb().formatRgb()}function FC(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=CC.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?IC(t):n===3?new BC(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?LC(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?LC(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=wC.exec(e))?new BC(t[1],t[2],t[3],1):(t=TC.exec(e))?new BC(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=EC.exec(e))?LC(t[1],t[2],t[3],t[4]):(t=DC.exec(e))?LC(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=OC.exec(e))?qC(t[1],t[2]/100,t[3]/100,1):(t=kC.exec(e))?qC(t[1],t[2]/100,t[3]/100,t[4]):AC.hasOwnProperty(e)?IC(AC[e]):e===`transparent`?new BC(NaN,NaN,NaN,0):null}function IC(e){return new BC(e>>16&255,e>>8&255,e&255,1)}function LC(e,t,n,r){return r<=0&&(e=t=n=NaN),new BC(e,t,n,r)}function RC(e){return e instanceof _C||(e=FC(e)),e?(e=e.rgb(),new BC(e.r,e.g,e.b,e.opacity)):new BC}function zC(e,t,n,r){return arguments.length===1?RC(e):new BC(e,t,n,r??1)}function BC(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}hC(BC,zC,gC(_C,{brighter(e){return e=e==null?yC:yC**+e,new BC(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vC:vC**+e,new BC(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new BC(GC(this.r),GC(this.g),GC(this.b),WC(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:VC,formatHex:VC,formatHex8:HC,formatRgb:UC,toString:UC}));function VC(){return`#${KC(this.r)}${KC(this.g)}${KC(this.b)}`}function HC(){return`#${KC(this.r)}${KC(this.g)}${KC(this.b)}${KC((isNaN(this.opacity)?1:this.opacity)*255)}`}function UC(){let e=WC(this.opacity);return`${e===1?`rgb(`:`rgba(`}${GC(this.r)}, ${GC(this.g)}, ${GC(this.b)}${e===1?`)`:`, ${e})`}`}function WC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function GC(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function KC(e){return e=GC(e),(e<16?`0`:``)+e.toString(16)}function qC(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new XC(e,t,n,r)}function JC(e){if(e instanceof XC)return new XC(e.h,e.s,e.l,e.opacity);if(e instanceof _C||(e=FC(e)),!e)return new XC;if(e instanceof XC)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new XC(o,s,c,e.opacity)}function YC(e,t,n,r){return arguments.length===1?JC(e):new XC(e,t,n,r??1)}function XC(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}hC(XC,YC,gC(_C,{brighter(e){return e=e==null?yC:yC**+e,new XC(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vC:vC**+e,new XC(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new BC($C(e>=240?e-240:e+120,i,r),$C(e,i,r),$C(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new XC(ZC(this.h),QC(this.s),QC(this.l),WC(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=WC(this.opacity);return`${e===1?`hsl(`:`hsla(`}${ZC(this.h)}, ${QC(this.s)*100}%, ${QC(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function ZC(e){return e=(e||0)%360,e<0?e+360:e}function QC(e){return Math.max(0,Math.min(1,e||0))}function $C(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var ew=e=>()=>e;function tw(e,t){return function(n){return e+n*t}}function nw(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function rw(e){return(e=+e)==1?iw:function(t,n){return n-t?nw(t,n,e):ew(isNaN(t)?n:t)}}function iw(e,t){var n=t-e;return n?tw(e,n):ew(isNaN(e)?t:e)}var aw=(function e(t){var n=rw(t);function r(e,t){var r=n((e=zC(e)).r,(t=zC(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=iw(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function ow(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function sw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cw(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=_w(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function lw(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function uw(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dw(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=_w(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var fw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pw=new RegExp(fw.source,`g`);function mw(e){return function(){return e}}function hw(e){return function(t){return e(t)+``}}function gw(e,t){var n=fw.lastIndex=pw.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=fw.exec(e))&&(i=pw.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:uw(r,i)})),n=pw.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?hw(c[0].x):mw(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function _w(e,t){var n=typeof t,r;return t==null||n===`boolean`?ew(t):(n===`number`?uw:n===`string`?(r=FC(t))?(t=r,aw):gw:t instanceof FC?aw:t instanceof Date?lw:sw(t)?ow:Array.isArray(t)?cw:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?dw:uw)(e,t)}var vw=180/Math.PI,yw={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bw(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*vw,skewX:Math.atan(c)*vw,scaleX:o,scaleY:s}}var xw;function Sw(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?yw:bw(t.a,t.b,t.c,t.d,t.e,t.f)}function Cw(e){return e==null||(xw||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),xw.setAttribute(`transform`,e),!(e=xw.transform.baseVal.consolidate()))?yw:(e=e.matrix,bw(e.a,e.b,e.c,e.d,e.e,e.f))}function ww(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:uw(e,i)},{i:c-2,x:uw(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:uw(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:uw(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:uw(e,n)},{i:s-2,x:uw(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Tw=ww(Sw,`px, `,`px)`,`deg)`),Ew=ww(Cw,`, `,`)`,`)`),Dw=1e-12;function Ow(e){return((e=Math.exp(e))+1/e)/2}function kw(e){return((e=Math.exp(e))-1/e)/2}function Aw(e){return((e=Math.exp(2*e))-1)/(e+1)}var jw=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Dw)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=Ow(y),c=s/(n*g)*(i*Aw(t*r+y)-kw(y));return[a+c*d,o+c*f,s*i/Ow(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),Mw=0,Nw=0,Pw=0,Fw=1e3,Iw,Lw,Rw=0,zw=0,Bw=0,Vw=typeof performance==`object`&&performance.now?performance:Date,Hw=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uw(){return zw||=(Hw(Ww),Vw.now()+Bw)}function Ww(){zw=0}function Gw(){this._call=this._time=this._next=null}Gw.prototype=Kw.prototype={constructor:Gw,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Uw():+n)+(t==null?0:+t),!this._next&&Lw!==this&&(Lw?Lw._next=this:Iw=this,Lw=this),this._call=e,this._time=n,Zw()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zw())}};function Kw(e,t,n){var r=new Gw;return r.restart(e,t,n),r}function qw(){Uw(),++Mw;for(var e=Iw,t;e;)(t=zw-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mw}function Jw(){zw=(Rw=Vw.now())+Bw,Mw=Nw=0;try{qw()}finally{Mw=0,Xw(),zw=0}}function Yw(){var e=Vw.now(),t=e-Rw;t>Fw&&(Bw-=t,Rw=e)}function Xw(){for(var e,t=Iw,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Iw=n);Lw=e,Zw(r)}function Zw(e){Mw||(Nw&&=clearTimeout(Nw),e-zw>24?(e<1/0&&(Nw=setTimeout(Jw,e-Vw.now()-Bw)),Pw&&=clearInterval(Pw)):(Pw||=(Rw=Vw.now(),setInterval(Yw,Fw)),Mw=1,Hw(Jw)))}function Qw(e,t,n){var r=new Gw;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var $w=Xb(`start`,`end`,`cancel`,`interrupt`),eT=[];function tT(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;aT(e,n,{name:t,index:r,group:i,on:$w,tween:eT,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function nT(e,t){var n=iT(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function rT(e,t){var n=iT(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function iT(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function aT(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Kw(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Qw(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Qw(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function oT(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function sT(e){return this.each(function(){oT(this,e)})}function cT(e,t){var n,r;return function(){var i=rT(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function lT(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=rT(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function uT(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=iT(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?cT:lT)(n,e,t))}function dT(e,t,n){var r=e._id;return e.each(function(){var e=rT(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return iT(e,r).value[t]}}function fT(e,t){var n;return(typeof t==`number`?uw:t instanceof FC?aw:(n=FC(t))?(t=n,aw):gw)(e,t)}function pT(e){return function(){this.removeAttribute(e)}}function mT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hT(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function gT(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function _T(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function vT(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function yT(e,t){var n=nx(e),r=n===`transform`?Ew:fT;return this.attrTween(e,typeof t==`function`?(n.local?vT:_T)(n,r,dT(this,`attr.`+e,t)):t==null?(n.local?mT:pT)(n):(n.local?gT:hT)(n,r,t))}function bT(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function xT(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ST(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&xT(e,i)),n}return i._value=t,i}function CT(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&bT(e,i)),n}return i._value=t,i}function wT(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=nx(e);return this.tween(n,(r.local?ST:CT)(r,t))}function TT(e,t){return function(){nT(this,e).delay=+t.apply(this,arguments)}}function ET(e,t){return t=+t,function(){nT(this,e).delay=t}}function DT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?TT:ET)(t,e)):iT(this.node(),t).delay}function OT(e,t){return function(){rT(this,e).duration=+t.apply(this,arguments)}}function kT(e,t){return t=+t,function(){rT(this,e).duration=t}}function AT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?OT:kT)(t,e)):iT(this.node(),t).duration}function jT(e,t){if(typeof t!=`function`)throw Error();return function(){rT(this,e).ease=t}}function MT(e){var t=this._id;return arguments.length?this.each(jT(t,e)):iT(this.node(),t).ease}function NT(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();rT(this,e).ease=n}}function PT(e){if(typeof e!=`function`)throw Error();return this.each(NT(this._id,e))}function FT(e){typeof e!=`function`&&(e=mx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new uE(r,this._parents,this._name,this._id)}function IT(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new uE(o,this._parents,this._name,this._id)}function LT(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function RT(e,t,n){var r,i,a=LT(t)?nT:rT;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function zT(e,t){var n=this._id;return arguments.length<2?iT(this.node(),n).on.on(e):this.each(RT(n,e,t))}function BT(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function VT(){return this.on(`end.remove`,BT(this._id))}function HT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=sx(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,tT(l[f],t,n,f,l,iT(u,n)));return new uE(a,this._parents,t,n)}function UT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=dx(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=iT(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&tT(p,t,n,h,f,m);a.push(f),o.push(u)}return new uE(a,o,t,n)}var WT=ZS.prototype.constructor;function GT(){return new WT(this._groups,this._parents)}function KT(e,t){var n,r,i;return function(){var a=iS(this,e),o=(this.style.removeProperty(e),iS(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function qT(e){return function(){this.style.removeProperty(e)}}function JT(e,t,n){var r,i=n+``,a;return function(){var o=iS(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function YT(e,t,n){var r,i,a;return function(){var o=iS(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),iS(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function XT(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=rT(this,e),l=c.on,u=c.value[a]==null?s||=qT(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ZT(e,t,n){var r=(e+=``)==`transform`?Tw:fT;return t==null?this.styleTween(e,KT(e,r)).on(`end.style.`+e,qT(e)):typeof t==`function`?this.styleTween(e,YT(e,r,dT(this,`style.`+e,t))).each(XT(this._id,e)):this.styleTween(e,JT(e,r,t),n).on(`end.style.`+e,null)}function QT(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $T(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&QT(e,a,n)),r}return a._value=t,a}function eE(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,$T(e,t,n??``))}function tE(e){return function(){this.textContent=e}}function nE(e){return function(){var t=e(this);this.textContent=t??``}}function rE(e){return this.tween(`text`,typeof e==`function`?nE(dT(this,`text`,e)):tE(e==null?``:e+``))}function iE(e){return function(t){this.textContent=e.call(this,t)}}function aE(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&iE(r)),t}return r._value=e,r}function oE(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,aE(e))}function sE(){for(var e=this._name,t=this._id,n=fE(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=iT(c,t);tT(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new uE(r,this._parents,e,n)}function cE(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=rT(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var lE=0;function uE(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function dE(e){return ZS().transition(e)}function fE(){return++lE}var pE=ZS.prototype;uE.prototype=dE.prototype={constructor:uE,select:HT,selectAll:UT,selectChild:pE.selectChild,selectChildren:pE.selectChildren,filter:FT,merge:IT,selection:GT,transition:sE,call:pE.call,nodes:pE.nodes,node:pE.node,size:pE.size,empty:pE.empty,each:pE.each,on:zT,attr:yT,attrTween:wT,style:ZT,styleTween:eE,text:rE,textTween:oE,remove:VT,tween:uT,delay:DT,duration:AT,ease:MT,easeVarying:PT,end:cE,[Symbol.iterator]:pE[Symbol.iterator]};function mE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var hE={time:null,delay:0,duration:250,ease:mE};function gE(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function _E(e){var t,n;e instanceof uE?(t=e._id,e=e._name):(t=fE(),(n=hE).time=Uw(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&tT(c,e,t,l,o,n||gE(c,t));return new uE(r,this._parents,e,t)}ZS.prototype.interrupt=sT,ZS.prototype.transition=_E;var vE=e=>()=>e;function yE(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function bE(e,t,n){this.k=e,this.x=t,this.y=n}bE.prototype={constructor:bE,scale:function(e){return e===1?this:new bE(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new bE(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var xE=new bE(1,0,0);SE.prototype=bE.prototype;function SE(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xE;return e.__zoom}function CE(e){e.stopImmediatePropagation()}function wE(e){e.preventDefault(),e.stopImmediatePropagation()}function TE(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function EE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function DE(){return this.__zoom||xE}function OE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function kE(){return navigator.maxTouchPoints||`ontouchstart`in this}function AE(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function jE(){var e=TE,t=EE,n=AE,r=OE,i=kE,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=jw,l=Xb(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,DE).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,DE),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(xE.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new bE(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new bE(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new bE(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=$S(this.that).datum();l.call(e,this.that,new yE(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=tC(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],oT(this),s.start();wE(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=$S(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=tC(t,i),l=t.clientX,u=t.clientY;oC(t.view),CE(t),a.mouse=[c,this.__zoom.invert(c)],oT(this),a.start();function d(e){if(wE(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=tC(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),sC(e.view,a.moved),wE(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=tC(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);wE(r),s>0?$S(this).transition().duration(s).call(x,d,c,r):$S(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(CE(t),s=0;s<i;++s)c=r[s],l=tC(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),oT(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(wE(e),s=0;s<a;++s)c=i[s],l=tC(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(CE(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=tC(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=$S(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:vE(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:vE(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:vE(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:vE([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var ME={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},NE=[[-1/0,-1/0],[1/0,1/0]],PE=[`Enter`,` `,`Escape`],FE={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},IE;(function(e){e.Strict=`strict`,e.Loose=`loose`})(IE||={});var LE;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(LE||={});var RE;(function(e){e.Partial=`partial`,e.Full=`full`})(RE||={});var zE={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},BE;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(BE||={});var VE;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(VE||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var HE={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function UE(e){return e===null?null:e?`valid`:`invalid`}var WE=e=>`id`in e&&`source`in e&&`target`in e,GE=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),KE=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),qE=(e,t=[0,0])=>{let{width:n,height:r}=ED(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},JE=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:lD(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):KE(n)?n:t.nodeLookup.get(n.id)),sD(e,i?dD(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),YE=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=sD(n,dD(e)),r=!0)}),r?lD(n):{x:0,y:0,width:0,height:0}},XE=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...vD(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=pD(s,uD(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},ZE=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function QE(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function $E({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=CD(YE(QE(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function eD({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,ME.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&TD(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=TD(d)?rD(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,ME.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function tD({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ZE(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var nD=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rD=(e={x:0,y:0},t,n)=>({x:nD(e.x,t[0][0],t[1][0]-(n?.width??0)),y:nD(e.y,t[0][1],t[1][1]-(n?.height??0))});function iD(e,t,n){let{width:r,height:i}=ED(n),{x:a,y:o}=n.internals.positionAbsolute;return rD(e,[[a,o],[a+r,o+i]],t)}var aD=(e,t,n)=>e<t?nD(Math.abs(e-t),1,t)/t:e>n?-nD(Math.abs(e-n),1,t)/t:0,oD=(e,t,n=15,r=40)=>[aD(e.x,r,t.width-r)*n,aD(e.y,r,t.height-r)*n],sD=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),cD=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),lD=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),uD=(e,t=[0,0])=>{let{x:n,y:r}=KE(e)?e.internals.positionAbsolute:qE(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},dD=(e,t=[0,0])=>{let{x:n,y:r}=KE(e)?e.internals.positionAbsolute:qE(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},fD=(e,t)=>lD(sD(cD(e),cD(t))),pD=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},mD=e=>hD(e.width)&&hD(e.height)&&hD(e.x)&&hD(e.y),hD=e=>!isNaN(e)&&isFinite(e),gD=(e,t)=>{},_D=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),vD=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?_D(s,o):s},yD=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function bD(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function xD(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=bD(e,n),i=bD(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=bD(e.top??e.y??0,n),i=bD(e.bottom??e.y??0,n),a=bD(e.left??e.x??0,t),o=bD(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function SD(e,t,n,r,i,a){let{x:o,y:s}=yD(e,[t,n,r]),{x:c,y:l}=yD({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var CD=(e,t,n,r,i,a)=>{let o=xD(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=nD(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=SD(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},wD=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function TD(e){return e!=null&&e!==`parent`}function ED(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function DD(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function OD(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function kD(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function AD(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function jD(e){return{...FE,...e||{}}}function MD(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=RD(e),s=vD({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?_D(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ND=e=>({width:e.offsetWidth,height:e.offsetHeight}),PD=e=>e?.getRootNode?.()||window?.document,FD=[`INPUT`,`SELECT`,`TEXTAREA`];function ID(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?FD.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var LD=e=>`clientX`in e,RD=(e,t)=>{let n=LD(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},zD=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ND(t)}})};function BD({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function VD(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function HD({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-VD(t-r,a),n];case $.Right:return[t+VD(r-t,a),n];case $.Top:return[t,n-VD(n-i,a)];case $.Bottom:return[t,n+VD(i-n,a)]}}function UD({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=HD({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=HD({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=BD({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function WD({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function GD({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function KD({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=sD(dD(e),dD(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),pD({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},lD(a))>0}var qD=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,JD=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),YD=(e,t,n={})=>{if(!e.source||!e.target)return ME.error006(),t;let r=n.getEdgeId||qD,i;return i=WE(e)?{...e}:{...e,id:r(e)},JD(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function XD({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=WD({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var ZD={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},QD=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},$D=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function eO({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=ZD[t],c=ZD[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=QD({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=WD({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function tO(e,t,n,r){let i=Math.min($D(e,t)/2,$D(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function nO({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=eO({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=tO(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function rO(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function iO(e){let{sourceNode:t,targetNode:n}=e;if(!rO(t)||!rO(n))return null;let r=t.internals.handleBounds||aO(t.handles),i=n.internals.handleBounds||aO(n.handles),a=sO(r?.source??[],e.sourceHandle),o=sO(e.connectionMode===IE.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,ME.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=oO(t,a,s),u=oO(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function aO(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function oO(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??ED(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function sO(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function cO(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function lO(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=cO(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var uO=1e3,dO=10,fO={nodeOrigin:[0,0],nodeExtent:NE,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},pO={...fO,checkEquality:!0};function mO(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function hO(e,t,n){let r=mO(fO,n);for(let n of e.values())if(n.parentId)bO(n,e,t,r);else{let e=rD(qE(n,r.nodeOrigin),TD(n.extent)?n.extent:r.nodeExtent,ED(n));n.internals.positionAbsolute=e}}function gO(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function _O(e){return e===`manual`}function vO(e,t,n,r={}){let i=mO(pO,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!_O(i.zIndexMode)?uO:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=rD(qE(u,i.nodeOrigin),TD(u.extent)?u.extent:i.nodeExtent,ED(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:gO(u,e),z:xO(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&bO(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function yO(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function bO(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=mO(fO,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}yO(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*dO),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=SO(e,u,o,s,a&&!_O(c)?uO:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function xO(e,t,n){let r=hD(e.zIndex)?e.zIndex:0;return _O(n)?r:r+(e.selected?t:0)}function SO(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ED(e),l=qE(e,n),u=TD(e.extent)?rD(l,e.extent,c):l,d=rD({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=iD(d,c,t));let f=xO(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function CO(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=fD(a.get(n.parentId)?.expandedRect??uD(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ED(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function wO(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=ND(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=TD(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=iD(h,s,t.get(e.parentId)):m&&(h=rD(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:zD(`source`,r.nodeElement,p,d,e.id),target:zD(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&bO(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:uD(g,i)}))}}if(f.length>0){let e=CO(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function TO({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function EO(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function DO(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;EO(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),EO(`target`,s,c,e,i,o),t.set(r.id,r)}}function OO(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:OO(n,t):!1}function kO(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function AO(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!OO(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function jO({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function MO({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=_D(a,t);return{x:o.x-a.x,y:o.y-a.y}}function NO({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=$S(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?cD(YE(s)):null,x=v&&l?MO({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:_D(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=eD({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=jO({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=oD(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=MD(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=AO(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=jO({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=mC().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=MD(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=RD(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=MD(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=RD(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=RD(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=jO({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!kO(t,`.${g}`,v))&&(!_||kO(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function PO(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())pD(i,uD(e))>0&&r.push(e);return r}var FO=250;function IO(e,t,n,r){let i=[],a=1/0,o=PO(e,n,t+FO);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=oO(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function LO(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...oO(o,c,c.position,!0)}:c}function RO(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function zO(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var BO=()=>!0;function VO(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=BO,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=PD(e.target),E=0,D,{x:O,y:k}=RD(e),A=RO(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=LO(i,A,r,c,t);if(!N)return;let P=RD(e,j),ee=!1,F=null,I=!1,te=null;function ne(){if(!u||!j)return;let[e,t]=oD(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ne)}let L={...N,nodeId:i,type:A,position:N.position},R=c.get(i),z={inProgress:!0,isValid:null,from:oO(R,L,$.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:R,to:P,toHandle:null,toPosition:HE[L.position],toNode:null,pointer:P};function B(){M=!0,y(z),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&B();function re(e){if(!M){let{x:t,y:n}=RD(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;B()}if(!x()||!L){ie(e);return}let a=b();P=RD(e,j),D=IO(vD(P,a,!1,[1,1]),n,c,L),ee||=(ne(),!0);let s=HO(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});te=s.handleDomNode,F=s.connection,I=zO(!!D,s.isValid);let u=c.get(i),f=u?oO(u,L,$.Left,!0):z.from,p={...z,from:f,isValid:I,to:s.toHandle&&I?yD({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:I&&s.toHandle?s.toHandle.position:HE[L.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),z=p}function ie(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||te)&&F&&I&&h?.(F);let{inProgress:t,...n}=z,r={...n,toPosition:z.toHandle?z.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ee=!1,I=!1,F=null,te=null,T.removeEventListener(`mousemove`,re),T.removeEventListener(`mouseup`,ie),T.removeEventListener(`touchmove`,re),T.removeEventListener(`touchend`,ie)}}T.addEventListener(`mousemove`,re),T.addEventListener(`mouseup`,ie),T.addEventListener(`touchmove`,re),T.addEventListener(`touchend`,ie)}function HO(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=BO,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=RD(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=RO(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===IE.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=LO(t,e,a,u,n,!0)}return _}var UO={onPointerDown:VO,isValid:HO};function WO({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=$S(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&wD()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=jE().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:tC}}var GO=e=>({x:e.x,y:e.y,zoom:e.k}),KO=({x:e,y:t,zoom:n})=>xE.translate(e,t).scale(n),qO=(e,t)=>e.target.closest(`.${t}`),JO=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),YO=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,XO=(e,t=0,n=YO,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ZO=e=>{let t=e.ctrlKey&&wD()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QO({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(qO(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=tC(u),t=d*2**ZO(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===LE.Vertical?0:u.deltaX*f,m=i===LE.Horizontal?0:u.deltaY*f;!wD()&&u.shiftKey&&i!==LE.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=GO(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function $O({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=qO(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function ek({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=GO(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function tk({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&JO(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,GO(a.transform))}}function nk({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&JO(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=GO(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function rk({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(qO(d,`${l}-flow__node`)||qO(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||qO(d,s)&&m||qO(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function ik({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=jE().scaleExtent([t,n]).translateExtent(r),f=$S(e).call(d);v({x:i.x,y:i.y,zoom:nD(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(ZO);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).transform(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!hD(E)||E<0?0:E);let k=O?QO({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):$O({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=ek({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=tk({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=nk({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=rk({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=KO(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=KO(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=KO(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?SE(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).scaleTo(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).scaleBy(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!hD(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var ak;(function(e){e.Line=`line`,e.Handle=`handle`})(ak||={});function ok({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function sk(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function ck(e,t){return Math.max(0,t-e)}function lk(e,t){return Math.max(0,e-t)}function uk(e,t,n){return Math.max(0,t-e,e-n)}function dk(e,t){return e?!t:t}function fk(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=uk(E,h,g),j=uk(D,_,v);if(o){let e=0,t=0;c&&w<0?e=ck(y+w+O,o[0][0]):!c&&w>0&&(e=lk(y+E+O,o[1][0])),l&&T<0?t=ck(b+T+k,o[0][1]):!l&&T>0&&(t=lk(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=lk(y+w,s[0][0]):!c&&w<0&&(e=ck(y+E,s[1][0])),l&&T>0?t=lk(b+T,s[0][1]):!l&&T<0&&(t=ck(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=uk(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?lk(b+k+E/C,o[1][1])*C:ck(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?ck(b+E/C,s[1][1])*C:lk(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=uk(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?lk(y+D*C+O,o[1][0])/C:ck(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?ck(y+D*C,s[1][0])/C:lk(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(dk(c,l)?-w:w)/C:w=(dk(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var pk={width:0,height:0,x:0,y:0},mk={...pk,pointerX:0,pointerY:0,aspectRatio:1};function hk(e){return[[0,0],[e.measured.width,e.measured.height]]}function gk(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function _k({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=$S(e),o={controlDirection:sk(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...pk},h={...mk};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:sk(e)};let g,_=null,v=[],y,b,x,S=!1,C=mC().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=MD(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?hk(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=gk(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=MD(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=fk(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let ee=ok({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),F={...m,direction:ee};p?.(e,F)!==!1&&(S=!0,d?.(e,F),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var vk=o((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),yk=o(((e,t)=>{t.exports=vk()})),bk=o((e=>{var t=p(),n=yk();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),xk=l(o(((e,t)=>{t.exports=bk()}))(),1),Sk=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Ck=e=>e?Sk(e):Sk,{useDebugValue:wk}=v.default,{useSyncExternalStoreWithSelector:Tk}=xk.default,Ek=e=>e;function Dk(e,t=Ek,n){let r=Tk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wk(r),r}var Ok=(e,t)=>{let n=Ck(e),r=(e,r=t)=>Dk(n,e,r);return Object.assign(r,n),r},kk=(e,t)=>e?Ok(e,t):Ok;function Ak(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var jk=(0,v.createContext)(null),Mk=jk.Provider,Nk=ME.error001();function Pk(e,t){let n=(0,v.useContext)(jk);if(n===null)throw Error(Nk);return Dk(n,e,t)}function Fk(){let e=(0,v.useContext)(jk);if(e===null)throw Error(Nk);return(0,v.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Ik={display:`none`},Lk={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Rk=`react-flow__node-desc`,zk=`react-flow__edge-desc`,Bk=`react-flow__aria-live`,Vk=e=>e.ariaLiveMessage,Hk=e=>e.ariaLabelConfig;function Uk({rfId:e}){let t=Pk(Vk);return(0,U.jsx)(`div`,{id:`${Bk}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Lk,children:t})}function Wk({rfId:e,disableKeyboardA11y:t}){let n=Pk(Hk);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${Rk}-${e}`,style:Ik,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${zk}-${e}`,style:Ik,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(Uk,{rfId:e})]})}var Gk=(0,v.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,U.jsx)(`div`,{className:Jb([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));Gk.displayName=`Panel`;function Kk({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,U.jsx)(Gk,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,U.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var qk=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Jk=e=>e.id;function Yk(e,t){return Ak(e.selectedNodes.map(Jk),t.selectedNodes.map(Jk))&&Ak(e.selectedEdges.map(Jk),t.selectedEdges.map(Jk))}function Xk({onSelectionChange:e}){let t=Fk(),{selectedNodes:n,selectedEdges:r}=Pk(qk,Yk);return(0,v.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Zk=e=>!!e.onSelectionChangeHandlers;function Qk({onSelectionChange:e}){let t=Pk(Zk);return e||t?(0,U.jsx)(Xk,{onSelectionChange:e}):null}var $k=typeof window<`u`?v.useLayoutEffect:v.useEffect,eA=[0,0],tA={x:0,y:0,zoom:1},nA=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],rA=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),iA={translateExtent:NE,nodeOrigin:eA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function aA(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Pk(rA,Ak),l=Fk();$k(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=iA,s()}),[]);let u=(0,v.useRef)(iA);return $k(()=>{for(let s of nA){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:jD(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},nA.map(t=>e[t])),null}function oA(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function sA(e){let[t,n]=(0,v.useState)(e===`system`?null:e);return(0,v.useEffect)(()=>{if(e!==`system`){n(e);return}let t=oA(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?oA()?.matches?`dark`:`light`:t}var cA=typeof document<`u`?document:null;function lA(e=null,t={target:cA,actInsideInputWithModifier:!0}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(!1),a=(0,v.useRef)(new Set([])),[o,s]=(0,v.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
77
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return O_(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Tv.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Fv(){return{exit:{taskListCheckValueChecked:Lv,taskListCheckValueUnchecked:Lv,paragraph:Rv}}}function Iv(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:zv}}}function Lv(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Rv(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function zv(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Tv.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Bv(){return[Kg(),g_(),x_(),Ev(),Fv()]}function Vv(e){return{extensions:[qg(),__(e),S_(),Pv(e),Iv()]}}var Hv={tokenize:ny,partial:!0},Uv={tokenize:ry,partial:!0},Wv={tokenize:iy,partial:!0},Gv={tokenize:ay,partial:!0},Kv={tokenize:oy,partial:!0},qv={name:`wwwAutolink`,tokenize:ey,previous:sy},Jv={name:`protocolAutolink`,tokenize:ty,previous:cy},Yv={name:`emailAutolink`,tokenize:$v,previous:ly},Xv={};function Zv(){return{text:Xv}}for(var Qv=48;Qv<123;)Xv[Qv]=Yv,Qv++,Qv===58?Qv=65:Qv===91&&(Qv=97);Xv[43]=Yv,Xv[45]=Yv,Xv[46]=Yv,Xv[95]=Yv,Xv[72]=[Yv,Jv],Xv[104]=[Yv,Jv],Xv[87]=[Yv,qv],Xv[119]=[Yv,qv];function $v(e,t,n){let r=this,i,a;return o;function o(t){return!uy(t)||!ly.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return uy(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Kv,u,l)(t):t===45||t===95||Kd(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Gd(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function ey(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!sy.call(r,r.previous)||dy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Hv,e.attempt(Uv,e.attempt(Wv,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function ty(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&cy.call(r,r.previous)&&!dy(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Gd(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Jd(t)||Qd(t)||tf(t)||ef(t)?n(t):e.attempt(Uv,e.attempt(Wv,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function ny(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function ry(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Gv,c,s)(t):t===null||Qd(t)||tf(t)||t!==45&&ef(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function iy(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Gv,t,a)(o):o===null||Qd(o)||tf(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function ay(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Qd(o)||tf(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Qd(e)||tf(e)?t(e):r(e)}function a(e){return Gd(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Gd(t)?(e.consume(t),o):n(t)}}function oy(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Kd(e)?n(e):t(e)}}function sy(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Qd(e)}function cy(e){return!Gd(e)}function ly(e){return!(e===47||uy(e))}function uy(e){return e===43||e===45||e===46||e===95||Kd(e)}function dy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var fy={tokenize:by,partial:!0};function py(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:_y,continuation:{tokenize:vy},exit:yy}},text:{91:{name:`gfmFootnoteCall`,tokenize:gy},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:my,resolveTo:hy}}}}function my(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Wd(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function hy(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function gy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Qd(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Wd(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Qd(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function _y(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Qd(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Wd(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Qd(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),af(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function vy(e,t,n){return e.check(bf,t,e.attempt(fy,t,n))}function yy(e){e.exit(`gfmFootnoteDefinition`)}function by(e,t,n){let r=this;return af(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function xy(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ld(o,o.length,0,pf(s,e.slice(r+1,n),t)),Ld(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ld(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ff(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ff(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Sy=class{constructor(){this.map=[]}add(e,t,n){Cy(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Cy(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function wy(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Ty(){return{flow:{null:{name:`table`,tokenize:Ey,resolveAll:Dy}}}}function Ey(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):$d(t)?af(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Qd(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,$d(t)?af(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return $d(t)?af(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return $d(t)?af(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Q(n)?(e.exit(`tableRow`),t(n)):$d(n)?af(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Qd(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Dy(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Sy;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ky(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Oy(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Oy(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Oy(f,t,o,i,n,d)):(o[0]=o[1],d=Oy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ky(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=wy(t.events,n))}return e}function Oy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ay(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ay(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ay(t.events,n[2]),a=Ay(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ay(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ky(e,t,n,r,i){let a=[],o=Ay(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ay(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var jy={name:`tasklistCheck`,tokenize:Ny};function My(){return{text:{91:jy}}}function Ny(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Qd(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Q(r)?t(r):$d(r)?e.check({tokenize:Py},t,n)(r):n(r)}}function Py(e,t,n){return af(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Fy(e){return Bd([Zv(),py(),xy(e),Ty(),My()])}var Iy={};function Ly(e){let t=this,n=e||Iy,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Fy(n)),a.push(Bv()),o.push(Vv(n))}function Ry(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zy(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=Math.max(0,Math.floor((Date.now()-t.getTime())/1e3));if(n<60)return`now`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);if(a<7)return`${a}d`;let o=Math.floor(a/7);return o<5?`${o}w`:`${Math.floor(a/30)}mo`}function By(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Vy(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Hy(e){return e===void 0?``:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Uy(e){return e===void 0?`-`:`${e.totalTokens} tok`}function Wy(e,t){return e.find(e=>e.id===t)?.name??t}function Gy(e,t){if(Ry(t.metadata)&&typeof t.metadata.agentName==`string`)return t.metadata.agentName;let n=Ky(t);return n===void 0?`-`:Wy(e,n)}function Ky(e){if(Ry(e.metadata)){if(typeof e.metadata.agentId==`string`)return e.metadata.agentId;if(Ry(e.metadata.metadata)&&typeof e.metadata.metadata.agentId==`string`)return e.metadata.metadata.agentId}}function qy(e){return e.length===0?`-`:e}function Jy(e){switch(e.status){case`pending`:return`Waiting for your decision`;case`approved`:return`Approved`;case`rejected`:return`Rejected`;case`timed_out`:return`Timed out`;default:return e.status}}function Yy(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xy(e){let t=e.trim();if(t.length===0)return{kind:`text`,value:e};try{return{kind:`json`,value:JSON.parse(t)}}catch{return{kind:`text`,value:e}}}function Zy(e){let t=e.replace(/s+/g,` `).trim();return t.length>72?`${t.slice(0,69)}...`:t}function Qy(e){return e instanceof Error?e.message:String(e)}function $y(e){return(0,U.jsx)(`div`,{className:`prose prose-sm max-w-none text-current [overflow-wrap:anywhere] prose-headings:text-current prose-headings:font-semibold prose-p:text-current prose-p:leading-7 prose-a:text-current prose-a:decoration-muted-foreground prose-a:underline-offset-2 prose-strong:text-current prose-code:rounded-lg prose-code:border prose-code:border-border/80 prose-code:bg-muted/80 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.92em] prose-code:font-semibold prose-code:text-current prose-code:before:content-none prose-code:after:content-none prose-pre:overflow-auto prose-pre:rounded-lg prose-pre:border prose-pre:border-border/80 prose-pre:bg-card/90 prose-pre:text-current prose-blockquote:border-border prose-blockquote:text-muted-foreground prose-li:marker:text-muted-foreground prose-hr:border-border prose-table:m-0 prose-thead:border-0 prose-tr:border-0 prose-th:p-0 prose-td:p-0 dark:prose-invert dark:prose-headings:text-current dark:prose-p:text-current dark:prose-strong:text-current dark:prose-code:text-current dark:prose-pre:bg-card dark:prose-pre:text-current`,children:(0,U.jsx)(Ng,{components:{table({children:e}){return(0,U.jsx)(`div`,{className:`my-4 w-full min-w-0 overflow-hidden rounded-lg border border-border/80 bg-card/90 shadow-sm`,children:(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`table`,{className:`m-0 w-full min-w-full border-separate border-spacing-0 text-left text-sm`,children:e})})})},thead({children:e}){return(0,U.jsx)(`thead`,{className:`bg-muted/45`,children:e})},tbody({children:e}){return(0,U.jsx)(`tbody`,{children:e})},tr({children:e}){return(0,U.jsx)(`tr`,{className:`group/row align-top`,children:e})},th({children:e}){return(0,U.jsx)(`th`,{className:`border-b border-border px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.2em] text-muted-foreground first:pl-5 last:pr-5`,style:{paddingBottom:`0.625rem`,paddingTop:`0.625rem`},children:e})},td({children:e}){return(0,U.jsx)(`td`,{className:`border-b border-border/70 px-4 text-sm leading-6 text-foreground [overflow-wrap:anywhere] first:pl-5 last:pr-5 group-last/row:border-b-0`,style:{paddingBottom:`0.75rem`,paddingTop:`0.75rem`},children:e})}},remarkPlugins:[Ly],children:e.text})})}function eb(e){let t=tb(e.value);return(0,U.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border/80 bg-background/70`,children:[(0,U.jsx)(`div`,{className:`flex min-h-9 items-center gap-3 border-b border-border/80 bg-muted/20 px-3`,children:(0,U.jsx)(`div`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.title})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 min-w-max p-3 font-mono text-[13px] leading-6 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:t})})})})]})}function tb(e){let t=Xy(e),n=t.kind===`json`?t.value:e;try{return JSON.stringify(n,null,2)}catch{return JSON.stringify(String(n),null,2)}}function nb(e){let t=/"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|\btrue\b|\bfalse\b|\bnull\b|[{}[\],:]/g,n=[],r=0,i=t.exec(e.text);for(;i!==null;){i.index>r&&n.push(e.text.slice(r,i.index));let a=i[0],o=e.text.slice(t.lastIndex).match(/\S/)?.[0],s=rb(a,o);n.push((0,U.jsx)(`span`,{className:ib(s),children:a},`${i.index}:${a}`)),r=t.lastIndex,i=t.exec(e.text)}return r<e.text.length&&n.push(e.text.slice(r)),(0,U.jsx)(U.Fragment,{children:n})}function rb(e,t){return e.startsWith(`"`)?t===`:`?`key`:`string`:e===`true`||e===`false`?`boolean`:e===`null`?`null`:/^-?\d/.test(e)?`number`:`punctuation`}function ib(e){switch(e){case`key`:return`text-primary`;case`string`:return`text-foreground dark:text-zinc-100`;case`number`:return`text-chart-2 dark:text-sky-300`;case`boolean`:return`text-chart-5 dark:text-fuchsia-300`;case`null`:return`text-muted-foreground`;case`punctuation`:return`text-muted-foreground`}}function ab(e){if(Array.isArray(e.value))return e.value.length===0?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`Empty array`}):(0,U.jsx)(`div`,{className:`grid gap-1.5`,children:Object.entries(e.value).map(([e,t])=>(0,U.jsx)(ob,{label:e,value:t},e))});if(Ry(e.value)){let t=Object.entries(e.value);return t.length===0?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`Empty object`}):(0,U.jsx)(`div`,{className:`grid gap-1.5`,children:t.map(([e,t])=>(0,U.jsx)(ob,{label:e,value:t},e))})}return(0,U.jsx)(sb,{value:e.value})}function ob(e){let t=Array.isArray(e.value)||Ry(e.value);return(0,U.jsxs)(`div`,{className:tr(`grid min-w-0 grid-cols-[minmax(92px,max-content)_minmax(0,1fr)] items-baseline gap-2.5`,t&&`items-start`),children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground [overflow-wrap:anywhere]`,children:e.label}),(0,U.jsx)(`div`,{className:`min-w-0 text-[13px] leading-5 text-foreground [overflow-wrap:anywhere] [&_.grid]:mt-2 [&_.grid]:border-l [&_.grid]:border-border [&_.grid]:pl-3`,children:t?(0,U.jsx)(ab,{value:e.value}):(0,U.jsx)(sb,{value:e.value})})]})}function sb(e){return e.value===null?(0,U.jsx)(`span`,{className:`italic text-muted-foreground`,children:`null`}):typeof e.value==`string`||typeof e.value==`number`?(0,U.jsx)(`span`,{children:e.value}):(e.value,(0,U.jsx)(`span`,{children:String(e.value)}))}function cb(e){let t=e.evals.find(t=>t.id===e.selectedEvalId)??e.evals[0];return e.enabled?(0,U.jsx)(`section`,{className:`grid min-h-0 overflow-auto bg-background/45`,children:(0,U.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl content-start gap-5 p-6`,children:[(0,U.jsxs)(`header`,{className:`flex min-w-0 items-start justify-between gap-4 border-b border-border/80 pb-5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evals`}),(0,U.jsx)(`h1`,{className:`m-0 mt-2 text-2xl font-semibold tracking-tight text-foreground`,children:t?.name??`Eval suite`}),t?.description===void 0?null:(0,U.jsx)(`p`,{className:`m-0 mt-2 max-w-2xl text-sm leading-6 text-muted-foreground`,children:t.description})]}),(0,U.jsxs)(K,{className:`h-9 shrink-0 rounded-lg px-3 text-sm font-semibold`,disabled:t===void 0||e.runState===`running`,onClick:e.onRun,children:[(0,U.jsx)(Ge,{className:`mr-1.5 h-3.5 w-3.5`}),e.runState===`running`?`Running`:`Run`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[320px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,U.jsxs)(`label`,{className:`grid gap-2`,htmlFor:`eval-suite-select`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Suite`}),(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectEval,children:[(0,U.jsx)(zl,{id:`eval-suite-select`,className:`h-9 w-full rounded-lg border-primary/55 bg-background font-mono text-[11px]`,children:(0,U.jsx)(Y,{placeholder:`Select eval`})}),(0,U.jsx)(Bl,{children:e.evals.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name},e.id))})]})]}),t===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsx)(lb,{label:`Cases`,value:String(t.caseCount)}),(0,U.jsx)(lb,{label:`Metrics`,value:String(t.metricNames.length)}),(0,U.jsx)(lb,{label:`Concurrency`,value:String(t.concurrency??1)})]})]}),(0,U.jsx)(`main`,{className:`min-w-0`,children:e.result===void 0?(0,U.jsx)(`div`,{className:`rounded-lg border border-border/80 bg-card/25 p-5 text-sm font-medium text-muted-foreground`,children:`Run a suite to inspect pass, fail, invalid, and per-case metric results.`}):(0,U.jsx)(ub,{result:e.result})})]})]})}):(0,U.jsx)(`section`,{className:`grid min-h-0 place-items-center p-8 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-lg gap-3`,children:[(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold text-foreground`,children:`Evals unavailable`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:`Register eval suites with Studio to run them from this workspace.`})]})})}function lb(e){return(0,U.jsxs)(`div`,{className:`rounded-lg bg-card/35 px-3 py-3`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-1 font-mono text-base font-semibold tabular-nums text-foreground`,children:e.value})]})}function ub(e){let t=e.result.result;return(0,U.jsxs)(`article`,{className:`grid gap-4 rounded-lg border border-border/80 bg-card/25 p-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,U.jsx)(lb,{label:`Passed`,value:String(t.passed??0)}),(0,U.jsx)(lb,{label:`Failed`,value:String(t.failed??0)}),(0,U.jsx)(lb,{label:`Invalid`,value:String(t.invalid??0)}),(0,U.jsx)(lb,{label:`Duration`,value:`${t.durationMs??e.result.durationMs}ms`})]}),(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Result`}),(0,U.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border/80 bg-background/55 p-3 font-mono text-xs leading-5 text-foreground`,children:(0,U.jsx)(nb,{text:JSON.stringify(e.result.result,null,2)})})]})]})}var db=50;function fb(e){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(),a=e.summary?.agents??[],o=e.summary?.evidence??[],s=(0,v.useMemo)(()=>xb(a),[a]),c=Ob(e.activeTab),l=(0,v.useMemo)(()=>c===void 0?[]:s.filter(e=>e.source.kind===c),[c,s]),u=l.find(e=>e.key===t)??l[0];(0,v.useEffect)(()=>{if(l.length===0){n(``);return}l.some(e=>e.key===t)||n((l.find(e=>e.source.inspectable===!0&&(e.source.itemCount??0)>0)??l.find(e=>e.source.inspectable===!0)??l[0])?.key??``)},[t,l]);let d=(0,v.useCallback)(async(e,t)=>{i(n=>({key:e.key,loading:!0,inspectable:n?.key===e.key?n.inspectable:e.source.inspectable===!0,items:t.append&&n?.key===e.key?n.items:[],...t.append&&n?.key===e.key&&n.nextCursor!==void 0?{nextCursor:n.nextCursor}:{},...n?.key===e.key&&n.totalCount!==void 0?{totalCount:n.totalCount}:{}}));try{let n=new URLSearchParams({agentId:e.agentId,sourceId:wb(e.source),limit:String(db)});t.cursor!==void 0&&n.set(`cursor`,t.cursor);let r=await fetch(`/knowledge/items?${n.toString()}`);if(!r.ok)throw Error(`Knowledge items failed with HTTP ${r.status}`);let a=await r.json();i(n=>({key:e.key,loading:!1,inspectable:a.inspectable,items:t.append&&n?.key===e.key?[...n.items,...a.items]:a.items,...a.nextCursor===void 0?{}:{nextCursor:a.nextCursor},...a.totalCount===void 0?{}:{totalCount:a.totalCount},...a.message===void 0?{}:{message:a.message}}))}catch(t){i(n=>({key:e.key,loading:!1,inspectable:n?.inspectable??!1,items:n?.items??[],error:t instanceof Error?t.message:String(t)}))}},[]);return(0,v.useEffect)(()=>{if(u===void 0){i(void 0);return}d(u,{append:!1})},[d,u]),e.enabled?(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Agent context`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Knowledge`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Browse configured context, dynamic chunks, and retrieval evidence.`})]}),(0,U.jsxs)(K,{className:`h-8 min-h-8 gap-2`,type:`button`,variant:`secondary`,onClick:e.onRefresh,children:[(0,U.jsx)(fe,{"aria-hidden":`true`}),`Refresh`]})]})}),(0,U.jsxs)(`div`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] gap-4 overflow-hidden pb-6 pl-0 pr-6 pt-0`,children:[(0,U.jsx)(pb,{activeTab:e.activeTab,sources:s,evidenceCount:o.length,onSelectTab:e.onSelectTab}),e.activeTab===`retrieval-log`?(0,U.jsx)(_b,{evidence:o,onOpenTrace:e.onOpenTrace}):(0,U.jsx)(mb,{sources:l,selectedKey:u?.key??``,loading:e.loading,activeTab:e.activeTab,onSelect:n,children:(0,U.jsx)(hb,{source:u,state:r,onLoadMore:()=>{u!==void 0&&d(u,r?.nextCursor===void 0?{append:!0}:{append:!0,cursor:r.nextCursor})}})})]})]}):(0,U.jsx)(yb,{title:`Knowledge unavailable`,text:`No registered agent exposes inspectable context.`})}function pb(e){return(0,U.jsx)(`nav`,{className:`flex min-w-0 gap-7 overflow-x-auto border-b border-border/80`,"aria-label":`Knowledge sections`,children:Sb.map(t=>{let n=e.activeTab===t.id;return(0,U.jsxs)(`button`,{className:[`flex min-h-10 shrink-0 items-center gap-2 border-b px-0 pb-2 pt-1 text-left transition duration-200 hover:text-foreground focus-visible:outline-none`,n?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:border-border`].join(` `),type:`button`,"aria-current":n?`page`:void 0,onClick:()=>e.onSelectTab(t.id),children:[(0,U.jsx)(`span`,{className:`text-sm font-semibold`,children:t.label}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Ab(t.id,e.sources,e.evidenceCount)})]},t.id)})})}function mb(e){let t=e.sources.length!==1||e.loading;return(0,U.jsxs)(`div`,{className:[`grid min-h-0 gap-3 overflow-hidden`,t?`grid-rows-[auto_minmax(0,1fr)]`:`grid-rows-[minmax(0,1fr)]`].join(` `),children:[t?(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto rounded-xl border border-border/80 bg-card/55`,children:(0,U.jsxs)(`div`,{className:`flex min-h-11 min-w-max items-center gap-2 px-3`,children:[(0,U.jsx)(`span`,{className:`mr-2 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:kb(e.activeTab)}),e.loading&&e.sources.length===0?(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`Loading sources`}):null,!e.loading&&e.sources.length===0?(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:`No knowledge sources`}):null,e.sources.map(t=>(0,U.jsxs)(`button`,{className:[`flex h-7 items-center gap-2 rounded-lg border border-border/80 bg-background/45 px-2.5 font-mono text-[11px] font-semibold text-muted-foreground transition duration-200 hover:border-primary/45 hover:bg-primary/10 hover:text-foreground focus-visible:border-ring focus-visible:outline-none`,e.selectedKey===t.key?`border-primary/45 bg-primary/10 text-primary`:``].join(` `),type:`button`,onClick:()=>e.onSelect(t.key),children:[(0,U.jsx)(`span`,{children:t.source.label??Db(t.source.kind)}),t.source.itemCount===void 0?null:(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:t.source.itemCount})]},t.key))]})}):null,e.children]})}function hb(e){let t=e.state;return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden rounded-xl border border-border/80 bg-card/55`,children:[(0,U.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate text-sm font-semibold text-foreground`,children:e.source?.source.label??`Knowledge items`}),(0,U.jsx)(`p`,{className:`m-0 mt-1 truncate font-mono text-xs text-muted-foreground`,children:e.source===void 0?`No source selected`:`${e.source.agentId} / ${wb(e.source.source)}`})]}),t?.totalCount===void 0?null:(0,U.jsxs)(Wl,{children:[t.totalCount,` total`]})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto`,children:(0,U.jsxs)(`div`,{className:`p-4`,children:[e.source===void 0?(0,U.jsx)(bb,{text:`No knowledge source selected`}):null,t?.loading===!0&&t.items.length===0?(0,U.jsx)(bb,{text:`Loading items`}):null,t?.error===void 0?null:(0,U.jsx)(bb,{text:t.error}),t?.inspectable===!1?(0,U.jsx)(bb,{text:t.message??`This source does not expose browseable chunks.`}):null,t?.inspectable!==!1&&t?.loading===!1&&t.items.length===0?(0,U.jsx)(bb,{text:`No items in this source`}):null,(0,U.jsx)(`div`,{className:`grid gap-3`,children:t?.items.map(e=>(0,U.jsx)(gb,{item:e},`${e.kind}:${e.id}`))})]})}),(0,U.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 bg-muted/10 px-4 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:t===void 0?`0 loaded`:`${t.items.length} loaded`}),(0,U.jsx)(K,{className:`h-8 min-h-8`,type:`button`,variant:`secondary`,disabled:t?.loading===!0||t?.nextCursor===void 0,onClick:e.onLoadMore,children:`Load more`})]})]})}function gb(e){return(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-background/55 p-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold text-primary`,children:e.item.toolName??e.item.id}),(0,U.jsx)(`div`,{className:`mt-1 font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:jb(e.item.kind)})]}),e.item.parameterKeys===void 0||e.item.parameterKeys.length===0?null:(0,U.jsxs)(Wl,{children:[e.item.parameterKeys.length,` params`]})]}),e.item.description===void 0||e.item.description.length===0?null:(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:e.item.description}),e.item.text===void 0?null:(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-sm leading-6 text-foreground [overflow-wrap:anywhere]`,children:e.item.text}),e.item.document===void 0?null:(0,U.jsx)(vb,{title:`Document`,value:e.item.document}),e.item.metadata===void 0?null:(0,U.jsx)(vb,{title:`Metadata`,value:e.item.metadata}),e.item.parameterKeys===void 0||e.item.parameterKeys.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.item.parameterKeys.map(e=>(0,U.jsx)(Wl,{children:e},e))})]})}function _b(e){return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-xl border border-border/80 bg-card/55`,children:[(0,U.jsx)(`div`,{className:`border-b border-border/80 px-4 py-3`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate text-sm font-semibold text-foreground`,children:`Retrieval log`}),(0,U.jsx)(`p`,{className:`m-0 mt-1 truncate font-mono text-xs text-muted-foreground`,children:`traces / retrieval-evidence`})]}),(0,U.jsxs)(Wl,{children:[e.evidence.length,` entries`]})]})}),(0,U.jsxs)(`div`,{className:`min-h-0 overflow-auto p-4`,children:[e.evidence.length===0?(0,U.jsx)(bb,{text:`No retrieval evidence captured yet`}):null,(0,U.jsx)(`div`,{className:`grid gap-3`,children:e.evidence.map(t=>(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-background/45 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:t.observationName}),(0,U.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[`Turn `,t.turn]})]}),(0,U.jsx)(K,{className:`h-auto min-h-0 rounded-lg border border-border bg-muted px-2 py-1 font-mono text-[10px] text-muted-foreground`,type:`button`,variant:`ghost`,onClick:()=>e.onOpenTrace(t.traceId),children:`Trace`})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(Wl,{children:[t.documentCount,` docs`]}),(0,U.jsxs)(Wl,{children:[t.toolCount,` tools`]})]}),t.query===void 0?null:(0,U.jsxs)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-semibold uppercase tracking-[0.14em] text-foreground`,children:`Query`}),` `,t.query]}),t.documents.slice(0,2).map(e=>(0,U.jsxs)(`p`,{className:`m-0 text-xs leading-5 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`span`,{className:`font-mono text-foreground`,children:e.id??`document`}),` `,e.text??``]},`${e.id??`doc`}:${e.text??``}`)),t.tools.length===0?null:(0,U.jsxs)(`p`,{className:`m-0 text-xs leading-5 text-muted-foreground`,children:[`Tools: `,t.tools.join(`, `)]})]},`${t.traceId}:${t.observationId}`))})]})]})}function vb(e){return(0,U.jsxs)(`div`,{className:`grid gap-2 border-t border-border/70 pt-3`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.title}),(0,U.jsx)(ab,{value:e.value})]})}function yb(e){return(0,U.jsx)(`section`,{className:`grid h-full place-items-center p-8`,children:(0,U.jsxs)(`div`,{className:`grid max-w-sm gap-2 text-center`,children:[(0,U.jsx)(`h1`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm font-medium leading-6 text-muted-foreground`,children:e.text})]})})}function bb(e){return(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-3 text-sm font-medium text-muted-foreground`,children:e.text})}function xb(e){return e.flatMap(e=>e.sources.map((t,n)=>({key:`${e.agentId}:${wb(t,n)}`,agentId:e.agentId,agentName:e.agentName??e.agentId,source:Cb(t,n)})))}var Sb=[{id:`static-context`,label:`Static Context`},{id:`dynamic-context`,label:`Dynamic Context`},{id:`dynamic-tools`,label:`Dynamic Tools`},{id:`retrieval-log`,label:`Retrieval Log`}];function Cb(e,t){return e.sourceId===void 0?{...e,sourceId:Tb(e,t)}:e}function wb(e,t=0){return e.sourceId??Tb(e,t)}function Tb(e,t){switch(e.kind){case`static_context`:return`static-context`;case`dynamic_context`:return`dynamic-context-${e.registrationIndex??t}`;case`dynamic_tools`:return`dynamic-tools-${e.registrationIndex??t}`}}function Eb(e,t){return e.filter(e=>e.kind===t).reduce((e,t)=>e+(t.itemCount??t.count),0)}function Db(e){switch(e){case`static_context`:return`Static context`;case`dynamic_context`:return`Dynamic context`;case`dynamic_tools`:return`Dynamic tools`}}function Ob(e){switch(e){case`static-context`:return`static_context`;case`dynamic-context`:return`dynamic_context`;case`dynamic-tools`:return`dynamic_tools`;case`retrieval-log`:return}}function kb(e){return Sb.find(t=>t.id===e)?.label??`Knowledge`}function Ab(e,t,n){let r=Ob(e);if(r===void 0)return`${n} entries`;let i=t.filter(e=>e.source.kind===r),a=Eb(i.map(e=>e.source),r);return`${i.length} sources / ${a} items`}function jb(e){switch(e){case`static_context`:return`Static context`;case`dynamic_context`:return`Dynamic context`;case`dynamic_tool`:return`Dynamic tool`}}function Mb(e){let t=e.agents.find(t=>t.id===e.selectedAgentId)??e.agents[0],n=e.summary?.servers??[],r=n.reduce((e,t)=>e+t.toolCount,0);return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`MCPs`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`External context`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`MCPs`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`MCP servers and remote tools registered on Studio agents, grouped by server.`})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 max-md:grid max-md:grid-cols-1`,children:[(0,U.jsxs)(Wl,{className:`h-9 justify-center border-border/80 bg-card/70 text-muted-foreground`,children:[n.length,` servers / `,r,` tools`]}),e.agents.length>1?(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectAgent,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 w-64 rounded-lg border-border bg-card/80 font-mono text-xs max-md:w-full`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:e.agents.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):null]})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:(0,U.jsx)(`div`,{className:`grid w-full gap-5`,children:e.enabled?e.loading?(0,U.jsx)(Ib,{title:`Loading MCPs`,message:`Reading registered MCP metadata.`}):n.length===0?(0,U.jsx)(Ib,{title:`No MCPs`,message:`The selected agent has no registered MCP tools.`}):n.map(e=>(0,U.jsx)(Nb,{server:e},e.name)):(0,U.jsx)(Ib,{title:`MCPs unavailable`,message:`No registered Studio agent exposes MCP tools.`})})})]})}function Nb(e){return(0,U.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-border/80 bg-card/55 p-2 shadow-sm`,children:[(0,U.jsxs)(`header`,{className:`grid min-h-14 grid-cols-[minmax(0,1fr)_auto] items-center gap-4 rounded-lg border border-border/60 bg-muted/20 px-4`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.server.name}),(0,U.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium text-muted-foreground`,children:e.server.agentId})]}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-background/50 text-muted-foreground`,children:[e.server.toolCount,` tools`]})]}),(0,U.jsx)(`div`,{className:`mt-1 grid gap-1`,children:e.server.tools.map(e=>(0,U.jsx)(Pb,{tool:e},`${e.source}:${e.name}`))})]})}function Pb(e){return(0,U.jsxs)(`article`,{className:`grid grid-cols-[minmax(300px,0.75fr)_minmax(0,1fr)] gap-2 rounded-lg border border-transparent bg-background/25 p-2 transition duration-200 hover:border-border/70 hover:bg-background/35 max-lg:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-4 rounded-lg bg-card/25 p-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h3`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.tool.name}),(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-muted-foreground`,children:e.tool.source})]}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:e.tool.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:Lb(e.tool.source),children:e.tool.source}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-transparent text-muted-foreground`,children:[zb(e.tool.parameters),` fields`]})]})]}),(0,U.jsx)(Fb,{value:e.tool.parameters})]})}function Fb(e){return(0,U.jsxs)(`section`,{className:`grid min-w-0 content-start overflow-hidden rounded-lg bg-background/45`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-3 bg-muted/20 px-4`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Parameter schema`}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:Rb(e.value)})]}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-80 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:Bb(e.value)})})})})]})}function Ib(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.message})]})})}function Lb(e){return e===`dynamic`?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`}function Rb(e){if(typeof e!=`object`||!e||Array.isArray(e))return`value`;let t=e.type;return typeof t==`string`?t:`object`}function zb(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e.properties;return typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length:0}function Bb(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Vb(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(),[d,f]=(0,v.useState)(),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=(0,v.useCallback)(async()=>{if(!e.enabled){n([]),i([]),u(void 0),f(void 0);return}m(!0),y(``);try{let[e,t]=await Promise.all([fetch(`/memory/users?limit=50`),fetch(`/memory/conversations?limit=100`)]);if(!e.ok)throw Error(`Memory users failed with HTTP ${e.status}`);if(!t.ok)throw Error(`Memory conversations failed with HTTP ${t.status}`);let r=await e.json(),a=await t.json();n(r.users),i(a.conversations),c(e=>e||a.conversations[0]?.id||``)}catch(e){y(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.enabled]);(0,v.useEffect)(()=>{b()},[b]),(0,v.useEffect)(()=>{if(!e.enabled||s.length===0){u(void 0),f(void 0);return}let t=!1;async function n(){g(!0);try{let[e,n]=await Promise.all([fetch(`/memory/conversations/${encodeURIComponent(s)}/messages`),fetch(`/memory/conversations/${encodeURIComponent(s)}/steps`)]);if(!e.ok)throw Error(`Conversation messages failed with HTTP ${e.status}`);if(!n.ok)throw Error(`Conversation steps failed with HTTP ${n.status}`);t||(u(await e.json()),f(await n.json()))}catch(e){t||(y(e instanceof Error?e.message:String(e)),u(void 0),f(void 0))}finally{t||g(!1)}}return n(),()=>{t=!0}},[e.enabled,s]);let x=a.length===0?r:r.filter(e=>e.userId===a),S=r.find(e=>e.id===s)??x[0];return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Memory`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Conversation store`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Memory`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Stored users, conversations, raw messages, and transcript steps from the Studio session store.`})]}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-3 font-mono text-xs`,type:`button`,variant:`secondary`,disabled:p,onClick:()=>void b(),children:`Refresh`})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:e.enabled?p&&r.length===0?(0,U.jsx)(Kb,{title:`Loading memory`,text:`Reading users and conversations.`}):_.length>0&&r.length===0?(0,U.jsx)(Kb,{title:`Memory error`,text:_}):(0,U.jsxs)(`div`,{className:`grid min-h-0 gap-4 xl:grid-cols-[280px_minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,U.jsxs)(`section`,{className:`grid content-start gap-2 rounded-xl border border-border/80 bg-card/45 p-3`,children:[(0,U.jsx)(Wb,{title:`Users`,value:t.length}),(0,U.jsx)(K,{className:`h-auto min-h-9 justify-start rounded-lg px-3 py-2 text-left font-mono text-xs`,type:`button`,variant:a.length===0?`secondary`:`ghost`,onClick:()=>o(``),children:`All users`}),t.map(e=>(0,U.jsxs)(K,{className:`grid h-auto min-h-14 justify-start rounded-lg px-3 py-2 text-left`,type:`button`,variant:a===e.userId?`secondary`:`ghost`,onClick:()=>o(e.userId),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-semibold`,children:e.userId}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:[e.conversationCount,` conversations ·`,` `,zy(e.lastInteractionAt)]})]},e.userId))]}),(0,U.jsxs)(`section`,{className:`grid content-start gap-2 rounded-xl border border-border/80 bg-card/45 p-3`,children:[(0,U.jsx)(Wb,{title:`Conversations`,value:x.length}),x.length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/80 bg-background/45 px-3 py-8 text-center text-sm text-muted-foreground`,children:`No conversations.`}):x.map(t=>(0,U.jsx)(Hb,{conversation:t,agentName:qb(e.agents,t.agentId),active:t.id===s,onSelect:()=>c(t.id)},t.id))]}),(0,U.jsx)(`section`,{className:`grid min-h-0 content-start gap-4`,children:S===void 0?(0,U.jsx)(Kb,{title:`No conversation selected`,text:`Choose a conversation to inspect.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`article`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 min-w-0 truncate text-lg font-semibold text-foreground`,children:S.title??`Untitled conversation`}),(0,U.jsx)(`span`,{className:`min-w-0 break-all font-mono text-xs text-muted-foreground`,children:S.id})]}),(0,U.jsx)(Wl,{className:`border-primary/35 bg-primary/10 text-primary`,children:qb(e.agents,S.agentId)})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,U.jsx)(Gb,{label:`user`,value:S.userId}),(0,U.jsx)(Gb,{label:`messages`,value:S.messageCount}),(0,U.jsx)(Gb,{label:`updated`,value:zy(S.updatedAt)})]})]}),h?(0,U.jsx)(Kb,{title:`Loading detail`,text:`Reading message and transcript data.`}):(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsx)(Ub,{title:`messages`,value:l?.messages??[]}),(0,U.jsx)(Ub,{title:`steps`,value:d?.steps??[]})]})]})})]}):(0,U.jsx)(Kb,{title:`Memory unavailable`,text:`This Studio runtime has no session store.`})})]})}function Hb(e){return(0,U.jsxs)(K,{className:`grid h-auto min-h-20 justify-start gap-2 rounded-lg px-3 py-3 text-left`,type:`button`,variant:e.active?`secondary`:`ghost`,onClick:e.onSelect,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate text-sm font-semibold text-foreground`,children:e.conversation.title??`Untitled conversation`}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,children:[e.agentName,` · `,e.conversation.userId]})]}),(0,U.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[e.conversation.messageCount,` messages ·`,` `,zy(e.conversation.updatedAt)]})]})}function Ub(e){let t=Array.isArray(e.value)?e.value.length:void 0;return(0,U.jsxs)(`section`,{className:`grid min-w-0 overflow-hidden rounded-xl border border-border/80 bg-card/45`,children:[(0,U.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/80 bg-muted/20 px-4`,children:(0,U.jsx)(Wb,{title:e.title,...t===void 0?{}:{value:t}})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-96 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:JSON.stringify(e.value,null,2)})})})})]})}function Wb(e){return(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,U.jsx)(`h2`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.title}),e.value===void 0?null:(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground`,children:e.value})]})}function Gb(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-background/45 px-3 py-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,title:String(e.value),children:e.value})]})}function Kb(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.text})]})})}function qb(e,t){return e.find(e=>e.id===t)?.name??t}function Jb(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Jb(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Yb={value:()=>{}};function Xb(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Zb(n)}function Zb(e){this._=e}function Qb(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Zb.prototype=Xb.prototype={constructor:Zb,on:function(e,t){var n=this._,r=Qb(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=$b(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=ex(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ex(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Zb(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function $b(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ex(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Yb,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var tx={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function nx(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),tx.hasOwnProperty(t)?{space:tx[t],local:e}:e}function rx(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function ix(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ax(e){var t=nx(e);return(t.local?ix:rx)(t)}function ox(){}function sx(e){return e==null?ox:function(){return this.querySelector(e)}}function cx(e){typeof e!=`function`&&(e=sx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new XS(r,this._parents)}function lx(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ux(){return[]}function dx(e){return e==null?ux:function(){return this.querySelectorAll(e)}}function fx(e){return function(){return lx(e.apply(this,arguments))}}function px(e){e=typeof e==`function`?fx(e):dx(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new XS(r,i)}function mx(e){return function(){return this.matches(e)}}function hx(e){return function(t){return t.matches(e)}}var gx=Array.prototype.find;function _x(e){return function(){return gx.call(this.children,e)}}function vx(){return this.firstElementChild}function yx(e){return this.select(e==null?vx:_x(typeof e==`function`?e:hx(e)))}var bx=Array.prototype.filter;function xx(){return Array.from(this.children)}function Sx(e){return function(){return bx.call(this.children,e)}}function Cx(e){return this.selectAll(e==null?xx:Sx(typeof e==`function`?e:hx(e)))}function wx(e){typeof e!=`function`&&(e=mx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new XS(r,this._parents)}function Tx(e){return Array(e.length)}function Ex(){return new XS(this._enter||this._groups.map(Tx),this._parents)}function Dx(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dx.prototype={constructor:Dx,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ox(e){return function(){return e}}function kx(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Dx(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Ax(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Dx(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function jx(e){return e.__data__}function Mx(e,t){if(!arguments.length)return Array.from(this,jx);var n=t?Ax:kx,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Ox(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Nx(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new XS(o,r),o._enter=s,o._exit=c,o}function Nx(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Px(){return new XS(this._exit||this._groups.map(Tx),this._parents)}function Fx(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function Ix(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new XS(s,this._parents)}function Lx(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Rx(e){e||=zx;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new XS(i,this._parents).order()}function zx(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Bx(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Vx(){return Array.from(this)}function Hx(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Ux(){let e=0;for(let t of this)++e;return e}function Wx(){return!this.node()}function Gx(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Kx(e){return function(){this.removeAttribute(e)}}function qx(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jx(e,t){return function(){this.setAttribute(e,t)}}function Yx(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xx(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Zx(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Qx(e,t){var n=nx(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?qx:Kx:typeof t==`function`?n.local?Zx:Xx:n.local?Yx:Jx)(n,t))}function $x(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function eS(e){return function(){this.style.removeProperty(e)}}function tS(e,t,n){return function(){this.style.setProperty(e,t,n)}}function nS(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function rS(e,t,n){return arguments.length>1?this.each((t==null?eS:typeof t==`function`?nS:tS)(e,t,n??``)):iS(this.node(),e)}function iS(e,t){return e.style.getPropertyValue(t)||$x(e).getComputedStyle(e,null).getPropertyValue(t)}function aS(e){return function(){delete this[e]}}function oS(e,t){return function(){this[e]=t}}function sS(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function cS(e,t){return arguments.length>1?this.each((t==null?aS:typeof t==`function`?sS:oS)(e,t)):this.node()[e]}function lS(e){return e.trim().split(/^|\s+/)}function uS(e){return e.classList||new dS(e)}function dS(e){this._node=e,this._names=lS(e.getAttribute(`class`)||``)}dS.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function fS(e,t){for(var n=uS(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function pS(e,t){for(var n=uS(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mS(e){return function(){fS(this,e)}}function hS(e){return function(){pS(this,e)}}function gS(e,t){return function(){(t.apply(this,arguments)?fS:pS)(this,e)}}function _S(e,t){var n=lS(e+``);if(arguments.length<2){for(var r=uS(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?gS:t?mS:hS)(n,t))}function vS(){this.textContent=``}function yS(e){return function(){this.textContent=e}}function bS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function xS(e){return arguments.length?this.each(e==null?vS:(typeof e==`function`?bS:yS)(e)):this.node().textContent}function SS(){this.innerHTML=``}function CS(e){return function(){this.innerHTML=e}}function wS(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function TS(e){return arguments.length?this.each(e==null?SS:(typeof e==`function`?wS:CS)(e)):this.node().innerHTML}function ES(){this.nextSibling&&this.parentNode.appendChild(this)}function DS(){return this.each(ES)}function OS(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function kS(){return this.each(OS)}function AS(e){var t=typeof e==`function`?e:ax(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function jS(){return null}function MS(e,t){var n=typeof e==`function`?e:ax(e),r=t==null?jS:typeof t==`function`?t:sx(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function NS(){var e=this.parentNode;e&&e.removeChild(this)}function PS(){return this.each(NS)}function FS(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function IS(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function LS(e){return this.select(e?IS:FS)}function RS(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function zS(e){return function(t){e.call(this,t,this.__data__)}}function BS(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function VS(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function HS(e,t,n){return function(){var r=this.__on,i,a=zS(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function US(e,t,n){var r=BS(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?HS:VS,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function WS(e,t,n){var r=$x(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function GS(e,t){return function(){return WS(this,e,t)}}function KS(e,t){return function(){return WS(this,e,t.apply(this,arguments))}}function qS(e,t){return this.each((typeof t==`function`?KS:GS)(e,t))}function*JS(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var YS=[null];function XS(e,t){this._groups=e,this._parents=t}function ZS(){return new XS([[document.documentElement]],YS)}function QS(){return this}XS.prototype=ZS.prototype={constructor:XS,select:cx,selectAll:px,selectChild:yx,selectChildren:Cx,filter:wx,data:Mx,enter:Ex,exit:Px,join:Fx,merge:Ix,selection:QS,order:Lx,sort:Rx,call:Bx,nodes:Vx,node:Hx,size:Ux,empty:Wx,each:Gx,attr:Qx,style:rS,property:cS,classed:_S,text:xS,html:TS,raise:DS,lower:kS,append:AS,insert:MS,remove:PS,clone:LS,datum:RS,on:US,dispatch:qS,[Symbol.iterator]:JS};function $S(e){return typeof e==`string`?new XS([[document.querySelector(e)]],[document.documentElement]):new XS([[e]],YS)}function eC(e){let t;for(;t=e.sourceEvent;)e=t;return e}function tC(e,t){if(e=eC(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var nC={passive:!1},rC={capture:!0,passive:!1};function iC(e){e.stopImmediatePropagation()}function aC(e){e.preventDefault(),e.stopImmediatePropagation()}function oC(e){var t=e.document.documentElement,n=$S(e).on(`dragstart.drag`,aC,rC);`onselectstart`in t?n.on(`selectstart.drag`,aC,rC):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function sC(e,t){var n=e.document.documentElement,r=$S(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,aC,rC),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var cC=e=>()=>e;function lC(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}lC.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uC(e){return!e.ctrlKey&&!e.button}function dC(){return this.parentNode}function fC(e,t){return t??{x:e.x,y:e.y}}function pC(){return navigator.maxTouchPoints||`ontouchstart`in this}function mC(){var e=uC,t=dC,n=fC,r=pC,i={},a=Xb(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,nC).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&($S(n.view).on(`mousemove.drag`,m,rC).on(`mouseup.drag`,h,rC),oC(n.view),iC(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(aC(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){$S(e.view).on(`mousemove.drag mouseup.drag`,null),sC(e.view,l),aC(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(iC(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(aC(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(iC(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=tC(l||r,t),p,m,h;if((h=n.call(e,new lC(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=tC(l||a,t),_=o;break}u.call(r,e,new lC(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:cC(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:cC(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:cC(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:cC(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function hC(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gC(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _C(){}var vC=.7,yC=1/vC,bC=`\\s*([+-]?\\d+)\\s*`,xC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,SC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,CC=/^#([0-9a-f]{3,8})$/,wC=RegExp(`^rgb\\(${bC},${bC},${bC}\\)$`),TC=RegExp(`^rgb\\(${SC},${SC},${SC}\\)$`),EC=RegExp(`^rgba\\(${bC},${bC},${bC},${xC}\\)$`),DC=RegExp(`^rgba\\(${SC},${SC},${SC},${xC}\\)$`),OC=RegExp(`^hsl\\(${xC},${SC},${SC}\\)$`),kC=RegExp(`^hsla\\(${xC},${SC},${SC},${xC}\\)$`),AC={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};hC(_C,FC,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jC,formatHex:jC,formatHex8:MC,formatHsl:NC,formatRgb:PC,toString:PC});function jC(){return this.rgb().formatHex()}function MC(){return this.rgb().formatHex8()}function NC(){return JC(this).formatHsl()}function PC(){return this.rgb().formatRgb()}function FC(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=CC.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?IC(t):n===3?new BC(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?LC(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?LC(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=wC.exec(e))?new BC(t[1],t[2],t[3],1):(t=TC.exec(e))?new BC(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=EC.exec(e))?LC(t[1],t[2],t[3],t[4]):(t=DC.exec(e))?LC(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=OC.exec(e))?qC(t[1],t[2]/100,t[3]/100,1):(t=kC.exec(e))?qC(t[1],t[2]/100,t[3]/100,t[4]):AC.hasOwnProperty(e)?IC(AC[e]):e===`transparent`?new BC(NaN,NaN,NaN,0):null}function IC(e){return new BC(e>>16&255,e>>8&255,e&255,1)}function LC(e,t,n,r){return r<=0&&(e=t=n=NaN),new BC(e,t,n,r)}function RC(e){return e instanceof _C||(e=FC(e)),e?(e=e.rgb(),new BC(e.r,e.g,e.b,e.opacity)):new BC}function zC(e,t,n,r){return arguments.length===1?RC(e):new BC(e,t,n,r??1)}function BC(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}hC(BC,zC,gC(_C,{brighter(e){return e=e==null?yC:yC**+e,new BC(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vC:vC**+e,new BC(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new BC(GC(this.r),GC(this.g),GC(this.b),WC(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:VC,formatHex:VC,formatHex8:HC,formatRgb:UC,toString:UC}));function VC(){return`#${KC(this.r)}${KC(this.g)}${KC(this.b)}`}function HC(){return`#${KC(this.r)}${KC(this.g)}${KC(this.b)}${KC((isNaN(this.opacity)?1:this.opacity)*255)}`}function UC(){let e=WC(this.opacity);return`${e===1?`rgb(`:`rgba(`}${GC(this.r)}, ${GC(this.g)}, ${GC(this.b)}${e===1?`)`:`, ${e})`}`}function WC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function GC(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function KC(e){return e=GC(e),(e<16?`0`:``)+e.toString(16)}function qC(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new XC(e,t,n,r)}function JC(e){if(e instanceof XC)return new XC(e.h,e.s,e.l,e.opacity);if(e instanceof _C||(e=FC(e)),!e)return new XC;if(e instanceof XC)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new XC(o,s,c,e.opacity)}function YC(e,t,n,r){return arguments.length===1?JC(e):new XC(e,t,n,r??1)}function XC(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}hC(XC,YC,gC(_C,{brighter(e){return e=e==null?yC:yC**+e,new XC(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vC:vC**+e,new XC(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new BC($C(e>=240?e-240:e+120,i,r),$C(e,i,r),$C(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new XC(ZC(this.h),QC(this.s),QC(this.l),WC(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=WC(this.opacity);return`${e===1?`hsl(`:`hsla(`}${ZC(this.h)}, ${QC(this.s)*100}%, ${QC(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function ZC(e){return e=(e||0)%360,e<0?e+360:e}function QC(e){return Math.max(0,Math.min(1,e||0))}function $C(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var ew=e=>()=>e;function tw(e,t){return function(n){return e+n*t}}function nw(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function rw(e){return(e=+e)==1?iw:function(t,n){return n-t?nw(t,n,e):ew(isNaN(t)?n:t)}}function iw(e,t){var n=t-e;return n?tw(e,n):ew(isNaN(e)?t:e)}var aw=(function e(t){var n=rw(t);function r(e,t){var r=n((e=zC(e)).r,(t=zC(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=iw(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function ow(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function sw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cw(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=_w(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function lw(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function uw(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dw(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=_w(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var fw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pw=new RegExp(fw.source,`g`);function mw(e){return function(){return e}}function hw(e){return function(t){return e(t)+``}}function gw(e,t){var n=fw.lastIndex=pw.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=fw.exec(e))&&(i=pw.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:uw(r,i)})),n=pw.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?hw(c[0].x):mw(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function _w(e,t){var n=typeof t,r;return t==null||n===`boolean`?ew(t):(n===`number`?uw:n===`string`?(r=FC(t))?(t=r,aw):gw:t instanceof FC?aw:t instanceof Date?lw:sw(t)?ow:Array.isArray(t)?cw:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?dw:uw)(e,t)}var vw=180/Math.PI,yw={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bw(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*vw,skewX:Math.atan(c)*vw,scaleX:o,scaleY:s}}var xw;function Sw(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?yw:bw(t.a,t.b,t.c,t.d,t.e,t.f)}function Cw(e){return e==null||(xw||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),xw.setAttribute(`transform`,e),!(e=xw.transform.baseVal.consolidate()))?yw:(e=e.matrix,bw(e.a,e.b,e.c,e.d,e.e,e.f))}function ww(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:uw(e,i)},{i:c-2,x:uw(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:uw(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:uw(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:uw(e,n)},{i:s-2,x:uw(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Tw=ww(Sw,`px, `,`px)`,`deg)`),Ew=ww(Cw,`, `,`)`,`)`),Dw=1e-12;function Ow(e){return((e=Math.exp(e))+1/e)/2}function kw(e){return((e=Math.exp(e))-1/e)/2}function Aw(e){return((e=Math.exp(2*e))-1)/(e+1)}var jw=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Dw)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=Ow(y),c=s/(n*g)*(i*Aw(t*r+y)-kw(y));return[a+c*d,o+c*f,s*i/Ow(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),Mw=0,Nw=0,Pw=0,Fw=1e3,Iw,Lw,Rw=0,zw=0,Bw=0,Vw=typeof performance==`object`&&performance.now?performance:Date,Hw=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uw(){return zw||=(Hw(Ww),Vw.now()+Bw)}function Ww(){zw=0}function Gw(){this._call=this._time=this._next=null}Gw.prototype=Kw.prototype={constructor:Gw,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Uw():+n)+(t==null?0:+t),!this._next&&Lw!==this&&(Lw?Lw._next=this:Iw=this,Lw=this),this._call=e,this._time=n,Zw()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zw())}};function Kw(e,t,n){var r=new Gw;return r.restart(e,t,n),r}function qw(){Uw(),++Mw;for(var e=Iw,t;e;)(t=zw-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mw}function Jw(){zw=(Rw=Vw.now())+Bw,Mw=Nw=0;try{qw()}finally{Mw=0,Xw(),zw=0}}function Yw(){var e=Vw.now(),t=e-Rw;t>Fw&&(Bw-=t,Rw=e)}function Xw(){for(var e,t=Iw,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Iw=n);Lw=e,Zw(r)}function Zw(e){Mw||(Nw&&=clearTimeout(Nw),e-zw>24?(e<1/0&&(Nw=setTimeout(Jw,e-Vw.now()-Bw)),Pw&&=clearInterval(Pw)):(Pw||=(Rw=Vw.now(),setInterval(Yw,Fw)),Mw=1,Hw(Jw)))}function Qw(e,t,n){var r=new Gw;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var $w=Xb(`start`,`end`,`cancel`,`interrupt`),eT=[];function tT(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;aT(e,n,{name:t,index:r,group:i,on:$w,tween:eT,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function nT(e,t){var n=iT(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function rT(e,t){var n=iT(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function iT(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function aT(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Kw(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Qw(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(Qw(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function oT(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function sT(e){return this.each(function(){oT(this,e)})}function cT(e,t){var n,r;return function(){var i=rT(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function lT(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=rT(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function uT(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=iT(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?cT:lT)(n,e,t))}function dT(e,t,n){var r=e._id;return e.each(function(){var e=rT(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return iT(e,r).value[t]}}function fT(e,t){var n;return(typeof t==`number`?uw:t instanceof FC?aw:(n=FC(t))?(t=n,aw):gw)(e,t)}function pT(e){return function(){this.removeAttribute(e)}}function mT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hT(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function gT(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function _T(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function vT(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function yT(e,t){var n=nx(e),r=n===`transform`?Ew:fT;return this.attrTween(e,typeof t==`function`?(n.local?vT:_T)(n,r,dT(this,`attr.`+e,t)):t==null?(n.local?mT:pT)(n):(n.local?gT:hT)(n,r,t))}function bT(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function xT(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ST(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&xT(e,i)),n}return i._value=t,i}function CT(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&bT(e,i)),n}return i._value=t,i}function wT(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=nx(e);return this.tween(n,(r.local?ST:CT)(r,t))}function TT(e,t){return function(){nT(this,e).delay=+t.apply(this,arguments)}}function ET(e,t){return t=+t,function(){nT(this,e).delay=t}}function DT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?TT:ET)(t,e)):iT(this.node(),t).delay}function OT(e,t){return function(){rT(this,e).duration=+t.apply(this,arguments)}}function kT(e,t){return t=+t,function(){rT(this,e).duration=t}}function AT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?OT:kT)(t,e)):iT(this.node(),t).duration}function jT(e,t){if(typeof t!=`function`)throw Error();return function(){rT(this,e).ease=t}}function MT(e){var t=this._id;return arguments.length?this.each(jT(t,e)):iT(this.node(),t).ease}function NT(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();rT(this,e).ease=n}}function PT(e){if(typeof e!=`function`)throw Error();return this.each(NT(this._id,e))}function FT(e){typeof e!=`function`&&(e=mx(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new uE(r,this._parents,this._name,this._id)}function IT(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new uE(o,this._parents,this._name,this._id)}function LT(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function RT(e,t,n){var r,i,a=LT(t)?nT:rT;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function zT(e,t){var n=this._id;return arguments.length<2?iT(this.node(),n).on.on(e):this.each(RT(n,e,t))}function BT(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function VT(){return this.on(`end.remove`,BT(this._id))}function HT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=sx(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,tT(l[f],t,n,f,l,iT(u,n)));return new uE(a,this._parents,t,n)}function UT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=dx(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=iT(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&tT(p,t,n,h,f,m);a.push(f),o.push(u)}return new uE(a,o,t,n)}var WT=ZS.prototype.constructor;function GT(){return new WT(this._groups,this._parents)}function KT(e,t){var n,r,i;return function(){var a=iS(this,e),o=(this.style.removeProperty(e),iS(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function qT(e){return function(){this.style.removeProperty(e)}}function JT(e,t,n){var r,i=n+``,a;return function(){var o=iS(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function YT(e,t,n){var r,i,a;return function(){var o=iS(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),iS(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function XT(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=rT(this,e),l=c.on,u=c.value[a]==null?s||=qT(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ZT(e,t,n){var r=(e+=``)==`transform`?Tw:fT;return t==null?this.styleTween(e,KT(e,r)).on(`end.style.`+e,qT(e)):typeof t==`function`?this.styleTween(e,YT(e,r,dT(this,`style.`+e,t))).each(XT(this._id,e)):this.styleTween(e,JT(e,r,t),n).on(`end.style.`+e,null)}function QT(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $T(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&QT(e,a,n)),r}return a._value=t,a}function eE(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,$T(e,t,n??``))}function tE(e){return function(){this.textContent=e}}function nE(e){return function(){var t=e(this);this.textContent=t??``}}function rE(e){return this.tween(`text`,typeof e==`function`?nE(dT(this,`text`,e)):tE(e==null?``:e+``))}function iE(e){return function(t){this.textContent=e.call(this,t)}}function aE(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&iE(r)),t}return r._value=e,r}function oE(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,aE(e))}function sE(){for(var e=this._name,t=this._id,n=fE(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=iT(c,t);tT(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new uE(r,this._parents,e,n)}function cE(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=rT(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var lE=0;function uE(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function dE(e){return ZS().transition(e)}function fE(){return++lE}var pE=ZS.prototype;uE.prototype=dE.prototype={constructor:uE,select:HT,selectAll:UT,selectChild:pE.selectChild,selectChildren:pE.selectChildren,filter:FT,merge:IT,selection:GT,transition:sE,call:pE.call,nodes:pE.nodes,node:pE.node,size:pE.size,empty:pE.empty,each:pE.each,on:zT,attr:yT,attrTween:wT,style:ZT,styleTween:eE,text:rE,textTween:oE,remove:VT,tween:uT,delay:DT,duration:AT,ease:MT,easeVarying:PT,end:cE,[Symbol.iterator]:pE[Symbol.iterator]};function mE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var hE={time:null,delay:0,duration:250,ease:mE};function gE(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function _E(e){var t,n;e instanceof uE?(t=e._id,e=e._name):(t=fE(),(n=hE).time=Uw(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&tT(c,e,t,l,o,n||gE(c,t));return new uE(r,this._parents,e,t)}ZS.prototype.interrupt=sT,ZS.prototype.transition=_E;var vE=e=>()=>e;function yE(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function bE(e,t,n){this.k=e,this.x=t,this.y=n}bE.prototype={constructor:bE,scale:function(e){return e===1?this:new bE(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new bE(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var xE=new bE(1,0,0);SE.prototype=bE.prototype;function SE(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xE;return e.__zoom}function CE(e){e.stopImmediatePropagation()}function wE(e){e.preventDefault(),e.stopImmediatePropagation()}function TE(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function EE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function DE(){return this.__zoom||xE}function OE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function kE(){return navigator.maxTouchPoints||`ontouchstart`in this}function AE(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function jE(){var e=TE,t=EE,n=AE,r=OE,i=kE,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=jw,l=Xb(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,DE).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,DE),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(xE.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new bE(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new bE(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new bE(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=$S(this.that).datum();l.call(e,this.that,new yE(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=tC(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],oT(this),s.start();wE(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=$S(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=tC(t,i),l=t.clientX,u=t.clientY;oC(t.view),CE(t),a.mouse=[c,this.__zoom.invert(c)],oT(this),a.start();function d(e){if(wE(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=tC(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),sC(e.view,a.moved),wE(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=tC(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);wE(r),s>0?$S(this).transition().duration(s).call(x,d,c,r):$S(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(CE(t),s=0;s<i;++s)c=r[s],l=tC(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),oT(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(wE(e),s=0;s<a;++s)c=i[s],l=tC(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(CE(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=tC(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=$S(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:vE(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:vE(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:vE(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:vE([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var ME={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},NE=[[-1/0,-1/0],[1/0,1/0]],PE=[`Enter`,` `,`Escape`],FE={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},IE;(function(e){e.Strict=`strict`,e.Loose=`loose`})(IE||={});var LE;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(LE||={});var RE;(function(e){e.Partial=`partial`,e.Full=`full`})(RE||={});var zE={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},BE;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(BE||={});var VE;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(VE||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var HE={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function UE(e){return e===null?null:e?`valid`:`invalid`}var WE=e=>`id`in e&&`source`in e&&`target`in e,GE=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),KE=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),qE=(e,t=[0,0])=>{let{width:n,height:r}=ED(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},JE=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:lD(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):KE(n)?n:t.nodeLookup.get(n.id)),sD(e,i?dD(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),YE=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=sD(n,dD(e)),r=!0)}),r?lD(n):{x:0,y:0,width:0,height:0}},XE=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...vD(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=pD(s,uD(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},ZE=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function QE(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function $E({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=CD(YE(QE(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function eD({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,ME.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&TD(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=TD(d)?rD(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,ME.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function tD({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ZE(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var nD=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rD=(e={x:0,y:0},t,n)=>({x:nD(e.x,t[0][0],t[1][0]-(n?.width??0)),y:nD(e.y,t[0][1],t[1][1]-(n?.height??0))});function iD(e,t,n){let{width:r,height:i}=ED(n),{x:a,y:o}=n.internals.positionAbsolute;return rD(e,[[a,o],[a+r,o+i]],t)}var aD=(e,t,n)=>e<t?nD(Math.abs(e-t),1,t)/t:e>n?-nD(Math.abs(e-n),1,t)/t:0,oD=(e,t,n=15,r=40)=>[aD(e.x,r,t.width-r)*n,aD(e.y,r,t.height-r)*n],sD=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),cD=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),lD=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),uD=(e,t=[0,0])=>{let{x:n,y:r}=KE(e)?e.internals.positionAbsolute:qE(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},dD=(e,t=[0,0])=>{let{x:n,y:r}=KE(e)?e.internals.positionAbsolute:qE(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},fD=(e,t)=>lD(sD(cD(e),cD(t))),pD=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},mD=e=>hD(e.width)&&hD(e.height)&&hD(e.x)&&hD(e.y),hD=e=>!isNaN(e)&&isFinite(e),gD=(e,t)=>{},_D=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),vD=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?_D(s,o):s},yD=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function bD(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function xD(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=bD(e,n),i=bD(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=bD(e.top??e.y??0,n),i=bD(e.bottom??e.y??0,n),a=bD(e.left??e.x??0,t),o=bD(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function SD(e,t,n,r,i,a){let{x:o,y:s}=yD(e,[t,n,r]),{x:c,y:l}=yD({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var CD=(e,t,n,r,i,a)=>{let o=xD(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=nD(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=SD(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},wD=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function TD(e){return e!=null&&e!==`parent`}function ED(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function DD(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function OD(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function kD(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function AD(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function jD(e){return{...FE,...e||{}}}function MD(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=RD(e),s=vD({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?_D(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ND=e=>({width:e.offsetWidth,height:e.offsetHeight}),PD=e=>e?.getRootNode?.()||window?.document,FD=[`INPUT`,`SELECT`,`TEXTAREA`];function ID(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?FD.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var LD=e=>`clientX`in e,RD=(e,t)=>{let n=LD(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},zD=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ND(t)}})};function BD({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function VD(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function HD({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-VD(t-r,a),n];case $.Right:return[t+VD(r-t,a),n];case $.Top:return[t,n-VD(n-i,a)];case $.Bottom:return[t,n+VD(i-n,a)]}}function UD({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=HD({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=HD({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=BD({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function WD({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function GD({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function KD({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=sD(dD(e),dD(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),pD({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},lD(a))>0}var qD=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,JD=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),YD=(e,t,n={})=>{if(!e.source||!e.target)return ME.error006(),t;let r=n.getEdgeId||qD,i;return i=WE(e)?{...e}:{...e,id:r(e)},JD(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function XD({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=WD({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var ZD={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},QD=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},$D=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function eO({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=ZD[t],c=ZD[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=QD({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=WD({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function tO(e,t,n,r){let i=Math.min($D(e,t)/2,$D(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function nO({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=eO({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=tO(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function rO(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function iO(e){let{sourceNode:t,targetNode:n}=e;if(!rO(t)||!rO(n))return null;let r=t.internals.handleBounds||aO(t.handles),i=n.internals.handleBounds||aO(n.handles),a=sO(r?.source??[],e.sourceHandle),o=sO(e.connectionMode===IE.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,ME.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=oO(t,a,s),u=oO(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function aO(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function oO(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??ED(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function sO(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function cO(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function lO(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=cO(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var uO=1e3,dO=10,fO={nodeOrigin:[0,0],nodeExtent:NE,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},pO={...fO,checkEquality:!0};function mO(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function hO(e,t,n){let r=mO(fO,n);for(let n of e.values())if(n.parentId)bO(n,e,t,r);else{let e=rD(qE(n,r.nodeOrigin),TD(n.extent)?n.extent:r.nodeExtent,ED(n));n.internals.positionAbsolute=e}}function gO(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function _O(e){return e===`manual`}function vO(e,t,n,r={}){let i=mO(pO,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!_O(i.zIndexMode)?uO:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=rD(qE(u,i.nodeOrigin),TD(u.extent)?u.extent:i.nodeExtent,ED(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:gO(u,e),z:xO(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&bO(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function yO(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function bO(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=mO(fO,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}yO(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*dO),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=SO(e,u,o,s,a&&!_O(c)?uO:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function xO(e,t,n){let r=hD(e.zIndex)?e.zIndex:0;return _O(n)?r:r+(e.selected?t:0)}function SO(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ED(e),l=qE(e,n),u=TD(e.extent)?rD(l,e.extent,c):l,d=rD({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=iD(d,c,t));let f=xO(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function CO(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=fD(a.get(n.parentId)?.expandedRect??uD(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=ED(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function wO(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=ND(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=TD(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=iD(h,s,t.get(e.parentId)):m&&(h=rD(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:zD(`source`,r.nodeElement,p,d,e.id),target:zD(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&bO(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:uD(g,i)}))}}if(f.length>0){let e=CO(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function TO({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function EO(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function DO(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;EO(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),EO(`target`,s,c,e,i,o),t.set(r.id,r)}}function OO(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:OO(n,t):!1}function kO(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function AO(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!OO(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function jO({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function MO({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=_D(a,t);return{x:o.x-a.x,y:o.y-a.y}}function NO({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=$S(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?cD(YE(s)):null,x=v&&l?MO({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:_D(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=eD({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=jO({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=oD(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=MD(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=AO(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=jO({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=mC().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=MD(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=RD(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=MD(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=RD(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=RD(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=jO({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!kO(t,`.${g}`,v))&&(!_||kO(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function PO(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())pD(i,uD(e))>0&&r.push(e);return r}var FO=250;function IO(e,t,n,r){let i=[],a=1/0,o=PO(e,n,t+FO);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=oO(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function LO(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...oO(o,c,c.position,!0)}:c}function RO(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function zO(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var BO=()=>!0;function VO(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=BO,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=PD(e.target),E=0,D,{x:O,y:k}=RD(e),A=RO(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=LO(i,A,r,c,t);if(!N)return;let P=RD(e,j),ee=!1,F=null,I=!1,te=null;function ne(){if(!u||!j)return;let[e,t]=oD(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ne)}let L={...N,nodeId:i,type:A,position:N.position},R=c.get(i),z={inProgress:!0,isValid:null,from:oO(R,L,$.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:R,to:P,toHandle:null,toPosition:HE[L.position],toNode:null,pointer:P};function B(){M=!0,y(z),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&B();function re(e){if(!M){let{x:t,y:n}=RD(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;B()}if(!x()||!L){ie(e);return}let a=b();P=RD(e,j),D=IO(vD(P,a,!1,[1,1]),n,c,L),ee||=(ne(),!0);let s=HO(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});te=s.handleDomNode,F=s.connection,I=zO(!!D,s.isValid);let u=c.get(i),f=u?oO(u,L,$.Left,!0):z.from,p={...z,from:f,isValid:I,to:s.toHandle&&I?yD({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:I&&s.toHandle?s.toHandle.position:HE[L.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),z=p}function ie(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||te)&&F&&I&&h?.(F);let{inProgress:t,...n}=z,r={...n,toPosition:z.toHandle?z.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ee=!1,I=!1,F=null,te=null,T.removeEventListener(`mousemove`,re),T.removeEventListener(`mouseup`,ie),T.removeEventListener(`touchmove`,re),T.removeEventListener(`touchend`,ie)}}T.addEventListener(`mousemove`,re),T.addEventListener(`mouseup`,ie),T.addEventListener(`touchmove`,re),T.addEventListener(`touchend`,ie)}function HO(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=BO,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=RD(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=RO(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===IE.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=LO(t,e,a,u,n,!0)}return _}var UO={onPointerDown:VO,isValid:HO};function WO({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=$S(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&wD()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=jE().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:tC}}var GO=e=>({x:e.x,y:e.y,zoom:e.k}),KO=({x:e,y:t,zoom:n})=>xE.translate(e,t).scale(n),qO=(e,t)=>e.target.closest(`.${t}`),JO=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),YO=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,XO=(e,t=0,n=YO,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ZO=e=>{let t=e.ctrlKey&&wD()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QO({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(qO(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=tC(u),t=d*2**ZO(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===LE.Vertical?0:u.deltaX*f,m=i===LE.Horizontal?0:u.deltaY*f;!wD()&&u.shiftKey&&i!==LE.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=GO(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function $O({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=qO(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function ek({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=GO(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function tk({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&JO(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,GO(a.transform))}}function nk({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&JO(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=GO(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function rk({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(qO(d,`${l}-flow__node`)||qO(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||qO(d,s)&&m||qO(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function ik({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=jE().scaleExtent([t,n]).translateExtent(r),f=$S(e).call(d);v({x:i.x,y:i.y,zoom:nD(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(ZO);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).transform(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!hD(E)||E<0?0:E);let k=O?QO({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):$O({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=ek({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=tk({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=nk({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=rk({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=KO(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=KO(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=KO(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?SE(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).scaleTo(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?_w:jw).scaleBy(XO(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!hD(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var ak;(function(e){e.Line=`line`,e.Handle=`handle`})(ak||={});function ok({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function sk(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function ck(e,t){return Math.max(0,t-e)}function lk(e,t){return Math.max(0,e-t)}function uk(e,t,n){return Math.max(0,t-e,e-n)}function dk(e,t){return e?!t:t}function fk(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=uk(E,h,g),j=uk(D,_,v);if(o){let e=0,t=0;c&&w<0?e=ck(y+w+O,o[0][0]):!c&&w>0&&(e=lk(y+E+O,o[1][0])),l&&T<0?t=ck(b+T+k,o[0][1]):!l&&T>0&&(t=lk(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=lk(y+w,s[0][0]):!c&&w<0&&(e=ck(y+E,s[1][0])),l&&T>0?t=lk(b+T,s[0][1]):!l&&T<0&&(t=ck(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=uk(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?lk(b+k+E/C,o[1][1])*C:ck(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?ck(b+E/C,s[1][1])*C:lk(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=uk(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?lk(y+D*C+O,o[1][0])/C:ck(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?ck(y+D*C,s[1][0])/C:lk(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(dk(c,l)?-w:w)/C:w=(dk(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var pk={width:0,height:0,x:0,y:0},mk={...pk,pointerX:0,pointerY:0,aspectRatio:1};function hk(e){return[[0,0],[e.measured.width,e.measured.height]]}function gk(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function _k({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=$S(e),o={controlDirection:sk(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...pk},h={...mk};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:sk(e)};let g,_=null,v=[],y,b,x,S=!1,C=mC().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=MD(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?hk(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=gk(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=MD(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=fk(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let ee=ok({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),F={...m,direction:ee};p?.(e,F)!==!1&&(S=!0,d?.(e,F),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var vk=o((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),yk=o(((e,t)=>{t.exports=vk()})),bk=o((e=>{var t=p(),n=yk();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),xk=l(o(((e,t)=>{t.exports=bk()}))(),1),Sk=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Ck=e=>e?Sk(e):Sk,{useDebugValue:wk}=v.default,{useSyncExternalStoreWithSelector:Tk}=xk.default,Ek=e=>e;function Dk(e,t=Ek,n){let r=Tk(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wk(r),r}var Ok=(e,t)=>{let n=Ck(e),r=(e,r=t)=>Dk(n,e,r);return Object.assign(r,n),r},kk=(e,t)=>e?Ok(e,t):Ok;function Ak(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var jk=(0,v.createContext)(null),Mk=jk.Provider,Nk=ME.error001();function Pk(e,t){let n=(0,v.useContext)(jk);if(n===null)throw Error(Nk);return Dk(n,e,t)}function Fk(){let e=(0,v.useContext)(jk);if(e===null)throw Error(Nk);return(0,v.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Ik={display:`none`},Lk={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Rk=`react-flow__node-desc`,zk=`react-flow__edge-desc`,Bk=`react-flow__aria-live`,Vk=e=>e.ariaLiveMessage,Hk=e=>e.ariaLabelConfig;function Uk({rfId:e}){let t=Pk(Vk);return(0,U.jsx)(`div`,{id:`${Bk}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Lk,children:t})}function Wk({rfId:e,disableKeyboardA11y:t}){let n=Pk(Hk);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${Rk}-${e}`,style:Ik,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${zk}-${e}`,style:Ik,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(Uk,{rfId:e})]})}var Gk=(0,v.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,U.jsx)(`div`,{className:Jb([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));Gk.displayName=`Panel`;function Kk({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,U.jsx)(Gk,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,U.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var qk=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Jk=e=>e.id;function Yk(e,t){return Ak(e.selectedNodes.map(Jk),t.selectedNodes.map(Jk))&&Ak(e.selectedEdges.map(Jk),t.selectedEdges.map(Jk))}function Xk({onSelectionChange:e}){let t=Fk(),{selectedNodes:n,selectedEdges:r}=Pk(qk,Yk);return(0,v.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Zk=e=>!!e.onSelectionChangeHandlers;function Qk({onSelectionChange:e}){let t=Pk(Zk);return e||t?(0,U.jsx)(Xk,{onSelectionChange:e}):null}var $k=typeof window<`u`?v.useLayoutEffect:v.useEffect,eA=[0,0],tA={x:0,y:0,zoom:1},nA=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],rA=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),iA={translateExtent:NE,nodeOrigin:eA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function aA(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Pk(rA,Ak),l=Fk();$k(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=iA,s()}),[]);let u=(0,v.useRef)(iA);return $k(()=>{for(let s of nA){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:jD(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},nA.map(t=>e[t])),null}function oA(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function sA(e){let[t,n]=(0,v.useState)(e===`system`?null:e);return(0,v.useEffect)(()=>{if(e!==`system`){n(e);return}let t=oA(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?oA()?.matches?`dark`:`light`:t}var cA=typeof document<`u`?document:null;function lA(e=null,t={target:cA,actInsideInputWithModifier:!0}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(!1),a=(0,v.useRef)(new Set([])),[o,s]=(0,v.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
78
78
  `).replace(`
79
79
 
80
80
  `,`
@@ -85,16 +85,16 @@ Error generating stack: `+e.message+`
85
85
 
86
86
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
87
87
 
88
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},VP=`DialogDescriptionWarning`,HP=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zP(VP).contentName}}.`;return v.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},UP=mP,WP=bP,GP=SP,KP=EP,qP=jP,JP=NP,YP=UP;function XP({className:e,children:t,...n}){return(0,U.jsxs)(WP,{children:[(0,U.jsx)(GP,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`}),(0,U.jsx)(KP,{className:tr(`fixed left-1/2 top-1/2 z-50 grid w-[min(420px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border border-border bg-popover p-5 text-popover-foreground shadow-2xl shadow-black/40`,e),...n,children:t})]})}function ZP({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`grid gap-1.5`,e),...t})}function QP({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`flex justify-end gap-2`,e),...t})}function $P({className:e,...t}){return(0,U.jsx)(qP,{className:tr(`text-base font-bold`,e),...t})}function eF({className:e,...t}){return(0,U.jsx)(JP,{className:tr(`text-sm leading-6 text-muted-foreground`,e),...t})}function tF(e){return e.sessionsEnabled?(0,U.jsx)(`section`,{className:`grid min-h-0 w-full overflow-auto pb-6 pl-0 pr-6`,"aria-label":`Sessions`,children:(0,U.jsxs)(`div`,{className:`min-w-225 overflow-hidden rounded-xl border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 grid min-h-11 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px_72px] items-center gap-4 rounded-lg border border-border/60 bg-card/95 px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Session`}),(0,U.jsx)(`span`,{children:`Agent`}),(0,U.jsx)(`span`,{children:`Messages`}),(0,U.jsx)(`span`,{children:`Updated`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),e.sessionLoadState===`loading`&&e.sessions.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`Loading sessions`}):null,e.sessionLoadState===`idle`&&e.sessions.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`No sessions`}):null,e.sessions.map(t=>(0,U.jsxs)(`div`,{className:tr(`mt-1 grid min-h-14 w-full min-w-0 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px_72px] items-center gap-4 rounded-lg border border-transparent px-4 text-left text-muted-foreground transition duration-200 hover:border-primary/20 hover:bg-accent/80 hover:text-accent-foreground`,t.id===e.selectedSessionId&&`border-primary/35 bg-primary/10 text-primary`),children:[(0,U.jsxs)(K,{className:`col-span-4 grid h-full min-h-14 min-w-0 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px] items-center justify-start gap-4 border-0 bg-transparent p-0 text-left text-inherit shadow-none hover:bg-transparent hover:text-inherit`,type:`button`,variant:`ghost`,onClick:()=>e.onOpenSession(t.id),children:[(0,U.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:t.title??`Untitled chat`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium text-muted-foreground`,children:t.id})]}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Wy(e.agents,t.agentId)}),(0,U.jsxs)(`span`,{className:`text-xs font-medium tabular-nums text-muted-foreground`,children:[t.messageCount,` messages`]}),(0,U.jsx)(`time`,{className:`text-xs font-medium text-muted-foreground`,children:zy(t.updatedAt)})]}),(0,U.jsxs)(`span`,{className:`flex items-center justify-end gap-1`,children:[(0,U.jsx)(K,{"aria-label":`View tracing for ${t.title??`Untitled chat`}`,className:`h-7 min-h-7 w-7 border-0 bg-transparent p-0 text-muted-foreground opacity-80 hover:bg-transparent hover:text-primary hover:opacity-100 [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,onClick:n=>{n.stopPropagation(),e.onViewSessionTracing(t.id)},children:(0,U.jsx)(Xe,{"aria-hidden":`true`})}),(0,U.jsx)(K,{"aria-label":`Delete ${t.title??`Untitled chat`}`,className:`h-7 min-h-7 w-7 border-0 bg-transparent p-0 text-muted-foreground opacity-80 hover:bg-transparent hover:text-destructive hover:opacity-100 [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,onClick:n=>{n.stopPropagation(),e.onDeleteSession(t)},children:(0,U.jsx)(it,{"aria-hidden":`true`})})]})]},t.id))]})}):(0,U.jsx)(`div`,{className:`w-full rounded-lg border border-dashed border-border p-8 text-sm font-medium text-muted-foreground`,children:`Sessions are disabled`})}function nF(e){let t=e.session?.title??`Untitled chat`;return(0,U.jsx)(YP,{open:e.session!==void 0,onOpenChange:e.onOpenChange,children:(0,U.jsxs)(XP,{children:[(0,U.jsxs)(ZP,{children:[(0,U.jsx)($P,{children:`Delete session`}),(0,U.jsxs)(eF,{children:[`Delete "`,t,`" and its traces. This cannot be undone.`]})]}),(0,U.jsxs)(QP,{children:[(0,U.jsx)(K,{type:`button`,variant:`ghost`,onClick:()=>e.onOpenChange(!1),children:`Cancel`}),(0,U.jsx)(K,{type:`button`,variant:`destructive`,onClick:()=>{e.session!==void 0&&e.onConfirm(e.session)},children:`Delete`})]})]})})}var rF=document.getElementById(`anvia-ui`),iF=rF?.dataset.uiPath??`/ui`,aF=rF?.dataset.uiCompatPath??`/ui`,oF=`${hF(iF)||hF(aF)||`/ui`}/assets/logo.png`,sF=`static-context`;function cF(){let e=hF(iF),t=hF(aF),n=window.location.pathname.replace(/\/+$/,``);return t.length>0&&(n===t||n.startsWith(`${t}/`))?lF(n===t?[]:n.slice(t.length+1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e))):e.length===0&&n.length>0?lF(n.slice(1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e))):n===e||!n.startsWith(`${e}/`)?{page:`playground`}:lF(n.slice(e.length+1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e)))}function lF(e){let[t,n,r]=e;return t===`tracing`?n===`sessions`?{page:`tracing`,...r===void 0?{}:{traceSessionId:r}}:{page:`tracing`,...n===void 0?{}:{traceId:n}}:t===`sessions`?{page:`sessions`}:t===`agents`?{page:`agents`}:t===`tools`?{page:`tools`}:t===`mcps`?{page:`mcps`}:t===`pipelines`?{page:`pipelines`}:t===`evals`?{page:`evals`}:t===`memory`?{page:`memory`}:t===`status`?{page:`status`}:t===`knowledge`?{page:`knowledge`,knowledgeTab:_F(n)}:t===`playground`?{page:`playground`,...n===void 0?{}:{sessionId:n}}:t!==void 0&&n===void 0?{page:`playground`,sessionId:t}:{page:`playground`}}function uF(e){if(e===`knowledge`){dF(sF);return}let t=hF(iF),n=hF(aF)||`/ui`;if(t.length===0&&(e===`sessions`||e===`agents`||e===`tools`||e===`mcps`||e===`pipelines`||e===`evals`||e===`memory`||e===`status`)){gF(`${n}/${e}`);return}gF(e===`playground`?`${t}/playground`:`${t}/${e}`)}function dF(e){let t=hF(iF),n=hF(aF)||`/ui`;gF(`${t.length===0?n:t}/knowledge/${e}`)}function fF(e){let t=hF(iF);gF(e===void 0?`${t}/playground`:`${t}/playground/${encodeURIComponent(e)}`)}function pF(e){gF(`${hF(iF)}/tracing/${encodeURIComponent(e)}`)}function mF(e){gF(`${hF(iF)}/tracing/sessions/${encodeURIComponent(e)}`)}function hF(e){return e===`/`?``:e.replace(/\/+$/,``)}function gF(e){let t=`${e}${window.location.search}${window.location.hash}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==t&&window.history.pushState({},``,t)}function _F(e){switch(e){case`dynamic-context`:case`retrieval-log`:case`static-context`:return e;default:return sF}}var vF=0;function yF(e){vF=e}function bF(){vF=0}function xF(e){return e.filter(e=>e.kind===`message`&&e.text.trim().length>0).map(e=>({role:e.role,content:[{type:`text`,text:e.text}]}))}function SF(e){return e.currentTarget.value}function CF(e){e!==null&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}function wF(){let e=vF;return vF+=1,e}function TF(e){return e.reduce((e,t)=>Math.max(e,t.entryId+1),0)}function EF(e,t,n){for(let r=e.length-1;r>=0;--r){let i=e[r];if(i!==void 0&&!(i.kind!==`tool`||i.toolName!==t||i.result!==void 0)&&(n===void 0||i.callId===n))return r}return-1}function DF(e,t,n){for(let r=e.length-1;r>=0;--r){let i=e[r];if(i!==void 0&&!(i.kind!==`tool`||i.toolName!==t)&&(n===void 0||i.callId===n))return r}return-1}function OF(e){return typeof e==`string`?e:Ry(e)?typeof e.text==`string`?e.text:typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(kF).filter(Boolean).join(`
89
- `):``:``}function kF(e){return typeof e==`string`?e:Ry(e)?typeof e.text==`string`?e.text:e.type===`tool_call`&&Ry(e.function)?`${String(e.function.name??`tool`)}(${Yy(e.function.arguments)})`:e.type===`tool_result`&&Array.isArray(e.content)?e.content.map(kF).filter(Boolean).join(`
90
- `):typeof e.type==`string`?e.type:``:``}async function AF(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let e=await n.read();if(e.done)break;i+=r.decode(e.value,{stream:!0});let a=i.split(`
91
- `);i=a.pop()??``;for(let e of a)e.trim().length>0&&await t(JSON.parse(e))}i+=r.decode(),i.trim().length>0&&await t(JSON.parse(i))}function jF(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})})}function MF(e){let t=NF(e.icon);return(0,U.jsxs)(K,{className:tr(`h-8 min-h-8 w-full justify-start gap-3 rounded-lg bg-transparent px-2.5 text-sm font-medium text-sidebar-foreground/62 shadow-none transition duration-200 hover:bg-sidebar-accent/80 hover:text-sidebar-foreground active:translate-y-px [&_svg]:h-3.5 [&_svg]:w-3.5`,e.active&&`bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`),variant:`ghost`,type:`button`,disabled:e.disabled,onClick:e.onClick,children:[(0,U.jsx)(t,{}),(0,U.jsx)(`span`,{children:e.label})]})}function NF(e){switch(e){case`activity`:return Xe;case`bot`:return Qe;case`database`:return ke;case`gauge`:return Ne;case`list`:return ze;case`message`:return Ce;case`plug`:return qe;case`shield`:return et;case`wrench`:return ot;case`workflow`:return je}}function PF(e){let[t,n]=(0,v.useState)(),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=(0,v.useCallback)(async()=>{if(!e.enabled){n(void 0);return}i(!0),o(``);try{let e=await fetch(`/status`);if(!e.ok)throw Error(`Status failed with HTTP ${e.status}`);n(await e.json())}catch(e){o(e instanceof Error?e.message:String(e)),n(void 0)}finally{i(!1)}},[e.enabled]);return(0,v.useEffect)(()=>{s()},[s]),(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Status`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Operations`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Status`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Runtime health, storage adapters, feature capabilities, and current record counts.`})]}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-3 font-mono text-xs`,type:`button`,variant:`secondary`,disabled:r,onClick:()=>void s(),children:`Refresh`})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:e.enabled?r&&t===void 0?(0,U.jsx)(RF,{title:`Loading status`,text:`Reading runtime status.`}):a.length>0?(0,U.jsx)(RF,{title:`Status error`,text:a}):t===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-4`,children:[(0,U.jsx)(FF,{label:`Agents`,value:t.counts.agents}),(0,U.jsx)(FF,{label:`Pipelines`,value:t.counts.pipelines}),(0,U.jsx)(FF,{label:`Sessions`,value:t.counts.sessions??`-`}),(0,U.jsx)(FF,{label:`Traces`,value:t.counts.traces??`-`})]}),(0,U.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,0.85fr)_minmax(0,1.15fr)]`,children:[(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(LF,{children:`runtime`}),(0,U.jsx)(IF,{label:`id`,value:t.runner.id}),(0,U.jsx)(IF,{label:`name`,value:t.runner.name??`-`}),(0,U.jsx)(IF,{label:`version`,value:t.runner.version??`-`}),(0,U.jsx)(IF,{label:`generated`,value:t.generatedAt})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(LF,{children:`storage`}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[Object.entries(t.storage).map(([e,t])=>(0,U.jsx)(IF,{label:e,value:t??`-`},e)),Object.entries(t.storage).length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/80 bg-background/45 px-3 py-2 text-sm text-muted-foreground`,children:`No storage adapters reported.`}):null]})]})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(LF,{children:`capabilities`}),(0,U.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:Object.entries(t.capabilities).map(([e,t])=>(0,U.jsx)(Wl,{className:t?.enabled?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`,children:e},e))})]}),(0,U.jsxs)(`section`,{className:`grid min-w-0 overflow-hidden rounded-xl border border-border/80 bg-card/45`,children:[(0,U.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/80 bg-muted/20 px-4`,children:(0,U.jsx)(LF,{children:`raw summary`})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:JSON.stringify(t,null,2)})})})})]})]}):(0,U.jsx)(RF,{title:`Status unavailable`,text:`This Studio runtime did not expose status.`})})]})}function FF(e){return(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`font-mono text-3xl font-semibold tracking-tight text-foreground`,children:e.value})]})}function IF(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-background/45 px-3 py-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,title:String(e.value),children:e.value})]})}function LF(e){return(0,U.jsx)(`h2`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.children})}function RF(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.text})]})})}function zF(e){let t=e.agents.find(t=>t.id===e.selectedAgentId)??e.agents[0],n=e.summary?.tools??[],[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(`{}`),[s,c]=(0,v.useState)(`idle`),[l,u]=(0,v.useState)(),[d,f]=(0,v.useState)(``),p=(0,v.useMemo)(()=>n.find(e=>e.name===r)??n[0],[r,n]);(0,v.useEffect)(()=>{if(n.length===0){i(``);return}n.some(e=>e.name===r)||i(n[0]?.name??``)},[r,n]);async function m(){if(t===void 0||p===void 0)return;let e;try{e=JSON.parse(a)}catch(e){f(e instanceof Error?e.message:String(e)),u(void 0);return}c(`running`),f(``),u(void 0);try{let n=await fetch(`/agents/${encodeURIComponent(t.id)}/tools/${encodeURIComponent(p.name)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({args:e})}),r=await n.json();u(r),(!n.ok||r.status===`error`)&&f(qF(r.error??r))}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(`idle`)}}return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Tools`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Agent capabilities`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Tools`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Tool definitions registered on Studio agents, including approval policy and input schema.`})]}),e.agents.length>1?(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectAgent,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 w-64 rounded-lg border-border bg-card/80 font-mono text-xs max-md:w-full`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:e.agents.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):null]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:(0,U.jsx)(`div`,{className:`grid w-full gap-4`,children:e.enabled?e.loading?(0,U.jsx)(HF,{title:`Loading tools`,message:`Reading registered tool metadata.`}):n.length===0?(0,U.jsx)(HF,{title:`No tools`,message:`The selected agent has no registered tools.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`section`,{className:`grid gap-4 rounded-xl border border-border/80 bg-card/55 p-4 shadow-sm xl:grid-cols-[minmax(300px,0.7fr)_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:`Run tool`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:`Invoke a registered tool directly with JSON arguments and inspect the raw result.`})]}),(0,U.jsxs)(J,{value:p?.name??``,onValueChange:i,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 rounded-lg border-border bg-background/80 font-mono text-xs`,children:(0,U.jsx)(Y,{placeholder:`Tool`})}),(0,U.jsx)(Bl,{children:n.map(e=>(0,U.jsx)(Vl,{value:e.name,children:e.name},`${e.source}:${e.name}`))})]}),p===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-background/45 p-3`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`selected definition`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:p.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:UF(p.source),children:p.source}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-muted/55 text-muted-foreground`,children:[GF(p.parameters),` fields`]})]})]})]}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,U.jsx)(Hl,{className:`min-h-40 resize-y rounded-lg border-border bg-background/70 p-3 font-mono text-xs leading-5`,value:a,spellCheck:!1,onChange:e=>o(e.target.value)}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:`Arguments must be valid JSON.`}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-4 font-mono text-xs`,type:`button`,disabled:s===`running`||p===void 0,onClick:()=>void m(),children:s===`running`?`Running`:`Run`})]}),d.length>0?(0,U.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 font-mono text-xs leading-5 text-destructive`,children:d}):null,l===void 0?null:(0,U.jsx)(VF,{value:l,title:`Result`})]})]}),(0,U.jsxs)(`div`,{className:`grid gap-1 overflow-hidden rounded-xl border border-border/80 bg-card/55 p-2 shadow-sm`,children:[(0,U.jsxs)(`div`,{className:`grid min-h-10 grid-cols-[minmax(260px,0.75fr)_minmax(0,1fr)] items-center rounded-lg border border-border/60 bg-muted/20 px-4 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground max-lg:hidden`,children:[(0,U.jsx)(`span`,{children:`Definition`}),(0,U.jsx)(`span`,{children:`Parameter schema`})]}),n.map(e=>(0,U.jsx)(BF,{tool:e},`${e.source}:${e.name}`))]})]}):(0,U.jsx)(HF,{title:`Tools unavailable`,message:`No registered Studio agent exposes static or dynamic tools.`})})})]})}function BF(e){let t=GF(e.tool.parameters);return(0,U.jsxs)(`article`,{className:`grid grid-cols-[minmax(300px,0.75fr)_minmax(0,1fr)] gap-2 rounded-lg border border-transparent bg-background/25 p-2 transition duration-200 hover:border-border/70 hover:bg-background/35 max-lg:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-4 rounded-lg bg-card/25 p-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.tool.name}),(0,U.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium text-muted-foreground`,children:e.tool.agentId})]}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:e.tool.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:UF(e.tool.source),children:e.tool.source}),(0,U.jsxs)(Wl,{className:tr(e.tool.approval.required?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`),children:[`approval `,e.tool.approval.required?`required`:`none`]}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-transparent text-muted-foreground`,children:[t,` `,t===1?`field`:`fields`]})]}),e.tool.approval.reason===void 0?null:(0,U.jsx)(`p`,{className:`m-0 rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:e.tool.approval.reason})]}),(0,U.jsx)(VF,{value:e.tool.parameters,title:`JSON schema`})]})}function VF(e){return(0,U.jsxs)(`section`,{className:`grid min-w-0 content-start overflow-hidden rounded-lg bg-background/45`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-3 bg-muted/20 px-4`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.title}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:WF(e.value)})]}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-96 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:KF(e.value)})})})})]})}function HF(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.message})]})})}function UF(e){return e===`dynamic`?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`}function WF(e){if(typeof e!=`object`||!e||Array.isArray(e))return`value`;let t=e.type;return typeof t==`string`?t:`object`}function GF(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e.properties;return typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length:0}function KF(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function qF(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function JF({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`rounded-xl border border-border/80 bg-card/95 text-card-foreground shadow-sm shadow-black/20`,e),...t})}function YF(e,t){return v.useReducer((e,n)=>t[e][n]??e,e)}var XF=`ScrollArea`,[ZF,QF]=sr(XF),[$F,eI]=ZF(XF),tI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=v.useState(null),[l,u]=v.useState(null),[d,f]=v.useState(null),[p,m]=v.useState(null),[h,g]=v.useState(null),[_,y]=v.useState(0),[b,x]=v.useState(0),[S,C]=v.useState(!1),[w,T]=v.useState(!1),E=ut(t,e=>c(e)),D=_r(i);return(0,U.jsx)($F,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,U.jsx)(vr.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})});tI.displayName=XF;var nI=`ScrollAreaViewport`,rI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=eI(nI,n),s=ut(t,v.useRef(null),o.onViewportChange);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,U.jsx)(vr.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,U.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});rI.displayName=nI;var iI=`ScrollAreaScrollbar`,aI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=eI(iI,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return v.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,U.jsx)(oI,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,U.jsx)(sI,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,U.jsx)(cI,{...r,ref:t,forceMount:n}):i.type===`always`?(0,U.jsx)(lI,{...r,ref:t}):null});aI.displayName=iI;var oI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=eI(iI,e.__scopeScrollArea),[a,o]=v.useState(!1);return v.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,U.jsx)(aP,{present:n||a,children:(0,U.jsx)(cI,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),sI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=eI(iI,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=kI(()=>c(`SCROLL_END`),100),[s,c]=YF(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return v.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),v.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,U.jsx)(aP,{present:n||s!==`hidden`,children:(0,U.jsx)(lI,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:ar(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:ar(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),cI=v.forwardRef((e,t)=>{let n=eI(iI,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=v.useState(!1),s=e.orientation===`horizontal`,c=kI(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return AI(n.viewport,c),AI(n.content,c),(0,U.jsx)(aP,{present:r||a,children:(0,U.jsx)(lI,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),lI=v.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=eI(iI,e.__scopeScrollArea),a=v.useRef(null),o=v.useRef(0),[s,c]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=SI(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return wI(e,o.current,s,t)}return n===`horizontal`?(0,U.jsx)(uI,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=TI(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,U.jsx)(dI,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=TI(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),uI=v.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=eI(iI,e.__scopeScrollArea),[o,s]=v.useState(),c=v.useRef(null),l=ut(t,c,a.onScrollbarXChange);return v.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(mI,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":CI(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),DI(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:xI(o.paddingLeft),paddingEnd:xI(o.paddingRight)}})}})}),dI=v.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=eI(iI,e.__scopeScrollArea),[o,s]=v.useState(),c=v.useRef(null),l=ut(t,c,a.onScrollbarYChange);return v.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(mI,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":CI(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),DI(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:xI(o.paddingTop),paddingEnd:xI(o.paddingBottom)}})}})}),[fI,pI]=ZF(iI),mI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=eI(iI,n),[m,h]=v.useState(null),g=ut(t,e=>h(e)),_=v.useRef(null),y=v.useRef(``),b=p.viewport,x=r.content-r.viewport,S=br(u),C=br(c),w=kI(d,10);function T(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return v.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),v.useEffect(C,[r,C]),AI(m,w),AI(p.content,w),(0,U.jsx)(fI,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:br(a),onThumbPointerUp:br(o),onThumbPositionChange:C,onThumbPointerDown:br(s),children:(0,U.jsx)(vr.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:ar(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:ar(e.onPointerMove,T),onPointerUp:ar(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),hI=`ScrollAreaThumb`,gI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=pI(hI,e.__scopeScrollArea);return(0,U.jsx)(aP,{present:n||i.hasThumb,children:(0,U.jsx)(_I,{ref:t,...r})})}),_I=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=eI(hI,n),o=pI(hI,n),{onThumbPositionChange:s}=o,c=ut(t,e=>o.onThumbChange(e)),l=v.useRef(void 0),u=kI(()=>{l.current&&=(l.current(),void 0)},100);return v.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=OI(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,U.jsx)(vr.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:ar(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:ar(e.onPointerUp,o.onThumbPointerUp)})});gI.displayName=hI;var vI=`ScrollAreaCorner`,yI=v.forwardRef((e,t)=>{let n=eI(vI,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,U.jsx)(bI,{...e,ref:t}):null});yI.displayName=vI;var bI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=eI(vI,n),[a,o]=v.useState(0),[s,c]=v.useState(0),l=!!(a&&s);return AI(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),AI(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,U.jsx)(vr.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function xI(e){return e?parseInt(e,10):0}function SI(e,t){let n=e/t;return isNaN(n)?0:n}function CI(e){let t=SI(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wI(e,t,n,r=`ltr`){let i=CI(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return EI([c,l],d)(e)}function TI(e,t,n=`ltr`){let r=CI(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=ir(e,n===`ltr`?[0,o]:[o*-1,0]);return EI([0,o],[0,s])(c)}function EI(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function DI(e,t){return e>0&&e<t}var OI=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function kI(e,t){let n=br(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function AI(e,t){let n=br(t);ei(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var jI=tI,MI=rI,NI=yI;function PI({className:e,children:t,...n}){return(0,U.jsxs)(jI,{className:tr(`relative overflow-hidden`,e),...n,children:[(0,U.jsx)(MI,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,U.jsx)(FI,{}),(0,U.jsx)(NI,{})]})}function FI({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(aI,{orientation:t,className:tr(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-px`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-px`,e),...n,children:(0,U.jsx)(gI,{className:`relative flex-1 rounded-lg bg-muted-foreground/40`})})}function II(e){if(!e.tracesEnabled)return(0,U.jsx)(`div`,{className:`w-full rounded-lg border border-dashed border-border p-8 text-sm font-medium text-muted-foreground`,children:`Tracing is disabled`});let t=e.selectedTraceId.length===0?void 0:e.traces.find(t=>t.id===e.selectedTraceId),n=t===void 0||e.traceSessionDetailId!==t.sessionId?[]:e.traces.filter(e=>e.sessionId===t.sessionId);return(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full content-stretch pb-6 pl-0 pr-6`,"aria-label":`Tracing`,children:e.selectedTraceId.length===0?(0,U.jsx)(LI,{agents:e.agents,traces:e.traces,traceLoadState:e.traceLoadState,onSelectTrace:e.onSelectTrace}):(0,U.jsx)(RI,{selectedTrace:t,selectedSessionTraces:n,selectedTraceId:e.selectedTraceId,traceLoadState:e.traceLoadState,onBack:()=>e.onSelectTrace(``),onShowSessionTraces:e.onShowSessionTraces})})}function LI(e){return(0,U.jsx)(JF,{className:`min-h-0 overflow-hidden rounded-xl border-border/80 bg-card/80`,"aria-label":`Traces`,children:(0,U.jsx)(PI,{className:`h-full min-h-0`,children:(0,U.jsxs)(`div`,{className:`grid min-w-280 gap-1 p-2`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 grid min-h-11 grid-cols-[minmax(220px,1.3fr)_150px_120px_120px_120px_120px_110px_90px] items-center gap-4 rounded-lg border border-border/60 bg-card/95 px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Trace`}),(0,U.jsx)(`span`,{children:`Session`}),(0,U.jsx)(`span`,{children:`Agent`}),(0,U.jsx)(`span`,{children:`Status`}),(0,U.jsx)(`span`,{children:`Started`}),(0,U.jsx)(`span`,{children:`Duration`}),(0,U.jsx)(`span`,{children:`First delta`}),(0,U.jsx)(`span`,{children:`Events`})]}),e.traceLoadState===`loading`&&e.traces.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`Loading traces`}):null,e.traceLoadState===`idle`&&e.traces.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`No traces found`}):null,e.traces.map(t=>(0,U.jsxs)(K,{className:`grid h-auto min-h-14 w-full grid-cols-[minmax(220px,1.3fr)_150px_120px_120px_120px_120px_110px_90px] items-center justify-start gap-4 whitespace-normal rounded-lg border border-transparent bg-transparent px-4 py-2.5 text-left text-muted-foreground shadow-none transition duration-200 hover:border-primary/20 hover:bg-accent/70 hover:text-accent-foreground`,type:`button`,variant:`ghost`,onClick:()=>e.onSelectTrace(t.id),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium text-muted-foreground`,children:t.id}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium`,children:t.sessionId}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Gy(e.agents,t)}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium capitalize`,children:[(0,U.jsx)(`span`,{className:tr(`h-2.5 w-2.5 shrink-0 rounded-lg`,ML(t.status))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t.status})]}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Vy(t.startedAt)}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:qy(Hy(t.durationMs))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:qy(Hy(AL(t.observations)))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium tabular-nums`,children:t.observationCount})]},t.id))]})})})}function RI(e){return(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] gap-2 overflow-hidden rounded-xl border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsxs)(`header`,{className:`grid min-h-16 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 overflow-hidden rounded-lg border border-border/60 bg-card/95 px-4 py-3`,children:[(0,U.jsx)(K,{"aria-label":`Back to traces`,className:`h-8 min-h-8 w-8 text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,onClick:e.onBack,children:(0,U.jsx)(pe,{"aria-hidden":`true`})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-semibold text-foreground`,children:e.selectedTrace?.name??`Trace detail`}),(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 overflow-hidden text-xs font-medium text-muted-foreground`,children:e.selectedTrace===void 0?e.traceLoadState===`loading`?`Loading trace`:`Trace not found`:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:tr(`h-2 w-2 shrink-0 rounded-lg`,ML(e.selectedTrace.status))}),(0,U.jsx)(`span`,{className:`shrink-0 capitalize`,children:e.selectedTrace.status}),(0,U.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:`/`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Session`,` `,(0,U.jsx)(`span`,{className:`font-mono font-semibold`,children:e.selectedTrace.sessionId})]})]})})]}),(0,U.jsx)(`span`,{className:`hidden max-w-[42vw] truncate rounded-lg bg-muted px-2 py-1 font-mono text-xs font-medium text-muted-foreground md:block`,children:e.selectedTraceId})]}),(0,U.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden`,children:e.selectedTrace===void 0?(0,U.jsx)(JF,{className:`grid h-full place-items-center rounded-lg border-border bg-card p-6 text-sm font-medium text-muted-foreground`,children:e.traceLoadState===`loading`?`Loading trace`:`Trace not found`}):(0,U.jsx)(zI,{traces:e.selectedSessionTraces.length>0?e.selectedSessionTraces:[e.selectedTrace],onShowSessionTraces:e.onShowSessionTraces})})]})}function zI(e){let t=(0,v.useMemo)(()=>[...e.traces].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)),[e.traces]),n=t[0]?.id??``,[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(`trace`);(0,v.useEffect)(()=>{i(n),o(`trace`)},[n]);let s=t.find(e=>e.id===r)??t[0],c=s===void 0?[]:hL(s),l=(e,t)=>{i(e),o(t)};return s===void 0?(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full place-items-center text-sm font-medium text-muted-foreground`,"aria-label":`Traces`,children:`No trace selected`}):(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full content-stretch overflow-hidden`,"aria-label":`Traces`,children:(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-[320px_minmax(0,1fr)] overflow-hidden max-md:grid-cols-1`,children:[(0,U.jsxs)(`nav`,{className:`grid min-h-0 auto-rows-min content-start overflow-auto border-r border-border/80 bg-card/35 pr-2 max-md:max-h-80 max-md:border-b max-md:border-r-0`,"aria-label":`Trace timeline`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-30 flex min-h-11 items-center justify-between bg-card/90 py-0 pl-0 pr-5 text-xs font-medium text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Search`}),(0,U.jsx)(`strong`,{className:`text-foreground`,children:`Timeline`})]}),t.map(e=>{let t=s.id===e.id,n=hL(e);return(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(BI,{active:t&&a===`trace`,ancestorLevels:[],hasChildren:!0,isLastSibling:!0,level:0,tone:`trace`,title:e.name??`Agent`,subtitle:Hy(e.durationMs),onSelect:()=>l(e.id,`trace`)}),(0,U.jsx)(BI,{active:t&&a===`agent`,ancestorLevels:[],hasChildren:n.length>0,isLastSibling:!0,level:1,tone:`agent`,title:`agent.run`,subtitle:Hy(e.durationMs),onSelect:()=>l(e.id,`agent`)}),n.map(r=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(BI,{active:t&&a===`turn:${r.turn}`,ancestorLevels:[],hasChildren:r.observations.length>0,isLastSibling:r.turn===n.at(-1)?.turn,level:2,tone:`turn`,title:`turn.${r.turn}`,subtitle:Hy(r.durationMs),onSelect:()=>l(e.id,`turn:${r.turn}`)}),(0,U.jsx)(VI,{activeKey:a,isLastTurn:r.turn===n.at(-1)?.turn,observations:r.observations,onSelect:t=>l(e.id,`observation:${t}`),traceActive:t})]},`${e.id}:turn:${r.turn}`))]},e.id)})]}),(0,U.jsx)(UI,{trace:s,turns:c,activeKey:a,onShowSessionTraces:e.onShowSessionTraces})]})})}function BI(e){let t=e=>22+e*22;return(0,U.jsxs)(K,{className:tr(`relative grid h-auto min-h-0 w-full min-w-0 grid-cols-[20px_minmax(0,1fr)] items-start justify-start gap-2 whitespace-normal rounded-lg border-0 bg-transparent px-3 py-2.5 text-left text-muted-foreground shadow-none transition duration-200 hover:bg-accent/70 hover:text-accent-foreground`,e.active&&`bg-primary/10 text-primary hover:bg-primary/10 hover:text-primary`),type:`button`,variant:`ghost`,onClick:e.onSelect,style:{paddingLeft:`${12+e.level*22}px`},children:[e.ancestorLevels.map(e=>(0,U.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 w-px bg-muted-foreground/35`,style:{left:`${t(e)}px`},"aria-hidden":`true`},`ancestor-line-${e}`)),e.level>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute top-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,height:`18px`},"aria-hidden":`true`}),e.isLastSibling?null:(0,U.jsx)(`span`,{className:`pointer-events-none absolute bottom-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,top:`18px`},"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`pointer-events-none absolute h-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,top:`18px`,width:`22px`},"aria-hidden":`true`})]}):null,e.hasChildren?(0,U.jsx)(`span`,{className:`pointer-events-none absolute bottom-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level)}px`,top:`18px`},"aria-hidden":`true`}):null,(0,U.jsx)(`span`,{className:tr(`relative z-10 grid h-5 w-5 place-items-center rounded-lg bg-transparent [&_svg]:h-3 [&_svg]:w-3 [&_svg]:opacity-100`,PL(e.tone)),children:(0,U.jsx)(NL,{tone:e.tone})}),(0,U.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-medium leading-5 text-current`,children:e.title}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:e.subtitle})]})]})}function VI(e){let t=gL(e.observations);return(0,U.jsx)(U.Fragment,{children:t.map((n,r)=>(0,U.jsx)(HI,{activeKey:e.activeKey,ancestorLevels:e.isLastTurn?[]:[1],isLastSibling:r===t.length-1,level:3,node:n,onSelect:e.onSelect,traceActive:e.traceActive},n.observation.id))})}function HI(e){let t=FL(e.node.observation),n=e.isLastSibling?e.ancestorLevels:[...e.ancestorLevels,e.level];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(BI,{active:e.traceActive&&e.activeKey===`observation:${e.node.observation.id}`,ancestorLevels:e.ancestorLevels,hasChildren:e.node.children.length>0,isLastSibling:e.isLastSibling,level:e.level,tone:e.node.observation.kind,title:kL(e.node.observation),subtitle:t.length>0?`${Hy(e.node.observation.durationMs)} · ${t}`:Hy(e.node.observation.durationMs),onSelect:()=>e.onSelect(e.node.observation.id)}),e.node.children.map((t,r)=>(0,U.jsx)(HI,{activeKey:e.activeKey,ancestorLevels:n,isLastSibling:r===e.node.children.length-1,level:e.level+1,node:t,onSelect:e.onSelect,traceActive:e.traceActive},t.observation.id))]})}function UI(e){let t=_L(e.trace,e.turns,e.activeKey);return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-card/70`,"aria-label":`Trace detail`,children:[(0,U.jsx)(`header`,{className:`border-b border-border/60 bg-card/70 px-6 py-5`,children:(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 items-start justify-between gap-4`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(`span`,{className:tr(`grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-primary text-primary-foreground [&_svg]:h-4 [&_svg]:w-4 [&_svg]:opacity-100`,t.tone!==`trace`&&`bg-muted text-foreground`,PL(t.tone)),children:(0,U.jsx)(NL,{tone:t.tone})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 min-w-0 truncate text-2xl font-semibold leading-none tracking-[-0.01em] text-foreground`,children:t.title}),(0,U.jsx)(`div`,{className:`font-mono text-xs font-medium text-muted-foreground`,children:t.startedAt})]})]})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-2`,children:[(0,U.jsx)(WI,{label:`Duration`,value:Hy(t.durationMs)}),t.firstDeltaMs===void 0?null:(0,U.jsx)(WI,{label:`First delta`,value:Hy(t.firstDeltaMs)}),t.usage.length===0?null:(0,U.jsx)(WI,{label:`Usage`,value:t.usage}),(0,U.jsxs)(`button`,{className:`grid min-w-0 gap-1 rounded-lg bg-card/85 px-4 py-3 text-left transition duration-200 hover:bg-accent hover:text-accent-foreground`,type:`button`,onClick:()=>e.onShowSessionTraces(e.trace.sessionId),children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:`Session`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-current`,children:e.trace.sessionId})]})]})]})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-auto`,children:(0,U.jsxs)(`div`,{className:`grid min-w-0 content-start gap-6 p-6`,children:[t.input===void 0?null:(0,U.jsx)(GI,{title:`Input`,value:t.input}),t.output===void 0?null:(0,U.jsx)(GI,{title:`Output`,value:t.output,tone:`success`}),t.error===void 0?null:(0,U.jsx)(GI,{title:`Error`,value:t.error,tone:`error`}),(0,U.jsx)(GI,{title:`Metadata`,value:t.metadata,rawJson:!0})]})})]})}function WI(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-card/85 px-4 py-3`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.value})]})}function GI(e){let t=oL(e.title,e.value);return(0,U.jsxs)(`section`,{className:`grid min-w-0 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`h3`,{className:`m-0 text-lg font-semibold leading-tight text-foreground`,children:e.title}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border/80`,"aria-hidden":`true`})]}),e.rawJson?(0,U.jsx)(YI,{value:e.value}):(0,U.jsx)(`div`,{className:`grid min-w-0 gap-3`,children:t.map(t=>(0,U.jsxs)(`article`,{className:tr(`grid min-w-0 gap-3 rounded-lg bg-card/85 px-4 py-4`,e.compact&&`grid-cols-[150px_minmax(0,1fr)] items-start gap-4 max-lg:grid-cols-1`),children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:[(0,U.jsx)(aL,{label:t.label}),t.label]}),(0,U.jsx)(KI,{compact:e.compact,item:t,tone:e.tone})]},`${t.label}-${t.text}`))})]})}function KI(e){let t=qI(e.item);return t.length>0?(0,U.jsx)(`div`,{className:`grid min-w-0 gap-5`,children:t.map(e=>(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-semibold tabular-nums text-muted-foreground`,children:e.index}),(0,U.jsx)(Wl,{className:tr(`px-1.5 py-0.5`,e.role===`User`&&`border-chart-2/40 bg-chart-2/15 text-chart-2`,e.role===`Assistant`&&`border-chart-1/40 bg-chart-1/15 text-chart-1`,e.role===`Tool`&&`border-chart-5/40 bg-chart-5/15 text-chart-5`),children:e.role})]}),(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-[15px] leading-7 text-foreground [overflow-wrap:anywhere]`,children:e.text})]},`${e.index}-${e.role}-${e.text}`))}):(0,U.jsx)(`p`,{className:tr(`m-0 whitespace-pre-wrap text-[15px] leading-7 text-foreground [overflow-wrap:anywhere]`,e.compact&&`font-mono text-[13px] leading-6`,e.tone===`success`&&!iL(e.item)&&`text-primary`,e.tone===`error`&&`text-destructive`),children:e.item.text})}function qI(e){return e.label.startsWith(`Conversation history`)?e.text.split(`
88
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},VP=`DialogDescriptionWarning`,HP=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${zP(VP).contentName}}.`;return v.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},UP=mP,WP=bP,GP=SP,KP=EP,qP=jP,JP=NP,YP=UP;function XP({className:e,children:t,...n}){return(0,U.jsxs)(WP,{children:[(0,U.jsx)(GP,{className:`fixed inset-0 z-50 bg-background/80 backdrop-blur-sm`}),(0,U.jsx)(KP,{className:tr(`fixed left-1/2 top-1/2 z-50 grid w-[min(420px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border border-border bg-popover p-5 text-popover-foreground shadow-2xl shadow-black/40`,e),...n,children:t})]})}function ZP({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`grid gap-1.5`,e),...t})}function QP({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`flex justify-end gap-2`,e),...t})}function $P({className:e,...t}){return(0,U.jsx)(qP,{className:tr(`text-base font-bold`,e),...t})}function eF({className:e,...t}){return(0,U.jsx)(JP,{className:tr(`text-sm leading-6 text-muted-foreground`,e),...t})}function tF(e){return e.sessionsEnabled?(0,U.jsx)(`section`,{className:`grid min-h-0 w-full overflow-auto pb-6 pl-0 pr-6`,"aria-label":`Sessions`,children:(0,U.jsxs)(`div`,{className:`min-w-225 overflow-hidden rounded-xl border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 grid min-h-11 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px_72px] items-center gap-4 rounded-lg border border-border/60 bg-card/95 px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Session`}),(0,U.jsx)(`span`,{children:`Agent`}),(0,U.jsx)(`span`,{children:`Messages`}),(0,U.jsx)(`span`,{children:`Updated`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),e.sessionLoadState===`loading`&&e.sessions.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`Loading sessions`}):null,e.sessionLoadState===`idle`&&e.sessions.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`No sessions`}):null,e.sessions.map(t=>(0,U.jsxs)(`div`,{className:tr(`mt-1 grid min-h-14 w-full min-w-0 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px_72px] items-center gap-4 rounded-lg border border-transparent px-4 text-left text-muted-foreground transition duration-200 hover:border-primary/20 hover:bg-accent/80 hover:text-accent-foreground`,t.id===e.selectedSessionId&&`border-primary/35 bg-primary/10 text-primary`),children:[(0,U.jsxs)(K,{className:`col-span-4 grid h-full min-h-14 min-w-0 grid-cols-[minmax(220px,1.3fr)_180px_120px_120px] items-center justify-start gap-4 border-0 bg-transparent p-0 text-left text-inherit shadow-none hover:bg-transparent hover:text-inherit`,type:`button`,variant:`ghost`,onClick:()=>e.onOpenSession(t.id),children:[(0,U.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:t.title??`Untitled chat`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium text-muted-foreground`,children:t.id})]}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Wy(e.agents,t.agentId)}),(0,U.jsxs)(`span`,{className:`text-xs font-medium tabular-nums text-muted-foreground`,children:[t.messageCount,` messages`]}),(0,U.jsx)(`time`,{className:`text-xs font-medium text-muted-foreground`,children:zy(t.updatedAt)})]}),(0,U.jsxs)(`span`,{className:`flex items-center justify-end gap-1`,children:[(0,U.jsx)(K,{"aria-label":`View tracing for ${t.title??`Untitled chat`}`,className:`h-7 min-h-7 w-7 border-0 bg-transparent p-0 text-muted-foreground opacity-80 hover:bg-transparent hover:text-primary hover:opacity-100 [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,onClick:n=>{n.stopPropagation(),e.onViewSessionTracing(t.id)},children:(0,U.jsx)(Xe,{"aria-hidden":`true`})}),(0,U.jsx)(K,{"aria-label":`Delete ${t.title??`Untitled chat`}`,className:`h-7 min-h-7 w-7 border-0 bg-transparent p-0 text-muted-foreground opacity-80 hover:bg-transparent hover:text-destructive hover:opacity-100 [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,onClick:n=>{n.stopPropagation(),e.onDeleteSession(t)},children:(0,U.jsx)(it,{"aria-hidden":`true`})})]})]},t.id))]})}):(0,U.jsx)(`div`,{className:`w-full rounded-lg border border-dashed border-border p-8 text-sm font-medium text-muted-foreground`,children:`Sessions are disabled`})}function nF(e){let t=e.session?.title??`Untitled chat`;return(0,U.jsx)(YP,{open:e.session!==void 0,onOpenChange:e.onOpenChange,children:(0,U.jsxs)(XP,{children:[(0,U.jsxs)(ZP,{children:[(0,U.jsx)($P,{children:`Delete session`}),(0,U.jsxs)(eF,{children:[`Delete "`,t,`" and its traces. This cannot be undone.`]})]}),(0,U.jsxs)(QP,{children:[(0,U.jsx)(K,{type:`button`,variant:`ghost`,onClick:()=>e.onOpenChange(!1),children:`Cancel`}),(0,U.jsx)(K,{type:`button`,variant:`destructive`,onClick:()=>{e.session!==void 0&&e.onConfirm(e.session)},children:`Delete`})]})]})})}var rF=document.getElementById(`anvia-ui`),iF=rF?.dataset.uiPath??`/ui`,aF=rF?.dataset.uiCompatPath??`/ui`,oF=`${hF(iF)||hF(aF)||`/ui`}/assets/logo.png`,sF=`static-context`;function cF(){let e=hF(iF),t=hF(aF),n=window.location.pathname.replace(/\/+$/,``);return t.length>0&&(n===t||n.startsWith(`${t}/`))?lF(n===t?[]:n.slice(t.length+1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e))):e.length===0&&n.length>0?lF(n.slice(1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e))):n===e||!n.startsWith(`${e}/`)?{page:`playground`}:lF(n.slice(e.length+1).split(`/`).filter(e=>e.length>0).map(e=>decodeURIComponent(e)))}function lF(e){let[t,n,r]=e;return t===`tracing`?n===`sessions`?{page:`tracing`,...r===void 0?{}:{traceSessionId:r}}:{page:`tracing`,...n===void 0?{}:{traceId:n}}:t===`sessions`?{page:`sessions`}:t===`agents`?{page:`agents`}:t===`tools`?{page:`tools`}:t===`mcps`?{page:`mcps`}:t===`pipelines`?{page:`pipelines`}:t===`evals`?{page:`evals`}:t===`memory`?{page:`memory`}:t===`status`?{page:`status`}:t===`knowledge`?{page:`knowledge`,knowledgeTab:vF(n)}:t===`playground`?{page:`playground`,...n===void 0?{}:{sessionId:n}}:t!==void 0&&n===void 0?{page:`playground`,sessionId:t}:{page:`playground`}}function uF(e){if(e===`knowledge`){dF(sF);return}let t=gF();_F(e===`playground`?`${t}/playground`:`${t}/${e}`)}function dF(e){_F(`${gF()}/knowledge/${e}`)}function fF(e){let t=gF();_F(e===void 0?`${t}/playground`:`${t}/playground/${encodeURIComponent(e)}`)}function pF(e){_F(`${gF()}/tracing/${encodeURIComponent(e)}`)}function mF(e){_F(`${gF()}/tracing/sessions/${encodeURIComponent(e)}`)}function hF(e){return e===`/`?``:e.replace(/\/+$/,``)}function gF(){return hF(aF)||hF(iF)||`/ui`}function _F(e){let t=`${e}${window.location.search}${window.location.hash}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==t&&window.history.pushState({},``,t)}function vF(e){switch(e){case`dynamic-context`:case`dynamic-tools`:case`retrieval-log`:case`static-context`:return e;default:return sF}}var yF=0;function bF(e){yF=e}function xF(){yF=0}function SF(e){return e.filter(e=>e.kind===`message`&&e.text.trim().length>0).map(e=>({role:e.role,content:[{type:`text`,text:e.text}]}))}function CF(e){return e.currentTarget.value}function wF(e){e!==null&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)}function TF(){let e=yF;return yF+=1,e}function EF(e){return e.reduce((e,t)=>Math.max(e,t.entryId+1),0)}function DF(e,t,n){for(let r=e.length-1;r>=0;--r){let i=e[r];if(i!==void 0&&!(i.kind!==`tool`||i.toolName!==t||i.result!==void 0)&&(n===void 0||i.callId===n))return r}return-1}function OF(e,t,n){for(let r=e.length-1;r>=0;--r){let i=e[r];if(i!==void 0&&!(i.kind!==`tool`||i.toolName!==t)&&(n===void 0||i.callId===n))return r}return-1}function kF(e){return typeof e==`string`?e:Ry(e)?typeof e.text==`string`?e.text:typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(AF).filter(Boolean).join(`
89
+ `):``:``}function AF(e){return typeof e==`string`?e:Ry(e)?typeof e.text==`string`?e.text:e.type===`tool_call`&&Ry(e.function)?`${String(e.function.name??`tool`)}(${Yy(e.function.arguments)})`:e.type===`tool_result`&&Array.isArray(e.content)?e.content.map(AF).filter(Boolean).join(`
90
+ `):typeof e.type==`string`?e.type:``:``}async function jF(e,t){let n=e.getReader(),r=new TextDecoder,i=``;for(;;){let e=await n.read();if(e.done)break;i+=r.decode(e.value,{stream:!0});let a=i.split(`
91
+ `);i=a.pop()??``;for(let e of a)e.trim().length>0&&await t(JSON.parse(e))}i+=r.decode(),i.trim().length>0&&await t(JSON.parse(i))}function MF(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})})}function NF(e){let t=PF(e.icon);return(0,U.jsxs)(K,{className:tr(`h-8 min-h-8 w-full justify-start gap-3 rounded-lg bg-transparent px-2.5 text-sm font-medium text-sidebar-foreground/62 shadow-none transition duration-200 hover:bg-sidebar-accent/80 hover:text-sidebar-foreground active:translate-y-px [&_svg]:h-3.5 [&_svg]:w-3.5`,e.active&&`bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`),variant:`ghost`,type:`button`,disabled:e.disabled,onClick:e.onClick,children:[(0,U.jsx)(t,{}),(0,U.jsx)(`span`,{children:e.label})]})}function PF(e){switch(e){case`activity`:return Xe;case`bot`:return Qe;case`database`:return ke;case`gauge`:return Ne;case`list`:return ze;case`message`:return Ce;case`plug`:return qe;case`shield`:return et;case`wrench`:return ot;case`workflow`:return je}}function FF(e){let[t,n]=(0,v.useState)(),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=(0,v.useCallback)(async()=>{if(!e.enabled){n(void 0);return}i(!0),o(``);try{let e=await fetch(`/status`);if(!e.ok)throw Error(`Status failed with HTTP ${e.status}`);n(await e.json())}catch(e){o(e instanceof Error?e.message:String(e)),n(void 0)}finally{i(!1)}},[e.enabled]);return(0,v.useEffect)(()=>{s()},[s]),(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Status`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Operations`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Status`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Runtime health, storage adapters, feature capabilities, and current record counts.`})]}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-3 font-mono text-xs`,type:`button`,variant:`secondary`,disabled:r,onClick:()=>void s(),children:`Refresh`})]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:e.enabled?r&&t===void 0?(0,U.jsx)(zF,{title:`Loading status`,text:`Reading runtime status.`}):a.length>0?(0,U.jsx)(zF,{title:`Status error`,text:a}):t===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-4`,children:[(0,U.jsx)(IF,{label:`Agents`,value:t.counts.agents}),(0,U.jsx)(IF,{label:`Pipelines`,value:t.counts.pipelines}),(0,U.jsx)(IF,{label:`Sessions`,value:t.counts.sessions??`-`}),(0,U.jsx)(IF,{label:`Traces`,value:t.counts.traces??`-`})]}),(0,U.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,0.85fr)_minmax(0,1.15fr)]`,children:[(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(RF,{children:`runtime`}),(0,U.jsx)(LF,{label:`id`,value:t.runner.id}),(0,U.jsx)(LF,{label:`name`,value:t.runner.name??`-`}),(0,U.jsx)(LF,{label:`version`,value:t.runner.version??`-`}),(0,U.jsx)(LF,{label:`generated`,value:t.generatedAt})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(RF,{children:`storage`}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[Object.entries(t.storage).map(([e,t])=>(0,U.jsx)(LF,{label:e,value:t??`-`},e)),Object.entries(t.storage).length===0?(0,U.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/80 bg-background/45 px-3 py-2 text-sm text-muted-foreground`,children:`No storage adapters reported.`}):null]})]})]}),(0,U.jsxs)(`section`,{className:`grid gap-3 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(RF,{children:`capabilities`}),(0,U.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:Object.entries(t.capabilities).map(([e,t])=>(0,U.jsx)(Wl,{className:t?.enabled?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`,children:e},e))})]}),(0,U.jsxs)(`section`,{className:`grid min-w-0 overflow-hidden rounded-xl border border-border/80 bg-card/45`,children:[(0,U.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/80 bg-muted/20 px-4`,children:(0,U.jsx)(RF,{children:`raw summary`})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:JSON.stringify(t,null,2)})})})})]})]}):(0,U.jsx)(zF,{title:`Status unavailable`,text:`This Studio runtime did not expose status.`})})]})}function IF(e){return(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-border/80 bg-card/45 p-5`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`font-mono text-3xl font-semibold tracking-tight text-foreground`,children:e.value})]})}function LF(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-background/45 px-3 py-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,title:String(e.value),children:e.value})]})}function RF(e){return(0,U.jsx)(`h2`,{className:`m-0 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.children})}function zF(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.text})]})})}function BF(e){let t=e.agents.find(t=>t.id===e.selectedAgentId)??e.agents[0],n=e.summary?.tools??[],[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(`{}`),[s,c]=(0,v.useState)(`idle`),[l,u]=(0,v.useState)(),[d,f]=(0,v.useState)(``),p=(0,v.useMemo)(()=>n.find(e=>e.name===r)??n[0],[r,n]);(0,v.useEffect)(()=>{if(n.length===0){i(``);return}n.some(e=>e.name===r)||i(n[0]?.name??``)},[r,n]);async function m(){if(t===void 0||p===void 0)return;let e;try{e=JSON.parse(a)}catch(e){f(e instanceof Error?e.message:String(e)),u(void 0);return}c(`running`),f(``),u(void 0);try{let n=await fetch(`/agents/${encodeURIComponent(t.id)}/tools/${encodeURIComponent(p.name)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({args:e})}),r=await n.json();u(r),(!n.ok||r.status===`error`)&&f(JF(r.error??r))}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(`idle`)}}return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-background/55`,"aria-label":`Tools`,children:[(0,U.jsx)(`header`,{className:`bg-background/70 pb-5 pl-0 pr-6 pt-0 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid w-full grid-cols-[minmax(0,1fr)_auto] items-end gap-4 max-md:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsx)(`div`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.24em] text-primary`,children:`Agent capabilities`}),(0,U.jsx)(`h1`,{className:`m-0 text-2xl font-semibold leading-none tracking-tight text-foreground`,children:`Tools`}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:`Tool definitions registered on Studio agents, including approval policy and input schema.`})]}),e.agents.length>1?(0,U.jsxs)(J,{value:t?.id??``,onValueChange:e.onSelectAgent,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 w-64 rounded-lg border-border bg-card/80 font-mono text-xs max-md:w-full`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:e.agents.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):null]})}),(0,U.jsx)(`div`,{className:`min-h-0 overflow-auto pb-6 pl-0 pr-6`,children:(0,U.jsx)(`div`,{className:`grid w-full gap-4`,children:e.enabled?e.loading?(0,U.jsx)(UF,{title:`Loading tools`,message:`Reading registered tool metadata.`}):n.length===0?(0,U.jsx)(UF,{title:`No tools`,message:`The selected agent has no registered tools.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`section`,{className:`grid gap-4 rounded-xl border border-border/80 bg-card/55 p-4 shadow-sm xl:grid-cols-[minmax(300px,0.7fr)_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:`Run tool`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:`Invoke a registered tool directly with JSON arguments and inspect the raw result.`})]}),(0,U.jsxs)(J,{value:p?.name??``,onValueChange:i,children:[(0,U.jsx)(zl,{className:`h-9 min-h-9 rounded-lg border-border bg-background/80 font-mono text-xs`,children:(0,U.jsx)(Y,{placeholder:`Tool`})}),(0,U.jsx)(Bl,{children:n.map(e=>(0,U.jsx)(Vl,{value:e.name,children:e.name},`${e.source}:${e.name}`))})]}),p===void 0?null:(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-background/45 p-3`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`selected definition`}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:p.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:WF(p.source),children:p.source}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-muted/55 text-muted-foreground`,children:[KF(p.parameters),` fields`]})]})]})]}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,U.jsx)(Hl,{className:`min-h-40 resize-y rounded-lg border-border bg-background/70 p-3 font-mono text-xs leading-5`,value:a,spellCheck:!1,onChange:e=>o(e.target.value)}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:`Arguments must be valid JSON.`}),(0,U.jsx)(K,{className:`h-9 min-h-9 rounded-lg px-4 font-mono text-xs`,type:`button`,disabled:s===`running`||p===void 0,onClick:()=>void m(),children:s===`running`?`Running`:`Run`})]}),d.length>0?(0,U.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 font-mono text-xs leading-5 text-destructive`,children:d}):null,l===void 0?null:(0,U.jsx)(HF,{value:l,title:`Result`})]})]}),(0,U.jsxs)(`div`,{className:`grid gap-1 overflow-hidden rounded-xl border border-border/80 bg-card/55 p-2 shadow-sm`,children:[(0,U.jsxs)(`div`,{className:`grid min-h-10 grid-cols-[minmax(260px,0.75fr)_minmax(0,1fr)] items-center rounded-lg border border-border/60 bg-muted/20 px-4 font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground max-lg:hidden`,children:[(0,U.jsx)(`span`,{children:`Definition`}),(0,U.jsx)(`span`,{children:`Parameter schema`})]}),n.map(e=>(0,U.jsx)(VF,{tool:e},`${e.source}:${e.name}`))]})]}):(0,U.jsx)(UF,{title:`Tools unavailable`,message:`No registered Studio agent exposes static or dynamic tools.`})})})]})}function VF(e){let t=KF(e.tool.parameters);return(0,U.jsxs)(`article`,{className:`grid grid-cols-[minmax(300px,0.75fr)_minmax(0,1fr)] gap-2 rounded-lg border border-transparent bg-background/25 p-2 transition duration-200 hover:border-border/70 hover:bg-background/35 max-lg:grid-cols-1`,children:[(0,U.jsxs)(`div`,{className:`grid content-start gap-4 rounded-lg bg-card/25 p-3`,children:[(0,U.jsxs)(`div`,{className:`grid gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 truncate font-mono text-[15px] font-semibold text-foreground`,children:e.tool.name}),(0,U.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium text-muted-foreground`,children:e.tool.agentId})]}),(0,U.jsx)(`p`,{className:`m-0 max-w-[62ch] text-sm leading-6 text-muted-foreground`,children:e.tool.description}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,U.jsx)(Wl,{className:WF(e.tool.source),children:e.tool.source}),(0,U.jsxs)(Wl,{className:tr(e.tool.approval.required?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`),children:[`approval `,e.tool.approval.required?`required`:`none`]}),(0,U.jsxs)(Wl,{className:`border-border/80 bg-transparent text-muted-foreground`,children:[t,` `,t===1?`field`:`fields`]})]}),e.tool.approval.reason===void 0?null:(0,U.jsx)(`p`,{className:`m-0 rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-muted-foreground`,children:e.tool.approval.reason})]}),(0,U.jsx)(HF,{value:e.tool.parameters,title:`JSON schema`})]})}function HF(e){return(0,U.jsxs)(`section`,{className:`grid min-w-0 content-start overflow-hidden rounded-lg bg-background/45`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-3 bg-muted/20 px-4`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:e.title}),(0,U.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:GF(e.value)})]}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,U.jsx)(`pre`,{className:`m-0 max-h-96 min-w-max p-4 font-mono text-[12px] leading-5 text-foreground`,children:(0,U.jsx)(`code`,{children:(0,U.jsx)(nb,{text:qF(e.value)})})})})]})}function UF(e){return(0,U.jsx)(`div`,{className:`grid min-h-80 place-items-center rounded-xl border border-dashed border-border/80 bg-card/35 px-6 text-center`,children:(0,U.jsxs)(`div`,{className:`grid max-w-md gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 text-base font-semibold text-foreground`,children:e.title}),(0,U.jsx)(`p`,{className:`m-0 text-sm leading-6 text-muted-foreground`,children:e.message})]})})}function WF(e){return e===`dynamic`?`border-primary/35 bg-primary/10 text-primary`:`border-border/80 bg-muted/55 text-muted-foreground`}function GF(e){if(typeof e!=`object`||!e||Array.isArray(e))return`value`;let t=e.type;return typeof t==`string`?t:`object`}function KF(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e.properties;return typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length:0}function qF(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function JF(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function YF({className:e,...t}){return(0,U.jsx)(`div`,{className:tr(`rounded-xl border border-border/80 bg-card/95 text-card-foreground shadow-sm shadow-black/20`,e),...t})}function XF(e,t){return v.useReducer((e,n)=>t[e][n]??e,e)}var ZF=`ScrollArea`,[QF,$F]=sr(ZF),[eI,tI]=QF(ZF),nI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=v.useState(null),[l,u]=v.useState(null),[d,f]=v.useState(null),[p,m]=v.useState(null),[h,g]=v.useState(null),[_,y]=v.useState(0),[b,x]=v.useState(0),[S,C]=v.useState(!1),[w,T]=v.useState(!1),E=ut(t,e=>c(e)),D=_r(i);return(0,U.jsx)(eI,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,U.jsx)(vr.div,{dir:D,...o,ref:E,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})});nI.displayName=ZF;var rI=`ScrollAreaViewport`,iI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=tI(rI,n),s=ut(t,v.useRef(null),o.onViewportChange);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,U.jsx)(vr.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,U.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})});iI.displayName=rI;var aI=`ScrollAreaScrollbar`,oI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=tI(aI,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return v.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,U.jsx)(sI,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,U.jsx)(cI,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,U.jsx)(lI,{...r,ref:t,forceMount:n}):i.type===`always`?(0,U.jsx)(uI,{...r,ref:t}):null});oI.displayName=aI;var sI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=tI(aI,e.__scopeScrollArea),[a,o]=v.useState(!1);return v.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},r=()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,U.jsx)(aP,{present:n||a,children:(0,U.jsx)(lI,{"data-state":a?`visible`:`hidden`,...r,ref:t})})}),cI=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=tI(aI,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=AI(()=>c(`SCROLL_END`),100),[s,c]=XF(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return v.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),v.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r};return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,U.jsx)(aP,{present:n||s!==`hidden`,children:(0,U.jsx)(uI,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:ar(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:ar(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})}),lI=v.forwardRef((e,t)=>{let n=tI(aI,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=v.useState(!1),s=e.orientation===`horizontal`,c=AI(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return jI(n.viewport,c),jI(n.content,c),(0,U.jsx)(aP,{present:r||a,children:(0,U.jsx)(uI,{"data-state":a?`visible`:`hidden`,...i,ref:t})})}),uI=v.forwardRef((e,t)=>{let{orientation:n=`vertical`,...r}=e,i=tI(aI,e.__scopeScrollArea),a=v.useRef(null),o=v.useRef(0),[s,c]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=CI(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:e=>a.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function d(e,t){return TI(e,o.current,s,t)}return n===`horizontal`?(0,U.jsx)(dI,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=EI(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,U.jsx)(fI,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=EI(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null}),dI=v.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=tI(aI,e.__scopeScrollArea),[o,s]=v.useState(),c=v.useRef(null),l=ut(t,c,a.onScrollbarXChange);return v.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(hI,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":wI(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),OI(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:SI(o.paddingLeft),paddingEnd:SI(o.paddingRight)}})}})}),fI=v.forwardRef((e,t)=>{let{sizes:n,onSizesChange:r,...i}=e,a=tI(aI,e.__scopeScrollArea),[o,s]=v.useState(),c=v.useRef(null),l=ut(t,c,a.onScrollbarYChange);return v.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,U.jsx)(hI,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":wI(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),OI(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:SI(o.paddingTop),paddingEnd:SI(o.paddingBottom)}})}})}),[pI,mI]=QF(aI),hI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=tI(aI,n),[m,h]=v.useState(null),g=ut(t,e=>h(e)),_=v.useRef(null),y=v.useRef(``),b=p.viewport,x=r.content-r.viewport,S=br(u),C=br(c),w=AI(d,10);function T(e){_.current&&l({x:e.clientX-_.current.left,y:e.clientY-_.current.top})}return v.useEffect(()=>{let e=e=>{let t=e.target;m?.contains(t)&&S(e,x)};return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),v.useEffect(C,[r,C]),jI(m,w),jI(p.content,w),(0,U.jsx)(pI,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:br(a),onThumbPointerUp:br(o),onThumbPositionChange:C,onThumbPointerDown:br(s),children:(0,U.jsx)(vr.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:ar(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),T(e))}),onPointerMove:ar(e.onPointerMove,T),onPointerUp:ar(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})}),gI=`ScrollAreaThumb`,_I=v.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=mI(gI,e.__scopeScrollArea);return(0,U.jsx)(aP,{present:n||i.hasThumb,children:(0,U.jsx)(vI,{ref:t,...r})})}),vI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:r,...i}=e,a=tI(gI,n),o=mI(gI,n),{onThumbPositionChange:s}=o,c=ut(t,e=>o.onThumbChange(e)),l=v.useRef(void 0),u=AI(()=>{l.current&&=(l.current(),void 0)},100);return v.useEffect(()=>{let e=a.viewport;if(e){let t=()=>{u(),l.current||(l.current=kI(e,s),s())};return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,U.jsx)(vr.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:ar(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:ar(e.onPointerUp,o.onThumbPointerUp)})});_I.displayName=gI;var yI=`ScrollAreaCorner`,bI=v.forwardRef((e,t)=>{let n=tI(yI,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,U.jsx)(xI,{...e,ref:t}):null});bI.displayName=yI;var xI=v.forwardRef((e,t)=>{let{__scopeScrollArea:n,...r}=e,i=tI(yI,n),[a,o]=v.useState(0),[s,c]=v.useState(0),l=!!(a&&s);return jI(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),jI(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),l?(0,U.jsx)(vr.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null});function SI(e){return e?parseInt(e,10):0}function CI(e,t){let n=e/t;return isNaN(n)?0:n}function wI(e){let t=CI(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function TI(e,t,n,r=`ltr`){let i=wI(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return DI([c,l],d)(e)}function EI(e,t,n=`ltr`){let r=wI(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=ir(e,n===`ltr`?[0,o]:[o*-1,0]);return DI([0,o],[0,s])(c)}function DI(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function OI(e,t){return e>0&&e<t}var kI=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)};function AI(e,t){let n=br(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function jI(e,t){let n=br(t);ei(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}var MI=nI,NI=iI,PI=bI;function FI({className:e,children:t,...n}){return(0,U.jsxs)(MI,{className:tr(`relative overflow-hidden`,e),...n,children:[(0,U.jsx)(NI,{className:`h-full w-full rounded-[inherit]`,children:t}),(0,U.jsx)(II,{}),(0,U.jsx)(PI,{})]})}function II({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(oI,{orientation:t,className:tr(`flex touch-none select-none transition-colors`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent p-px`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent p-px`,e),...n,children:(0,U.jsx)(_I,{className:`relative flex-1 rounded-lg bg-muted-foreground/40`})})}function LI(e){if(!e.tracesEnabled)return(0,U.jsx)(`div`,{className:`w-full rounded-lg border border-dashed border-border p-8 text-sm font-medium text-muted-foreground`,children:`Tracing is disabled`});let t=e.selectedTraceId.length===0?void 0:e.traces.find(t=>t.id===e.selectedTraceId),n=t===void 0||e.traceSessionDetailId!==t.sessionId?[]:e.traces.filter(e=>e.sessionId===t.sessionId);return(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full content-stretch pb-6 pl-0 pr-6`,"aria-label":`Tracing`,children:e.selectedTraceId.length===0?(0,U.jsx)(RI,{agents:e.agents,traces:e.traces,traceLoadState:e.traceLoadState,onSelectTrace:e.onSelectTrace}):(0,U.jsx)(zI,{selectedTrace:t,selectedSessionTraces:n,selectedTraceId:e.selectedTraceId,traceLoadState:e.traceLoadState,onBack:()=>e.onSelectTrace(``),onShowSessionTraces:e.onShowSessionTraces})})}function RI(e){return(0,U.jsx)(YF,{className:`min-h-0 overflow-hidden rounded-xl border-border/80 bg-card/80`,"aria-label":`Traces`,children:(0,U.jsx)(FI,{className:`h-full min-h-0`,children:(0,U.jsxs)(`div`,{className:`grid min-w-280 gap-1 p-2`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 grid min-h-11 grid-cols-[minmax(220px,1.3fr)_150px_120px_120px_120px_120px_110px_90px] items-center gap-4 rounded-lg border border-border/60 bg-card/95 px-4 font-mono text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Trace`}),(0,U.jsx)(`span`,{children:`Session`}),(0,U.jsx)(`span`,{children:`Agent`}),(0,U.jsx)(`span`,{children:`Status`}),(0,U.jsx)(`span`,{children:`Started`}),(0,U.jsx)(`span`,{children:`Duration`}),(0,U.jsx)(`span`,{children:`First delta`}),(0,U.jsx)(`span`,{children:`Events`})]}),e.traceLoadState===`loading`&&e.traces.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`Loading traces`}):null,e.traceLoadState===`idle`&&e.traces.length===0?(0,U.jsx)(`div`,{className:`px-5 py-4 text-sm font-medium text-muted-foreground`,children:`No traces found`}):null,e.traces.map(t=>(0,U.jsxs)(K,{className:`grid h-auto min-h-14 w-full grid-cols-[minmax(220px,1.3fr)_150px_120px_120px_120px_120px_110px_90px] items-center justify-start gap-4 whitespace-normal rounded-lg border border-transparent bg-transparent px-4 py-2.5 text-left text-muted-foreground shadow-none transition duration-200 hover:border-primary/20 hover:bg-accent/70 hover:text-accent-foreground`,type:`button`,variant:`ghost`,onClick:()=>e.onSelectTrace(t.id),children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium text-muted-foreground`,children:t.id}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs font-medium`,children:t.sessionId}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Gy(e.agents,t)}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-xs font-medium capitalize`,children:[(0,U.jsx)(`span`,{className:tr(`h-2.5 w-2.5 shrink-0 rounded-lg`,NL(t.status))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t.status})]}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:Vy(t.startedAt)}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:qy(Hy(t.durationMs))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:qy(Hy(jL(t.observations)))}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium tabular-nums`,children:t.observationCount})]},t.id))]})})})}function zI(e){return(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] gap-2 overflow-hidden rounded-xl border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsxs)(`header`,{className:`grid min-h-16 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 overflow-hidden rounded-lg border border-border/60 bg-card/95 px-4 py-3`,children:[(0,U.jsx)(K,{"aria-label":`Back to traces`,className:`h-8 min-h-8 w-8 text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,onClick:e.onBack,children:(0,U.jsx)(pe,{"aria-hidden":`true`})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-semibold text-foreground`,children:e.selectedTrace?.name??`Trace detail`}),(0,U.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 overflow-hidden text-xs font-medium text-muted-foreground`,children:e.selectedTrace===void 0?e.traceLoadState===`loading`?`Loading trace`:`Trace not found`:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:tr(`h-2 w-2 shrink-0 rounded-lg`,NL(e.selectedTrace.status))}),(0,U.jsx)(`span`,{className:`shrink-0 capitalize`,children:e.selectedTrace.status}),(0,U.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:`/`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Session`,` `,(0,U.jsx)(`span`,{className:`font-mono font-semibold`,children:e.selectedTrace.sessionId})]})]})})]}),(0,U.jsx)(`span`,{className:`hidden max-w-[42vw] truncate rounded-lg bg-muted px-2 py-1 font-mono text-xs font-medium text-muted-foreground md:block`,children:e.selectedTraceId})]}),(0,U.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden`,children:e.selectedTrace===void 0?(0,U.jsx)(YF,{className:`grid h-full place-items-center rounded-lg border-border bg-card p-6 text-sm font-medium text-muted-foreground`,children:e.traceLoadState===`loading`?`Loading trace`:`Trace not found`}):(0,U.jsx)(BI,{traces:e.selectedSessionTraces.length>0?e.selectedSessionTraces:[e.selectedTrace],onShowSessionTraces:e.onShowSessionTraces})})]})}function BI(e){let t=(0,v.useMemo)(()=>[...e.traces].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)),[e.traces]),n=t[0]?.id??``,[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(`trace`);(0,v.useEffect)(()=>{i(n),o(`trace`)},[n]);let s=t.find(e=>e.id===r)??t[0],c=s===void 0?[]:gL(s),l=(e,t)=>{i(e),o(t)};return s===void 0?(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full place-items-center text-sm font-medium text-muted-foreground`,"aria-label":`Traces`,children:`No trace selected`}):(0,U.jsx)(`section`,{className:`grid h-full min-h-0 w-full content-stretch overflow-hidden`,"aria-label":`Traces`,children:(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-[320px_minmax(0,1fr)] overflow-hidden max-md:grid-cols-1`,children:[(0,U.jsxs)(`nav`,{className:`grid min-h-0 auto-rows-min content-start overflow-auto border-r border-border/80 bg-card/35 pr-2 max-md:max-h-80 max-md:border-b max-md:border-r-0`,"aria-label":`Trace timeline`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-30 flex min-h-11 items-center justify-between bg-card/90 py-0 pl-0 pr-5 text-xs font-medium text-muted-foreground backdrop-blur`,children:[(0,U.jsx)(`span`,{children:`Search`}),(0,U.jsx)(`strong`,{className:`text-foreground`,children:`Timeline`})]}),t.map(e=>{let t=s.id===e.id,n=gL(e);return(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(VI,{active:t&&a===`trace`,ancestorLevels:[],hasChildren:!0,isLastSibling:!0,level:0,tone:`trace`,title:e.name??`Agent`,subtitle:Hy(e.durationMs),onSelect:()=>l(e.id,`trace`)}),(0,U.jsx)(VI,{active:t&&a===`agent`,ancestorLevels:[],hasChildren:n.length>0,isLastSibling:!0,level:1,tone:`agent`,title:`agent.run`,subtitle:Hy(e.durationMs),onSelect:()=>l(e.id,`agent`)}),n.map(r=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(VI,{active:t&&a===`turn:${r.turn}`,ancestorLevels:[],hasChildren:r.observations.length>0,isLastSibling:r.turn===n.at(-1)?.turn,level:2,tone:`turn`,title:`turn.${r.turn}`,subtitle:Hy(r.durationMs),onSelect:()=>l(e.id,`turn:${r.turn}`)}),(0,U.jsx)(HI,{activeKey:a,isLastTurn:r.turn===n.at(-1)?.turn,observations:r.observations,onSelect:t=>l(e.id,`observation:${t}`),traceActive:t})]},`${e.id}:turn:${r.turn}`))]},e.id)})]}),(0,U.jsx)(WI,{trace:s,turns:c,activeKey:a,onShowSessionTraces:e.onShowSessionTraces})]})})}function VI(e){let t=e=>22+e*22;return(0,U.jsxs)(K,{className:tr(`relative grid h-auto min-h-0 w-full min-w-0 grid-cols-[20px_minmax(0,1fr)] items-start justify-start gap-2 whitespace-normal rounded-lg border-0 bg-transparent px-3 py-2.5 text-left text-muted-foreground shadow-none transition duration-200 hover:bg-accent/70 hover:text-accent-foreground`,e.active&&`bg-primary/10 text-primary hover:bg-primary/10 hover:text-primary`),type:`button`,variant:`ghost`,onClick:e.onSelect,style:{paddingLeft:`${12+e.level*22}px`},children:[e.ancestorLevels.map(e=>(0,U.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 w-px bg-muted-foreground/35`,style:{left:`${t(e)}px`},"aria-hidden":`true`},`ancestor-line-${e}`)),e.level>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`pointer-events-none absolute top-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,height:`18px`},"aria-hidden":`true`}),e.isLastSibling?null:(0,U.jsx)(`span`,{className:`pointer-events-none absolute bottom-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,top:`18px`},"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`pointer-events-none absolute h-px bg-muted-foreground/35`,style:{left:`${t(e.level-1)}px`,top:`18px`,width:`22px`},"aria-hidden":`true`})]}):null,e.hasChildren?(0,U.jsx)(`span`,{className:`pointer-events-none absolute bottom-0 w-px bg-muted-foreground/35`,style:{left:`${t(e.level)}px`,top:`18px`},"aria-hidden":`true`}):null,(0,U.jsx)(`span`,{className:tr(`relative z-10 grid h-5 w-5 place-items-center rounded-lg bg-transparent [&_svg]:h-3 [&_svg]:w-3 [&_svg]:opacity-100`,FL(e.tone)),children:(0,U.jsx)(PL,{tone:e.tone})}),(0,U.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,U.jsx)(`strong`,{className:`min-w-0 truncate text-sm font-medium leading-5 text-current`,children:e.title}),(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:e.subtitle})]})]})}function HI(e){let t=_L(e.observations);return(0,U.jsx)(U.Fragment,{children:t.map((n,r)=>(0,U.jsx)(UI,{activeKey:e.activeKey,ancestorLevels:e.isLastTurn?[]:[1],isLastSibling:r===t.length-1,level:3,node:n,onSelect:e.onSelect,traceActive:e.traceActive},n.observation.id))})}function UI(e){let t=IL(e.node.observation),n=e.isLastSibling?e.ancestorLevels:[...e.ancestorLevels,e.level];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(VI,{active:e.traceActive&&e.activeKey===`observation:${e.node.observation.id}`,ancestorLevels:e.ancestorLevels,hasChildren:e.node.children.length>0,isLastSibling:e.isLastSibling,level:e.level,tone:e.node.observation.kind,title:AL(e.node.observation),subtitle:t.length>0?`${Hy(e.node.observation.durationMs)} · ${t}`:Hy(e.node.observation.durationMs),onSelect:()=>e.onSelect(e.node.observation.id)}),e.node.children.map((t,r)=>(0,U.jsx)(UI,{activeKey:e.activeKey,ancestorLevels:n,isLastSibling:r===e.node.children.length-1,level:e.level+1,node:t,onSelect:e.onSelect,traceActive:e.traceActive},t.observation.id))]})}function WI(e){let t=vL(e.trace,e.turns,e.activeKey);return(0,U.jsxs)(`section`,{className:`grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-card/70`,"aria-label":`Trace detail`,children:[(0,U.jsx)(`header`,{className:`border-b border-border/60 bg-card/70 px-6 py-5`,children:(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,U.jsx)(`div`,{className:`flex min-w-0 items-start justify-between gap-4`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(`span`,{className:tr(`grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-primary text-primary-foreground [&_svg]:h-4 [&_svg]:w-4 [&_svg]:opacity-100`,t.tone!==`trace`&&`bg-muted text-foreground`,FL(t.tone)),children:(0,U.jsx)(PL,{tone:t.tone})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,U.jsx)(`h2`,{className:`m-0 min-w-0 truncate text-2xl font-semibold leading-none tracking-[-0.01em] text-foreground`,children:t.title}),(0,U.jsx)(`div`,{className:`font-mono text-xs font-medium text-muted-foreground`,children:t.startedAt})]})]})}),(0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-2`,children:[(0,U.jsx)(GI,{label:`Duration`,value:Hy(t.durationMs)}),t.firstDeltaMs===void 0?null:(0,U.jsx)(GI,{label:`First delta`,value:Hy(t.firstDeltaMs)}),t.usage.length===0?null:(0,U.jsx)(GI,{label:`Usage`,value:t.usage}),(0,U.jsxs)(`button`,{className:`grid min-w-0 gap-1 rounded-lg bg-card/85 px-4 py-3 text-left transition duration-200 hover:bg-accent hover:text-accent-foreground`,type:`button`,onClick:()=>e.onShowSessionTraces(e.trace.sessionId),children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:`Session`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-current`,children:e.trace.sessionId})]})]})]})}),(0,U.jsx)(`div`,{className:`min-w-0 overflow-auto`,children:(0,U.jsxs)(`div`,{className:`grid min-w-0 content-start gap-6 p-6`,children:[t.input===void 0?null:(0,U.jsx)(KI,{title:`Input`,value:t.input}),t.output===void 0?null:(0,U.jsx)(KI,{title:`Output`,value:t.output,tone:`success`}),t.error===void 0?null:(0,U.jsx)(KI,{title:`Error`,value:t.error,tone:`error`}),(0,U.jsx)(KI,{title:`Metadata`,value:t.metadata,rawJson:!0})]})})]})}function GI(e){return(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-1 rounded-lg bg-card/85 px-4 py-3`,children:[(0,U.jsx)(`span`,{className:`font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:e.label}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-sm font-semibold text-foreground`,children:e.value})]})}function KI(e){let t=sL(e.title,e.value);return(0,U.jsxs)(`section`,{className:`grid min-w-0 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`h3`,{className:`m-0 text-lg font-semibold leading-tight text-foreground`,children:e.title}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-border/80`,"aria-hidden":`true`})]}),e.rawJson?(0,U.jsx)(XI,{value:e.value}):(0,U.jsx)(`div`,{className:`grid min-w-0 gap-3`,children:t.map(t=>(0,U.jsxs)(`article`,{className:tr(`grid min-w-0 gap-3 rounded-lg bg-card/85 px-4 py-4`,e.compact&&`grid-cols-[150px_minmax(0,1fr)] items-start gap-4 max-lg:grid-cols-1`),children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-mono text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:[(0,U.jsx)(oL,{label:t.label}),t.label]}),(0,U.jsx)(qI,{compact:e.compact,item:t,tone:e.tone})]},`${t.label}-${t.text}`))})]})}function qI(e){let t=JI(e.item);return t.length>0?(0,U.jsx)(`div`,{className:`grid min-w-0 gap-5`,children:t.map(e=>(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs font-semibold tabular-nums text-muted-foreground`,children:e.index}),(0,U.jsx)(Wl,{className:tr(`px-1.5 py-0.5`,e.role===`User`&&`border-chart-2/40 bg-chart-2/15 text-chart-2`,e.role===`Assistant`&&`border-chart-1/40 bg-chart-1/15 text-chart-1`,e.role===`Tool`&&`border-chart-5/40 bg-chart-5/15 text-chart-5`),children:e.role})]}),(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap text-[15px] leading-7 text-foreground [overflow-wrap:anywhere]`,children:e.text})]},`${e.index}-${e.role}-${e.text}`))}):(0,U.jsx)(`p`,{className:tr(`m-0 whitespace-pre-wrap text-[15px] leading-7 text-foreground [overflow-wrap:anywhere]`,e.compact&&`font-mono text-[13px] leading-6`,e.tone===`success`&&!aL(e.item)&&`text-primary`,e.tone===`error`&&`text-destructive`),children:e.item.text})}function JI(e){return e.label.startsWith(`Conversation history`)?e.text.split(`
92
92
 
93
93
  `).flatMap(e=>{let[t,...n]=e.split(`
94
94
  `),r=/^(\d+)\.\s+(.+)$/.exec(t??``);return r===null?[]:[{index:r[1]??``,role:r[2]??`Message`,text:n.join(`
95
- `)}]}):[]}function JI(e){try{return JSON.stringify(e,null,2)??`undefined`}catch{return String(e)}}function YI(e){return(0,U.jsx)(`div`,{className:`overflow-x-auto rounded-lg bg-card/85 px-4 py-4 font-mono text-[13px] leading-6 text-foreground`,children:(0,U.jsx)(QI,{depth:0,path:`$`,value:e.value})})}var XI=16,ZI=20;function QI(e){return rL(e.value)?(0,U.jsx)($I,{arrayIndex:e.arrayIndex,depth:e.depth,path:e.path,propertyKey:e.propertyKey,trailingComma:e.trailingComma,value:e.value}):(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre`,style:{paddingLeft:`${eL(e.depth)}px`},children:[(0,U.jsx)(tL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),(0,U.jsx)(nL,{value:e.value}),e.trailingComma?(0,U.jsx)(`span`,{className:`text-foreground`,children:`,`}):null]})}function $I(e){let[t,n]=(0,v.useState)(e.depth===0),r=Array.isArray(e.value)?e.value:void 0,i=r===void 0?Object.entries(e.value):r.map((e,t)=>[String(t),e]),a=r===void 0?`{`:`[`,o=r===void 0?`}`:`]`,s=r===void 0?`{…}`:`[…]`;return i.length===0?(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre`,style:{paddingLeft:`${eL(e.depth)}px`},children:[(0,U.jsx)(tL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),(0,U.jsxs)(`span`,{className:`text-foreground`,children:[a,o,e.trailingComma?`,`:``]})]}):(0,U.jsxs)(`div`,{className:`grid min-w-max`,children:[(0,U.jsxs)(`button`,{"aria-expanded":t,className:`grid min-w-max grid-cols-[16px_auto] items-center gap-1 rounded-lg py-0.5 pr-2 text-left transition duration-200 hover:bg-accent/45 hover:text-accent-foreground`,onClick:()=>n(e=>!e),style:{paddingLeft:`${e.depth*XI}px`},type:`button`,children:[(0,U.jsx)(`span`,{className:`grid h-4 w-4 place-items-center text-muted-foreground [&_svg]:h-3 [&_svg]:w-3`,children:t?(0,U.jsx)(ye,{"aria-hidden":`true`}):(0,U.jsx)(xe,{"aria-hidden":`true`})}),(0,U.jsxs)(`span`,{className:`whitespace-pre`,children:[(0,U.jsx)(tL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),t?(0,U.jsx)(`span`,{className:`text-foreground`,children:a}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:s}),!t&&e.trailingComma?(0,U.jsx)(`span`,{className:`text-foreground`,children:`,`}):null]})]}),t?(0,U.jsxs)(U.Fragment,{children:[i.map(([t,n],a)=>(0,U.jsx)(QI,{arrayIndex:r===void 0?void 0:Number(t),depth:e.depth+1,path:`${e.path}.${t}`,propertyKey:r===void 0?t:void 0,trailingComma:a<i.length-1,value:n},`${e.path}.${t}`)),(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre text-foreground`,style:{paddingLeft:`${eL(e.depth)}px`},children:[o,e.trailingComma?`,`:``]})]}):null]})}function eL(e){return e*XI+ZI}function tL(e){return e.propertyKey===void 0?e.arrayIndex===void 0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[`,e.arrayIndex,`]`]}),(0,U.jsx)(`span`,{className:`text-foreground`,children:` `})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-chart-2`,children:JSON.stringify(e.propertyKey)}),(0,U.jsx)(`span`,{className:`text-foreground`,children:`: `})]})}function nL(e){return typeof e.value==`string`?(0,U.jsx)(`span`,{className:`text-primary`,children:JSON.stringify(e.value)}):typeof e.value==`number`?(0,U.jsx)(`span`,{className:`text-chart-1`,children:String(e.value)}):typeof e.value==`boolean`?(0,U.jsx)(`span`,{className:`text-chart-4`,children:String(e.value)}):e.value===null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`null`}):e.value===void 0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`undefined`}):(0,U.jsx)(`span`,{className:`text-foreground`,children:JI(e.value)})}function rL(e){return Array.isArray(e)||Ry(e)}function iL(e){return e.label===`Message Id`}function aL(e){let t=`h-3.5 w-3.5 shrink-0`;switch(e.label){case`System prompt`:return(0,U.jsx)(Fe,{"aria-hidden":`true`,className:t});case`Prompt`:return(0,U.jsx)(Ce,{"aria-hidden":`true`,className:t});case`Output`:case`Assistant output`:return(0,U.jsx)(ue,{"aria-hidden":`true`,className:t});default:return null}}function oL(e,t){if(e===`Output`){let e=sL(t);if(e.length>0)return e}let n=cL(t,e);if(n.length>0)return n;if(!Ry(t))return[{label:e,text:mL(t)}];let r=[];for(let[e,n]of Object.entries(t)){let t=cL(n,e);if(t.length>0){r.push(...t);continue}r.push({label:fL(e),text:mL(n)})}return r.length>0?r:[{label:e,text:`Empty object`}]}function sL(e){if(!Ry(e))return[];let t=[],n=cL(e.choice,`choice`);return t.push(...n),typeof e.messageId==`string`&&e.messageId.length>0&&t.push({label:`Message Id`,text:e.messageId}),t}function cL(e,t){if(typeof e==`string`&&t===void 0)return[{label:`Value`,text:e}];if(Array.isArray(e))return t===`chatHistory`?lL(e):t===`history`?uL(e):e.map((e,n)=>({label:dL(e,n,t),text:OF(e)||Yy(e)})).filter(e=>e.text.length>0);if(!Ry(e))return[];let n=Array.isArray(e.chatHistory)?e.chatHistory:void 0;if(n!==void 0){let t=pL(e);return t.push(...cL(n,`chatHistory`)),t}if(Array.isArray(e.prompt))return cL(e.prompt,`prompt`);let r=[];r.push(...pL(e));let i=Array.isArray(e.history)?e.history:[];i.length>0&&r.push(...cL(i,`history`));let a=OF(e.prompt);return a.length>0&&r.push({label:i.length>0?`Current prompt`:`Prompt`,text:a}),r}function lL(e){let t=e.map((e,t)=>({label:dL(e,t,`chatHistory`),text:OF(e)||Yy(e)})).filter(e=>e.text.length>0),n=t.at(-1),r=t.slice(0,-1),i=[];return r.length>0&&i.push({label:`Conversation history (${r.length})`,text:r.map((e,t)=>`${t+1}. ${e.label}\n${e.text}`).join(`
95
+ `)}]}):[]}function YI(e){try{return JSON.stringify(e,null,2)??`undefined`}catch{return String(e)}}function XI(e){return(0,U.jsx)(`div`,{className:`overflow-x-auto rounded-lg bg-card/85 px-4 py-4 font-mono text-[13px] leading-6 text-foreground`,children:(0,U.jsx)($I,{depth:0,path:`$`,value:e.value})})}var ZI=16,QI=20;function $I(e){return iL(e.value)?(0,U.jsx)(eL,{arrayIndex:e.arrayIndex,depth:e.depth,path:e.path,propertyKey:e.propertyKey,trailingComma:e.trailingComma,value:e.value}):(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre`,style:{paddingLeft:`${tL(e.depth)}px`},children:[(0,U.jsx)(nL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),(0,U.jsx)(rL,{value:e.value}),e.trailingComma?(0,U.jsx)(`span`,{className:`text-foreground`,children:`,`}):null]})}function eL(e){let[t,n]=(0,v.useState)(e.depth===0),r=Array.isArray(e.value)?e.value:void 0,i=r===void 0?Object.entries(e.value):r.map((e,t)=>[String(t),e]),a=r===void 0?`{`:`[`,o=r===void 0?`}`:`]`,s=r===void 0?`{…}`:`[…]`;return i.length===0?(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre`,style:{paddingLeft:`${tL(e.depth)}px`},children:[(0,U.jsx)(nL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),(0,U.jsxs)(`span`,{className:`text-foreground`,children:[a,o,e.trailingComma?`,`:``]})]}):(0,U.jsxs)(`div`,{className:`grid min-w-max`,children:[(0,U.jsxs)(`button`,{"aria-expanded":t,className:`grid min-w-max grid-cols-[16px_auto] items-center gap-1 rounded-lg py-0.5 pr-2 text-left transition duration-200 hover:bg-accent/45 hover:text-accent-foreground`,onClick:()=>n(e=>!e),style:{paddingLeft:`${e.depth*ZI}px`},type:`button`,children:[(0,U.jsx)(`span`,{className:`grid h-4 w-4 place-items-center text-muted-foreground [&_svg]:h-3 [&_svg]:w-3`,children:t?(0,U.jsx)(ye,{"aria-hidden":`true`}):(0,U.jsx)(xe,{"aria-hidden":`true`})}),(0,U.jsxs)(`span`,{className:`whitespace-pre`,children:[(0,U.jsx)(nL,{arrayIndex:e.arrayIndex,propertyKey:e.propertyKey}),t?(0,U.jsx)(`span`,{className:`text-foreground`,children:a}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:s}),!t&&e.trailingComma?(0,U.jsx)(`span`,{className:`text-foreground`,children:`,`}):null]})]}),t?(0,U.jsxs)(U.Fragment,{children:[i.map(([t,n],a)=>(0,U.jsx)($I,{arrayIndex:r===void 0?void 0:Number(t),depth:e.depth+1,path:`${e.path}.${t}`,propertyKey:r===void 0?t:void 0,trailingComma:a<i.length-1,value:n},`${e.path}.${t}`)),(0,U.jsxs)(`div`,{className:`min-w-max whitespace-pre text-foreground`,style:{paddingLeft:`${tL(e.depth)}px`},children:[o,e.trailingComma?`,`:``]})]}):null]})}function tL(e){return e*ZI+QI}function nL(e){return e.propertyKey===void 0?e.arrayIndex===void 0?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`[`,e.arrayIndex,`]`]}),(0,U.jsx)(`span`,{className:`text-foreground`,children:` `})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-chart-2`,children:JSON.stringify(e.propertyKey)}),(0,U.jsx)(`span`,{className:`text-foreground`,children:`: `})]})}function rL(e){return typeof e.value==`string`?(0,U.jsx)(`span`,{className:`text-primary`,children:JSON.stringify(e.value)}):typeof e.value==`number`?(0,U.jsx)(`span`,{className:`text-chart-1`,children:String(e.value)}):typeof e.value==`boolean`?(0,U.jsx)(`span`,{className:`text-chart-4`,children:String(e.value)}):e.value===null?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`null`}):e.value===void 0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`undefined`}):(0,U.jsx)(`span`,{className:`text-foreground`,children:YI(e.value)})}function iL(e){return Array.isArray(e)||Ry(e)}function aL(e){return e.label===`Message Id`}function oL(e){let t=`h-3.5 w-3.5 shrink-0`;switch(e.label){case`System prompt`:return(0,U.jsx)(Fe,{"aria-hidden":`true`,className:t});case`Prompt`:return(0,U.jsx)(Ce,{"aria-hidden":`true`,className:t});case`Output`:case`Assistant output`:return(0,U.jsx)(ue,{"aria-hidden":`true`,className:t});default:return null}}function sL(e,t){if(e===`Output`){let e=cL(t);if(e.length>0)return e}let n=lL(t,e);if(n.length>0)return n;if(!Ry(t))return[{label:e,text:hL(t)}];let r=[];for(let[e,n]of Object.entries(t)){let t=lL(n,e);if(t.length>0){r.push(...t);continue}r.push({label:pL(e),text:hL(n)})}return r.length>0?r:[{label:e,text:`Empty object`}]}function cL(e){if(!Ry(e))return[];let t=[],n=lL(e.choice,`choice`);return t.push(...n),typeof e.messageId==`string`&&e.messageId.length>0&&t.push({label:`Message Id`,text:e.messageId}),t}function lL(e,t){if(typeof e==`string`&&t===void 0)return[{label:`Value`,text:e}];if(Array.isArray(e))return t===`chatHistory`?uL(e):t===`history`?dL(e):e.map((e,n)=>({label:fL(e,n,t),text:kF(e)||Yy(e)})).filter(e=>e.text.length>0);if(!Ry(e))return[];let n=Array.isArray(e.chatHistory)?e.chatHistory:void 0;if(n!==void 0){let t=mL(e);return t.push(...lL(n,`chatHistory`)),t}if(Array.isArray(e.prompt))return lL(e.prompt,`prompt`);let r=[];r.push(...mL(e));let i=Array.isArray(e.history)?e.history:[];i.length>0&&r.push(...lL(i,`history`));let a=kF(e.prompt);return a.length>0&&r.push({label:i.length>0?`Current prompt`:`Prompt`,text:a}),r}function uL(e){let t=e.map((e,t)=>({label:fL(e,t,`chatHistory`),text:kF(e)||Yy(e)})).filter(e=>e.text.length>0),n=t.at(-1),r=t.slice(0,-1),i=[];return r.length>0&&i.push({label:`Conversation history (${r.length})`,text:r.map((e,t)=>`${t+1}. ${e.label}\n${e.text}`).join(`
96
96
 
97
- `)}),n!==void 0&&i.push({label:r.length>0?`Current prompt`:`Prompt`,text:n.text}),i}function uL(e){let t=e.map((e,t)=>({label:dL(e,t,`history`),text:OF(e)||Yy(e)})).filter(e=>e.text.length>0);return t.length===0?[]:[{label:`Conversation history (${t.length})`,text:t.map((e,t)=>`${t+1}. ${e.label}\n${e.text}`).join(`
97
+ `)}),n!==void 0&&i.push({label:r.length>0?`Current prompt`:`Prompt`,text:n.text}),i}function dL(e){let t=e.map((e,t)=>({label:fL(e,t,`history`),text:kF(e)||Yy(e)})).filter(e=>e.text.length>0);return t.length===0?[]:[{label:`Conversation history (${t.length})`,text:t.map((e,t)=>`${t+1}. ${e.label}\n${e.text}`).join(`
98
98
 
99
- `)}]}function dL(e,t,n){if(Ry(e)){let t=typeof e.type==`string`?e.type:void 0;if(n===`choice`){if(t===`text`)return`Assistant output`;if(t===`reasoning`)return`Reasoning`}if(t===`reasoning`)return`Reasoning`;if(typeof e.role==`string`)return fL(e.role);if(t!==void 0)return fL(t)}return`${n===void 0?`Item`:`${fL(n)} item`} ${t+1}`}function fL(e){return e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).trim().replace(/\b\w/g,e=>e.toUpperCase())}function pL(e){let t=e.instructions;return typeof t!=`string`||t.trim().length===0?[]:[{label:`System prompt`,text:t}]}function mL(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function hL(e){let t=new Map;for(let n of e.observations){let e=Number.isFinite(n.turn)?n.turn:t.size+1;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].sort(([e],[t])=>e-t).map(([e,t])=>({turn:e,observations:t,durationMs:t.reduce((e,t)=>e+(t.durationMs??0),0)}))}function gL(e){let t=new Map;for(let n of e)t.set(n.id,{observation:n,children:[]});let n=[];for(let r of e){let e=t.get(r.id);if(e===void 0)continue;let i=r.parentObservationId,a=i===void 0?void 0:t.get(i);a===void 0?n.push(e):a.children.push(e)}return n}function _L(e,t,n){if(n===`agent`)return{title:`agent.run`,tone:`agent`,startedAt:By(e.startedAt),durationMs:e.durationMs,firstDeltaMs:AL(e.observations),usage:Uy(e.usage),input:e.input,output:e.output,error:e.error,metadata:vL(e)};if(n.startsWith(`turn:`)){let r=Number(n.slice(5)),i=t.find(e=>e.turn===r);return{title:`turn.${Number.isFinite(r)?r:1}`,tone:`turn`,startedAt:By(i?.observations[0]?.startedAt??e.startedAt),durationMs:i?.durationMs,firstDeltaMs:AL(i?.observations??[]),usage:IL(i?.observations??[]),input:i?.observations[0]?.input,output:i?.observations.at(-1)?.output,metadata:yL(r,i?.observations??[])}}if(n.startsWith(`observation:`)){let t=n.slice(12),r=e.observations.find(e=>e.id===t);if(r!==void 0)return{title:kL(r),tone:r.kind,startedAt:By(r.startedAt),durationMs:r.durationMs,firstDeltaMs:jL(r.metadata),usage:FL(r),input:r.input,output:r.output,error:r.error,metadata:bL(r)}}return{title:e.name??`Agent`,tone:`trace`,startedAt:By(e.startedAt),durationMs:e.durationMs,firstDeltaMs:AL(e.observations),usage:Uy(e.usage),input:e.input,output:e.output,error:e.error,metadata:vL(e)}}function vL(e){let t=Ry(e.metadata)?e.metadata:{},n=OL({status:e.status,traceId:e.trace?.traceId??e.id,observationId:e.trace?.observationId,sessionId:e.sessionId,observationCount:e.observationCount,messageCount:DL(t.messages),startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs});return OL({...t,status:e.status,traceId:e.trace?.traceId??e.id,observationId:e.trace?.observationId,sessionId:e.sessionId,observationCount:e.observationCount,messageCount:DL(t.messages),startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,trace:Ry(t.trace)?t.trace:n})}function yL(e,t){return OL({turn:e,observationCount:t.length,generationCount:t.filter(e=>e.kind===`generation`).length,toolCount:t.filter(e=>e.kind===`tool`).length,agentCount:t.filter(e=>e.kind===`agent`).length,firstDeltaMs:AL(t),status:EL(t),startedAt:t[0]?.startedAt,endedAt:t.at(-1)?.endedAt})}function bL(e){let t=OL({...Ry(e.metadata)?e.metadata:{},status:e.status,kind:e.kind,turn:e.turn,parentObservationId:e.parentObservationId??null,startedAt:e.startedAt,endedAt:e.endedAt??null,durationMs:e.durationMs});return OL({...t,trace:Ry(t.trace)?t.trace:OL({status:e.status,kind:e.kind,turn:e.turn,parentObservationId:e.parentObservationId??null,startedAt:e.startedAt,endedAt:e.endedAt??null,durationMs:e.durationMs}),modelInfo:Ry(t.modelInfo)?t.modelInfo:xL(t),modelCall:Ry(t.modelCall)?t.modelCall:SL(t),response:Ry(t.response)?t.response:CL(t),tools:Ry(t.tools)?t.tools:wL(t),timing:Ry(t.timing)?t.timing:TL(t)})}function xL(e){let t=OL({provider:e.provider,model:e.model,requestedModel:e.requestedModel,defaultModel:e.defaultModel});return Object.keys(t).length===0?void 0:t}function SL(e){let t=OL({messageCount:e.historyCount,documentCount:e.documentCount,toolCount:e.toolCount,toolNames:e.toolNames,temperature:e.temperature,maxTokens:e.maxTokens,toolChoice:e.toolChoice,hasOutputSchema:e.hasOutputSchema,additionalParamKeys:e.additionalParamKeys}),n=OL({request:Object.keys(t).length===0?void 0:t,providerRequest:e.providerRequest});return Object.keys(n).length===0?void 0:n}function CL(e){let t=OL({messageId:e.messageId,usage:e.usage,providerResponse:e.providerResponse});return Object.keys(t).length===0?void 0:t}function wL(e){let t=OL({count:e.toolCount,names:e.toolNames,toolChoice:e.toolChoice,internalCallId:e.internalCallId,toolCallId:e.toolCallId,skipped:e.skipped,description:e.toolDescription,parameterKeys:e.parameterKeys,requiredParameterKeys:e.requiredParameterKeys,approvalRequired:e.approvalRequired,mcpServerName:e.mcpServerName,argumentBytes:e.argumentBytes,resultBytes:e.resultBytes});return Object.keys(t).length===0?void 0:t}function TL(e){let t=OL({firstDeltaMs:e.firstDeltaMs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt});return Object.keys(t).length===0?void 0:t}function EL(e){return e.length===0?`empty`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`running`)?`running`:`success`}function DL(e){return Array.isArray(e)?e.length:void 0}function OL(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function kL(e){return e.kind===`agent`?e.name:e.kind===`tool`?`tool.${e.name}`:e.name}function AL(e){for(let t of e){let e=jL(t.metadata);if(e!==void 0)return e}}function jL(e){if(!(!Ry(e)||typeof e.firstDeltaMs!=`number`))return e.firstDeltaMs}function ML(e){switch(e){case`success`:return`bg-primary`;case`error`:return`bg-destructive`;case`running`:return`bg-chart-2`}}function NL(e){switch(e.tone){case`trace`:return(0,U.jsx)(Ue,{"aria-hidden":`true`});case`agent`:return(0,U.jsx)(Qe,{"aria-hidden":`true`});case`turn`:return(0,U.jsx)(Le,{"aria-hidden":`true`});case`generation`:return(0,U.jsx)(De,{"aria-hidden":`true`});case`tool`:return(0,U.jsx)(ot,{"aria-hidden":`true`})}}function PL(e){switch(e){case`trace`:return`bg-primary text-background`;case`agent`:return`bg-chart-2 text-background`;case`turn`:return`bg-chart-4 text-background`;case`generation`:return`bg-chart-1 text-background`;case`tool`:return`bg-chart-5 text-background`}}function FL(e){return!Ry(e.output)||!Ry(e.output.usage)?``:LL(e.output.usage)}function IL(e){return e.map(FL).filter(e=>e.length>0).join(` + `)}function LL(e){let t=typeof e.inputTokens==`number`?e.inputTokens:0,n=typeof e.outputTokens==`number`?e.outputTokens:0,r=typeof e.totalTokens==`number`?e.totalTokens:t+n;return r===0?``:`${t} -> ${n} (Σ ${r})`}var RL=`anvia-studio-theme`;function zL(){if(typeof window>`u`)return`dark`;try{let e=window.localStorage.getItem(RL);return e===`light`||e===`dark`?e:`dark`}catch{return`dark`}}function BL(e){typeof document>`u`||(document.documentElement.classList.toggle(`dark`,e===`dark`),document.documentElement.style.colorScheme=e)}function VL(e){try{window.localStorage.setItem(RL,e)}catch{}}var HL=zL();BL(HL);async function UL(e,t){let n=``;try{let t=await e.json();typeof t==`object`&&t&&`error`in t&&typeof t.error==`object`&&t.error!==null&&`message`in t.error&&typeof t.error.message==`string`&&(n=`: ${t.error.message}`)}catch{}return`${t} with HTTP ${e.status}${n}`}function WL(){let e=cF(),[t,n]=(0,v.useState)(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)([]),[O,k]=(0,v.useState)([]),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(`"Hello from Studio"`),[P,ee]=(0,v.useState)(``),[F,I]=(0,v.useState)(),[te,ne]=(0,v.useState)(``),[L,R]=(0,v.useState)(()=>e.page),[z,B]=(0,v.useState)(()=>HL),[re,ie]=(0,v.useState)(()=>e.knowledgeTab??`static-context`),[ae,oe]=(0,v.useState)(()=>e.traceId??``),[V,se]=(0,v.useState)(()=>e.traceSessionId),[le,ue]=(0,v.useState)(),[de,fe]=(0,v.useState)(`Loading`),[,H]=(0,v.useState)(``),[pe,me]=(0,v.useState)(`idle`),[he,ge]=(0,v.useState)(()=>new Set),[ve,ye]=(0,v.useState)(()=>new Set),[be,xe]=(0,v.useState)(`idle`),[Se,Ce]=(0,v.useState)(`idle`),[we,Te]=(0,v.useState)(`idle`),[Ee,De]=(0,v.useState)(),[Oe,ke]=(0,v.useState)(`idle`),[Ae,je]=(0,v.useState)(),[Me,Ne]=(0,v.useState)(`idle`),[Pe,Fe]=(0,v.useState)(),[Ie,Le]=(0,v.useState)(`idle`),[Re,ze]=(0,v.useState)(`idle`),[Be,He]=(0,v.useState)(`idle`),[Ue,We]=(0,v.useState)(`idle`),[Ge,Ke]=(0,v.useState)(`idle`),[qe,Je]=(0,v.useState)(`idle`),Xe=(0,v.useRef)(null),Ze=(0,v.useRef)(null),Qe=(0,v.useRef)(!0);function $e(){let e=Ze.current;e!==null&&(Qe.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)}(0,v.useEffect)(()=>{if(L!==`playground`||O.length===0||!Qe.current)return;let e=window.requestAnimationFrame(()=>{let e=Ze.current;e!==null&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[L,O]);let et=(0,v.useCallback)(async()=>{fe(`Loading`),H(``);try{let e=await fetch(`/config`);if(e.status===401){fe(`Authentication required`);return}if(!e.ok)throw Error(`Config failed with HTTP ${e.status}`);let t=await e.json();n(t),i(e=>e||t.agents[0]?.id||``),o(e=>e||t.agents[0]?.id||``),c(e=>e||t.agents[0]?.id||``),u(e=>e||t.pipelines[0]?.id||``),f(e=>e||t.evals[0]?.id||``),fe(`Connected`)}catch(e){H(Qy(e)),fe(`Config error`)}},[]);(0,v.useEffect)(()=>{et()},[et]);let tt=t?.capabilities.sessions?.enabled===!0,rt=t?.capabilities.traces?.enabled===!0,it=t?.capabilities.knowledge?.enabled===!0,at=t?.capabilities.mcps?.enabled===!0,ot=t?.capabilities.tools?.enabled===!0,st=t?.capabilities.pipelines?.enabled===!0,ct=t?.capabilities.evals?.enabled===!0,lt=t?.capabilities.memory?.enabled===!0,ut=t?.capabilities.status?.enabled===!0,dt=t?.agents??[],ft=t?.pipelines??[],pt=t?.evals??[],mt=dt.length>0,ht=dt.find(e=>e.id===r)??dt[0]??void 0,gt=ht?.quickPrompts??[],_t=O.length>0;(0,v.useEffect)(()=>{BL(z),VL(z)},[z]);let vt=(0,v.useCallback)(async()=>{if(!tt){g([]);return}try{let e=await fetch(`/sessions?limit=100`);if(!e.ok)throw Error(`Sessions failed with HTTP ${e.status}`);g((await e.json()).sessions)}catch(e){H(Qy(e))}},[tt]);(0,v.useEffect)(()=>{vt()},[vt]);let yt=(0,v.useCallback)(async e=>{if(!tt)return x([]),[];Ce(`loading`);try{let t=new URLSearchParams({limit:`1000`}),n=await fetch(`/sessions/${encodeURIComponent(e)}/logs?${t}`);if(!n.ok)throw Error(`Session logs failed with HTTP ${n.status}`);let r=await n.json();return x(r.logs),r.logs}catch(e){return H(Qy(e)),x([]),[]}finally{Ce(`idle`)}},[tt]);async function bt(e){let t=ht?.id??r,n=await fetch(`/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({agentId:t,title:e,metadata:{source:`anvia-studio`}})});if(!n.ok)throw Error(await UL(n,`Session create failed`));let i=await n.json();return m(i.id),g(e=>[i,...e.filter(e=>e.id!==i.id)]),fF(i.id),await yt(i.id),i}let xt=(0,v.useCallback)(async()=>{if(!rt){y([]);return}Te(`loading`);try{let e=new URLSearchParams({limit:`50`}),t=await fetch(`/traces?${e.toString()}`);if(!t.ok)throw Error(`Traces failed with HTTP ${t.status}`);let n=await t.json(),r=await Promise.all(n.traces.map(async e=>{let t=await fetch(`/traces/${encodeURIComponent(e.id)}`);if(!t.ok)throw Error(`Trace load failed with HTTP ${t.status}`);return await t.json()}));if(ae.length>0&&!r.some(e=>e.id===ae)){let e=await fetch(`/traces/${encodeURIComponent(ae)}`);if(e.ok){y([await e.json(),...r]);return}}y(r)}catch(e){H(Qy(e))}finally{Te(`idle`)}},[ae,rt]),St=(0,v.useCallback)(async(e,t={})=>{if(rt){Te(`loading`);try{let n=new URLSearchParams({limit:`50`,sessionId:e}),r=await fetch(`/traces?${n.toString()}`);if(!r.ok)throw Error(`Session traces failed with HTTP ${r.status}`);let i=await r.json(),a=[...await Promise.all(i.traces.map(async e=>{let t=await fetch(`/traces/${encodeURIComponent(e.id)}`);if(!t.ok)throw Error(`Trace load failed with HTTP ${t.status}`);return await t.json()}))].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt));y(a);let o=a[0]?.id;if(o===void 0){oe(``),se(e),t.updatePath!==!1&&mF(e);return}R(`tracing`),oe(o),se(e),t.updatePath!==!1&&mF(e)}catch(e){H(Qy(e))}finally{Te(`idle`)}}},[rt]),Ct=(0,v.useCallback)(async e=>{if(!rt)return[];let t=new URLSearchParams({limit:`100`}),n=await fetch(`/sessions/${encodeURIComponent(e)}/traces?${t}`);return n.ok?(await n.json()).traces:[]},[rt]);(0,v.useEffect)(()=>{L!==`tracing`||V!==void 0||xt()},[L,xt,V]);let wt=(0,v.useCallback)(async()=>{if(!it){De(void 0);return}ke(`loading`);try{let e=await fetch(`/knowledge?limit=25`);if(!e.ok)throw Error(`Knowledge failed with HTTP ${e.status}`);De(await e.json())}catch(e){H(Qy(e))}finally{ke(`idle`)}},[it]);(0,v.useEffect)(()=>{L===`knowledge`&&wt()},[L,wt]);let Tt=(0,v.useCallback)(async e=>{if(!at||e.length===0){je(void 0);return}Ne(`loading`);try{let t=await fetch(`/agents/${encodeURIComponent(e)}/mcps`);if(!t.ok)throw Error(`MCPs failed with HTTP ${t.status}`);je(await t.json())}catch(e){H(Qy(e)),je(void 0)}finally{Ne(`idle`)}},[at]);(0,v.useEffect)(()=>{L===`mcps`&&Tt(a||r)},[L,Tt,a,r]);let Et=(0,v.useCallback)(async e=>{if(!ot||e.length===0){Fe(void 0);return}Le(`loading`);try{let t=await fetch(`/agents/${encodeURIComponent(e)}/tools`);if(!t.ok)throw Error(`Tools failed with HTTP ${t.status}`);Fe(await t.json())}catch(e){H(Qy(e)),Fe(void 0)}finally{Le(`idle`)}},[ot]);(0,v.useEffect)(()=>{L===`tools`&&Et(s||r)},[L,Et,r,s]);let Dt=(0,v.useCallback)(async e=>{if(!st||e.length===0)return T([]),[];He(`loading`);try{let t=new URLSearchParams({limit:`1000`}),n=await fetch(`/pipelines/${encodeURIComponent(e)}/logs?${t}`);if(!n.ok)throw Error(`Pipeline logs failed with HTTP ${n.status}`);let r=await n.json();return T(r.logs),r.logs}catch(e){return H(Qy(e)),T([]),[]}finally{He(`idle`)}},[st]),Ot=(0,v.useCallback)(async e=>{if(!st||e.length===0)return D([]),[];We(`loading`);try{let t=new URLSearchParams({limit:`50`}),n=await fetch(`/pipelines/${encodeURIComponent(e)}/runs?${t}`);if(!n.ok)throw Error(`Pipeline runs failed with HTTP ${n.status}`);let r=await n.json();return D(r.runs),r.runs}catch(e){return H(Qy(e)),D([]),[]}finally{We(`idle`)}},[st]),kt=(0,v.useCallback)(async e=>{if(!st||e.length===0){C(void 0),T([]),D([]);return}ze(`loading`),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Pipeline load failed with HTTP ${t.status}`);u(e),C(await t.json()),await Promise.all([Dt(e),Ot(e)])}catch(e){H(Qy(e)),C(void 0)}finally{ze(`idle`)}},[Dt,Ot,st]);(0,v.useEffect)(()=>{if(L!==`pipelines`)return;let e=l||t?.pipelines[0]?.id||``;e.length>0&&kt(e)},[L,t?.pipelines,kt,l]);let At=(0,v.useCallback)(async(e,t={})=>{if(pe!==`running`){xe(`loading`),H(``);try{let n=await fetch(`/sessions/${encodeURIComponent(e)}`);if(!n.ok)throw Error(`Session load failed with HTTP ${n.status}`);let r=await n.json(),[a]=await Promise.all([Ct(r.id),yt(r.id)]);yF(TF(r.transcript)),i(r.agentId),m(r.id),k(XL(r.transcript,a)),t.updatePath!==!1&&(R(`playground`),fF(r.id)),fe(`Connected`)}catch(e){H(Qy(e))}finally{xe(`idle`)}}},[pe,Ct,yt]),jt=(0,v.useCallback)((e={})=>{pe!==`running`&&(bF(),m(``),x([]),k([]),j(``),R(`playground`),H(``),e.updatePath!==!1&&fF(void 0),requestAnimationFrame(()=>CF(Xe.current)))},[pe]),Mt=(0,v.useCallback)(e=>{pe===`running`||e===r||(i(e),bF(),m(``),x([]),k([]),j(``),R(`playground`),H(``),fF(void 0),requestAnimationFrame(()=>CF(Xe.current)))},[pe,r]);async function Nt(e){if(pe!==`running`){H(``);try{let t=await fetch(`/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`});if(!t.ok)throw Error(`Session delete failed with HTTP ${t.status}`);g(t=>t.filter(t=>t.id!==e.id)),y(t=>t.filter(t=>t.sessionId!==e.id)),p===e.id&&(bF(),m(``),x([]),k([]),j(``),L===`playground`&&fF(void 0)),fe(`Connected`)}catch(e){H(Qy(e))}finally{ue(void 0)}}}(0,v.useEffect)(()=>{if(!tt)return;let e=cF();if(R(e.page),ie(e.knowledgeTab??`static-context`),oe(e.traceId??``),se(e.traceSessionId),e.page===`tracing`&&e.traceSessionId!==void 0){St(e.traceSessionId,{updatePath:!1});return}e.page!==`playground`||e.sessionId===void 0||e.sessionId===p||At(e.sessionId,{updatePath:!1})},[p,tt,At,St]),(0,v.useEffect)(()=>{function e(){let e=cF();if(R(e.page),ie(e.knowledgeTab??`static-context`),oe(e.traceId??``),se(e.traceSessionId),e.page===`tracing`&&e.traceSessionId!==void 0){St(e.traceSessionId,{updatePath:!1});return}if(e.page===`playground`){if(e.sessionId===void 0){jt({updatePath:!1});return}At(e.sessionId,{updatePath:!1})}}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[At,St,jt]);async function Pt(e){let t=e.trim(),n=ht?.id??r;if(!(t.length===0||n.length===0||pe===`running`)){me(`running`),R(`playground`),H(``),j(``),Qe.current=!0,requestAnimationFrame(()=>CF(Xe.current)),k(e=>[...e,{entryId:wF(),kind:`message`,role:`user`,text:t}]);try{let e=tt&&p.length===0?(await bt(Zy(t))).id:p,r=tt?void 0:xF(O),i=await fetch(`/agents/${encodeURIComponent(n)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,...e.length===0?{}:{sessionId:e},...r===void 0?{}:{history:r},stream:!0,metadata:{source:`anvia-studio`}})});if(i.status===401)throw Error(`Authentication required`);if(!i.ok||i.body===null)throw Error(`Run failed with HTTP ${i.status}`);if(await AF(i.body,async e=>{zt(e)&&await jF()}),await vt(),e.length>0){m(e);let[t]=await Promise.all([Ct(e),yt(e)]);k(e=>XL(e,t))}fe(`Connected`)}catch(e){let t=Qy(e);H(t),Ht(`\n${t}`)}finally{me(`idle`)}}}async function Ft(){let e=l||t?.pipelines[0]?.id||``;if(e.length===0||Ge===`running`)return;let n;try{n=JSON.parse(M)}catch{H(`Pipeline input must be valid JSON`);return}Ke(`running`),ee(``),ne(``),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(e)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({input:n,stream:!0,metadata:{source:`anvia-studio`}})});if(!t.ok||t.body===null)throw Error(await UL(t,`Pipeline run failed`));await Rt(t.body),await Promise.all([Dt(e),Ot(e)]),fe(`Connected`)}catch(e){H(Qy(e))}finally{Ke(`idle`)}}async function It(e){let n=l||t?.pipelines[0]?.id||``;if(!(n.length===0||e.length===0||Ge===`running`)){Ke(`running`),ee(``),ne(``),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(n)}/runs/${encodeURIComponent(e)}/replay`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({stream:!0,metadata:{source:`anvia-studio`}})});if(!t.ok||t.body===null)throw Error(await UL(t,`Pipeline replay failed`));await Rt(t.body),await Promise.all([Dt(n),Ot(n)]),fe(`Connected`)}catch(e){H(Qy(e))}finally{Ke(`idle`)}}}async function Lt(){let e=d||t?.evals[0]?.id||``;if(!(e.length===0||qe===`running`)){Je(`running`),I(void 0),H(``);try{let t=await fetch(`/evals/${encodeURIComponent(e)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({})});if(!t.ok)throw Error(await UL(t,`Eval run failed`));I(await t.json()),fe(`Connected`)}catch(e){H(Qy(e))}finally{Je(`idle`)}}}async function Rt(e){await AF(e,async e=>{if(KL(e)){e.log.runId!==void 0&&ne(t=>t||e.log.runId||``),Vt(e.log),await jF();return}if(qL(e)){ee(JSON.stringify(e.output,null,2)),await jF();return}if(JL(e))throw Error(JSON.stringify(e.error))})}function zt(e){return e.type===`text_delta`?(Ht(e.delta),!0):e.type===`reasoning_delta`?(Jt(e.delta,e.id),!0):e.type===`tool_call`?(Yt(e.toolCall.function.name,Yy(e.toolCall.function.arguments),e.toolCall.callId??e.toolCall.id),!0):e.type===`tool_result`?(Xt({toolName:e.toolName,callId:e.toolCallId,args:e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}}),!0):e.type===`agent_tool_event`?(Zt(e),!0):e.type===`tool_approval_request`||e.type===`tool_approval_result`?(Wt(e.approval),!0):e.type===`tool_question_request`||e.type===`tool_question_result`?(Gt(e.question),!0):e.type===`session_log`?(Bt(e.log),!0):e.type===`final`&&e.trace?.traceId!==void 0?(Ut(e.trace.traceId),!0):(e.type===`error`&&H(JSON.stringify(e.error)),!1)}function Bt(e){x(t=>t.some(t=>t.id===e.id)?t:[...t,e].sort((e,t)=>e.sequence-t.sequence))}function Vt(e){T(t=>t.some(t=>t.id===e.id)?t:[...t,e].sort((e,t)=>e.sequence-t.sequence))}function Ht(e){k(t=>{let n=[...t],r=n.at(-1);return r?.kind===`message`&&r.role===`assistant`?n[n.length-1]={...r,text:`${r.text}${e}`}:n.push({entryId:wF(),kind:`message`,role:`assistant`,text:e}),n})}function Ut(e){k(t=>{let n=[...t];for(let t=n.length-1;t>=0;--t){let r=n[t];if(r?.kind===`message`&&r.role===`assistant`){n[t]={...r,traceId:e};break}}return n})}function Wt(e){k(t=>{let n=[...t],r=DF(n,e.toolName,e.callId);if(r<0)return n.push({entryId:wF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},approval:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt},...e.reason===void 0?{}:{reason:e.reason}}}),n;let i=n[r];return i!==void 0&&i.kind===`tool`&&(n[r]={...i,approval:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt},...e.reason===void 0?{}:{reason:e.reason}}}),n})}function Gt(e){k(t=>{let n=[...t],r=DF(n,e.toolName,e.callId);if(r<0)return n.push({entryId:wF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},question:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.answeredAt===void 0?{}:{answeredAt:e.answeredAt},questions:e.questions,...e.answers===void 0?{}:{answers:e.answers}}}),n;let i=n[r];return i!==void 0&&i.kind===`tool`&&(n[r]={...i,question:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.answeredAt===void 0?{}:{answeredAt:e.answeredAt},questions:e.questions,...e.answers===void 0?{}:{answers:e.answers}}}),n})}async function Kt(e,t){if(!he.has(e)){ge(t=>new Set(t).add(e)),H(``);try{let n=await fetch(`/approvals/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approved:t})});if(!n.ok)throw Error(`Approval decision failed with HTTP ${n.status}`);Wt(await n.json())}catch(e){H(Qy(e))}finally{ge(t=>{let n=new Set(t);return n.delete(e),n})}}}async function qt(e,t){if(!ve.has(e)){ye(t=>new Set(t).add(e)),H(``);try{let n=await fetch(`/questions/${encodeURIComponent(e)}/answer`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answers:t})});if(!n.ok)throw Error(`Question answer failed with HTTP ${n.status}`);Gt(await n.json())}catch(e){H(Qy(e))}finally{ye(t=>{let n=new Set(t);return n.delete(e),n})}}}function Jt(e,t){k(n=>{let r=[...n],i=r.at(-1);return i?.kind===`reasoning`&&(i.reasoningId??``)===(t??``)?r[r.length-1]={...i,text:`${i.text}${e}`}:r.push({entryId:wF(),kind:`reasoning`,...t===void 0?{}:{reasoningId:t},text:e}),r})}function Yt(e,t,n){k(r=>[...r,{entryId:wF(),kind:`tool`,toolName:e,...n===void 0?{}:{callId:n},...t.length===0?{}:{args:t}}])}function Xt(e){k(t=>{let n=[...t],r=EF(n,e.toolName,e.callId);if(r>=0){let t=n[r];if(t!==void 0&&t.kind===`tool`)return n[r]={...t,args:t.args??e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}},n}return n.push({entryId:wF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},args:e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}}),n})}function Zt(e){let t=Qt(e);t!==void 0&&k(n=>{let r=[...n],i=EF(r,e.toolName,e.toolCallId);if(i<0)return r.push({entryId:wF(),kind:`tool`,toolName:e.toolName,...e.toolCallId===void 0?{}:{callId:e.toolCallId},childEvents:[t]}),r;let a=r[i];if(a===void 0||a.kind!==`tool`)return r;let o=[...a.childEvents??[]];return $t(o,t),r[i]={...a,childEvents:o},r})}function Qt(e){let t=e.event;if(t.type===`text_delta`)return{kind:`message`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},text:t.delta};if(t.type===`reasoning_delta`)return{kind:`reasoning`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},...t.id===void 0?{}:{reasoningId:t.id},text:t.delta};if(t.type===`tool_call`)return{kind:`tool`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},toolName:t.toolCall.function.name,...t.toolCall.callId===void 0&&t.toolCall.id===void 0?{}:{callId:t.toolCall.callId??t.toolCall.id},args:Yy(t.toolCall.function.arguments)};if(t.type===`tool_result`)return{kind:`tool`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},toolName:t.toolName,...t.toolCallId===void 0?{}:{callId:t.toolCallId},args:t.args,result:t.result,...t.structuredResult===void 0?{}:{structuredResult:t.structuredResult}};if(t.type===`error`)return{kind:`message`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},text:`Error: ${Qy(t.error)}`}}function $t(e,t){if(t.kind===`message`){let n=e.at(-1);n?.kind===`message`&&n.agentId===t.agentId?e[e.length-1]={...n,text:`${n.text}${t.text}`}:e.push(t);return}if(t.kind===`reasoning`){let n=e.at(-1);n?.kind===`reasoning`&&n.agentId===t.agentId&&(n.reasoningId??``)===(t.reasoningId??``)?e[e.length-1]={...n,text:`${n.text}${t.text}`}:e.push(t);return}let n=en(e,t);if(n<0){e.push(t);return}let r=e[n];r?.kind===`tool`&&(e[n]={...r,...r.args!==void 0||t.args===void 0?{}:{args:t.args},...t.result===void 0?{}:{result:t.result}})}function en(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(!(r?.kind!==`tool`||r.agentId!==t.agentId||r.toolName!==t.toolName||r.result!==void 0)&&(t.callId===void 0||r.callId===t.callId))return n}return-1}function tn(e){j(SF(e)),CF(e.currentTarget)}function nn(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),Pt(A))}function rn(e){if(!(e===`playground`&&!mt)){if(R(e),e===`pipelines`){let e=l||ft[0]?.id||``;e.length>0&&(u(e),kt(e))}if(e===`tracing`){oe(``),se(void 0),uF(`tracing`);return}if(e===`knowledge`){oe(``),se(void 0),dF(re);return}if(oe(``),se(void 0),e===`playground`&&p.length>0){fF(p);return}uF(e)}}function an(e){R(`knowledge`),ie(e),oe(``),se(void 0),dF(e)}(0,v.useEffect)(()=>{if(t===void 0||mt||L!==`playground`)return;let e=st?`pipelines`:ct?`evals`:tt?`sessions`:rt?`tracing`:`agents`;if(bF(),m(``),x([]),k([]),j(``),R(e),uF(e),e===`pipelines`){let e=l||ft[0]?.id||``;e.length>0&&(u(e),kt(e))}e===`evals`&&f(d||t.evals[0]?.id||``)},[L,t,mt,kt,ct,ft,st,d,l,tt,rt]);function on(e){if(R(`tracing`),oe(e),se(void 0),e.length===0){uF(`tracing`);return}pF(e)}return(0,U.jsxs)(`div`,{className:`grid h-[100dvh] min-h-0 overflow-hidden bg-background text-foreground lg:grid-cols-[228px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`flex h-[100dvh] min-h-0 flex-col overflow-hidden bg-sidebar text-sidebar-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-15 items-center px-4`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,U.jsx)(`img`,{className:`h-7 w-7 shrink-0 object-contain`,src:oF,alt:``}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,U.jsx)(`span`,{className:`anvia-wordmark text-[1.08rem] font-semibold tracking-normal text-sidebar-foreground`,children:`Anvia Studio`})})]})}),(0,U.jsxs)(`nav`,{className:`grid gap-0.5 px-3 py-3`,"aria-label":`Main`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Workspace`}),(0,U.jsx)(MF,{active:L===`playground`,icon:`message`,label:`Chat`,disabled:!mt,onClick:()=>rn(`playground`)}),(0,U.jsx)(MF,{active:L===`pipelines`,icon:`workflow`,label:`Pipelines`,disabled:!st,onClick:()=>rn(`pipelines`)}),(0,U.jsx)(MF,{active:L===`evals`,icon:`gauge`,label:`Evals`,disabled:!ct,onClick:()=>rn(`evals`)}),(0,U.jsx)(MF,{active:L===`sessions`,icon:`list`,label:`Sessions`,onClick:()=>rn(`sessions`)}),(0,U.jsx)(MF,{active:L===`tracing`,icon:`activity`,label:`Traces`,onClick:()=>rn(`tracing`)})]}),(0,U.jsxs)(`nav`,{className:`grid gap-0.5 px-3 py-3`,"aria-label":`Studio`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Inspect`}),(0,U.jsx)(MF,{active:L===`agents`,icon:`bot`,label:`Studio`,onClick:()=>rn(`agents`)}),(0,U.jsx)(MF,{active:L===`tools`,icon:`wrench`,label:`Tools`,onClick:()=>rn(`tools`)}),(0,U.jsx)(MF,{active:L===`mcps`,icon:`plug`,label:`MCPs`,onClick:()=>rn(`mcps`)}),(0,U.jsx)(MF,{active:L===`knowledge`,icon:`database`,label:`Knowledge`,onClick:()=>rn(`knowledge`)}),(0,U.jsx)(MF,{active:L===`memory`,icon:`database`,label:`Memory`,disabled:!lt,onClick:()=>rn(`memory`)}),(0,U.jsx)(MF,{active:L===`status`,icon:`gauge`,label:`Status`,disabled:!ut,onClick:()=>rn(`status`)})]}),(0,U.jsxs)(`nav`,{className:`grid min-h-0 gap-0.5 overflow-auto px-3 py-3`,"aria-label":`Recent sessions`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Recent`}),h.slice(0,8).map(e=>(0,U.jsxs)(`div`,{className:tr(`group grid min-h-7 min-w-0 grid-cols-[minmax(0,1fr)_36px] items-center gap-1 rounded-lg pr-1 transition duration-200 hover:bg-sidebar-accent/80 focus-within:bg-sidebar-accent/80`,e.id===p&&`bg-sidebar-accent`),children:[(0,U.jsx)(K,{className:tr(`grid h-auto min-h-7 min-w-0 justify-start rounded-lg border-0 bg-transparent px-2.5 py-0.5 text-left text-sidebar-foreground/72 shadow-none hover:bg-transparent hover:text-sidebar-foreground`,e.id===p&&`text-sidebar-accent-foreground`),type:`button`,variant:`ghost`,onClick:()=>void At(e.id),children:(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:e.title??`Untitled chat`})}),(0,U.jsxs)(`div`,{className:`relative grid h-7 min-w-0 place-items-end`,children:[(0,U.jsx)(`time`,{className:`grid h-6 min-w-6 place-items-center self-center justify-self-end rounded-lg px-1.5 font-mono text-[10px] font-medium tabular-nums text-muted-foreground group-hover:opacity-0 group-focus-within:opacity-0`,children:zy(e.updatedAt)}),(0,U.jsx)(K,{"aria-label":`Delete ${e.title??`Untitled chat`}`,className:`absolute right-0 top-1/2 hidden h-6 min-h-6 w-6 -translate-y-1/2 border-0 bg-transparent p-0 text-muted-foreground opacity-70 shadow-none hover:bg-transparent hover:text-destructive hover:opacity-100 group-hover:grid group-focus-within:grid [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,disabled:pe===`running`,onClick:()=>ue(e),children:(0,U.jsx)(ce,{"aria-hidden":`true`})})]})]},e.id))]}),(0,U.jsxs)(`div`,{className:`mt-auto px-3 py-3`,children:[(0,U.jsxs)(`nav`,{className:`grid gap-1`,"aria-label":`Anvia links`,children:[(0,U.jsx)(GL,{href:`https://anvia.dev/docs`,label:`Anvia Docs`}),(0,U.jsx)(GL,{href:`https://anvia.dev`,label:`Anvia Web`})]}),(0,U.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:de})]})]}),(0,U.jsxs)(`main`,{className:`grid h-[100dvh] min-w-0 grid-rows-[52px_minmax(0,1fr)] overflow-hidden bg-background/80`,children:[(0,U.jsx)(`header`,{className:`grid min-h-13 bg-background/88 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid min-h-13 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 py-0 pl-0 pr-6`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:[(0,U.jsx)(`span`,{className:`text-primary`,children:L===`playground`?`Agents`:`Studio`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,U.jsx)(`span`,{className:`truncate`,children:ht?.name??ht?.id??`Agent`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(K,{"aria-label":z===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`h-8 min-h-8 w-8 border-transparent bg-transparent p-0 text-muted-foreground hover:bg-muted hover:text-foreground`,title:z===`dark`?`Switch to light theme`:`Switch to dark theme`,type:`button`,variant:`secondary`,size:`icon`,onClick:()=>B(e=>e===`dark`?`light`:`dark`),children:z===`dark`?(0,U.jsx)(nt,{"aria-hidden":`true`}):(0,U.jsx)(Ve,{"aria-hidden":`true`})}),(0,U.jsx)(K,{className:`h-8 min-h-8 border-transparent bg-transparent px-3 font-mono text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,type:`button`,variant:`secondary`,onClick:()=>rn(`sessions`),children:`Sessions`}),(0,U.jsxs)(K,{className:`h-8 min-h-8 gap-1.5 rounded-lg border-0 bg-primary px-3 font-mono text-xs text-primary-foreground hover:bg-primary/90`,type:`button`,onClick:()=>jt(),children:[(0,U.jsx)(Ye,{"aria-hidden":`true`}),`New session`]})]})]})}),L===`playground`?(0,U.jsxs)(`section`,{className:`grid h-full min-h-0 min-w-0 max-h-full max-w-full grid-cols-[minmax(0,1fr)_minmax(0,460px)] overflow-hidden bg-background/45 max-xl:grid-cols-1`,children:[(0,U.jsx)(`div`,{className:`grid min-h-0 min-w-0 pb-6 pr-6`,children:(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)_auto] overflow-hidden rounded-lg border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsx)(`section`,{className:`min-h-0 overflow-y-auto overflow-x-hidden px-4 py-4 [scrollbar-gutter:stable]`,ref:Ze,onScroll:$e,children:(0,U.jsxs)(`div`,{className:`mx-auto grid min-h-full w-full max-w-235 content-start items-start gap-6 pb-8`,children:[_t?null:(0,U.jsx)(`div`,{className:`grid min-h-96 place-items-center text-sm font-medium text-muted-foreground`,children:(0,U.jsxs)(`div`,{className:`grid max-w-xl gap-4 text-center`,children:[(0,U.jsx)(`div`,{className:`mx-auto h-px w-28 bg-primary/45`}),(0,U.jsx)(`h1`,{className:`m-0 text-4xl font-semibold leading-tight text-foreground text-balance`,children:`What should this agent work on?`}),(0,U.jsx)(`p`,{className:`m-0 text-base leading-7 text-muted-foreground text-pretty`,children:`Choose a prompt below or write a task. Studio will stream the response, tool calls, approvals, and trace data here.`})]})}),O.map(e=>(0,U.jsx)(WN,{entry:e,decidingApprovals:he,answeringQuestions:ve,onApprovalDecision:(e,t)=>void Kt(e,t),onQuestionAnswer:(e,t)=>void qt(e,t),onOpenTrace:on},e.entryId))]})}),(0,U.jsxs)(`form`,{className:`grid gap-3 bg-gradient-to-t from-card via-card/95 to-card/0 px-4 pb-4 pt-2`,onSubmit:e=>{e.preventDefault(),Pt(A)},children:[_t||gt.length===0?null:(0,U.jsx)(`div`,{className:`mx-auto grid w-full max-w-235 grid-cols-3 gap-2 max-md:grid-cols-1`,children:gt.map(e=>(0,U.jsx)(K,{className:`h-auto min-h-16 justify-start whitespace-normal rounded-lg border border-border/80 bg-card/85 px-3 py-2.5 text-left text-sm font-medium leading-5 text-foreground shadow-sm hover:border-primary/45 hover:bg-primary/10 hover:text-primary`,type:`button`,variant:`ghost`,disabled:pe===`running`||r.length===0,onClick:()=>void Pt(e),children:(0,U.jsx)(`span`,{className:`min-w-0 whitespace-normal wrap-break-words`,children:e})},e))}),(0,U.jsxs)(`div`,{className:`mx-auto grid w-full max-w-235 gap-2 rounded-lg border border-border/80 bg-card/95 p-2.5 shadow-xl shadow-black/35 backdrop-blur focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/25`,children:[(0,U.jsx)(Hl,{className:`min-h-16 min-w-0 resize-none rounded-lg border-0 bg-transparent px-3 py-3 text-[15px] leading-7 text-foreground shadow-none outline-none ring-0 placeholder:text-muted-foreground/70 focus:border-transparent focus:ring-0`,ref:Xe,rows:1,value:A,onChange:tn,onKeyDown:nn,placeholder:`Ask anything...`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,U.jsx)(`div`,{}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[dt.length>1?(0,U.jsxs)(J,{value:ht?.id??r,onValueChange:Mt,disabled:pe===`running`,children:[(0,U.jsx)(zl,{"aria-label":`Select agent`,className:`hidden h-8 min-h-8 w-auto max-w-64 gap-2 border-0 bg-transparent px-2 py-1 font-mono text-xs font-medium text-muted-foreground shadow-none hover:bg-accent hover:text-accent-foreground sm:flex`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:dt.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):(0,U.jsx)(`span`,{className:`hidden max-w-60 truncate rounded-lg px-2 py-1 font-mono text-xs font-medium text-muted-foreground sm:block`,children:ht?.name??ht?.id??`Agent`}),(0,U.jsx)(K,{"aria-label":pe===`running`?`Running`:`Send message`,className:`h-9 min-h-9 w-9 rounded-lg border-primary bg-primary text-primary-foreground hover:bg-primary/90`,size:`icon`,type:`submit`,disabled:pe===`running`||r.length===0,children:(0,U.jsx)(_e,{})})]})]})]})]})]})}),(0,U.jsx)($N,{logs:b,selectedSessionId:p,loading:Se===`loading`})]}):null,L===`tracing`?(0,U.jsx)(II,{agents:dt,traces:_,tracesEnabled:rt,traceLoadState:we,selectedTraceId:ae,traceSessionDetailId:V,onRefresh:()=>void xt(),onSelectTrace:on,onShowSessionTraces:e=>void St(e)}):null,L===`sessions`?(0,U.jsx)(tF,{agents:dt,sessions:h,sessionsEnabled:tt,sessionLoadState:be,selectedSessionId:p,onOpenSession:e=>void At(e),onViewSessionTracing:e=>void St(e),onDeleteSession:ue}):null,L===`agents`?(0,U.jsx)(Gl,{agents:dt,selectedAgentId:r}):null,L===`tools`?(0,U.jsx)(zF,{agents:dt,selectedAgentId:s||ht?.id||r,summary:Pe,enabled:ot,loading:Ie===`loading`,onSelectAgent:e=>{c(e),Et(e)}}):null,L===`pipelines`?(0,U.jsx)(_N,{pipelines:ft,selectedPipelineId:l,detail:S,logs:w,activeRunId:te,runs:E,enabled:st,detailLoading:Re===`loading`,logsLoading:Be===`loading`,runsLoading:Ue===`loading`,runState:Ge,runInput:M,runOutput:P,theme:z,onSelectPipeline:e=>{u(e),ee(``),ne(``),kt(e)},onRunInputChange:N,onRun:()=>void Ft(),onReplayRun:e=>void It(e)}):null,L===`evals`?(0,U.jsx)(cb,{evals:pt,selectedEvalId:d,enabled:ct,runState:qe,result:F,onSelectEval:e=>{f(e),I(void 0)},onRun:()=>void Lt()}):null,L===`mcps`?(0,U.jsx)(Mb,{agents:dt,selectedAgentId:a||ht?.id||r,summary:Ae,enabled:at,loading:Me===`loading`,onSelectAgent:e=>{o(e),Tt(e)}}):null,L===`knowledge`?(0,U.jsx)(fb,{activeTab:re,enabled:it,summary:Ee,loading:Oe===`loading`,onOpenTrace:on,onRefresh:()=>void wt(),onSelectTab:an}):null,L===`memory`?(0,U.jsx)(Vb,{agents:dt,enabled:lt}):null,L===`status`?(0,U.jsx)(PF,{enabled:ut}):null]}),(0,U.jsx)(nF,{session:le,onOpenChange:e=>{e||ue(void 0)},onConfirm:e=>void Nt(e)})]})}function GL(e){return(0,U.jsxs)(`a`,{className:`flex h-8 min-h-8 items-center justify-between rounded-lg px-2 font-mono text-[11px] font-semibold text-sidebar-foreground/62 transition duration-200 hover:bg-sidebar-accent hover:text-sidebar-foreground`,href:e.href,target:`_blank`,rel:`noreferrer`,children:[(0,U.jsx)(`span`,{children:e.label}),(0,U.jsx)(he,{"aria-hidden":`true`,className:`h-3 w-3 text-muted-foreground`})]})}function KL(e){return YL(e)&&e.type===`pipeline_log`&&YL(e.log)}function qL(e){return YL(e)&&e.type===`pipeline_final`&&`output`in e}function JL(e){return YL(e)&&e.type===`error`}function YL(e){return typeof e==`object`&&!!e}function XL(e,t){let n=[...t].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)).map(e=>e.id),r=0,i,a=e.map(e=>e.kind===`message`&&e.role===`assistant`?ZL(e):e);function o(){if(i===void 0)return;let e=n[r];r+=1,e!==void 0&&(a[i]={...a[i],traceId:e}),i=void 0}for(let[e,t]of a.entries()){if(t.kind===`message`&&t.role===`user`){o();continue}t.kind===`message`&&t.role===`assistant`&&(i=e)}return o(),a}function ZL(e){let{traceId:t,...n}=e;return n}var QL=document.getElementById(`anvia-ui`);QL!==null&&(0,st.createRoot)(QL).render((0,U.jsx)(WL,{}));
100
- //# sourceMappingURL=index-B0bCx2Nv.js.map
99
+ `)}]}function fL(e,t,n){if(Ry(e)){let t=typeof e.type==`string`?e.type:void 0;if(n===`choice`){if(t===`text`)return`Assistant output`;if(t===`reasoning`)return`Reasoning`}if(t===`reasoning`)return`Reasoning`;if(typeof e.role==`string`)return pL(e.role);if(t!==void 0)return pL(t)}return`${n===void 0?`Item`:`${pL(n)} item`} ${t+1}`}function pL(e){return e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).trim().replace(/\b\w/g,e=>e.toUpperCase())}function mL(e){let t=e.instructions;return typeof t!=`string`||t.trim().length===0?[]:[{label:`System prompt`,text:t}]}function hL(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function gL(e){let t=new Map;for(let n of e.observations){let e=Number.isFinite(n.turn)?n.turn:t.size+1;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].sort(([e],[t])=>e-t).map(([e,t])=>({turn:e,observations:t,durationMs:t.reduce((e,t)=>e+(t.durationMs??0),0)}))}function _L(e){let t=new Map;for(let n of e)t.set(n.id,{observation:n,children:[]});let n=[];for(let r of e){let e=t.get(r.id);if(e===void 0)continue;let i=r.parentObservationId,a=i===void 0?void 0:t.get(i);a===void 0?n.push(e):a.children.push(e)}return n}function vL(e,t,n){if(n===`agent`)return{title:`agent.run`,tone:`agent`,startedAt:By(e.startedAt),durationMs:e.durationMs,firstDeltaMs:jL(e.observations),usage:Uy(e.usage),input:e.input,output:e.output,error:e.error,metadata:yL(e)};if(n.startsWith(`turn:`)){let r=Number(n.slice(5)),i=t.find(e=>e.turn===r);return{title:`turn.${Number.isFinite(r)?r:1}`,tone:`turn`,startedAt:By(i?.observations[0]?.startedAt??e.startedAt),durationMs:i?.durationMs,firstDeltaMs:jL(i?.observations??[]),usage:LL(i?.observations??[]),input:i?.observations[0]?.input,output:i?.observations.at(-1)?.output,metadata:bL(r,i?.observations??[])}}if(n.startsWith(`observation:`)){let t=n.slice(12),r=e.observations.find(e=>e.id===t);if(r!==void 0)return{title:AL(r),tone:r.kind,startedAt:By(r.startedAt),durationMs:r.durationMs,firstDeltaMs:ML(r.metadata),usage:IL(r),input:r.input,output:r.output,error:r.error,metadata:xL(r)}}return{title:e.name??`Agent`,tone:`trace`,startedAt:By(e.startedAt),durationMs:e.durationMs,firstDeltaMs:jL(e.observations),usage:Uy(e.usage),input:e.input,output:e.output,error:e.error,metadata:yL(e)}}function yL(e){let t=Ry(e.metadata)?e.metadata:{},n=kL({status:e.status,traceId:e.trace?.traceId??e.id,observationId:e.trace?.observationId,sessionId:e.sessionId,observationCount:e.observationCount,messageCount:OL(t.messages),startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs});return kL({...t,status:e.status,traceId:e.trace?.traceId??e.id,observationId:e.trace?.observationId,sessionId:e.sessionId,observationCount:e.observationCount,messageCount:OL(t.messages),startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,trace:Ry(t.trace)?t.trace:n})}function bL(e,t){return kL({turn:e,observationCount:t.length,generationCount:t.filter(e=>e.kind===`generation`).length,toolCount:t.filter(e=>e.kind===`tool`).length,agentCount:t.filter(e=>e.kind===`agent`).length,firstDeltaMs:jL(t),status:DL(t),startedAt:t[0]?.startedAt,endedAt:t.at(-1)?.endedAt})}function xL(e){let t=kL({...Ry(e.metadata)?e.metadata:{},status:e.status,kind:e.kind,turn:e.turn,parentObservationId:e.parentObservationId??null,startedAt:e.startedAt,endedAt:e.endedAt??null,durationMs:e.durationMs});return kL({...t,trace:Ry(t.trace)?t.trace:kL({status:e.status,kind:e.kind,turn:e.turn,parentObservationId:e.parentObservationId??null,startedAt:e.startedAt,endedAt:e.endedAt??null,durationMs:e.durationMs}),modelInfo:Ry(t.modelInfo)?t.modelInfo:SL(t),modelCall:Ry(t.modelCall)?t.modelCall:CL(t),response:Ry(t.response)?t.response:wL(t),tools:Ry(t.tools)?t.tools:TL(t),timing:Ry(t.timing)?t.timing:EL(t)})}function SL(e){let t=kL({provider:e.provider,model:e.model,requestedModel:e.requestedModel,defaultModel:e.defaultModel});return Object.keys(t).length===0?void 0:t}function CL(e){let t=kL({messageCount:e.historyCount,documentCount:e.documentCount,toolCount:e.toolCount,toolNames:e.toolNames,temperature:e.temperature,maxTokens:e.maxTokens,toolChoice:e.toolChoice,hasOutputSchema:e.hasOutputSchema,additionalParamKeys:e.additionalParamKeys}),n=kL({request:Object.keys(t).length===0?void 0:t,providerRequest:e.providerRequest});return Object.keys(n).length===0?void 0:n}function wL(e){let t=kL({messageId:e.messageId,usage:e.usage,providerResponse:e.providerResponse});return Object.keys(t).length===0?void 0:t}function TL(e){let t=kL({count:e.toolCount,names:e.toolNames,toolChoice:e.toolChoice,internalCallId:e.internalCallId,toolCallId:e.toolCallId,skipped:e.skipped,description:e.toolDescription,parameterKeys:e.parameterKeys,requiredParameterKeys:e.requiredParameterKeys,approvalRequired:e.approvalRequired,mcpServerName:e.mcpServerName,argumentBytes:e.argumentBytes,resultBytes:e.resultBytes});return Object.keys(t).length===0?void 0:t}function EL(e){let t=kL({firstDeltaMs:e.firstDeltaMs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt});return Object.keys(t).length===0?void 0:t}function DL(e){return e.length===0?`empty`:e.some(e=>e.status===`error`)?`error`:e.some(e=>e.status===`running`)?`running`:`success`}function OL(e){return Array.isArray(e)?e.length:void 0}function kL(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function AL(e){return e.kind===`agent`?e.name:e.kind===`tool`?`tool.${e.name}`:e.name}function jL(e){for(let t of e){let e=ML(t.metadata);if(e!==void 0)return e}}function ML(e){if(!(!Ry(e)||typeof e.firstDeltaMs!=`number`))return e.firstDeltaMs}function NL(e){switch(e){case`success`:return`bg-primary`;case`error`:return`bg-destructive`;case`running`:return`bg-chart-2`}}function PL(e){switch(e.tone){case`trace`:return(0,U.jsx)(Ue,{"aria-hidden":`true`});case`agent`:return(0,U.jsx)(Qe,{"aria-hidden":`true`});case`turn`:return(0,U.jsx)(Le,{"aria-hidden":`true`});case`generation`:return(0,U.jsx)(De,{"aria-hidden":`true`});case`tool`:return(0,U.jsx)(ot,{"aria-hidden":`true`})}}function FL(e){switch(e){case`trace`:return`bg-primary text-background`;case`agent`:return`bg-chart-2 text-background`;case`turn`:return`bg-chart-4 text-background`;case`generation`:return`bg-chart-1 text-background`;case`tool`:return`bg-chart-5 text-background`}}function IL(e){return!Ry(e.output)||!Ry(e.output.usage)?``:RL(e.output.usage)}function LL(e){return e.map(IL).filter(e=>e.length>0).join(` + `)}function RL(e){let t=typeof e.inputTokens==`number`?e.inputTokens:0,n=typeof e.outputTokens==`number`?e.outputTokens:0,r=typeof e.totalTokens==`number`?e.totalTokens:t+n;return r===0?``:`${t} -> ${n} (Σ ${r})`}var zL=`anvia-studio-theme`;function BL(){if(typeof window>`u`)return`dark`;try{let e=window.localStorage.getItem(zL);return e===`light`||e===`dark`?e:`dark`}catch{return`dark`}}function VL(e){typeof document>`u`||(document.documentElement.classList.toggle(`dark`,e===`dark`),document.documentElement.style.colorScheme=e)}function HL(e){try{window.localStorage.setItem(zL,e)}catch{}}var UL=BL();VL(UL);async function WL(e,t){let n=``;try{let t=await e.json();typeof t==`object`&&t&&`error`in t&&typeof t.error==`object`&&t.error!==null&&`message`in t.error&&typeof t.error.message==`string`&&(n=`: ${t.error.message}`)}catch{}return`${t} with HTTP ${e.status}${n}`}function GL(){let e=cF(),[t,n]=(0,v.useState)(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)([]),[O,k]=(0,v.useState)([]),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(`"Hello from Studio"`),[P,ee]=(0,v.useState)(``),[F,I]=(0,v.useState)(),[te,ne]=(0,v.useState)(``),[L,R]=(0,v.useState)(()=>e.page),[z,B]=(0,v.useState)(()=>UL),[re,ie]=(0,v.useState)(()=>e.knowledgeTab??`static-context`),[ae,oe]=(0,v.useState)(()=>e.traceId??``),[V,se]=(0,v.useState)(()=>e.traceSessionId),[le,ue]=(0,v.useState)(),[de,fe]=(0,v.useState)(`Loading`),[,H]=(0,v.useState)(``),[pe,me]=(0,v.useState)(`idle`),[he,ge]=(0,v.useState)(()=>new Set),[ve,ye]=(0,v.useState)(()=>new Set),[be,xe]=(0,v.useState)(`idle`),[Se,Ce]=(0,v.useState)(`idle`),[we,Te]=(0,v.useState)(`idle`),[Ee,De]=(0,v.useState)(),[Oe,ke]=(0,v.useState)(`idle`),[Ae,je]=(0,v.useState)(),[Me,Ne]=(0,v.useState)(`idle`),[Pe,Fe]=(0,v.useState)(),[Ie,Le]=(0,v.useState)(`idle`),[Re,ze]=(0,v.useState)(`idle`),[Be,He]=(0,v.useState)(`idle`),[Ue,We]=(0,v.useState)(`idle`),[Ge,Ke]=(0,v.useState)(`idle`),[qe,Je]=(0,v.useState)(`idle`),Xe=(0,v.useRef)(null),Ze=(0,v.useRef)(null),Qe=(0,v.useRef)(!0);function $e(){let e=Ze.current;e!==null&&(Qe.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)}(0,v.useEffect)(()=>{if(L!==`playground`||O.length===0||!Qe.current)return;let e=window.requestAnimationFrame(()=>{let e=Ze.current;e!==null&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[L,O]);let et=(0,v.useCallback)(async()=>{fe(`Loading`),H(``);try{let e=await fetch(`/config`);if(e.status===401){fe(`Authentication required`);return}if(!e.ok)throw Error(`Config failed with HTTP ${e.status}`);let t=await e.json();n(t),i(e=>e||t.agents[0]?.id||``),o(e=>e||t.agents[0]?.id||``),c(e=>e||t.agents[0]?.id||``),u(e=>e||t.pipelines[0]?.id||``),f(e=>e||t.evals[0]?.id||``),fe(`Connected`)}catch(e){H(Qy(e)),fe(`Config error`)}},[]);(0,v.useEffect)(()=>{et()},[et]);let tt=t?.capabilities.sessions?.enabled===!0,rt=t?.capabilities.traces?.enabled===!0,it=t?.capabilities.knowledge?.enabled===!0,at=t?.capabilities.mcps?.enabled===!0,ot=t?.capabilities.tools?.enabled===!0,st=t?.capabilities.pipelines?.enabled===!0,ct=t?.capabilities.evals?.enabled===!0,lt=t?.capabilities.memory?.enabled===!0,ut=t?.capabilities.status?.enabled===!0,dt=t?.agents??[],ft=t?.pipelines??[],pt=t?.evals??[],mt=dt.length>0,ht=dt.find(e=>e.id===r)??dt[0]??void 0,gt=ht?.quickPrompts??[],_t=O.length>0;(0,v.useEffect)(()=>{VL(z),HL(z)},[z]);let vt=(0,v.useCallback)(async()=>{if(!tt){g([]);return}try{let e=await fetch(`/sessions?limit=100`);if(!e.ok)throw Error(`Sessions failed with HTTP ${e.status}`);g((await e.json()).sessions)}catch(e){H(Qy(e))}},[tt]);(0,v.useEffect)(()=>{vt()},[vt]);let yt=(0,v.useCallback)(async e=>{if(!tt)return x([]),[];Ce(`loading`);try{let t=new URLSearchParams({limit:`1000`}),n=await fetch(`/sessions/${encodeURIComponent(e)}/logs?${t}`);if(!n.ok)throw Error(`Session logs failed with HTTP ${n.status}`);let r=await n.json();return x(r.logs),r.logs}catch(e){return H(Qy(e)),x([]),[]}finally{Ce(`idle`)}},[tt]);async function bt(e){let t=ht?.id??r,n=await fetch(`/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({agentId:t,title:e,metadata:{source:`anvia-studio`}})});if(!n.ok)throw Error(await WL(n,`Session create failed`));let i=await n.json();return m(i.id),g(e=>[i,...e.filter(e=>e.id!==i.id)]),fF(i.id),await yt(i.id),i}let xt=(0,v.useCallback)(async()=>{if(!rt){y([]);return}Te(`loading`);try{let e=new URLSearchParams({limit:`50`}),t=await fetch(`/traces?${e.toString()}`);if(!t.ok)throw Error(`Traces failed with HTTP ${t.status}`);let n=await t.json(),r=await Promise.all(n.traces.map(async e=>{let t=await fetch(`/traces/${encodeURIComponent(e.id)}`);if(!t.ok)throw Error(`Trace load failed with HTTP ${t.status}`);return await t.json()}));if(ae.length>0&&!r.some(e=>e.id===ae)){let e=await fetch(`/traces/${encodeURIComponent(ae)}`);if(e.ok){y([await e.json(),...r]);return}}y(r)}catch(e){H(Qy(e))}finally{Te(`idle`)}},[ae,rt]),St=(0,v.useCallback)(async(e,t={})=>{if(rt){Te(`loading`);try{let n=new URLSearchParams({limit:`50`,sessionId:e}),r=await fetch(`/traces?${n.toString()}`);if(!r.ok)throw Error(`Session traces failed with HTTP ${r.status}`);let i=await r.json(),a=[...await Promise.all(i.traces.map(async e=>{let t=await fetch(`/traces/${encodeURIComponent(e.id)}`);if(!t.ok)throw Error(`Trace load failed with HTTP ${t.status}`);return await t.json()}))].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt));y(a);let o=a[0]?.id;if(o===void 0){oe(``),se(e),t.updatePath!==!1&&mF(e);return}R(`tracing`),oe(o),se(e),t.updatePath!==!1&&mF(e)}catch(e){H(Qy(e))}finally{Te(`idle`)}}},[rt]),Ct=(0,v.useCallback)(async e=>{if(!rt)return[];let t=new URLSearchParams({limit:`100`}),n=await fetch(`/sessions/${encodeURIComponent(e)}/traces?${t}`);return n.ok?(await n.json()).traces:[]},[rt]);(0,v.useEffect)(()=>{L!==`tracing`||V!==void 0||xt()},[L,xt,V]);let wt=(0,v.useCallback)(async()=>{if(!it){De(void 0);return}ke(`loading`);try{let e=await fetch(`/knowledge?limit=25`);if(!e.ok)throw Error(`Knowledge failed with HTTP ${e.status}`);De(await e.json())}catch(e){H(Qy(e))}finally{ke(`idle`)}},[it]);(0,v.useEffect)(()=>{L===`knowledge`&&wt()},[L,wt]);let Tt=(0,v.useCallback)(async e=>{if(!at||e.length===0){je(void 0);return}Ne(`loading`);try{let t=await fetch(`/agents/${encodeURIComponent(e)}/mcps`);if(!t.ok)throw Error(`MCPs failed with HTTP ${t.status}`);je(await t.json())}catch(e){H(Qy(e)),je(void 0)}finally{Ne(`idle`)}},[at]);(0,v.useEffect)(()=>{L===`mcps`&&Tt(a||r)},[L,Tt,a,r]);let Et=(0,v.useCallback)(async e=>{if(!ot||e.length===0){Fe(void 0);return}Le(`loading`);try{let t=await fetch(`/agents/${encodeURIComponent(e)}/tools`);if(!t.ok)throw Error(`Tools failed with HTTP ${t.status}`);Fe(await t.json())}catch(e){H(Qy(e)),Fe(void 0)}finally{Le(`idle`)}},[ot]);(0,v.useEffect)(()=>{L===`tools`&&Et(s||r)},[L,Et,r,s]);let Dt=(0,v.useCallback)(async e=>{if(!st||e.length===0)return T([]),[];He(`loading`);try{let t=new URLSearchParams({limit:`1000`}),n=await fetch(`/pipelines/${encodeURIComponent(e)}/logs?${t}`);if(!n.ok)throw Error(`Pipeline logs failed with HTTP ${n.status}`);let r=await n.json();return T(r.logs),r.logs}catch(e){return H(Qy(e)),T([]),[]}finally{He(`idle`)}},[st]),Ot=(0,v.useCallback)(async e=>{if(!st||e.length===0)return D([]),[];We(`loading`);try{let t=new URLSearchParams({limit:`50`}),n=await fetch(`/pipelines/${encodeURIComponent(e)}/runs?${t}`);if(!n.ok)throw Error(`Pipeline runs failed with HTTP ${n.status}`);let r=await n.json();return D(r.runs),r.runs}catch(e){return H(Qy(e)),D([]),[]}finally{We(`idle`)}},[st]),kt=(0,v.useCallback)(async e=>{if(!st||e.length===0){C(void 0),T([]),D([]);return}ze(`loading`),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Pipeline load failed with HTTP ${t.status}`);u(e),C(await t.json()),await Promise.all([Dt(e),Ot(e)])}catch(e){H(Qy(e)),C(void 0)}finally{ze(`idle`)}},[Dt,Ot,st]);(0,v.useEffect)(()=>{if(L!==`pipelines`)return;let e=l||t?.pipelines[0]?.id||``;e.length>0&&kt(e)},[L,t?.pipelines,kt,l]);let At=(0,v.useCallback)(async(e,t={})=>{if(pe!==`running`){xe(`loading`),H(``);try{let n=await fetch(`/sessions/${encodeURIComponent(e)}`);if(!n.ok)throw Error(`Session load failed with HTTP ${n.status}`);let r=await n.json(),[a]=await Promise.all([Ct(r.id),yt(r.id)]);bF(EF(r.transcript)),i(r.agentId),m(r.id),k(ZL(r.transcript,a)),t.updatePath!==!1&&(R(`playground`),fF(r.id)),fe(`Connected`)}catch(e){H(Qy(e))}finally{xe(`idle`)}}},[pe,Ct,yt]),jt=(0,v.useCallback)((e={})=>{pe!==`running`&&(xF(),m(``),x([]),k([]),j(``),R(`playground`),H(``),e.updatePath!==!1&&fF(void 0),requestAnimationFrame(()=>wF(Xe.current)))},[pe]),Mt=(0,v.useCallback)(e=>{pe===`running`||e===r||(i(e),xF(),m(``),x([]),k([]),j(``),R(`playground`),H(``),fF(void 0),requestAnimationFrame(()=>wF(Xe.current)))},[pe,r]);async function Nt(e){if(pe!==`running`){H(``);try{let t=await fetch(`/sessions/${encodeURIComponent(e.id)}`,{method:`DELETE`});if(!t.ok)throw Error(`Session delete failed with HTTP ${t.status}`);g(t=>t.filter(t=>t.id!==e.id)),y(t=>t.filter(t=>t.sessionId!==e.id)),p===e.id&&(xF(),m(``),x([]),k([]),j(``),L===`playground`&&fF(void 0)),fe(`Connected`)}catch(e){H(Qy(e))}finally{ue(void 0)}}}(0,v.useEffect)(()=>{if(!tt)return;let e=cF();if(R(e.page),ie(e.knowledgeTab??`static-context`),oe(e.traceId??``),se(e.traceSessionId),e.page===`tracing`&&e.traceSessionId!==void 0){St(e.traceSessionId,{updatePath:!1});return}e.page!==`playground`||e.sessionId===void 0||e.sessionId===p||At(e.sessionId,{updatePath:!1})},[p,tt,At,St]),(0,v.useEffect)(()=>{function e(){let e=cF();if(R(e.page),ie(e.knowledgeTab??`static-context`),oe(e.traceId??``),se(e.traceSessionId),e.page===`tracing`&&e.traceSessionId!==void 0){St(e.traceSessionId,{updatePath:!1});return}if(e.page===`playground`){if(e.sessionId===void 0){jt({updatePath:!1});return}At(e.sessionId,{updatePath:!1})}}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[At,St,jt]);async function Pt(e){let t=e.trim(),n=ht?.id??r;if(!(t.length===0||n.length===0||pe===`running`)){me(`running`),R(`playground`),H(``),j(``),Qe.current=!0,requestAnimationFrame(()=>wF(Xe.current)),k(e=>[...e,{entryId:TF(),kind:`message`,role:`user`,text:t}]);try{let e=tt&&p.length===0?(await bt(Zy(t))).id:p,r=tt?void 0:SF(O),i=await fetch(`/agents/${encodeURIComponent(n)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,...e.length===0?{}:{sessionId:e},...r===void 0?{}:{history:r},stream:!0,metadata:{source:`anvia-studio`}})});if(i.status===401)throw Error(`Authentication required`);if(!i.ok||i.body===null)throw Error(`Run failed with HTTP ${i.status}`);if(await jF(i.body,async e=>{zt(e)&&await MF()}),await vt(),e.length>0){m(e);let[t]=await Promise.all([Ct(e),yt(e)]);k(e=>ZL(e,t))}fe(`Connected`)}catch(e){let t=Qy(e);H(t),Ht(`\n${t}`)}finally{me(`idle`)}}}async function Ft(){let e=l||t?.pipelines[0]?.id||``;if(e.length===0||Ge===`running`)return;let n;try{n=JSON.parse(M)}catch{H(`Pipeline input must be valid JSON`);return}Ke(`running`),ee(``),ne(``),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(e)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({input:n,stream:!0,metadata:{source:`anvia-studio`}})});if(!t.ok||t.body===null)throw Error(await WL(t,`Pipeline run failed`));await Rt(t.body),await Promise.all([Dt(e),Ot(e)]),fe(`Connected`)}catch(e){H(Qy(e))}finally{Ke(`idle`)}}async function It(e){let n=l||t?.pipelines[0]?.id||``;if(!(n.length===0||e.length===0||Ge===`running`)){Ke(`running`),ee(``),ne(``),H(``);try{let t=await fetch(`/pipelines/${encodeURIComponent(n)}/runs/${encodeURIComponent(e)}/replay`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({stream:!0,metadata:{source:`anvia-studio`}})});if(!t.ok||t.body===null)throw Error(await WL(t,`Pipeline replay failed`));await Rt(t.body),await Promise.all([Dt(n),Ot(n)]),fe(`Connected`)}catch(e){H(Qy(e))}finally{Ke(`idle`)}}}async function Lt(){let e=d||t?.evals[0]?.id||``;if(!(e.length===0||qe===`running`)){Je(`running`),I(void 0),H(``);try{let t=await fetch(`/evals/${encodeURIComponent(e)}/runs`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({})});if(!t.ok)throw Error(await WL(t,`Eval run failed`));I(await t.json()),fe(`Connected`)}catch(e){H(Qy(e))}finally{Je(`idle`)}}}async function Rt(e){await jF(e,async e=>{if(qL(e)){e.log.runId!==void 0&&ne(t=>t||e.log.runId||``),Vt(e.log),await MF();return}if(JL(e)){ee(JSON.stringify(e.output,null,2)),await MF();return}if(YL(e))throw Error(JSON.stringify(e.error))})}function zt(e){return e.type===`text_delta`?(Ht(e.delta),!0):e.type===`reasoning_delta`?(Jt(e.delta,e.id),!0):e.type===`tool_call`?(Yt(e.toolCall.function.name,Yy(e.toolCall.function.arguments),e.toolCall.callId??e.toolCall.id),!0):e.type===`tool_result`?(Xt({toolName:e.toolName,callId:e.toolCallId,args:e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}}),!0):e.type===`agent_tool_event`?(Zt(e),!0):e.type===`tool_approval_request`||e.type===`tool_approval_result`?(Wt(e.approval),!0):e.type===`tool_question_request`||e.type===`tool_question_result`?(Gt(e.question),!0):e.type===`session_log`?(Bt(e.log),!0):e.type===`final`&&e.trace?.traceId!==void 0?(Ut(e.trace.traceId),!0):(e.type===`error`&&H(JSON.stringify(e.error)),!1)}function Bt(e){x(t=>t.some(t=>t.id===e.id)?t:[...t,e].sort((e,t)=>e.sequence-t.sequence))}function Vt(e){T(t=>t.some(t=>t.id===e.id)?t:[...t,e].sort((e,t)=>e.sequence-t.sequence))}function Ht(e){k(t=>{let n=[...t],r=n.at(-1);return r?.kind===`message`&&r.role===`assistant`?n[n.length-1]={...r,text:`${r.text}${e}`}:n.push({entryId:TF(),kind:`message`,role:`assistant`,text:e}),n})}function Ut(e){k(t=>{let n=[...t];for(let t=n.length-1;t>=0;--t){let r=n[t];if(r?.kind===`message`&&r.role===`assistant`){n[t]={...r,traceId:e};break}}return n})}function Wt(e){k(t=>{let n=[...t],r=OF(n,e.toolName,e.callId);if(r<0)return n.push({entryId:TF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},approval:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt},...e.reason===void 0?{}:{reason:e.reason}}}),n;let i=n[r];return i!==void 0&&i.kind===`tool`&&(n[r]={...i,approval:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.resolvedAt===void 0?{}:{resolvedAt:e.resolvedAt},...e.reason===void 0?{}:{reason:e.reason}}}),n})}function Gt(e){k(t=>{let n=[...t],r=OF(n,e.toolName,e.callId);if(r<0)return n.push({entryId:TF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},question:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.answeredAt===void 0?{}:{answeredAt:e.answeredAt},questions:e.questions,...e.answers===void 0?{}:{answers:e.answers}}}),n;let i=n[r];return i!==void 0&&i.kind===`tool`&&(n[r]={...i,question:{id:e.id,status:e.status,requestedAt:e.requestedAt,...e.answeredAt===void 0?{}:{answeredAt:e.answeredAt},questions:e.questions,...e.answers===void 0?{}:{answers:e.answers}}}),n})}async function Kt(e,t){if(!he.has(e)){ge(t=>new Set(t).add(e)),H(``);try{let n=await fetch(`/approvals/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approved:t})});if(!n.ok)throw Error(`Approval decision failed with HTTP ${n.status}`);Wt(await n.json())}catch(e){H(Qy(e))}finally{ge(t=>{let n=new Set(t);return n.delete(e),n})}}}async function qt(e,t){if(!ve.has(e)){ye(t=>new Set(t).add(e)),H(``);try{let n=await fetch(`/questions/${encodeURIComponent(e)}/answer`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answers:t})});if(!n.ok)throw Error(`Question answer failed with HTTP ${n.status}`);Gt(await n.json())}catch(e){H(Qy(e))}finally{ye(t=>{let n=new Set(t);return n.delete(e),n})}}}function Jt(e,t){k(n=>{let r=[...n],i=r.at(-1);return i?.kind===`reasoning`&&(i.reasoningId??``)===(t??``)?r[r.length-1]={...i,text:`${i.text}${e}`}:r.push({entryId:TF(),kind:`reasoning`,...t===void 0?{}:{reasoningId:t},text:e}),r})}function Yt(e,t,n){k(r=>[...r,{entryId:TF(),kind:`tool`,toolName:e,...n===void 0?{}:{callId:n},...t.length===0?{}:{args:t}}])}function Xt(e){k(t=>{let n=[...t],r=DF(n,e.toolName,e.callId);if(r>=0){let t=n[r];if(t!==void 0&&t.kind===`tool`)return n[r]={...t,args:t.args??e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}},n}return n.push({entryId:TF(),kind:`tool`,toolName:e.toolName,...e.callId===void 0?{}:{callId:e.callId},args:e.args,result:e.result,...e.structuredResult===void 0?{}:{structuredResult:e.structuredResult}}),n})}function Zt(e){let t=Qt(e);t!==void 0&&k(n=>{let r=[...n],i=DF(r,e.toolName,e.toolCallId);if(i<0)return r.push({entryId:TF(),kind:`tool`,toolName:e.toolName,...e.toolCallId===void 0?{}:{callId:e.toolCallId},childEvents:[t]}),r;let a=r[i];if(a===void 0||a.kind!==`tool`)return r;let o=[...a.childEvents??[]];return $t(o,t),r[i]={...a,childEvents:o},r})}function Qt(e){let t=e.event;if(t.type===`text_delta`)return{kind:`message`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},text:t.delta};if(t.type===`reasoning_delta`)return{kind:`reasoning`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},...t.id===void 0?{}:{reasoningId:t.id},text:t.delta};if(t.type===`tool_call`)return{kind:`tool`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},toolName:t.toolCall.function.name,...t.toolCall.callId===void 0&&t.toolCall.id===void 0?{}:{callId:t.toolCall.callId??t.toolCall.id},args:Yy(t.toolCall.function.arguments)};if(t.type===`tool_result`)return{kind:`tool`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},toolName:t.toolName,...t.toolCallId===void 0?{}:{callId:t.toolCallId},args:t.args,result:t.result,...t.structuredResult===void 0?{}:{structuredResult:t.structuredResult}};if(t.type===`error`)return{kind:`message`,agentId:e.agentId,...e.agentName===void 0?{}:{agentName:e.agentName},text:`Error: ${Qy(t.error)}`}}function $t(e,t){if(t.kind===`message`){let n=e.at(-1);n?.kind===`message`&&n.agentId===t.agentId?e[e.length-1]={...n,text:`${n.text}${t.text}`}:e.push(t);return}if(t.kind===`reasoning`){let n=e.at(-1);n?.kind===`reasoning`&&n.agentId===t.agentId&&(n.reasoningId??``)===(t.reasoningId??``)?e[e.length-1]={...n,text:`${n.text}${t.text}`}:e.push(t);return}let n=en(e,t);if(n<0){e.push(t);return}let r=e[n];r?.kind===`tool`&&(e[n]={...r,...r.args!==void 0||t.args===void 0?{}:{args:t.args},...t.result===void 0?{}:{result:t.result}})}function en(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(!(r?.kind!==`tool`||r.agentId!==t.agentId||r.toolName!==t.toolName||r.result!==void 0)&&(t.callId===void 0||r.callId===t.callId))return n}return-1}function tn(e){j(CF(e)),wF(e.currentTarget)}function nn(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),Pt(A))}function rn(e){if(!(e===`playground`&&!mt)){if(R(e),e===`pipelines`){let e=l||ft[0]?.id||``;e.length>0&&(u(e),kt(e))}if(e===`tracing`){oe(``),se(void 0),uF(`tracing`);return}if(e===`knowledge`){oe(``),se(void 0),dF(re);return}if(oe(``),se(void 0),e===`playground`&&p.length>0){fF(p);return}uF(e)}}function an(e){R(`knowledge`),ie(e),oe(``),se(void 0),dF(e)}(0,v.useEffect)(()=>{if(t===void 0||mt||L!==`playground`)return;let e=st?`pipelines`:ct?`evals`:tt?`sessions`:rt?`tracing`:`agents`;if(xF(),m(``),x([]),k([]),j(``),R(e),uF(e),e===`pipelines`){let e=l||ft[0]?.id||``;e.length>0&&(u(e),kt(e))}e===`evals`&&f(d||t.evals[0]?.id||``)},[L,t,mt,kt,ct,ft,st,d,l,tt,rt]);function on(e){if(R(`tracing`),oe(e),se(void 0),e.length===0){uF(`tracing`);return}pF(e)}return(0,U.jsxs)(`div`,{className:`grid h-[100dvh] min-h-0 overflow-hidden bg-background text-foreground lg:grid-cols-[228px_minmax(0,1fr)]`,children:[(0,U.jsxs)(`aside`,{className:`flex h-[100dvh] min-h-0 flex-col overflow-hidden bg-sidebar text-sidebar-foreground`,children:[(0,U.jsx)(`div`,{className:`flex h-15 items-center px-4`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,U.jsx)(`img`,{className:`h-7 w-7 shrink-0 object-contain`,src:oF,alt:``}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,U.jsx)(`span`,{className:`anvia-wordmark text-[1.08rem] font-semibold tracking-normal text-sidebar-foreground`,children:`Anvia Studio`})})]})}),(0,U.jsxs)(`nav`,{className:`grid gap-0.5 px-3 py-3`,"aria-label":`Main`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Workspace`}),(0,U.jsx)(NF,{active:L===`playground`,icon:`message`,label:`Chat`,disabled:!mt,onClick:()=>rn(`playground`)}),(0,U.jsx)(NF,{active:L===`pipelines`,icon:`workflow`,label:`Pipelines`,disabled:!st,onClick:()=>rn(`pipelines`)}),(0,U.jsx)(NF,{active:L===`evals`,icon:`gauge`,label:`Evals`,disabled:!ct,onClick:()=>rn(`evals`)}),(0,U.jsx)(NF,{active:L===`sessions`,icon:`list`,label:`Sessions`,onClick:()=>rn(`sessions`)}),(0,U.jsx)(NF,{active:L===`tracing`,icon:`activity`,label:`Traces`,onClick:()=>rn(`tracing`)})]}),(0,U.jsxs)(`nav`,{className:`grid gap-0.5 px-3 py-3`,"aria-label":`Studio`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Inspect`}),(0,U.jsx)(NF,{active:L===`agents`,icon:`bot`,label:`Studio`,onClick:()=>rn(`agents`)}),(0,U.jsx)(NF,{active:L===`tools`,icon:`wrench`,label:`Tools`,onClick:()=>rn(`tools`)}),(0,U.jsx)(NF,{active:L===`mcps`,icon:`plug`,label:`MCPs`,onClick:()=>rn(`mcps`)}),(0,U.jsx)(NF,{active:L===`knowledge`,icon:`database`,label:`Knowledge`,onClick:()=>rn(`knowledge`)}),(0,U.jsx)(NF,{active:L===`memory`,icon:`database`,label:`Memory`,disabled:!lt,onClick:()=>rn(`memory`)}),(0,U.jsx)(NF,{active:L===`status`,icon:`gauge`,label:`Status`,disabled:!ut,onClick:()=>rn(`status`)})]}),(0,U.jsxs)(`nav`,{className:`grid min-h-0 gap-0.5 overflow-auto px-3 py-3`,"aria-label":`Recent sessions`,children:[(0,U.jsx)(`div`,{className:`px-2.5 pb-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:`Recent`}),h.slice(0,8).map(e=>(0,U.jsxs)(`div`,{className:tr(`group grid min-h-7 min-w-0 grid-cols-[minmax(0,1fr)_36px] items-center gap-1 rounded-lg pr-1 transition duration-200 hover:bg-sidebar-accent/80 focus-within:bg-sidebar-accent/80`,e.id===p&&`bg-sidebar-accent`),children:[(0,U.jsx)(K,{className:tr(`grid h-auto min-h-7 min-w-0 justify-start rounded-lg border-0 bg-transparent px-2.5 py-0.5 text-left text-sidebar-foreground/72 shadow-none hover:bg-transparent hover:text-sidebar-foreground`,e.id===p&&`text-sidebar-accent-foreground`),type:`button`,variant:`ghost`,onClick:()=>void At(e.id),children:(0,U.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium`,children:e.title??`Untitled chat`})}),(0,U.jsxs)(`div`,{className:`relative grid h-7 min-w-0 place-items-end`,children:[(0,U.jsx)(`time`,{className:`grid h-6 min-w-6 place-items-center self-center justify-self-end rounded-lg px-1.5 font-mono text-[10px] font-medium tabular-nums text-muted-foreground group-hover:opacity-0 group-focus-within:opacity-0`,children:zy(e.updatedAt)}),(0,U.jsx)(K,{"aria-label":`Delete ${e.title??`Untitled chat`}`,className:`absolute right-0 top-1/2 hidden h-6 min-h-6 w-6 -translate-y-1/2 border-0 bg-transparent p-0 text-muted-foreground opacity-70 shadow-none hover:bg-transparent hover:text-destructive hover:opacity-100 group-hover:grid group-focus-within:grid [&_svg]:h-3.5 [&_svg]:w-3.5`,size:`icon`,type:`button`,variant:`ghost`,disabled:pe===`running`,onClick:()=>ue(e),children:(0,U.jsx)(ce,{"aria-hidden":`true`})})]})]},e.id))]}),(0,U.jsxs)(`div`,{className:`mt-auto px-3 py-3`,children:[(0,U.jsxs)(`nav`,{className:`grid gap-1`,"aria-label":`Anvia links`,children:[(0,U.jsx)(KL,{href:`https://anvia.dev/docs`,label:`Anvia Docs`}),(0,U.jsx)(KL,{href:`https://anvia.dev`,label:`Anvia Web`})]}),(0,U.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:de})]})]}),(0,U.jsxs)(`main`,{className:`grid h-[100dvh] min-w-0 grid-rows-[52px_minmax(0,1fr)] overflow-hidden bg-background/80`,children:[(0,U.jsx)(`header`,{className:`grid min-h-13 bg-background/88 backdrop-blur`,children:(0,U.jsxs)(`div`,{className:`grid min-h-13 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 py-0 pl-0 pr-6`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium`,children:[(0,U.jsx)(`span`,{className:`text-primary`,children:L===`playground`?`Agents`:`Studio`}),(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,U.jsx)(`span`,{className:`truncate`,children:ht?.name??ht?.id??`Agent`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(K,{"aria-label":z===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`h-8 min-h-8 w-8 border-transparent bg-transparent p-0 text-muted-foreground hover:bg-muted hover:text-foreground`,title:z===`dark`?`Switch to light theme`:`Switch to dark theme`,type:`button`,variant:`secondary`,size:`icon`,onClick:()=>B(e=>e===`dark`?`light`:`dark`),children:z===`dark`?(0,U.jsx)(nt,{"aria-hidden":`true`}):(0,U.jsx)(Ve,{"aria-hidden":`true`})}),(0,U.jsx)(K,{className:`h-8 min-h-8 border-transparent bg-transparent px-3 font-mono text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,type:`button`,variant:`secondary`,onClick:()=>rn(`sessions`),children:`Sessions`}),(0,U.jsxs)(K,{className:`h-8 min-h-8 gap-1.5 rounded-lg border-0 bg-primary px-3 font-mono text-xs text-primary-foreground hover:bg-primary/90`,type:`button`,onClick:()=>jt(),children:[(0,U.jsx)(Ye,{"aria-hidden":`true`}),`New session`]})]})]})}),L===`playground`?(0,U.jsxs)(`section`,{className:`grid h-full min-h-0 min-w-0 max-h-full max-w-full grid-cols-[minmax(0,1fr)_minmax(0,460px)] overflow-hidden bg-background/45 max-xl:grid-cols-1`,children:[(0,U.jsx)(`div`,{className:`grid min-h-0 min-w-0 pb-6 pr-6`,children:(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[minmax(0,1fr)_auto] overflow-hidden rounded-lg border border-border/80 bg-card/70 p-2 shadow-sm`,children:[(0,U.jsx)(`section`,{className:`min-h-0 overflow-y-auto overflow-x-hidden px-4 py-4 [scrollbar-gutter:stable]`,ref:Ze,onScroll:$e,children:(0,U.jsxs)(`div`,{className:`mx-auto grid min-h-full w-full max-w-235 content-start items-start gap-6 pb-8`,children:[_t?null:(0,U.jsx)(`div`,{className:`grid min-h-96 place-items-center text-sm font-medium text-muted-foreground`,children:(0,U.jsxs)(`div`,{className:`grid max-w-xl gap-4 text-center`,children:[(0,U.jsx)(`div`,{className:`mx-auto h-px w-28 bg-primary/45`}),(0,U.jsx)(`h1`,{className:`m-0 text-4xl font-semibold leading-tight text-foreground text-balance`,children:`What should this agent work on?`}),(0,U.jsx)(`p`,{className:`m-0 text-base leading-7 text-muted-foreground text-pretty`,children:`Choose a prompt below or write a task. Studio will stream the response, tool calls, approvals, and trace data here.`})]})}),O.map(e=>(0,U.jsx)(WN,{entry:e,decidingApprovals:he,answeringQuestions:ve,onApprovalDecision:(e,t)=>void Kt(e,t),onQuestionAnswer:(e,t)=>void qt(e,t),onOpenTrace:on},e.entryId))]})}),(0,U.jsxs)(`form`,{className:`grid gap-3 bg-gradient-to-t from-card via-card/95 to-card/0 px-4 pb-4 pt-2`,onSubmit:e=>{e.preventDefault(),Pt(A)},children:[_t||gt.length===0?null:(0,U.jsx)(`div`,{className:`mx-auto grid w-full max-w-235 grid-cols-3 gap-2 max-md:grid-cols-1`,children:gt.map(e=>(0,U.jsx)(K,{className:`h-auto min-h-16 justify-start whitespace-normal rounded-lg border border-border/80 bg-card/85 px-3 py-2.5 text-left text-sm font-medium leading-5 text-foreground shadow-sm hover:border-primary/45 hover:bg-primary/10 hover:text-primary`,type:`button`,variant:`ghost`,disabled:pe===`running`||r.length===0,onClick:()=>void Pt(e),children:(0,U.jsx)(`span`,{className:`min-w-0 whitespace-normal wrap-break-words`,children:e})},e))}),(0,U.jsxs)(`div`,{className:`mx-auto grid w-full max-w-235 gap-2 rounded-lg border border-border/80 bg-card/95 p-2.5 shadow-xl shadow-black/35 backdrop-blur focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/25`,children:[(0,U.jsx)(Hl,{className:`min-h-16 min-w-0 resize-none rounded-lg border-0 bg-transparent px-3 py-3 text-[15px] leading-7 text-foreground shadow-none outline-none ring-0 placeholder:text-muted-foreground/70 focus:border-transparent focus:ring-0`,ref:Xe,rows:1,value:A,onChange:tn,onKeyDown:nn,placeholder:`Ask anything...`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,U.jsx)(`div`,{}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[dt.length>1?(0,U.jsxs)(J,{value:ht?.id??r,onValueChange:Mt,disabled:pe===`running`,children:[(0,U.jsx)(zl,{"aria-label":`Select agent`,className:`hidden h-8 min-h-8 w-auto max-w-64 gap-2 border-0 bg-transparent px-2 py-1 font-mono text-xs font-medium text-muted-foreground shadow-none hover:bg-accent hover:text-accent-foreground sm:flex`,children:(0,U.jsx)(Y,{placeholder:`Agent`})}),(0,U.jsx)(Bl,{align:`end`,children:dt.map(e=>(0,U.jsx)(Vl,{value:e.id,children:e.name??e.id},e.id))})]}):(0,U.jsx)(`span`,{className:`hidden max-w-60 truncate rounded-lg px-2 py-1 font-mono text-xs font-medium text-muted-foreground sm:block`,children:ht?.name??ht?.id??`Agent`}),(0,U.jsx)(K,{"aria-label":pe===`running`?`Running`:`Send message`,className:`h-9 min-h-9 w-9 rounded-lg border-primary bg-primary text-primary-foreground hover:bg-primary/90`,size:`icon`,type:`submit`,disabled:pe===`running`||r.length===0,children:(0,U.jsx)(_e,{})})]})]})]})]})]})}),(0,U.jsx)($N,{logs:b,selectedSessionId:p,loading:Se===`loading`})]}):null,L===`tracing`?(0,U.jsx)(LI,{agents:dt,traces:_,tracesEnabled:rt,traceLoadState:we,selectedTraceId:ae,traceSessionDetailId:V,onRefresh:()=>void xt(),onSelectTrace:on,onShowSessionTraces:e=>void St(e)}):null,L===`sessions`?(0,U.jsx)(tF,{agents:dt,sessions:h,sessionsEnabled:tt,sessionLoadState:be,selectedSessionId:p,onOpenSession:e=>void At(e),onViewSessionTracing:e=>void St(e),onDeleteSession:ue}):null,L===`agents`?(0,U.jsx)(Gl,{agents:dt,selectedAgentId:r}):null,L===`tools`?(0,U.jsx)(BF,{agents:dt,selectedAgentId:s||ht?.id||r,summary:Pe,enabled:ot,loading:Ie===`loading`,onSelectAgent:e=>{c(e),Et(e)}}):null,L===`pipelines`?(0,U.jsx)(_N,{pipelines:ft,selectedPipelineId:l,detail:S,logs:w,activeRunId:te,runs:E,enabled:st,detailLoading:Re===`loading`,logsLoading:Be===`loading`,runsLoading:Ue===`loading`,runState:Ge,runInput:M,runOutput:P,theme:z,onSelectPipeline:e=>{u(e),ee(``),ne(``),kt(e)},onRunInputChange:N,onRun:()=>void Ft(),onReplayRun:e=>void It(e)}):null,L===`evals`?(0,U.jsx)(cb,{evals:pt,selectedEvalId:d,enabled:ct,runState:qe,result:F,onSelectEval:e=>{f(e),I(void 0)},onRun:()=>void Lt()}):null,L===`mcps`?(0,U.jsx)(Mb,{agents:dt,selectedAgentId:a||ht?.id||r,summary:Ae,enabled:at,loading:Me===`loading`,onSelectAgent:e=>{o(e),Tt(e)}}):null,L===`knowledge`?(0,U.jsx)(fb,{activeTab:re,enabled:it,summary:Ee,loading:Oe===`loading`,onOpenTrace:on,onRefresh:()=>void wt(),onSelectTab:an}):null,L===`memory`?(0,U.jsx)(Vb,{agents:dt,enabled:lt}):null,L===`status`?(0,U.jsx)(FF,{enabled:ut}):null]}),(0,U.jsx)(nF,{session:le,onOpenChange:e=>{e||ue(void 0)},onConfirm:e=>void Nt(e)})]})}function KL(e){return(0,U.jsxs)(`a`,{className:`flex h-8 min-h-8 items-center justify-between rounded-lg px-2 font-mono text-[11px] font-semibold text-sidebar-foreground/62 transition duration-200 hover:bg-sidebar-accent hover:text-sidebar-foreground`,href:e.href,target:`_blank`,rel:`noreferrer`,children:[(0,U.jsx)(`span`,{children:e.label}),(0,U.jsx)(he,{"aria-hidden":`true`,className:`h-3 w-3 text-muted-foreground`})]})}function qL(e){return XL(e)&&e.type===`pipeline_log`&&XL(e.log)}function JL(e){return XL(e)&&e.type===`pipeline_final`&&`output`in e}function YL(e){return XL(e)&&e.type===`error`}function XL(e){return typeof e==`object`&&!!e}function ZL(e,t){let n=[...t].sort((e,t)=>Date.parse(e.startedAt)-Date.parse(t.startedAt)).map(e=>e.id),r=0,i,a=e.map(e=>e.kind===`message`&&e.role===`assistant`?QL(e):e);function o(){if(i===void 0)return;let e=n[r];r+=1,e!==void 0&&(a[i]={...a[i],traceId:e}),i=void 0}for(let[e,t]of a.entries()){if(t.kind===`message`&&t.role===`user`){o();continue}t.kind===`message`&&t.role===`assistant`&&(i=e)}return o(),a}function QL(e){let{traceId:t,...n}=e;return n}var $L=document.getElementById(`anvia-ui`);$L!==null&&(0,st.createRoot)($L).render((0,U.jsx)(GL,{}));
100
+ //# sourceMappingURL=index-B4i1IueG.js.map