mastra 0.2.0-alpha.169 → 0.2.0-alpha.170

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.
@@ -282,7 +282,7 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
282
282
  `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(t,{before:"# ",after:`
283
283
  `,...s.current()});return/^[\t ]/.test(u)&&(u=Jh(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}FB.peek=oue;function FB(t){return t.value||""}function oue(){return"<"}BB.peek=aue;function BB(t,e,n,r){const i=tA(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(t.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(t.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(t.url,{before:u,after:t.title?" ":")",...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(t.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),u+=l.move(")"),o(),u}function aue(){return"!"}zB.peek=lue;function zB(t,e,n,r){const i=t.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(t.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function lue(){return"!"}$B.peek=uue;function $B(t,e,n){let r=t.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function uue(){return"`"}function VB(t,e){const n=qT(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}WB.peek=cue;function WB(t,e,n,r){const i=tA(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(VB(t,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(t,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=c,d}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(t,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(t.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(t.url,{before:u,after:t.title?" ":")",...o.current()}))),l(),t.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(t.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function cue(t,e,n){return VB(t,n)?"<":"["}HB.peek=due;function HB(t,e,n,r){const i=t.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(t,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function due(){return"["}function nA(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function fue(t){const e=nA(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function hue(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function UB(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function pue(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?hue(n):nA(n);const a=t.ordered?o==="."?")":".":fue(n);let l=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){const c=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.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&&(l=!0),UB(n)===o&&c){let d=-1;for(;++d<t.children.length;){const p=t.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(t,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),u}function mue(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function gue(t,e,n,r){const i=mue(n);let s=n.bulletCurrent||nA(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(t,a.current()),c);return l(),u;function c(d,p,m){return p?(m?"":" ".repeat(o))+d:(m?s:s+" ".repeat(o-s.length))+d}}function yue(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const xue=uv(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function vue(t,e,n,r){return(t.children.some(function(o){return xue(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function wue(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}qB.peek=bue;function qB(t,e,n,r){const i=wue(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(t,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),c=Rx(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=Jh(u)+l.slice(1));const d=l.charCodeAt(l.length-1),p=Rx(r.after.charCodeAt(0),d,i);p.inside&&(l=l.slice(0,-1)+Jh(d));const m=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+l+m}function bue(t,e,n){return n.options.strong||"*"}function kue(t,e,n,r){return n.safe(t.value,r)}function Sue(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Cue(t,e,n){const r=(UB(n)+(n.options.ruleSpaces?" ":"")).repeat(Sue(n));return n.options.ruleSpaces?r.slice(0,-1):r}const YB={blockquote:Yle,break:QO,code:Jle,definition:tue,emphasis:LB,hardBreak:QO,heading:sue,html:FB,image:BB,imageReference:zB,inlineCode:$B,link:WB,linkReference:HB,list:pue,listItem:gue,paragraph:yue,root:vue,strong:qB,text:kue,thematicBreak:Cue};function Eue(){return{enter:{table:Nue,tableData:JO,tableHeader:JO,tableRow:Aue},exit:{codeText:_ue,table:Tue,tableData:K1,tableHeader:K1,tableRow:K1}}}function Nue(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function Tue(t){this.exit(t),this.data.inTable=void 0}function Aue(t){this.enter({type:"tableRow",children:[]},t)}function K1(t){this.exit(t)}function JO(t){this.enter({type:"tableCell",children:[]},t)}function _ue(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Mue));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function Mue(t,e){return e==="|"?e:t}function Pue(t){const e=t,n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
284
284
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:l,tableRow:a}};function o(m,y,v,w){return u(c(m,v,w),m.align)}function a(m,y,v,w){const b=d(m,v,w),k=u([b]);return k.slice(0,k.indexOf(`
285
- `))}function l(m,y,v,w){const b=v.enter("tableCell"),k=v.enter("phrasing"),E=v.containerPhrasing(m,{...w,before:s,after:s});return k(),b(),E}function u(m,y){return Ule(m,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function c(m,y,v){const w=m.children;let b=-1;const k=[],E=y.enter("table");for(;++b<w.length;)k[b]=d(w[b],y,v);return E(),k}function d(m,y,v){const w=m.children;let b=-1;const k=[],E=y.enter("tableRow");for(;++b<w.length;)k[b]=l(w[b],m,y,v);return E(),k}function p(m,y,v){let w=YB.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Rue(){return{exit:{taskListCheckValueChecked:eD,taskListCheckValueUnchecked:eD,paragraph:Due}}}function Oue(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:jue}}}function eD(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Due(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function jue(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=YB.listItem(t,e,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+o}}function Iue(){return[hle(),Ele(),Ble(),Eue(),Rue()]}function Lue(t){return{extensions:[ple(),Nle(),zle(),Pue(t),Oue()]}}const Fue={tokenize:Hue,partial:!0},GB={tokenize:Uue,partial:!0},KB={tokenize:que,partial:!0},XB={tokenize:Yue,partial:!0},Bue={tokenize:Gue,partial:!0},ZB={name:"wwwAutolink",tokenize:Vue,previous:JB},QB={name:"protocolAutolink",tokenize:Wue,previous:ez},fa={name:"emailAutolink",tokenize:$ue,previous:tz},So={};function zue(){return{text:So}}let Yl=48;for(;Yl<123;)So[Yl]=fa,Yl++,Yl===58?Yl=65:Yl===91&&(Yl=97);So[43]=fa;So[45]=fa;So[46]=fa;So[95]=fa;So[72]=[fa,QB];So[104]=[fa,QB];So[87]=[fa,ZB];So[119]=[fa,ZB];function $ue(t,e,n){const r=this;let i,s;return o;function o(d){return!KC(d)||!tz.call(r,r.previous)||rA(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return KC(d)?(t.consume(d),a):d===64?(t.consume(d),l):n(d)}function l(d){return d===46?t.check(Bue,c,u)(d):d===45||d===95||Tr(d)?(s=!0,t.consume(d),l):c(d)}function u(d){return t.consume(d),i=!0,l}function c(d){return s&&i&&Vr(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function Vue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!JB.call(r,r.previous)||rA(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Fue,t.attempt(GB,t.attempt(KB,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function Wue(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&ez.call(r,r.previous)&&!rA(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(Vr(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(d),l}return n(d)}function l(d){return d===47?(t.consume(d),s?u:(s=!0,l)):n(d)}function u(d){return d===null||_x(d)||Kt(d)||pu(d)||ov(d)?n(d):t.attempt(GB,t.attempt(KB,c),n)(d)}function c(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function Hue(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),s):n(o)}function s(o){return o===null?n(o):e(o)}}function Uue(t,e,n){let r,i,s;return o;function o(u){return u===46||u===95?t.check(XB,l,a)(u):u===null||Kt(u)||pu(u)||u!==45&&ov(u)?l(u):(s=!0,t.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),t.consume(u),o}function l(u){return i||r||!s?n(u):e(u)}}function que(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?s(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?t.check(XB,e,s)(o):o===null||Kt(o)||pu(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function Yue(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),s):a===93?(t.consume(a),i):a===60||a===null||Kt(a)||pu(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Kt(a)||pu(a)?e(a):r(a)}function s(a){return Vr(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):Vr(a)?(t.consume(a),o):n(a)}}function Gue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Tr(s)?n(s):e(s)}}function JB(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Kt(t)}function ez(t){return!Vr(t)}function tz(t){return!(t===47||KC(t))}function KC(t){return t===43||t===45||t===46||t===95||Tr(t)}function rA(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Kue={tokenize:rce,partial:!0};function Xue(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ece,continuation:{tokenize:tce},exit:nce}},text:{91:{name:"gfmFootnoteCall",tokenize:Jue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Zue,resolveTo:Que}}}}function Zue(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=bs(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function Que(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",o,e],["exit",o,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function Jue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(d){if(s>999||d===93&&!o||d===null||d===91||Kt(d))return n(d);if(d===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bs(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Kt(d)||(o=!0),s++,t.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(t.consume(d),s++,u):u(d)}}function ece(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",c):n(y)}function c(y){if(o>999||y===93&&!a||y===null||y===91||Kt(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return s=bs(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return Kt(y)||(a=!0),o++,t.consume(y),y===92?d:c}function d(y){return y===91||y===92||y===93?(t.consume(y),o++,c):c(y)}function p(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(s)||i.push(s),Pt(t,m,"gfmFootnoteDefinitionWhitespace")):n(y)}function m(y){return e(y)}}function tce(t,e,n){return t.check(im,e,t.attempt(Kue,e,n))}function nce(t){t.exit("gfmFootnoteDefinition")}function rce(t,e,n){const r=this;return Pt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function ice(t){let n=t.singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",c,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],m=a.parser.constructs.insideSpan.null;m&&Ti(p,p.length,0,av(m,o.slice(u+1,l),a)),Ti(p,p.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",c,a]]),Ti(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const u=this.previous,c=this.events;let d=0;return p;function p(y){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),m(y))}function m(y){const v=id(u);if(y===126)return d>1?l(y):(o.consume(y),d++,m);if(d<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=id(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class sce{constructor(){this.map=[]}add(e,n,r){oce(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function oce(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function ace(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function lce(){return{flow:{null:{name:"table",tokenize:uce,resolveAll:cce}}}}function uce(t,e,n){const r=this;let i=0,s=0,o;return a;function a(O){let B=r.events.length-1;for(;B>-1;){const I=r.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,V=F==="tableHead"||F==="tableRow"?_:l;return V===_&&r.parser.lazy[r.now().line]?n(O):V(O)}function l(O){return t.enter("tableHead"),t.enter("tableRow"),u(O)}function u(O){return O===124||(o=!0,s+=1),c(O)}function c(O){return O===null?n(O):nt(O)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),m):n(O):Tt(O)?Pt(t,c,"whitespace")(O):(s+=1,o&&(o=!1,i+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),o=!0,c):(t.enter("data"),d(O)))}function d(O){return O===null||O===124||Kt(O)?(t.exit("data"),c(O)):(t.consume(O),O===92?p:d)}function p(O){return O===92||O===124?(t.consume(O),d):d(O)}function m(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),o=!1,Tt(O)?Pt(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):y(O))}function y(O){return O===45||O===58?w(O):O===124?(o=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),v):A(O)}function v(O){return Tt(O)?Pt(t,w,"whitespace")(O):w(O)}function w(O){return O===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),b):O===45?(s+=1,b(O)):O===null||nt(O)?N(O):A(O)}function b(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):A(O)}function k(O){return O===45?(t.consume(O),k):O===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(O))}function E(O){return Tt(O)?Pt(t,N,"whitespace")(O):N(O)}function N(O){return O===124?y(O):O===null||nt(O)?!o||i!==s?A(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):A(O)}function A(O){return n(O)}function _(O){return t.enter("tableRow"),M(O)}function M(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),M):O===null||nt(O)?(t.exit("tableRow"),e(O)):Tt(O)?Pt(t,M,"whitespace")(O):(t.enter("data"),R(O))}function R(O){return O===null||O===124||Kt(O)?(t.exit("data"),M(O)):(t.consume(O),O===92?D:R)}function D(O){return O===92||O===124?(t.consume(O),R):R(O)}}function cce(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,c,d;const p=new sce;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(tD(p,e,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},p.add(n,0,[["enter",u,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},p.add(n,0,[["enter",c,e]])),i=y.type==="tableDelimiterRow"?2:c?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=ny(p,e,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=ny(p,e,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):y.type==="tableHead"?(a=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=ny(p,e,s,i,n,d)):o[1]!==0&&(d=ny(p,e,o,i,n,d)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&tD(p,e,l,u,c),p.consume(e.events),n=-1;++n<e.events.length;){const m=e.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=ace(e.events,n))}return t}function ny(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},vc(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=vc(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const u=vc(e.events,n[2]),c=vc(e.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const p=e.events[n[2]],m=e.events[n[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(s.end=Object.assign({},vc(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function tD(t,e,n,r,i){const s=[],o=vc(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function vc(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const dce={name:"tasklistCheck",tokenize:hce};function fce(){return{text:{91:dce}}}function hce(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return Kt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return nt(l)?e(l):Tt(l)?t.check({tokenize:pce},e,n)(l):n(l)}}function pce(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function mce(t){return hB([zue(),Xue(),ice(t),lce(),fce()])}const gce={};function yce(t){const e=this,n=t||gce,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mce(n)),s.push(Iue()),o.push(Lue(n))}const xce="modulepreload",vce=function(t){return"/"+t},nD={},wce=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=vce(l),l in nD)return;nD[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":xce,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};async function bce(t,e){const{codeToTokens:n,bundledLanguages:r}=await wce(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-DJ4PjFBw.js");return{codeToTokens:s,bundledLanguages:o}},[]);if(!(e in r))return null;const{tokens:i}=await n(t,{lang:e,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return i}function kce({children:t}){const e=t.replace(/\\n/g,`
285
+ `))}function l(m,y,v,w){const b=v.enter("tableCell"),k=v.enter("phrasing"),E=v.containerPhrasing(m,{...w,before:s,after:s});return k(),b(),E}function u(m,y){return Ule(m,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function c(m,y,v){const w=m.children;let b=-1;const k=[],E=y.enter("table");for(;++b<w.length;)k[b]=d(w[b],y,v);return E(),k}function d(m,y,v){const w=m.children;let b=-1;const k=[],E=y.enter("tableRow");for(;++b<w.length;)k[b]=l(w[b],m,y,v);return E(),k}function p(m,y,v){let w=YB.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Rue(){return{exit:{taskListCheckValueChecked:eD,taskListCheckValueUnchecked:eD,paragraph:Due}}}function Oue(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:jue}}}function eD(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Due(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function jue(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=YB.listItem(t,e,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+o}}function Iue(){return[hle(),Ele(),Ble(),Eue(),Rue()]}function Lue(t){return{extensions:[ple(),Nle(),zle(),Pue(t),Oue()]}}const Fue={tokenize:Hue,partial:!0},GB={tokenize:Uue,partial:!0},KB={tokenize:que,partial:!0},XB={tokenize:Yue,partial:!0},Bue={tokenize:Gue,partial:!0},ZB={name:"wwwAutolink",tokenize:Vue,previous:JB},QB={name:"protocolAutolink",tokenize:Wue,previous:ez},fa={name:"emailAutolink",tokenize:$ue,previous:tz},So={};function zue(){return{text:So}}let Yl=48;for(;Yl<123;)So[Yl]=fa,Yl++,Yl===58?Yl=65:Yl===91&&(Yl=97);So[43]=fa;So[45]=fa;So[46]=fa;So[95]=fa;So[72]=[fa,QB];So[104]=[fa,QB];So[87]=[fa,ZB];So[119]=[fa,ZB];function $ue(t,e,n){const r=this;let i,s;return o;function o(d){return!KC(d)||!tz.call(r,r.previous)||rA(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return KC(d)?(t.consume(d),a):d===64?(t.consume(d),l):n(d)}function l(d){return d===46?t.check(Bue,c,u)(d):d===45||d===95||Tr(d)?(s=!0,t.consume(d),l):c(d)}function u(d){return t.consume(d),i=!0,l}function c(d){return s&&i&&Vr(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function Vue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!JB.call(r,r.previous)||rA(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Fue,t.attempt(GB,t.attempt(KB,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function Wue(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&ez.call(r,r.previous)&&!rA(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(Vr(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(d),l}return n(d)}function l(d){return d===47?(t.consume(d),s?u:(s=!0,l)):n(d)}function u(d){return d===null||_x(d)||Kt(d)||pu(d)||ov(d)?n(d):t.attempt(GB,t.attempt(KB,c),n)(d)}function c(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function Hue(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),s):n(o)}function s(o){return o===null?n(o):e(o)}}function Uue(t,e,n){let r,i,s;return o;function o(u){return u===46||u===95?t.check(XB,l,a)(u):u===null||Kt(u)||pu(u)||u!==45&&ov(u)?l(u):(s=!0,t.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),t.consume(u),o}function l(u){return i||r||!s?n(u):e(u)}}function que(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?s(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?t.check(XB,e,s)(o):o===null||Kt(o)||pu(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function Yue(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),s):a===93?(t.consume(a),i):a===60||a===null||Kt(a)||pu(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Kt(a)||pu(a)?e(a):r(a)}function s(a){return Vr(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):Vr(a)?(t.consume(a),o):n(a)}}function Gue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Tr(s)?n(s):e(s)}}function JB(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Kt(t)}function ez(t){return!Vr(t)}function tz(t){return!(t===47||KC(t))}function KC(t){return t===43||t===45||t===46||t===95||Tr(t)}function rA(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Kue={tokenize:rce,partial:!0};function Xue(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ece,continuation:{tokenize:tce},exit:nce}},text:{91:{name:"gfmFootnoteCall",tokenize:Jue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Zue,resolveTo:Que}}}}function Zue(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=bs(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function Que(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",o,e],["exit",o,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function Jue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(d){if(s>999||d===93&&!o||d===null||d===91||Kt(d))return n(d);if(d===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bs(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Kt(d)||(o=!0),s++,t.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(t.consume(d),s++,u):u(d)}}function ece(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",c):n(y)}function c(y){if(o>999||y===93&&!a||y===null||y===91||Kt(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return s=bs(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return Kt(y)||(a=!0),o++,t.consume(y),y===92?d:c}function d(y){return y===91||y===92||y===93?(t.consume(y),o++,c):c(y)}function p(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(s)||i.push(s),Pt(t,m,"gfmFootnoteDefinitionWhitespace")):n(y)}function m(y){return e(y)}}function tce(t,e,n){return t.check(im,e,t.attempt(Kue,e,n))}function nce(t){t.exit("gfmFootnoteDefinition")}function rce(t,e,n){const r=this;return Pt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function ice(t){let n=t.singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",c,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",d,a]],m=a.parser.constructs.insideSpan.null;m&&Ti(p,p.length,0,av(m,o.slice(u+1,l),a)),Ti(p,p.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",c,a]]),Ti(o,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const u=this.previous,c=this.events;let d=0;return p;function p(y){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),m(y))}function m(y){const v=id(u);if(y===126)return d>1?l(y):(o.consume(y),d++,m);if(d<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=id(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class sce{constructor(){this.map=[]}add(e,n,r){oce(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function oce(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function ace(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function lce(){return{flow:{null:{name:"table",tokenize:uce,resolveAll:cce}}}}function uce(t,e,n){const r=this;let i=0,s=0,o;return a;function a(O){let B=r.events.length-1;for(;B>-1;){const I=r.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,V=F==="tableHead"||F==="tableRow"?_:l;return V===_&&r.parser.lazy[r.now().line]?n(O):V(O)}function l(O){return t.enter("tableHead"),t.enter("tableRow"),u(O)}function u(O){return O===124||(o=!0,s+=1),c(O)}function c(O){return O===null?n(O):nt(O)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),m):n(O):Tt(O)?Pt(t,c,"whitespace")(O):(s+=1,o&&(o=!1,i+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),o=!0,c):(t.enter("data"),d(O)))}function d(O){return O===null||O===124||Kt(O)?(t.exit("data"),c(O)):(t.consume(O),O===92?p:d)}function p(O){return O===92||O===124?(t.consume(O),d):d(O)}function m(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),o=!1,Tt(O)?Pt(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):y(O))}function y(O){return O===45||O===58?w(O):O===124?(o=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),v):A(O)}function v(O){return Tt(O)?Pt(t,w,"whitespace")(O):w(O)}function w(O){return O===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),b):O===45?(s+=1,b(O)):O===null||nt(O)?N(O):A(O)}function b(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):A(O)}function k(O){return O===45?(t.consume(O),k):O===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(O))}function E(O){return Tt(O)?Pt(t,N,"whitespace")(O):N(O)}function N(O){return O===124?y(O):O===null||nt(O)?!o||i!==s?A(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):A(O)}function A(O){return n(O)}function _(O){return t.enter("tableRow"),M(O)}function M(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),M):O===null||nt(O)?(t.exit("tableRow"),e(O)):Tt(O)?Pt(t,M,"whitespace")(O):(t.enter("data"),R(O))}function R(O){return O===null||O===124||Kt(O)?(t.exit("data"),M(O)):(t.consume(O),O===92?D:R)}function D(O){return O===92||O===124?(t.consume(O),R):R(O)}}function cce(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,c,d;const p=new sce;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(tD(p,e,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},p.add(n,0,[["enter",u,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},p.add(n,0,[["enter",c,e]])),i=y.type==="tableDelimiterRow"?2:c?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=ny(p,e,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=ny(p,e,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):y.type==="tableHead"?(a=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=ny(p,e,s,i,n,d)):o[1]!==0&&(d=ny(p,e,o,i,n,d)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&tD(p,e,l,u,c),p.consume(e.events),n=-1;++n<e.events.length;){const m=e.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=ace(e.events,n))}return t}function ny(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},vc(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=vc(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const u=vc(e.events,n[2]),c=vc(e.events,n[3]),d={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const p=e.events[n[2]],m=e.events[n[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(s.end=Object.assign({},vc(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function tD(t,e,n,r,i){const s=[],o=vc(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function vc(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const dce={name:"tasklistCheck",tokenize:hce};function fce(){return{text:{91:dce}}}function hce(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return Kt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return nt(l)?e(l):Tt(l)?t.check({tokenize:pce},e,n)(l):n(l)}}function pce(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function mce(t){return hB([zue(),Xue(),ice(t),lce(),fce()])}const gce={};function yce(t){const e=this,n=t||gce,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mce(n)),s.push(Iue()),o.push(Lue(n))}const xce="modulepreload",vce=function(t){return"/"+t},nD={},wce=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=vce(l),l in nD)return;nD[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":xce,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};async function bce(t,e){const{codeToTokens:n,bundledLanguages:r}=await wce(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-J963xAo4.js");return{codeToTokens:s,bundledLanguages:o}},[]);if(!(e in r))return null;const{tokens:i}=await n(t,{lang:e,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return i}function kce({children:t}){const e=t.replace(/\\n/g,`
286
286
  `);return g.jsx(ole,{remarkPlugins:[yce],components:Cce,className:"space-y-3",children:e})}const nz=ne.memo(({children:t,language:e,...n})=>{const[r,i]=S.useState([]);return S.useEffect(()=>{bce(t,e).then(s=>{s&&i(s)})},[t,e]),r.length?g.jsx("pre",{...n,children:g.jsx("code",{children:r.map((s,o)=>g.jsxs(g.Fragment,{children:[g.jsx("span",{children:s.map((a,l)=>{const u=typeof a.htmlStyle=="string"?void 0:a.htmlStyle;return g.jsx("span",{className:"text-shiki-light bg-shiki-light-bg dark:text-shiki-dark dark:bg-shiki-dark-bg",style:u,children:a.content},l)})},o),o!==r.length-1&&`
287
287
  `]}))})}):g.jsx("pre",{...n,children:t})});nz.displayName="HighlightedCode";const Sce=({children:t,className:e,language:n,...r})=>{const i=typeof t=="string"?t:XC(t),s=be("overflow-x-scroll rounded-md border bg-background/50 p-4 font-mono text-sm [scrollbar-width:none]",e);return g.jsxs("div",{className:"group/code relative mb-4",children:[g.jsx(S.Suspense,{fallback:g.jsx("pre",{className:s,...r,children:t}),children:g.jsx(nz,{language:n,className:s,children:i})}),g.jsx("div",{className:"invisible absolute right-2 top-2 flex space-x-1 rounded-lg p-1 opacity-0 transition-all duration-200 group-hover/code:visible group-hover/code:opacity-100",children:g.jsx(Zh,{content:i,copyMessage:"Copied code to clipboard"})})]})};function XC(t){var e;if(typeof t=="string")return t;if((e=t==null?void 0:t.props)!=null&&e.children){let n=t.props.children;return Array.isArray(n)?n.map(r=>XC(r)).join(""):XC(n)}return""}const Cce={h1:dr("h1","text-2xl font-semibold"),h2:dr("h2","font-semibold text-xl"),h3:dr("h3","font-semibold text-lg"),h4:dr("h4","font-semibold text-base"),h5:dr("h5","font-medium"),strong:dr("strong","font-semibold"),a:dr("a","text-primary underline underline-offset-2"),blockquote:dr("blockquote","border-l-2 border-primary pl-4"),code:({children:t,className:e,node:n,...r})=>{const i=/language-(\w+)/.exec(e||"");return i?g.jsx(Sce,{className:e,language:i[1],...r,children:t}):g.jsx("code",{className:be("font-mono [:not(pre)>&]:rounded-md [:not(pre)>&]:bg-background/50 [:not(pre)>&]:px-1 [:not(pre)>&]:py-0.5"),...r,children:t})},pre:({children:t})=>t,ol:dr("ol","list-decimal space-y-2 pl-6"),ul:dr("ul","list-disc space-y-2 pl-6"),li:dr("li","my-1.5"),table:dr("table","w-full border-collapse overflow-y-auto rounded-md border border-foreground/20"),th:dr("th","border border-foreground/20 px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right"),td:dr("td","border border-foreground/20 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right"),tr:dr("tr","m-0 border-t p-0 even:bg-muted"),p:dr("p","whitespace-pre-wrap leading-relaxed"),hr:dr("hr","border-foreground/20")};function dr(t,e){const n=({node:r,...i})=>g.jsx(t,{className:e,...i});return n.displayName=t,n}const Ece=Id("group/message relative break-words rounded-lg p-3 text-sm sm:max-w-[70%]",{variants:{isUser:{true:"bg-primary text-primary-foreground",false:"bg-muted text-foreground"},isError:{true:"bg-red-100 dark:bg-red-900/20",false:""},animation:{none:"",slide:"duration-300 animate-in fade-in-0",scale:"duration-300 animate-in fade-in-0 zoom-in-75",fade:"duration-500 animate-in fade-in-0"}},compoundVariants:[{isUser:!0,animation:"slide",class:"slide-in-from-right"},{isUser:!1,animation:"slide",class:"slide-in-from-left"},{isUser:!0,animation:"scale",class:"origin-bottom-right"},{isUser:!1,animation:"scale",class:"origin-bottom-left"}]}),Nce=({role:t,content:e,createdAt:n,showTimeStamp:r=!1,animation:i="scale",actions:s,className:o,experimental_attachments:a,isError:l=!1})=>{const u=t==="user",c=S.useMemo(()=>a==null?void 0:a.map(p=>{const m=Tce(p.url);return new File([m],p.name??"Unknown")}),[a]),d=n==null?void 0:n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return g.jsxs("div",{className:be("flex flex-col",u?"items-end":"items-start"),children:[c?g.jsx("div",{className:"mb-1 flex gap-2 flex-wrap",children:c.map((p,m)=>g.jsx(BT,{file:p},m))}):null,g.jsxs("div",{className:be(Ece({isUser:u,isError:l,animation:i}),o),children:[g.jsx("div",{children:g.jsx(kce,{children:e})}),t==="assistant"&&s?g.jsx("div",{className:"absolute -bottom-4 right-2 flex space-x-1 rounded-lg border bg-background p-1 opacity-0 transition-opacity group-hover/message:opacity-100 text-foreground",children:s}):null]}),r&&n?g.jsx("time",{dateTime:n.toISOString(),className:be("mt-1 block px-1 text-xs opacity-50",i!=="none"&&"duration-500 animate-in fade-in-0"),children:d}):null]})};function Tce(t){const e=t.split(",")[1],n=Buffer.from(e??"","base64");return new Uint8Array(n)}function Ace(){return g.jsx("div",{className:"justify-left flex space-x-1",children:g.jsx("div",{className:"rounded-lg bg-muted p-3",children:g.jsxs("div",{className:"flex -space-x-2.5",children:[g.jsx(d1,{className:"h-5 w-5 animate-typing-dot-bounce"}),g.jsx(d1,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:90ms]"}),g.jsx(d1,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:180ms]"})]})})})}function _ce({messages:t,showTimeStamps:e=!0,isTyping:n=!1,messageOptions:r}){return g.jsxs("div",{className:"space-y-4 overflow-visible",children:[t.map((i,s)=>{const o=typeof r=="function"?r(i):r;return i.role==="assistant"&&!i.content.trim()?null:g.jsx(Nce,{showTimeStamp:e,...i,...o},s)}),n&&g.jsx(Ace,{})]})}function Mce({label:t,append:e,suggestions:n}){return g.jsxs("div",{className:"space-y-6",children:[g.jsx("h2",{className:"text-center text-2xl font-bold",children:t}),g.jsx("div",{className:"flex flex-col sm:flex-row gap-6 text-sm items-center justify-center",children:n.map(r=>g.jsx("button",{onClick:()=>e({role:"user",content:r}),className:"h-max rounded-xl border bg-transparent p-4 hover:bg-accent",children:g.jsx("p",{children:r})},r))})]})}const Pce=50;function Rce(t){const e=S.useRef(null),n=S.useRef(null),[r,i]=S.useState(!0),s=()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight)},o=()=>{if(e.current){const{scrollTop:l,scrollHeight:u,clientHeight:c}=e.current;if(n.current?l<n.current:!1)i(!1);else{const p=Math.abs(u-l-c)<Pce;i(p)}n.current=l}},a=()=>{i(!1)};return S.useEffect(()=>{e.current&&(n.current=e.current.scrollTop)},[]),S.useEffect(()=>{r&&s()},t),{containerRef:e,scrollToBottom:s,handleScroll:o,shouldAutoScroll:r,handleTouchStart:a}}function Oce({messages:t,children:e}){const{containerRef:n,scrollToBottom:r,handleScroll:i,shouldAutoScroll:s,handleTouchStart:o}=Rce([t]);return g.jsxs("div",{className:"grid overflow-y-auto pb-4 grid-cols-1",ref:n,onScroll:i,onTouchStart:o,children:[g.jsx("div",{className:"[grid-column:1/1] [grid-row:1/1] max-w-full",children:e}),g.jsx("div",{className:"flex justify-end items-end [grid-column:1/1] [grid-row:1/1] flex-1",children:!s&&g.jsx("div",{className:"sticky bottom-0 left-0 flex w-full justify-end",children:g.jsx(ht,{onClick:r,className:"h-8 w-8 rounded-full ease-in-out animate-in fade-in-0 slide-in-from-bottom-1",size:"icon",variant:"ghost",children:g.jsx(AX,{className:"h-4 w-4"})})})})]})}const rz=S.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:be("grid max-h-full w-full grid-rows-[1fr_auto]",t),...e}));rz.displayName="ChatContainer";const iz=S.forwardRef(({children:t,handleSubmit:e,isPending:n,className:r},i)=>{const[s,o]=S.useState(null),a=l=>{if(n){l.preventDefault();return}if(!s){e(l);return}const u=Dce(s);e(l,{experimental_attachments:u}),o(null)};return g.jsx("form",{ref:i,onSubmit:a,className:r,children:t({files:s,setFiles:o})})});iz.displayName="ChatForm";function Dce(t){const e=new DataTransfer;for(const n of Array.from(t))e.items.add(n);return e.files}function jce({agentId:t,initialMessages:e=[],agentName:n,threadId:r,memory:i}){const[s,o]=S.useState(e),[a,l]=S.useState(""),[u,c]=S.useState(!1),{mutate:d}=IT();S.useEffect(()=>{e&&o(e)},[e]);const p=S.useCallback(E=>{l(E.target.value)},[]),m=async E=>{var M;if((M=E==null?void 0:E.preventDefault)==null||M.call(E),!a.trim()||u)return;const N=a;l(""),c(!0);const A={id:Date.now().toString(),role:"user",content:N},_={id:(Date.now()+1).toString(),role:"assistant",content:""};o(R=>[...R,A,_]);try{const R=await fetch("/api/agents/"+t+"/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[N],...i?{threadId:r,resourceid:t}:{}})});if(!R.body)throw new Error("No response body");if(R.status!==200){const I=await R.json();throw new Error(I.message)}d(`/api/memory/threads?resourceid=${t}&agentId=${t}`);const D=R.body.getReader(),O=new TextDecoder;let B="",F="",V="";try{for(;;){const{done:I,value:Y}=await D.read();if(I)break;const W=O.decode(Y);B+=W;const G=B.matchAll(/0:"([^"]*)"/g),H=B.matchAll(/3:"([^"]*)"/g);if(H)for(const $ of H){const L=$[1];V+=L,o(q=>[...q.slice(0,-1),{...q[q.length-1],content:V,isError:!0}])}for(const $ of G){const L=$[1];F+=L,o(q=>[...q.slice(0,-1),{...q[q.length-1],content:F}])}B=""}}catch(I){throw new Error(I.message)}finally{D.releaseLock()}}catch(R){o(D=>[...D.slice(0,-1),{...D[D.length-1],content:(R==null?void 0:R.message)||"An error occurred while processing your request.",isError:!0}])}finally{c(!1)}},y=s.at(-1),v=s.length===0,w=u&&(y==null?void 0:y.role)==="assistant"&&!(y!=null&&y.content.trim()),b=S.useCallback(E=>{l(E.content),m()},[m]),k=["What capabilities do you have?","How can you help me?","Tell me about yourself"];return g.jsxs(rz,{className:"h-full px-4 pb-3 pt-4 max-w-[1000px] mx-auto",children:[g.jsx("div",{className:"flex flex-col h-full",children:v?g.jsx("div",{className:"mx-auto max-w-2xl",children:g.jsx(Mce,{label:`Chat with ${n}`,append:b,suggestions:k})}):g.jsx(Mn,{className:" h-[calc(100vh-15rem)] px-4",children:g.jsx(Oce,{messages:s,children:g.jsx(_ce,{messages:s,isTyping:w})})})}),g.jsxs("div",{className:"flex flex-col mt-auto gap-2",children:[g.jsx(iz,{isPending:u||w,handleSubmit:m,children:({files:E,setFiles:N})=>g.jsx(Z5,{value:a,onChange:p,files:E,setFiles:N,isGenerating:u,placeholder:"Enter your message..."})}),!i&&g.jsxs("div",{className:"flex items-center gap-1 text-sm text-mastra-el-5",children:[g.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-purple-400",children:[g.jsx("circle",{cx:"12",cy:"12",r:"10"}),g.jsx("path",{d:"M12 16v-4"}),g.jsx("path",{d:"M12 8h.01"})]}),g.jsxs("span",{className:"text-xs text-gray-300/60",children:["Agent will not remember previous messages. To enable memory for agent see"," ",g.jsx("a",{href:"https://mastra.ai/docs/agents/01-agent-memory",target:"_blank",rel:"noopener",className:"text-gray-300/60 hover:text-gray-100 underline",children:"docs."})]})]})]})]})}function iA(t){const e=t+"CollectionProvider",[n,r]=Oi(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:y,children:v}=m,w=ne.useRef(null),b=ne.useRef(new Map).current;return g.jsx(i,{scope:y,itemMap:b,collectionRef:w,children:v})};o.displayName=e;const a=t+"CollectionSlot",l=ne.forwardRef((m,y)=>{const{scope:v,children:w}=m,b=s(a,v),k=kt(y,b.collectionRef);return g.jsx(uo,{ref:k,children:w})});l.displayName=a;const u=t+"CollectionItemSlot",c="data-radix-collection-item",d=ne.forwardRef((m,y)=>{const{scope:v,children:w,...b}=m,k=ne.useRef(null),E=kt(y,k),N=s(u,v);return ne.useEffect(()=>(N.itemMap.set(k,{ref:k,...b}),()=>void N.itemMap.delete(k))),g.jsx(uo,{[c]:"",ref:E,children:w})});d.displayName=u;function p(m){const y=s(t+"CollectionConsumer",m);return ne.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${c}]`));return Array.from(y.itemMap.values()).sort((N,A)=>b.indexOf(N.ref.current)-b.indexOf(A.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:l,ItemSlot:d},p,r]}var Ice=GG.useId||(()=>{}),Lce=0;function zn(t){const[e,n]=S.useState(Ice());return Ar(()=>{t||n(r=>r??String(Lce++))},[t]),t||(e?`radix-${e}`:"")}function po({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=Fce({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,a=Fn(n),l=S.useCallback(u=>{if(s){const d=typeof u=="function"?u(t):u;d!==t&&a(d)}else i(u)},[s,t,i,a]);return[o,l]}function Fce({defaultProp:t,onChange:e}){const n=S.useState(t),[r]=n,i=S.useRef(r),s=Fn(e);return S.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var X1="rovingFocusGroup.onEntryFocus",Bce={bubbles:!1,cancelable:!0},dv="RovingFocusGroup",[ZC,sz,zce]=iA(dv),[$ce,fv]=Oi(dv,[zce]),[Vce,Wce]=$ce(dv),oz=S.forwardRef((t,e)=>g.jsx(ZC.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(ZC.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(Hce,{...t,ref:e})})}));oz.displayName=dv;var Hce=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=t,p=S.useRef(null),m=kt(e,p),y=Zp(s),[v=null,w]=po({prop:o,defaultProp:a,onChange:l}),[b,k]=S.useState(!1),E=Fn(u),N=sz(n),A=S.useRef(!1),[_,M]=S.useState(0);return S.useEffect(()=>{const R=p.current;if(R)return R.addEventListener(X1,E),()=>R.removeEventListener(X1,E)},[E]),g.jsx(Vce,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:v,onItemFocus:S.useCallback(R=>w(R),[w]),onItemShiftTab:S.useCallback(()=>k(!0),[]),onFocusableItemAdd:S.useCallback(()=>M(R=>R+1),[]),onFocusableItemRemove:S.useCallback(()=>M(R=>R-1),[]),children:g.jsx(Ze.div,{tabIndex:b||_===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...t.style},onMouseDown:Pe(t.onMouseDown,()=>{A.current=!0}),onFocus:Pe(t.onFocus,R=>{const D=!A.current;if(R.target===R.currentTarget&&D&&!b){const O=new CustomEvent(X1,Bce);if(R.currentTarget.dispatchEvent(O),!O.defaultPrevented){const B=N().filter(W=>W.focusable),F=B.find(W=>W.active),V=B.find(W=>W.id===v),Y=[F,V,...B].filter(Boolean).map(W=>W.ref.current);uz(Y,c)}}A.current=!1}),onBlur:Pe(t.onBlur,()=>k(!1))})})}),az="RovingFocusGroupItem",lz=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,...o}=t,a=zn(),l=s||a,u=Wce(az,n),c=u.currentTabStopId===l,d=sz(n),{onFocusableItemAdd:p,onFocusableItemRemove:m}=u;return S.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),g.jsx(ZC.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:g.jsx(Ze.span,{tabIndex:c?0:-1,"data-orientation":u.orientation,...o,ref:e,onMouseDown:Pe(t.onMouseDown,y=>{r?u.onItemFocus(l):y.preventDefault()}),onFocus:Pe(t.onFocus,()=>u.onItemFocus(l)),onKeyDown:Pe(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=Yce(y,u.orientation,u.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=d().filter(k=>k.focusable).map(k=>k.ref.current);if(v==="last")b.reverse();else if(v==="prev"||v==="next"){v==="prev"&&b.reverse();const k=b.indexOf(y.currentTarget);b=u.loop?Gce(b,k+1):b.slice(k+1)}setTimeout(()=>uz(b))}})})})});lz.displayName=az;var Uce={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qce(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Yce(t,e,n){const r=qce(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Uce[r]}function uz(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function Gce(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var cz=oz,dz=lz,sA="Tabs",[Kce,KIe]=Oi(sA,[fv]),fz=fv(),[Xce,oA]=Kce(sA),hz=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:l="automatic",...u}=t,c=Zp(a),[d,p]=po({prop:r,onChange:i,defaultProp:s});return g.jsx(Xce,{scope:n,baseId:zn(),value:d,onValueChange:p,orientation:o,dir:c,activationMode:l,children:g.jsx(Ze.div,{dir:c,"data-orientation":o,...u,ref:e})})});hz.displayName=sA;var pz="TabsList",mz=S.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=oA(pz,n),o=fz(n);return g.jsx(cz,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:g.jsx(Ze.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});mz.displayName=pz;var gz="TabsTrigger",yz=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=oA(gz,n),a=fz(n),l=wz(o.baseId,r),u=bz(o.baseId,r),c=r===o.value;return g.jsx(dz,{asChild:!0,...a,focusable:!i,active:c,children:g.jsx(Ze.button,{type:"button",role:"tab","aria-selected":c,"aria-controls":u,"data-state":c?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...s,ref:e,onMouseDown:Pe(t.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?o.onValueChange(r):d.preventDefault()}),onKeyDown:Pe(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(r)}),onFocus:Pe(t.onFocus,()=>{const d=o.activationMode!=="manual";!c&&!i&&d&&o.onValueChange(r)})})})});yz.displayName=gz;var xz="TabsContent",vz=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=oA(xz,n),l=wz(a.baseId,r),u=bz(a.baseId,r),c=r===a.value,d=S.useRef(c);return S.useEffect(()=>{const p=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(p)},[]),g.jsx(Pr,{present:i||c,children:({present:p})=>g.jsx(Ze.div,{"data-state":c?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:u,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:d.current?"0s":void 0},children:p&&s})})});vz.displayName=xz;function wz(t,e){return`${t}-trigger-${e}`}function bz(t,e){return`${t}-content-${e}`}var Zce=hz,kz=mz,Sz=yz,Cz=vz;const aA=Zce,hv=S.forwardRef(({className:t,...e},n)=>g.jsx(kz,{ref:n,className:be(t),...e}));hv.displayName=kz.displayName;const Xs=S.forwardRef(({className:t,...e},n)=>g.jsx(Sz,{ref:n,className:be(t),...e}));Xs.displayName=Sz.displayName;const Zs=S.forwardRef(({className:t,...e},n)=>g.jsx(Cz,{ref:n,className:be("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Zs.displayName=Cz.displayName;function Qce({agentId:t}){var i;const{isLoading:e,agent:n}=Pu(t),r=bo();return e?g.jsx(Mn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"}),g.jsx(He,{className:"h-3"})]})]})]})}):g.jsx(Mn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Name"}),g.jsx("p",{className:"text-mastra-el-5",children:n==null?void 0:n.name})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Instructions"}),g.jsx("p",{className:"text-mastra-el-5 whitespace-pre-wrap",children:n==null?void 0:n.instructions})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Model"}),g.jsx("p",{className:"text-mastra-el-5",children:n==null?void 0:n.modelId})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Provider"}),g.jsx("p",{className:"text-mastra-el-5",children:(i=n==null?void 0:n.provider)==null?void 0:i.split(".")[0].toUpperCase()})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Tools"}),g.jsx("div",{className:"flex flex-col gap-2 text-mastra-el-5",children:Object.entries((n==null?void 0:n.tools)??{}).map(([s,o])=>g.jsx("span",{onClick:()=>{r(`/tools/${t}/${o.id}`)},className:"no-underline",children:o.id},s))})]})]})})}function Jce({agentId:t}){return g.jsx(Mn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsx("p",{className:"text-mastra-el-5",children:"/api/agents"})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/evals/ci"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/evals/live"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/instructions"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/generate"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/stream"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/text-object"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/stream-object"]})]})]})})}function ede(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t);S.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var tde="DismissableLayer",QC="dismissableLayer.update",nde="dismissableLayer.pointerDownOutside",rde="dismissableLayer.focusOutside",rD,Ez=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$d=S.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,u=S.useContext(Ez),[c,d]=S.useState(null),p=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=S.useState({}),y=kt(e,M=>d(M)),v=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(w),k=c?v.indexOf(c):-1,E=u.layersWithOutsidePointerEventsDisabled.size>0,N=k>=b,A=ode(M=>{const R=M.target,D=[...u.branches].some(O=>O.contains(R));!N||D||(i==null||i(M),o==null||o(M),M.defaultPrevented||a==null||a())},p),_=ade(M=>{const R=M.target;[...u.branches].some(O=>O.contains(R))||(s==null||s(M),o==null||o(M),M.defaultPrevented||a==null||a())},p);return ede(M=>{k===u.layers.size-1&&(r==null||r(M),!M.defaultPrevented&&a&&(M.preventDefault(),a()))},p),S.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(rD=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),iD(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=rD)}},[c,p,n,u]),S.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),iD())},[c,u]),S.useEffect(()=>{const M=()=>m({});return document.addEventListener(QC,M),()=>document.removeEventListener(QC,M)},[]),g.jsx(Ze.div,{...l,ref:y,style:{pointerEvents:E?N?"auto":"none":void 0,...t.style},onFocusCapture:Pe(t.onFocusCapture,_.onFocusCapture),onBlurCapture:Pe(t.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Pe(t.onPointerDownCapture,A.onPointerDownCapture)})});$d.displayName=tde;var ide="DismissableLayerBranch",sde=S.forwardRef((t,e)=>{const n=S.useContext(Ez),r=S.useRef(null),i=kt(e,r);return S.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),g.jsx(Ze.div,{...t,ref:i})});sde.displayName=ide;function ode(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t),r=S.useRef(!1),i=S.useRef(()=>{});return S.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Nz(nde,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=l,e.addEventListener("click",i.current,{once:!0})):l()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function ade(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t),r=S.useRef(!1);return S.useEffect(()=>{const i=s=>{s.target&&!r.current&&Nz(rde,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function iD(){const t=new CustomEvent(QC);document.dispatchEvent(t)}function Nz(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?K4(i,s):i.dispatchEvent(s)}var Z1="focusScope.autoFocusOnMount",Q1="focusScope.autoFocusOnUnmount",sD={bubbles:!1,cancelable:!0},lde="FocusScope",om=S.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=S.useState(null),u=Fn(i),c=Fn(s),d=S.useRef(null),p=kt(e,v=>l(v)),m=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let v=function(E){if(m.paused||!a)return;const N=E.target;a.contains(N)?d.current=N:qa(d.current,{select:!0})},w=function(E){if(m.paused||!a)return;const N=E.relatedTarget;N!==null&&(a.contains(N)||qa(d.current,{select:!0}))},b=function(E){if(document.activeElement===document.body)for(const A of E)A.removedNodes.length>0&&qa(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const k=new MutationObserver(b);return a&&k.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),k.disconnect()}}},[r,a,m.paused]),S.useEffect(()=>{if(a){aD.add(m);const v=document.activeElement;if(!a.contains(v)){const b=new CustomEvent(Z1,sD);a.addEventListener(Z1,u),a.dispatchEvent(b),b.defaultPrevented||(ude(pde(Tz(a)),{select:!0}),document.activeElement===v&&qa(a))}return()=>{a.removeEventListener(Z1,u),setTimeout(()=>{const b=new CustomEvent(Q1,sD);a.addEventListener(Q1,c),a.dispatchEvent(b),b.defaultPrevented||qa(v??document.body,{select:!0}),a.removeEventListener(Q1,c),aD.remove(m)},0)}}},[a,u,c,m]);const y=S.useCallback(v=>{if(!n&&!r||m.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,b=document.activeElement;if(w&&b){const k=v.currentTarget,[E,N]=cde(k);E&&N?!v.shiftKey&&b===N?(v.preventDefault(),n&&qa(E,{select:!0})):v.shiftKey&&b===E&&(v.preventDefault(),n&&qa(N,{select:!0})):b===k&&v.preventDefault()}},[n,r,m.paused]);return g.jsx(Ze.div,{tabIndex:-1,...o,ref:p,onKeyDown:y})});om.displayName=lde;function ude(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qa(r,{select:e}),document.activeElement!==n)return}function cde(t){const e=Tz(t),n=oD(e,t),r=oD(e.reverse(),t);return[n,r]}function Tz(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function oD(t,e){for(const n of t)if(!dde(n,{upTo:e}))return n}function dde(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function fde(t){return t instanceof HTMLInputElement&&"select"in t}function qa(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&fde(t)&&e&&t.select()}}var aD=hde();function hde(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=lD(t,e),t.unshift(e)},remove(e){var n;t=lD(t,e),(n=t[0])==null||n.resume()}}}function lD(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function pde(t){return t.filter(e=>e.tagName!=="A")}var mde="Portal",am=S.forwardRef((t,e)=>{var a;const{container:n,...r}=t,[i,s]=S.useState(!1);Ar(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?I4.createPortal(g.jsx(Ze.div,{...r,ref:e}),o):null});am.displayName=mde;var J1=0;function pv(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??uD()),document.body.insertAdjacentElement("beforeend",t[1]??uD()),J1++,()=>{J1===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),J1--}},[])}function uD(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Us=function(){return Us=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Us.apply(this,arguments)};function Az(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function gde(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var Zy="right-scroll-bar-position",Qy="width-before-scroll-bar",yde="with-scroll-bars-hidden",xde="--removed-body-scroll-bar-size";function ek(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function vde(t,e){var n=S.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var wde=typeof window<"u"?S.useLayoutEffect:S.useEffect,cD=new WeakMap;function bde(t,e){var n=vde(null,function(r){return t.forEach(function(i){return ek(i,r)})});return wde(function(){var r=cD.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||ek(a,null)}),s.forEach(function(a){i.has(a)||ek(a,o)})}cD.set(n,t)},[t]),n}function kde(t){return t}function Sde(t,e){e===void 0&&(e=kde);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var c=o;o=[],c.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(c){o.push(c),u()},filter:function(c){return o=o.filter(c),n}}}};return i}function Cde(t){t===void 0&&(t={});var e=Sde(null);return e.options=Us({async:!0,ssr:!1},t),e}var _z=function(t){var e=t.sideCar,n=Az(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return S.createElement(r,Us({},n))};_z.isSideCarExport=!0;function Ede(t,e){return t.useMedium(e),_z}var Mz=Cde(),tk=function(){},mv=S.forwardRef(function(t,e){var n=S.useRef(null),r=S.useState({onScrollCapture:tk,onWheelCapture:tk,onTouchMoveCapture:tk}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,u=t.removeScrollBar,c=t.enabled,d=t.shards,p=t.sideCar,m=t.noIsolation,y=t.inert,v=t.allowPinchZoom,w=t.as,b=w===void 0?"div":w,k=t.gapMode,E=Az(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=p,A=bde([n,e]),_=Us(Us({},E),i);return S.createElement(S.Fragment,null,c&&S.createElement(N,{sideCar:Mz,removeScrollBar:u,shards:d,noIsolation:m,inert:y,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:k}),o?S.cloneElement(S.Children.only(a),Us(Us({},_),{ref:A})):S.createElement(b,Us({},_,{className:l,ref:A}),a))});mv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};mv.classNames={fullWidth:Qy,zeroRight:Zy};var Nde=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Tde(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Nde();return e&&t.setAttribute("nonce",e),t}function Ade(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function _de(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Mde=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Tde())&&(Ade(e,n),_de(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Pde=function(){var t=Mde();return function(e,n){S.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Pz=function(){var t=Pde(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},Rde={left:0,top:0,right:0,gap:0},nk=function(t){return parseInt(t||"",10)||0},Ode=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[nk(n),nk(r),nk(i)]},Dde=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Rde;var e=Ode(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},jde=Pz(),Bc="data-scroll-locked",Ide=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
288
288
  .`.concat(yde,` {
@@ -338,7 +338,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
338
338
  `);return g.jsxs("div",{className:`rounded-md border ${n?"border-mastra-purple/30":"border-mastra-bg-3"} bg-mastra-bg-2`,children:[g.jsxs("div",{className:"p-2 flex items-center justify-between cursor-pointer hover:bg-mastra-bg-3/50",onClick:s,children:[g.jsxs("div",{className:"flex items-center space-x-2",children:[g.jsx(rh,{className:`h-3 w-3 transition-transform ${n?"rotate-90 text-mastra-purple":""}`}),g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center space-x-2",children:[g.jsxs("p",{className:"text-xs font-medium text-mastra-el-4",children:["Version ",e+1]}),t.status==="active"&&g.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-green-500/20 text-green-500",children:"Active"}),t.status==="original"&&g.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-500",children:"Original"}),t.status==="draft"&&g.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-yellow-500/20 text-yellow-500",children:"Draft"})]}),g.jsx("p",{className:"text-[10px] text-mastra-el-3",children:t.timestamp.toLocaleString()})]})]}),g.jsx(Tfe,{version:t,index:e,isUpdating:i,isAnalysisExpanded:r===e,onSetActive:a,onDelete:l,onToggleAnalysis:o})]}),n&&g.jsx(Mn,{className:"h-[250px]",children:g.jsxs("div",{className:"px-2 pb-2 space-y-2",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center space-x-1 cursor-pointer hover:bg-mastra-bg-3/50 p-1 rounded-md mb-2",onClick:k=>{k.stopPropagation(),p(!d)},children:[g.jsx(rh,{className:`h-3 w-3 transition-transform ${d?"rotate-90":""}`}),g.jsx("p",{className:"text-xs font-medium text-mastra-el-4",children:"Instructions"})]}),d&&g.jsx("div",{className:"rounded-md border border-mastra-bg-3",children:g.jsx("div",{className:"mt-2",children:g.jsx(P$,{content:b(t.content),isCopied:w,onCopy:v})})})]}),t.analysis&&g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center space-x-1 cursor-pointer hover:bg-mastra-bg-3/50 p-1 rounded-md mb-2",onClick:k=>{k.stopPropagation(),y(!m)},children:[g.jsx(rh,{className:`h-3 w-3 transition-transform ${m?"rotate-90":""}`}),g.jsx("p",{className:"text-xs font-medium text-mastra-el-4",children:"Analysis"})]}),m&&g.jsx("div",{className:"rounded-md border border-mastra-bg-3",children:g.jsx("div",{className:"p-2",children:g.jsx("pre",{className:"text-[10px] text-mastra-el-4 whitespace-pre-wrap font-mono",children:b(t.analysis||"")})})})]}),t.evals&&t.evals.length>0&&g.jsxs("div",{className:"space-y-1",children:[g.jsxs("div",{className:"flex items-center space-x-1 cursor-pointer hover:bg-mastra-bg-3/50 p-1 rounded-md",onClick:k=>{k.stopPropagation(),c(!u)},children:[g.jsx(rh,{className:`h-3 w-3 transition-transform ${u?"rotate-90":""}`}),g.jsxs("p",{className:"text-xs font-medium text-mastra-el-4",children:["Evaluations (",t.evals.length,")"]})]}),u&&g.jsx("div",{className:"pl-4",children:g.jsx("div",{className:"space-y-1 pr-4",children:t.evals.map((k,E)=>g.jsxs("div",{className:"rounded-md border border-mastra-bg-3 p-1.5 text-[10px]",children:[g.jsx("div",{className:"flex items-center justify-between",children:g.jsxs("div",{className:"flex items-center space-x-2",children:[g.jsx("span",{className:`px-1.5 py-0.5 rounded-full min-w-[32px] text-center ${k.result.score>=.7?"bg-green-500/20 text-green-500":k.result.score>=.4?"bg-yellow-500/20 text-yellow-500":"bg-red-500/20 text-red-500"}`,children:k.result.score.toFixed(2)}),g.jsx("span",{className:"text-mastra-el-3 text-[9px]",children:new Date(k.createdAt).toLocaleTimeString()})]})}),g.jsxs("div",{className:"mt-1 space-y-1",children:[g.jsxs("div",{className:"flex gap-1.5",children:[g.jsx("span",{className:"text-mastra-el-3 shrink-0",children:"→"}),g.jsx("span",{className:"text-mastra-el-4",children:k.input})]}),g.jsxs("div",{className:"flex gap-1.5",children:[g.jsx("span",{className:"text-mastra-el-3 shrink-0",children:"←"}),g.jsx("span",{className:"text-mastra-el-4",children:k.output})]}),g.jsxs("div",{className:"flex gap-1.5 text-[9px] text-mastra-el-3",children:[g.jsx("span",{className:"shrink-0",children:"⚬"}),g.jsx("span",{children:k.result.info.reason})]})]})]},E))})})]})]})})]})}function _fe({versions:t,isUpdating:e,copiedVersions:n,onCopy:r,onSetActive:i,onDelete:s}){const[o,a]=S.useState(null),[l,u]=S.useState(null);return g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsx("div",{className:"flex items-center justify-between mb-1.5",children:g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-medium text-mastra-el-5",children:"Version History"}),g.jsx("p",{className:"text-xs text-mastra-el-3",children:"Previous versions of the instructions"})]})}),g.jsx(Mn,{className:"flex-1",children:g.jsx("div",{className:"space-y-2 pr-4",children:t.map((c,d)=>g.jsx(Afe,{version:c,index:d,isExpanded:o===d,isAnalysisExpanded:l,isUpdating:e,copiedVersions:n,onToggleExpand:()=>{if(o===d)return a(null);a(d)},onToggleAnalysis:()=>{if(l===d)return u(null);u(d)},onCopy:r,onSetActive:i,onDelete:s},d))})})]})}function Mfe({agentId:t,instructions:e,versions:n,onVersionCreate:r,onVersionUpdate:i}){const[s,o]=S.useState(""),[a,l]=S.useState(""),[u,c]=S.useState(!1),[d,p]=S.useState(!1),[m,y]=S.useState(""),v=async()=>{if(e){c(!0);try{const k=await fetch(`http://localhost:4111/api/agents/${t}/instructions/enhance`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:e,comment:m})});if(!k.ok)throw new Error("Failed to enhance prompt");const E=await k.json();o(E.new_prompt),l(E.explanation),y(""),p(!1)}catch(k){console.error("Failed to enhance prompt:",k)}finally{c(!1)}}},w=()=>{o(""),l("")};return{enhancedPrompt:s,explanation:a,isEnhancing:u,userComment:m,showCommentInput:d,enhancePrompt:v,setUserComment:y,setShowCommentInput:p,clearEnhancement:w,applyChanges:()=>{if(!s)return;const k=n.findIndex(E=>E.status==="draft");k!==-1?i(k,{content:s,analysis:a,status:"published",timestamp:new Date}):r({content:s,timestamp:new Date,analysis:a,status:"published"}),w()}}}function Pfe(t,e){const[n,r]=S.useState([]),[i,s]=S.useState({}),[o,a]=S.useState(!1),[l,u]=S.useState(null),c=async()=>{try{const v=await fetch(`/api/agents/${t}/evals/live`,{method:"GET"});if(!v.ok)throw new Error("Failed to fetch eval results");const w=await v.json();return w==null?void 0:w.evals}catch(v){return console.error("Failed to fetch eval results:",v),[]}};return S.useEffect(()=>{(async()=>{const w=await c(),b=localStorage.getItem(`agent-${t}-versions`);if(b){const k=JSON.parse(b),E=k.find(N=>N.status==="original");if(e&&E&&E.content!==e){const N=w==null?void 0:w.filter(_=>_.meta.instructions===e),A=[{content:e,timestamp:new Date,analysis:"Original instructions",status:"original",evals:N}];A[0].evals=w,r(A),localStorage.setItem(`agent-${t}-versions`,JSON.stringify(A))}else{const N=await Promise.all(k.map(async A=>{const _=w==null?void 0:w.filter(R=>R.meta.instructions===A.content);return{...{...A,timestamp:new Date(A.timestamp),status:A.content===e?"active":A.status==="active"?"published":A.status},evals:_}}));r(N)}}else if(e){const k=[{content:e,timestamp:new Date,analysis:"Original instructions",status:"original",evals:[]}],E=w==null?void 0:w.filter(N=>N.meta.instructions===e);k[0].evals=E,r(k),localStorage.setItem(`agent-${t}-versions`,JSON.stringify(k))}})()},[e,t]),S.useEffect(()=>{n.length>0&&localStorage.setItem(`agent-${t}-versions`,JSON.stringify(n))},[n,t]),{versions:n,copiedVersions:i,isUpdating:o,versionToDelete:l,setVersions:r,setVersionToDelete:u,copyToClipboard:async(v,w)=>{s(k=>({...k,[w]:!0}));const b=setTimeout(()=>{s(k=>({...k,[w]:!1}))},1e3);return()=>clearTimeout(b)},setVersionActive:async(v,w)=>{a(!0);try{if(!(await fetch(`http://localhost:4111/api/agents/${t}/instructions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({instructions:v.content})})).ok)throw new Error("Failed to update instructions");r(k=>k.map((E,N)=>({...E,status:N===w?"active":E.status==="active"?"published":E.status})))}catch(b){console.error("Failed to set version as active:",b)}finally{a(!1)}},deleteVersion:v=>{r(w=>w.filter((b,k)=>k!==v)),u(null)},updateVersion:async(v,w)=>{const b={...n[v],...w};r(k=>k.map((E,N)=>N===v?b:E))}}}function Rfe({agentId:t}){const{agent:e}=Pu(t),{versions:n,isUpdating:r,versionToDelete:i,setVersions:s,setVersionToDelete:o,deleteVersion:a,updateVersion:l,setVersionActive:u}=Pfe(t,e==null?void 0:e.instructions),{enhancedPrompt:c,isEnhancing:d,userComment:p,showCommentInput:m,enhancePrompt:y,setUserComment:v,setShowCommentInput:w,clearEnhancement:b,applyChanges:k}=Mfe({agentId:t,instructions:e==null?void 0:e.instructions,versions:n,onVersionCreate:E=>{s(N=>[...N,E])},onVersionUpdate:l});return g.jsxs("div",{className:"grid p-4 h-full",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsx(Nfe,{instructions:e==null?void 0:e.instructions,enhancedPrompt:c,isEnhancing:d,showCommentInput:m,userComment:p,onEnhance:y,onCancel:b,onSave:k,onCommentToggle:()=>w(!m),onCommentChange:v}),g.jsx(_fe,{versions:n,isUpdating:r,copiedVersions:{},onCopy:async()=>{},onSetActive:u,onDelete:o})]}),g.jsx(tn,{open:i!==null,onOpenChange:()=>o(null),children:g.jsxs(tn.Content,{children:[g.jsxs(tn.Header,{children:[g.jsxs(tn.Title,{children:["Delete Version ",i!==null?i+1:""]}),g.jsx(tn.Description,{children:"Are you sure you want to delete this version? This action cannot be undone."})]}),g.jsxs(tn.Footer,{children:[g.jsx(tn.Cancel,{children:"Cancel"}),g.jsx(tn.Action,{className:"bg-red-500 hover:bg-red-600",onClick:()=>{i!==null&&a(i)},children:"Delete"})]})]})})]})}const R$=t=>{const[e,n]=S.useState([]),[r,i]=S.useState(!0),s=async o=>{i(!0);try{const a=await fetch(`/api/logs/${o??t}`);if(!a.ok){const u=await a.json();n([]),console.error("Error fetching logs",u),kn.error((u==null?void 0:u.error)||"Error fetching logs");return}const l=await a.json();n(l)}catch(a){n([]),console.error("Error fetching logs",a),kn.error("Error fetching logs")}finally{i(!1)}};return S.useEffect(()=>{s(t)},[t]),{logs:e,isLoading:r,refetchLogs:s}};function Ofe({agentId:t}){const{logs:e,isLoading:n,refetchLogs:r}=R$(t);return g.jsxs(Mn,{className:"h-[calc(100vh-126px)] px-4 pb-4 text-xs w-[400px]",children:[g.jsx("div",{className:"flex justify-end sticky top-0 bg-mastra-bg-2 py-2",children:g.jsx(ht,{variant:"outline",onClick:()=>r(),children:n?g.jsx(Jc,{className:"w-4 h-4 animate-spin"}):g.jsx(Jc,{className:"w-4 h-4"})})}),g.jsx("div",{className:"space-y-4",children:e.length===0?g.jsxs("p",{className:"text-gray-300/60",children:["No log drains. By default, logs are sent to the console. To configure log drains see"," ",g.jsx("a",{href:"https://mastra.ai/docs/reference/observability/create-logger#upstash-logger-remote-log-drain",target:"_blank",rel:"noopener",className:" hover:text-gray-100 underline",children:"docs."})]}):e.map(i=>{const s=JSON.parse(i.message);return g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex gap-2 items-center",children:[g.jsxs("p",{className:"text-mastra-el-4",children:["[",i.timestamp,"]"]}),g.jsxs("p",{className:"text-mastra-el-5",children:["[",i.level,"]"]})]}),g.jsx("p",{className:"text-mastra-el-5 whitespace-pre-wrap",children:g.jsx("code",{children:JSON.stringify(s,null,2)})})]},i.timestamp)})})]})}function Dx({agentId:t}){return g.jsxs(aA,{defaultValue:"details",children:[g.jsxs(hv,{className:"flex shrink-0 border-b",children:[g.jsx(Xs,{value:"details",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Details"})}),g.jsx(Xs,{value:"instructions",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Instructions"})}),g.jsx(Xs,{value:"endpoints",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Endpoints"})}),g.jsx(Xs,{value:"logs",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Log Drains"})})]}),g.jsx(Zs,{value:"details",children:t?g.jsx(Qce,{agentId:t}):null}),g.jsx(Zs,{value:"endpoints",children:g.jsx(Jce,{agentId:t})}),g.jsx(Zs,{value:"logs",children:g.jsx(Ofe,{agentId:t})}),g.jsx(Zs,{value:"instructions",children:g.jsx(Rfe,{agentId:t})})]})}const Dfe=["top","right","bottom","left"],ul=Math.min,ki=Math.max,jx=Math.round,ay=Math.floor,io=t=>({x:t,y:t}),jfe={left:"right",right:"left",bottom:"top",top:"bottom"},Ife={start:"end",end:"start"};function eE(t,e,n){return ki(t,ul(e,n))}function ra(t,e){return typeof t=="function"?t(e):t}function ia(t){return t.split("-")[0]}function Vd(t){return t.split("-")[1]}function pA(t){return t==="x"?"y":"x"}function mA(t){return t==="y"?"height":"width"}function cl(t){return["top","bottom"].includes(ia(t))?"y":"x"}function gA(t){return pA(cl(t))}function Lfe(t,e,n){n===void 0&&(n=!1);const r=Vd(t),i=gA(t),s=mA(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Ix(o)),[o,Ix(o)]}function Ffe(t){const e=Ix(t);return[tE(t),e,tE(e)]}function tE(t){return t.replace(/start|end/g,e=>Ife[e])}function Bfe(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function zfe(t,e,n,r){const i=Vd(t);let s=Bfe(ia(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(tE)))),s}function Ix(t){return t.replace(/left|right|bottom|top/g,e=>jfe[e])}function $fe(t){return{top:0,right:0,bottom:0,left:0,...t}}function O$(t){return typeof t!="number"?$fe(t):{top:t,right:t,bottom:t,left:t}}function Lx(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function mD(t,e,n){let{reference:r,floating:i}=t;const s=cl(e),o=gA(e),a=mA(o),l=ia(e),u=s==="y",c=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,p=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:c,y:r.y-i.height};break;case"bottom":m={x:c,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-i.width,y:d};break;default:m={x:r.x,y:r.y}}switch(Vd(e)){case"start":m[o]-=p*(n&&u?-1:1);break;case"end":m[o]+=p*(n&&u?-1:1);break}return m}const Vfe=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:c,y:d}=mD(u,r,l),p=r,m={},y=0;for(let v=0;v<a.length;v++){const{name:w,fn:b}=a[v],{x:k,y:E,data:N,reset:A}=await b({x:c,y:d,initialPlacement:r,placement:p,strategy:i,middlewareData:m,rects:u,platform:o,elements:{reference:t,floating:e}});c=k??c,d=E??d,m={...m,[w]:{...m[w],...N}},A&&y<=50&&(y++,typeof A=="object"&&(A.placement&&(p=A.placement),A.rects&&(u=A.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):A.rects),{x:c,y:d}=mD(u,p,l)),v=-1)}return{x:c,y:d,placement:p,strategy:i,middlewareData:m}};async function ep(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:p=!1,padding:m=0}=ra(e,t),y=O$(m),w=a[p?d==="floating"?"reference":"floating":d],b=Lx(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:c,strategy:l})),k=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=await(s.isElement==null?void 0:s.isElement(E))?await(s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},A=Lx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:k,offsetParent:E,strategy:l}):k);return{top:(b.top-A.top+y.top)/N.y,bottom:(A.bottom-b.bottom+y.bottom)/N.y,left:(b.left-A.left+y.left)/N.x,right:(A.right-b.right+y.right)/N.x}}const Wfe=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:u,padding:c=0}=ra(t,e)||{};if(u==null)return{};const d=O$(c),p={x:n,y:r},m=gA(i),y=mA(m),v=await o.getDimensions(u),w=m==="y",b=w?"top":"left",k=w?"bottom":"right",E=w?"clientHeight":"clientWidth",N=s.reference[y]+s.reference[m]-p[m]-s.floating[y],A=p[m]-s.reference[m],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let M=_?_[E]:0;(!M||!await(o.isElement==null?void 0:o.isElement(_)))&&(M=a.floating[E]||s.floating[y]);const R=N/2-A/2,D=M/2-v[y]/2-1,O=ul(d[b],D),B=ul(d[k],D),F=O,V=M-v[y]-B,I=M/2-v[y]/2+R,Y=eE(F,I,V),W=!l.arrow&&Vd(i)!=null&&I!==Y&&s.reference[y]/2-(I<F?O:B)-v[y]/2<0,G=W?I<F?I-F:I-V:0;return{[m]:p[m]+G,data:{[m]:Y,centerOffset:I-Y-G,...W&&{alignmentOffset:G}},reset:W}}}),Hfe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:u}=e,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...w}=ra(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=ia(i),k=cl(a),E=ia(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),A=p||(E||!v?[Ix(a)]:Ffe(a)),_=y!=="none";!p&&_&&A.push(...zfe(a,v,y,N));const M=[a,...A],R=await ep(e,w),D=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(c&&D.push(R[b]),d){const I=Lfe(i,o,N);D.push(R[I[0]],R[I[1]])}if(O=[...O,{placement:i,overflows:D}],!D.every(I=>I<=0)){var B,F;const I=(((B=s.flip)==null?void 0:B.index)||0)+1,Y=M[I];if(Y)return{data:{index:I,overflows:O},reset:{placement:Y}};let W=(F=O.filter(G=>G.overflows[0]<=0).sort((G,H)=>G.overflows[1]-H.overflows[1])[0])==null?void 0:F.placement;if(!W)switch(m){case"bestFit":{var V;const G=(V=O.filter(H=>{if(_){const $=cl(H.placement);return $===k||$==="y"}return!0}).map(H=>[H.placement,H.overflows.filter($=>$>0).reduce(($,L)=>$+L,0)]).sort((H,$)=>H[1]-$[1])[0])==null?void 0:V[0];G&&(W=G);break}case"initialPlacement":W=a;break}if(i!==W)return{reset:{placement:W}}}return{}}}};function gD(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function yD(t){return Dfe.some(e=>t[e]>=0)}const Ufe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=ra(t,e);switch(r){case"referenceHidden":{const s=await ep(e,{...i,elementContext:"reference"}),o=gD(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:yD(o)}}}case"escaped":{const s=await ep(e,{...i,altBoundary:!0}),o=gD(s,n.floating);return{data:{escapedOffsets:o,escaped:yD(o)}}}default:return{}}}}};async function qfe(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ia(n),a=Vd(n),l=cl(n)==="y",u=["left","top"].includes(o)?-1:1,c=s&&l?-1:1,d=ra(e,t);let{mainAxis:p,crossAxis:m,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof y=="number"&&(m=a==="end"?y*-1:y),l?{x:m*c,y:p*u}:{x:p*u,y:m*c}}const Yfe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await qfe(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},Gfe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:w=>{let{x:b,y:k}=w;return{x:b,y:k}}},...l}=ra(t,e),u={x:n,y:r},c=await ep(e,l),d=cl(ia(i)),p=pA(d);let m=u[p],y=u[d];if(s){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",k=m+c[w],E=m-c[b];m=eE(k,m,E)}if(o){const w=d==="y"?"top":"left",b=d==="y"?"bottom":"right",k=y+c[w],E=y-c[b];y=eE(k,y,E)}const v=a.fn({...e,[p]:m,[d]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[p]:s,[d]:o}}}}}},Kfe=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=ra(t,e),c={x:n,y:r},d=cl(i),p=pA(d);let m=c[p],y=c[d];const v=ra(a,e),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const E=p==="y"?"height":"width",N=s.reference[p]-s.floating[E]+w.mainAxis,A=s.reference[p]+s.reference[E]-w.mainAxis;m<N?m=N:m>A&&(m=A)}if(u){var b,k;const E=p==="y"?"width":"height",N=["top","left"].includes(ia(i)),A=s.reference[d]-s.floating[E]+(N&&((b=o.offset)==null?void 0:b[d])||0)+(N?0:w.crossAxis),_=s.reference[d]+s.reference[E]+(N?0:((k=o.offset)==null?void 0:k[d])||0)-(N?w.crossAxis:0);y<A?y=A:y>_&&(y=_)}return{[p]:m,[d]:y}}}},Xfe=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...u}=ra(t,e),c=await ep(e,u),d=ia(i),p=Vd(i),m=cl(i)==="y",{width:y,height:v}=s.floating;let w,b;d==="top"||d==="bottom"?(w=d,b=p===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=d,w=p==="end"?"top":"bottom");const k=v-c.top-c.bottom,E=y-c.left-c.right,N=ul(v-c[w],k),A=ul(y-c[b],E),_=!e.middlewareData.shift;let M=N,R=A;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(R=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=k),_&&!p){const O=ki(c.left,0),B=ki(c.right,0),F=ki(c.top,0),V=ki(c.bottom,0);m?R=y-2*(O!==0||B!==0?O+B:ki(c.left,c.right)):M=v-2*(F!==0||V!==0?F+V:ki(c.top,c.bottom))}await l({...e,availableWidth:R,availableHeight:M});const D=await o.getDimensions(a.floating);return y!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}};function yv(){return typeof window<"u"}function Wd(t){return D$(t)?(t.nodeName||"").toLowerCase():"#document"}function Ai(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Co(t){var e;return(e=(D$(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function D$(t){return yv()?t instanceof Node||t instanceof Ai(t).Node:!1}function Ss(t){return yv()?t instanceof Element||t instanceof Ai(t).Element:!1}function mo(t){return yv()?t instanceof HTMLElement||t instanceof Ai(t).HTMLElement:!1}function xD(t){return!yv()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ai(t).ShadowRoot}function um(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Cs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function Zfe(t){return["table","td","th"].includes(Wd(t))}function xv(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function yA(t){const e=xA(),n=Ss(t)?Cs(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Qfe(t){let e=dl(t);for(;mo(e)&&!sd(e);){if(yA(e))return e;if(xv(e))return null;e=dl(e)}return null}function xA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function sd(t){return["html","body","#document"].includes(Wd(t))}function Cs(t){return Ai(t).getComputedStyle(t)}function vv(t){return Ss(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function dl(t){if(Wd(t)==="html")return t;const e=t.assignedSlot||t.parentNode||xD(t)&&t.host||Co(t);return xD(e)?e.host:e}function j$(t){const e=dl(t);return sd(e)?t.ownerDocument?t.ownerDocument.body:t.body:mo(e)&&um(e)?e:j$(e)}function tp(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=j$(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ai(i);if(s){const a=nE(o);return e.concat(o,o.visualViewport||[],um(i)?i:[],a&&n?tp(a):[])}return e.concat(i,tp(i,[],n))}function nE(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function I$(t){const e=Cs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=mo(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=jx(n)!==s||jx(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function vA(t){return Ss(t)?t:t.contextElement}function $c(t){const e=vA(t);if(!mo(e))return io(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=I$(e);let o=(s?jx(n.width):n.width)/r,a=(s?jx(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Jfe=io(0);function L$(t){const e=Ai(t);return!xA()||!e.visualViewport?Jfe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ehe(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ai(t)?!1:e}function gu(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=vA(t);let o=io(1);e&&(r?Ss(r)&&(o=$c(r)):o=$c(t));const a=ehe(s,n,r)?L$(s):io(0);let l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(s){const p=Ai(s),m=r&&Ss(r)?Ai(r):r;let y=p,v=nE(y);for(;v&&r&&m!==y;){const w=$c(v),b=v.getBoundingClientRect(),k=Cs(v),E=b.left+(v.clientLeft+parseFloat(k.paddingLeft))*w.x,N=b.top+(v.clientTop+parseFloat(k.paddingTop))*w.y;l*=w.x,u*=w.y,c*=w.x,d*=w.y,l+=E,u+=N,y=Ai(v),v=nE(y)}}return Lx({width:c,height:d,x:l,y:u})}function wA(t,e){const n=vv(t).scrollLeft;return e?e.left+n:gu(Co(t)).left+n}function F$(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:wA(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function the(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Co(r),a=e?xv(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=io(1);const c=io(0),d=mo(r);if((d||!d&&!s)&&((Wd(r)!=="body"||um(o))&&(l=vv(r)),mo(r))){const m=gu(r);u=$c(r),c.x=m.x+r.clientLeft,c.y=m.y+r.clientTop}const p=o&&!d&&!s?F$(o,l,!0):io(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+p.x,y:n.y*u.y-l.scrollTop*u.y+c.y+p.y}}function nhe(t){return Array.from(t.getClientRects())}function rhe(t){const e=Co(t),n=vv(t),r=t.ownerDocument.body,i=ki(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=ki(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+wA(t);const a=-n.scrollTop;return Cs(r).direction==="rtl"&&(o+=ki(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function ihe(t,e){const n=Ai(t),r=Co(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=xA();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function she(t,e){const n=gu(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=mo(t)?$c(t):io(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,u=r*s.y;return{width:o,height:a,x:l,y:u}}function vD(t,e,n){let r;if(e==="viewport")r=ihe(t,n);else if(e==="document")r=rhe(Co(t));else if(Ss(e))r=she(e,n);else{const i=L$(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Lx(r)}function B$(t,e){const n=dl(t);return n===e||!Ss(n)||sd(n)?!1:Cs(n).position==="fixed"||B$(n,e)}function ohe(t,e){const n=e.get(t);if(n)return n;let r=tp(t,[],!1).filter(a=>Ss(a)&&Wd(a)!=="body"),i=null;const s=Cs(t).position==="fixed";let o=s?dl(t):t;for(;Ss(o)&&!sd(o);){const a=Cs(o),l=yA(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||um(o)&&!l&&B$(t,o))?r=r.filter(c=>c!==o):i=a,o=dl(o)}return e.set(t,r),r}function ahe(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?xv(e)?[]:ohe(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((u,c)=>{const d=vD(e,c,i);return u.top=ki(d.top,u.top),u.right=ul(d.right,u.right),u.bottom=ul(d.bottom,u.bottom),u.left=ki(d.left,u.left),u},vD(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function lhe(t){const{width:e,height:n}=I$(t);return{width:e,height:n}}function uhe(t,e,n){const r=mo(e),i=Co(e),s=n==="fixed",o=gu(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=io(0);if(r||!r&&!s)if((Wd(e)!=="body"||um(i))&&(a=vv(e)),r){const p=gu(e,!0,s,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else i&&(l.x=wA(i));const u=i&&!r&&!s?F$(i,a):io(0),c=o.left+a.scrollLeft-l.x-u.x,d=o.top+a.scrollTop-l.y-u.y;return{x:c,y:d,width:o.width,height:o.height}}function ik(t){return Cs(t).position==="static"}function wD(t,e){if(!mo(t)||Cs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Co(t)===n&&(n=n.ownerDocument.body),n}function z$(t,e){const n=Ai(t);if(xv(t))return n;if(!mo(t)){let i=dl(t);for(;i&&!sd(i);){if(Ss(i)&&!ik(i))return i;i=dl(i)}return n}let r=wD(t,e);for(;r&&Zfe(r)&&ik(r);)r=wD(r,e);return r&&sd(r)&&ik(r)&&!yA(r)?n:r||Qfe(t)||n}const che=async function(t){const e=this.getOffsetParent||z$,n=this.getDimensions,r=await n(t.floating);return{reference:uhe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function dhe(t){return Cs(t).direction==="rtl"}const fhe={convertOffsetParentRelativeRectToViewportRelativeRect:the,getDocumentElement:Co,getClippingRect:ahe,getOffsetParent:z$,getElementRects:che,getClientRects:nhe,getDimensions:lhe,getScale:$c,isElement:Ss,isRTL:dhe};function $$(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function hhe(t,e){let n=null,r;const i=Co(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=t.getBoundingClientRect(),{left:c,top:d,width:p,height:m}=u;if(a||e(),!p||!m)return;const y=ay(d),v=ay(i.clientWidth-(c+p)),w=ay(i.clientHeight-(d+m)),b=ay(c),E={rootMargin:-y+"px "+-v+"px "+-w+"px "+-b+"px",threshold:ki(0,ul(1,l))||1};let N=!0;function A(_){const M=_[0].intersectionRatio;if(M!==l){if(!N)return o();M?o(!1,M):r=setTimeout(()=>{o(!1,1e-7)},1e3)}M===1&&!$$(u,t.getBoundingClientRect())&&o(),N=!1}try{n=new IntersectionObserver(A,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(A,E)}n.observe(t)}return o(!0),s}function phe(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=vA(t),c=i||s?[...u?tp(u):[],...tp(e)]:[];c.forEach(b=>{i&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const d=u&&a?hhe(u,n):null;let p=-1,m=null;o&&(m=new ResizeObserver(b=>{let[k]=b;k&&k.target===u&&m&&(m.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var E;(E=m)==null||E.observe(e)})),n()}),u&&!l&&m.observe(u),m.observe(e));let y,v=l?gu(t):null;l&&w();function w(){const b=gu(t);v&&!$$(v,b)&&n(),v=b,y=requestAnimationFrame(w)}return n(),()=>{var b;c.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),d==null||d(),(b=m)==null||b.disconnect(),m=null,l&&cancelAnimationFrame(y)}}const mhe=Yfe,ghe=Gfe,yhe=Hfe,xhe=Xfe,vhe=Ufe,bD=Wfe,whe=Kfe,bhe=(t,e,n)=>{const r=new Map,i={platform:fhe,...n},s={...i.platform,_c:r};return Vfe(t,e,{...i,platform:s})};var Jy=typeof document<"u"?S.useLayoutEffect:S.useEffect;function Fx(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Fx(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!Fx(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function V$(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function kD(t,e){const n=V$(t);return Math.round(e*n)/n}function sk(t){const e=S.useRef(t);return Jy(()=>{e.current=t}),e}function khe(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:u}=t,[c,d]=S.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[p,m]=S.useState(r);Fx(p,r)||m(r);const[y,v]=S.useState(null),[w,b]=S.useState(null),k=S.useCallback(H=>{H!==_.current&&(_.current=H,v(H))},[]),E=S.useCallback(H=>{H!==M.current&&(M.current=H,b(H))},[]),N=s||y,A=o||w,_=S.useRef(null),M=S.useRef(null),R=S.useRef(c),D=l!=null,O=sk(l),B=sk(i),F=sk(u),V=S.useCallback(()=>{if(!_.current||!M.current)return;const H={placement:e,strategy:n,middleware:p};B.current&&(H.platform=B.current),bhe(_.current,M.current,H).then($=>{const L={...$,isPositioned:F.current!==!1};I.current&&!Fx(R.current,L)&&(R.current=L,Dd.flushSync(()=>{d(L)}))})},[p,e,n,B,F]);Jy(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,d(H=>({...H,isPositioned:!1})))},[u]);const I=S.useRef(!1);Jy(()=>(I.current=!0,()=>{I.current=!1}),[]),Jy(()=>{if(N&&(_.current=N),A&&(M.current=A),N&&A){if(O.current)return O.current(N,A,V);V()}},[N,A,V,O,D]);const Y=S.useMemo(()=>({reference:_,floating:M,setReference:k,setFloating:E}),[k,E]),W=S.useMemo(()=>({reference:N,floating:A}),[N,A]),G=S.useMemo(()=>{const H={position:n,left:0,top:0};if(!W.floating)return H;const $=kD(W.floating,c.x),L=kD(W.floating,c.y);return a?{...H,transform:"translate("+$+"px, "+L+"px)",...V$(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:L}},[n,a,W.floating,c.x,c.y]);return S.useMemo(()=>({...c,update:V,refs:Y,elements:W,floatingStyles:G}),[c,V,Y,W,G])}const She=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?bD({element:r.current,padding:i}).fn(n):{}:r?bD({element:r,padding:i}).fn(n):{}}}},Che=(t,e)=>({...mhe(t),options:[t,e]}),Ehe=(t,e)=>({...ghe(t),options:[t,e]}),Nhe=(t,e)=>({...whe(t),options:[t,e]}),The=(t,e)=>({...yhe(t),options:[t,e]}),Ahe=(t,e)=>({...xhe(t),options:[t,e]}),_he=(t,e)=>({...vhe(t),options:[t,e]}),Mhe=(t,e)=>({...She(t),options:[t,e]});var Phe="Arrow",W$=S.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return g.jsx(Ze.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});W$.displayName=Phe;var Rhe=W$;function H$(t){const[e,n]=S.useState(void 0);return Ar(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;o=u.inlineSize,a=u.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var bA="Popper",[U$,El]=Oi(bA),[Ohe,q$]=U$(bA),Y$=t=>{const{__scopePopper:e,children:n}=t,[r,i]=S.useState(null);return g.jsx(Ohe,{scope:e,anchor:r,onAnchorChange:i,children:n})};Y$.displayName=bA;var G$="PopperAnchor",K$=S.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=q$(G$,n),o=S.useRef(null),a=kt(e,o);return S.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:g.jsx(Ze.div,{...i,ref:a})});K$.displayName=G$;var kA="PopperContent",[Dhe,jhe]=U$(kA),X$=S.forwardRef((t,e)=>{var ee,se,de,pe,Te,he;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:y,...v}=t,w=q$(kA,n),[b,k]=S.useState(null),E=kt(e,we=>k(we)),[N,A]=S.useState(null),_=H$(N),M=(_==null?void 0:_.width)??0,R=(_==null?void 0:_.height)??0,D=r+(s!=="center"?"-"+s:""),O=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},B=Array.isArray(u)?u:[u],F=B.length>0,V={padding:O,boundary:B.filter(Lhe),altBoundary:F},{refs:I,floatingStyles:Y,placement:W,isPositioned:G,middlewareData:H}=khe({strategy:"fixed",placement:D,whileElementsMounted:(...we)=>phe(...we,{animationFrame:m==="always"}),elements:{reference:w.anchor},middleware:[Che({mainAxis:i+R,alignmentAxis:o}),l&&Ehe({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?Nhe():void 0,...V}),l&&The({...V}),Ahe({...V,apply:({elements:we,rects:Ie,availableWidth:Ke,availableHeight:pt})=>{const{width:Vt,height:Q}=Ie.reference,oe=we.floating.style;oe.setProperty("--radix-popper-available-width",`${Ke}px`),oe.setProperty("--radix-popper-available-height",`${pt}px`),oe.setProperty("--radix-popper-anchor-width",`${Vt}px`),oe.setProperty("--radix-popper-anchor-height",`${Q}px`)}}),N&&Mhe({element:N,padding:a}),Fhe({arrowWidth:M,arrowHeight:R}),p&&_he({strategy:"referenceHidden",...V})]}),[$,L]=J$(W),q=Fn(y);Ar(()=>{G&&(q==null||q())},[G,q]);const U=(ee=H.arrow)==null?void 0:ee.x,j=(se=H.arrow)==null?void 0:se.y,K=((de=H.arrow)==null?void 0:de.centerOffset)!==0,[X,J]=S.useState();return Ar(()=>{b&&J(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:G?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(pe=H.transformOrigin)==null?void 0:pe.x,(Te=H.transformOrigin)==null?void 0:Te.y].join(" "),...((he=H.hide)==null?void 0:he.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(Dhe,{scope:n,placedSide:$,onArrowChange:A,arrowX:U,arrowY:j,shouldHideArrow:K,children:g.jsx(Ze.div,{"data-side":$,"data-align":L,...v,ref:E,style:{...v.style,animation:G?void 0:"none"}})})})});X$.displayName=kA;var Z$="PopperArrow",Ihe={top:"bottom",right:"left",bottom:"top",left:"right"},Q$=S.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=jhe(Z$,r),o=Ihe[s.placedSide];return g.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:g.jsx(Rhe,{...i,ref:n,style:{...i.style,display:"block"}})})});Q$.displayName=Z$;function Lhe(t){return t!==null}var Fhe=t=>({name:"transformOrigin",options:t,fn(e){var w,b,k;const{placement:n,rects:r,middlewareData:i}=e,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[u,c]=J$(n),d={start:"0%",center:"50%",end:"100%"}[c],p=(((b=i.arrow)==null?void 0:b.x)??0)+a/2,m=(((k=i.arrow)==null?void 0:k.y)??0)+l/2;let y="",v="";return u==="bottom"?(y=o?d:`${p}px`,v=`${-l}px`):u==="top"?(y=o?d:`${p}px`,v=`${r.floating.height+l}px`):u==="right"?(y=`${-l}px`,v=o?d:`${m}px`):u==="left"&&(y=`${r.floating.width+l}px`,v=o?d:`${m}px`),{data:{x:y,y:v}}}});function J$(t){const[e,n="center"]=t.split("-");return[e,n]}var cm=Y$,dm=K$,wv=X$,bv=Q$,rE=["Enter"," "],Bhe=["ArrowDown","PageUp","Home"],eV=["ArrowUp","PageDown","End"],zhe=[...Bhe,...eV],$he={ltr:[...rE,"ArrowRight"],rtl:[...rE,"ArrowLeft"]},Vhe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fm="Menu",[np,Whe,Hhe]=iA(fm),[Du,tV]=Oi(fm,[Hhe,El,fv]),hm=El(),nV=fv(),[rV,Nl]=Du(fm),[Uhe,pm]=Du(fm),iV=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=hm(e),[l,u]=S.useState(null),c=S.useRef(!1),d=Fn(s),p=Zp(i);return S.useEffect(()=>{const m=()=>{c.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>c.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),g.jsx(cm,{...a,children:g.jsx(rV,{scope:e,open:n,onOpenChange:d,content:l,onContentChange:u,children:g.jsx(Uhe,{scope:e,onClose:S.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:c,dir:p,modal:o,children:r})})})};iV.displayName=fm;var qhe="MenuAnchor",SA=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=hm(n);return g.jsx(dm,{...i,...r,ref:e})});SA.displayName=qhe;var CA="MenuPortal",[Yhe,sV]=Du(CA,{forceMount:void 0}),oV=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=Nl(CA,e);return g.jsx(Yhe,{scope:e,forceMount:n,children:g.jsx(Pr,{present:n||s.open,children:g.jsx(am,{asChild:!0,container:i,children:r})})})};oV.displayName=CA;var Zi="MenuContent",[Ghe,EA]=Du(Zi),aV=S.forwardRef((t,e)=>{const n=sV(Zi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Nl(Zi,t.__scopeMenu),o=pm(Zi,t.__scopeMenu);return g.jsx(np.Provider,{scope:t.__scopeMenu,children:g.jsx(Pr,{present:r||s.open,children:g.jsx(np.Slot,{scope:t.__scopeMenu,children:o.modal?g.jsx(Khe,{...i,ref:e}):g.jsx(Xhe,{...i,ref:e})})})})}),Khe=S.forwardRef((t,e)=>{const n=Nl(Zi,t.__scopeMenu),r=S.useRef(null),i=kt(e,r);return S.useEffect(()=>{const s=r.current;if(s)return gv(s)},[]),g.jsx(NA,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Xhe=S.forwardRef((t,e)=>{const n=Nl(Zi,t.__scopeMenu);return g.jsx(NA,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),NA=S.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,onDismiss:m,disableOutsideScroll:y,...v}=t,w=Nl(Zi,n),b=pm(Zi,n),k=hm(n),E=nV(n),N=Whe(n),[A,_]=S.useState(null),M=S.useRef(null),R=kt(e,M,w.onContentChange),D=S.useRef(0),O=S.useRef(""),B=S.useRef(0),F=S.useRef(null),V=S.useRef("right"),I=S.useRef(0),Y=y?lm:S.Fragment,W=y?{as:uo,allowPinchZoom:!0}:void 0,G=$=>{var ee,se;const L=O.current+$,q=N().filter(de=>!de.disabled),U=document.activeElement,j=(ee=q.find(de=>de.ref.current===U))==null?void 0:ee.textValue,K=q.map(de=>de.textValue),X=lpe(K,L,j),J=(se=q.find(de=>de.textValue===X))==null?void 0:se.ref.current;(function de(pe){O.current=pe,window.clearTimeout(D.current),pe!==""&&(D.current=window.setTimeout(()=>de(""),1e3))})(L),J&&setTimeout(()=>J.focus())};S.useEffect(()=>()=>window.clearTimeout(D.current),[]),pv();const H=S.useCallback($=>{var q,U;return V.current===((q=F.current)==null?void 0:q.side)&&cpe($,(U=F.current)==null?void 0:U.area)},[]);return g.jsx(Ghe,{scope:n,searchRef:O,onItemEnter:S.useCallback($=>{H($)&&$.preventDefault()},[H]),onItemLeave:S.useCallback($=>{var L;H($)||((L=M.current)==null||L.focus(),_(null))},[H]),onTriggerLeave:S.useCallback($=>{H($)&&$.preventDefault()},[H]),pointerGraceTimerRef:B,onPointerGraceIntentChange:S.useCallback($=>{F.current=$},[]),children:g.jsx(Y,{...W,children:g.jsx(om,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,$=>{var L;$.preventDefault(),(L=M.current)==null||L.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx($d,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:p,onDismiss:m,children:g.jsx(cz,{asChild:!0,...E,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:_,onEntryFocus:Pe(l,$=>{b.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(wv,{role:"menu","aria-orientation":"vertical","data-state":CV(w.open),"data-radix-menu-content":"",dir:b.dir,...k,...v,ref:R,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,$=>{const q=$.target.closest("[data-radix-menu-content]")===$.currentTarget,U=$.ctrlKey||$.altKey||$.metaKey,j=$.key.length===1;q&&($.key==="Tab"&&$.preventDefault(),!U&&j&&G($.key));const K=M.current;if($.target!==K||!zhe.includes($.key))return;$.preventDefault();const J=N().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);eV.includes($.key)&&J.reverse(),ope(J)}),onBlur:Pe(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(D.current),O.current="")}),onPointerMove:Pe(t.onPointerMove,rp($=>{const L=$.target,q=I.current!==$.clientX;if($.currentTarget.contains(L)&&q){const U=$.clientX>I.current?"right":"left";V.current=U,I.current=$.clientX}}))})})})})})})});aV.displayName=Zi;var Zhe="MenuGroup",TA=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Ze.div,{role:"group",...r,ref:e})});TA.displayName=Zhe;var Qhe="MenuLabel",lV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Ze.div,{...r,ref:e})});lV.displayName=Qhe;var Bx="MenuItem",SD="menu.itemSelect",kv=S.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=S.useRef(null),o=pm(Bx,t.__scopeMenu),a=EA(Bx,t.__scopeMenu),l=kt(e,s),u=S.useRef(!1),c=()=>{const d=s.current;if(!n&&d){const p=new CustomEvent(SD,{bubbles:!0,cancelable:!0});d.addEventListener(SD,m=>r==null?void 0:r(m),{once:!0}),K4(d,p),p.defaultPrevented?u.current=!1:o.onClose()}};return g.jsx(uV,{...i,ref:l,disabled:n,onClick:Pe(t.onClick,c),onPointerDown:d=>{var p;(p=t.onPointerDown)==null||p.call(t,d),u.current=!0},onPointerUp:Pe(t.onPointerUp,d=>{var p;u.current||(p=d.currentTarget)==null||p.click()}),onKeyDown:Pe(t.onKeyDown,d=>{const p=a.searchRef.current!=="";n||p&&d.key===" "||rE.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});kv.displayName=Bx;var uV=S.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=EA(Bx,n),a=nV(n),l=S.useRef(null),u=kt(e,l),[c,d]=S.useState(!1),[p,m]=S.useState("");return S.useEffect(()=>{const y=l.current;y&&m((y.textContent??"").trim())},[s.children]),g.jsx(np.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:g.jsx(dz,{asChild:!0,...a,focusable:!r,children:g.jsx(Ze.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:Pe(t.onPointerMove,rp(y=>{r?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(t.onPointerLeave,rp(y=>o.onItemLeave(y))),onFocus:Pe(t.onFocus,()=>d(!0)),onBlur:Pe(t.onBlur,()=>d(!1))})})})}),Jhe="MenuCheckboxItem",cV=S.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return g.jsx(mV,{scope:t.__scopeMenu,checked:n,children:g.jsx(kv,{role:"menuitemcheckbox","aria-checked":zx(n)?"mixed":n,...i,ref:e,"data-state":MA(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(zx(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cV.displayName=Jhe;var dV="MenuRadioGroup",[epe,tpe]=Du(dV,{value:void 0,onValueChange:()=>{}}),fV=S.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Fn(r);return g.jsx(epe,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(TA,{...i,ref:e})})});fV.displayName=dV;var hV="MenuRadioItem",pV=S.forwardRef((t,e)=>{const{value:n,...r}=t,i=tpe(hV,t.__scopeMenu),s=n===i.value;return g.jsx(mV,{scope:t.__scopeMenu,checked:s,children:g.jsx(kv,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":MA(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});pV.displayName=hV;var AA="MenuItemIndicator",[mV,npe]=Du(AA,{checked:!1}),gV=S.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=npe(AA,n);return g.jsx(Pr,{present:r||zx(s.checked)||s.checked===!0,children:g.jsx(Ze.span,{...i,ref:e,"data-state":MA(s.checked)})})});gV.displayName=AA;var rpe="MenuSeparator",yV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Ze.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});yV.displayName=rpe;var ipe="MenuArrow",xV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=hm(n);return g.jsx(bv,{...i,...r,ref:e})});xV.displayName=ipe;var _A="MenuSub",[spe,vV]=Du(_A),wV=t=>{const{__scopeMenu:e,children:n,open:r=!1,onOpenChange:i}=t,s=Nl(_A,e),o=hm(e),[a,l]=S.useState(null),[u,c]=S.useState(null),d=Fn(i);return S.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),g.jsx(cm,{...o,children:g.jsx(rV,{scope:e,open:r,onOpenChange:d,content:u,onContentChange:c,children:g.jsx(spe,{scope:e,contentId:zn(),triggerId:zn(),trigger:a,onTriggerChange:l,children:n})})})};wV.displayName=_A;var ah="MenuSubTrigger",bV=S.forwardRef((t,e)=>{const n=Nl(ah,t.__scopeMenu),r=pm(ah,t.__scopeMenu),i=vV(ah,t.__scopeMenu),s=EA(ah,t.__scopeMenu),o=S.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:t.__scopeMenu},c=S.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return S.useEffect(()=>c,[c]),S.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),g.jsx(SA,{asChild:!0,...u,children:g.jsx(uV,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":CV(n.open),...t,ref:G0(e,i.onTriggerChange),onClick:d=>{var p;(p=t.onClick)==null||p.call(t,d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(t.onPointerMove,rp(d=>{s.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:Pe(t.onPointerLeave,rp(d=>{var m,y;c();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const v=(y=n.content)==null?void 0:y.dataset.side,w=v==="right",b=w?-5:5,k=p[w?"left":"right"],E=p[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+b,y:d.clientY},{x:k,y:p.top},{x:E,y:p.top},{x:E,y:p.bottom},{x:k,y:p.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(t.onKeyDown,d=>{var m;const p=s.searchRef.current!=="";t.disabled||p&&d.key===" "||$he[r.dir].includes(d.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),d.preventDefault())})})})});bV.displayName=ah;var kV="MenuSubContent",SV=S.forwardRef((t,e)=>{const n=sV(Zi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Nl(Zi,t.__scopeMenu),o=pm(Zi,t.__scopeMenu),a=vV(kV,t.__scopeMenu),l=S.useRef(null),u=kt(e,l);return g.jsx(np.Provider,{scope:t.__scopeMenu,children:g.jsx(Pr,{present:r||s.open,children:g.jsx(np.Slot,{scope:t.__scopeMenu,children:g.jsx(NA,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:Pe(t.onFocusOutside,c=>{c.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(t.onEscapeKeyDown,c=>{o.onClose(),c.preventDefault()}),onKeyDown:Pe(t.onKeyDown,c=>{var m;const d=c.currentTarget.contains(c.target),p=Vhe[o.dir].includes(c.key);d&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),c.preventDefault())})})})})})});SV.displayName=kV;function CV(t){return t?"open":"closed"}function zx(t){return t==="indeterminate"}function MA(t){return zx(t)?"indeterminate":t?"checked":"unchecked"}function ope(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function ape(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function lpe(t,e,n){const i=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=ape(t,Math.max(s,0));i.length===1&&(o=o.filter(u=>u!==n));const l=o.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function upe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,u=e[o].x,c=e[o].y;l>r!=c>r&&n<(u-a)*(r-l)/(c-l)+a&&(i=!i)}return i}function cpe(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return upe(n,e)}function rp(t){return e=>e.pointerType==="mouse"?t(e):void 0}var dpe=iV,fpe=SA,hpe=oV,ppe=aV,mpe=TA,gpe=lV,ype=kv,xpe=cV,vpe=fV,wpe=pV,bpe=gV,kpe=yV,Spe=xV,Cpe=wV,Epe=bV,Npe=SV,PA="DropdownMenu",[Tpe,ZIe]=Oi(PA,[tV]),Or=tV(),[Ape,EV]=Tpe(PA),NV=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=t,l=Or(e),u=S.useRef(null),[c=!1,d]=po({prop:i,defaultProp:s,onChange:o});return g.jsx(Ape,{scope:e,triggerId:zn(),triggerRef:u,contentId:zn(),open:c,onOpenChange:d,onOpenToggle:S.useCallback(()=>d(p=>!p),[d]),modal:a,children:g.jsx(dpe,{...l,open:c,onOpenChange:d,dir:r,modal:a,children:n})})};NV.displayName=PA;var TV="DropdownMenuTrigger",AV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=EV(TV,n),o=Or(n);return g.jsx(fpe,{asChild:!0,...o,children:g.jsx(Ze.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:G0(e,s.triggerRef),onPointerDown:Pe(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});AV.displayName=TV;var _pe="DropdownMenuPortal",_V=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Or(e);return g.jsx(hpe,{...r,...n})};_V.displayName=_pe;var MV="DropdownMenuContent",PV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=EV(MV,n),s=Or(n),o=S.useRef(!1);return g.jsx(ppe,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:e,onCloseAutoFocus:Pe(t.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(t.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,c=l.button===2||u;(!i.modal||c)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});PV.displayName=MV;var Mpe="DropdownMenuGroup",RV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(mpe,{...i,...r,ref:e})});RV.displayName=Mpe;var Ppe="DropdownMenuLabel",OV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(gpe,{...i,...r,ref:e})});OV.displayName=Ppe;var Rpe="DropdownMenuItem",DV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(ype,{...i,...r,ref:e})});DV.displayName=Rpe;var Ope="DropdownMenuCheckboxItem",jV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(xpe,{...i,...r,ref:e})});jV.displayName=Ope;var Dpe="DropdownMenuRadioGroup",IV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(vpe,{...i,...r,ref:e})});IV.displayName=Dpe;var jpe="DropdownMenuRadioItem",LV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(wpe,{...i,...r,ref:e})});LV.displayName=jpe;var Ipe="DropdownMenuItemIndicator",FV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(bpe,{...i,...r,ref:e})});FV.displayName=Ipe;var Lpe="DropdownMenuSeparator",BV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(kpe,{...i,...r,ref:e})});BV.displayName=Lpe;var Fpe="DropdownMenuArrow",Bpe=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(Spe,{...i,...r,ref:e})});Bpe.displayName=Fpe;var zpe=t=>{const{__scopeDropdownMenu:e,children:n,open:r,onOpenChange:i,defaultOpen:s}=t,o=Or(e),[a=!1,l]=po({prop:r,defaultProp:s,onChange:i});return g.jsx(Cpe,{...o,open:a,onOpenChange:l,children:n})},$pe="DropdownMenuSubTrigger",zV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(Epe,{...i,...r,ref:e})});zV.displayName=$pe;var Vpe="DropdownMenuSubContent",$V=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Or(n);return g.jsx(Npe,{...i,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});$V.displayName=Vpe;var Wpe=NV,VV=AV,WV=_V,HV=PV,Hpe=RV,UV=OV,qV=DV,YV=jV,Upe=IV,GV=LV,KV=FV,XV=BV,qpe=zpe,ZV=zV,QV=$V;function mc(t,e,n){let r=n.initialDeps??[],i;return()=>{var s,o,a,l;let u;n.key&&((s=n.debug)!=null&&s.call(n))&&(u=Date.now());const c=t();if(!(c.length!==r.length||c.some((m,y)=>r[y]!==m)))return i;r=c;let p;if(n.key&&((o=n.debug)!=null&&o.call(n))&&(p=Date.now()),i=e(...c),n.key&&((a=n.debug)!=null&&a.call(n))){const m=Math.round((Date.now()-u)*100)/100,y=Math.round((Date.now()-p)*100)/100,v=y/16,w=(b,k)=>{for(b=String(b);b.length<k;)b=" "+b;return b};console.info(`%c⏱ ${w(y,5)} /${w(m,5)} ms`,`
339
339
  font-size: .6rem;
340
340
  font-weight: bold;
341
- color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,i),i}}function ok(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Ype=(t,e)=>Math.abs(t-e)<1,Gpe=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},Kpe=t=>t,Xpe=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let i=e;i<=n;i++)r.push(i);return r},Zpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=o[0];if(a!=null&&a.borderBoxSize){const l=a.borderBoxSize[0];if(l){i({width:l.inlineSize,height:l.blockSize});return}}i(n.getBoundingClientRect())});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},CD={passive:!0},Qpe=typeof window>"u"?!0:"onscrollend"in window,Jpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&Qpe?()=>{}:Gpe(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:c,isRtl:d}=t.options;i=c?n.scrollLeft*(d&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);return l(),n.addEventListener("scroll",a,CD),n.addEventListener("scrollend",l,CD),()=>{n.removeEventListener("scroll",a),n.removeEventListener("scrollend",l)}},eme=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(t.getBoundingClientRect()[n.options.horizontal?"width":"height"])},tme=(t,{adjustments:e=0,behavior:n},r)=>{var i,s;const o=t+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class nme{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{this._measureElement(s.target,s)})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Kpe,rangeExtractor:Xpe,onChange:()=>{},measureElement:eme,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=mc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=mc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,i,s,o)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o}),{key:!1}),this.getMeasurements=mc(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,l);for(let c=l;c<n;c++){const d=s(c),p=this.options.lanes===1?u[c-1]:this.getFurthestMeasurement(u,c),m=p?p.end+this.options.gap:r+i,y=a.get(d),v=typeof y=="number"?y:this.options.estimateSize(c),w=m+v,b=p?p.lane:c%this.options.lanes;u[c]={index:c,start:m,size:v,end:w,key:d,lane:b}}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=mc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?rme({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getIndexes=mc(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const i=this.indexFromElement(n),s=this.measurementsCache[i];if(!s)return;const o=s.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(i,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const i=this.measurementsCache[n];if(!i)return;const s=this.itemSizeCache.get(i.key)??i.size,o=r-s;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,i)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(i))});return}this._measureElement(n,void 0)},this.getVirtualItems=mc(()=>[this.getIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return ok(r[JV(0,r.length-1,i=>ok(r[i]).start,n)])},this.getOffsetForAlignment=(n,r)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&n>=s+i&&(r="end"),r==="end"&&(n-=i);const o=this.options.horizontal?"scrollWidth":"scrollHeight",l=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[o]:this.scrollElement[o]:0)-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.measurementsCache[n];if(!i)return;const s=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(i.end>=o+s-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=i.start-this.options.scrollPaddingStart+(i.size-s)/2;switch(r){case"center":return[this.getOffsetForAlignment(a,r),r];case"end":return[this.getOffsetForAlignment(i.end+this.options.scrollPaddingEnd,r),r];default:return[this.getOffsetForAlignment(i.start-this.options.scrollPaddingStart,r),r]}},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:i}={})=>{this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(n,{align:r="auto",behavior:i}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s;this._scrollToOffset(o,{adjustments:void 0,behavior:i}),i!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[u]=ok(this.getOffsetForIndex(n,a));Ype(u,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:i})}else this.scrollToIndex(n,{align:a,behavior:i})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;return r.length===0?i=this.options.paddingStart:i=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(s=>s.end)),Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const JV=(t,e,n,r)=>{for(;t<=e;){const i=(t+e)/2|0,s=n(i);if(s<r)t=i+1;else if(s>r)e=i-1;else return i}return t>0?t-1:0};function rme({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=JV(0,r,a=>t[a].start,n);let o=s;for(;o<r&&t[o].end<n+e;)o++;return{startIndex:s,endIndex:o}}const ED=typeof document<"u"?S.useLayoutEffect:S.useEffect;function ime(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Dd.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new nme(n));return r.setOptions(n),ED(()=>r._didMount(),[]),ED(()=>r._willUpdate()),r}function sme(t){return ime({observeElementRect:Zpe,observeElementOffset:Jpe,scrollToFn:tme,...t})}const ome=Wpe,ame=Hpe,lme=WV,ume=qpe,cme=Upe,e6=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx(VV,{ref:i,className:be("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));e6.displayName=VV.displayName;const t6=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(ZV,{ref:i,className:be("focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",e&&"pl-8",t),...r,children:[n,g.jsx(Wh,{className:"ml-auto -rotate-90"})]}));t6.displayName=ZV.displayName;const n6=S.forwardRef(({className:t,...e},n)=>g.jsx(QV,{ref:n,className:be("popover-backdrop-filter popover-background popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...e}));n6.displayName=QV.displayName;const r6=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(WV,{container:e,children:g.jsx(HV,{ref:i,sideOffset:n,className:be("popover-backdrop-filter bg-mastra-bg-2 popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...r})}));r6.displayName=HV.displayName;const i6=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(qV,{ref:r,className:be("focus:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",e&&"pl-8",t),...n}));i6.displayName=qV.displayName;const s6=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(YV,{ref:i,className:be("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:n,...r,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(KV,{children:g.jsx(UN,{className:"h-2 w-2 fill-current"})})}),e]}));s6.displayName=YV.displayName;const o6=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(GV,{ref:r,className:be("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(KV,{children:g.jsx(RX,{className:"h-2 w-2 fill-current"})})}),e]}));o6.displayName=GV.displayName;const a6=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(UV,{ref:r,className:be("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));a6.displayName=UV.displayName;const l6=S.forwardRef(({className:t,...e},n)=>g.jsx(XV,{ref:n,className:be("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));l6.displayName=XV.displayName;const u6=({className:t,...e})=>g.jsx("span",{className:be("ml-auto text-xs tracking-widest opacity-60",t),...e});u6.displayName="DropdownMenuShortcut";function Qn({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(ome,{modal:r,open:t,onOpenChange:e,children:n})}function dme({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=sme({count:t,estimateSize:()=>35,getScrollElement:()=>i.current,overscan:5,measureElement:typeof window<"u"&&navigator.userAgent.indexOf("Firefox")===-1?o=>o==null?void 0:o.getBoundingClientRect().height:void 0});return g.jsx("div",{ref:i,className:"h-64 overflow-auto",children:g.jsx("div",{className:"relative w-full overflow-auto",style:{height:`${s.getTotalSize()}px`},children:s==null?void 0:s.getVirtualItems().map((o,a)=>g.jsx("button",{className:"text-accent-foreground absolute left-0 top-0 flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors hover:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",style:{height:`${o.size}px`,transform:`translateY(${o.start}px)`},...r,children:n(e[a])},o.index))})})}Qn.Trigger=e6;Qn.Content=r6;Qn.Group=ame;Qn.Portal=lme;Qn.Item=i6;Qn.CheckboxItem=s6;Qn.RadioItem=o6;Qn.Label=a6;Qn.Separator=l6;Qn.Shortcut=u6;Qn.Sub=ume;Qn.SubContent=n6;Qn.SubTrigger=t6;Qn.RadioGroup=cme;Qn.VirtualizedItems=dme;const fme=t=>{const{data:e,isLoading:n,mutate:r}=LT(`/api/memory/status?agentId=${t}`,YN,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},hme=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=LT(`/api/memory/threads?resourceid=${t}&agentId=${e}`,YN,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},pme=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=LT(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>YN(o,!0),{fallbackData:{uiMessages:[],messages:[]},revalidateOnFocus:!1,isPaused:()=>!t,shouldRetryOnError:!1});return S.useEffect(()=>{t&&e&&s()},[t,e]),{messages:r==null?void 0:r.uiMessages,isLoading:i,mutate:s}},mme=()=>{const{mutate:t}=IT();return{deleteThread:async({threadId:n,resourceid:r,agentId:i})=>{const s=fetch(`/api/memory/threads/${n}?agentId=${i}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});kn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function gme({agentId:t,threadId:e}){const{threads:n,isLoading:r}=hme({resourceid:t,agentId:t}),{deleteThread:i}=mme(),s=bo(),[o,a]=S.useState(null),[l,u]=S.useState(!1),c=async()=>{await i({threadId:o,resourceid:t,agentId:t}),u(!1),o===e&&s(`/agents/${t}/chat/${crypto.randomUUID()}`)};return r?g.jsxs("div",{className:"p-4 w-full h-full space-y-2",children:[g.jsx("div",{className:"flex justify-end",children:g.jsx(He,{className:"h-9 w-9"})}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"})]}):n!=null&&n.length?g.jsxs(Mn,{className:"h-full px-4 pb-4 w-[256px]",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex justify-between items-center pl-2 sticky top-0 bg-mastra-bg-2 pt-4",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(ht,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Hh,{})})]}),n.map(d=>{const p=d.id===e;return g.jsxs("div",{className:be("flex cursor-pointer w-full px-2 items-center focus-visible:outline-none transition-colors focus-visible:ring-1 focus-visible:ring-mastra-border-4 gap-3 rounded-xs group text-small hover:bg-mastra-el-6/5",p?"bg-mastra-el-6/5":""),children:[g.jsx(Xp,{to:`/agents/${t}/chat/${d.id}`,className:"flex-1",children:g.jsx("p",{className:be("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",p?"text-mastra-el-6":""),children:d.title})}),g.jsxs(Qn,{children:[g.jsx(Qn.Trigger,{asChild:!0,children:g.jsxs(ht,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(jX,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(Qn.Content,{children:g.jsxs(Qn.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(d.id),u(!0)},children:[g.jsx(HX,{}),g.jsx("span",{children:"Delete"})]})})]})]},d.id)})]}),g.jsx(tn,{open:l,onOpenChange:u,children:g.jsxs(tn.Content,{children:[g.jsxs(tn.Header,{children:[g.jsx(tn.Title,{children:"Are you absolutely sure?"}),g.jsx(tn.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(tn.Footer,{children:[g.jsx(tn.Cancel,{children:"Cancel"}),g.jsx(tn.Action,{onClick:c,children:"Continue"})]})]})})]}):g.jsxs("div",{className:"p-4 w-full space-y-2 h-full",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(ht,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Hh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function ND(){const{agentId:t,threadId:e}=da(),{agent:n,isLoading:r}=Pu(t),{memory:i}=fme(t),s=bo(),{messages:o,isLoading:a}=pme({agentId:t,threadId:e,memory:!!(i!=null&&i.result)}),[l,u]=S.useState(!0);return S.useEffect(()=>{i!=null&&i.result&&!e&&s(`/agents/${t}/chat/${crypto.randomUUID()}`)},[i==null?void 0:i.result,e]),r?g.jsxs("main",{className:"flex-1 relative grid grid-cols-[1fr_400px] divide-x",children:[g.jsx("div",{className:"p-4",children:g.jsx(He,{className:"h-[600px]"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx(Dx,{agentId:t})})]}):g.jsxs("main",{className:be("flex-1 relative grid divide-x",l&&(i!=null&&i.result)?"grid-cols-[256px_1fr_400px] overflow-y-hidden h-full":"grid-cols-[1fr_400px]"),children:[l&&(i!=null&&i.result)?g.jsx(gme,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(ht,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>u(!l),children:g.jsx(BX,{})}):null,g.jsx(jce,{agentId:t,agentName:n==null?void 0:n.name,threadId:e,initialMessages:a?void 0:o,memory:i==null?void 0:i.result})]}),g.jsx("div",{className:"flex flex-col",children:g.jsx(Dx,{agentId:t})})]})}const yme=Id("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ah({className:t,variant:e,...n}){return g.jsx("div",{className:be(yme({variant:e}),t),...n})}function ly({content:t,label:e,multiline:n=!1}){const r=()=>{navigator.clipboard.writeText(t)};return g.jsxs("div",{className:"group relative flex items-start gap-2",children:[g.jsx("span",{className:be("text-sm text-mastra-el-4",n?"whitespace-pre-wrap":"truncate"),children:t}),g.jsx(ht,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 -mt-1",onClick:i=>{i.stopPropagation(),r()},"aria-label":`Copy ${e}`,children:g.jsx(R4,{className:"h-3 w-3"})})]})}const c6=6048e5,xme=864e5,uy=43200,TD=1440,AD=Symbol.for("constructDateFrom");function Vn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&AD in t?t[AD](e):t instanceof Date?new t.constructor(e):new Date(e)}function Rt(t,e){return Vn(e||t,t)}function d6(t,e,n){const r=Rt(t,n==null?void 0:n.in);return isNaN(e)?Vn(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function f6(t,e,n){const r=Rt(t,n==null?void 0:n.in);if(isNaN(e))return Vn(t,NaN);if(!e)return r;const i=r.getDate(),s=Vn(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const o=s.getDate();return i>=o?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let vme={};function Hd(){return vme}function od(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.weekStartsOn)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=Rt(t,e==null?void 0:e.in),s=i.getDay(),o=(s<r?7:0)+s-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function ip(t,e){return od(t,{...e,weekStartsOn:1})}function h6(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=Vn(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=ip(i),o=Vn(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);const a=ip(o);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function $x(t){const e=Rt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Tl(t,...e){const n=Vn.bind(null,t||e.find(r=>typeof r=="object"));return e.map(n)}function sp(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function p6(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e),s=sp(r),o=sp(i),a=+s-$x(s),l=+o-$x(o);return Math.round((a-l)/xme)}function wme(t,e){const n=h6(t,e),r=Vn(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),ip(r)}function bme(t,e,n){return d6(t,e*7,n)}function kme(t,e,n){return f6(t,e*12,n)}function Sme(t,e){let n,r=e==null?void 0:e.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Vn.bind(null,i));const s=Rt(i,r);(!n||n<s||isNaN(+s))&&(n=s)}),Vn(r,n||NaN)}function Cme(t,e){let n,r=e==null?void 0:e.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Vn.bind(null,i));const s=Rt(i,r);(!n||n>s||isNaN(+s))&&(n=s)}),Vn(r,n||NaN)}function ex(t,e){const n=+Rt(t)-+Rt(e);return n<0?-1:n>0?1:n}function Eme(t){return Vn(t,Date.now())}function Nme(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return+sp(r)==+sp(i)}function m6(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function g6(t){return!(!m6(t)&&typeof t!="number"||isNaN(+Rt(t)))}function y6(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e),s=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return s*12+o}function Tme(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function Ame(t,e){return+Rt(t)-+Rt(e)}function _me(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setHours(23,59,59,999),n}function x6(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Mme(t,e){const n=Rt(t,e==null?void 0:e.in);return+_me(n,e)==+x6(n,e)}function Pme(t,e,n){const[r,i,s]=Tl(n==null?void 0:n.in,t,t,e),o=ex(i,s),a=Math.abs(y6(i,s));if(a<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*a);let l=ex(i,s)===-o;Mme(r)&&a===1&&ex(r,s)===1&&(l=!1);const u=o*(a-+l);return u===0?0:u}function Rme(t,e,n){const r=Ame(t,e)/1e3;return Tme(n==null?void 0:n.roundingMethod)(r)}function Ome(t,e){const[n,r]=Tl(t,e.start,e.end);return{start:n,end:r}}function Dme(t,e){const{start:n,end:r}=Ome(e==null?void 0:e.in,t);let i=+n>+r;const s=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let a=1;const l=[];for(;+o<=s;)l.push(Vn(n,o)),o.setMonth(o.getMonth()+a);return i?l.reverse():l}function jme(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Ime(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function v6(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function w6(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.weekStartsOn)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=Rt(t,e==null?void 0:e.in),s=i.getDay(),o=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function Lme(t,e){return w6(t,{...e,weekStartsOn:1})}const Fme={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Bme=(t,e,n)=>{let r;const i=Fme[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function ak(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const zme={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$me={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Vme={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wme={date:ak({formats:zme,defaultWidth:"full"}),time:ak({formats:$me,defaultWidth:"full"}),dateTime:ak({formats:Vme,defaultWidth:"full"})},Hme={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ume=(t,e,n,r)=>Hme[t];function Hf(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,a=n!=null&&n.width?String(n.width):o;i=t.formattingValues[a]||t.formattingValues[o]}else{const o=t.defaultWidth,a=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[a]||t.values[o]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const qme={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Yme={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Gme={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Kme={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Xme={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Zme={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Qme=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Jme={ordinalNumber:Qme,era:Hf({values:qme,defaultWidth:"wide"}),quarter:Hf({values:Yme,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Hf({values:Gme,defaultWidth:"wide"}),day:Hf({values:Kme,defaultWidth:"wide"}),dayPeriod:Hf({values:Xme,defaultWidth:"wide",formattingValues:Zme,defaultFormattingWidth:"wide"})};function Uf(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const o=s[0],a=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?tge(a,d=>d.test(o)):ege(a,d=>d.test(o));let u;u=t.valueCallback?t.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=e.slice(o.length);return{value:u,rest:c}}}function ege(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function tge(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function nge(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let o=t.valueCallback?t.valueCallback(s[0]):s[0];o=n.valueCallback?n.valueCallback(o):o;const a=e.slice(i.length);return{value:o,rest:a}}}const rge=/^(\d+)(th|st|nd|rd)?/i,ige=/\d+/i,sge={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},oge={any:[/^b/i,/^(a|c)/i]},age={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},lge={any:[/1/i,/2/i,/3/i,/4/i]},uge={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},cge={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},dge={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},fge={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},hge={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},pge={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},mge={ordinalNumber:nge({matchPattern:rge,parsePattern:ige,valueCallback:t=>parseInt(t,10)}),era:Uf({matchPatterns:sge,defaultMatchWidth:"wide",parsePatterns:oge,defaultParseWidth:"any"}),quarter:Uf({matchPatterns:age,defaultMatchWidth:"wide",parsePatterns:lge,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Uf({matchPatterns:uge,defaultMatchWidth:"wide",parsePatterns:cge,defaultParseWidth:"any"}),day:Uf({matchPatterns:dge,defaultMatchWidth:"wide",parsePatterns:fge,defaultParseWidth:"any"}),dayPeriod:Uf({matchPatterns:hge,defaultMatchWidth:"any",parsePatterns:pge,defaultParseWidth:"any"})},Sv={code:"en-US",formatDistance:Bme,formatLong:Wme,formatRelative:Ume,localize:Jme,match:mge,options:{weekStartsOn:0,firstWeekContainsDate:1}};function gge(t,e){const n=Rt(t,e==null?void 0:e.in);return p6(n,v6(n))+1}function b6(t,e){const n=Rt(t,e==null?void 0:e.in),r=+ip(n)-+wme(n);return Math.round(r/c6)+1}function k6(t,e){var c,d,p,m;const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=Hd(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??i.firstWeekContainsDate??((m=(p=i.locale)==null?void 0:p.options)==null?void 0:m.firstWeekContainsDate)??1,o=Vn((e==null?void 0:e.in)||t,0);o.setFullYear(r+1,0,s),o.setHours(0,0,0,0);const a=od(o,e),l=Vn((e==null?void 0:e.in)||t,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=od(l,e);return+n>=+a?r+1:+n>=+u?r:r-1}function yge(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.firstWeekContainsDate)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,i=k6(t,e),s=Vn((e==null?void 0:e.in)||t,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),od(s,e)}function S6(t,e){const n=Rt(t,e==null?void 0:e.in),r=+od(n,e)-+yge(n,e);return Math.round(r/c6)+1}function Ut(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const $a={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Ut(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Ut(n+1,2)},d(t,e){return Ut(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Ut(t.getHours()%12||12,e.length)},H(t,e){return Ut(t.getHours(),e.length)},m(t,e){return Ut(t.getMinutes(),e.length)},s(t,e){return Ut(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Ut(i,e.length)}},gc={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_D={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return $a.y(t,e)},Y:function(t,e,n,r){const i=k6(t,r),s=i>0?i:1-i;if(e==="YY"){const o=s%100;return Ut(o,2)}return e==="Yo"?n.ordinalNumber(s,{unit:"year"}):Ut(s,e.length)},R:function(t,e){const n=h6(t);return Ut(n,e.length)},u:function(t,e){const n=t.getFullYear();return Ut(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Ut(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Ut(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return $a.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Ut(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=S6(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Ut(i,e.length)},I:function(t,e,n){const r=b6(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Ut(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):$a.d(t,e)},D:function(t,e,n){const r=gge(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Ut(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return Ut(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return Ut(s,e.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Ut(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=gc.noon:r===0?i=gc.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=gc.evening:r>=12?i=gc.afternoon:r>=4?i=gc.morning:i=gc.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return $a.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):$a.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Ut(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Ut(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):$a.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):$a.s(t,e)},S:function(t,e){return $a.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return PD(r);case"XXXX":case"XX":return Zl(r);case"XXXXX":case"XXX":default:return Zl(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return PD(r);case"xxxx":case"xx":return Zl(r);case"xxxxx":case"xxx":default:return Zl(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+MD(r,":");case"OOOO":default:return"GMT"+Zl(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+MD(r,":");case"zzzz":default:return"GMT"+Zl(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Ut(r,e.length)},T:function(t,e,n){return Ut(+t,e.length)}};function MD(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+e+Ut(s,2)}function PD(t,e){return t%60===0?(t>0?"-":"+")+Ut(Math.abs(t)/60,2):Zl(t,e)}function Zl(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Ut(Math.trunc(r/60),2),s=Ut(r%60,2);return n+i+e+s}const RD=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},C6=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},xge=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return RD(t,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;case"PPPP":default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",RD(r,e)).replace("{{time}}",C6(i,e))},vge={p:C6,P:xge},wge=/^D+$/,bge=/^Y+$/,kge=["D","DD","YY","YYYY"];function Sge(t){return wge.test(t)}function Cge(t){return bge.test(t)}function Ege(t,e,n){const r=Nge(t,e,n);if(console.warn(r),kge.includes(t))throw new RangeError(r)}function Nge(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Tge=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Age=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_ge=/^'([^]*?)'?$/,Mge=/''/g,Pge=/[a-zA-Z]/;function Vc(t,e,n){var c,d,p,m,y,v,w,b;const r=Hd(),i=(n==null?void 0:n.locale)??r.locale??Sv,s=(n==null?void 0:n.firstWeekContainsDate)??((d=(c=n==null?void 0:n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(p=r.locale)==null?void 0:p.options)==null?void 0:m.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(y=n==null?void 0:n.locale)==null?void 0:y.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((b=(w=r.locale)==null?void 0:w.options)==null?void 0:b.weekStartsOn)??0,a=Rt(t,n==null?void 0:n.in);if(!g6(a))throw new RangeError("Invalid time value");let l=e.match(Age).map(k=>{const E=k[0];if(E==="p"||E==="P"){const N=vge[E];return N(k,i.formatLong)}return k}).join("").match(Tge).map(k=>{if(k==="''")return{isToken:!1,value:"'"};const E=k[0];if(E==="'")return{isToken:!1,value:Rge(k)};if(_D[E])return{isToken:!0,value:k};if(E.match(Pge))throw new RangeError("Format string contains an unescaped latin alphabet character `"+E+"`");return{isToken:!1,value:k}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:i};return l.map(k=>{if(!k.isToken)return k.value;const E=k.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Cge(E)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Sge(E))&&Ege(E,e,String(t));const N=_D[E[0]];return N(a,E,i.localize,u)}).join("")}function Rge(t){const e=t.match(_ge);return e?e[1].replace(Mge,"'"):t}function Oge(t,e,n){const r=Hd(),i=(n==null?void 0:n.locale)??r.locale??Sv,s=2520,o=ex(t,e);if(isNaN(o))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o}),[l,u]=Tl(n==null?void 0:n.in,...o>0?[e,t]:[t,e]),c=Rme(u,l),d=($x(u)-$x(l))/1e3,p=Math.round((c-d)/60);let m;if(p<2)return n!=null&&n.includeSeconds?c<5?i.formatDistance("lessThanXSeconds",5,a):c<10?i.formatDistance("lessThanXSeconds",10,a):c<20?i.formatDistance("lessThanXSeconds",20,a):c<40?i.formatDistance("halfAMinute",0,a):c<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):p===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",p,a);if(p<45)return i.formatDistance("xMinutes",p,a);if(p<90)return i.formatDistance("aboutXHours",1,a);if(p<TD){const y=Math.round(p/60);return i.formatDistance("aboutXHours",y,a)}else{if(p<s)return i.formatDistance("xDays",1,a);if(p<uy){const y=Math.round(p/TD);return i.formatDistance("xDays",y,a)}else if(p<uy*2)return m=Math.round(p/uy),i.formatDistance("aboutXMonths",m,a)}if(m=Pme(u,l),m<12){const y=Math.round(p/uy);return i.formatDistance("xMonths",y,a)}else{const y=m%12,v=Math.trunc(m/12);return y<3?i.formatDistance("aboutXYears",v,a):y<9?i.formatDistance("overXYears",v,a):i.formatDistance("almostXYears",v+1,a)}}function Dge(t,e){return Oge(t,Eme(t),e)}function jge(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=n.getMonth(),s=Vn(n,0);return s.setFullYear(r,i+1,0),s.setHours(0,0,0,0),s.getDate()}function Ige(t,e){return Rt(t,e==null?void 0:e.in).getMonth()}function Lge(t,e){return Rt(t,e==null?void 0:e.in).getFullYear()}function Fge(t,e){return+Rt(t)>+Rt(e)}function Bge(t,e){return+Rt(t)<+Rt(e)}function zge(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function $ge(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return r.getFullYear()===i.getFullYear()}function Vge(t,e,n){const r=Rt(t,n==null?void 0:n.in),i=r.getFullYear(),s=r.getDate(),o=Vn(t,0);o.setFullYear(i,e,15),o.setHours(0,0,0,0);const a=jge(o);return r.setMonth(e,Math.min(s,a)),r}function Wge(t,e,n){const r=Rt(t,n==null?void 0:n.in);return isNaN(+r)?Vn(t,NaN):(r.setFullYear(e),r)}var Hge="VisuallyHidden",RA=S.forwardRef((t,e)=>g.jsx(Ze.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));RA.displayName=Hge;var Uge=RA,[Cv,QIe]=Oi("Tooltip",[El]),Ev=El(),E6="TooltipProvider",qge=700,iE="tooltip.open",[Yge,OA]=Cv(E6),N6=t=>{const{__scopeTooltip:e,delayDuration:n=qge,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,[o,a]=S.useState(!0),l=S.useRef(!1),u=S.useRef(0);return S.useEffect(()=>{const c=u.current;return()=>window.clearTimeout(c)},[]),g.jsx(Yge,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:S.useCallback(()=>{window.clearTimeout(u.current),a(!1)},[]),onClose:S.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(c=>{l.current=c},[]),disableHoverableContent:i,children:s})};N6.displayName=E6;var Nv="Tooltip",[Gge,Tv]=Cv(Nv),T6=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i=!1,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=OA(Nv,t.__scopeTooltip),u=Ev(e),[c,d]=S.useState(null),p=zn(),m=S.useRef(0),y=o??l.disableHoverableContent,v=a??l.delayDuration,w=S.useRef(!1),[b=!1,k]=po({prop:r,defaultProp:i,onChange:M=>{M?(l.onOpen(),document.dispatchEvent(new CustomEvent(iE))):l.onClose(),s==null||s(M)}}),E=S.useMemo(()=>b?w.current?"delayed-open":"instant-open":"closed",[b]),N=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w.current=!1,k(!0)},[k]),A=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),_=S.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,k(!0),m.current=0},v)},[v,k]);return S.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),g.jsx(cm,{...u,children:g.jsx(Gge,{scope:e,contentId:p,open:b,stateAttribute:E,trigger:c,onTriggerChange:d,onTriggerEnter:S.useCallback(()=>{l.isOpenDelayed?_():N()},[l.isOpenDelayed,_,N]),onTriggerLeave:S.useCallback(()=>{y?A():(window.clearTimeout(m.current),m.current=0)},[A,y]),onOpen:N,onClose:A,disableHoverableContent:y,children:n})})};T6.displayName=Nv;var sE="TooltipTrigger",A6=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Tv(sE,n),s=OA(sE,n),o=Ev(n),a=S.useRef(null),l=kt(e,a,i.onTriggerChange),u=S.useRef(!1),c=S.useRef(!1),d=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(dm,{asChild:!0,...o,children:g.jsx(Ze.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(t.onPointerMove,p=>{p.pointerType!=="touch"&&!c.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),c.current=!0)}),onPointerLeave:Pe(t.onPointerLeave,()=>{i.onTriggerLeave(),c.current=!1}),onPointerDown:Pe(t.onPointerDown,()=>{u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(t.onFocus,()=>{u.current||i.onOpen()}),onBlur:Pe(t.onBlur,i.onClose),onClick:Pe(t.onClick,i.onClose)})})});A6.displayName=sE;var Kge="TooltipPortal",[JIe,Xge]=Cv(Kge,{forceMount:void 0}),ad="TooltipContent",_6=S.forwardRef((t,e)=>{const n=Xge(ad,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Tv(ad,t.__scopeTooltip);return g.jsx(Pr,{present:r||o.open,children:o.disableHoverableContent?g.jsx(M6,{side:i,...s,ref:e}):g.jsx(Zge,{side:i,...s,ref:e})})}),Zge=S.forwardRef((t,e)=>{const n=Tv(ad,t.__scopeTooltip),r=OA(ad,t.__scopeTooltip),i=S.useRef(null),s=kt(e,i),[o,a]=S.useState(null),{trigger:l,onClose:u}=n,c=i.current,{onPointerInTransitChange:d}=r,p=S.useCallback(()=>{a(null),d(!1)},[d]),m=S.useCallback((y,v)=>{const w=y.currentTarget,b={x:y.clientX,y:y.clientY},k=tye(b,w.getBoundingClientRect()),E=nye(b,k),N=rye(v.getBoundingClientRect()),A=sye([...E,...N]);a(A),d(!0)},[d]);return S.useEffect(()=>()=>p(),[p]),S.useEffect(()=>{if(l&&c){const y=w=>m(w,c),v=w=>m(w,l);return l.addEventListener("pointerleave",y),c.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",y),c.removeEventListener("pointerleave",v)}}},[l,c,m,p]),S.useEffect(()=>{if(o){const y=v=>{const w=v.target,b={x:v.clientX,y:v.clientY},k=(l==null?void 0:l.contains(w))||(c==null?void 0:c.contains(w)),E=!iye(b,o);k?p():E&&(p(),u())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[l,c,o,u,p]),g.jsx(M6,{...t,ref:s})}),[Qge,Jge]=Cv(Nv,{isInside:!1}),M6=S.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=Tv(ad,n),u=Ev(n),{onClose:c}=l;return S.useEffect(()=>(document.addEventListener(iE,c),()=>document.removeEventListener(iE,c)),[c]),S.useEffect(()=>{if(l.trigger){const d=p=>{const m=p.target;m!=null&&m.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),g.jsx($d,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:g.jsxs(wv,{"data-state":l.stateAttribute,...u,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[g.jsx(GN,{children:r}),g.jsx(Qge,{scope:n,isInside:!0,children:g.jsx(Uge,{id:l.contentId,role:"tooltip",children:i||r})})]})})});_6.displayName=ad;var P6="TooltipArrow",eye=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Ev(n);return Jge(P6,n).isInside?null:g.jsx(bv,{...i,...r,ref:e})});eye.displayName=P6;function tye(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function nye(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function rye(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function iye(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,u=e[o].x,c=e[o].y;l>r!=c>r&&n<(u-a)*(r-l)/(c-l)+a&&(i=!i)}return i}function sye(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),oye(e)}function oye(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var aye=N6,lye=T6,uye=A6,R6=_6;const cye=aye,dye=lye,fye=uye,O6=S.forwardRef(({className:t,sideOffset:e=4,...n},r)=>g.jsx(R6,{ref:r,sideOffset:e,className:be("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));O6.displayName=R6.displayName;function hye({date:t}){const e={relativeTime:Dge(new Date(t),{addSuffix:!0}),fullDate:Vc(new Date(t),"PPpp")};return g.jsx(cye,{children:g.jsxs(dye,{children:[g.jsx(fye,{className:"text-left text-sm text-mastra-el-4",children:e.relativeTime}),g.jsx(O6,{className:"bg-mastra-bg-1 text-mastra-el-1",children:g.jsx("p",{className:"text-sm",children:e.fullDate})})]})})}const pye=Id("flex w-full text-mastra-el-6 rounded-sm border bg-transparent shadow-sm focus-visible:ring-ring transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-mastra-border-1 border-border-1 placeholder:text-muted-foreground",filled:"bg-inputFill border-border-1 placeholder:text-muted-foreground",unstyled:"border-0 bg-transparent placeholder:text-muted-foreground focus-visible:ring-transparent focus-visible:outline-none"},customSize:{default:"px-[13px] text-[calc(13_/_16_*_1rem)] h-[34px]",sm:"h-[30px] px-[13px] text-xs",lg:"h-10 px-[17px] rounded-md text-[calc(13_/_16_*_1rem)]"}},defaultVariants:{variant:"default",customSize:"default"}}),Ud=S.forwardRef(({className:t,customSize:e,testId:n,variant:r,type:i,...s},o)=>g.jsx("input",{type:i,className:be(t,pye({variant:r,customSize:e,className:t})),"data-testid":n,ref:o,...s}));Ud.displayName="Input";function OD({score:t}){return g.jsx(Ah,{variant:"secondary",children:t.toFixed(2)})}const DD=(t,e)=>{const[n,r]=S.useState([]),[i,s]=S.useState(!0),o=async a=>{s(!0);try{const l=await fetch(`/api/agents/${a??t}/evals/${e}`);if(!l.ok){const c=await l.json();r([]),console.error("Error fetching evals",c),kn.error((c==null?void 0:c.error)||"Error fetching evals");return}const u=await l.json();r(u.evals)}catch(l){r([]),console.error("Error fetching evals",l),kn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}},D6=S.createContext({handleRefresh:()=>{},isLoading:!1}),cy=be("relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible","[&::-webkit-scrollbar]:w-1","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb]:bg-mastra-border/20","[&>*]:visible"),jD=be("px-4 py-2 text-sm transition-all border-b-2 border-transparent","data-[state=active]:border-white data-[state=active]:text-white font-medium","data-[state=inactive]:text-mastra-el-4 hover:data-[state=inactive]:text-mastra-el-2","focus-visible:outline-none"),ID=be("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");function mye({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=DD(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=DD(t,"ci"),u={handleRefresh:c,isLoading:e==="live"?i:a};return g.jsx(D6.Provider,{value:u,children:g.jsxs(aA,{value:e,onValueChange:d=>n(d),className:"grid grid-rows-[auto_1fr] h-full min-h-0 pb-2",children:[g.jsx("div",{className:"bg-mastra-bg-2 border-b border-mastra-border/10",children:g.jsxs(hv,{className:"bg-transparent border-0 h-auto mx-4 pt-5",children:[g.jsx(Xs,{value:"live",className:jD,children:"Live"}),g.jsx(Xs,{value:"ci",className:jD,children:"CI"})]})}),g.jsx(Zs,{value:"live",className:ID,children:g.jsx(LD,{evals:r,isCIMode:!1})}),g.jsx(Zs,{value:"ci",className:ID,children:g.jsx(LD,{evals:o,isCIMode:!0})})]})});function c(){e==="live"?s():l()}}function LD({evals:t,isCIMode:e=!1}){const{handleRefresh:n,isLoading:r}=S.useContext(D6),[i,s]=S.useState(new Set),[o,a]=S.useState(""),[l,u]=S.useState({field:"metricName",direction:"asc"}),[c,d]=S.useState(!1);return S.useEffect(()=>{if(r){const b=setTimeout(()=>{d(!0)},200);return()=>clearTimeout(b)}else d(!1)},[r]),g.jsxs("div",{className:"min-h-0 grid grid-rows-[auto_1fr]",children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-mastra-bg-2 rounded-lg",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx(uC,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mastra-el-3"}),g.jsx(Ud,{id:"search-input",placeholder:"Search metrics, inputs, or outputs...",value:o,onChange:b=>a(b.target.value),className:"pl-10"})]}),g.jsxs(Ah,{variant:"secondary",className:"text-xs",children:[t.length," Total Evaluations"]}),g.jsx(ht,{variant:"ghost",size:"icon",onClick:n,disabled:c,className:"h-9 w-9",children:c?g.jsx(Jc,{className:"h-4 w-4 animate-spin"}):g.jsx(Jc,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"overflow-auto",children:g.jsxs(co,{className:"w-full",children:[g.jsx(fo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(ln,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"w-12"}),g.jsx(yt,{className:"min-w-[200px] max-w-[30%] text-mastra-el-3 cursor-pointer",onClick:()=>y("metricName"),children:g.jsxs("div",{className:"flex items-center",children:["Metric ",v("metricName")]})}),g.jsx(yt,{className:"flex-1 text-mastra-el-3"}),g.jsx(yt,{className:"w-48 text-mastra-el-3 cursor-pointer",onClick:()=>y("averageScore"),children:g.jsxs("div",{className:"flex items-center",children:["Average Score ",v("averageScore")]})}),g.jsx(yt,{className:"w-48 text-mastra-el-3",children:"Evaluations"})]})}),g.jsx(ho,{className:"border-b border-gray-6 relative",children:g.jsx(rT,{mode:"wait",presenceAffectsLayout:!1,children:c?Array.from({length:3}).map((b,k)=>g.jsxs(F5,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(it,{className:"w-12",children:g.jsx(He,{className:"h-8 w-8 rounded-full"})}),g.jsx(it,{className:"min-w-[200px]",children:g.jsx(He,{className:"h-4 w-3/4"})}),g.jsx(it,{className:"flex-1",children:g.jsx(He,{className:"h-4 w-full"})}),g.jsx(it,{className:"w-48",children:g.jsx(He,{className:"h-4 w-20"})}),g.jsx(it,{className:"w-48",children:g.jsx(He,{className:"h-4 w-16"})})]},k)):w(t).length===0?g.jsx(ln,{children:g.jsx(it,{colSpan:5,className:"h-32 text-center text-mastra-el-3",children:g.jsxs("div",{className:"flex flex-col items-center gap-2",children:[g.jsx(uC,{className:"h-8 w-8"}),g.jsx("p",{children:"No evaluations found"}),o&&g.jsx("p",{className:"text-sm",children:"Try adjusting your search terms"})]})})}):w(t).map(b=>g.jsxs(ne.Fragment,{children:[g.jsxs(ln,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>m(b.metricName),children:[g.jsx(it,{className:"w-12",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:g.jsx("div",{className:be("transform transition-transform duration-200",i.has(b.metricName)?"rotate-90":""),children:g.jsx(rh,{className:"h-4 w-4 text-mastra-el-5"})})})}),g.jsx(it,{className:"min-w-[200px] max-w-[30%] font-medium text-mastra-el-5",children:b.metricName}),g.jsx(it,{className:"flex-1 text-mastra-el-5"}),g.jsx(it,{className:"w-48 text-mastra-el-5",children:g.jsx(OD,{score:b.averageScore})}),g.jsx(it,{className:"w-48 text-mastra-el-5",children:g.jsx(Ah,{variant:"secondary",children:b.evals.length})})]}),i.has(b.metricName)&&g.jsx(ln,{children:g.jsx(it,{colSpan:5+(p(b.evals)?1:0)+(e?1:0),className:"p-0",children:g.jsx("div",{className:"bg-mastra-bg-3 rounded-lg m-2",children:g.jsx("div",{className:"w-full",children:g.jsxs(co,{className:"w-full",children:[g.jsx(fo,{children:g.jsxs(ln,{className:"text-[0.7rem] text-mastra-el-3 hover:bg-transparent",children:[g.jsx(yt,{className:"pl-12 w-[120px]",children:"Timestamp"}),g.jsx(yt,{className:"w-[300px]",children:"Instructions"}),g.jsx(yt,{className:"w-[300px]",children:"Input"}),g.jsx(yt,{className:"w-[300px]",children:"Output"}),g.jsx(yt,{className:"w-[80px]",children:"Score"}),p(b.evals)&&g.jsx(yt,{className:"w-[250px]",children:"Reason"}),e&&g.jsx(yt,{className:"w-[120px]",children:"Test Name"})]})}),g.jsx(ho,{children:b.evals.map((k,E)=>{var N,A;return g.jsxs(ln,{className:"text-[0.8125rem] hover:bg-mastra-bg-2/50",children:[g.jsx(it,{className:"pl-12 text-mastra-el-4 align-top py-4",children:g.jsx(hye,{date:k.createdAt})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.instructions,label:"instructions",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.input,label:"input",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.output,label:"output",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx(OD,{score:k.result.score})}),p(b.evals)&&g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:((N=k.result.info)==null?void 0:N.reason)||"",label:"reason",multiline:!0})})}),e&&g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:((A=k.testInfo)==null?void 0:A.testName)&&g.jsx(Ah,{variant:"secondary",className:"text-xs",children:k.testInfo.testName})})]},`${b.metricName}-${E}`)})})]})})})})})]},b.metricName))})})]})})]});function p(b){return b.some(k=>{var E;return(E=k.result.info)==null?void 0:E.reason})}function m(b){const k=new Set(i);k.has(b)?k.delete(b):k.add(b),s(k)}function y(b){u(k=>({field:b,direction:k.field===b&&k.direction==="asc"?"desc":"asc"}))}function v(b){return l.field!==b?null:l.direction==="asc"?g.jsx(_X,{className:"h-4 w-4 ml-1"}):g.jsx(TX,{className:"h-4 w-4 ml-1"})}function w(b){let k=b.reduce((E,N)=>{const A=E.find(_=>_.metricName===N.metricName);return A?(A.evals.push(N),A.averageScore=A.evals.reduce((_,M)=>_+M.result.score,0)/A.evals.length):E.push({metricName:N.metricName,averageScore:N.result.score,evals:[N]}),E},[]);return o&&(k=k.filter(E=>E.metricName.toLowerCase().includes(o.toLowerCase())||E.evals.some(N=>{var A,_,M;return((A=N.input)==null?void 0:A.toLowerCase().includes(o.toLowerCase()))||((_=N.output)==null?void 0:_.toLowerCase().includes(o.toLowerCase()))||((M=N.instructions)==null?void 0:M.toLowerCase().includes(o.toLowerCase()))}))),k.sort((E,N)=>{const A=l.direction==="asc"?1:-1;switch(l.field){case"metricName":return A*E.metricName.localeCompare(N.metricName);case"averageScore":return A*(E.averageScore-N.averageScore);default:return 0}}),k}}function gye(){const{agentId:t}=da();return g.jsx("main",{className:"min-h-0",children:g.jsx(mye,{agentId:t})})}function yye({fetchFn:t,interval:e=3e3,enabled:n=!1,onSuccess:r,onError:i,shouldContinue:s=()=>!0}){const[o,a]=S.useState(n),[l,u]=S.useState(null),[c,d]=S.useState(null),[p,m]=S.useState(!1),[y,v]=S.useState(!1),w=S.useRef(null),b=S.useRef(!0),k=S.useCallback(()=>{console.log("cleanup"),w.current&&(clearTimeout(w.current),w.current=null)},[]),E=S.useCallback(()=>{console.log("stopPolling"),a(!1),k()},[k]),N=S.useCallback(()=>{console.log("startPolling"),a(!0),u(null)},[]),A=S.useCallback(async(_=!1)=>{if(b.current){m(!0),v(_);try{const M=await t();d(M),u(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(A,e):E()}catch(M){if(!b.current)return;u(M),i==null||i(M),E()}finally{b.current&&(v(!1),m(!1))}}},[t,e,r,i,s,E]);return S.useEffect(()=>(b.current=!0,n&&o&&A(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,A,k]),{isPolling:o,isLoading:p,error:l,data:c,startPolling:N,stopPolling:E,firstCallLoading:y}}function DA(t,e=2){return(t/1e3).toFixed(e)}function j6(t){const e=new Date(t/1e3);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function xye(t){const e=new Date(t/1e6);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function vye(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function FD(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const wye=t=>{const e=t.reduce((r,i)=>{const s={...i,duration:i.endTime-i.startTime};return{...r,[i.traceId]:[...r[i.traceId]||[],s]}},{});return Object.entries(e).map(([r,i])=>{var l;const s=i.find(u=>!u.parentSpanId),o=i.map(u=>({...u,relativePercentage:s?u.duration/s.duration:0})),a=(l=i.find(u=>u.status.code!==0))==null?void 0:l.status;return{traceId:r,serviceName:(s==null?void 0:s.name)||r,duration:i.reduce((u,c)=>u+c.duration,0),status:a||(s==null?void 0:s.status)||i[0].status,started:i[0].startTime,trace:o}})},I6=t=>{const[e,n]=S.useState(null),r=S.useCallback(async()=>{try{const u=await fetch(`/api/telemetry?attribute=componentName:${t}`);if(!u.ok){const p=await u.json();throw new Error((p==null?void 0:p.error)||"Error fetching traces")}const c=await u.json();return wye((c==null?void 0:c.traces)||[])}catch(u){throw u}},[t]),i=S.useCallback(u=>{u.length>0&&n(()=>u)},[]),s=S.useCallback(u=>{kn.error(u.message)},[]),o=S.useCallback(u=>u.length>0,[]),{firstCallLoading:a,error:l}=yye({fetchFn:r,interval:3e3,onSuccess:i,onError:s,shouldContinue:o,enabled:!0});return{traces:e,firstCallLoading:a,error:l}},Al=S.createContext({});function L6({children:t}){const[e,n]=S.useState(!1),[r,i]=S.useState(null),[s,o]=S.useState([]),[a,l]=S.useState(0),[u,c]=S.useState(null),[d,p]=S.useState(!1),m=()=>{if(a<s.length-1){const w=a+1;l(w);const b=s[w].trace;i(b);const k=b.find(E=>E.parentSpanId===null)||b[0];c(k)}},y=()=>{if(a>0){const w=a-1;l(w);const b=s[w].trace;i(b);const k=b.find(E=>E.parentSpanId===null)||b[0];c(k)}},v=()=>{n(!1),i(null),c(null),p(!1)};return g.jsx(Al.Provider,{value:{isOpen:e,setIsOpen:n,trace:r,setTrace:i,traces:s,setTraces:o,currentTraceIndex:a,setCurrentTraceIndex:l,nextTrace:m,prevTrace:y,span:u,setSpan:c,openDetail:d,setOpenDetail:p,clearData:v},children:t})}function F6({traces:t}){const{setTraces:e,trace:n}=S.useContext(Al),r=(n==null?void 0:n.find(i=>i.parentSpanId===void 0))||(n==null?void 0:n[0]);return S.useEffect(()=>{e(t)},[t]),g.jsx("div",{className:"h-full w-[calc(100%_-_400px)]",children:g.jsx(Mn,{className:"rounded-lg h-full",children:g.jsxs(co,{children:[g.jsx(fo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(ln,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(yt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Vh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(yt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(yt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(ho,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(ln,{className:be("border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",{"bg-muted/50":(r==null?void 0:r.traceId)===i.traceId}),children:[g.jsx(it,{children:g.jsx(bye,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(it,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(it,{className:"text-mastra-el-5 text-sm",children:j6(i.started)}),g.jsx(it,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(OX,{className:"h-3 w-3"}),DA(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(ln,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(it,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function bye({trace:t,name:e,traceIndex:n,status:r}){const{setTrace:i,isOpen:s,setIsOpen:o,trace:a,setSpan:l,setOpenDetail:u,setCurrentTraceIndex:c}=S.useContext(Al);return g.jsxs(ht,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var p;i(t);const d=t.find(m=>m.parentSpanId===null)||t[0];l(d),c(n),!(s&&((p=a==null?void 0:a[0])==null?void 0:p.id)!==t[0].id)&&(o(m=>!m),u(m=>!m))},children:[r.code===0?g.jsx("svg",{className:"h-3 w-3",xmlns:"http://www.w3.org/2000/svg",width:"13",height:"12",viewBox:"0 0 13 12",fill:"none",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.37695 12C9.69067 12 12.377 9.31371 12.377 6C12.377 2.68629 9.69067 0 6.37695 0C3.06325 0 0.376953 2.68629 0.376953 6C0.376953 9.31371 3.06325 12 6.37695 12ZM9.62004 4.65344C9.87907 4.36036 9.8651 3.90005 9.58884 3.6253C9.3125 3.35055 8.87861 3.3654 8.61958 3.65847L5.6477 7.02105L4.08967 5.55197C3.80661 5.28508 3.37319 5.31213 3.12159 5.61237C2.87 5.91262 2.89549 6.37239 3.17854 6.63927L4.90294 8.26517C5.36588 8.70171 6.07235 8.6676 6.49598 8.18829L9.62004 4.65344Z",fill:"#6CD063"})}):g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FF4500",width:"13",height:"12",children:g.jsx("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z",clipRule:"evenodd"})}),g.jsx("span",{className:"truncate max-w-[150px]",children:e})]})}function B6({node:t,depth:e=0}){var c,d;const[n,r]=S.useState(!0),i=t.children&&t.children.length>0,{setOpenDetail:s,setSpan:o,openDetail:a,span:l}=S.useContext(Al),u=Math.min(t.relativePercentage?t==null?void 0:t.relativePercentage:0,100);return g.jsxs("div",{children:[g.jsxs(ht,{variant:"ghost",className:be("relative flex w-full items-center justify-start gap-2 py-3 pr-1 text-sm",{"text-accent-foreground bg-accent":(l==null?void 0:l.id)===t.id}),onClick:p=>{p.preventDefault(),p.stopPropagation(),o(t),!(a&&t.id!==(l==null?void 0:l.id))&&s(m=>!m)},style:{paddingLeft:`${e>0?e*35+28:24}px`},children:[i?g.jsx("div",{onClick:()=>r(!n),className:"relative grid h-auto flex-shrink-0 place-items-center rounded-sm bg-[#1a1a1a] p-2",children:g.jsx("svg",{className:be("!h-2 !w-2 transition-transform",n?"":"-rotate-90"),xmlns:"http://www.w3.org/2000/svg",width:"7",height:"6",viewBox:"0 0 7 6",fill:"none",children:g.jsx("path",{d:"M3.9338 5.5C3.74135 5.83333 3.26022 5.83333 3.06777 5.5L0.469694 0.999999C0.277244 0.666666 0.517814 0.25 0.902714 0.25L6.09886 0.25C6.48376 0.25 6.72433 0.666666 6.53188 1L3.9338 5.5Z",fill:"#939393"})})}):null,g.jsxs("div",{className:"flex w-full gap-4 pr-4",children:[g.jsx("p",{className:be("max-w-[400px] truncate px-1 text-sm",{"text-white":((c=t==null?void 0:t.status)==null?void 0:c.code)===0,"text-[#FF4500]":((d=t==null?void 0:t.status)==null?void 0:d.code)!==0}),children:t.name}),t.duration>0&&g.jsxs("div",{className:"relative w-full max-w-[200px]",children:[g.jsx("div",{className:"absolute top-[11px] h-px w-full bg-[hsl(220,14%,19%)]"}),g.jsx("div",{style:{width:`${u}%`,left:0},className:be("absolute top-[9px] z-0 h-[5px] rounded-[5px] bg-white transition-all",t.name.includes("agent")&&"left-1/2 bg-green-500",t.name.includes("llm")&&"bg-[#5699A8]",t.name.includes("ai")&&"left-2/4 w-5 bg-[#F09A56]")}),g.jsxs("span",{className:"absolute left-0 top-3 text-[0.63rem] text-mastra-el-3",children:[DA(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(p=>g.jsx(B6,{node:p,depth:e+1},p.id))})]})}function kye({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(B6,{node:e},e.id))})}function z6(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:z6(t,n.id)}))}function Sye({trace:t}){const e=z6(t);return g.jsx("div",{children:g.jsx(kye,{tree:e})})}function $6(){const{trace:t,currentTraceIndex:e,prevTrace:n,nextTrace:r,traces:i,clearData:s}=S.useContext(Al);return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center justify-between px-6 pt-[1.56rem]",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("h3",{className:"text-[1.125rem]",children:["Trace Span",t!=null&&t.length&&t.length>1?"s":""]}),g.jsxs("span",{className:"text-xs text-mastra-el-3",children:[t!=null&&t.length?t.length:0," span",t!=null&&t.length&&t.length>1?"s":""]})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ht,{onClick:()=>{n()},disabled:e===0,variant:"secondary",size:"icon",className:"!h-3 !w-3 rotate-180 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Wh,{})})," ",g.jsx(ht,{onClick:()=>{r()},disabled:e===i.length-1,variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Wh,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(ht,{onClick:()=>{s()},variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(kl,{})})]})]}),g.jsxs("div",{className:"p-6 px-1",children:[" ",t&&g.jsx(Sye,{trace:t})]})]})}const V6=1024;let Cye=0,lk=class{constructor(e,n){this.from=e,this.to=n}};class Et{constructor(e={}){this.id=Cye++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=li.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Et.closedBy=new Et({deserialize:t=>t.split(" ")});Et.openedBy=new Et({deserialize:t=>t.split(" ")});Et.group=new Et({deserialize:t=>t.split(" ")});Et.isolate=new Et({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Et.contextHash=new Et({perNode:!0});Et.lookAhead=new Et({perNode:!0});Et.mounted=new Et({perNode:!0});class Vx{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[Et.mounted.id]}}const Eye=Object.create(null);class li{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):Eye,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new li(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Et.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Et.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}li.none=new li("",Object.create(null),0,8);class jA{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new li(r.name,i,r.id,r.flags):r)}return new jA(n)}}const dy=new WeakMap,BD=new WeakMap;var sr;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(sr||(sr={}));class Bn{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Vx.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new aE(this.topNode,e)}cursorAt(e,n=0,r=0){let i=dy.get(this)||this.topNode,s=new aE(i);return s.moveTo(e,n),dy.set(this,s._tree),s}get topNode(){return new Qi(this,0,0,null)}resolve(e,n=0){let r=op(dy.get(this)||this.topNode,e,n,!1);return dy.set(this,r),r}resolveInner(e,n=0){let r=op(BD.get(this)||this.topNode,e,n,!0);return BD.set(this,r),r}resolveStack(e,n=0){return Aye(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&sr.IncludeAnonymous)>0;for(let l=this.cursor(o|sr.IncludeAnonymous);;){let u=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:FA(li.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Bn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Bn(li.none,n,r,i)))}static build(e){return _ye(e)}}Bn.empty=new Bn(li.none,[],[],0);class IA{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new IA(this.buffer,this.index)}}class fl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return li.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(W6(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let u=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,u)}return new fl(s,o,this.set)}}function W6(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function op(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof Qi&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:sr.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof Qi&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class H6{cursor(e=0){return new aE(this,e)}getChild(e,n=null,r=null){let i=zD(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return zD(this,e,n,r)}resolve(e,n=0){return op(this,e,n,!1)}resolveInner(e,n=0){return op(this,e,n,!0)}matchContext(e){return oE(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Qi extends H6{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,u=n>0?a.length:-1;e!=u;e+=n){let c=a[e],d=l[e]+o.from;if(W6(i,r,d,d+c.length)){if(c instanceof fl){if(s&sr.ExcludeBuffers)continue;let p=c.findChild(0,c.buffer.length,n,r-d,i);if(p>-1)return new el(new Nye(o,c,e,d),null,p)}else if(s&sr.IncludeAnonymous||!c.type.isAnonymous||LA(c)){let p;if(!(s&sr.IgnoreMounts)&&(p=Vx.get(c))&&!p.overlay)return new Qi(p.tree,d,e,o);let m=new Qi(c,d,e,o);return s&sr.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?c.children.length-1:0,n,r,i)}}}if(s&sr.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&sr.IgnoreOverlays)&&(i=Vx.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new Qi(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function zD(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function oE(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Nye{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class el extends H6{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new el(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&sr.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new el(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new el(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new el(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Bn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function U6(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof Qi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new Tye(i,n)}class Tye{constructor(e,n){this.heads=e,this.node=n}get next(){return U6(this.heads)}}function Aye(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Qi?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=Vx.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Qi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(op(a,e,n,!1))}}return i?U6(i):r}class aE{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Qi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Qi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&sr.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&sr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&sr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&sr.IncludeAnonymous||a instanceof fl||!a.type.isAnonymous||LA(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new el(this.buffer,n,this.stack[i]);return this.bufferNode=new el(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return oE(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return oE(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function LA(t){return t.children.some(e=>e instanceof fl||!e.type.isAnonymous||LA(e))}function _ye(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=V6,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new IA(n,n.length):n,l=r.types,u=0,c=0;function d(A,_,M,R,D,O){let{id:B,start:F,end:V,size:I}=a,Y=c,W=u;for(;I<0;)if(a.next(),I==-1){let q=s[B];M.push(q),R.push(F-A);return}else if(I==-3){u=B;return}else if(I==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let G=l[B],H,$,L=F-A;if(V-F<=i&&($=w(a.pos-_,D))){let q=new Uint16Array($.size-$.skip),U=a.pos-$.size,j=q.length;for(;a.pos>U;)j=b($.start,q,j);H=new fl(q,V-$.start,r),L=$.start-A}else{let q=a.pos-I;a.next();let U=[],j=[],K=B>=o?B:-1,X=0,J=V;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,j,F,X,a.end,J,K,Y,W),X=U.length,J=a.end),a.next()):O>2500?p(F,q,U,j):d(F,q,U,j,K,O+1);if(K>=0&&X>0&&X<U.length&&y(U,j,F,X,F,J,K,Y,W),U.reverse(),j.reverse(),K>-1&&X>0){let ee=m(G,W);H=FA(G,U,j,0,U.length,0,V-F,ee,ee)}else H=v(G,U,j,V-F,Y-V,W)}M.push(H),R.push(L)}function p(A,_,M,R){let D=[],O=0,B=-1;for(;a.pos>_;){let{id:F,start:V,end:I,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&V<B)break;B<0&&(B=I-i),D.push(F,V,I),O++,a.next()}}if(O){let F=new Uint16Array(O*4),V=D[D.length-2];for(let I=D.length-3,Y=0;I>=0;I-=3)F[Y++]=D[I],F[Y++]=D[I+1]-V,F[Y++]=D[I+2]-V,F[Y++]=Y;M.push(new fl(F,D[2]-V,r)),R.push(V-A)}}function m(A,_){return(M,R,D)=>{let O=0,B=M.length-1,F,V;if(B>=0&&(F=M[B])instanceof Bn){if(!B&&F.type==A&&F.length==D)return F;(V=F.prop(Et.lookAhead))&&(O=R[B]+F.length+V)}return v(A,M,R,D,O,_)}}function y(A,_,M,R,D,O,B,F,V){let I=[],Y=[];for(;A.length>R;)I.push(A.pop()),Y.push(_.pop()+M-D);A.push(v(r.types[B],I,Y,O-D,F-O,V)),_.push(D-M)}function v(A,_,M,R,D,O,B){if(O){let F=[Et.contextHash,O];B=B?[F].concat(B):[F]}if(D>25){let F=[Et.lookAhead,D];B=B?[F].concat(B):[F]}return new Bn(A,_,M,R,B)}function w(A,_){let M=a.fork(),R=0,D=0,O=0,B=M.end-i,F={size:0,start:0,skip:0};e:for(let V=M.pos-A;M.pos>V;){let I=M.size;if(M.id==_&&I>=0){F.size=R,F.start=D,F.skip=O,O+=4,R+=4,M.next();continue}let Y=M.pos-I;if(I<0||Y<V||M.start<B)break;let W=M.id>=o?4:0,G=M.start;for(M.next();M.pos>Y;){if(M.size<0)if(M.size==-3)W+=4;else break e;else M.id>=o&&(W+=4);M.next()}D=G,R+=I,O+=W}return(_<0||R==A)&&(F.size=R,F.start=D,F.skip=O),F.size>4?F:void 0}function b(A,_,M){let{id:R,start:D,end:O,size:B}=a;if(a.next(),B>=0&&R<o){let F=M;if(B>4){let V=a.pos-(B-4);for(;a.pos>V;)M=b(A,_,M)}_[--M]=F,_[--M]=O-A,_[--M]=D-A,_[--M]=R}else B==-3?u=R:B==-4&&(c=R);return M}let k=[],E=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,E,-1,0);let N=(e=t.length)!==null&&e!==void 0?e:k.length?E[0]+k[0].length:0;return new Bn(l[t.topID],k.reverse(),E.reverse(),N)}const $D=new WeakMap;function tx(t,e){if(!t.isAnonymous||e instanceof fl||e.type!=t)return 1;let n=$D.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Bn)){n=1;break}n+=tx(t,r)}$D.set(e,n)}return n}function FA(t,e,n,r,i,s,o,a,l){let u=0;for(let y=r;y<i;y++)u+=tx(t,e[y]);let c=Math.ceil(u*1.5/8),d=[],p=[];function m(y,v,w,b,k){for(let E=w;E<b;){let N=E,A=v[E],_=tx(t,y[E]);for(E++;E<b;E++){let M=tx(t,y[E]);if(_+M>=c)break;_+=M}if(E==N+1){if(_>c){let M=y[N];m(M.children,M.positions,0,M.children.length,v[N]+k);continue}d.push(y[N])}else{let M=v[E-1]+y[E-1].length-A;d.push(FA(t,y,v,N,E,A,M,null,l))}p.push(A+k-s)}}return m(e,n,r,i,0),(a||l)(d,p,o)}class uu{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new uu(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,u=0;;a++){let c=a<n.length?n[a]:null,d=c?c.fromA:1e9;if(d-l>=r)for(;o&&o.from<d;){let p=o;if(l>=p.from||d<=p.to||u){let m=Math.max(p.from,l)-u,y=Math.min(p.to,d)-u;p=m>=y?null:new uu(m,y,p.tree,p.offset+u,a>0,!!c)}if(p&&i.push(p),o.to>d)break;o=s<e.length?e[s++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}}class q6{startParse(e,n,r){return typeof e=="string"&&(e=new Mye(e)),r=r?r.length?r.map(i=>new lk(i.from,i.to)):[new lk(0,0)]:[new lk(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class Mye{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Et({perNode:!0});var VD={};class Wx{constructor(e,n,r,i,s,o,a,l,u,c=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=u,this.lookAhead=c,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Wx(e,[],n,r,r,0,[],0,i?new WD(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let d=l?this.stack[l-1]:0,p=this.bufferBase+this.buffer.length-d;if(i<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,u,m,p+4,!0)}if(e&262144)this.state=this.stack[l];else{let m=this.stack[l-3];this.state=s.getGoto(m,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(n==r)return;if(o.buffer[a-2]>=n){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||n<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Wx(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new Pye(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,l)=>l&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let r=n>>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,u=this.stack.length-a*3;if(u>=0&&e.getGoto(this.stack[u],l,!1)>=0)return a<<19|65536|l}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new WD(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class WD{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Pye{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Hx{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Hx(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hx(this.stack,this.pos,this.index)}}function fy(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r<t.length;){let s=0;for(;;){let o=t.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class nx{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const HD=new nx;class Rye{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=HD,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;n<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=HD,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Wc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;Oye(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Wc.prototype.contextual=Wc.prototype.fallback=Wc.prototype.extend=!1;Wc.prototype.fallback=Wc.prototype.extend=!1;function Oye(t,e,n,r,i,s){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;a&t[o];){let u=t[o+1];for(let m=o+3;m<u;m+=2)if((t[m+1]&a)>0){let y=t[m];if(l.allows(y)&&(e.token.value==-1||e.token.value==y||Dye(y,e.token.value,i,s))){e.acceptToken(y);break}}let c=e.next,d=0,p=t[o+2];if(e.next<0&&p>d&&t[u+p*3-3]==65535){o=t[u+p*3-1];continue e}for(;d<p;){let m=d+p>>1,y=u+m+(m<<1),v=t[y],w=t[y+1]||65536;if(c<v)p=m;else if(c>=w)d=m+1;else{o=t[y+2],e.advance();continue e}}break}}function UD(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function Dye(t,e,n,r){let i=UD(n,r,e);return i<0||UD(n,r,t)<i}const gi=typeof process<"u"&&VD&&/\bparse\b/.test(VD.LOG);let uk=null;function qD(t,e,n){let r=t.cursor(sr.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class jye{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?qD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?qD(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[n]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof Bn){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(Et.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class Iye{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new nx)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let u=0;u<s.length;u++){if(!(1<<u&o))continue;let c=s[u],d=this.tokens[u];if(!(r&&!c.fallback)&&((c.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,c,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let p=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!c.extend&&(r=d,n>p))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new nx,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new nx,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=n,this.actions[i++]=r,i}addActions(e,n,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let u=o.stateSlot(s,l?2:1);;u+=3){if(a[u]==65535)if(a[u+1]==1)u=Vo(a,u+2);else{i==0&&a[u+1]==2&&(i=this.putAction(Vo(a,u+2),n,r,i));break}a[u]==n&&(i=this.putAction(Vo(a,u+1),n,r,i))}return i}}class Lye{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Rye(n,i),this.tokens=new Iye(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Wx.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new jye(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!r.length){let o=i&&Bye(i);if(o)return gi&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw gi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return gi&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,l)=>l.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let l=o+1;l<r.length;l++){let u=r[l];if(a.sameState(u)||a.buffer.length>500&&u.buffer.length>500)if((a.score-u.score||a.buffer.length-u.buffer.length)>0)r.splice(l--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let i=e.pos,{parser:s}=this,o=gi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let p=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(p>-1&&d.length&&(!u||(d.prop(Et.contextHash)||0)==c))return e.useNode(d,p),gi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof Bn)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Bn&&d.positions[0]==0)d=m;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),gi&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let u=0;u<l.length;){let c=l[u++],d=l[u++],p=l[u++],m=u==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(c,d,v?v.start:y.pos,p),gi&&console.log(o+this.stackID(y)+` (via ${c&65536?`reduce of ${s.getName(c&65535)}`:"shift"} for ${s.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?n.push(y):r.push(y)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return YD(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=n[o<<1],u=n[(o<<1)+1],c=gi?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),gi&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),p=c;for(let m=0;d.forceReduce()&&m<10&&(gi&&console.log(p+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));m++)gi&&(p=this.stackID(d)+" -> ");for(let m of a.recoverByInsert(l))gi&&console.log(c+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(u==a.pos&&(u++,l=0),a.recoverByDelete(l,u),gi&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),YD(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),Bn.build({buffer:Hx.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(uk||(uk=new WeakMap)).get(e);return n||uk.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function YD(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class Fye{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Ux extends q6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,l,u){i[a].push([l,l.deserialize(String(u))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Et[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)s(c,l,a[u++]);else{let d=a[u+-c];for(let p=-c;p>0;p--)s(a[u++],l,d);u++}}}this.nodeSet=new jA(n.map((a,l)=>li.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=V6;let o=fy(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(GD),this.states=fy(e.states,Uint32Array),this.data=fy(e.stateData),this.goto=fy(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Wc(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new Lye(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&r)return l;for(let u=s+(o>>1);s<u;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Vo(r,s+2)];else{if(r[s+1]==2)return Vo(r,s+2);break}if(o==n||o==0)return Vo(r,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vo(this.data,s+2);else break;i=n(Vo(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Vo(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Ux.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=GD(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new Fye(e,r,i)}static deserialize(e){return new Ux(e)}}function Vo(t,e){return t[e]|t[e+1]<<16}function Bye(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function GD(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let zye=0;class Yi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=zye++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Yi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Yi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new qx(e);return r=>r.modified.indexOf(n)>-1?r:qx.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let $ye=0;class qx{constructor(e){this.name=e,this.instances=[],this.id=$ye++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Vye(n,a.modified));if(r)return r;let i=[],s=new Yi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=Wye(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(qx.get(a,l));return s}}function Vye(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function Wye(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function Y6(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){o=1;break}let p=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!p)throw new RangeError("Invalid path: "+i);if(s.push(p[0]=="*"?"":p[0][0]=='"'?JSON.parse(p[0]):p[0]),d+=p[0].length,d==i.length)break;let m=i[d++];if(d==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new Yx(r,o,l>0?s.slice(0,l):null);e[u]=c.sort(e[u])}}return G6.add(e)}const G6=new Et;class Yx{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Yx.empty=new Yx([],2,null);function K6(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let u=n[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function Hye(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function Uye(t,e,n,r=0,i=t.length){let s=new qye(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class qye{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(o)));let u=i,c=Yye(e)||Yx.empty,d=Hye(s,c.tags);if(d&&(u&&(u+=" "),u+=d,c.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,a),u),c.opaque)return;let p=e.tree&&e.tree.prop(Et.mounted);if(p&&p.overlay){let m=e.node.enter(p.overlay[0].from+a,1),y=this.highlighters.filter(w=>!w.scope||w.scope(p.tree.type)),v=e.firstChild();for(let w=0,b=a;;w++){let k=w<p.overlay.length?p.overlay[w]:null,E=k?k.from+a:l,N=Math.max(n,b),A=Math.min(r,E);if(N<A&&v)for(;e.from<A&&(this.highlightRange(e,N,A,i,s),this.startSpan(Math.min(A,e.to),u),!(e.to>=E||!e.nextSibling())););if(!k||E>r)break;b=k.to+a,b>n&&(this.highlightRange(m.cursor(),Math.max(n,k.from+a),Math.min(r,b),"",y),this.startSpan(Math.min(r,b),u))}v&&e.parent()}else if(e.firstChild()){p&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function Yye(t){let e=t.type.prop(G6);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Re=Yi.define,hy=Re(),Ya=Re(),KD=Re(Ya),XD=Re(Ya),Ga=Re(),py=Re(Ga),ck=Re(Ga),Vs=Re(),Gl=Re(Vs),Fs=Re(),Bs=Re(),lE=Re(),qf=Re(lE),my=Re(),re={comment:hy,lineComment:Re(hy),blockComment:Re(hy),docComment:Re(hy),name:Ya,variableName:Re(Ya),typeName:KD,tagName:Re(KD),propertyName:XD,attributeName:Re(XD),className:Re(Ya),labelName:Re(Ya),namespace:Re(Ya),macroName:Re(Ya),literal:Ga,string:py,docString:Re(py),character:Re(py),attributeValue:Re(py),number:ck,integer:Re(ck),float:Re(ck),bool:Re(Ga),regexp:Re(Ga),escape:Re(Ga),color:Re(Ga),url:Re(Ga),keyword:Fs,self:Re(Fs),null:Re(Fs),atom:Re(Fs),unit:Re(Fs),modifier:Re(Fs),operatorKeyword:Re(Fs),controlKeyword:Re(Fs),definitionKeyword:Re(Fs),moduleKeyword:Re(Fs),operator:Bs,derefOperator:Re(Bs),arithmeticOperator:Re(Bs),logicOperator:Re(Bs),bitwiseOperator:Re(Bs),compareOperator:Re(Bs),updateOperator:Re(Bs),definitionOperator:Re(Bs),typeOperator:Re(Bs),controlOperator:Re(Bs),punctuation:lE,separator:Re(lE),bracket:qf,angleBracket:Re(qf),squareBracket:Re(qf),paren:Re(qf),brace:Re(qf),content:Vs,heading:Gl,heading1:Re(Gl),heading2:Re(Gl),heading3:Re(Gl),heading4:Re(Gl),heading5:Re(Gl),heading6:Re(Gl),contentSeparator:Re(Vs),list:Re(Vs),quote:Re(Vs),emphasis:Re(Vs),strong:Re(Vs),link:Re(Vs),monospace:Re(Vs),strikethrough:Re(Vs),inserted:Re(),deleted:Re(),changed:Re(),invalid:Re(),meta:my,documentMeta:Re(my),annotation:Re(my),processingInstruction:Re(my),definition:Yi.defineModifier("definition"),constant:Yi.defineModifier("constant"),function:Yi.defineModifier("function"),standard:Yi.defineModifier("standard"),local:Yi.defineModifier("local"),special:Yi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof Yi&&(e.name=t)}K6([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]);const Gye=Y6({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),Kye=Ux.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Gye],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let uE=[],X6=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?X6:uE).push(n=n+t[e])})();function Xye(t){if(t<768)return!1;for(let e=0,n=uE.length;;){let r=e+n>>1;if(t<uE[r])n=r;else if(t>=X6[r])e=r+1;else return!0;if(e==n)return!1}}function ZD(t){return t>=127462&&t<=127487}const QD=8205;function Zye(t,e,n=!0,r=!0){return(n?Z6:Qye)(t,e,r)}function Z6(t,e,n){if(e==t.length)return e;e&&Q6(t.charCodeAt(e))&&J6(t.charCodeAt(e-1))&&e--;let r=dk(t,e);for(e+=JD(r);e<t.length;){let i=dk(t,e);if(r==QD||i==QD||n&&Xye(i))e+=JD(i),r=i;else if(ZD(i)){let s=0,o=e-2;for(;o>=0&&ZD(dk(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Qye(t,e,n){for(;e>0;){let r=Z6(t,e-2,n);if(r<e)return r;e--}return 0}function dk(t,e){let n=t.charCodeAt(e);if(!J6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return Q6(r)?(n-55296<<10)+(r-56320)+65536:n}function Q6(t){return t>=56320&&t<57344}function J6(t){return t>=55296&&t<56320}function JD(t){return t<65536?1:2}let $t=class e8{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=ld(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),qs.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=ld(this,e,n);let r=[];return this.decompose(e,n,r,0),qs.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new _h(this),s=new _h(e);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new _h(this,e)}iterRange(e,n=this.length){return new t8(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new n8(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?e8.empty:e.length<=32?new An(e):qs.from(An.split(e,[]))}};class An extends $t{constructor(e,n=Jye(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=e)return new exe(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new An(ej(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=rx(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new An(a,o.length+s.length));else{let l=a.length>>1;r.push(new An(a.slice(0,l)),new An(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof An))return super.replace(e,n,r);[e,n]=ld(this,e,n);let i=rx(this.text,rx(r.text,ej(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new An(i,s):qs.from(An.split(i,[]),s)}sliceString(e,n=this.length,r=`
341
+ color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,i),i}}function ok(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Ype=(t,e)=>Math.abs(t-e)<1,Gpe=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},Kpe=t=>t,Xpe=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let i=e;i<=n;i++)r.push(i);return r},Zpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=o[0];if(a!=null&&a.borderBoxSize){const l=a.borderBoxSize[0];if(l){i({width:l.inlineSize,height:l.blockSize});return}}i(n.getBoundingClientRect())});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},CD={passive:!0},Qpe=typeof window>"u"?!0:"onscrollend"in window,Jpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&Qpe?()=>{}:Gpe(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:c,isRtl:d}=t.options;i=c?n.scrollLeft*(d&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);return l(),n.addEventListener("scroll",a,CD),n.addEventListener("scrollend",l,CD),()=>{n.removeEventListener("scroll",a),n.removeEventListener("scrollend",l)}},eme=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(t.getBoundingClientRect()[n.options.horizontal?"width":"height"])},tme=(t,{adjustments:e=0,behavior:n},r)=>{var i,s;const o=t+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class nme{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{this._measureElement(s.target,s)})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Kpe,rangeExtractor:Xpe,onChange:()=>{},measureElement:eme,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=mc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=mc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,i,s,o)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o}),{key:!1}),this.getMeasurements=mc(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,l);for(let c=l;c<n;c++){const d=s(c),p=this.options.lanes===1?u[c-1]:this.getFurthestMeasurement(u,c),m=p?p.end+this.options.gap:r+i,y=a.get(d),v=typeof y=="number"?y:this.options.estimateSize(c),w=m+v,b=p?p.lane:c%this.options.lanes;u[c]={index:c,start:m,size:v,end:w,key:d,lane:b}}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=mc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?rme({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getIndexes=mc(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const i=this.indexFromElement(n),s=this.measurementsCache[i];if(!s)return;const o=s.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(i,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const i=this.measurementsCache[n];if(!i)return;const s=this.itemSizeCache.get(i.key)??i.size,o=r-s;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,i)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(i))});return}this._measureElement(n,void 0)},this.getVirtualItems=mc(()=>[this.getIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return ok(r[JV(0,r.length-1,i=>ok(r[i]).start,n)])},this.getOffsetForAlignment=(n,r)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&n>=s+i&&(r="end"),r==="end"&&(n-=i);const o=this.options.horizontal?"scrollWidth":"scrollHeight",l=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[o]:this.scrollElement[o]:0)-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.measurementsCache[n];if(!i)return;const s=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(i.end>=o+s-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=i.start-this.options.scrollPaddingStart+(i.size-s)/2;switch(r){case"center":return[this.getOffsetForAlignment(a,r),r];case"end":return[this.getOffsetForAlignment(i.end+this.options.scrollPaddingEnd,r),r];default:return[this.getOffsetForAlignment(i.start-this.options.scrollPaddingStart,r),r]}},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:i}={})=>{this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(n,{align:r="auto",behavior:i}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s;this._scrollToOffset(o,{adjustments:void 0,behavior:i}),i!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[u]=ok(this.getOffsetForIndex(n,a));Ype(u,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:i})}else this.scrollToIndex(n,{align:a,behavior:i})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;return r.length===0?i=this.options.paddingStart:i=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(s=>s.end)),Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const JV=(t,e,n,r)=>{for(;t<=e;){const i=(t+e)/2|0,s=n(i);if(s<r)t=i+1;else if(s>r)e=i-1;else return i}return t>0?t-1:0};function rme({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=JV(0,r,a=>t[a].start,n);let o=s;for(;o<r&&t[o].end<n+e;)o++;return{startIndex:s,endIndex:o}}const ED=typeof document<"u"?S.useLayoutEffect:S.useEffect;function ime(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Dd.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new nme(n));return r.setOptions(n),ED(()=>r._didMount(),[]),ED(()=>r._willUpdate()),r}function sme(t){return ime({observeElementRect:Zpe,observeElementOffset:Jpe,scrollToFn:tme,...t})}const ome=Wpe,ame=Hpe,lme=WV,ume=qpe,cme=Upe,e6=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx(VV,{ref:i,className:be("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));e6.displayName=VV.displayName;const t6=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(ZV,{ref:i,className:be("focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",e&&"pl-8",t),...r,children:[n,g.jsx(Wh,{className:"ml-auto -rotate-90"})]}));t6.displayName=ZV.displayName;const n6=S.forwardRef(({className:t,...e},n)=>g.jsx(QV,{ref:n,className:be("popover-backdrop-filter popover-background popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...e}));n6.displayName=QV.displayName;const r6=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(WV,{container:e,children:g.jsx(HV,{ref:i,sideOffset:n,className:be("popover-backdrop-filter bg-mastra-bg-2 popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...r})}));r6.displayName=HV.displayName;const i6=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(qV,{ref:r,className:be("focus:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",e&&"pl-8",t),...n}));i6.displayName=qV.displayName;const s6=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(YV,{ref:i,className:be("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:n,...r,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(KV,{children:g.jsx(UN,{className:"h-2 w-2 fill-current"})})}),e]}));s6.displayName=YV.displayName;const o6=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(GV,{ref:r,className:be("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(KV,{children:g.jsx(RX,{className:"h-2 w-2 fill-current"})})}),e]}));o6.displayName=GV.displayName;const a6=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(UV,{ref:r,className:be("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));a6.displayName=UV.displayName;const l6=S.forwardRef(({className:t,...e},n)=>g.jsx(XV,{ref:n,className:be("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));l6.displayName=XV.displayName;const u6=({className:t,...e})=>g.jsx("span",{className:be("ml-auto text-xs tracking-widest opacity-60",t),...e});u6.displayName="DropdownMenuShortcut";function Qn({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(ome,{modal:r,open:t,onOpenChange:e,children:n})}function dme({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=sme({count:t,estimateSize:()=>35,getScrollElement:()=>i.current,overscan:5,measureElement:typeof window<"u"&&navigator.userAgent.indexOf("Firefox")===-1?o=>o==null?void 0:o.getBoundingClientRect().height:void 0});return g.jsx("div",{ref:i,className:"h-64 overflow-auto",children:g.jsx("div",{className:"relative w-full overflow-auto",style:{height:`${s.getTotalSize()}px`},children:s==null?void 0:s.getVirtualItems().map((o,a)=>g.jsx("button",{className:"text-accent-foreground absolute left-0 top-0 flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors hover:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",style:{height:`${o.size}px`,transform:`translateY(${o.start}px)`},...r,children:n(e[a])},o.index))})})}Qn.Trigger=e6;Qn.Content=r6;Qn.Group=ame;Qn.Portal=lme;Qn.Item=i6;Qn.CheckboxItem=s6;Qn.RadioItem=o6;Qn.Label=a6;Qn.Separator=l6;Qn.Shortcut=u6;Qn.Sub=ume;Qn.SubContent=n6;Qn.SubTrigger=t6;Qn.RadioGroup=cme;Qn.VirtualizedItems=dme;const fme=t=>{const{data:e,isLoading:n,mutate:r}=LT(`/api/memory/status?agentId=${t}`,YN,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},hme=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=LT(`/api/memory/threads?resourceid=${t}&agentId=${e}`,YN,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},pme=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=LT(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>YN(o,!0),{fallbackData:{uiMessages:[],messages:[]},revalidateOnFocus:!1,isPaused:()=>!t,shouldRetryOnError:!1});return S.useEffect(()=>{t&&e&&s()},[t,e]),{messages:r==null?void 0:r.uiMessages,isLoading:i,mutate:s}},mme=()=>{const{mutate:t}=IT();return{deleteThread:async({threadId:n,resourceid:r,agentId:i})=>{const s=fetch(`/api/memory/threads/${n}?agentId=${i}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});kn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function gme({agentId:t,threadId:e}){const{threads:n,isLoading:r}=hme({resourceid:t,agentId:t}),{deleteThread:i}=mme(),s=bo(),[o,a]=S.useState(null),[l,u]=S.useState(!1),c=async()=>{await i({threadId:o,resourceid:t,agentId:t}),u(!1),o===e&&s(`/agents/${t}/chat/${crypto.randomUUID()}`)};return r?g.jsxs("div",{className:"p-4 w-full h-full space-y-2",children:[g.jsx("div",{className:"flex justify-end",children:g.jsx(He,{className:"h-9 w-9"})}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"}),g.jsx(He,{className:"h-4"})]}):n!=null&&n.length?g.jsxs(Mn,{className:"h-full px-4 pb-4 w-[256px]",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex justify-between items-center pl-2 sticky top-0 bg-mastra-bg-2 pt-4",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(ht,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Hh,{})})]}),n.map(d=>{const p=d.id===e;return g.jsxs("div",{className:be("flex cursor-pointer w-full px-2 items-center focus-visible:outline-none transition-colors focus-visible:ring-1 focus-visible:ring-mastra-border-4 gap-3 rounded-xs group text-small hover:bg-mastra-el-6/5",p?"bg-mastra-el-6/5":""),children:[g.jsx(Xp,{to:`/agents/${t}/chat/${d.id}`,className:"flex-1",children:g.jsx("p",{className:be("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",p?"text-mastra-el-6":""),children:d.title})}),g.jsxs(Qn,{children:[g.jsx(Qn.Trigger,{asChild:!0,children:g.jsxs(ht,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(jX,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(Qn.Content,{children:g.jsxs(Qn.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(d.id),u(!0)},children:[g.jsx(HX,{}),g.jsx("span",{children:"Delete"})]})})]})]},d.id)})]}),g.jsx(tn,{open:l,onOpenChange:u,children:g.jsxs(tn.Content,{children:[g.jsxs(tn.Header,{children:[g.jsx(tn.Title,{children:"Are you absolutely sure?"}),g.jsx(tn.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(tn.Footer,{children:[g.jsx(tn.Cancel,{children:"Cancel"}),g.jsx(tn.Action,{onClick:c,children:"Continue"})]})]})})]}):g.jsxs("div",{className:"p-4 w-full space-y-2 h-full",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(ht,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Hh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function ND(){const{agentId:t,threadId:e}=da(),{agent:n,isLoading:r}=Pu(t),{memory:i}=fme(t),s=bo(),{messages:o,isLoading:a}=pme({agentId:t,threadId:e,memory:!!(i!=null&&i.result)}),[l,u]=S.useState(!0);return S.useEffect(()=>{i!=null&&i.result&&!e&&s(`/agents/${t}/chat/${crypto.randomUUID()}`)},[i==null?void 0:i.result,e]),r?g.jsxs("main",{className:"flex-1 relative grid grid-cols-[1fr_400px] divide-x",children:[g.jsx("div",{className:"p-4",children:g.jsx(He,{className:"h-[600px]"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx(Dx,{agentId:t})})]}):g.jsxs("main",{className:be("flex-1 relative grid divide-x",l&&(i!=null&&i.result)?"grid-cols-[256px_1fr_400px] overflow-y-hidden h-full":"grid-cols-[1fr_400px]"),children:[l&&(i!=null&&i.result)?g.jsx(gme,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(ht,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>u(!l),children:g.jsx(BX,{})}):null,g.jsx(jce,{agentId:t,agentName:n==null?void 0:n.name,threadId:e,initialMessages:a?void 0:o,memory:i==null?void 0:i.result})]}),g.jsx("div",{className:"flex flex-col",children:g.jsx(Dx,{agentId:t})})]})}const yme=Id("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ah({className:t,variant:e,...n}){return g.jsx("div",{className:be(yme({variant:e}),t),...n})}function ly({content:t,label:e,multiline:n=!1}){const r=()=>{navigator.clipboard.writeText(t)};return g.jsxs("div",{className:"group relative flex items-start gap-2",children:[g.jsx("span",{className:be("text-sm text-mastra-el-4",n?"whitespace-pre-wrap":"truncate"),children:t}),g.jsx(ht,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 -mt-1",onClick:i=>{i.stopPropagation(),r()},"aria-label":`Copy ${e}`,children:g.jsx(R4,{className:"h-3 w-3"})})]})}const c6=6048e5,xme=864e5,uy=43200,TD=1440,AD=Symbol.for("constructDateFrom");function Vn(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&AD in t?t[AD](e):t instanceof Date?new t.constructor(e):new Date(e)}function Rt(t,e){return Vn(e||t,t)}function d6(t,e,n){const r=Rt(t,n==null?void 0:n.in);return isNaN(e)?Vn(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function f6(t,e,n){const r=Rt(t,n==null?void 0:n.in);if(isNaN(e))return Vn(t,NaN);if(!e)return r;const i=r.getDate(),s=Vn(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const o=s.getDate();return i>=o?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let vme={};function Hd(){return vme}function od(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.weekStartsOn)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=Rt(t,e==null?void 0:e.in),s=i.getDay(),o=(s<r?7:0)+s-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function ip(t,e){return od(t,{...e,weekStartsOn:1})}function h6(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=Vn(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=ip(i),o=Vn(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);const a=ip(o);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function $x(t){const e=Rt(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function Tl(t,...e){const n=Vn.bind(null,t||e.find(r=>typeof r=="object"));return e.map(n)}function sp(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setHours(0,0,0,0),n}function p6(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e),s=sp(r),o=sp(i),a=+s-$x(s),l=+o-$x(o);return Math.round((a-l)/xme)}function wme(t,e){const n=h6(t,e),r=Vn(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),ip(r)}function bme(t,e,n){return d6(t,e*7,n)}function kme(t,e,n){return f6(t,e*12,n)}function Sme(t,e){let n,r=e==null?void 0:e.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Vn.bind(null,i));const s=Rt(i,r);(!n||n<s||isNaN(+s))&&(n=s)}),Vn(r,n||NaN)}function Cme(t,e){let n,r=e==null?void 0:e.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Vn.bind(null,i));const s=Rt(i,r);(!n||n>s||isNaN(+s))&&(n=s)}),Vn(r,n||NaN)}function ex(t,e){const n=+Rt(t)-+Rt(e);return n<0?-1:n>0?1:n}function Eme(t){return Vn(t,Date.now())}function Nme(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return+sp(r)==+sp(i)}function m6(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function g6(t){return!(!m6(t)&&typeof t!="number"||isNaN(+Rt(t)))}function y6(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e),s=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return s*12+o}function Tme(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function Ame(t,e){return+Rt(t)-+Rt(e)}function _me(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setHours(23,59,59,999),n}function x6(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Mme(t,e){const n=Rt(t,e==null?void 0:e.in);return+_me(n,e)==+x6(n,e)}function Pme(t,e,n){const[r,i,s]=Tl(n==null?void 0:n.in,t,t,e),o=ex(i,s),a=Math.abs(y6(i,s));if(a<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*a);let l=ex(i,s)===-o;Mme(r)&&a===1&&ex(r,s)===1&&(l=!1);const u=o*(a-+l);return u===0?0:u}function Rme(t,e,n){const r=Ame(t,e)/1e3;return Tme(n==null?void 0:n.roundingMethod)(r)}function Ome(t,e){const[n,r]=Tl(t,e.start,e.end);return{start:n,end:r}}function Dme(t,e){const{start:n,end:r}=Ome(e==null?void 0:e.in,t);let i=+n>+r;const s=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let a=1;const l=[];for(;+o<=s;)l.push(Vn(n,o)),o.setMonth(o.getMonth()+a);return i?l.reverse():l}function jme(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Ime(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function v6(t,e){const n=Rt(t,e==null?void 0:e.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function w6(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.weekStartsOn)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=Rt(t,e==null?void 0:e.in),s=i.getDay(),o=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function Lme(t,e){return w6(t,{...e,weekStartsOn:1})}const Fme={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Bme=(t,e,n)=>{let r;const i=Fme[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function ak(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const zme={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},$me={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Vme={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wme={date:ak({formats:zme,defaultWidth:"full"}),time:ak({formats:$me,defaultWidth:"full"}),dateTime:ak({formats:Vme,defaultWidth:"full"})},Hme={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ume=(t,e,n,r)=>Hme[t];function Hf(t){return(e,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const o=t.defaultFormattingWidth||t.defaultWidth,a=n!=null&&n.width?String(n.width):o;i=t.formattingValues[a]||t.formattingValues[o]}else{const o=t.defaultWidth,a=n!=null&&n.width?String(n.width):t.defaultWidth;i=t.values[a]||t.values[o]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const qme={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Yme={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Gme={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Kme={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Xme={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Zme={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Qme=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Jme={ordinalNumber:Qme,era:Hf({values:qme,defaultWidth:"wide"}),quarter:Hf({values:Yme,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Hf({values:Gme,defaultWidth:"wide"}),day:Hf({values:Kme,defaultWidth:"wide"}),dayPeriod:Hf({values:Xme,defaultWidth:"wide",formattingValues:Zme,defaultFormattingWidth:"wide"})};function Uf(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const o=s[0],a=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],l=Array.isArray(a)?tge(a,d=>d.test(o)):ege(a,d=>d.test(o));let u;u=t.valueCallback?t.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=e.slice(o.length);return{value:u,rest:c}}}function ege(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function tge(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function nge(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let o=t.valueCallback?t.valueCallback(s[0]):s[0];o=n.valueCallback?n.valueCallback(o):o;const a=e.slice(i.length);return{value:o,rest:a}}}const rge=/^(\d+)(th|st|nd|rd)?/i,ige=/\d+/i,sge={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},oge={any:[/^b/i,/^(a|c)/i]},age={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},lge={any:[/1/i,/2/i,/3/i,/4/i]},uge={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},cge={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},dge={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},fge={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},hge={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},pge={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},mge={ordinalNumber:nge({matchPattern:rge,parsePattern:ige,valueCallback:t=>parseInt(t,10)}),era:Uf({matchPatterns:sge,defaultMatchWidth:"wide",parsePatterns:oge,defaultParseWidth:"any"}),quarter:Uf({matchPatterns:age,defaultMatchWidth:"wide",parsePatterns:lge,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Uf({matchPatterns:uge,defaultMatchWidth:"wide",parsePatterns:cge,defaultParseWidth:"any"}),day:Uf({matchPatterns:dge,defaultMatchWidth:"wide",parsePatterns:fge,defaultParseWidth:"any"}),dayPeriod:Uf({matchPatterns:hge,defaultMatchWidth:"any",parsePatterns:pge,defaultParseWidth:"any"})},Sv={code:"en-US",formatDistance:Bme,formatLong:Wme,formatRelative:Ume,localize:Jme,match:mge,options:{weekStartsOn:0,firstWeekContainsDate:1}};function gge(t,e){const n=Rt(t,e==null?void 0:e.in);return p6(n,v6(n))+1}function b6(t,e){const n=Rt(t,e==null?void 0:e.in),r=+ip(n)-+wme(n);return Math.round(r/c6)+1}function k6(t,e){var c,d,p,m;const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=Hd(),s=(e==null?void 0:e.firstWeekContainsDate)??((d=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??i.firstWeekContainsDate??((m=(p=i.locale)==null?void 0:p.options)==null?void 0:m.firstWeekContainsDate)??1,o=Vn((e==null?void 0:e.in)||t,0);o.setFullYear(r+1,0,s),o.setHours(0,0,0,0);const a=od(o,e),l=Vn((e==null?void 0:e.in)||t,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=od(l,e);return+n>=+a?r+1:+n>=+u?r:r-1}function yge(t,e){var a,l,u,c;const n=Hd(),r=(e==null?void 0:e.firstWeekContainsDate)??((l=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,i=k6(t,e),s=Vn((e==null?void 0:e.in)||t,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),od(s,e)}function S6(t,e){const n=Rt(t,e==null?void 0:e.in),r=+od(n,e)-+yge(n,e);return Math.round(r/c6)+1}function Ut(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const $a={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Ut(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Ut(n+1,2)},d(t,e){return Ut(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Ut(t.getHours()%12||12,e.length)},H(t,e){return Ut(t.getHours(),e.length)},m(t,e){return Ut(t.getMinutes(),e.length)},s(t,e){return Ut(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Ut(i,e.length)}},gc={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},_D={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return $a.y(t,e)},Y:function(t,e,n,r){const i=k6(t,r),s=i>0?i:1-i;if(e==="YY"){const o=s%100;return Ut(o,2)}return e==="Yo"?n.ordinalNumber(s,{unit:"year"}):Ut(s,e.length)},R:function(t,e){const n=h6(t);return Ut(n,e.length)},u:function(t,e){const n=t.getFullYear();return Ut(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Ut(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Ut(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return $a.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Ut(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=S6(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Ut(i,e.length)},I:function(t,e,n){const r=b6(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Ut(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):$a.d(t,e)},D:function(t,e,n){const r=gge(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Ut(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return Ut(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return Ut(s,e.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Ut(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=gc.noon:r===0?i=gc.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=gc.evening:r>=12?i=gc.afternoon:r>=4?i=gc.morning:i=gc.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return $a.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):$a.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Ut(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Ut(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):$a.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):$a.s(t,e)},S:function(t,e){return $a.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return PD(r);case"XXXX":case"XX":return Zl(r);case"XXXXX":case"XXX":default:return Zl(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return PD(r);case"xxxx":case"xx":return Zl(r);case"xxxxx":case"xxx":default:return Zl(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+MD(r,":");case"OOOO":default:return"GMT"+Zl(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+MD(r,":");case"zzzz":default:return"GMT"+Zl(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Ut(r,e.length)},T:function(t,e,n){return Ut(+t,e.length)}};function MD(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+e+Ut(s,2)}function PD(t,e){return t%60===0?(t>0?"-":"+")+Ut(Math.abs(t)/60,2):Zl(t,e)}function Zl(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Ut(Math.trunc(r/60),2),s=Ut(r%60,2);return n+i+e+s}const RD=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},C6=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},xge=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return RD(t,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;case"PPPP":default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",RD(r,e)).replace("{{time}}",C6(i,e))},vge={p:C6,P:xge},wge=/^D+$/,bge=/^Y+$/,kge=["D","DD","YY","YYYY"];function Sge(t){return wge.test(t)}function Cge(t){return bge.test(t)}function Ege(t,e,n){const r=Nge(t,e,n);if(console.warn(r),kge.includes(t))throw new RangeError(r)}function Nge(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Tge=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Age=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_ge=/^'([^]*?)'?$/,Mge=/''/g,Pge=/[a-zA-Z]/;function Vc(t,e,n){var c,d,p,m,y,v,w,b;const r=Hd(),i=(n==null?void 0:n.locale)??r.locale??Sv,s=(n==null?void 0:n.firstWeekContainsDate)??((d=(c=n==null?void 0:n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(p=r.locale)==null?void 0:p.options)==null?void 0:m.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((v=(y=n==null?void 0:n.locale)==null?void 0:y.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((b=(w=r.locale)==null?void 0:w.options)==null?void 0:b.weekStartsOn)??0,a=Rt(t,n==null?void 0:n.in);if(!g6(a))throw new RangeError("Invalid time value");let l=e.match(Age).map(k=>{const E=k[0];if(E==="p"||E==="P"){const N=vge[E];return N(k,i.formatLong)}return k}).join("").match(Tge).map(k=>{if(k==="''")return{isToken:!1,value:"'"};const E=k[0];if(E==="'")return{isToken:!1,value:Rge(k)};if(_D[E])return{isToken:!0,value:k};if(E.match(Pge))throw new RangeError("Format string contains an unescaped latin alphabet character `"+E+"`");return{isToken:!1,value:k}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:i};return l.map(k=>{if(!k.isToken)return k.value;const E=k.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Cge(E)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Sge(E))&&Ege(E,e,String(t));const N=_D[E[0]];return N(a,E,i.localize,u)}).join("")}function Rge(t){const e=t.match(_ge);return e?e[1].replace(Mge,"'"):t}function Oge(t,e,n){const r=Hd(),i=(n==null?void 0:n.locale)??r.locale??Sv,s=2520,o=ex(t,e);if(isNaN(o))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:o}),[l,u]=Tl(n==null?void 0:n.in,...o>0?[e,t]:[t,e]),c=Rme(u,l),d=($x(u)-$x(l))/1e3,p=Math.round((c-d)/60);let m;if(p<2)return n!=null&&n.includeSeconds?c<5?i.formatDistance("lessThanXSeconds",5,a):c<10?i.formatDistance("lessThanXSeconds",10,a):c<20?i.formatDistance("lessThanXSeconds",20,a):c<40?i.formatDistance("halfAMinute",0,a):c<60?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",1,a):p===0?i.formatDistance("lessThanXMinutes",1,a):i.formatDistance("xMinutes",p,a);if(p<45)return i.formatDistance("xMinutes",p,a);if(p<90)return i.formatDistance("aboutXHours",1,a);if(p<TD){const y=Math.round(p/60);return i.formatDistance("aboutXHours",y,a)}else{if(p<s)return i.formatDistance("xDays",1,a);if(p<uy){const y=Math.round(p/TD);return i.formatDistance("xDays",y,a)}else if(p<uy*2)return m=Math.round(p/uy),i.formatDistance("aboutXMonths",m,a)}if(m=Pme(u,l),m<12){const y=Math.round(p/uy);return i.formatDistance("xMonths",y,a)}else{const y=m%12,v=Math.trunc(m/12);return y<3?i.formatDistance("aboutXYears",v,a):y<9?i.formatDistance("overXYears",v,a):i.formatDistance("almostXYears",v+1,a)}}function Dge(t,e){return Oge(t,Eme(t),e)}function jge(t,e){const n=Rt(t,e==null?void 0:e.in),r=n.getFullYear(),i=n.getMonth(),s=Vn(n,0);return s.setFullYear(r,i+1,0),s.setHours(0,0,0,0),s.getDate()}function Ige(t,e){return Rt(t,e==null?void 0:e.in).getMonth()}function Lge(t,e){return Rt(t,e==null?void 0:e.in).getFullYear()}function Fge(t,e){return+Rt(t)>+Rt(e)}function Bge(t,e){return+Rt(t)<+Rt(e)}function zge(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function $ge(t,e,n){const[r,i]=Tl(n==null?void 0:n.in,t,e);return r.getFullYear()===i.getFullYear()}function Vge(t,e,n){const r=Rt(t,n==null?void 0:n.in),i=r.getFullYear(),s=r.getDate(),o=Vn(t,0);o.setFullYear(i,e,15),o.setHours(0,0,0,0);const a=jge(o);return r.setMonth(e,Math.min(s,a)),r}function Wge(t,e,n){const r=Rt(t,n==null?void 0:n.in);return isNaN(+r)?Vn(t,NaN):(r.setFullYear(e),r)}var Hge="VisuallyHidden",RA=S.forwardRef((t,e)=>g.jsx(Ze.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));RA.displayName=Hge;var Uge=RA,[Cv,QIe]=Oi("Tooltip",[El]),Ev=El(),E6="TooltipProvider",qge=700,iE="tooltip.open",[Yge,OA]=Cv(E6),N6=t=>{const{__scopeTooltip:e,delayDuration:n=qge,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,[o,a]=S.useState(!0),l=S.useRef(!1),u=S.useRef(0);return S.useEffect(()=>{const c=u.current;return()=>window.clearTimeout(c)},[]),g.jsx(Yge,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:S.useCallback(()=>{window.clearTimeout(u.current),a(!1)},[]),onClose:S.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(c=>{l.current=c},[]),disableHoverableContent:i,children:s})};N6.displayName=E6;var Nv="Tooltip",[Gge,Tv]=Cv(Nv),T6=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i=!1,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=OA(Nv,t.__scopeTooltip),u=Ev(e),[c,d]=S.useState(null),p=zn(),m=S.useRef(0),y=o??l.disableHoverableContent,v=a??l.delayDuration,w=S.useRef(!1),[b=!1,k]=po({prop:r,defaultProp:i,onChange:M=>{M?(l.onOpen(),document.dispatchEvent(new CustomEvent(iE))):l.onClose(),s==null||s(M)}}),E=S.useMemo(()=>b?w.current?"delayed-open":"instant-open":"closed",[b]),N=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w.current=!1,k(!0)},[k]),A=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),_=S.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,k(!0),m.current=0},v)},[v,k]);return S.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),g.jsx(cm,{...u,children:g.jsx(Gge,{scope:e,contentId:p,open:b,stateAttribute:E,trigger:c,onTriggerChange:d,onTriggerEnter:S.useCallback(()=>{l.isOpenDelayed?_():N()},[l.isOpenDelayed,_,N]),onTriggerLeave:S.useCallback(()=>{y?A():(window.clearTimeout(m.current),m.current=0)},[A,y]),onOpen:N,onClose:A,disableHoverableContent:y,children:n})})};T6.displayName=Nv;var sE="TooltipTrigger",A6=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Tv(sE,n),s=OA(sE,n),o=Ev(n),a=S.useRef(null),l=kt(e,a,i.onTriggerChange),u=S.useRef(!1),c=S.useRef(!1),d=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(dm,{asChild:!0,...o,children:g.jsx(Ze.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(t.onPointerMove,p=>{p.pointerType!=="touch"&&!c.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),c.current=!0)}),onPointerLeave:Pe(t.onPointerLeave,()=>{i.onTriggerLeave(),c.current=!1}),onPointerDown:Pe(t.onPointerDown,()=>{u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(t.onFocus,()=>{u.current||i.onOpen()}),onBlur:Pe(t.onBlur,i.onClose),onClick:Pe(t.onClick,i.onClose)})})});A6.displayName=sE;var Kge="TooltipPortal",[JIe,Xge]=Cv(Kge,{forceMount:void 0}),ad="TooltipContent",_6=S.forwardRef((t,e)=>{const n=Xge(ad,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Tv(ad,t.__scopeTooltip);return g.jsx(Pr,{present:r||o.open,children:o.disableHoverableContent?g.jsx(M6,{side:i,...s,ref:e}):g.jsx(Zge,{side:i,...s,ref:e})})}),Zge=S.forwardRef((t,e)=>{const n=Tv(ad,t.__scopeTooltip),r=OA(ad,t.__scopeTooltip),i=S.useRef(null),s=kt(e,i),[o,a]=S.useState(null),{trigger:l,onClose:u}=n,c=i.current,{onPointerInTransitChange:d}=r,p=S.useCallback(()=>{a(null),d(!1)},[d]),m=S.useCallback((y,v)=>{const w=y.currentTarget,b={x:y.clientX,y:y.clientY},k=tye(b,w.getBoundingClientRect()),E=nye(b,k),N=rye(v.getBoundingClientRect()),A=sye([...E,...N]);a(A),d(!0)},[d]);return S.useEffect(()=>()=>p(),[p]),S.useEffect(()=>{if(l&&c){const y=w=>m(w,c),v=w=>m(w,l);return l.addEventListener("pointerleave",y),c.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",y),c.removeEventListener("pointerleave",v)}}},[l,c,m,p]),S.useEffect(()=>{if(o){const y=v=>{const w=v.target,b={x:v.clientX,y:v.clientY},k=(l==null?void 0:l.contains(w))||(c==null?void 0:c.contains(w)),E=!iye(b,o);k?p():E&&(p(),u())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[l,c,o,u,p]),g.jsx(M6,{...t,ref:s})}),[Qge,Jge]=Cv(Nv,{isInside:!1}),M6=S.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=Tv(ad,n),u=Ev(n),{onClose:c}=l;return S.useEffect(()=>(document.addEventListener(iE,c),()=>document.removeEventListener(iE,c)),[c]),S.useEffect(()=>{if(l.trigger){const d=p=>{const m=p.target;m!=null&&m.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),g.jsx($d,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:g.jsxs(wv,{"data-state":l.stateAttribute,...u,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[g.jsx(GN,{children:r}),g.jsx(Qge,{scope:n,isInside:!0,children:g.jsx(Uge,{id:l.contentId,role:"tooltip",children:i||r})})]})})});_6.displayName=ad;var P6="TooltipArrow",eye=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Ev(n);return Jge(P6,n).isInside?null:g.jsx(bv,{...i,...r,ref:e})});eye.displayName=P6;function tye(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function nye(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function rye(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function iye(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,u=e[o].x,c=e[o].y;l>r!=c>r&&n<(u-a)*(r-l)/(c-l)+a&&(i=!i)}return i}function sye(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),oye(e)}function oye(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var aye=N6,lye=T6,uye=A6,R6=_6;const cye=aye,dye=lye,fye=uye,O6=S.forwardRef(({className:t,sideOffset:e=4,...n},r)=>g.jsx(R6,{ref:r,sideOffset:e,className:be("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));O6.displayName=R6.displayName;function hye({date:t}){const e={relativeTime:Dge(new Date(t),{addSuffix:!0}),fullDate:Vc(new Date(t),"PPpp")};return g.jsx(cye,{children:g.jsxs(dye,{children:[g.jsx(fye,{className:"text-left text-sm text-mastra-el-4",children:e.relativeTime}),g.jsx(O6,{className:"bg-mastra-bg-1 text-mastra-el-1",children:g.jsx("p",{className:"text-sm",children:e.fullDate})})]})})}const pye=Id("flex w-full text-mastra-el-6 rounded-sm border bg-transparent shadow-sm focus-visible:ring-ring transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-mastra-border-1 border-border-1 placeholder:text-muted-foreground",filled:"bg-inputFill border-border-1 placeholder:text-muted-foreground",unstyled:"border-0 bg-transparent placeholder:text-muted-foreground focus-visible:ring-transparent focus-visible:outline-none"},customSize:{default:"px-[13px] text-[calc(13_/_16_*_1rem)] h-[34px]",sm:"h-[30px] px-[13px] text-xs",lg:"h-10 px-[17px] rounded-md text-[calc(13_/_16_*_1rem)]"}},defaultVariants:{variant:"default",customSize:"default"}}),Ud=S.forwardRef(({className:t,customSize:e,testId:n,variant:r,type:i,...s},o)=>g.jsx("input",{type:i,className:be(t,pye({variant:r,customSize:e,className:t})),"data-testid":n,ref:o,...s}));Ud.displayName="Input";function OD({score:t}){return g.jsx(Ah,{variant:"secondary",children:t.toFixed(2)})}const DD=(t,e)=>{const[n,r]=S.useState([]),[i,s]=S.useState(!0),o=async a=>{s(!0);try{const l=await fetch(`/api/agents/${a??t}/evals/${e}`);if(!l.ok){const c=await l.json();r([]),console.error("Error fetching evals",c),kn.error((c==null?void 0:c.error)||"Error fetching evals");return}const u=await l.json();r(u.evals)}catch(l){r([]),console.error("Error fetching evals",l),kn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}},D6=S.createContext({handleRefresh:()=>{},isLoading:!1}),cy=be("relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible","[&::-webkit-scrollbar]:w-1","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb]:bg-mastra-border/20","[&>*]:visible"),jD=be("px-4 py-2 text-sm transition-all border-b-2 border-transparent","data-[state=active]:border-white data-[state=active]:text-white font-medium","data-[state=inactive]:text-mastra-el-4 hover:data-[state=inactive]:text-mastra-el-2","focus-visible:outline-none"),ID=be("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");function mye({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=DD(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=DD(t,"ci"),u={handleRefresh:c,isLoading:e==="live"?i:a};return g.jsx(D6.Provider,{value:u,children:g.jsxs(aA,{value:e,onValueChange:d=>n(d),className:"grid grid-rows-[auto_1fr] h-full min-h-0 pb-2",children:[g.jsx("div",{className:"bg-mastra-bg-2 border-b border-mastra-border/10",children:g.jsxs(hv,{className:"bg-transparent border-0 h-auto mx-4 pt-5",children:[g.jsx(Xs,{value:"live",className:jD,children:"Live"}),g.jsx(Xs,{value:"ci",className:jD,children:"CI"})]})}),g.jsx(Zs,{value:"live",className:ID,children:g.jsx(LD,{evals:r,isCIMode:!1})}),g.jsx(Zs,{value:"ci",className:ID,children:g.jsx(LD,{evals:o,isCIMode:!0})})]})});function c(){e==="live"?s():l()}}function LD({evals:t,isCIMode:e=!1}){const{handleRefresh:n,isLoading:r}=S.useContext(D6),[i,s]=S.useState(new Set),[o,a]=S.useState(""),[l,u]=S.useState({field:"metricName",direction:"asc"}),[c,d]=S.useState(!1);return S.useEffect(()=>{if(r){const b=setTimeout(()=>{d(!0)},200);return()=>clearTimeout(b)}else d(!1)},[r]),g.jsxs("div",{className:"min-h-0 grid grid-rows-[auto_1fr]",children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-mastra-bg-2 rounded-lg",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx(uC,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mastra-el-3"}),g.jsx(Ud,{id:"search-input",placeholder:"Search metrics, inputs, or outputs...",value:o,onChange:b=>a(b.target.value),className:"pl-10"})]}),g.jsxs(Ah,{variant:"secondary",className:"text-xs",children:[t.length," Total Evaluations"]}),g.jsx(ht,{variant:"ghost",size:"icon",onClick:n,disabled:c,className:"h-9 w-9",children:c?g.jsx(Jc,{className:"h-4 w-4 animate-spin"}):g.jsx(Jc,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"overflow-auto",children:g.jsxs(co,{className:"w-full",children:[g.jsx(fo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(ln,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"w-12"}),g.jsx(yt,{className:"min-w-[200px] max-w-[30%] text-mastra-el-3 cursor-pointer",onClick:()=>y("metricName"),children:g.jsxs("div",{className:"flex items-center",children:["Metric ",v("metricName")]})}),g.jsx(yt,{className:"flex-1 text-mastra-el-3"}),g.jsx(yt,{className:"w-48 text-mastra-el-3 cursor-pointer",onClick:()=>y("averageScore"),children:g.jsxs("div",{className:"flex items-center",children:["Average Score ",v("averageScore")]})}),g.jsx(yt,{className:"w-48 text-mastra-el-3",children:"Evaluations"})]})}),g.jsx(ho,{className:"border-b border-gray-6 relative",children:g.jsx(rT,{mode:"wait",presenceAffectsLayout:!1,children:c?Array.from({length:3}).map((b,k)=>g.jsxs(F5,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(it,{className:"w-12",children:g.jsx(He,{className:"h-8 w-8 rounded-full"})}),g.jsx(it,{className:"min-w-[200px]",children:g.jsx(He,{className:"h-4 w-3/4"})}),g.jsx(it,{className:"flex-1",children:g.jsx(He,{className:"h-4 w-full"})}),g.jsx(it,{className:"w-48",children:g.jsx(He,{className:"h-4 w-20"})}),g.jsx(it,{className:"w-48",children:g.jsx(He,{className:"h-4 w-16"})})]},k)):w(t).length===0?g.jsx(ln,{children:g.jsx(it,{colSpan:5,className:"h-32 text-center text-mastra-el-3",children:g.jsxs("div",{className:"flex flex-col items-center gap-2",children:[g.jsx(uC,{className:"h-8 w-8"}),g.jsx("p",{children:"No evaluations found"}),o&&g.jsx("p",{className:"text-sm",children:"Try adjusting your search terms"})]})})}):w(t).map(b=>g.jsxs(ne.Fragment,{children:[g.jsxs(ln,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>m(b.metricName),children:[g.jsx(it,{className:"w-12",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:g.jsx("div",{className:be("transform transition-transform duration-200",i.has(b.metricName)?"rotate-90":""),children:g.jsx(rh,{className:"h-4 w-4 text-mastra-el-5"})})})}),g.jsx(it,{className:"min-w-[200px] max-w-[30%] font-medium text-mastra-el-5",children:b.metricName}),g.jsx(it,{className:"flex-1 text-mastra-el-5"}),g.jsx(it,{className:"w-48 text-mastra-el-5",children:g.jsx(OD,{score:b.averageScore})}),g.jsx(it,{className:"w-48 text-mastra-el-5",children:g.jsx(Ah,{variant:"secondary",children:b.evals.length})})]}),i.has(b.metricName)&&g.jsx(ln,{children:g.jsx(it,{colSpan:5+(p(b.evals)?1:0)+(e?1:0),className:"p-0",children:g.jsx("div",{className:"bg-mastra-bg-3 rounded-lg m-2",children:g.jsx("div",{className:"w-full",children:g.jsxs(co,{className:"w-full",children:[g.jsx(fo,{children:g.jsxs(ln,{className:"text-[0.7rem] text-mastra-el-3 hover:bg-transparent",children:[g.jsx(yt,{className:"pl-12 w-[120px]",children:"Timestamp"}),g.jsx(yt,{className:"w-[300px]",children:"Instructions"}),g.jsx(yt,{className:"w-[300px]",children:"Input"}),g.jsx(yt,{className:"w-[300px]",children:"Output"}),g.jsx(yt,{className:"w-[80px]",children:"Score"}),p(b.evals)&&g.jsx(yt,{className:"w-[250px]",children:"Reason"}),e&&g.jsx(yt,{className:"w-[120px]",children:"Test Name"})]})}),g.jsx(ho,{children:b.evals.map((k,E)=>{var N,A;return g.jsxs(ln,{className:"text-[0.8125rem] hover:bg-mastra-bg-2/50",children:[g.jsx(it,{className:"pl-12 text-mastra-el-4 align-top py-4",children:g.jsx(hye,{date:k.createdAt})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.instructions,label:"instructions",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.input,label:"input",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:k.output,label:"output",multiline:!0})})}),g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx(OD,{score:k.result.score})}),p(b.evals)&&g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:be("max-w-[300px] max-h-[200px]",cy),children:g.jsx(ly,{content:((N=k.result.info)==null?void 0:N.reason)||"",label:"reason",multiline:!0})})}),e&&g.jsx(it,{className:"text-mastra-el-4 align-top py-4",children:((A=k.testInfo)==null?void 0:A.testName)&&g.jsx(Ah,{variant:"secondary",className:"text-xs",children:k.testInfo.testName})})]},`${b.metricName}-${E}`)})})]})})})})})]},b.metricName))})})]})})]});function p(b){return b.some(k=>{var E;return(E=k.result.info)==null?void 0:E.reason})}function m(b){const k=new Set(i);k.has(b)?k.delete(b):k.add(b),s(k)}function y(b){u(k=>({field:b,direction:k.field===b&&k.direction==="asc"?"desc":"asc"}))}function v(b){return l.field!==b?null:l.direction==="asc"?g.jsx(_X,{className:"h-4 w-4 ml-1"}):g.jsx(TX,{className:"h-4 w-4 ml-1"})}function w(b){let k=b.reduce((E,N)=>{const A=E.find(_=>_.metricName===N.metricName);return A?(A.evals.push(N),A.averageScore=A.evals.reduce((_,M)=>_+M.result.score,0)/A.evals.length):E.push({metricName:N.metricName,averageScore:N.result.score,evals:[N]}),E},[]);return o&&(k=k.filter(E=>E.metricName.toLowerCase().includes(o.toLowerCase())||E.evals.some(N=>{var A,_,M;return((A=N.input)==null?void 0:A.toLowerCase().includes(o.toLowerCase()))||((_=N.output)==null?void 0:_.toLowerCase().includes(o.toLowerCase()))||((M=N.instructions)==null?void 0:M.toLowerCase().includes(o.toLowerCase()))}))),k.sort((E,N)=>{const A=l.direction==="asc"?1:-1;switch(l.field){case"metricName":return A*E.metricName.localeCompare(N.metricName);case"averageScore":return A*(E.averageScore-N.averageScore);default:return 0}}),k}}function gye(){const{agentId:t}=da();return g.jsx("main",{className:"min-h-0",children:g.jsx(mye,{agentId:t})})}function yye({fetchFn:t,interval:e=3e3,enabled:n=!1,onSuccess:r,onError:i,shouldContinue:s=()=>!0}){const[o,a]=S.useState(n),[l,u]=S.useState(null),[c,d]=S.useState(null),[p,m]=S.useState(!1),[y,v]=S.useState(!1),w=S.useRef(null),b=S.useRef(!0),k=S.useCallback(()=>{console.log("cleanup"),w.current&&(clearTimeout(w.current),w.current=null)},[]),E=S.useCallback(()=>{console.log("stopPolling"),a(!1),k()},[k]),N=S.useCallback(()=>{console.log("startPolling"),a(!0),u(null)},[]),A=S.useCallback(async(_=!1)=>{if(b.current){m(!0),v(_);try{const M=await t();d(M),u(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(A,e):E()}catch(M){if(!b.current)return;u(M),i==null||i(M),E()}finally{b.current&&(v(!1),m(!1))}}},[t,e,r,i,s,E]);return S.useEffect(()=>(b.current=!0,n&&o&&A(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,A,k]),{isPolling:o,isLoading:p,error:l,data:c,startPolling:N,stopPolling:E,firstCallLoading:y}}function DA(t,e=2){return(t/1e3).toFixed(e)}function j6(t){const e=new Date(t/1e3);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function xye(t){const e=new Date(t/1e6);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function vye(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function FD(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const wye=t=>{const e=new Set,n=t.reduce((i,s)=>{const o={...s,duration:s.endTime-s.startTime};return e.add(s.id),{...i,[s.traceId]:[...i[s.traceId]||[],o]}},{});return Object.entries(n).map(([i,s])=>{var u;const o=s.find(c=>!c.parentSpanId||!e.has(c.parentSpanId)),a=s.map(c=>({...c,parentSpanId:(o==null?void 0:o.id)===c.id?null:c==null?void 0:c.parentSpanId,relativePercentage:o?c.duration/o.duration:0})),l=(u=s.find(c=>c.status.code!==0))==null?void 0:u.status;return{traceId:i,serviceName:(o==null?void 0:o.name)||i,duration:s.reduce((c,d)=>c+d.duration,0),status:l||(o==null?void 0:o.status)||s[0].status,started:s[0].startTime,trace:a}})},I6=t=>{const[e,n]=S.useState(null),r=S.useCallback(async()=>{try{const u=await fetch(`/api/telemetry?attribute=componentName:${t}`);if(!u.ok){const p=await u.json();throw new Error((p==null?void 0:p.error)||"Error fetching traces")}const c=await u.json();return wye((c==null?void 0:c.traces)||[])}catch(u){throw u}},[t]),i=S.useCallback(u=>{u.length>0&&n(()=>u)},[]),s=S.useCallback(u=>{kn.error(u.message)},[]),o=S.useCallback(u=>u.length>0,[]),{firstCallLoading:a,error:l}=yye({fetchFn:r,interval:3e3,onSuccess:i,onError:s,shouldContinue:o,enabled:!0});return{traces:e,firstCallLoading:a,error:l}},Al=S.createContext({});function L6({children:t}){const[e,n]=S.useState(!1),[r,i]=S.useState(null),[s,o]=S.useState([]),[a,l]=S.useState(0),[u,c]=S.useState(null),[d,p]=S.useState(!1),m=()=>{if(a<s.length-1){const w=a+1;l(w);const b=s[w].trace;i(b);const k=b.find(E=>E.parentSpanId===null)||b[0];c(k)}},y=()=>{if(a>0){const w=a-1;l(w);const b=s[w].trace;i(b);const k=b.find(E=>E.parentSpanId===null)||b[0];c(k)}},v=()=>{n(!1),i(null),c(null),p(!1)};return g.jsx(Al.Provider,{value:{isOpen:e,setIsOpen:n,trace:r,setTrace:i,traces:s,setTraces:o,currentTraceIndex:a,setCurrentTraceIndex:l,nextTrace:m,prevTrace:y,span:u,setSpan:c,openDetail:d,setOpenDetail:p,clearData:v},children:t})}function F6({traces:t}){const{setTraces:e,trace:n}=S.useContext(Al),r=(n==null?void 0:n.find(i=>i.parentSpanId===void 0))||(n==null?void 0:n[0]);return S.useEffect(()=>{e(t)},[t]),g.jsx("div",{className:"h-full w-[calc(100%_-_400px)]",children:g.jsx(Mn,{className:"rounded-lg h-full",children:g.jsxs(co,{children:[g.jsx(fo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(ln,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(yt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Vh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(yt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(yt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(ho,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(ln,{className:be("border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",{"bg-muted/50":(r==null?void 0:r.traceId)===i.traceId}),children:[g.jsx(it,{children:g.jsx(bye,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(it,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(it,{className:"text-mastra-el-5 text-sm",children:j6(i.started)}),g.jsx(it,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(OX,{className:"h-3 w-3"}),DA(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(ln,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(it,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function bye({trace:t,name:e,traceIndex:n,status:r}){const{setTrace:i,isOpen:s,setIsOpen:o,trace:a,setSpan:l,setOpenDetail:u,setCurrentTraceIndex:c}=S.useContext(Al);return g.jsxs(ht,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var p;i(t);const d=t.find(m=>m.parentSpanId===null)||t[0];l(d),c(n),!(s&&((p=a==null?void 0:a[0])==null?void 0:p.id)!==t[0].id)&&(o(m=>!m),u(m=>!m))},children:[r.code===0?g.jsx("svg",{className:"h-3 w-3",xmlns:"http://www.w3.org/2000/svg",width:"13",height:"12",viewBox:"0 0 13 12",fill:"none",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.37695 12C9.69067 12 12.377 9.31371 12.377 6C12.377 2.68629 9.69067 0 6.37695 0C3.06325 0 0.376953 2.68629 0.376953 6C0.376953 9.31371 3.06325 12 6.37695 12ZM9.62004 4.65344C9.87907 4.36036 9.8651 3.90005 9.58884 3.6253C9.3125 3.35055 8.87861 3.3654 8.61958 3.65847L5.6477 7.02105L4.08967 5.55197C3.80661 5.28508 3.37319 5.31213 3.12159 5.61237C2.87 5.91262 2.89549 6.37239 3.17854 6.63927L4.90294 8.26517C5.36588 8.70171 6.07235 8.6676 6.49598 8.18829L9.62004 4.65344Z",fill:"#6CD063"})}):g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FF4500",width:"13",height:"12",children:g.jsx("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z",clipRule:"evenodd"})}),g.jsx("span",{className:"truncate max-w-[150px]",children:e})]})}function B6({node:t,depth:e=0}){var c,d;const[n,r]=S.useState(!0),i=t.children&&t.children.length>0,{setOpenDetail:s,setSpan:o,openDetail:a,span:l}=S.useContext(Al),u=Math.min(t.relativePercentage?t==null?void 0:t.relativePercentage:0,100);return g.jsxs("div",{children:[g.jsxs(ht,{variant:"ghost",className:be("relative flex w-full items-center justify-start gap-2 py-3 pr-1 text-sm",{"text-accent-foreground bg-accent":(l==null?void 0:l.id)===t.id}),onClick:p=>{p.preventDefault(),p.stopPropagation(),o(t),!(a&&t.id!==(l==null?void 0:l.id))&&s(m=>!m)},style:{paddingLeft:`${e>0?e*35+28:24}px`},children:[i?g.jsx("div",{onClick:()=>r(!n),className:"relative grid h-auto flex-shrink-0 place-items-center rounded-sm bg-[#1a1a1a] p-2",children:g.jsx("svg",{className:be("!h-2 !w-2 transition-transform",n?"":"-rotate-90"),xmlns:"http://www.w3.org/2000/svg",width:"7",height:"6",viewBox:"0 0 7 6",fill:"none",children:g.jsx("path",{d:"M3.9338 5.5C3.74135 5.83333 3.26022 5.83333 3.06777 5.5L0.469694 0.999999C0.277244 0.666666 0.517814 0.25 0.902714 0.25L6.09886 0.25C6.48376 0.25 6.72433 0.666666 6.53188 1L3.9338 5.5Z",fill:"#939393"})})}):null,g.jsxs("div",{className:"flex w-full gap-4 pr-4",children:[g.jsx("p",{className:be("max-w-[400px] truncate px-1 text-sm",{"text-white":((c=t==null?void 0:t.status)==null?void 0:c.code)===0,"text-[#FF4500]":((d=t==null?void 0:t.status)==null?void 0:d.code)!==0}),children:t.name}),t.duration>0&&g.jsxs("div",{className:"relative w-full max-w-[200px]",children:[g.jsx("div",{className:"absolute top-[11px] h-px w-full bg-[hsl(220,14%,19%)]"}),g.jsx("div",{style:{width:`${u}%`,left:0},className:be("absolute top-[9px] z-0 h-[5px] rounded-[5px] bg-white transition-all",t.name.includes("agent")&&"left-1/2 bg-green-500",t.name.includes("llm")&&"bg-[#5699A8]",t.name.includes("ai")&&"left-2/4 w-5 bg-[#F09A56]")}),g.jsxs("span",{className:"absolute left-0 top-3 text-[0.63rem] text-mastra-el-3",children:[DA(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(p=>g.jsx(B6,{node:p,depth:e+1},p.id))})]})}function kye({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(B6,{node:e},e.id))})}function z6(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:z6(t,n.id)}))}function Sye({trace:t}){const e=z6(t.concat([]).reverse());return g.jsx("div",{children:g.jsx(kye,{tree:e})})}function $6(){const{trace:t,currentTraceIndex:e,prevTrace:n,nextTrace:r,traces:i,clearData:s}=S.useContext(Al);return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center justify-between px-6 pt-[1.56rem]",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("h3",{className:"text-[1.125rem]",children:["Trace Span",t!=null&&t.length&&t.length>1?"s":""]}),g.jsxs("span",{className:"text-xs text-mastra-el-3",children:[t!=null&&t.length?t.length:0," span",t!=null&&t.length&&t.length>1?"s":""]})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ht,{onClick:()=>{n()},disabled:e===0,variant:"secondary",size:"icon",className:"!h-3 !w-3 rotate-180 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Wh,{})})," ",g.jsx(ht,{onClick:()=>{r()},disabled:e===i.length-1,variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Wh,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(ht,{onClick:()=>{s()},variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(kl,{})})]})]}),g.jsxs("div",{className:"p-6 px-1",children:[" ",t&&g.jsx(Sye,{trace:t})]})]})}const V6=1024;let Cye=0,lk=class{constructor(e,n){this.from=e,this.to=n}};class Et{constructor(e={}){this.id=Cye++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=li.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Et.closedBy=new Et({deserialize:t=>t.split(" ")});Et.openedBy=new Et({deserialize:t=>t.split(" ")});Et.group=new Et({deserialize:t=>t.split(" ")});Et.isolate=new Et({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Et.contextHash=new Et({perNode:!0});Et.lookAhead=new Et({perNode:!0});Et.mounted=new Et({perNode:!0});class Vx{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[Et.mounted.id]}}const Eye=Object.create(null);class li{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):Eye,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new li(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Et.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Et.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}li.none=new li("",Object.create(null),0,8);class jA{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new li(r.name,i,r.id,r.flags):r)}return new jA(n)}}const dy=new WeakMap,BD=new WeakMap;var sr;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(sr||(sr={}));class Bn{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Vx.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new aE(this.topNode,e)}cursorAt(e,n=0,r=0){let i=dy.get(this)||this.topNode,s=new aE(i);return s.moveTo(e,n),dy.set(this,s._tree),s}get topNode(){return new Qi(this,0,0,null)}resolve(e,n=0){let r=op(dy.get(this)||this.topNode,e,n,!1);return dy.set(this,r),r}resolveInner(e,n=0){let r=op(BD.get(this)||this.topNode,e,n,!0);return BD.set(this,r),r}resolveStack(e,n=0){return Aye(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&sr.IncludeAnonymous)>0;for(let l=this.cursor(o|sr.IncludeAnonymous);;){let u=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:FA(li.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Bn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Bn(li.none,n,r,i)))}static build(e){return _ye(e)}}Bn.empty=new Bn(li.none,[],[],0);class IA{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new IA(this.buffer,this.index)}}class fl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return li.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(W6(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let u=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,u)}return new fl(s,o,this.set)}}function W6(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function op(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof Qi&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:sr.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof Qi&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class H6{cursor(e=0){return new aE(this,e)}getChild(e,n=null,r=null){let i=zD(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return zD(this,e,n,r)}resolve(e,n=0){return op(this,e,n,!1)}resolveInner(e,n=0){return op(this,e,n,!0)}matchContext(e){return oE(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Qi extends H6{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,u=n>0?a.length:-1;e!=u;e+=n){let c=a[e],d=l[e]+o.from;if(W6(i,r,d,d+c.length)){if(c instanceof fl){if(s&sr.ExcludeBuffers)continue;let p=c.findChild(0,c.buffer.length,n,r-d,i);if(p>-1)return new el(new Nye(o,c,e,d),null,p)}else if(s&sr.IncludeAnonymous||!c.type.isAnonymous||LA(c)){let p;if(!(s&sr.IgnoreMounts)&&(p=Vx.get(c))&&!p.overlay)return new Qi(p.tree,d,e,o);let m=new Qi(c,d,e,o);return s&sr.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?c.children.length-1:0,n,r,i)}}}if(s&sr.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&sr.IgnoreOverlays)&&(i=Vx.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new Qi(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function zD(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function oE(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Nye{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class el extends H6{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new el(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&sr.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new el(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new el(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new el(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Bn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function U6(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof Qi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new Tye(i,n)}class Tye{constructor(e,n){this.heads=e,this.node=n}get next(){return U6(this.heads)}}function Aye(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Qi?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=Vx.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Qi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(op(a,e,n,!1))}}return i?U6(i):r}class aE{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Qi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof Qi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&sr.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&sr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&sr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&sr.IncludeAnonymous||a instanceof fl||!a.type.isAnonymous||LA(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new el(this.buffer,n,this.stack[i]);return this.bufferNode=new el(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return oE(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return oE(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function LA(t){return t.children.some(e=>e instanceof fl||!e.type.isAnonymous||LA(e))}function _ye(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=V6,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new IA(n,n.length):n,l=r.types,u=0,c=0;function d(A,_,M,R,D,O){let{id:B,start:F,end:V,size:I}=a,Y=c,W=u;for(;I<0;)if(a.next(),I==-1){let q=s[B];M.push(q),R.push(F-A);return}else if(I==-3){u=B;return}else if(I==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let G=l[B],H,$,L=F-A;if(V-F<=i&&($=w(a.pos-_,D))){let q=new Uint16Array($.size-$.skip),U=a.pos-$.size,j=q.length;for(;a.pos>U;)j=b($.start,q,j);H=new fl(q,V-$.start,r),L=$.start-A}else{let q=a.pos-I;a.next();let U=[],j=[],K=B>=o?B:-1,X=0,J=V;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,j,F,X,a.end,J,K,Y,W),X=U.length,J=a.end),a.next()):O>2500?p(F,q,U,j):d(F,q,U,j,K,O+1);if(K>=0&&X>0&&X<U.length&&y(U,j,F,X,F,J,K,Y,W),U.reverse(),j.reverse(),K>-1&&X>0){let ee=m(G,W);H=FA(G,U,j,0,U.length,0,V-F,ee,ee)}else H=v(G,U,j,V-F,Y-V,W)}M.push(H),R.push(L)}function p(A,_,M,R){let D=[],O=0,B=-1;for(;a.pos>_;){let{id:F,start:V,end:I,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&V<B)break;B<0&&(B=I-i),D.push(F,V,I),O++,a.next()}}if(O){let F=new Uint16Array(O*4),V=D[D.length-2];for(let I=D.length-3,Y=0;I>=0;I-=3)F[Y++]=D[I],F[Y++]=D[I+1]-V,F[Y++]=D[I+2]-V,F[Y++]=Y;M.push(new fl(F,D[2]-V,r)),R.push(V-A)}}function m(A,_){return(M,R,D)=>{let O=0,B=M.length-1,F,V;if(B>=0&&(F=M[B])instanceof Bn){if(!B&&F.type==A&&F.length==D)return F;(V=F.prop(Et.lookAhead))&&(O=R[B]+F.length+V)}return v(A,M,R,D,O,_)}}function y(A,_,M,R,D,O,B,F,V){let I=[],Y=[];for(;A.length>R;)I.push(A.pop()),Y.push(_.pop()+M-D);A.push(v(r.types[B],I,Y,O-D,F-O,V)),_.push(D-M)}function v(A,_,M,R,D,O,B){if(O){let F=[Et.contextHash,O];B=B?[F].concat(B):[F]}if(D>25){let F=[Et.lookAhead,D];B=B?[F].concat(B):[F]}return new Bn(A,_,M,R,B)}function w(A,_){let M=a.fork(),R=0,D=0,O=0,B=M.end-i,F={size:0,start:0,skip:0};e:for(let V=M.pos-A;M.pos>V;){let I=M.size;if(M.id==_&&I>=0){F.size=R,F.start=D,F.skip=O,O+=4,R+=4,M.next();continue}let Y=M.pos-I;if(I<0||Y<V||M.start<B)break;let W=M.id>=o?4:0,G=M.start;for(M.next();M.pos>Y;){if(M.size<0)if(M.size==-3)W+=4;else break e;else M.id>=o&&(W+=4);M.next()}D=G,R+=I,O+=W}return(_<0||R==A)&&(F.size=R,F.start=D,F.skip=O),F.size>4?F:void 0}function b(A,_,M){let{id:R,start:D,end:O,size:B}=a;if(a.next(),B>=0&&R<o){let F=M;if(B>4){let V=a.pos-(B-4);for(;a.pos>V;)M=b(A,_,M)}_[--M]=F,_[--M]=O-A,_[--M]=D-A,_[--M]=R}else B==-3?u=R:B==-4&&(c=R);return M}let k=[],E=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,E,-1,0);let N=(e=t.length)!==null&&e!==void 0?e:k.length?E[0]+k[0].length:0;return new Bn(l[t.topID],k.reverse(),E.reverse(),N)}const $D=new WeakMap;function tx(t,e){if(!t.isAnonymous||e instanceof fl||e.type!=t)return 1;let n=$D.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Bn)){n=1;break}n+=tx(t,r)}$D.set(e,n)}return n}function FA(t,e,n,r,i,s,o,a,l){let u=0;for(let y=r;y<i;y++)u+=tx(t,e[y]);let c=Math.ceil(u*1.5/8),d=[],p=[];function m(y,v,w,b,k){for(let E=w;E<b;){let N=E,A=v[E],_=tx(t,y[E]);for(E++;E<b;E++){let M=tx(t,y[E]);if(_+M>=c)break;_+=M}if(E==N+1){if(_>c){let M=y[N];m(M.children,M.positions,0,M.children.length,v[N]+k);continue}d.push(y[N])}else{let M=v[E-1]+y[E-1].length-A;d.push(FA(t,y,v,N,E,A,M,null,l))}p.push(A+k-s)}}return m(e,n,r,i,0),(a||l)(d,p,o)}class uu{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new uu(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,u=0;;a++){let c=a<n.length?n[a]:null,d=c?c.fromA:1e9;if(d-l>=r)for(;o&&o.from<d;){let p=o;if(l>=p.from||d<=p.to||u){let m=Math.max(p.from,l)-u,y=Math.min(p.to,d)-u;p=m>=y?null:new uu(m,y,p.tree,p.offset+u,a>0,!!c)}if(p&&i.push(p),o.to>d)break;o=s<e.length?e[s++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}}class q6{startParse(e,n,r){return typeof e=="string"&&(e=new Mye(e)),r=r?r.length?r.map(i=>new lk(i.from,i.to)):[new lk(0,0)]:[new lk(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class Mye{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Et({perNode:!0});var VD={};class Wx{constructor(e,n,r,i,s,o,a,l,u,c=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=u,this.lookAhead=c,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Wx(e,[],n,r,r,0,[],0,i?new WD(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let d=l?this.stack[l-1]:0,p=this.bufferBase+this.buffer.length-d;if(i<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,u,m,p+4,!0)}if(e&262144)this.state=this.stack[l];else{let m=this.stack[l-3];this.state=s.getGoto(m,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(n==r)return;if(o.buffer[a-2]>=n){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||n<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Wx(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new Pye(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,l)=>l&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let r=n>>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,u=this.stack.length-a*3;if(u>=0&&e.getGoto(this.stack[u],l,!1)>=0)return a<<19|65536|l}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new WD(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class WD{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Pye{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Hx{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Hx(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hx(this.stack,this.pos,this.index)}}function fy(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r<t.length;){let s=0;for(;;){let o=t.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class nx{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const HD=new nx;class Rye{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=HD,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;n<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=HD,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Wc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;Oye(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Wc.prototype.contextual=Wc.prototype.fallback=Wc.prototype.extend=!1;Wc.prototype.fallback=Wc.prototype.extend=!1;function Oye(t,e,n,r,i,s){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;a&t[o];){let u=t[o+1];for(let m=o+3;m<u;m+=2)if((t[m+1]&a)>0){let y=t[m];if(l.allows(y)&&(e.token.value==-1||e.token.value==y||Dye(y,e.token.value,i,s))){e.acceptToken(y);break}}let c=e.next,d=0,p=t[o+2];if(e.next<0&&p>d&&t[u+p*3-3]==65535){o=t[u+p*3-1];continue e}for(;d<p;){let m=d+p>>1,y=u+m+(m<<1),v=t[y],w=t[y+1]||65536;if(c<v)p=m;else if(c>=w)d=m+1;else{o=t[y+2],e.advance();continue e}}break}}function UD(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function Dye(t,e,n,r){let i=UD(n,r,e);return i<0||UD(n,r,t)<i}const gi=typeof process<"u"&&VD&&/\bparse\b/.test(VD.LOG);let uk=null;function qD(t,e,n){let r=t.cursor(sr.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class jye{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?qD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?qD(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[n]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof Bn){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(Et.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class Iye{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new nx)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let u=0;u<s.length;u++){if(!(1<<u&o))continue;let c=s[u],d=this.tokens[u];if(!(r&&!c.fallback)&&((c.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,c,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let p=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!c.extend&&(r=d,n>p))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new nx,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new nx,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=n,this.actions[i++]=r,i}addActions(e,n,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let u=o.stateSlot(s,l?2:1);;u+=3){if(a[u]==65535)if(a[u+1]==1)u=Vo(a,u+2);else{i==0&&a[u+1]==2&&(i=this.putAction(Vo(a,u+2),n,r,i));break}a[u]==n&&(i=this.putAction(Vo(a,u+1),n,r,i))}return i}}class Lye{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Rye(n,i),this.tokens=new Iye(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Wx.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new jye(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!r.length){let o=i&&Bye(i);if(o)return gi&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw gi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return gi&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,l)=>l.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let l=o+1;l<r.length;l++){let u=r[l];if(a.sameState(u)||a.buffer.length>500&&u.buffer.length>500)if((a.score-u.score||a.buffer.length-u.buffer.length)>0)r.splice(l--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let i=e.pos,{parser:s}=this,o=gi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let p=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(p>-1&&d.length&&(!u||(d.prop(Et.contextHash)||0)==c))return e.useNode(d,p),gi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof Bn)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Bn&&d.positions[0]==0)d=m;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),gi&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let u=0;u<l.length;){let c=l[u++],d=l[u++],p=l[u++],m=u==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(c,d,v?v.start:y.pos,p),gi&&console.log(o+this.stackID(y)+` (via ${c&65536?`reduce of ${s.getName(c&65535)}`:"shift"} for ${s.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?n.push(y):r.push(y)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return YD(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=n[o<<1],u=n[(o<<1)+1],c=gi?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),gi&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),p=c;for(let m=0;d.forceReduce()&&m<10&&(gi&&console.log(p+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));m++)gi&&(p=this.stackID(d)+" -> ");for(let m of a.recoverByInsert(l))gi&&console.log(c+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(u==a.pos&&(u++,l=0),a.recoverByDelete(l,u),gi&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),YD(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),Bn.build({buffer:Hx.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(uk||(uk=new WeakMap)).get(e);return n||uk.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function YD(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class Fye{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Ux extends q6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,l,u){i[a].push([l,l.deserialize(String(u))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Et[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)s(c,l,a[u++]);else{let d=a[u+-c];for(let p=-c;p>0;p--)s(a[u++],l,d);u++}}}this.nodeSet=new jA(n.map((a,l)=>li.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=V6;let o=fy(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(GD),this.states=fy(e.states,Uint32Array),this.data=fy(e.stateData),this.goto=fy(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Wc(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new Lye(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&r)return l;for(let u=s+(o>>1);s<u;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Vo(r,s+2)];else{if(r[s+1]==2)return Vo(r,s+2);break}if(o==n||o==0)return Vo(r,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vo(this.data,s+2);else break;i=n(Vo(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Vo(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Ux.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=GD(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new Fye(e,r,i)}static deserialize(e){return new Ux(e)}}function Vo(t,e){return t[e]|t[e+1]<<16}function Bye(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function GD(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let zye=0;class Yi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=zye++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Yi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Yi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new qx(e);return r=>r.modified.indexOf(n)>-1?r:qx.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let $ye=0;class qx{constructor(e){this.name=e,this.instances=[],this.id=$ye++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Vye(n,a.modified));if(r)return r;let i=[],s=new Yi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=Wye(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(qx.get(a,l));return s}}function Vye(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function Wye(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function Y6(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){o=1;break}let p=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!p)throw new RangeError("Invalid path: "+i);if(s.push(p[0]=="*"?"":p[0][0]=='"'?JSON.parse(p[0]):p[0]),d+=p[0].length,d==i.length)break;let m=i[d++];if(d==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new Yx(r,o,l>0?s.slice(0,l):null);e[u]=c.sort(e[u])}}return G6.add(e)}const G6=new Et;class Yx{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Yx.empty=new Yx([],2,null);function K6(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let u=n[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function Hye(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function Uye(t,e,n,r=0,i=t.length){let s=new qye(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class qye{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(o)));let u=i,c=Yye(e)||Yx.empty,d=Hye(s,c.tags);if(d&&(u&&(u+=" "),u+=d,c.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,a),u),c.opaque)return;let p=e.tree&&e.tree.prop(Et.mounted);if(p&&p.overlay){let m=e.node.enter(p.overlay[0].from+a,1),y=this.highlighters.filter(w=>!w.scope||w.scope(p.tree.type)),v=e.firstChild();for(let w=0,b=a;;w++){let k=w<p.overlay.length?p.overlay[w]:null,E=k?k.from+a:l,N=Math.max(n,b),A=Math.min(r,E);if(N<A&&v)for(;e.from<A&&(this.highlightRange(e,N,A,i,s),this.startSpan(Math.min(A,e.to),u),!(e.to>=E||!e.nextSibling())););if(!k||E>r)break;b=k.to+a,b>n&&(this.highlightRange(m.cursor(),Math.max(n,k.from+a),Math.min(r,b),"",y),this.startSpan(Math.min(r,b),u))}v&&e.parent()}else if(e.firstChild()){p&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function Yye(t){let e=t.type.prop(G6);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Re=Yi.define,hy=Re(),Ya=Re(),KD=Re(Ya),XD=Re(Ya),Ga=Re(),py=Re(Ga),ck=Re(Ga),Vs=Re(),Gl=Re(Vs),Fs=Re(),Bs=Re(),lE=Re(),qf=Re(lE),my=Re(),re={comment:hy,lineComment:Re(hy),blockComment:Re(hy),docComment:Re(hy),name:Ya,variableName:Re(Ya),typeName:KD,tagName:Re(KD),propertyName:XD,attributeName:Re(XD),className:Re(Ya),labelName:Re(Ya),namespace:Re(Ya),macroName:Re(Ya),literal:Ga,string:py,docString:Re(py),character:Re(py),attributeValue:Re(py),number:ck,integer:Re(ck),float:Re(ck),bool:Re(Ga),regexp:Re(Ga),escape:Re(Ga),color:Re(Ga),url:Re(Ga),keyword:Fs,self:Re(Fs),null:Re(Fs),atom:Re(Fs),unit:Re(Fs),modifier:Re(Fs),operatorKeyword:Re(Fs),controlKeyword:Re(Fs),definitionKeyword:Re(Fs),moduleKeyword:Re(Fs),operator:Bs,derefOperator:Re(Bs),arithmeticOperator:Re(Bs),logicOperator:Re(Bs),bitwiseOperator:Re(Bs),compareOperator:Re(Bs),updateOperator:Re(Bs),definitionOperator:Re(Bs),typeOperator:Re(Bs),controlOperator:Re(Bs),punctuation:lE,separator:Re(lE),bracket:qf,angleBracket:Re(qf),squareBracket:Re(qf),paren:Re(qf),brace:Re(qf),content:Vs,heading:Gl,heading1:Re(Gl),heading2:Re(Gl),heading3:Re(Gl),heading4:Re(Gl),heading5:Re(Gl),heading6:Re(Gl),contentSeparator:Re(Vs),list:Re(Vs),quote:Re(Vs),emphasis:Re(Vs),strong:Re(Vs),link:Re(Vs),monospace:Re(Vs),strikethrough:Re(Vs),inserted:Re(),deleted:Re(),changed:Re(),invalid:Re(),meta:my,documentMeta:Re(my),annotation:Re(my),processingInstruction:Re(my),definition:Yi.defineModifier("definition"),constant:Yi.defineModifier("constant"),function:Yi.defineModifier("function"),standard:Yi.defineModifier("standard"),local:Yi.defineModifier("local"),special:Yi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof Yi&&(e.name=t)}K6([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]);const Gye=Y6({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),Kye=Ux.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Gye],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let uE=[],X6=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?X6:uE).push(n=n+t[e])})();function Xye(t){if(t<768)return!1;for(let e=0,n=uE.length;;){let r=e+n>>1;if(t<uE[r])n=r;else if(t>=X6[r])e=r+1;else return!0;if(e==n)return!1}}function ZD(t){return t>=127462&&t<=127487}const QD=8205;function Zye(t,e,n=!0,r=!0){return(n?Z6:Qye)(t,e,r)}function Z6(t,e,n){if(e==t.length)return e;e&&Q6(t.charCodeAt(e))&&J6(t.charCodeAt(e-1))&&e--;let r=dk(t,e);for(e+=JD(r);e<t.length;){let i=dk(t,e);if(r==QD||i==QD||n&&Xye(i))e+=JD(i),r=i;else if(ZD(i)){let s=0,o=e-2;for(;o>=0&&ZD(dk(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Qye(t,e,n){for(;e>0;){let r=Z6(t,e-2,n);if(r<e)return r;e--}return 0}function dk(t,e){let n=t.charCodeAt(e);if(!J6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return Q6(r)?(n-55296<<10)+(r-56320)+65536:n}function Q6(t){return t>=56320&&t<57344}function J6(t){return t>=55296&&t<56320}function JD(t){return t<65536?1:2}let $t=class e8{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=ld(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),qs.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=ld(this,e,n);let r=[];return this.decompose(e,n,r,0),qs.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new _h(this),s=new _h(e);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new _h(this,e)}iterRange(e,n=this.length){return new t8(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new n8(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?e8.empty:e.length<=32?new An(e):qs.from(An.split(e,[]))}};class An extends $t{constructor(e,n=Jye(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=e)return new exe(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new An(ej(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=rx(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new An(a,o.length+s.length));else{let l=a.length>>1;r.push(new An(a.slice(0,l)),new An(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof An))return super.replace(e,n,r);[e,n]=ld(this,e,n);let i=rx(this.text,rx(r.text,ej(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new An(i,s):qs.from(An.split(i,[]),s)}sliceString(e,n=this.length,r=`
342
342
  `){[e,n]=ld(this,e,n);let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(i+=r),e<l&&n>s&&(i+=a.slice(Math.max(0,e-s),n-s)),s=l+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new An(r,i)),r=[],i=-1);return i>-1&&n.push(new An(r,i)),n}}class qs extends $t{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,l=r+o.lines-1;if((n?l:a)>=e)return o.lineInner(e,n,r,i);i=a+1,r=l+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&n>=o){let u=i&((o<=e?1:0)|(l>=n?2:0));o>=e&&l<=n&&!u?r.push(a):a.decompose(e-o,n-o,r,u)}o=l+1}}replace(e,n,r){if([e,n]=ld(this,e,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(e>=s&&n<=a){let l=o.replace(e-s,n-s,r),u=this.lines-o.lines+l.lines;if(l.lines<u>>4&&l.lines>u>>6){let c=this.children.slice();return c[i]=l,new qs(c,this.length-(n-e)+r.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
343
343
  `){[e,n]=ld(this,e,n);let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let a=this.children[s],l=o+a.length;o>e&&s&&(i+=r),e<l&&n>o&&(i+=a.sliceString(e-o,n-o,r)),o=l+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof qs))return 0;let r=0,[i,s,o,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==a)return r;let l=this.children[i],u=e.children[s];if(l!=u)return r+l.scanIdentical(u,n);r+=l.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let m of e)r+=m.lines;if(r<32){let m=[];for(let y of e)y.flatten(m);return new An(m,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],l=0,u=-1,c=[];function d(m){let y;if(m.lines>s&&m instanceof qs)for(let v of m.children)d(v);else m.lines>o&&(l>o||!l)?(p(),a.push(m)):m instanceof An&&l&&(y=c[c.length-1])instanceof An&&m.lines+y.lines<=32?(l+=m.lines,u+=m.length+1,c[c.length-1]=new An(y.text.concat(m.text),y.length+1+m.length)):(l+m.lines>i&&p(),l+=m.lines,u+=m.length+1,c.push(m))}function p(){l!=0&&(a.push(c.length==1?c[0]:qs.from(c,u)),u=-1,l=c.length=0)}for(let m of e)d(m);return p(),a.length==1?a[0]:new qs(a,n)}}$t.empty=new An([""],0);function Jye(t){let e=-1;for(let n of t)e+=n.length+1;return e}function rx(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=r;s++){let a=t[s],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),o?(e[e.length-1]+=a,o=!1):e.push(a)),i=l+1}return e}function ej(t,e,n){return rx(t,[""],e,n)}class _h{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof An?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,a=i instanceof An?i.text.length:i.children.length;if(o==(n>0?a:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
344
344
  `,this;e--}else if(i instanceof An){let l=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof An?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class t8{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new _h(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class n8{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&($t.prototype[Symbol.iterator]=function(){return this.iter()},_h.prototype[Symbol.iterator]=t8.prototype[Symbol.iterator]=n8.prototype[Symbol.iterator]=function(){return this});class exe{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function ld(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function mr(t,e,n=!0,r=!0){return Zye(t,e,n,r)}function txe(t){return t>=56320&&t<57344}function nxe(t){return t>=55296&&t<56320}function ti(t,e){let n=t.charCodeAt(e);if(!nxe(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return txe(r)?(n-55296<<10)+(r-56320)+65536:n}function BA(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Ys(t){return t<65536?1:2}const cE=/\r\n?|\n/;var Wr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Wr||(Wr={}));class so{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,n=!1){dE(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new so(e)}composeDesc(e){return this.empty?e:e.empty?this:r8(this,e)}mapDesc(e,n=!1){return e.empty?this:fE(this,e,n)}mapPos(e,n=-1,r=Wr.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],u=i+a;if(l<0){if(u>e)return s+(e-i);s+=a}else{if(r!=Wr.Simple&&u>=e&&(r==Wr.TrackDel&&i<e&&u>e||r==Wr.TrackBefore&&i<e||r==Wr.TrackAfter&&u>e))return null;if(u>e||u==e&&n<0&&!a)return e==i||n<0?s:s+l;s+=l}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=n&&a>=e)return i<e&&a>n?"cover":!0;i=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new so(e)}static create(e){return new so(e)}}class Zn extends so{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dE(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return fE(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=o;let l=i>>1;for(;r.length<l;)r.push($t.empty);r.push(o?e.slice(s,s+o):$t.empty)}s+=o}return new Zn(n,r)}compose(e){return this.empty?e:e.empty?this:r8(this,e,!0)}map(e,n=!1){return e.empty?this:fE(this,e,n,!0)}iterChanges(e,n=!1){dE(this,e,n)}get desc(){return so.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new ap(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,l-a);Cr(i,c,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;Cr(n,c,d),d>0&&tl(r,n,s.text),s.forward(c),a+=c}let u=e[o++];for(;a<u;){if(s.done)break e;let c=Math.min(s.len,u-a);Cr(n,c,-1),Cr(i,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),a+=c}}return{changes:new Zn(n,r),filtered:so.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,a=null;function l(c=!1){if(!c&&!i.length)return;o<n&&Cr(i,n-o,-1);let d=new Zn(i,s);a=a?a.compose(d.map(a)):d,i=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let d of c)u(d);else if(c instanceof Zn){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:d,to:p=d,insert:m}=c;if(d>p||d<0||p>n)throw new RangeError(`Invalid change range ${d} to ${p} (in doc of length ${n})`);let y=m?typeof m=="string"?$t.of(m.split(r||cE)):m:$t.empty,v=y.length;if(d==p&&v==0)return;d<o&&l(),d>o&&Cr(i,d-o,-1),Cr(i,p-d,v),tl(s,i,y),o=p}}return u(e),l(!a),a}static empty(e){return new Zn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push($t.empty);r[i]=$t.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new Zn(n,r)}static createSet(e,n){return new Zn(e,n)}}function Cr(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function tl(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push($t.empty);t.push(n)}}function dE(t,e,n){let r=t.inserted;for(let i=0,s=0,o=0;o<t.sections.length;){let a=t.sections[o++],l=t.sections[o++];if(l<0)i+=a,s+=a;else{let u=i,c=s,d=$t.empty;for(;u+=a,c+=l,l&&r&&(d=d.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],l=t.sections[o++];e(i,u,s,c,d),i=u,s=c}}}function fE(t,e,n,r=!1){let i=[],s=r?[]:null,o=new ap(t),a=new ap(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let u=Math.min(o.len,a.len);Cr(i,u,-1),o.forward(u),a.forward(u)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!n))){let u=a.len;for(Cr(i,a.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&l<o.i&&o.len<=c&&(Cr(i,0,o.ins),s&&tl(s,i,o.text),l=o.i),o.forward(c),u-=c}a.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(a.ins==-1){let d=Math.min(c,a.len);u+=d,c-=d,a.forward(d)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;Cr(i,u,l<o.i?o.ins:0),s&&l<o.i&&tl(s,i,o.text),l=o.i,o.forward(o.len-c)}else{if(o.done&&a.done)return s?Zn.createSet(i,s):so.create(i);throw new Error("Mismatched change set lengths")}}}function r8(t,e,n=!1){let r=[],i=n?[]:null,s=new ap(t),o=new ap(e);for(let a=!1;;){if(s.done&&o.done)return i?Zn.createSet(r,i):so.create(r);if(s.ins==0)Cr(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)Cr(r,0,o.ins,a),i&&tl(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),u=r.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Cr(r,l,c,a),i&&c&&tl(i,r,o.text)}else o.ins==-1?(Cr(r,s.off?0:s.len,l,a),i&&tl(i,r,s.textBit(l))):(Cr(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&tl(i,r,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>u),s.forward2(l),o.forward(l)}}}}class ap{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?$t.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?$t.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ru{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new ru(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ye.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ye.range(this.anchor,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ye.range(e.anchor,e.head)}static create(e,n,r){return new ru(e,n,r)}}class ye{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ye.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ye([this.main],0)}addRange(e,n=!0){return ye.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,ye.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ye(e.ranges.map(n=>ru.fromJSON(n)),e.main)}static single(e,n=e){return new ye([ye.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return ye.normalized(e.slice(),n);r=s.to}return new ye(e,n)}static cursor(e,n=0,r,i){return ru.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<e?ru.create(n,e,48|s):ru.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let r=e[n];e.sort((i,s)=>i.from-s.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);i<=n&&n--,e.splice(--i,2,s.anchor>s.head?ye.range(l,a):ye.range(a,l))}}return new ye(e,n)}}function i8(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let zA=0;class ze{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=zA++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ze(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:$A),!!e.static,e.enables)}of(e){return new ix([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ix(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ix(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function $A(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class ix{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=zA++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,u=!1,c=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?u=!0:((n=e[d.id])!==null&&n!==void 0?n:1)&1||c.push(e[d.id]);return{create(d){return d.values[o]=r(d),1},update(d,p){if(l&&p.docChanged||u&&(p.docChanged||p.selection)||hE(d,c)){let m=r(d);if(a?!tj(m,d.values[o],i):!i(m,d.values[o]))return d.values[o]=m,1}return 0},reconfigure:(d,p)=>{let m,y=p.config.address[s];if(y!=null){let v=Kx(p,y);if(this.dependencies.every(w=>w instanceof ze?p.facet(w)===d.facet(w):w instanceof gr?p.field(w,!1)==d.field(w,!1):!0)||(a?tj(m=r(d),v,i):i(m=r(d),v)))return d.values[o]=v,0}else m=r(d);return d.values[o]=m,1}}}}function tj(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function hE(t,e){let n=!1;for(let r of e)Mh(t,r)&1&&(n=!0);return n}function rxe(t,e,n){let r=n.map(l=>t[l.id]),i=n.map(l=>l.type),s=r.filter(l=>!(l&1)),o=t[e.id]>>1;function a(l){let u=[];for(let c=0;c<r.length;c++){let d=Kx(l,r[c]);if(i[c]==2)for(let p of d)u.push(p);else u.push(d)}return e.combine(u)}return{create(l){for(let u of r)Mh(l,u);return l.values[o]=a(l),1},update(l,u){if(!hE(l,s))return 0;let c=a(l);return e.compare(c,l.values[o])?0:(l.values[o]=c,1)},reconfigure(l,u){let c=hE(l,r),d=u.config.facets[e.id],p=u.facet(e);if(d&&!c&&$A(n,d))return l.values[o]=p,0;let m=a(l);return e.compare(m,p)?(l.values[o]=p,0):(l.values[o]=m,1)}}}const gy=ze.define({static:!0});class gr{constructor(e,n,r,i,s){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let n=new gr(zA++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(gy).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(gy),o=i.facet(gy),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[n]=a.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,gy.of({field:this,create:e})]}get extension(){return this}}const Jl={lowest:4,low:3,default:2,high:1,highest:0};function Yf(t){return e=>new s8(e,t)}const ju={highest:Yf(Jl.highest),high:Yf(Jl.high),default:Yf(Jl.default),low:Yf(Jl.low),lowest:Yf(Jl.lowest)};class s8{constructor(e,n){this.inner=e,this.prec=n}}class Av{of(e){return new pE(this,e)}reconfigure(e){return Av.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class pE{constructor(e,n){this.compartment=e,this.inner=n}}class Gx{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let p of ixe(e,n,o))p instanceof gr?i.push(p):(s[p.facet.id]||(s[p.facet.id]=[])).push(p);let a=Object.create(null),l=[],u=[];for(let p of i)a[p.id]=u.length<<1,u.push(m=>p.slot(m));let c=r==null?void 0:r.config.facets;for(let p in s){let m=s[p],y=m[0].facet,v=c&&c[p]||[];if(m.every(w=>w.type==0))if(a[y.id]=l.length<<1|1,$A(v,m))l.push(r.facet(y));else{let w=y.combine(m.map(b=>b.value));l.push(r&&y.compare(w,r.facet(y))?r.facet(y):w)}else{for(let w of m)w.type==0?(a[w.id]=l.length<<1|1,l.push(w.value)):(a[w.id]=u.length<<1,u.push(b=>w.dynamicSlot(b)));a[y.id]=u.length<<1,u.push(w=>rxe(w,y,m))}}let d=u.map(p=>p(a));return new Gx(e,o,d,a,l,s)}}function ixe(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let u=r[l].indexOf(o);u>-1&&r[l].splice(u,1),o instanceof pE&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let u of o)s(u,a);else if(o instanceof pE){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,a)}else if(o instanceof s8)s(o.inner,o.prec);else if(o instanceof gr)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof ix)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,Jl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,a)}}return s(t,Jl.default),r.reduce((o,a)=>o.concat(a))}function Mh(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Kx(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const o8=ze.define(),mE=ze.define({combine:t=>t.some(e=>e),static:!0}),a8=ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),l8=ze.define(),u8=ze.define(),c8=ze.define(),d8=ze.define({combine:t=>t.length?t[0]:!1});class Eo{constructor(e,n){this.type=e,this.value=n}static define(){return new sxe}}class sxe{of(e){return new Eo(this,e)}}class oxe{constructor(e){this.map=e}of(e){return new xt(this,e)}}class xt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new xt(this.type,n)}is(e){return this.type==e}static define(e={}){return new oxe(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}xt.reconfigure=xt.define();xt.appendConfig=xt.define();class Jn{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&i8(r,n.newLength),s.some(a=>a.type==Jn.time)||(this.annotations=s.concat(Jn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Jn(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Jn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Jn.time=Eo.define();Jn.userEvent=Eo.define();Jn.addToHistory=Eo.define();Jn.remote=Eo.define();function axe(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))s=t[r++],o=t[r++];else if(i<e.length)s=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function f8(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=Zn.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:xt.mapEffects(t.effects,i).concat(xt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function gE(t,e,n){let r=e.selection,i=Hc(e.annotations);return e.userEvent&&(i=i.concat(Jn.userEvent.of(e.userEvent))),{changes:e.changes instanceof Zn?e.changes:Zn.of(e.changes||[],n,t.facet(a8)),selection:r&&(r instanceof ye?r:ye.single(r.anchor,r.head)),effects:Hc(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function h8(t,e,n){let r=gE(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;r=f8(r,gE(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=Jn.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return uxe(n?lxe(i):i)}function lxe(t){let e=t.startState,n=!0;for(let i of e.facet(l8)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:axe(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=Zn.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Jn.create(e,i,t.selection&&t.selection.map(s),xt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(u8);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof Jn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Jn?t=s[0]:t=h8(e,Hc(s),!1)}return t}function uxe(t){let e=t.startState,n=e.facet(c8),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=f8(r,gE(e,s,t.changes.newLength),!0))}return r==t?t:Jn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const cxe=[];function Hc(t){return t==null?cxe:Array.isArray(t)?t:[t]}var mn=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(mn||(mn={}));const dxe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let yE;try{yE=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function fxe(t){if(yE)return yE.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||dxe.test(n)))return!0}return!1}function hxe(t){return e=>{if(!/\S/.test(e))return mn.Space;if(fxe(e))return mn.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return mn.Word;return mn.Other}}class At{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Mh(this,a<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return Mh(this,r),Kx(this,r)}update(...e){return h8(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(Av.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,u)=>i.set(u,l)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(xt.reconfigure)?(n=null,r=a.value):a.is(xt.appendConfig)&&(n=null,r=Hc(r).concat(a.value));let s;n?s=e.startState.values.slice():(n=Gx.resolve(r,i,this),s=new At(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,u)=>u.reconfigure(l,this),null).values);let o=e.startState.facet(mE)?e.newSelection:e.newSelection.asSingle();new At(n,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ye.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Hc(r.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),u=this.changes(l.changes),c=u.map(i);for(let p=0;p<a;p++)s[p]=s[p].map(c);let d=i.mapDesc(u,!0);s.push(l.range.map(d)),i=i.compose(c),o=xt.mapEffects(o,c).concat(xt.mapEffects(Hc(l.effects),d))}return{changes:i,selection:ye.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof Zn?e:Zn.of(e,this.doc.length,this.facet(At.lineSeparator))}toText(e){return $t.of(e.split(this.facet(At.lineSeparator)||cE))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Mh(this,n),Kx(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof gr&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];i.push(o.init(l=>o.spec.fromJSON(a,l)))}}return At.create({doc:e.doc,selection:ye.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Gx.resolve(e.extensions||[],new Map),r=e.doc instanceof $t?e.doc:$t.of((e.doc||"").split(n.staticFacet(At.lineSeparator)||cE)),i=e.selection?e.selection instanceof ye?e.selection:ye.single(e.selection.anchor,e.selection.head):ye.single(0);return i8(i,r.length),n.staticFacet(mE)||(i=i.asSingle()),new At(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(At.tabSize)}get lineBreak(){return this.facet(At.lineSeparator)||`