mastra 0.2.0-alpha.162 → 0.2.0-alpha.163

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.
@@ -247,7 +247,7 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
247
247
  `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(t,{before:"# ",after:`
248
248
  `,...s.current()});return/^[\t ]/.test(u)&&(u=Yh(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}pB.peek=kle;function pB(t){return t.value||""}function kle(){return"<"}mB.peek=Sle;function mB(t,e,n,r){const i=DT(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 Sle(){return"!"}gB.peek=Cle;function gB(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 f=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Cle(){return"!"}yB.peek=Ele;function yB(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 Ele(){return"`"}function xB(t,e){const n=ET(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))}vB.peek=Ale;function vB(t,e,n,r){const i=DT(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(xB(t,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(t,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=c,f}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 Ale(t,e,n){return xB(t,n)?"<":"["}wB.peek=Tle;function wB(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 f=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Tle(){return"["}function IT(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 Nle(t){const e=IT(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 _le(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 bB(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 Mle(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?_le(n):IT(n);const a=t.ordered?o==="."?")":".":Nle(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),bB(n)===o&&c){let f=-1;for(;++f<t.children.length;){const p=t.children[f];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 Ple(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 Rle(t,e,n,r){const i=Ple(n);let s=n.bulletCurrent||IT(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(f,p,m){return p?(m?"":" ".repeat(o))+f:(m?s:s+" ".repeat(o-s.length))+f}}function Ole(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const Dle=J0(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Ile(t,e,n,r){return(t.children.some(function(o){return Dle(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function jle(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}kB.peek=Lle;function kB(t,e,n,r){const i=jle(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=kx(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=Yh(u)+l.slice(1));const f=l.charCodeAt(l.length-1),p=kx(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+Yh(f));const m=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:c.outside},a+l+m}function Lle(t,e,n){return n.options.strong||"*"}function Fle(t,e,n,r){return n.safe(t.value,r)}function Ble(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 zle(t,e,n){const r=(bB(n)+(n.options.ruleSpaces?" ":"")).repeat(Ble(n));return n.options.ruleSpaces?r.slice(0,-1):r}const SB={blockquote:ule,break:PO,code:mle,definition:yle,emphasis:hB,hardBreak:PO,heading:ble,html:pB,image:mB,imageReference:gB,inlineCode:yB,link:vB,linkReference:wB,list:Mle,listItem:Rle,paragraph:Ole,root:Ile,strong:kB,text:Fle,thematicBreak:zle};function $le(){return{enter:{table:Vle,tableData:RO,tableHeader:RO,tableRow:Hle},exit:{codeText:Ule,table:Wle,tableData:D1,tableHeader:D1,tableRow:D1}}}function Vle(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 Wle(t){this.exit(t),this.data.inTable=void 0}function Hle(t){this.enter({type:"tableRow",children:[]},t)}function D1(t){this.exit(t)}function RO(t){this.enter({type:"tableCell",children:[]},t)}function Ule(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,qle));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function qle(t,e){return e==="|"?e:t}function Yle(t){const e=t,n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
249
249
  `,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=f(m,v,w),k=u([b]);return k.slice(0,k.indexOf(`
250
- `))}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 ale(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]=f(w[b],y,v);return E(),k}function f(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=SB.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Gle(){return{exit:{taskListCheckValueChecked:OO,taskListCheckValueUnchecked:OO,paragraph:Zle}}}function Kle(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Xle}}}function OO(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Zle(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 Xle(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=SB.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 Qle(){return[_ae(),$ae(),tle(),$le(),Gle()]}function Jle(t){return{extensions:[Mae(),Vae(),nle(),Yle(t),Kle()]}}const eue={tokenize:oue,partial:!0},CB={tokenize:aue,partial:!0},EB={tokenize:lue,partial:!0},AB={tokenize:uue,partial:!0},tue={tokenize:cue,partial:!0},TB={name:"wwwAutolink",tokenize:iue,previous:_B},NB={name:"protocolAutolink",tokenize:sue,previous:MB},da={name:"emailAutolink",tokenize:rue,previous:PB},yo={};function nue(){return{text:yo}}let Ul=48;for(;Ul<123;)yo[Ul]=da,Ul++,Ul===58?Ul=65:Ul===91&&(Ul=97);yo[43]=da;yo[45]=da;yo[46]=da;yo[95]=da;yo[72]=[da,NB];yo[104]=[da,NB];yo[87]=[da,TB];yo[119]=[da,TB];function rue(t,e,n){const r=this;let i,s;return o;function o(f){return!OC(f)||!PB.call(r,r.previous)||jT(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(f))}function a(f){return OC(f)?(t.consume(f),a):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(tue,c,u)(f):f===45||f===95||Tr(f)?(s=!0,t.consume(f),l):c(f)}function u(f){return t.consume(f),i=!0,l}function c(f){return s&&i&&$r(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function iue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!_B.call(r,r.previous)||jT(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(eue,t.attempt(CB,t.attempt(EB,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function sue(t,e,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&MB.call(r,r.previous)&&!jT(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),a):n(f)}function a(f){if($r(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),s?u:(s=!0,l)):n(f)}function u(f){return f===null||vx(f)||Gt(f)||du(f)||Z0(f)?n(f):t.attempt(CB,t.attempt(EB,c),n)(f)}function c(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function oue(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 aue(t,e,n){let r,i,s;return o;function o(u){return u===46||u===95?t.check(AB,l,a)(u):u===null||Gt(u)||du(u)||u!==45&&Z0(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 lue(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(AB,e,s)(o):o===null||Gt(o)||du(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function uue(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||Gt(a)||du(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Gt(a)||du(a)?e(a):r(a)}function s(a){return $r(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):$r(a)?(t.consume(a),o):n(a)}}function cue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Tr(s)?n(s):e(s)}}function _B(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Gt(t)}function MB(t){return!$r(t)}function PB(t){return!(t===47||OC(t))}function OC(t){return t===43||t===45||t===46||t===95||Tr(t)}function jT(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 fue={tokenize:vue,partial:!0};function due(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:gue,continuation:{tokenize:yue},exit:xue}},text:{91:{name:"gfmFootnoteCall",tokenize:mue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hue,resolveTo:pue}}}}function hue(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 pue(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 mue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!o||f===null||f===91||Gt(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bs(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return Gt(f)||(o=!0),s++,t.consume(f),f===92?c:u}function c(f){return f===91||f===92||f===93?(t.consume(f),s++,u):u(f)}}function gue(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||Gt(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 Gt(y)||(a=!0),o++,t.consume(y),y===92?f:c}function f(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 yue(t,e,n){return t.check(Xp,e,t.attempt(fue,e,n))}function xue(t){t.exit("gfmFootnoteDefinition")}function vue(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 wue(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)},f={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",f,a]],m=a.parser.constructs.insideSpan.null;m&&Ti(p,p.length,0,X0(m,o.slice(u+1,l),a)),Ti(p,p.length,0,[["exit",f,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 f=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=tf(u);if(y===126)return f>1?l(y):(o.consume(y),f++,m);if(f<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=tf(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class bue{constructor(){this.map=[]}add(e,n,r){kue(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 kue(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 Sue(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 Cue(){return{flow:{null:{name:"table",tokenize:Eue,resolveAll:Aue}}}}function Eue(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 j=r.events[B][1].type;if(j==="lineEnding"||j==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,V=F==="tableHead"||F==="tableRow"?N:l;return V===N&&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):rt(O)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),m):n(O):Et(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"),f(O)))}function f(O){return O===null||O===124||Gt(O)?(t.exit("data"),c(O)):(t.consume(O),O===92?p:f)}function p(O){return O===92||O===124?(t.consume(O),f):f(O)}function m(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),o=!1,Et(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):_(O)}function v(O){return Et(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||rt(O)?A(O):_(O)}function b(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):_(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 Et(O)?Pt(t,A,"whitespace")(O):A(O)}function A(O){return O===124?y(O):O===null||rt(O)?!o||i!==s?_(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):_(O)}function _(O){return n(O)}function N(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||rt(O)?(t.exit("tableRow"),e(O)):Et(O)?Pt(t,M,"whitespace")(O):(t.enter("data"),R(O))}function R(O){return O===null||O===124||Gt(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 Aue(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,f;const p=new bue;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(DO(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,f=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],f=Zg(p,e,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=Zg(p,e,s,i,void 0,f)),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],f=Zg(p,e,s,i,n,f)):o[1]!==0&&(f=Zg(p,e,o,i,n,f)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&DO(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=Sue(e.events,n))}return t}function Zg(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},gc(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=gc(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=gc(e.events,n[2]),c=gc(e.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",f,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",f,e]])}return i!==void 0&&(s.end=Object.assign({},gc(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function DO(t,e,n,r,i){const s=[],o=gc(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 gc(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Tue={name:"tasklistCheck",tokenize:_ue};function Nue(){return{text:{91:Tue}}}function _ue(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 Gt(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 rt(l)?e(l):Et(l)?t.check({tokenize:Mue},e,n)(l):n(l)}}function Mue(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Pue(t){return W5([nue(),due(),wue(t),Cue(),Nue()])}const Rue={};function Oue(t){const e=this,n=t||Rue,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Pue(n)),s.push(Qle()),o.push(Jle(n))}const Due="modulepreload",Iue=function(t){return"/"+t},IO={},jue=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=Iue(l),l in IO)return;IO[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Due,u||(f.as="script"),f.crossOrigin="",f.href=l,a&&f.setAttribute("nonce",a),document.head.appendChild(f),u)return new Promise((p,m)=>{f.addEventListener("load",p),f.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 Lue(t,e){const{codeToTokens:n,bundledLanguages:r}=await jue(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-BdWmAV4M.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 Fue({children:t}){const e=t.replace(/\\n/g,`
250
+ `))}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 ale(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]=f(w[b],y,v);return E(),k}function f(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=SB.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Gle(){return{exit:{taskListCheckValueChecked:OO,taskListCheckValueUnchecked:OO,paragraph:Zle}}}function Kle(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Xle}}}function OO(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Zle(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 Xle(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=SB.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 Qle(){return[_ae(),$ae(),tle(),$le(),Gle()]}function Jle(t){return{extensions:[Mae(),Vae(),nle(),Yle(t),Kle()]}}const eue={tokenize:oue,partial:!0},CB={tokenize:aue,partial:!0},EB={tokenize:lue,partial:!0},AB={tokenize:uue,partial:!0},tue={tokenize:cue,partial:!0},TB={name:"wwwAutolink",tokenize:iue,previous:_B},NB={name:"protocolAutolink",tokenize:sue,previous:MB},da={name:"emailAutolink",tokenize:rue,previous:PB},yo={};function nue(){return{text:yo}}let Ul=48;for(;Ul<123;)yo[Ul]=da,Ul++,Ul===58?Ul=65:Ul===91&&(Ul=97);yo[43]=da;yo[45]=da;yo[46]=da;yo[95]=da;yo[72]=[da,NB];yo[104]=[da,NB];yo[87]=[da,TB];yo[119]=[da,TB];function rue(t,e,n){const r=this;let i,s;return o;function o(f){return!OC(f)||!PB.call(r,r.previous)||jT(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(f))}function a(f){return OC(f)?(t.consume(f),a):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(tue,c,u)(f):f===45||f===95||Tr(f)?(s=!0,t.consume(f),l):c(f)}function u(f){return t.consume(f),i=!0,l}function c(f){return s&&i&&$r(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function iue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!_B.call(r,r.previous)||jT(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(eue,t.attempt(CB,t.attempt(EB,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function sue(t,e,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&MB.call(r,r.previous)&&!jT(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),a):n(f)}function a(f){if($r(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),a;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),s?u:(s=!0,l)):n(f)}function u(f){return f===null||vx(f)||Gt(f)||du(f)||Z0(f)?n(f):t.attempt(CB,t.attempt(EB,c),n)(f)}function c(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function oue(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 aue(t,e,n){let r,i,s;return o;function o(u){return u===46||u===95?t.check(AB,l,a)(u):u===null||Gt(u)||du(u)||u!==45&&Z0(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 lue(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(AB,e,s)(o):o===null||Gt(o)||du(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function uue(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||Gt(a)||du(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Gt(a)||du(a)?e(a):r(a)}function s(a){return $r(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):$r(a)?(t.consume(a),o):n(a)}}function cue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Tr(s)?n(s):e(s)}}function _B(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Gt(t)}function MB(t){return!$r(t)}function PB(t){return!(t===47||OC(t))}function OC(t){return t===43||t===45||t===46||t===95||Tr(t)}function jT(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 fue={tokenize:vue,partial:!0};function due(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:gue,continuation:{tokenize:yue},exit:xue}},text:{91:{name:"gfmFootnoteCall",tokenize:mue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hue,resolveTo:pue}}}}function hue(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 pue(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 mue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!o||f===null||f===91||Gt(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bs(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return Gt(f)||(o=!0),s++,t.consume(f),f===92?c:u}function c(f){return f===91||f===92||f===93?(t.consume(f),s++,u):u(f)}}function gue(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||Gt(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 Gt(y)||(a=!0),o++,t.consume(y),y===92?f:c}function f(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 yue(t,e,n){return t.check(Xp,e,t.attempt(fue,e,n))}function xue(t){t.exit("gfmFootnoteDefinition")}function vue(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 wue(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)},f={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",f,a]],m=a.parser.constructs.insideSpan.null;m&&Ti(p,p.length,0,X0(m,o.slice(u+1,l),a)),Ti(p,p.length,0,[["exit",f,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 f=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=tf(u);if(y===126)return f>1?l(y):(o.consume(y),f++,m);if(f<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=tf(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class bue{constructor(){this.map=[]}add(e,n,r){kue(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 kue(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 Sue(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 Cue(){return{flow:{null:{name:"table",tokenize:Eue,resolveAll:Aue}}}}function Eue(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 j=r.events[B][1].type;if(j==="lineEnding"||j==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,V=F==="tableHead"||F==="tableRow"?N:l;return V===N&&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):rt(O)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),m):n(O):Et(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"),f(O)))}function f(O){return O===null||O===124||Gt(O)?(t.exit("data"),c(O)):(t.consume(O),O===92?p:f)}function p(O){return O===92||O===124?(t.consume(O),f):f(O)}function m(O){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(O):(t.enter("tableDelimiterRow"),o=!1,Et(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):_(O)}function v(O){return Et(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||rt(O)?A(O):_(O)}function b(O){return O===45?(t.enter("tableDelimiterFiller"),k(O)):_(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 Et(O)?Pt(t,A,"whitespace")(O):A(O)}function A(O){return O===124?y(O):O===null||rt(O)?!o||i!==s?_(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):_(O)}function _(O){return n(O)}function N(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||rt(O)?(t.exit("tableRow"),e(O)):Et(O)?Pt(t,M,"whitespace")(O):(t.enter("data"),R(O))}function R(O){return O===null||O===124||Gt(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 Aue(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,f;const p=new bue;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(DO(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,f=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],f=Zg(p,e,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=Zg(p,e,s,i,void 0,f)),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],f=Zg(p,e,s,i,n,f)):o[1]!==0&&(f=Zg(p,e,o,i,n,f)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&DO(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=Sue(e.events,n))}return t}function Zg(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},gc(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=gc(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=gc(e.events,n[2]),c=gc(e.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(t.add(n[2],0,[["enter",f,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",f,e]])}return i!==void 0&&(s.end=Object.assign({},gc(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function DO(t,e,n,r,i){const s=[],o=gc(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 gc(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Tue={name:"tasklistCheck",tokenize:_ue};function Nue(){return{text:{91:Tue}}}function _ue(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 Gt(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 rt(l)?e(l):Et(l)?t.check({tokenize:Mue},e,n)(l):n(l)}}function Mue(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Pue(t){return W5([nue(),due(),wue(t),Cue(),Nue()])}const Rue={};function Oue(t){const e=this,n=t||Rue,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Pue(n)),s.push(Qle()),o.push(Jle(n))}const Due="modulepreload",Iue=function(t){return"/"+t},IO={},jue=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=Iue(l),l in IO)return;IO[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Due,u||(f.as="script"),f.crossOrigin="",f.href=l,a&&f.setAttribute("nonce",a),document.head.appendChild(f),u)return new Promise((p,m)=>{f.addEventListener("load",p),f.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 Lue(t,e){const{codeToTokens:n,bundledLanguages:r}=await jue(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-Cg3fVVjw.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 Fue({children:t}){const e=t.replace(/\\n/g,`
251
251
  `);return g.jsx(kae,{remarkPlugins:[Oue],components:zue,className:"space-y-3",children:e})}const RB=ne.memo(({children:t,language:e,...n})=>{const[r,i]=S.useState([]);return S.useEffect(()=>{Lue(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&&`
252
252
  `]}))})}):g.jsx("pre",{...n,children:t})});RB.displayName="HighlightedCode";const Bue=({children:t,className:e,language:n,...r})=>{const i=typeof t=="string"?t:DC(t),s=Te("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(RB,{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 DC(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=>DC(r)).join(""):DC(n)}return""}const zue={h1:fr("h1","text-2xl font-semibold"),h2:fr("h2","font-semibold text-xl"),h3:fr("h3","font-semibold text-lg"),h4:fr("h4","font-semibold text-base"),h5:fr("h5","font-medium"),strong:fr("strong","font-semibold"),a:fr("a","text-primary underline underline-offset-2"),blockquote:fr("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(Bue,{className:e,language:i[1],...r,children:t}):g.jsx("code",{className:Te("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:fr("ol","list-decimal space-y-2 pl-6"),ul:fr("ul","list-disc space-y-2 pl-6"),li:fr("li","my-1.5"),table:fr("table","w-full border-collapse overflow-y-auto rounded-md border border-foreground/20"),th:fr("th","border border-foreground/20 px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right"),td:fr("td","border border-foreground/20 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right"),tr:fr("tr","m-0 border-t p-0 even:bg-muted"),p:fr("p","whitespace-pre-wrap leading-relaxed"),hr:fr("hr","border-foreground/20")};function fr(t,e){const n=({node:r,...i})=>g.jsx(t,{className:e,...i});return n.displayName=t,n}const $ue=Df("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"}]}),Vue=({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=Wue(p.url);return new File([m],p.name??"Unknown")}),[a]),f=n==null?void 0:n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return g.jsxs("div",{className:Te("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(xT,{file:p},m))}):null,g.jsxs("div",{className:Te($ue({isUser:u,isError:l,animation:i}),o),children:[g.jsx("div",{children:g.jsx(Fue,{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:Te("mt-1 block px-1 text-xs opacity-50",i!=="none"&&"duration-500 animate-in fade-in-0"),children:f}):null]})};function Wue(t){const e=t.split(",")[1],n=Buffer.from(e??"","base64");return new Uint8Array(n)}function Hue(){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(Zb,{className:"h-5 w-5 animate-typing-dot-bounce"}),g.jsx(Zb,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:90ms]"}),g.jsx(Zb,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:180ms]"})]})})})}function Uue({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(Vue,{showTimeStamp:e,...i,...o},s)}),n&&g.jsx(Hue,{})]})}function que({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 Yue=50;function Gue(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)<Yue;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 Kue({messages:t,children:e}){const{containerRef:n,scrollToBottom:r,handleScroll:i,shouldAutoScroll:s,handleTouchStart:o}=Gue([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(At,{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(qK,{className:"h-4 w-4"})})})})]})}const OB=S.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Te("grid max-h-full w-full grid-rows-[1fr_auto]",t),...e}));OB.displayName="ChatContainer";const DB=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=Zue(s);e(l,{experimental_attachments:u}),o(null)};return g.jsx("form",{ref:i,onSubmit:a,className:r,children:t({files:s,setFiles:o})})});DB.displayName="ChatForm";function Zue(t){const e=new DataTransfer;for(const n of Array.from(t))e.items.add(n);return e.files}function Xue({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:f}=jA();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 A=a;l(""),c(!0);const _={id:Date.now().toString(),role:"user",content:A},N={id:(Date.now()+1).toString(),role:"assistant",content:""};o(R=>[...R,_,N]);try{const R=await fetch("/api/agents/"+t+"/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[A],...i?{threadId:r,resourceid:t}:{}})});if(!R.body)throw new Error("No response body");if(R.status!==200){const j=await R.json();throw new Error(j.message)}f(`/api/memory/threads?resourceid=${t}&agentId=${t}`);const D=R.body.getReader(),O=new TextDecoder;let B="",F="",V="";try{for(;;){const{done:j,value:Y}=await D.read();if(j)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(j){throw new Error(j.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(OB,{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(que,{label:`Chat with ${n}`,append:b,suggestions:k})}):g.jsx(Zn,{className:" h-[calc(100vh-15rem)] px-4",children:g.jsx(Kue,{messages:s,children:g.jsx(Uue,{messages:s,isTyping:w})})})}),g.jsxs("div",{className:"flex flex-col mt-auto gap-2",children:[g.jsx(DB,{isPending:u||w,handleSubmit:m,children:({files:E,setFiles:A})=>g.jsx(T5,{value:a,onChange:p,files:E,setFiles:A,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 LT(t){const e=t+"CollectionProvider",[n,r]=ts(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=St(y,b.collectionRef);return g.jsx(ao,{ref:k,children:w})});l.displayName=a;const u=t+"CollectionItemSlot",c="data-radix-collection-item",f=ne.forwardRef((m,y)=>{const{scope:v,children:w,...b}=m,k=ne.useRef(null),E=St(y,k),A=s(u,v);return ne.useEffect(()=>(A.itemMap.set(k,{ref:k,...b}),()=>void A.itemMap.delete(k))),g.jsx(ao,{[c]:"",ref:E,children:w})});f.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((A,_)=>b.indexOf(A.ref.current)-b.indexOf(_.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:l,ItemSlot:f},p,r]}var Que=hG.useId||(()=>{}),Jue=0;function Xn(t){const[e,n]=S.useState(Que());return Nr(()=>{t||n(r=>r??String(Jue++))},[t]),t||(e?`radix-${e}`:"")}function na({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=ece({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,a=jn(n),l=S.useCallback(u=>{if(s){const f=typeof u=="function"?u(t):u;f!==t&&a(f)}else i(u)},[s,t,i,a]);return[o,l]}function ece({defaultProp:t,onChange:e}){const n=S.useState(t),[r]=n,i=S.useRef(r),s=jn(e);return S.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var I1="rovingFocusGroup.onEntryFocus",tce={bubbles:!1,cancelable:!0},tv="RovingFocusGroup",[IC,IB,nce]=LT(tv),[rce,nv]=ts(tv,[nce]),[ice,sce]=rce(tv),jB=S.forwardRef((t,e)=>g.jsx(IC.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(IC.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(oce,{...t,ref:e})})}));jB.displayName=tv;var oce=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,...f}=t,p=S.useRef(null),m=St(e,p),y=Up(s),[v=null,w]=na({prop:o,defaultProp:a,onChange:l}),[b,k]=S.useState(!1),E=jn(u),A=IB(n),_=S.useRef(!1),[N,M]=S.useState(0);return S.useEffect(()=>{const R=p.current;if(R)return R.addEventListener(I1,E),()=>R.removeEventListener(I1,E)},[E]),g.jsx(ice,{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(Xe.div,{tabIndex:b||N===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...t.style},onMouseDown:Ie(t.onMouseDown,()=>{_.current=!0}),onFocus:Ie(t.onFocus,R=>{const D=!_.current;if(R.target===R.currentTarget&&D&&!b){const O=new CustomEvent(I1,tce);if(R.currentTarget.dispatchEvent(O),!O.defaultPrevented){const B=A().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);BB(Y,c)}}_.current=!1}),onBlur:Ie(t.onBlur,()=>k(!1))})})}),LB="RovingFocusGroupItem",FB=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,...o}=t,a=Xn(),l=s||a,u=sce(LB,n),c=u.currentTabStopId===l,f=IB(n),{onFocusableItemAdd:p,onFocusableItemRemove:m}=u;return S.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),g.jsx(IC.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:g.jsx(Xe.span,{tabIndex:c?0:-1,"data-orientation":u.orientation,...o,ref:e,onMouseDown:Ie(t.onMouseDown,y=>{r?u.onItemFocus(l):y.preventDefault()}),onFocus:Ie(t.onFocus,()=>u.onItemFocus(l)),onKeyDown:Ie(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=uce(y,u.orientation,u.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=f().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?cce(b,k+1):b.slice(k+1)}setTimeout(()=>BB(b))}})})})});FB.displayName=LB;var ace={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lce(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function uce(t,e,n){const r=lce(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ace[r]}function BB(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function cce(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var zB=jB,$B=FB,FT="Tabs",[fce,_Ie]=ts(FT,[nv]),VB=nv(),[dce,BT]=fce(FT),WB=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:l="automatic",...u}=t,c=Up(a),[f,p]=na({prop:r,onChange:i,defaultProp:s});return g.jsx(dce,{scope:n,baseId:Xn(),value:f,onValueChange:p,orientation:o,dir:c,activationMode:l,children:g.jsx(Xe.div,{dir:c,"data-orientation":o,...u,ref:e})})});WB.displayName=FT;var HB="TabsList",UB=S.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=BT(HB,n),o=VB(n);return g.jsx(zB,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:g.jsx(Xe.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});UB.displayName=HB;var qB="TabsTrigger",YB=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=BT(qB,n),a=VB(n),l=ZB(o.baseId,r),u=XB(o.baseId,r),c=r===o.value;return g.jsx($B,{asChild:!0,...a,focusable:!i,active:c,children:g.jsx(Xe.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:Ie(t.onMouseDown,f=>{!i&&f.button===0&&f.ctrlKey===!1?o.onValueChange(r):f.preventDefault()}),onKeyDown:Ie(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&o.onValueChange(r)}),onFocus:Ie(t.onFocus,()=>{const f=o.activationMode!=="manual";!c&&!i&&f&&o.onValueChange(r)})})})});YB.displayName=qB;var GB="TabsContent",KB=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=BT(GB,n),l=ZB(a.baseId,r),u=XB(a.baseId,r),c=r===a.value,f=S.useRef(c);return S.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),g.jsx(qr,{present:i||c,children:({present:p})=>g.jsx(Xe.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:f.current?"0s":void 0},children:p&&s})})});KB.displayName=GB;function ZB(t,e){return`${t}-trigger-${e}`}function XB(t,e){return`${t}-content-${e}`}var hce=WB,QB=UB,JB=YB,ez=KB;const zT=hce,rv=S.forwardRef(({className:t,...e},n)=>g.jsx(QB,{ref:n,className:Te(t),...e}));rv.displayName=QB.displayName;const Yo=S.forwardRef(({className:t,...e},n)=>g.jsx(JB,{ref:n,className:Te(t),...e}));Yo.displayName=JB.displayName;const Go=S.forwardRef(({className:t,...e},n)=>g.jsx(ez,{ref:n,className:Te("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Go.displayName=ez.displayName;function pce({agentId:t}){var i;const{isLoading:e,agent:n}=Of(t),r=mo();return e?g.jsx(Zn,{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(Zn,{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 mce({agentId:t}){return g.jsx(Zn,{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"]})]})]})})}const tz=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),bn.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),bn.error("Error fetching logs")}finally{i(!1)}};return S.useEffect(()=>{s(t)},[t]),{logs:e,isLoading:r,refetchLogs:s}};function gce({agentId:t}){const{logs:e,isLoading:n,refetchLogs:r}=tz(t);return g.jsxs(Zn,{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(At,{variant:"outline",onClick:()=>r(),children:n?g.jsx(Zc,{className:"w-4 h-4 animate-spin"}):g.jsx(Zc,{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 Sx({agentId:t}){return g.jsxs(zT,{defaultValue:"details",children:[g.jsxs(rv,{className:"flex shrink-0 border-b",children:[g.jsx(Yo,{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(Yo,{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(Yo,{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(Go,{value:"details",children:t?g.jsx(pce,{agentId:t}):null}),g.jsx(Go,{value:"endpoints",children:g.jsx(mce,{agentId:t})}),g.jsx(Go,{value:"logs",children:g.jsx(gce,{agentId:t})})]})}function yce(t,e=globalThis==null?void 0:globalThis.document){const n=jn(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 xce="DismissableLayer",jC="dismissableLayer.update",vce="dismissableLayer.pointerDownOutside",wce="dismissableLayer.focusOutside",jO,nz=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Jp=S.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,u=S.useContext(nz),[c,f]=S.useState(null),p=(c==null?void 0:c.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=S.useState({}),y=St(e,M=>f(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,A=k>=b,_=Sce(M=>{const R=M.target,D=[...u.branches].some(O=>O.contains(R));!A||D||(i==null||i(M),o==null||o(M),M.defaultPrevented||a==null||a())},p),N=Cce(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 yce(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&&(jO=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),LO(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=jO)}},[c,p,n,u]),S.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),LO())},[c,u]),S.useEffect(()=>{const M=()=>m({});return document.addEventListener(jC,M),()=>document.removeEventListener(jC,M)},[]),g.jsx(Xe.div,{...l,ref:y,style:{pointerEvents:E?A?"auto":"none":void 0,...t.style},onFocusCapture:Ie(t.onFocusCapture,N.onFocusCapture),onBlurCapture:Ie(t.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Ie(t.onPointerDownCapture,_.onPointerDownCapture)})});Jp.displayName=xce;var bce="DismissableLayerBranch",kce=S.forwardRef((t,e)=>{const n=S.useContext(nz),r=S.useRef(null),i=St(e,r);return S.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),g.jsx(Xe.div,{...t,ref:i})});kce.displayName=bce;function Sce(t,e=globalThis==null?void 0:globalThis.document){const n=jn(t),r=S.useRef(!1),i=S.useRef(()=>{});return S.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){rz(vce,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 Cce(t,e=globalThis==null?void 0:globalThis.document){const n=jn(t),r=S.useRef(!1);return S.useEffect(()=>{const i=s=>{s.target&&!r.current&&rz(wce,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 LO(){const t=new CustomEvent(jC);document.dispatchEvent(t)}function rz(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?E3(i,s):i.dispatchEvent(s)}var j1="focusScope.autoFocusOnMount",L1="focusScope.autoFocusOnUnmount",FO={bubbles:!1,cancelable:!0},Ece="FocusScope",em=S.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=S.useState(null),u=jn(i),c=jn(s),f=S.useRef(null),p=St(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 A=E.target;a.contains(A)?f.current=A:qa(f.current,{select:!0})},w=function(E){if(m.paused||!a)return;const A=E.relatedTarget;A!==null&&(a.contains(A)||qa(f.current,{select:!0}))},b=function(E){if(document.activeElement===document.body)for(const _ of E)_.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){zO.add(m);const v=document.activeElement;if(!a.contains(v)){const b=new CustomEvent(j1,FO);a.addEventListener(j1,u),a.dispatchEvent(b),b.defaultPrevented||(Ace(Pce(iz(a)),{select:!0}),document.activeElement===v&&qa(a))}return()=>{a.removeEventListener(j1,u),setTimeout(()=>{const b=new CustomEvent(L1,FO);a.addEventListener(L1,c),a.dispatchEvent(b),b.defaultPrevented||qa(v??document.body,{select:!0}),a.removeEventListener(L1,c),zO.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,A]=Tce(k);E&&A?!v.shiftKey&&b===A?(v.preventDefault(),n&&qa(E,{select:!0})):v.shiftKey&&b===E&&(v.preventDefault(),n&&qa(A,{select:!0})):b===k&&v.preventDefault()}},[n,r,m.paused]);return g.jsx(Xe.div,{tabIndex:-1,...o,ref:p,onKeyDown:y})});em.displayName=Ece;function Ace(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qa(r,{select:e}),document.activeElement!==n)return}function Tce(t){const e=iz(t),n=BO(e,t),r=BO(e.reverse(),t);return[n,r]}function iz(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 BO(t,e){for(const n of t)if(!Nce(n,{upTo:e}))return n}function Nce(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 _ce(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&&_ce(t)&&e&&t.select()}}var zO=Mce();function Mce(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=$O(t,e),t.unshift(e)},remove(e){var n;t=$O(t,e),(n=t[0])==null||n.resume()}}}function $O(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Pce(t){return t.filter(e=>e.tagName!=="A")}var Rce="Portal",tm=S.forwardRef((t,e)=>{var a;const{container:n,...r}=t,[i,s]=S.useState(!1);Nr(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?f3.createPortal(g.jsx(Xe.div,{...r,ref:e}),o):null});tm.displayName=Rce;var F1=0;function iv(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??VO()),document.body.insertAdjacentElement("beforeend",t[1]??VO()),F1++,()=>{F1===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),F1--}},[])}function VO(){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 sz(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 Oce(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 Vy="right-scroll-bar-position",Wy="width-before-scroll-bar",Dce="with-scroll-bars-hidden",Ice="--removed-body-scroll-bar-size";function B1(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function jce(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 Lce=typeof window<"u"?S.useLayoutEffect:S.useEffect,WO=new WeakMap;function Fce(t,e){var n=jce(null,function(r){return t.forEach(function(i){return B1(i,r)})});return Lce(function(){var r=WO.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||B1(a,null)}),s.forEach(function(a){i.has(a)||B1(a,o)})}WO.set(n,t)},[t]),n}function Bce(t){return t}function zce(t,e){e===void 0&&(e=Bce);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 $ce(t){t===void 0&&(t={});var e=zce(null);return e.options=Us({async:!0,ssr:!1},t),e}var oz=function(t){var e=t.sideCar,n=sz(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))};oz.isSideCarExport=!0;function Vce(t,e){return t.useMedium(e),oz}var az=$ce(),z1=function(){},sv=S.forwardRef(function(t,e){var n=S.useRef(null),r=S.useState({onScrollCapture:z1,onWheelCapture:z1,onTouchMoveCapture:z1}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,u=t.removeScrollBar,c=t.enabled,f=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=sz(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=p,_=Fce([n,e]),N=Us(Us({},E),i);return S.createElement(S.Fragment,null,c&&S.createElement(A,{sideCar:az,removeScrollBar:u,shards:f,noIsolation:m,inert:y,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:k}),o?S.cloneElement(S.Children.only(a),Us(Us({},N),{ref:_})):S.createElement(b,Us({},N,{className:l,ref:_}),a))});sv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sv.classNames={fullWidth:Wy,zeroRight:Vy};var Wce=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Hce(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=Wce();return e&&t.setAttribute("nonce",e),t}function Uce(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function qce(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var Yce=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Hce())&&(Uce(e,n),qce(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},Gce=function(){var t=Yce();return function(e,n){S.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},lz=function(){var t=Gce(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},Kce={left:0,top:0,right:0,gap:0},$1=function(t){return parseInt(t||"",10)||0},Zce=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[$1(n),$1(r),$1(i)]},Xce=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Kce;var e=Zce(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])}},Qce=lz(),jc="data-scroll-locked",Jce=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
253
253
  .`.concat(Dce,` {
@@ -302,7 +302,7 @@ Alternatively, you can use your own component as a description by assigning it a
302
302
  For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return S.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},Ffe=jz,Bfe=Lz,zfe=Fz,Gz=Bz,Kz=zz,Zz=Uz,Xz=Yz,Qz=Vz,Jz=Hz;const $fe=Ffe,Vfe=Bfe,e$=zfe;function ir({open:t,onOpenChange:e,children:n}){return g.jsx($fe,{open:t,onOpenChange:e,children:n})}const UT=S.forwardRef(({className:t,...e},n)=>g.jsx(Gz,{className:Te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:n}));UT.displayName=Gz.displayName;const t$=S.forwardRef(({className:t,...e},n)=>g.jsxs(e$,{children:[g.jsx(UT,{}),g.jsx(Kz,{ref:n,className:Te("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));t$.displayName=Kz.displayName;const n$=({className:t,...e})=>g.jsx("div",{className:Te("flex flex-col space-y-2 text-center sm:text-left",t),...e});n$.displayName="AlertDialogHeader";const r$=({className:t,...e})=>g.jsx("div",{className:Te("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});r$.displayName="AlertDialogFooter";const i$=S.forwardRef(({className:t,...e},n)=>g.jsx(Qz,{ref:n,className:Te("text-lg font-semibold",t),...e}));i$.displayName=Qz.displayName;const s$=S.forwardRef(({className:t,...e},n)=>g.jsx(Jz,{ref:n,className:Te("text-sm text-muted-foreground",t),...e}));s$.displayName=Jz.displayName;const o$=S.forwardRef(({className:t,...e},n)=>g.jsx(Zz,{ref:n,className:Te(Dc(),t),...e}));o$.displayName=Zz.displayName;const a$=S.forwardRef(({className:t,...e},n)=>g.jsx(Xz,{ref:n,className:Te(Dc({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));a$.displayName=Xz.displayName;ir.Trigger=Vfe;ir.Portal=e$;ir.Overlay=UT;ir.Content=t$;ir.Header=n$;ir.Footer=r$;ir.Title=i$;ir.Description=s$;ir.Action=o$;ir.Cancel=a$;const Wfe=["top","right","bottom","left"],ul=Math.min,ki=Math.max,Ex=Math.round,ty=Math.floor,no=t=>({x:t,y:t}),Hfe={left:"right",right:"left",bottom:"top",top:"bottom"},Ufe={start:"end",end:"start"};function FC(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 Bf(t){return t.split("-")[1]}function qT(t){return t==="x"?"y":"x"}function YT(t){return t==="y"?"height":"width"}function cl(t){return["top","bottom"].includes(ia(t))?"y":"x"}function GT(t){return qT(cl(t))}function qfe(t,e,n){n===void 0&&(n=!1);const r=Bf(t),i=GT(t),s=YT(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Ax(o)),[o,Ax(o)]}function Yfe(t){const e=Ax(t);return[BC(t),e,BC(e)]}function BC(t){return t.replace(/start|end/g,e=>Ufe[e])}function Gfe(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 Kfe(t,e,n,r){const i=Bf(t);let s=Gfe(ia(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(BC)))),s}function Ax(t){return t.replace(/left|right|bottom|top/g,e=>Hfe[e])}function Zfe(t){return{top:0,right:0,bottom:0,left:0,...t}}function l$(t){return typeof t!="number"?Zfe(t):{top:t,right:t,bottom:t,left:t}}function Tx(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 GO(t,e,n){let{reference:r,floating:i}=t;const s=cl(e),o=GT(e),a=YT(o),l=ia(e),u=s==="y",c=r.x+r.width/2-i.width/2,f=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:f};break;case"left":m={x:r.x-i.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Bf(e)){case"start":m[o]-=p*(n&&u?-1:1);break;case"end":m[o]+=p*(n&&u?-1:1);break}return m}const Xfe=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:f}=GO(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:A,reset:_}=await b({x:c,y:f,initialPlacement:r,placement:p,strategy:i,middlewareData:m,rects:u,platform:o,elements:{reference:t,floating:e}});c=k??c,f=E??f,m={...m,[w]:{...m[w],...A}},_&&y<=50&&(y++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(u=_.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):_.rects),{x:c,y:f}=GO(u,p,l)),v=-1)}return{x:c,y:f,placement:p,strategy:i,middlewareData:m}};async function Gh(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:f="floating",altBoundary:p=!1,padding:m=0}=ra(e,t),y=l$(m),w=a[p?f==="floating"?"reference":"floating":f],b=Tx(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=f==="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)),A=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},_=Tx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:k,offsetParent:E,strategy:l}):k);return{top:(b.top-_.top+y.top)/A.y,bottom:(_.bottom-b.bottom+y.bottom)/A.y,left:(b.left-_.left+y.left)/A.x,right:(_.right-b.right+y.right)/A.x}}const Qfe=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 f=l$(c),p={x:n,y:r},m=GT(i),y=YT(m),v=await o.getDimensions(u),w=m==="y",b=w?"top":"left",k=w?"bottom":"right",E=w?"clientHeight":"clientWidth",A=s.reference[y]+s.reference[m]-p[m]-s.floating[y],_=p[m]-s.reference[m],N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let M=N?N[E]:0;(!M||!await(o.isElement==null?void 0:o.isElement(N)))&&(M=a.floating[E]||s.floating[y]);const R=A/2-_/2,D=M/2-v[y]/2-1,O=ul(f[b],D),B=ul(f[k],D),F=O,V=M-v[y]-B,j=M/2-v[y]/2+R,Y=FC(F,j,V),W=!l.arrow&&Bf(i)!=null&&j!==Y&&s.reference[y]/2-(j<F?O:B)-v[y]/2<0,G=W?j<F?j-F:j-V:0;return{[m]:p[m]+G,data:{[m]:Y,centerOffset:j-Y-G,...W&&{alignmentOffset:G}},reset:W}}}),Jfe=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:f=!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,A=await(l.isRTL==null?void 0:l.isRTL(u.floating)),_=p||(E||!v?[Ax(a)]:Yfe(a)),N=y!=="none";!p&&N&&_.push(...Kfe(a,v,y,A));const M=[a,..._],R=await Gh(e,w),D=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(c&&D.push(R[b]),f){const j=qfe(i,o,A);D.push(R[j[0]],R[j[1]])}if(O=[...O,{placement:i,overflows:D}],!D.every(j=>j<=0)){var B,F;const j=(((B=s.flip)==null?void 0:B.index)||0)+1,Y=M[j];if(Y)return{data:{index:j,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(N){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 KO(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function ZO(t){return Wfe.some(e=>t[e]>=0)}const ede=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 Gh(e,{...i,elementContext:"reference"}),o=KO(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:ZO(o)}}}case"escaped":{const s=await Gh(e,{...i,altBoundary:!0}),o=KO(s,n.floating);return{data:{escapedOffsets:o,escaped:ZO(o)}}}default:return{}}}}};async function tde(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=Bf(n),l=cl(n)==="y",u=["left","top"].includes(o)?-1:1,c=s&&l?-1:1,f=ra(e,t);let{mainAxis:p,crossAxis:m,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.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 nde=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 tde(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}}}}},rde=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 Gh(e,l),f=cl(ia(i)),p=qT(f);let m=u[p],y=u[f];if(s){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",k=m+c[w],E=m-c[b];m=FC(k,m,E)}if(o){const w=f==="y"?"top":"left",b=f==="y"?"bottom":"right",k=y+c[w],E=y-c[b];y=FC(k,y,E)}const v=a.fn({...e,[p]:m,[f]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[p]:s,[f]:o}}}}}},ide=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},f=cl(i),p=qT(f);let m=c[p],y=c[f];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",A=s.reference[p]-s.floating[E]+w.mainAxis,_=s.reference[p]+s.reference[E]-w.mainAxis;m<A?m=A:m>_&&(m=_)}if(u){var b,k;const E=p==="y"?"width":"height",A=["top","left"].includes(ia(i)),_=s.reference[f]-s.floating[E]+(A&&((b=o.offset)==null?void 0:b[f])||0)+(A?0:w.crossAxis),N=s.reference[f]+s.reference[E]+(A?0:((k=o.offset)==null?void 0:k[f])||0)-(A?w.crossAxis:0);y<_?y=_:y>N&&(y=N)}return{[p]:m,[f]:y}}}},sde=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 Gh(e,u),f=ia(i),p=Bf(i),m=cl(i)==="y",{width:y,height:v}=s.floating;let w,b;f==="top"||f==="bottom"?(w=f,b=p===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=f,w=p==="end"?"top":"bottom");const k=v-c.top-c.bottom,E=y-c.left-c.right,A=ul(v-c[w],k),_=ul(y-c[b],E),N=!e.middlewareData.shift;let M=A,R=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(R=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=k),N&&!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 av(){return typeof window<"u"}function zf(t){return u$(t)?(t.nodeName||"").toLowerCase():"#document"}function Ni(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function xo(t){var e;return(e=(u$(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function u$(t){return av()?t instanceof Node||t instanceof Ni(t).Node:!1}function Ss(t){return av()?t instanceof Element||t instanceof Ni(t).Element:!1}function lo(t){return av()?t instanceof HTMLElement||t instanceof Ni(t).HTMLElement:!1}function XO(t){return!av()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ni(t).ShadowRoot}function rm(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 ode(t){return["table","td","th"].includes(zf(t))}function lv(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function KT(t){const e=ZT(),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 ade(t){let e=fl(t);for(;lo(e)&&!nf(e);){if(KT(e))return e;if(lv(e))return null;e=fl(e)}return null}function ZT(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function nf(t){return["html","body","#document"].includes(zf(t))}function Cs(t){return Ni(t).getComputedStyle(t)}function uv(t){return Ss(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function fl(t){if(zf(t)==="html")return t;const e=t.assignedSlot||t.parentNode||XO(t)&&t.host||xo(t);return XO(e)?e.host:e}function c$(t){const e=fl(t);return nf(e)?t.ownerDocument?t.ownerDocument.body:t.body:lo(e)&&rm(e)?e:c$(e)}function Kh(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=c$(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ni(i);if(s){const a=zC(o);return e.concat(o,o.visualViewport||[],rm(i)?i:[],a&&n?Kh(a):[])}return e.concat(i,Kh(i,[],n))}function zC(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function f$(t){const e=Cs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=lo(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=Ex(n)!==s||Ex(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function XT(t){return Ss(t)?t:t.contextElement}function Fc(t){const e=XT(t);if(!lo(e))return no(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=f$(e);let o=(s?Ex(n.width):n.width)/r,a=(s?Ex(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const lde=no(0);function d$(t){const e=Ni(t);return!ZT()||!e.visualViewport?lde:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ude(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ni(t)?!1:e}function pu(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=XT(t);let o=no(1);e&&(r?Ss(r)&&(o=Fc(r)):o=Fc(t));const a=ude(s,n,r)?d$(s):no(0);let l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,c=i.width/o.x,f=i.height/o.y;if(s){const p=Ni(s),m=r&&Ss(r)?Ni(r):r;let y=p,v=zC(y);for(;v&&r&&m!==y;){const w=Fc(v),b=v.getBoundingClientRect(),k=Cs(v),E=b.left+(v.clientLeft+parseFloat(k.paddingLeft))*w.x,A=b.top+(v.clientTop+parseFloat(k.paddingTop))*w.y;l*=w.x,u*=w.y,c*=w.x,f*=w.y,l+=E,u+=A,y=Ni(v),v=zC(y)}}return Tx({width:c,height:f,x:l,y:u})}function QT(t,e){const n=uv(t).scrollLeft;return e?e.left+n:pu(xo(t)).left+n}function h$(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:QT(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function cde(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=xo(r),a=e?lv(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=no(1);const c=no(0),f=lo(r);if((f||!f&&!s)&&((zf(r)!=="body"||rm(o))&&(l=uv(r)),lo(r))){const m=pu(r);u=Fc(r),c.x=m.x+r.clientLeft,c.y=m.y+r.clientTop}const p=o&&!f&&!s?h$(o,l,!0):no(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 fde(t){return Array.from(t.getClientRects())}function dde(t){const e=xo(t),n=uv(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+QT(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 hde(t,e){const n=Ni(t),r=xo(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=ZT();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function pde(t,e){const n=pu(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=lo(t)?Fc(t):no(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 QO(t,e,n){let r;if(e==="viewport")r=hde(t,n);else if(e==="document")r=dde(xo(t));else if(Ss(e))r=pde(e,n);else{const i=d$(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Tx(r)}function p$(t,e){const n=fl(t);return n===e||!Ss(n)||nf(n)?!1:Cs(n).position==="fixed"||p$(n,e)}function mde(t,e){const n=e.get(t);if(n)return n;let r=Kh(t,[],!1).filter(a=>Ss(a)&&zf(a)!=="body"),i=null;const s=Cs(t).position==="fixed";let o=s?fl(t):t;for(;Ss(o)&&!nf(o);){const a=Cs(o),l=KT(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||rm(o)&&!l&&p$(t,o))?r=r.filter(c=>c!==o):i=a,o=fl(o)}return e.set(t,r),r}function gde(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?lv(e)?[]:mde(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((u,c)=>{const f=QO(e,c,i);return u.top=ki(f.top,u.top),u.right=ul(f.right,u.right),u.bottom=ul(f.bottom,u.bottom),u.left=ki(f.left,u.left),u},QO(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function yde(t){const{width:e,height:n}=f$(t);return{width:e,height:n}}function xde(t,e,n){const r=lo(e),i=xo(e),s=n==="fixed",o=pu(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=no(0);if(r||!r&&!s)if((zf(e)!=="body"||rm(i))&&(a=uv(e)),r){const p=pu(e,!0,s,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else i&&(l.x=QT(i));const u=i&&!r&&!s?h$(i,a):no(0),c=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:c,y:f,width:o.width,height:o.height}}function W1(t){return Cs(t).position==="static"}function JO(t,e){if(!lo(t)||Cs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return xo(t)===n&&(n=n.ownerDocument.body),n}function m$(t,e){const n=Ni(t);if(lv(t))return n;if(!lo(t)){let i=fl(t);for(;i&&!nf(i);){if(Ss(i)&&!W1(i))return i;i=fl(i)}return n}let r=JO(t,e);for(;r&&ode(r)&&W1(r);)r=JO(r,e);return r&&nf(r)&&W1(r)&&!KT(r)?n:r||ade(t)||n}const vde=async function(t){const e=this.getOffsetParent||m$,n=this.getDimensions,r=await n(t.floating);return{reference:xde(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wde(t){return Cs(t).direction==="rtl"}const bde={convertOffsetParentRelativeRectToViewportRelativeRect:cde,getDocumentElement:xo,getClippingRect:gde,getOffsetParent:m$,getElementRects:vde,getClientRects:fde,getDimensions:yde,getScale:Fc,isElement:Ss,isRTL:wde};function g$(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function kde(t,e){let n=null,r;const i=xo(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:f,width:p,height:m}=u;if(a||e(),!p||!m)return;const y=ty(f),v=ty(i.clientWidth-(c+p)),w=ty(i.clientHeight-(f+m)),b=ty(c),E={rootMargin:-y+"px "+-v+"px "+-w+"px "+-b+"px",threshold:ki(0,ul(1,l))||1};let A=!0;function _(N){const M=N[0].intersectionRatio;if(M!==l){if(!A)return o();M?o(!1,M):r=setTimeout(()=>{o(!1,1e-7)},1e3)}M===1&&!g$(u,t.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(_,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(_,E)}n.observe(t)}return o(!0),s}function Sde(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=XT(t),c=i||s?[...u?Kh(u):[],...Kh(e)]:[];c.forEach(b=>{i&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const f=u&&a?kde(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?pu(t):null;l&&w();function w(){const b=pu(t);v&&!g$(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)}),f==null||f(),(b=m)==null||b.disconnect(),m=null,l&&cancelAnimationFrame(y)}}const Cde=nde,Ede=rde,Ade=Jfe,Tde=sde,Nde=ede,eD=Qfe,_de=ide,Mde=(t,e,n)=>{const r=new Map,i={platform:bde,...n},s={...i.platform,_c:r};return Xfe(t,e,{...i,platform:s})};var Hy=typeof document<"u"?S.useLayoutEffect:S.useEffect;function Nx(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(!Nx(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)&&!Nx(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function y$(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function tD(t,e){const n=y$(t);return Math.round(e*n)/n}function H1(t){const e=S.useRef(t);return Hy(()=>{e.current=t}),e}function Pde(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,f]=S.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[p,m]=S.useState(r);Nx(p,r)||m(r);const[y,v]=S.useState(null),[w,b]=S.useState(null),k=S.useCallback(H=>{H!==N.current&&(N.current=H,v(H))},[]),E=S.useCallback(H=>{H!==M.current&&(M.current=H,b(H))},[]),A=s||y,_=o||w,N=S.useRef(null),M=S.useRef(null),R=S.useRef(c),D=l!=null,O=H1(l),B=H1(i),F=H1(u),V=S.useCallback(()=>{if(!N.current||!M.current)return;const H={placement:e,strategy:n,middleware:p};B.current&&(H.platform=B.current),Mde(N.current,M.current,H).then($=>{const L={...$,isPositioned:F.current!==!1};j.current&&!Nx(R.current,L)&&(R.current=L,Pf.flushSync(()=>{f(L)}))})},[p,e,n,B,F]);Hy(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(H=>({...H,isPositioned:!1})))},[u]);const j=S.useRef(!1);Hy(()=>(j.current=!0,()=>{j.current=!1}),[]),Hy(()=>{if(A&&(N.current=A),_&&(M.current=_),A&&_){if(O.current)return O.current(A,_,V);V()}},[A,_,V,O,D]);const Y=S.useMemo(()=>({reference:N,floating:M,setReference:k,setFloating:E}),[k,E]),W=S.useMemo(()=>({reference:A,floating:_}),[A,_]),G=S.useMemo(()=>{const H={position:n,left:0,top:0};if(!W.floating)return H;const $=tD(W.floating,c.x),L=tD(W.floating,c.y);return a?{...H,transform:"translate("+$+"px, "+L+"px)",...y$(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 Rde=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?eD({element:r.current,padding:i}).fn(n):{}:r?eD({element:r,padding:i}).fn(n):{}}}},Ode=(t,e)=>({...Cde(t),options:[t,e]}),Dde=(t,e)=>({...Ede(t),options:[t,e]}),Ide=(t,e)=>({..._de(t),options:[t,e]}),jde=(t,e)=>({...Ade(t),options:[t,e]}),Lde=(t,e)=>({...Tde(t),options:[t,e]}),Fde=(t,e)=>({...Nde(t),options:[t,e]}),Bde=(t,e)=>({...Rde(t),options:[t,e]});var zde="Arrow",x$=S.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return g.jsx(Xe.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"})})});x$.displayName=zde;var $de=x$;function v$(t){const[e,n]=S.useState(void 0);return Nr(()=>{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 JT="Popper",[w$,$f]=ts(JT),[Vde,b$]=w$(JT),k$=t=>{const{__scopePopper:e,children:n}=t,[r,i]=S.useState(null);return g.jsx(Vde,{scope:e,anchor:r,onAnchorChange:i,children:n})};k$.displayName=JT;var S$="PopperAnchor",C$=S.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=b$(S$,n),o=S.useRef(null),a=St(e,o);return S.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:g.jsx(Xe.div,{...i,ref:a})});C$.displayName=S$;var eN="PopperContent",[Wde,Hde]=w$(eN),E$=S.forwardRef((t,e)=>{var ee,se,fe,pe,Ae,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:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:y,...v}=t,w=b$(eN,n),[b,k]=S.useState(null),E=St(e,we=>k(we)),[A,_]=S.useState(null),N=v$(A),M=(N==null?void 0:N.width)??0,R=(N==null?void 0:N.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(qde),altBoundary:F},{refs:j,floatingStyles:Y,placement:W,isPositioned:G,middlewareData:H}=Pde({strategy:"fixed",placement:D,whileElementsMounted:(...we)=>Sde(...we,{animationFrame:m==="always"}),elements:{reference:w.anchor},middleware:[Ode({mainAxis:i+R,alignmentAxis:o}),l&&Dde({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ide():void 0,...V}),l&&jde({...V}),Lde({...V,apply:({elements:we,rects:je,availableWidth:Ke,availableHeight:ht})=>{const{width:zt,height:Q}=je.reference,oe=we.floating.style;oe.setProperty("--radix-popper-available-width",`${Ke}px`),oe.setProperty("--radix-popper-available-height",`${ht}px`),oe.setProperty("--radix-popper-anchor-width",`${zt}px`),oe.setProperty("--radix-popper-anchor-height",`${Q}px`)}}),A&&Bde({element:A,padding:a}),Yde({arrowWidth:M,arrowHeight:R}),p&&Fde({strategy:"referenceHidden",...V})]}),[$,L]=N$(W),q=jn(y);Nr(()=>{G&&(q==null||q())},[G,q]);const U=(ee=H.arrow)==null?void 0:ee.x,I=(se=H.arrow)==null?void 0:se.y,K=((fe=H.arrow)==null?void 0:fe.centerOffset)!==0,[Z,J]=S.useState();return Nr(()=>{b&&J(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:G?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(pe=H.transformOrigin)==null?void 0:pe.x,(Ae=H.transformOrigin)==null?void 0:Ae.y].join(" "),...((he=H.hide)==null?void 0:he.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(Wde,{scope:n,placedSide:$,onArrowChange:_,arrowX:U,arrowY:I,shouldHideArrow:K,children:g.jsx(Xe.div,{"data-side":$,"data-align":L,...v,ref:E,style:{...v.style,animation:G?void 0:"none"}})})})});E$.displayName=eN;var A$="PopperArrow",Ude={top:"bottom",right:"left",bottom:"top",left:"right"},T$=S.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=Hde(A$,r),o=Ude[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($de,{...i,ref:n,style:{...i.style,display:"block"}})})});T$.displayName=A$;function qde(t){return t!==null}var Yde=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]=N$(n),f={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?f:`${p}px`,v=`${-l}px`):u==="top"?(y=o?f:`${p}px`,v=`${r.floating.height+l}px`):u==="right"?(y=`${-l}px`,v=o?f:`${m}px`):u==="left"&&(y=`${r.floating.width+l}px`,v=o?f:`${m}px`),{data:{x:y,y:v}}}});function N$(t){const[e,n="center"]=t.split("-");return[e,n]}var cv=k$,fv=C$,tN=E$,nN=T$,$C=["Enter"," "],Gde=["ArrowDown","PageUp","Home"],_$=["ArrowUp","PageDown","End"],Kde=[...Gde,..._$],Zde={ltr:[...$C,"ArrowRight"],rtl:[...$C,"ArrowLeft"]},Xde={ltr:["ArrowLeft"],rtl:["ArrowRight"]},im="Menu",[Zh,Qde,Jde]=LT(im),[Pu,M$]=ts(im,[Jde,$f,nv]),sm=$f(),P$=nv(),[R$,El]=Pu(im),[ehe,om]=Pu(im),O$=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=sm(e),[l,u]=S.useState(null),c=S.useRef(!1),f=jn(s),p=Up(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(cv,{...a,children:g.jsx(R$,{scope:e,open:n,onOpenChange:f,content:l,onContentChange:u,children:g.jsx(ehe,{scope:e,onClose:S.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:c,dir:p,modal:o,children:r})})})};O$.displayName=im;var the="MenuAnchor",rN=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=sm(n);return g.jsx(fv,{...i,...r,ref:e})});rN.displayName=the;var iN="MenuPortal",[nhe,D$]=Pu(iN,{forceMount:void 0}),I$=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=El(iN,e);return g.jsx(nhe,{scope:e,forceMount:n,children:g.jsx(qr,{present:n||s.open,children:g.jsx(tm,{asChild:!0,container:i,children:r})})})};I$.displayName=iN;var Zi="MenuContent",[rhe,sN]=Pu(Zi),j$=S.forwardRef((t,e)=>{const n=D$(Zi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=El(Zi,t.__scopeMenu),o=om(Zi,t.__scopeMenu);return g.jsx(Zh.Provider,{scope:t.__scopeMenu,children:g.jsx(qr,{present:r||s.open,children:g.jsx(Zh.Slot,{scope:t.__scopeMenu,children:o.modal?g.jsx(ihe,{...i,ref:e}):g.jsx(she,{...i,ref:e})})})})}),ihe=S.forwardRef((t,e)=>{const n=El(Zi,t.__scopeMenu),r=S.useRef(null),i=St(e,r);return S.useEffect(()=>{const s=r.current;if(s)return ov(s)},[]),g.jsx(oN,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ie(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),she=S.forwardRef((t,e)=>{const n=El(Zi,t.__scopeMenu);return g.jsx(oN,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),oN=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:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:y,...v}=t,w=El(Zi,n),b=om(Zi,n),k=sm(n),E=P$(n),A=Qde(n),[_,N]=S.useState(null),M=S.useRef(null),R=St(e,M,w.onContentChange),D=S.useRef(0),O=S.useRef(""),B=S.useRef(0),F=S.useRef(null),V=S.useRef("right"),j=S.useRef(0),Y=y?nm:S.Fragment,W=y?{as:ao,allowPinchZoom:!0}:void 0,G=$=>{var ee,se;const L=O.current+$,q=A().filter(fe=>!fe.disabled),U=document.activeElement,I=(ee=q.find(fe=>fe.ref.current===U))==null?void 0:ee.textValue,K=q.map(fe=>fe.textValue),Z=yhe(K,L,I),J=(se=q.find(fe=>fe.textValue===Z))==null?void 0:se.ref.current;(function fe(pe){O.current=pe,window.clearTimeout(D.current),pe!==""&&(D.current=window.setTimeout(()=>fe(""),1e3))})(L),J&&setTimeout(()=>J.focus())};S.useEffect(()=>()=>window.clearTimeout(D.current),[]),iv();const H=S.useCallback($=>{var q,U;return V.current===((q=F.current)==null?void 0:q.side)&&vhe($,(U=F.current)==null?void 0:U.area)},[]);return g.jsx(rhe,{scope:n,searchRef:O,onItemEnter:S.useCallback($=>{H($)&&$.preventDefault()},[H]),onItemLeave:S.useCallback($=>{var L;H($)||((L=M.current)==null||L.focus(),N(null))},[H]),onTriggerLeave:S.useCallback($=>{H($)&&$.preventDefault()},[H]),pointerGraceTimerRef:B,onPointerGraceIntentChange:S.useCallback($=>{F.current=$},[]),children:g.jsx(Y,{...W,children:g.jsx(em,{asChild:!0,trapped:i,onMountAutoFocus:Ie(s,$=>{var L;$.preventDefault(),(L=M.current)==null||L.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx(Jp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:g.jsx(zB,{asChild:!0,...E,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:_,onCurrentTabStopIdChange:N,onEntryFocus:Ie(l,$=>{b.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(tN,{role:"menu","aria-orientation":"vertical","data-state":J$(w.open),"data-radix-menu-content":"",dir:b.dir,...k,...v,ref:R,style:{outline:"none",...v.style},onKeyDown:Ie(v.onKeyDown,$=>{const q=$.target.closest("[data-radix-menu-content]")===$.currentTarget,U=$.ctrlKey||$.altKey||$.metaKey,I=$.key.length===1;q&&($.key==="Tab"&&$.preventDefault(),!U&&I&&G($.key));const K=M.current;if($.target!==K||!Kde.includes($.key))return;$.preventDefault();const J=A().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);_$.includes($.key)&&J.reverse(),mhe(J)}),onBlur:Ie(t.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(D.current),O.current="")}),onPointerMove:Ie(t.onPointerMove,Xh($=>{const L=$.target,q=j.current!==$.clientX;if($.currentTarget.contains(L)&&q){const U=$.clientX>j.current?"right":"left";V.current=U,j.current=$.clientX}}))})})})})})})});j$.displayName=Zi;var ohe="MenuGroup",aN=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{role:"group",...r,ref:e})});aN.displayName=ohe;var ahe="MenuLabel",L$=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{...r,ref:e})});L$.displayName=ahe;var _x="MenuItem",nD="menu.itemSelect",dv=S.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=S.useRef(null),o=om(_x,t.__scopeMenu),a=sN(_x,t.__scopeMenu),l=St(e,s),u=S.useRef(!1),c=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(nD,{bubbles:!0,cancelable:!0});f.addEventListener(nD,m=>r==null?void 0:r(m),{once:!0}),E3(f,p),p.defaultPrevented?u.current=!1:o.onClose()}};return g.jsx(F$,{...i,ref:l,disabled:n,onClick:Ie(t.onClick,c),onPointerDown:f=>{var p;(p=t.onPointerDown)==null||p.call(t,f),u.current=!0},onPointerUp:Ie(t.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:Ie(t.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||$C.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});dv.displayName=_x;var F$=S.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=sN(_x,n),a=P$(n),l=S.useRef(null),u=St(e,l),[c,f]=S.useState(!1),[p,m]=S.useState("");return S.useEffect(()=>{const y=l.current;y&&m((y.textContent??"").trim())},[s.children]),g.jsx(Zh.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:g.jsx($B,{asChild:!0,...a,focusable:!r,children:g.jsx(Xe.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:Ie(t.onPointerMove,Xh(y=>{r?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ie(t.onPointerLeave,Xh(y=>o.onItemLeave(y))),onFocus:Ie(t.onFocus,()=>f(!0)),onBlur:Ie(t.onBlur,()=>f(!1))})})})}),lhe="MenuCheckboxItem",B$=S.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return g.jsx(H$,{scope:t.__scopeMenu,checked:n,children:g.jsx(dv,{role:"menuitemcheckbox","aria-checked":Mx(n)?"mixed":n,...i,ref:e,"data-state":cN(n),onSelect:Ie(i.onSelect,()=>r==null?void 0:r(Mx(n)?!0:!n),{checkForDefaultPrevented:!1})})})});B$.displayName=lhe;var z$="MenuRadioGroup",[uhe,che]=Pu(z$,{value:void 0,onValueChange:()=>{}}),$$=S.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=jn(r);return g.jsx(uhe,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(aN,{...i,ref:e})})});$$.displayName=z$;var V$="MenuRadioItem",W$=S.forwardRef((t,e)=>{const{value:n,...r}=t,i=che(V$,t.__scopeMenu),s=n===i.value;return g.jsx(H$,{scope:t.__scopeMenu,checked:s,children:g.jsx(dv,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":cN(s),onSelect:Ie(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});W$.displayName=V$;var lN="MenuItemIndicator",[H$,fhe]=Pu(lN,{checked:!1}),U$=S.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=fhe(lN,n);return g.jsx(qr,{present:r||Mx(s.checked)||s.checked===!0,children:g.jsx(Xe.span,{...i,ref:e,"data-state":cN(s.checked)})})});U$.displayName=lN;var dhe="MenuSeparator",q$=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});q$.displayName=dhe;var hhe="MenuArrow",Y$=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=sm(n);return g.jsx(nN,{...i,...r,ref:e})});Y$.displayName=hhe;var uN="MenuSub",[phe,G$]=Pu(uN),K$=t=>{const{__scopeMenu:e,children:n,open:r=!1,onOpenChange:i}=t,s=El(uN,e),o=sm(e),[a,l]=S.useState(null),[u,c]=S.useState(null),f=jn(i);return S.useEffect(()=>(s.open===!1&&f(!1),()=>f(!1)),[s.open,f]),g.jsx(cv,{...o,children:g.jsx(R$,{scope:e,open:r,onOpenChange:f,content:u,onContentChange:c,children:g.jsx(phe,{scope:e,contentId:Xn(),triggerId:Xn(),trigger:a,onTriggerChange:l,children:n})})})};K$.displayName=uN;var nh="MenuSubTrigger",Z$=S.forwardRef((t,e)=>{const n=El(nh,t.__scopeMenu),r=om(nh,t.__scopeMenu),i=G$(nh,t.__scopeMenu),s=sN(nh,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 f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),g.jsx(rN,{asChild:!0,...u,children:g.jsx(F$,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":J$(n.open),...t,ref:L0(e,i.onTriggerChange),onClick:f=>{var p;(p=t.onClick)==null||p.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ie(t.onPointerMove,Xh(f=>{s.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:Ie(t.onPointerLeave,Xh(f=>{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:f.clientX+b,y:f.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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Ie(t.onKeyDown,f=>{var m;const p=s.searchRef.current!=="";t.disabled||p&&f.key===" "||Zde[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});Z$.displayName=nh;var X$="MenuSubContent",Q$=S.forwardRef((t,e)=>{const n=D$(Zi,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=El(Zi,t.__scopeMenu),o=om(Zi,t.__scopeMenu),a=G$(X$,t.__scopeMenu),l=S.useRef(null),u=St(e,l);return g.jsx(Zh.Provider,{scope:t.__scopeMenu,children:g.jsx(qr,{present:r||s.open,children:g.jsx(Zh.Slot,{scope:t.__scopeMenu,children:g.jsx(oN,{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 f;o.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:Ie(t.onFocusOutside,c=>{c.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Ie(t.onEscapeKeyDown,c=>{o.onClose(),c.preventDefault()}),onKeyDown:Ie(t.onKeyDown,c=>{var m;const f=c.currentTarget.contains(c.target),p=Xde[o.dir].includes(c.key);f&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),c.preventDefault())})})})})})});Q$.displayName=X$;function J$(t){return t?"open":"closed"}function Mx(t){return t==="indeterminate"}function cN(t){return Mx(t)?"indeterminate":t?"checked":"unchecked"}function mhe(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function ghe(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function yhe(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=ghe(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 xhe(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 vhe(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return xhe(n,e)}function Xh(t){return e=>e.pointerType==="mouse"?t(e):void 0}var whe=O$,bhe=rN,khe=I$,She=j$,Che=aN,Ehe=L$,Ahe=dv,The=B$,Nhe=$$,_he=W$,Mhe=U$,Phe=q$,Rhe=Y$,Ohe=K$,Dhe=Z$,Ihe=Q$,fN="DropdownMenu",[jhe,PIe]=ts(fN,[M$]),Rr=M$(),[Lhe,eV]=jhe(fN),tV=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=t,l=Rr(e),u=S.useRef(null),[c=!1,f]=na({prop:i,defaultProp:s,onChange:o});return g.jsx(Lhe,{scope:e,triggerId:Xn(),triggerRef:u,contentId:Xn(),open:c,onOpenChange:f,onOpenToggle:S.useCallback(()=>f(p=>!p),[f]),modal:a,children:g.jsx(whe,{...l,open:c,onOpenChange:f,dir:r,modal:a,children:n})})};tV.displayName=fN;var nV="DropdownMenuTrigger",rV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=eV(nV,n),o=Rr(n);return g.jsx(bhe,{asChild:!0,...o,children:g.jsx(Xe.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:L0(e,s.triggerRef),onPointerDown:Ie(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Ie(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});rV.displayName=nV;var Fhe="DropdownMenuPortal",iV=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Rr(e);return g.jsx(khe,{...r,...n})};iV.displayName=Fhe;var sV="DropdownMenuContent",oV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=eV(sV,n),s=Rr(n),o=S.useRef(!1);return g.jsx(She,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:e,onCloseAutoFocus:Ie(t.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Ie(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)"}})});oV.displayName=sV;var Bhe="DropdownMenuGroup",aV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Che,{...i,...r,ref:e})});aV.displayName=Bhe;var zhe="DropdownMenuLabel",lV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Ehe,{...i,...r,ref:e})});lV.displayName=zhe;var $he="DropdownMenuItem",uV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Ahe,{...i,...r,ref:e})});uV.displayName=$he;var Vhe="DropdownMenuCheckboxItem",cV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(The,{...i,...r,ref:e})});cV.displayName=Vhe;var Whe="DropdownMenuRadioGroup",fV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Nhe,{...i,...r,ref:e})});fV.displayName=Whe;var Hhe="DropdownMenuRadioItem",dV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(_he,{...i,...r,ref:e})});dV.displayName=Hhe;var Uhe="DropdownMenuItemIndicator",hV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Mhe,{...i,...r,ref:e})});hV.displayName=Uhe;var qhe="DropdownMenuSeparator",pV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Phe,{...i,...r,ref:e})});pV.displayName=qhe;var Yhe="DropdownMenuArrow",Ghe=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Rhe,{...i,...r,ref:e})});Ghe.displayName=Yhe;var Khe=t=>{const{__scopeDropdownMenu:e,children:n,open:r,onOpenChange:i,defaultOpen:s}=t,o=Rr(e),[a=!1,l]=na({prop:r,defaultProp:s,onChange:i});return g.jsx(Ohe,{...o,open:a,onOpenChange:l,children:n})},Zhe="DropdownMenuSubTrigger",mV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Dhe,{...i,...r,ref:e})});mV.displayName=Zhe;var Xhe="DropdownMenuSubContent",gV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=Rr(n);return g.jsx(Ihe,{...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)"}})});gV.displayName=Xhe;var Qhe=tV,yV=rV,xV=iV,vV=oV,Jhe=aV,wV=lV,bV=uV,kV=cV,epe=fV,SV=dV,CV=hV,EV=pV,tpe=Khe,AV=mV,TV=gV;function dc(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`,`
303
303
  font-size: .6rem;
304
304
  font-weight: bold;
305
- 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 U1(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const npe=(t,e)=>Math.abs(t-e)<1,rpe=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},ipe=t=>t,spe=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},ope=(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)}},rD={passive:!0},ape=typeof window>"u"?!0:"onscrollend"in window,lpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&ape?()=>{}:rpe(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:c,isRtl:f}=t.options;i=c?n.scrollLeft*(f&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);return l(),n.addEventListener("scroll",a,rD),n.addEventListener("scrollend",l,rD),()=>{n.removeEventListener("scroll",a),n.removeEventListener("scrollend",l)}},upe=(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"])},cpe=(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 fpe{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:ipe,rangeExtractor:spe,onChange:()=>{},measureElement:upe,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=dc(()=>(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=dc(()=>[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=dc(()=>[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 f=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(f),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:f,lane:b}}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=dc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?dpe({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getIndexes=dc(()=>{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=dc(()=>[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 U1(r[NV(0,r.length-1,i=>U1(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]=U1(this.getOffsetForIndex(n,a));npe(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 NV=(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 dpe({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=NV(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 iD=typeof document<"u"?S.useLayoutEffect:S.useEffect;function hpe(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Pf.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new fpe(n));return r.setOptions(n),iD(()=>r._didMount(),[]),iD(()=>r._willUpdate()),r}function ppe(t){return hpe({observeElementRect:ope,observeElementOffset:lpe,scrollToFn:cpe,...t})}const mpe=Qhe,gpe=Jhe,ype=xV,xpe=tpe,vpe=epe,_V=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx(yV,{ref:i,className:Te("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));_V.displayName=yV.displayName;const MV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(AV,{ref:i,className:Te("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(Kc,{className:"ml-auto -rotate-90"})]}));MV.displayName=AV.displayName;const PV=S.forwardRef(({className:t,...e},n)=>g.jsx(TV,{ref:n,className:Te("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}));PV.displayName=TV.displayName;const RV=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(xV,{container:e,children:g.jsx(vV,{ref:i,sideOffset:n,className:Te("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})}));RV.displayName=vV.displayName;const OV=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(bV,{ref:r,className:Te("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}));OV.displayName=bV.displayName;const DV=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(kV,{ref:i,className:Te("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(CV,{children:g.jsx(TA,{className:"h-2 w-2 fill-current"})})}),e]}));DV.displayName=kV.displayName;const IV=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(SV,{ref:r,className:Te("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(CV,{children:g.jsx(ZK,{className:"h-2 w-2 fill-current"})})}),e]}));IV.displayName=SV.displayName;const jV=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(wV,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));jV.displayName=wV.displayName;const LV=S.forwardRef(({className:t,...e},n)=>g.jsx(EV,{ref:n,className:Te("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));LV.displayName=EV.displayName;const FV=({className:t,...e})=>g.jsx("span",{className:Te("ml-auto text-xs tracking-widest opacity-60",t),...e});FV.displayName="DropdownMenuShortcut";function Gn({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(mpe,{modal:r,open:t,onOpenChange:e,children:n})}function wpe({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=ppe({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))})})}Gn.Trigger=_V;Gn.Content=RV;Gn.Group=gpe;Gn.Portal=ype;Gn.Item=OV;Gn.CheckboxItem=DV;Gn.RadioItem=IV;Gn.Label=jV;Gn.Separator=LV;Gn.Shortcut=FV;Gn.Sub=xpe;Gn.SubContent=PV;Gn.SubTrigger=MV;Gn.RadioGroup=vpe;Gn.VirtualizedItems=wpe;const bpe=t=>{const{data:e,isLoading:n,mutate:r}=LA(`/api/memory/status?agentId=${t}`,_A,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},kpe=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=LA(`/api/memory/threads?resourceid=${t}&agentId=${e}`,_A,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},Spe=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=LA(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>_A(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}},Cpe=()=>{const{mutate:t}=jA();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"}});bn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function Epe({agentId:t,threadId:e}){const{threads:n,isLoading:r}=kpe({resourceid:t,agentId:t}),{deleteThread:i}=Cpe(),s=mo(),[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(Zn,{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(At,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Fh,{})})]}),n.map(f=>{const p=f.id===e;return g.jsxs("div",{className:Te("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(Hp,{to:`/agents/${t}/chat/${f.id}`,className:"flex-1",children:g.jsx("p",{className:Te("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",p?"text-mastra-el-6":""),children:f.title})}),g.jsxs(Gn,{children:[g.jsx(Gn.Trigger,{asChild:!0,children:g.jsxs(At,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(eZ,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(Gn.Content,{children:g.jsxs(Gn.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(f.id),u(!0)},children:[g.jsx(oZ,{}),g.jsx("span",{children:"Delete"})]})})]})]},f.id)})]}),g.jsx(ir,{open:l,onOpenChange:u,children:g.jsxs(ir.Content,{children:[g.jsxs(ir.Header,{children:[g.jsx(ir.Title,{children:"Are you absolutely sure?"}),g.jsx(ir.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(ir.Footer,{children:[g.jsx(ir.Cancel,{children:"Cancel"}),g.jsx(ir.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(At,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Fh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function sD(){const{agentId:t,threadId:e}=fa(),{agent:n,isLoading:r}=Of(t),{memory:i}=bpe(t),s=mo(),{messages:o,isLoading:a}=Spe({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(Sx,{agentId:t})})]}):g.jsxs("main",{className:Te("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(Epe,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(At,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>u(!l),children:g.jsx(rZ,{})}):null,g.jsx(Xue,{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(Sx,{agentId:t})})]})}const oD=(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),bn.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),bn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}};function Ape({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=oD(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=oD(t,"ci"),u=()=>{e==="live"?s():l()};return g.jsx("div",{className:"flex-1 relative overflow-hidden",children:g.jsx("div",{className:"flex justify-between sticky top-0 bg-mastra-bg-2 p-4",children:g.jsxs(zT,{value:e,onValueChange:c=>n(c),className:"w-full",children:[g.jsxs(rv,{children:[g.jsx(Yo,{value:"live",className:"mr-4",children:"Live"}),g.jsx(Yo,{value:"ci",children:"CI"})]}),g.jsx("div",{className:"flex justify-end my-2",children:g.jsx(At,{variant:"outline",onClick:u,disabled:e==="live"?i:a,children:(e==="live"?i:a)?g.jsx(Zc,{className:"w-4 h-4 animate-spin"}):g.jsx(Zc,{className:"w-4 h-4"})})}),g.jsxs(Zn,{className:"rounded-lg h-[calc(100vh-180px)]",children:[g.jsx(Go,{value:"live",className:"mt-0",children:g.jsx(aD,{showTestName:!1,evals:r,isLoading:i})}),g.jsx(Go,{value:"ci",className:"mt-0",children:g.jsx(aD,{showTestName:!0,evals:o,isLoading:a})})]})]})})})}function aD({showTestName:t=!1,evals:e,isLoading:n}){const[r,i]=S.useState(new Set),s=a=>{const l=new Set(r);l.has(a)?l.delete(a):l.add(a),i(l)},o=a=>a.reduce((l,u)=>{const c=l.find(f=>f.metricName===u.metricName);return c?(c.evals.push(u),c.averageScore=c.evals.reduce((f,p)=>f+p.result.score,0)/c.evals.length):l.push({metricName:u.metricName,averageScore:u.result.score,evals:[u]}),l},[]);return g.jsxs(Qo,{children:[g.jsx(Jo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(vn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(Nt,{className:"w-[50px]"}),g.jsx(Nt,{className:"w-[300px] text-mastra-el-3",children:"Metric"}),g.jsx(Nt,{className:"w-[600px] text-mastra-el-3"}),g.jsx(Nt,{className:"w-[200px] text-mastra-el-3",children:"Average Score"}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Total Evaluations"})]})}),g.jsx(ea,{className:"border-b border-gray-6",children:n?g.jsxs(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(nt,{className:"w-[50px]",children:g.jsx(He,{className:"h-8 w-8"})}),g.jsx(nt,{className:"w-[400px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{className:"w-[400px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{className:"w-[200px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{children:g.jsx(He,{className:"h-8 w-full"})})]}):o(e).map(a=>g.jsxs(g.Fragment,{children:[g.jsxs(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>s(a.metricName),children:[g.jsx(nt,{className:"w-[50px]",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:r.has(a.metricName)?g.jsx(Kc,{className:"h-4 w-4 text-mastra-el-5"}):g.jsx(KK,{className:"h-4 w-4 text-mastra-el-5"})})}),g.jsx(nt,{className:"w-[300px] font-medium text-mastra-el-5",children:a.metricName}),g.jsx(nt,{className:"w-[600px] text-mastra-el-5"}),g.jsx(nt,{className:"w-[200px] text-mastra-el-5",children:a.averageScore.toFixed(2)}),g.jsx(nt,{className:"text-mastra-el-5",children:a.evals.length})]},a.metricName),r.has(a.metricName)&&g.jsxs(g.Fragment,{children:[g.jsxs(vn,{className:"bg-mastra-bg-3 text-[0.7rem] text-mastra-el-3",children:[g.jsx(nt,{className:"w-[50px]"}),g.jsx(nt,{className:"w-[300px] pl-8",children:"Timestamp"}),g.jsx(nt,{className:"w-[600px] pl-8",children:"Input"}),g.jsx(nt,{className:"w-[200px]",children:"Score"}),t&&g.jsx(nt,{children:"Test Name"})]}),a.evals.map((l,u)=>{var c;return g.jsxs(vn,{className:"bg-mastra-bg-3 text-[0.8125rem]",children:[g.jsx(nt,{className:"w-[50px]"}),g.jsx(nt,{className:"w-[300px] text-mastra-el-4 pl-8",children:new Date(l.createdAt).toLocaleString()}),g.jsx(nt,{className:"w-[600px] text-mastra-el-4",children:l.input}),g.jsx(nt,{className:"w-[200px] text-mastra-el-4",children:l.result.score}),t&&g.jsx(nt,{className:"text-mastra-el-4",children:(c=l==null?void 0:l.testInfo)==null?void 0:c.testName})]},`${a.metricName}-${u}`)})]})]}))})]})}function Tpe(){const{agentId:t}=fa();return g.jsx("main",{className:"flex-1",children:g.jsx(Ape,{agentId:t})})}function Npe({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,f]=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]),A=S.useCallback(()=>{console.log("startPolling"),a(!0),u(null)},[]),_=S.useCallback(async(N=!1)=>{if(b.current){m(!0),v(N);try{const M=await t();f(M),u(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(_,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&&_(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,_,k]),{isPolling:o,isLoading:p,error:l,data:c,startPolling:A,stopPolling:E,firstCallLoading:y}}function dN(t,e=2){return(t/1e3).toFixed(e)}function BV(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 _pe(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 Mpe(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function lD(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const Ppe=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}})},zV=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 Ppe((c==null?void 0:c.traces)||[])}catch(u){throw u}},[t]),i=S.useCallback(u=>{u.length>0&&n(()=>u)},[]),s=S.useCallback(u=>{bn.error(u.message)},[]),o=S.useCallback(u=>u.length>0,[]),{firstCallLoading:a,error:l}=Npe({fetchFn:r,interval:3e3,onSuccess:i,onError:s,shouldContinue:o,enabled:!0});return{traces:e,firstCallLoading:a,error:l}},Al=S.createContext({});function $V({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),[f,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:f,setOpenDetail:p,clearData:v},children:t})}function VV({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(Zn,{className:"rounded-lg h-full",children:g.jsxs(Qo,{children:[g.jsx(Jo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(vn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(Nt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(Nt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Lh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(ea,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(vn,{className:Te("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(nt,{children:g.jsx(Rpe,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(nt,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(nt,{className:"text-mastra-el-5 text-sm",children:BV(i.started)}),g.jsx(nt,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(XK,{className:"h-3 w-3"}),dN(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(nt,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function Rpe({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(At,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var p;i(t);const f=t.find(m=>m.parentSpanId===null)||t[0];l(f),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"})}),e]})}function WV({node:t,depth:e=0}){var c,f;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(At,{variant:"ghost",className:Te("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:Te("!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:Te("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]":((f=t==null?void 0:t.status)==null?void 0:f.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:Te("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:[dN(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(p=>g.jsx(WV,{node:p,depth:e+1},p.id))})]})}function Ope({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(WV,{node:e},e.id))})}function HV(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:HV(t,n.id)}))}function Dpe({trace:t}){const e=HV(t);return g.jsx("div",{children:g.jsx(Ope,{tree:e})})}function UV(){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(At,{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(Kc,{})})," ",g.jsx(At,{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(Kc,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(At,{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(Dpe,{trace:t})]})]})}const qV=1024;let Ipe=0,q1=class{constructor(e,n){this.from=e,this.to=n}};class kt{constructor(e={}){this.id=Ipe++,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]}}}kt.closedBy=new kt({deserialize:t=>t.split(" ")});kt.openedBy=new kt({deserialize:t=>t.split(" ")});kt.group=new kt({deserialize:t=>t.split(" ")});kt.isolate=new kt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});kt.contextHash=new kt({perNode:!0});kt.lookAhead=new kt({perNode:!0});kt.mounted=new kt({perNode:!0});class Px{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[kt.mounted.id]}}const jpe=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):jpe,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(kt.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(kt.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 hN{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 hN(n)}}const ny=new WeakMap,uD=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 Ln{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=Px.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 WC(this.topNode,e)}cursorAt(e,n=0,r=0){let i=ny.get(this)||this.topNode,s=new WC(i);return s.moveTo(e,n),ny.set(this,s._tree),s}get topNode(){return new Xi(this,0,0,null)}resolve(e,n=0){let r=Qh(ny.get(this)||this.topNode,e,n,!1);return ny.set(this,r),r}resolveInner(e,n=0){let r=Qh(uD.get(this)||this.topNode,e,n,!0);return uD.set(this,r),r}resolveStack(e,n=0){return Bpe(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:gN(li.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Ln(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Ln(li.none,n,r,i)))}static build(e){return zpe(e)}}Ln.empty=new Ln(li.none,[],[],0);class pN{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 pN(this.buffer,this.index)}}class dl{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&&!(YV(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 dl(s,o,this.set)}}function YV(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 Qh(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 Xi&&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 Xi&&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 GV{cursor(e=0){return new WC(this,e)}getChild(e,n=null,r=null){let i=cD(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return cD(this,e,n,r)}resolve(e,n=0){return Qh(this,e,n,!1)}resolveInner(e,n=0){return Qh(this,e,n,!0)}matchContext(e){return VC(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 Xi extends GV{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],f=l[e]+o.from;if(YV(i,r,f,f+c.length)){if(c instanceof dl){if(s&sr.ExcludeBuffers)continue;let p=c.findChild(0,c.buffer.length,n,r-f,i);if(p>-1)return new el(new Lpe(o,c,e,f),null,p)}else if(s&sr.IncludeAnonymous||!c.type.isAnonymous||mN(c)){let p;if(!(s&sr.IgnoreMounts)&&(p=Px.get(c))&&!p.overlay)return new Xi(p.tree,f,e,o);let m=new Xi(c,f,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=Px.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 Xi(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 cD(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 VC(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 Lpe{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class el extends GV{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 Ln(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function KV(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 Xi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new Fpe(i,n)}class Fpe{constructor(e,n){this.heads=e,this.node=n}get next(){return KV(this.heads)}}function Bpe(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Xi?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=Px.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Xi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Qh(a,e,n,!1))}}return i?KV(i):r}class WC{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 Xi)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 Xi?(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 dl||!a.type.isAnonymous||mN(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 VC(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 VC(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 mN(t){return t.children.some(e=>e instanceof dl||!e.type.isAnonymous||mN(e))}function zpe(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=qV,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new pN(n,n.length):n,l=r.types,u=0,c=0;function f(_,N,M,R,D,O){let{id:B,start:F,end:V,size:j}=a,Y=c,W=u;for(;j<0;)if(a.next(),j==-1){let q=s[B];M.push(q),R.push(F-_);return}else if(j==-3){u=B;return}else if(j==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${j}`);let G=l[B],H,$,L=F-_;if(V-F<=i&&($=w(a.pos-N,D))){let q=new Uint16Array($.size-$.skip),U=a.pos-$.size,I=q.length;for(;a.pos>U;)I=b($.start,q,I);H=new dl(q,V-$.start,r),L=$.start-_}else{let q=a.pos-j;a.next();let U=[],I=[],K=B>=o?B:-1,Z=0,J=V;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,I,F,Z,a.end,J,K,Y,W),Z=U.length,J=a.end),a.next()):O>2500?p(F,q,U,I):f(F,q,U,I,K,O+1);if(K>=0&&Z>0&&Z<U.length&&y(U,I,F,Z,F,J,K,Y,W),U.reverse(),I.reverse(),K>-1&&Z>0){let ee=m(G,W);H=gN(G,U,I,0,U.length,0,V-F,ee,ee)}else H=v(G,U,I,V-F,Y-V,W)}M.push(H),R.push(L)}function p(_,N,M,R){let D=[],O=0,B=-1;for(;a.pos>N;){let{id:F,start:V,end:j,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&V<B)break;B<0&&(B=j-i),D.push(F,V,j),O++,a.next()}}if(O){let F=new Uint16Array(O*4),V=D[D.length-2];for(let j=D.length-3,Y=0;j>=0;j-=3)F[Y++]=D[j],F[Y++]=D[j+1]-V,F[Y++]=D[j+2]-V,F[Y++]=Y;M.push(new dl(F,D[2]-V,r)),R.push(V-_)}}function m(_,N){return(M,R,D)=>{let O=0,B=M.length-1,F,V;if(B>=0&&(F=M[B])instanceof Ln){if(!B&&F.type==_&&F.length==D)return F;(V=F.prop(kt.lookAhead))&&(O=R[B]+F.length+V)}return v(_,M,R,D,O,N)}}function y(_,N,M,R,D,O,B,F,V){let j=[],Y=[];for(;_.length>R;)j.push(_.pop()),Y.push(N.pop()+M-D);_.push(v(r.types[B],j,Y,O-D,F-O,V)),N.push(D-M)}function v(_,N,M,R,D,O,B){if(O){let F=[kt.contextHash,O];B=B?[F].concat(B):[F]}if(D>25){let F=[kt.lookAhead,D];B=B?[F].concat(B):[F]}return new Ln(_,N,M,R,B)}function w(_,N){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-_;M.pos>V;){let j=M.size;if(M.id==N&&j>=0){F.size=R,F.start=D,F.skip=O,O+=4,R+=4,M.next();continue}let Y=M.pos-j;if(j<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+=j,O+=W}return(N<0||R==_)&&(F.size=R,F.start=D,F.skip=O),F.size>4?F:void 0}function b(_,N,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(_,N,M)}N[--M]=F,N[--M]=O-_,N[--M]=D-_,N[--M]=R}else B==-3?u=R:B==-4&&(c=R);return M}let k=[],E=[];for(;a.pos>0;)f(t.start||0,t.bufferStart||0,k,E,-1,0);let A=(e=t.length)!==null&&e!==void 0?e:k.length?E[0]+k[0].length:0;return new Ln(l[t.topID],k.reverse(),E.reverse(),A)}const fD=new WeakMap;function Uy(t,e){if(!t.isAnonymous||e instanceof dl||e.type!=t)return 1;let n=fD.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Ln)){n=1;break}n+=Uy(t,r)}fD.set(e,n)}return n}function gN(t,e,n,r,i,s,o,a,l){let u=0;for(let y=r;y<i;y++)u+=Uy(t,e[y]);let c=Math.ceil(u*1.5/8),f=[],p=[];function m(y,v,w,b,k){for(let E=w;E<b;){let A=E,_=v[E],N=Uy(t,y[E]);for(E++;E<b;E++){let M=Uy(t,y[E]);if(N+M>=c)break;N+=M}if(E==A+1){if(N>c){let M=y[A];m(M.children,M.positions,0,M.children.length,v[A]+k);continue}f.push(y[A])}else{let M=v[E-1]+y[E-1].length-_;f.push(gN(t,y,v,A,E,_,M,null,l))}p.push(_+k-s)}}return m(e,n,r,i,0),(a||l)(f,p,o)}class au{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 au(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,f=c?c.fromA:1e9;if(f-l>=r)for(;o&&o.from<f;){let p=o;if(l>=p.from||f<=p.to||u){let m=Math.max(p.from,l)-u,y=Math.min(p.to,f)-u;p=m>=y?null:new au(m,y,p.tree,p.offset+u,a>0,!!c)}if(p&&i.push(p),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}}class ZV{startParse(e,n,r){return typeof e=="string"&&(e=new $pe(e)),r=r?r.length?r.map(i=>new q1(i.from,i.to)):[new q1(0,0)]:[new q1(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 $pe{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 kt({perNode:!0});var dD={};class Rx{constructor(e,n,r,i,s,o,a,l,u,c=0,f){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=f}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 Rx(e,[],n,r,r,0,[],0,i?new hD(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 f=l?this.stack[l-1]:0,p=this.bufferBase+this.buffer.length-f;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 Rx(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 Vpe(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 hD(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 hD{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Vpe{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 Ox{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 Ox(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 Ox(this.stack,this.pos,this.index)}}function ry(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 qy{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const pD=new qy;class Wpe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=pD,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=pD,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 Bc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;Hpe(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Bc.prototype.contextual=Bc.prototype.fallback=Bc.prototype.extend=!1;Bc.prototype.fallback=Bc.prototype.extend=!1;function Hpe(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||Upe(y,e.token.value,i,s))){e.acceptToken(y);break}}let c=e.next,f=0,p=t[o+2];if(e.next<0&&p>f&&t[u+p*3-3]==65535){o=t[u+p*3-1];continue e}for(;f<p;){let m=f+p>>1,y=u+m+(m<<1),v=t[y],w=t[y+1]||65536;if(c<v)p=m;else if(c>=w)f=m+1;else{o=t[y+2],e.advance();continue e}}break}}function mD(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function Upe(t,e,n,r){let i=mD(n,r,e);return i<0||mD(n,r,t)<i}const gi=typeof process<"u"&&dD&&/\bparse\b/.test(dD.LOG);let Y1=null;function gD(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 qpe{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?gD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?gD(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 Ln){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(kt.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 Ype{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new qy)}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],f=this.tokens[u];if(!(r&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=a)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=a),f.lookAhead>f.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let p=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>p))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new qy,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 qy,{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=jo(a,u+2);else{i==0&&a[u+1]==2&&(i=this.putAction(jo(a,u+2),n,r,i));break}a[u]==n&&(i=this.putAction(jo(a,u+1),n,r,i))}return i}}class Gpe{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 Wpe(n,i),this.tokens=new Ype(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Rx.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new qpe(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&&Zpe(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 f=this.fragments.nodeAt(i);f;){let p=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(p>-1&&f.length&&(!u||(f.prop(kt.contextHash)||0)==c))return e.useNode(f,p),gi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Ln)||f.children.length==0||f.positions[0]>0)break;let m=f.children[0];if(m instanceof Ln&&f.positions[0]==0)f=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++],f=l[u++],p=l[u++],m=u==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(c,f,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(f)} @ ${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 f=a.split(),p=c;for(let m=0;f.forceReduce()&&m<10&&(gi&&console.log(p+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));m++)gi&&(p=this.stackID(f)+" -> ");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(),Ln.build({buffer:Ox.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=(Y1||(Y1=new WeakMap)).get(e);return n||Y1.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 Kpe{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Dx extends ZV{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=kt[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)s(c,l,a[u++]);else{let f=a[u+-c];for(let p=-c;p>0;p--)s(a[u++],l,f);u++}}}this.nodeSet=new hN(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=qV;let o=ry(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(xD),this.states=ry(e.states,Uint32Array),this.data=ry(e.stateData),this.goto=ry(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Bc(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 Gpe(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=jo(r,s+2)];else{if(r[s+1]==2)return jo(r,s+2);break}if(o==n||o==0)return jo(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=jo(this.data,s+2);else break;i=n(jo(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=jo(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(Dx.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]=xD(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 Kpe(e,r,i)}static deserialize(e){return new Dx(e)}}function jo(t,e){return t[e]|t[e+1]<<16}function Zpe(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 xD(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let Xpe=0;class qi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=Xpe++}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 qi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new qi(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 Ix(e);return r=>r.modified.indexOf(n)>-1?r:Ix.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let Qpe=0;class Ix{constructor(e){this.name=e,this.instances=[],this.id=Qpe++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Jpe(n,a.modified));if(r)return r;let i=[],s=new qi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=eme(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Ix.get(a,l));return s}}function Jpe(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function eme(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 XV(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 f=0;;){if(a=="..."&&f>0&&f+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]),f+=p[0].length,f==i.length)break;let m=i[f++];if(f==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(f)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new jx(r,o,l>0?s.slice(0,l):null);e[u]=c.sort(e[u])}}return QV.add(e)}const QV=new kt;class jx{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}}jx.empty=new jx([],2,null);function JV(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 tme(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function nme(t,e,n,r=0,i=t.length){let s=new rme(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class rme{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=ime(e)||jx.empty,f=tme(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,a),u),c.opaque)return;let p=e.tree&&e.tree.prop(kt.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,A=Math.max(n,b),_=Math.min(r,E);if(A<_&&v)for(;e.from<_&&(this.highlightRange(e,A,_,i,s),this.startSpan(Math.min(_,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 ime(t){let e=t.type.prop(QV);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Pe=qi.define,iy=Pe(),Ya=Pe(),vD=Pe(Ya),wD=Pe(Ya),Ga=Pe(),sy=Pe(Ga),G1=Pe(Ga),Vs=Pe(),ql=Pe(Vs),Fs=Pe(),Bs=Pe(),HC=Pe(),zd=Pe(HC),oy=Pe(),re={comment:iy,lineComment:Pe(iy),blockComment:Pe(iy),docComment:Pe(iy),name:Ya,variableName:Pe(Ya),typeName:vD,tagName:Pe(vD),propertyName:wD,attributeName:Pe(wD),className:Pe(Ya),labelName:Pe(Ya),namespace:Pe(Ya),macroName:Pe(Ya),literal:Ga,string:sy,docString:Pe(sy),character:Pe(sy),attributeValue:Pe(sy),number:G1,integer:Pe(G1),float:Pe(G1),bool:Pe(Ga),regexp:Pe(Ga),escape:Pe(Ga),color:Pe(Ga),url:Pe(Ga),keyword:Fs,self:Pe(Fs),null:Pe(Fs),atom:Pe(Fs),unit:Pe(Fs),modifier:Pe(Fs),operatorKeyword:Pe(Fs),controlKeyword:Pe(Fs),definitionKeyword:Pe(Fs),moduleKeyword:Pe(Fs),operator:Bs,derefOperator:Pe(Bs),arithmeticOperator:Pe(Bs),logicOperator:Pe(Bs),bitwiseOperator:Pe(Bs),compareOperator:Pe(Bs),updateOperator:Pe(Bs),definitionOperator:Pe(Bs),typeOperator:Pe(Bs),controlOperator:Pe(Bs),punctuation:HC,separator:Pe(HC),bracket:zd,angleBracket:Pe(zd),squareBracket:Pe(zd),paren:Pe(zd),brace:Pe(zd),content:Vs,heading:ql,heading1:Pe(ql),heading2:Pe(ql),heading3:Pe(ql),heading4:Pe(ql),heading5:Pe(ql),heading6:Pe(ql),contentSeparator:Pe(Vs),list:Pe(Vs),quote:Pe(Vs),emphasis:Pe(Vs),strong:Pe(Vs),link:Pe(Vs),monospace:Pe(Vs),strikethrough:Pe(Vs),inserted:Pe(),deleted:Pe(),changed:Pe(),invalid:Pe(),meta:oy,documentMeta:Pe(oy),annotation:Pe(oy),processingInstruction:Pe(oy),definition:qi.defineModifier("definition"),constant:qi.defineModifier("constant"),function:qi.defineModifier("function"),standard:qi.defineModifier("standard"),local:qi.defineModifier("local"),special:qi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof qi&&(e.name=t)}JV([{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 sme=XV({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),ome=Dx.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:[sme],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 UC=[],e6=[];(()=>{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?e6:UC).push(n=n+t[e])})();function ame(t){if(t<768)return!1;for(let e=0,n=UC.length;;){let r=e+n>>1;if(t<UC[r])n=r;else if(t>=e6[r])e=r+1;else return!0;if(e==n)return!1}}function bD(t){return t>=127462&&t<=127487}const kD=8205;function lme(t,e,n=!0,r=!0){return(n?t6:ume)(t,e,r)}function t6(t,e,n){if(e==t.length)return e;e&&n6(t.charCodeAt(e))&&r6(t.charCodeAt(e-1))&&e--;let r=K1(t,e);for(e+=SD(r);e<t.length;){let i=K1(t,e);if(r==kD||i==kD||n&&ame(i))e+=SD(i),r=i;else if(bD(i)){let s=0,o=e-2;for(;o>=0&&bD(K1(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function ume(t,e,n){for(;e>0;){let r=t6(t,e-2,n);if(r<e)return r;e--}return 0}function K1(t,e){let n=t.charCodeAt(e);if(!r6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return n6(r)?(n-55296<<10)+(r-56320)+65536:n}function n6(t){return t>=56320&&t<57344}function r6(t){return t>=55296&&t<56320}function SD(t){return t<65536?1:2}let Bt=class i6{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]=rf(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]=rf(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 Sh(this),s=new Sh(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 Sh(this,e)}iterRange(e,n=this.length){return new s6(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 o6(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]?i6.empty:e.length<=32?new Tn(e):qs.from(Tn.split(e,[]))}};class Tn extends Bt{constructor(e,n=cme(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 fme(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Tn(CD(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=Yy(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Tn(a,o.length+s.length));else{let l=a.length>>1;r.push(new Tn(a.slice(0,l)),new Tn(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Tn))return super.replace(e,n,r);[e,n]=rf(this,e,n);let i=Yy(this.text,Yy(r.text,CD(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Tn(i,s):qs.from(Tn.split(i,[]),s)}sliceString(e,n=this.length,r=`
305
+ 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 U1(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const npe=(t,e)=>Math.abs(t-e)<1,rpe=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},ipe=t=>t,spe=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},ope=(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)}},rD={passive:!0},ape=typeof window>"u"?!0:"onscrollend"in window,lpe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&ape?()=>{}:rpe(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:c,isRtl:f}=t.options;i=c?n.scrollLeft*(f&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);return l(),n.addEventListener("scroll",a,rD),n.addEventListener("scrollend",l,rD),()=>{n.removeEventListener("scroll",a),n.removeEventListener("scrollend",l)}},upe=(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"])},cpe=(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 fpe{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:ipe,rangeExtractor:spe,onChange:()=>{},measureElement:upe,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=dc(()=>(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=dc(()=>[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=dc(()=>[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 f=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(f),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:f,lane:b}}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=dc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?dpe({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getIndexes=dc(()=>{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=dc(()=>[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 U1(r[NV(0,r.length-1,i=>U1(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]=U1(this.getOffsetForIndex(n,a));npe(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 NV=(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 dpe({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=NV(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 iD=typeof document<"u"?S.useLayoutEffect:S.useEffect;function hpe(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Pf.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new fpe(n));return r.setOptions(n),iD(()=>r._didMount(),[]),iD(()=>r._willUpdate()),r}function ppe(t){return hpe({observeElementRect:ope,observeElementOffset:lpe,scrollToFn:cpe,...t})}const mpe=Qhe,gpe=Jhe,ype=xV,xpe=tpe,vpe=epe,_V=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx(yV,{ref:i,className:Te("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));_V.displayName=yV.displayName;const MV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(AV,{ref:i,className:Te("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(Kc,{className:"ml-auto -rotate-90"})]}));MV.displayName=AV.displayName;const PV=S.forwardRef(({className:t,...e},n)=>g.jsx(TV,{ref:n,className:Te("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}));PV.displayName=TV.displayName;const RV=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(xV,{container:e,children:g.jsx(vV,{ref:i,sideOffset:n,className:Te("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})}));RV.displayName=vV.displayName;const OV=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(bV,{ref:r,className:Te("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}));OV.displayName=bV.displayName;const DV=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(kV,{ref:i,className:Te("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(CV,{children:g.jsx(TA,{className:"h-2 w-2 fill-current"})})}),e]}));DV.displayName=kV.displayName;const IV=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(SV,{ref:r,className:Te("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(CV,{children:g.jsx(ZK,{className:"h-2 w-2 fill-current"})})}),e]}));IV.displayName=SV.displayName;const jV=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(wV,{ref:r,className:Te("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));jV.displayName=wV.displayName;const LV=S.forwardRef(({className:t,...e},n)=>g.jsx(EV,{ref:n,className:Te("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));LV.displayName=EV.displayName;const FV=({className:t,...e})=>g.jsx("span",{className:Te("ml-auto text-xs tracking-widest opacity-60",t),...e});FV.displayName="DropdownMenuShortcut";function Gn({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(mpe,{modal:r,open:t,onOpenChange:e,children:n})}function wpe({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=ppe({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))})})}Gn.Trigger=_V;Gn.Content=RV;Gn.Group=gpe;Gn.Portal=ype;Gn.Item=OV;Gn.CheckboxItem=DV;Gn.RadioItem=IV;Gn.Label=jV;Gn.Separator=LV;Gn.Shortcut=FV;Gn.Sub=xpe;Gn.SubContent=PV;Gn.SubTrigger=MV;Gn.RadioGroup=vpe;Gn.VirtualizedItems=wpe;const bpe=t=>{const{data:e,isLoading:n,mutate:r}=LA(`/api/memory/status?agentId=${t}`,_A,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},kpe=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=LA(`/api/memory/threads?resourceid=${t}&agentId=${e}`,_A,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},Spe=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=LA(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>_A(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}},Cpe=()=>{const{mutate:t}=jA();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"}});bn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function Epe({agentId:t,threadId:e}){const{threads:n,isLoading:r}=kpe({resourceid:t,agentId:t}),{deleteThread:i}=Cpe(),s=mo(),[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(Zn,{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(At,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Fh,{})})]}),n.map(f=>{const p=f.id===e;return g.jsxs("div",{className:Te("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(Hp,{to:`/agents/${t}/chat/${f.id}`,className:"flex-1",children:g.jsx("p",{className:Te("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",p?"text-mastra-el-6":""),children:f.title})}),g.jsxs(Gn,{children:[g.jsx(Gn.Trigger,{asChild:!0,children:g.jsxs(At,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(eZ,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(Gn.Content,{children:g.jsxs(Gn.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(f.id),u(!0)},children:[g.jsx(oZ,{}),g.jsx("span",{children:"Delete"})]})})]})]},f.id)})]}),g.jsx(ir,{open:l,onOpenChange:u,children:g.jsxs(ir.Content,{children:[g.jsxs(ir.Header,{children:[g.jsx(ir.Title,{children:"Are you absolutely sure?"}),g.jsx(ir.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(ir.Footer,{children:[g.jsx(ir.Cancel,{children:"Cancel"}),g.jsx(ir.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(At,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${crypto.randomUUID()}`),children:g.jsx(Fh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function sD(){const{agentId:t,threadId:e}=fa(),{agent:n,isLoading:r}=Of(t),{memory:i}=bpe(t),s=mo(),{messages:o,isLoading:a}=Spe({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(Sx,{agentId:t})})]}):g.jsxs("main",{className:Te("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(Epe,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(At,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>u(!l),children:g.jsx(rZ,{})}):null,g.jsx(Xue,{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(Sx,{agentId:t})})]})}const oD=(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),bn.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),bn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}};function Ape({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=oD(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=oD(t,"ci"),u=()=>{e==="live"?s():l()};return g.jsx("div",{className:"flex-1 relative overflow-hidden",children:g.jsx("div",{className:"flex justify-between sticky top-0 bg-mastra-bg-2 p-4",children:g.jsxs(zT,{value:e,onValueChange:c=>n(c),className:"w-full",children:[g.jsxs(rv,{children:[g.jsx(Yo,{value:"live",className:"mr-4",children:"Live"}),g.jsx(Yo,{value:"ci",children:"CI"})]}),g.jsx("div",{className:"flex justify-end my-2",children:g.jsx(At,{variant:"outline",onClick:u,disabled:e==="live"?i:a,children:(e==="live"?i:a)?g.jsx(Zc,{className:"w-4 h-4 animate-spin"}):g.jsx(Zc,{className:"w-4 h-4"})})}),g.jsxs(Zn,{className:"rounded-lg h-[calc(100vh-180px)]",children:[g.jsx(Go,{value:"live",className:"mt-0",children:g.jsx(aD,{showTestName:!1,evals:r,isLoading:i})}),g.jsx(Go,{value:"ci",className:"mt-0",children:g.jsx(aD,{showTestName:!0,evals:o,isLoading:a})})]})]})})})}function aD({showTestName:t=!1,evals:e,isLoading:n}){const[r,i]=S.useState(new Set),s=a=>{const l=new Set(r);l.has(a)?l.delete(a):l.add(a),i(l)},o=a=>a.reduce((l,u)=>{const c=l.find(f=>f.metricName===u.metricName);return c?(c.evals.push(u),c.averageScore=c.evals.reduce((f,p)=>f+p.result.score,0)/c.evals.length):l.push({metricName:u.metricName,averageScore:u.result.score,evals:[u]}),l},[]);return g.jsxs(Qo,{children:[g.jsx(Jo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(vn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(Nt,{className:"w-[50px]"}),g.jsx(Nt,{className:"w-[300px] text-mastra-el-3",children:"Metric"}),g.jsx(Nt,{className:"w-[600px] text-mastra-el-3"}),g.jsx(Nt,{className:"w-[200px] text-mastra-el-3",children:"Average Score"}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Total Evaluations"})]})}),g.jsx(ea,{className:"border-b border-gray-6",children:n?g.jsxs(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(nt,{className:"w-[50px]",children:g.jsx(He,{className:"h-8 w-8"})}),g.jsx(nt,{className:"w-[400px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{className:"w-[400px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{className:"w-[200px]",children:g.jsx(He,{className:"h-8 w-full"})}),g.jsx(nt,{children:g.jsx(He,{className:"h-8 w-full"})})]}):o(e).map(a=>g.jsxs(g.Fragment,{children:[g.jsxs(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>s(a.metricName),children:[g.jsx(nt,{className:"w-[50px]",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:r.has(a.metricName)?g.jsx(Kc,{className:"h-4 w-4 text-mastra-el-5"}):g.jsx(KK,{className:"h-4 w-4 text-mastra-el-5"})})}),g.jsx(nt,{className:"w-[300px] font-medium text-mastra-el-5",children:a.metricName}),g.jsx(nt,{className:"w-[600px] text-mastra-el-5"}),g.jsx(nt,{className:"w-[200px] text-mastra-el-5",children:a.averageScore.toFixed(2)}),g.jsx(nt,{className:"text-mastra-el-5",children:a.evals.length})]},a.metricName),r.has(a.metricName)&&g.jsxs(g.Fragment,{children:[g.jsxs(vn,{className:"bg-mastra-bg-3 text-[0.7rem] text-mastra-el-3",children:[g.jsx(nt,{className:"w-[50px]"}),g.jsx(nt,{className:"w-[300px] pl-8",children:"Timestamp"}),g.jsx(nt,{className:"w-[600px] pl-8",children:"Input"}),g.jsx(nt,{className:"w-[200px]",children:"Score"}),t&&g.jsx(nt,{children:"Test Name"})]}),a.evals.map((l,u)=>{var c;return g.jsxs(vn,{className:"bg-mastra-bg-3 text-[0.8125rem]",children:[g.jsx(nt,{className:"w-[50px]"}),g.jsx(nt,{className:"w-[300px] text-mastra-el-4 pl-8",children:new Date(l.createdAt).toLocaleString()}),g.jsx(nt,{className:"w-[600px] text-mastra-el-4",children:l.input}),g.jsx(nt,{className:"w-[200px] text-mastra-el-4",children:l.result.score}),t&&g.jsx(nt,{className:"text-mastra-el-4",children:(c=l==null?void 0:l.testInfo)==null?void 0:c.testName})]},`${a.metricName}-${u}`)})]})]}))})]})}function Tpe(){const{agentId:t}=fa();return g.jsx("main",{className:"flex-1",children:g.jsx(Ape,{agentId:t})})}function Npe({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,f]=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]),A=S.useCallback(()=>{console.log("startPolling"),a(!0),u(null)},[]),_=S.useCallback(async(N=!1)=>{if(b.current){m(!0),v(N);try{const M=await t();f(M),u(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(_,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&&_(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,_,k]),{isPolling:o,isLoading:p,error:l,data:c,startPolling:A,stopPolling:E,firstCallLoading:y}}function dN(t,e=2){return(t/1e3).toFixed(e)}function BV(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 _pe(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 Mpe(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function lD(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const Ppe=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}})},zV=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 Ppe((c==null?void 0:c.traces)||[])}catch(u){throw u}},[t]),i=S.useCallback(u=>{u.length>0&&n(()=>u)},[]),s=S.useCallback(u=>{bn.error(u.message)},[]),o=S.useCallback(u=>u.length>0,[]),{firstCallLoading:a,error:l}=Npe({fetchFn:r,interval:3e3,onSuccess:i,onError:s,shouldContinue:o,enabled:!0});return{traces:e,firstCallLoading:a,error:l}},Al=S.createContext({});function $V({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),[f,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:f,setOpenDetail:p,clearData:v},children:t})}function VV({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(Zn,{className:"rounded-lg h-full",children:g.jsxs(Qo,{children:[g.jsx(Jo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(vn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(Nt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(Nt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Lh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(Nt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(ea,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(vn,{className:Te("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(nt,{children:g.jsx(Rpe,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(nt,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(nt,{className:"text-mastra-el-5 text-sm",children:BV(i.started)}),g.jsx(nt,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(XK,{className:"h-3 w-3"}),dN(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(vn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(nt,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function Rpe({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(At,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var p;i(t);const f=t.find(m=>m.parentSpanId===null)||t[0];l(f),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 WV({node:t,depth:e=0}){var c,f;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(At,{variant:"ghost",className:Te("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:Te("!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:Te("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]":((f=t==null?void 0:t.status)==null?void 0:f.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:Te("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:[dN(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(p=>g.jsx(WV,{node:p,depth:e+1},p.id))})]})}function Ope({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(WV,{node:e},e.id))})}function HV(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:HV(t,n.id)}))}function Dpe({trace:t}){const e=HV(t);return g.jsx("div",{children:g.jsx(Ope,{tree:e})})}function UV(){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(At,{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(Kc,{})})," ",g.jsx(At,{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(Kc,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(At,{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(Dpe,{trace:t})]})]})}const qV=1024;let Ipe=0,q1=class{constructor(e,n){this.from=e,this.to=n}};class kt{constructor(e={}){this.id=Ipe++,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]}}}kt.closedBy=new kt({deserialize:t=>t.split(" ")});kt.openedBy=new kt({deserialize:t=>t.split(" ")});kt.group=new kt({deserialize:t=>t.split(" ")});kt.isolate=new kt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});kt.contextHash=new kt({perNode:!0});kt.lookAhead=new kt({perNode:!0});kt.mounted=new kt({perNode:!0});class Px{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[kt.mounted.id]}}const jpe=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):jpe,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(kt.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(kt.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 hN{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 hN(n)}}const ny=new WeakMap,uD=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 Ln{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=Px.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 WC(this.topNode,e)}cursorAt(e,n=0,r=0){let i=ny.get(this)||this.topNode,s=new WC(i);return s.moveTo(e,n),ny.set(this,s._tree),s}get topNode(){return new Xi(this,0,0,null)}resolve(e,n=0){let r=Qh(ny.get(this)||this.topNode,e,n,!1);return ny.set(this,r),r}resolveInner(e,n=0){let r=Qh(uD.get(this)||this.topNode,e,n,!0);return uD.set(this,r),r}resolveStack(e,n=0){return Bpe(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:gN(li.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Ln(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Ln(li.none,n,r,i)))}static build(e){return zpe(e)}}Ln.empty=new Ln(li.none,[],[],0);class pN{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 pN(this.buffer,this.index)}}class dl{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&&!(YV(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 dl(s,o,this.set)}}function YV(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 Qh(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 Xi&&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 Xi&&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 GV{cursor(e=0){return new WC(this,e)}getChild(e,n=null,r=null){let i=cD(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return cD(this,e,n,r)}resolve(e,n=0){return Qh(this,e,n,!1)}resolveInner(e,n=0){return Qh(this,e,n,!0)}matchContext(e){return VC(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 Xi extends GV{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],f=l[e]+o.from;if(YV(i,r,f,f+c.length)){if(c instanceof dl){if(s&sr.ExcludeBuffers)continue;let p=c.findChild(0,c.buffer.length,n,r-f,i);if(p>-1)return new el(new Lpe(o,c,e,f),null,p)}else if(s&sr.IncludeAnonymous||!c.type.isAnonymous||mN(c)){let p;if(!(s&sr.IgnoreMounts)&&(p=Px.get(c))&&!p.overlay)return new Xi(p.tree,f,e,o);let m=new Xi(c,f,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=Px.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 Xi(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 cD(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 VC(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 Lpe{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class el extends GV{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 Ln(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function KV(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 Xi&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new Fpe(i,n)}class Fpe{constructor(e,n){this.heads=e,this.node=n}get next(){return KV(this.heads)}}function Bpe(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof Xi?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=Px.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new Xi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Qh(a,e,n,!1))}}return i?KV(i):r}class WC{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 Xi)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 Xi?(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 dl||!a.type.isAnonymous||mN(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 VC(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 VC(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 mN(t){return t.children.some(e=>e instanceof dl||!e.type.isAnonymous||mN(e))}function zpe(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=qV,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new pN(n,n.length):n,l=r.types,u=0,c=0;function f(_,N,M,R,D,O){let{id:B,start:F,end:V,size:j}=a,Y=c,W=u;for(;j<0;)if(a.next(),j==-1){let q=s[B];M.push(q),R.push(F-_);return}else if(j==-3){u=B;return}else if(j==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${j}`);let G=l[B],H,$,L=F-_;if(V-F<=i&&($=w(a.pos-N,D))){let q=new Uint16Array($.size-$.skip),U=a.pos-$.size,I=q.length;for(;a.pos>U;)I=b($.start,q,I);H=new dl(q,V-$.start,r),L=$.start-_}else{let q=a.pos-j;a.next();let U=[],I=[],K=B>=o?B:-1,Z=0,J=V;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,I,F,Z,a.end,J,K,Y,W),Z=U.length,J=a.end),a.next()):O>2500?p(F,q,U,I):f(F,q,U,I,K,O+1);if(K>=0&&Z>0&&Z<U.length&&y(U,I,F,Z,F,J,K,Y,W),U.reverse(),I.reverse(),K>-1&&Z>0){let ee=m(G,W);H=gN(G,U,I,0,U.length,0,V-F,ee,ee)}else H=v(G,U,I,V-F,Y-V,W)}M.push(H),R.push(L)}function p(_,N,M,R){let D=[],O=0,B=-1;for(;a.pos>N;){let{id:F,start:V,end:j,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&V<B)break;B<0&&(B=j-i),D.push(F,V,j),O++,a.next()}}if(O){let F=new Uint16Array(O*4),V=D[D.length-2];for(let j=D.length-3,Y=0;j>=0;j-=3)F[Y++]=D[j],F[Y++]=D[j+1]-V,F[Y++]=D[j+2]-V,F[Y++]=Y;M.push(new dl(F,D[2]-V,r)),R.push(V-_)}}function m(_,N){return(M,R,D)=>{let O=0,B=M.length-1,F,V;if(B>=0&&(F=M[B])instanceof Ln){if(!B&&F.type==_&&F.length==D)return F;(V=F.prop(kt.lookAhead))&&(O=R[B]+F.length+V)}return v(_,M,R,D,O,N)}}function y(_,N,M,R,D,O,B,F,V){let j=[],Y=[];for(;_.length>R;)j.push(_.pop()),Y.push(N.pop()+M-D);_.push(v(r.types[B],j,Y,O-D,F-O,V)),N.push(D-M)}function v(_,N,M,R,D,O,B){if(O){let F=[kt.contextHash,O];B=B?[F].concat(B):[F]}if(D>25){let F=[kt.lookAhead,D];B=B?[F].concat(B):[F]}return new Ln(_,N,M,R,B)}function w(_,N){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-_;M.pos>V;){let j=M.size;if(M.id==N&&j>=0){F.size=R,F.start=D,F.skip=O,O+=4,R+=4,M.next();continue}let Y=M.pos-j;if(j<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+=j,O+=W}return(N<0||R==_)&&(F.size=R,F.start=D,F.skip=O),F.size>4?F:void 0}function b(_,N,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(_,N,M)}N[--M]=F,N[--M]=O-_,N[--M]=D-_,N[--M]=R}else B==-3?u=R:B==-4&&(c=R);return M}let k=[],E=[];for(;a.pos>0;)f(t.start||0,t.bufferStart||0,k,E,-1,0);let A=(e=t.length)!==null&&e!==void 0?e:k.length?E[0]+k[0].length:0;return new Ln(l[t.topID],k.reverse(),E.reverse(),A)}const fD=new WeakMap;function Uy(t,e){if(!t.isAnonymous||e instanceof dl||e.type!=t)return 1;let n=fD.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Ln)){n=1;break}n+=Uy(t,r)}fD.set(e,n)}return n}function gN(t,e,n,r,i,s,o,a,l){let u=0;for(let y=r;y<i;y++)u+=Uy(t,e[y]);let c=Math.ceil(u*1.5/8),f=[],p=[];function m(y,v,w,b,k){for(let E=w;E<b;){let A=E,_=v[E],N=Uy(t,y[E]);for(E++;E<b;E++){let M=Uy(t,y[E]);if(N+M>=c)break;N+=M}if(E==A+1){if(N>c){let M=y[A];m(M.children,M.positions,0,M.children.length,v[A]+k);continue}f.push(y[A])}else{let M=v[E-1]+y[E-1].length-_;f.push(gN(t,y,v,A,E,_,M,null,l))}p.push(_+k-s)}}return m(e,n,r,i,0),(a||l)(f,p,o)}class au{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 au(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,f=c?c.fromA:1e9;if(f-l>=r)for(;o&&o.from<f;){let p=o;if(l>=p.from||f<=p.to||u){let m=Math.max(p.from,l)-u,y=Math.min(p.to,f)-u;p=m>=y?null:new au(m,y,p.tree,p.offset+u,a>0,!!c)}if(p&&i.push(p),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}}class ZV{startParse(e,n,r){return typeof e=="string"&&(e=new $pe(e)),r=r?r.length?r.map(i=>new q1(i.from,i.to)):[new q1(0,0)]:[new q1(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 $pe{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 kt({perNode:!0});var dD={};class Rx{constructor(e,n,r,i,s,o,a,l,u,c=0,f){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=f}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 Rx(e,[],n,r,r,0,[],0,i?new hD(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 f=l?this.stack[l-1]:0,p=this.bufferBase+this.buffer.length-f;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 Rx(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 Vpe(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 hD(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 hD{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Vpe{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 Ox{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 Ox(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 Ox(this.stack,this.pos,this.index)}}function ry(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 qy{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const pD=new qy;class Wpe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=pD,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=pD,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 Bc{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;Hpe(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Bc.prototype.contextual=Bc.prototype.fallback=Bc.prototype.extend=!1;Bc.prototype.fallback=Bc.prototype.extend=!1;function Hpe(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||Upe(y,e.token.value,i,s))){e.acceptToken(y);break}}let c=e.next,f=0,p=t[o+2];if(e.next<0&&p>f&&t[u+p*3-3]==65535){o=t[u+p*3-1];continue e}for(;f<p;){let m=f+p>>1,y=u+m+(m<<1),v=t[y],w=t[y+1]||65536;if(c<v)p=m;else if(c>=w)f=m+1;else{o=t[y+2],e.advance();continue e}}break}}function mD(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function Upe(t,e,n,r){let i=mD(n,r,e);return i<0||mD(n,r,t)<i}const gi=typeof process<"u"&&dD&&/\bparse\b/.test(dD.LOG);let Y1=null;function gD(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 qpe{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?gD(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?gD(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 Ln){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(kt.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 Ype{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new qy)}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],f=this.tokens[u];if(!(r&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=a)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=a),f.lookAhead>f.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let p=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>p))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new qy,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 qy,{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=jo(a,u+2);else{i==0&&a[u+1]==2&&(i=this.putAction(jo(a,u+2),n,r,i));break}a[u]==n&&(i=this.putAction(jo(a,u+1),n,r,i))}return i}}class Gpe{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 Wpe(n,i),this.tokens=new Ype(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[Rx.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new qpe(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&&Zpe(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 f=this.fragments.nodeAt(i);f;){let p=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(p>-1&&f.length&&(!u||(f.prop(kt.contextHash)||0)==c))return e.useNode(f,p),gi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Ln)||f.children.length==0||f.positions[0]>0)break;let m=f.children[0];if(m instanceof Ln&&f.positions[0]==0)f=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++],f=l[u++],p=l[u++],m=u==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(c,f,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(f)} @ ${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 f=a.split(),p=c;for(let m=0;f.forceReduce()&&m<10&&(gi&&console.log(p+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));m++)gi&&(p=this.stackID(f)+" -> ");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(),Ln.build({buffer:Ox.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=(Y1||(Y1=new WeakMap)).get(e);return n||Y1.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 Kpe{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Dx extends ZV{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=kt[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)s(c,l,a[u++]);else{let f=a[u+-c];for(let p=-c;p>0;p--)s(a[u++],l,f);u++}}}this.nodeSet=new hN(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=qV;let o=ry(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(xD),this.states=ry(e.states,Uint32Array),this.data=ry(e.stateData),this.goto=ry(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Bc(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 Gpe(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=jo(r,s+2)];else{if(r[s+1]==2)return jo(r,s+2);break}if(o==n||o==0)return jo(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=jo(this.data,s+2);else break;i=n(jo(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=jo(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(Dx.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]=xD(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 Kpe(e,r,i)}static deserialize(e){return new Dx(e)}}function jo(t,e){return t[e]|t[e+1]<<16}function Zpe(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 xD(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let Xpe=0;class qi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=Xpe++}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 qi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new qi(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 Ix(e);return r=>r.modified.indexOf(n)>-1?r:Ix.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let Qpe=0;class Ix{constructor(e){this.name=e,this.instances=[],this.id=Qpe++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&Jpe(n,a.modified));if(r)return r;let i=[],s=new qi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=eme(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Ix.get(a,l));return s}}function Jpe(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function eme(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 XV(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 f=0;;){if(a=="..."&&f>0&&f+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]),f+=p[0].length,f==i.length)break;let m=i[f++];if(f==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(f)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new jx(r,o,l>0?s.slice(0,l):null);e[u]=c.sort(e[u])}}return QV.add(e)}const QV=new kt;class jx{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}}jx.empty=new jx([],2,null);function JV(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 tme(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function nme(t,e,n,r=0,i=t.length){let s=new rme(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class rme{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=ime(e)||jx.empty,f=tme(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,a),u),c.opaque)return;let p=e.tree&&e.tree.prop(kt.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,A=Math.max(n,b),_=Math.min(r,E);if(A<_&&v)for(;e.from<_&&(this.highlightRange(e,A,_,i,s),this.startSpan(Math.min(_,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 ime(t){let e=t.type.prop(QV);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Pe=qi.define,iy=Pe(),Ya=Pe(),vD=Pe(Ya),wD=Pe(Ya),Ga=Pe(),sy=Pe(Ga),G1=Pe(Ga),Vs=Pe(),ql=Pe(Vs),Fs=Pe(),Bs=Pe(),HC=Pe(),zd=Pe(HC),oy=Pe(),re={comment:iy,lineComment:Pe(iy),blockComment:Pe(iy),docComment:Pe(iy),name:Ya,variableName:Pe(Ya),typeName:vD,tagName:Pe(vD),propertyName:wD,attributeName:Pe(wD),className:Pe(Ya),labelName:Pe(Ya),namespace:Pe(Ya),macroName:Pe(Ya),literal:Ga,string:sy,docString:Pe(sy),character:Pe(sy),attributeValue:Pe(sy),number:G1,integer:Pe(G1),float:Pe(G1),bool:Pe(Ga),regexp:Pe(Ga),escape:Pe(Ga),color:Pe(Ga),url:Pe(Ga),keyword:Fs,self:Pe(Fs),null:Pe(Fs),atom:Pe(Fs),unit:Pe(Fs),modifier:Pe(Fs),operatorKeyword:Pe(Fs),controlKeyword:Pe(Fs),definitionKeyword:Pe(Fs),moduleKeyword:Pe(Fs),operator:Bs,derefOperator:Pe(Bs),arithmeticOperator:Pe(Bs),logicOperator:Pe(Bs),bitwiseOperator:Pe(Bs),compareOperator:Pe(Bs),updateOperator:Pe(Bs),definitionOperator:Pe(Bs),typeOperator:Pe(Bs),controlOperator:Pe(Bs),punctuation:HC,separator:Pe(HC),bracket:zd,angleBracket:Pe(zd),squareBracket:Pe(zd),paren:Pe(zd),brace:Pe(zd),content:Vs,heading:ql,heading1:Pe(ql),heading2:Pe(ql),heading3:Pe(ql),heading4:Pe(ql),heading5:Pe(ql),heading6:Pe(ql),contentSeparator:Pe(Vs),list:Pe(Vs),quote:Pe(Vs),emphasis:Pe(Vs),strong:Pe(Vs),link:Pe(Vs),monospace:Pe(Vs),strikethrough:Pe(Vs),inserted:Pe(),deleted:Pe(),changed:Pe(),invalid:Pe(),meta:oy,documentMeta:Pe(oy),annotation:Pe(oy),processingInstruction:Pe(oy),definition:qi.defineModifier("definition"),constant:qi.defineModifier("constant"),function:qi.defineModifier("function"),standard:qi.defineModifier("standard"),local:qi.defineModifier("local"),special:qi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof qi&&(e.name=t)}JV([{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 sme=XV({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),ome=Dx.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:[sme],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 UC=[],e6=[];(()=>{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?e6:UC).push(n=n+t[e])})();function ame(t){if(t<768)return!1;for(let e=0,n=UC.length;;){let r=e+n>>1;if(t<UC[r])n=r;else if(t>=e6[r])e=r+1;else return!0;if(e==n)return!1}}function bD(t){return t>=127462&&t<=127487}const kD=8205;function lme(t,e,n=!0,r=!0){return(n?t6:ume)(t,e,r)}function t6(t,e,n){if(e==t.length)return e;e&&n6(t.charCodeAt(e))&&r6(t.charCodeAt(e-1))&&e--;let r=K1(t,e);for(e+=SD(r);e<t.length;){let i=K1(t,e);if(r==kD||i==kD||n&&ame(i))e+=SD(i),r=i;else if(bD(i)){let s=0,o=e-2;for(;o>=0&&bD(K1(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function ume(t,e,n){for(;e>0;){let r=t6(t,e-2,n);if(r<e)return r;e--}return 0}function K1(t,e){let n=t.charCodeAt(e);if(!r6(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return n6(r)?(n-55296<<10)+(r-56320)+65536:n}function n6(t){return t>=56320&&t<57344}function r6(t){return t>=55296&&t<56320}function SD(t){return t<65536?1:2}let Bt=class i6{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]=rf(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]=rf(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 Sh(this),s=new Sh(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 Sh(this,e)}iterRange(e,n=this.length){return new s6(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 o6(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]?i6.empty:e.length<=32?new Tn(e):qs.from(Tn.split(e,[]))}};class Tn extends Bt{constructor(e,n=cme(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 fme(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Tn(CD(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=Yy(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Tn(a,o.length+s.length));else{let l=a.length>>1;r.push(new Tn(a.slice(0,l)),new Tn(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Tn))return super.replace(e,n,r);[e,n]=rf(this,e,n);let i=Yy(this.text,Yy(r.text,CD(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Tn(i,s):qs.from(Tn.split(i,[]),s)}sliceString(e,n=this.length,r=`
306
306
  `){[e,n]=rf(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 Tn(r,i)),r=[],i=-1);return i>-1&&n.push(new Tn(r,i)),n}}class qs extends Bt{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]=rf(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=`
307
307
  `){[e,n]=rf(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 Tn(m,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],l=0,u=-1,c=[];function f(m){let y;if(m.lines>s&&m instanceof qs)for(let v of m.children)f(v);else m.lines>o&&(l>o||!l)?(p(),a.push(m)):m instanceof Tn&&l&&(y=c[c.length-1])instanceof Tn&&m.lines+y.lines<=32?(l+=m.lines,u+=m.length+1,c[c.length-1]=new Tn(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)f(m);return p(),a.length==1?a[0]:new qs(a,n)}}Bt.empty=new Tn([""],0);function cme(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Yy(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 CD(t,e,n){return Yy(t,[""],e,n)}class Sh{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 Tn?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 Tn?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=`
308
308
  `,this;e--}else if(i instanceof Tn){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 Tn?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 s6{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new Sh(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 o6{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"&&(Bt.prototype[Symbol.iterator]=function(){return this.iter()},Sh.prototype[Symbol.iterator]=s6.prototype[Symbol.iterator]=o6.prototype[Symbol.iterator]=function(){return this});class fme{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 rf(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 lme(t,e,n,r)}function dme(t){return t>=56320&&t<57344}function hme(t){return t>=55296&&t<56320}function ti(t,e){let n=t.charCodeAt(e);if(!hme(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return dme(r)?(n-55296<<10)+(r-56320)+65536:n}function yN(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 qC=/\r\n?|\n/;var Vr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Vr||(Vr={}));class ro{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){YC(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 ro(e)}composeDesc(e){return this.empty?e:e.empty?this:a6(this,e)}mapDesc(e,n=!1){return e.empty?this:GC(this,e,n)}mapPos(e,n=-1,r=Vr.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!=Vr.Simple&&u>=e&&(r==Vr.TrackDel&&i<e&&u>e||r==Vr.TrackBefore&&i<e||r==Vr.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 ro(e)}static create(e){return new ro(e)}}class Yn extends ro{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 YC(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return GC(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(Bt.empty);r.push(o?e.slice(s,s+o):Bt.empty)}s+=o}return new Yn(n,r)}compose(e){return this.empty?e:e.empty?this:a6(this,e,!0)}map(e,n=!1){return e.empty?this:GC(this,e,n,!0)}iterChanges(e,n=!1){YC(this,e,n)}get desc(){return ro.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new Jh(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 f=s.ins==-1?-1:s.off==0?s.ins:0;Cr(n,c,f),f>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 Yn(n,r),filtered:ro.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 f=new Yn(i,s);a=a?a.compose(f.map(a)):f,i=[],s=[],o=0}function u(c){if(Array.isArray(c))for(let f of c)u(f);else if(c instanceof Yn){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:f,to:p=f,insert:m}=c;if(f>p||f<0||p>n)throw new RangeError(`Invalid change range ${f} to ${p} (in doc of length ${n})`);let y=m?typeof m=="string"?Bt.of(m.split(r||qC)):m:Bt.empty,v=y.length;if(f==p&&v==0)return;f<o&&l(),f>o&&Cr(i,f-o,-1),Cr(i,p-f,v),tl(s,i,y),o=p}}return u(e),l(!a),a}static empty(e){return new Yn(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(Bt.empty);r[i]=Bt.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new Yn(n,r)}static createSet(e,n){return new Yn(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(Bt.empty);t.push(n)}}function YC(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,f=Bt.empty;for(;u+=a,c+=l,l&&r&&(f=f.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,f),i=u,s=c}}}function GC(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Jh(t),a=new Jh(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 f=Math.min(c,a.len);u+=f,c-=f,a.forward(f)}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?Yn.createSet(i,s):ro.create(i);throw new Error("Mismatched change set lengths")}}}function a6(t,e,n=!1){let r=[],i=n?[]:null,s=new Jh(t),o=new Jh(e);for(let a=!1;;){if(s.done&&o.done)return i?Yn.createSet(r,i):ro.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 Jh{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?Bt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Bt.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 tu{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 tu(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 tu(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=>tu.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 tu.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?tu.create(n,e,48|s):tu.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 l6(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let xN=0;class ze{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=xN++,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:vN),!!e.static,e.enables)}of(e){return new Gy([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Gy(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Gy(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function vN(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Gy{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=xN++}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 f of this.dependencies)f=="doc"?l=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,p){if(l&&p.docChanged||u&&(p.docChanged||p.selection)||KC(f,c)){let m=r(f);if(a?!ED(m,f.values[o],i):!i(m,f.values[o]))return f.values[o]=m,1}return 0},reconfigure:(f,p)=>{let m,y=p.config.address[s];if(y!=null){let v=Fx(p,y);if(this.dependencies.every(w=>w instanceof ze?p.facet(w)===f.facet(w):w instanceof gr?p.field(w,!1)==f.field(w,!1):!0)||(a?ED(m=r(f),v,i):i(m=r(f),v)))return f.values[o]=v,0}else m=r(f);return f.values[o]=m,1}}}}function ED(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 KC(t,e){let n=!1;for(let r of e)Ch(t,r)&1&&(n=!0);return n}function pme(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 f=Fx(l,r[c]);if(i[c]==2)for(let p of f)u.push(p);else u.push(f)}return e.combine(u)}return{create(l){for(let u of r)Ch(l,u);return l.values[o]=a(l),1},update(l,u){if(!KC(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=KC(l,r),f=u.config.facets[e.id],p=u.facet(e);if(f&&!c&&vN(n,f))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 ay=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(xN++,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(ay).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(ay),o=i.facet(ay),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,ay.of({field:this,create:e})]}get extension(){return this}}const Xl={lowest:4,low:3,default:2,high:1,highest:0};function $d(t){return e=>new u6(e,t)}const Ru={highest:$d(Xl.highest),high:$d(Xl.high),default:$d(Xl.default),low:$d(Xl.low),lowest:$d(Xl.lowest)};class u6{constructor(e,n){this.inner=e,this.prec=n}}class hv{of(e){return new ZC(this,e)}reconfigure(e){return hv.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ZC{constructor(e,n){this.compartment=e,this.inner=n}}class Lx{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 mme(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,vN(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=>pme(w,y,m))}}let f=u.map(p=>p(a));return new Lx(e,o,f,a,l,s)}}function mme(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 ZC&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let u of o)s(u,a);else if(o instanceof ZC){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 u6)s(o.inner,o.prec);else if(o instanceof gr)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Gy)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,Xl.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,Xl.default),r.reduce((o,a)=>o.concat(a))}function Ch(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 Fx(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const c6=ze.define(),XC=ze.define({combine:t=>t.some(e=>e),static:!0}),f6=ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),d6=ze.define(),h6=ze.define(),p6=ze.define(),m6=ze.define({combine:t=>t.length?t[0]:!1});class vo{constructor(e,n){this.type=e,this.value=n}static define(){return new gme}}class gme{of(e){return new vo(this,e)}}class yme{constructor(e){this.map=e}of(e){return new gt(this,e)}}class gt{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 gt(this.type,n)}is(e){return this.type==e}static define(e={}){return new yme(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}}gt.reconfigure=gt.define();gt.appendConfig=gt.define();class Kn{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&&l6(r,n.newLength),s.some(a=>a.type==Kn.time)||(this.annotations=s.concat(Kn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Kn(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(Kn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Kn.time=vo.define();Kn.userEvent=vo.define();Kn.addToHistory=vo.define();Kn.remote=vo.define();function xme(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 g6(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=Yn.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:gt.mapEffects(t.effects,i).concat(gt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function QC(t,e,n){let r=e.selection,i=zc(e.annotations);return e.userEvent&&(i=i.concat(Kn.userEvent.of(e.userEvent))),{changes:e.changes instanceof Yn?e.changes:Yn.of(e.changes||[],n,t.facet(f6)),selection:r&&(r instanceof ye?r:ye.single(r.anchor,r.head)),effects:zc(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function y6(t,e,n){let r=QC(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=g6(r,QC(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=Kn.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return wme(n?vme(i):i)}function vme(t){let e=t.startState,n=!0;for(let i of e.facet(d6)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:xme(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=Yn.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Kn.create(e,i,t.selection&&t.selection.map(s),gt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(h6);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof Kn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Kn?t=s[0]:t=y6(e,zc(s),!1)}return t}function wme(t){let e=t.startState,n=e.facet(p6),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=g6(r,QC(e,s,t.changes.newLength),!0))}return r==t?t:Kn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const bme=[];function zc(t){return t==null?bme:Array.isArray(t)?t:[t]}var hn=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(hn||(hn={}));const kme=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let JC;try{JC=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Sme(t){if(JC)return JC.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||kme.test(n)))return!0}return!1}function Cme(t){return e=>{if(!/\S/.test(e))return hn.Space;if(Sme(e))return hn.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return hn.Word;return hn.Other}}class Tt{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++)Ch(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 Ch(this,r),Fx(this,r)}update(...e){return y6(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(hv.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(gt.reconfigure)?(n=null,r=a.value):a.is(gt.appendConfig)&&(n=null,r=zc(r).concat(a.value));let s;n?s=e.startState.values.slice():(n=Lx.resolve(r,i,this),s=new Tt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,u)=>u.reconfigure(l,this),null).values);let o=e.startState.facet(XC)?e.newSelection:e.newSelection.asSingle();new Tt(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=zc(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 f=i.mapDesc(u,!0);s.push(l.range.map(f)),i=i.compose(c),o=gt.mapEffects(o,c).concat(gt.mapEffects(zc(l.effects),f))}return{changes:i,selection:ye.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof Yn?e:Yn.of(e,this.doc.length,this.facet(Tt.lineSeparator))}toText(e){return Bt.of(e.split(this.facet(Tt.lineSeparator)||qC))}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:(Ch(this,n),Fx(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 Tt.create({doc:e.doc,selection:ye.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Lx.resolve(e.extensions||[],new Map),r=e.doc instanceof Bt?e.doc:Bt.of((e.doc||"").split(n.staticFacet(Tt.lineSeparator)||qC)),i=e.selection?e.selection instanceof ye?e.selection:ye.single(e.selection.anchor,e.selection.head):ye.single(0);return l6(i,r.length),n.staticFacet(XC)||(i=i.asSingle()),new Tt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Tt.tabSize)}get lineBreak(){return this.facet(Tt.lineSeparator)||`